Changeset 89 for trunk/hal/x86_64/core/hal_apic.c
- Timestamp:
- Jun 29, 2017, 9:54:01 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_apic.c
r86 r89 50 50 out8(PIC1_DATA, 0xff); 51 51 out8(PIC2_DATA, 0xff); 52 } 53 54 /* -------------------------------------------------------------------------- */ 55 56 paddr_t ioapic_pa __in_kdata = 0; 57 vaddr_t ioapic_va __in_kdata = 0; 58 59 #define IRQ_TIMER 0x00 60 #define IRQ_KEYBOARD 0x01 61 #define IRQ_COM2 0x03 62 #define IRQ_COM1 0x04 63 #define IRQ_FLOPPY 0x06 64 #define IRQ_ATA0 0x0e 65 #define IRQ_ATA1 0x0f 66 67 #define IOREGSEL 0x00 68 #define IOWIN 0x10 69 70 #define IOAPICID 0x00 71 #define IOAPICVER 0x01 72 #define IOAPICARB 0x02 73 #define IOREDTBL 0x10 74 75 #define IOENTRY_DISABLE 0x10000 76 77 void hal_ioapic_write(uint8_t reg, uint32_t val) 78 { 79 *((volatile uint32_t *)((uint8_t *)ioapic_va + IOREGSEL)) = reg; 80 *((volatile uint32_t *)((uint8_t *)ioapic_va + IOWIN)) = val; 81 } 82 83 uint32_t hal_ioapic_read(uint8_t reg) 84 { 85 *((volatile uint32_t *)((uint8_t *)ioapic_va + IOREGSEL)) = reg; 86 return *((volatile uint32_t *)((uint8_t *)ioapic_va + IOWIN)); 87 } 88 89 void hal_ioapic_set_entry(uint8_t index, uint64_t data) 90 { 91 hal_ioapic_write(IOREDTBL + index * 2, (uint32_t)(data & 0xFFFFFFFF)); 92 hal_ioapic_write(IOREDTBL + index * 2 + 1, (uint32_t)(data >> 32)); 93 } 94 95 static void hal_ioapic_init() 96 { 97 size_t i, pins; 98 uint32_t ver; 99 100 ioapic_va = hal_gpt_bootstrap_valloc(1); // XXX: should be shared 101 102 hal_gpt_enter(ioapic_va, ioapic_pa, PG_V|PG_KW|PG_NX|PG_N); 103 104 ver = hal_ioapic_read(IOAPICVER); 105 pins = ((ver >> 16) & 0xFF) + 1; 106 107 /* Explicitly disable (mask) each vector */ 108 for (i = 0; i < pins; i++) { 109 hal_ioapic_set_entry(i, IOENTRY_DISABLE); 110 } 111 112 /* Now, enable the keyboard */ 113 hal_ioapic_set_entry(IRQ_KEYBOARD, IOAPIC_KEYBOARD_VECTOR); 52 114 } 53 115 … … 122 184 /* Enable the LAPIC */ 123 185 hal_lapic_init(); 186 187 /* Enable the IOAPIC */ 188 hal_ioapic_init(); 124 189 } 125 190
Note: See TracChangeset
for help on using the changeset viewer.