- Timestamp:
- Jun 29, 2017, 9:54:01 AM (7 years ago)
- Location:
- trunk/hal/x86_64
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_acpi.c
r51 r89 109 109 /* -------------------------------------------------------------------------- */ 110 110 111 static void hal_acpi_parse_ioapic(madt_ioapic_t *ioapic) 112 { 113 extern paddr_t ioapic_pa; 114 ioapic_pa = ioapic->Address; 115 x86_printf("-> IOAPIC address: %Z\n", ioapic_pa); 116 } 117 111 118 static void hal_acpi_parse_madt(madt_t *madt) 112 119 { 120 void *ptr, *end; 121 subheader_t *sub; 122 113 123 extern paddr_t lapic_pa; 114 124 lapic_pa = (paddr_t)madt->Address; 125 126 ptr = (void *)(madt + 1); 127 end = (void *)madt + madt->Header.Length; 128 129 while (ptr < end) { 130 sub = (subheader_t *)ptr; 131 if (sub->Type == ACPI_MADT_TYPE_IO_APIC) { 132 hal_acpi_parse_ioapic((madt_ioapic_t *)sub); 133 } 134 // XXX: handle lapic override 135 ptr += sub->Length; 136 } 137 115 138 x86_printf("-> LAPIC address: %Z\n", lapic_pa); 116 139 } -
trunk/hal/x86_64/core/hal_acpi.h
r51 r89 179 179 uint64_t Address; /* APIC physical address */ 180 180 } __packed; 181 typedef struct acpi_madt_local_apic_override madt_lapic_override ;181 typedef struct acpi_madt_local_apic_override madt_lapic_override_t; 182 182 183 struct acpi_madt_io_apic { 184 subheader_t Header; 185 uint8_t Id; /* I/O APIC ID */ 186 uint8_t Reserved; /* Reserved - must be zero */ 187 uint32_t Address; /* APIC physical address */ 188 uint32_t GlobalIrqBase; /* Global system interrupt where INTI lines start */ 189 } __packed; 190 typedef struct acpi_madt_io_apic madt_ioapic_t; 191 -
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 -
trunk/hal/x86_64/core/hal_apic.h
r86 r89 27 27 #define LAPIC_SPURIOUS_VECTOR LAPICVEC_MIN 28 28 #define LAPIC_TIMER_VECTOR (LAPICVEC_MIN + 1) 29 #define IOAPIC_KEYBOARD_VECTOR (LAPICVEC_MIN + 2) 29 30 30 31 #define LAPIC_ID 0x020 /* ID. RW */ -
trunk/hal/x86_64/core/hal_kentry.S
r86 r89 36 36 .globl hal_trap_entry 37 37 .globl hal_timer_intr 38 .globl hal_keyboard_intr 38 39 .type hal_trap_entry, @function 39 40 .type hal_timer_intr, @function 41 .type hal_keyboard_intr, @function 40 42 41 43 /* … … 119 121 120 122 /* 121 * LAPIC interrupts.123 * APIC interrupts. 122 124 */ 123 125 ASM_ENTRY(x86_lapic_spurious) … … 131 133 movq %rsp,%rdi 132 134 call hal_timer_intr 135 136 movq lapic_va(%rip),%rax 137 movl $0,LAPIC_EOI(%rax) 138 139 INTR_RESTORE_REGS 140 addq $16,%rsp 141 iretq 142 143 ASM_ENTRY(x86_ioapic_keyboard) 144 pushq $0 145 pushq $T_ASTFLT 146 INTR_SAVE_REGS 147 148 movq %rsp,%rdi 149 call hal_keyboard_intr 133 150 134 151 movq lapic_va(%rip),%rax … … 182 199 .quad x86_lapic_spurious 183 200 .quad x86_lapic_timer 184 201 .quad x86_ioapic_keyboard 202 -
trunk/hal/x86_64/core/hal_segmentation.h
r80 r89 194 194 #define CPUVEC_MAX 32 /* reserved entries for CPU exceptions */ 195 195 #define LAPICVEC_MIN CPUVEC_MAX 196 #define LAPICVEC_MAX (LAPICVEC_MIN + 2)196 #define LAPICVEC_MAX (LAPICVEC_MIN + 3) 197 197 198 198 #define NIDT 256 /* total number of IDT entries */ -
trunk/hal/x86_64/core/hal_trap.c
r86 r89 82 82 } 83 83 84 /* 85 * Keyboard interrupt 86 */ 87 void hal_keyboard_intr(struct trapframe *tf) 88 { 89 x86_printf("-> got keyboard: rip=%Z\n", tf->tf_rip); 90 return; 91 } 92 -
trunk/hal/x86_64/drivers/soclib_tty.c
r76 r89 36 36 void __attribute__ ((noinline)) soclib_tty_cmd( xptr_t th_xp ) 37 37 { 38 38 // Pour le write: tout en sync, ça part direct sur le VGA/série 39 // Pour le read: là on attend l'ISR 39 40 } 40 41 41 42 void __attribute__ ((noinline)) soclib_tty_isr( chdev_t * chdev ) 42 43 { 43 44 // Cette ISR est juste utile pour le clavier; on arrive ici quand une touche 45 // est pressée 44 46 } 45 47
Note: See TracChangeset
for help on using the changeset viewer.