Changeset 203 for trunk/hal/x86_64/core
- Timestamp:
- Jul 13, 2017, 3:24:38 PM (7 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_apic.c
r202 r203 268 268 } 269 269 270 void hal_ioapic_disable_entry(uint8_t index) 271 { 272 const uint64_t data = IOREDTBL_MSK; 273 274 hal_ioapic_write(IOREDTBL + index * 2, (uint32_t)(data & 0xFFFFFFFF)); 275 hal_ioapic_write(IOREDTBL + index * 2 + 1, (uint32_t)(data >> 32)); 276 } 277 278 void hal_ioapic_set_entry(uint8_t index, uint8_t vec, uint8_t dest) 270 void hal_ioapic_bind_irq(uint8_t irq, uint8_t vec, uint8_t dest) 279 271 { 280 272 const uint64_t data = ((uint64_t)dest << IOREDTBL_DES_SHIFT) | 281 IOREDTBL_DEM_PHYS | IOREDTBL_DEL_FIXED | vec; 282 283 hal_ioapic_write(IOREDTBL + index * 2, (uint32_t)(data & 0xFFFFFFFF)); 284 hal_ioapic_write(IOREDTBL + index * 2 + 1, (uint32_t)(data >> 32)); 273 IOREDTBL_DEM_PHYS | IOREDTBL_DEL_FIXED | IOREDTBL_MSK | vec; 274 275 hal_ioapic_write(IOREDTBL + irq * 2, (uint32_t)(data & 0xFFFFFFFF)); 276 hal_ioapic_write(IOREDTBL + irq * 2 + 1, (uint32_t)(data >> 32)); 277 } 278 279 void hal_ioapic_enable_irq(uint8_t irq) 280 { 281 uint32_t data[2]; 282 283 data[0] = hal_ioapic_read(IOREDTBL + irq * 2); 284 data[1] = hal_ioapic_read(IOREDTBL + irq * 2 + 1); 285 286 data[0] &= ~IOREDTBL_MSK; 287 288 hal_ioapic_write(IOREDTBL + irq * 2, data[0]); 289 hal_ioapic_write(IOREDTBL + irq * 2 + 1, data[1]); 290 } 291 292 void hal_ioapic_disable_irq(uint8_t irq) 293 { 294 uint32_t data[2]; 295 296 data[0] = hal_ioapic_read(IOREDTBL + irq * 2); 297 data[1] = hal_ioapic_read(IOREDTBL + irq * 2 + 1); 298 299 data[0] |= IOREDTBL_MSK; 300 301 hal_ioapic_write(IOREDTBL + irq * 2, data[0]); 302 hal_ioapic_write(IOREDTBL + irq * 2 + 1, data[1]); 285 303 } 286 304 … … 295 313 /* Explicitly disable (mask) each vector */ 296 314 for (i = 0; i < ioapic_pins; i++) { 297 hal_ioapic_disable_ entry(i);315 hal_ioapic_disable_irq(i); 298 316 } 299 317 … … 301 319 302 320 /* Now, enable the com1 port and the keyboard */ 303 hal_ioapic_set_entry(IRQ_COM1, IOAPIC_COM1_VECTOR, 0); 304 hal_ioapic_set_entry(IRQ_KEYBOARD, IOAPIC_KEYBOARD_VECTOR, 0); 321 hal_ioapic_bind_irq(IRQ_COM1, IOAPIC_COM1_VECTOR, 0); 322 hal_ioapic_enable_irq(IRQ_COM1); 323 hal_ioapic_bind_irq(IRQ_KEYBOARD, IOAPIC_KEYBOARD_VECTOR, 0); 324 hal_ioapic_enable_irq(IRQ_KEYBOARD); 305 325 } 306 326 -
trunk/hal/x86_64/core/hal_apic.h
r202 r203 25 25 void hal_com_init_early(); 26 26 27 void hal_ioapic_disable_entry(uint8_t index); 28 void hal_ioapic_set_entry(uint8_t index, uint8_t vec, uint8_t dest); 27 void hal_ioapic_bind_irq(uint8_t irq, uint8_t vec, uint8_t dest); 28 void hal_ioapic_enable_irq(uint8_t irq); 29 void hal_ioapic_disable_irq(uint8_t irq); 30 31 void hal_ioapic_disable_entry(uint8_t irq); 32 void hal_ioapic_set_entry(uint8_t irq, uint8_t vec, uint8_t dest); 29 33 30 34 uint32_t hal_lapic_gid(); -
trunk/hal/x86_64/core/hal_init.c
r202 r203 419 419 /* -------------------------------------------------------------------------- */ 420 420 421 struct { 422 bool_t busy[256]; 423 } idt_bitmap __in_kdata; 424 425 int idt_slot_alloc() 426 { 427 size_t i; 428 429 for (i = 0; i < 256; i++) { 430 if (!idt_bitmap.busy[i]) 431 break; 432 } 433 if (i == 256) { 434 return -1; 435 } 436 437 idt_bitmap.busy[i] = true; 438 return (int)i; 439 } 440 441 void idt_slot_free(int slot) 442 { 443 idt_bitmap.busy[slot] = false; 444 } 445 421 446 static void 422 447 idt_set_seg(struct idt_seg *seg, void *func, int ist, int type, int dpl, int sel) … … 441 466 size_t i; 442 467 468 memset(&idt_bitmap, 0, sizeof(idt_bitmap)); 443 469 idt = (struct idt_seg *)&idtstore; 444 470 … … 453 479 idt_set_seg(&idt[i], (void *)x86_traps[i - CPUVEC_MIN], 0, 454 480 SDT_SYS386IGT, SEL_KPL, GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 481 idt_bitmap.busy[i] = true; 455 482 } 456 483 … … 459 486 idt_set_seg(&idt[i], (void *)x86_intrs[i - DYNVEC_MIN], 0, 460 487 SDT_SYS386IGT, SEL_KPL, GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 488 idt_bitmap.busy[i] = true; 461 489 } 462 490 } -
trunk/hal/x86_64/core/hal_internal.h
r195 r203 30 30 x86_panic((char *)__func__); \ 31 31 } 32 33 /* hal_init.c */ 34 int idt_slot_alloc(); 35 void idt_slot_free(int slot); 32 36 33 37 /* hal_cpu.S */ -
trunk/hal/x86_64/core/hal_kentry.S
r152 r203 172 172 addq $16,%rsp 173 173 iretq 174 175 /*176 * The XCU interrupt entries.177 */178 179 #define XCU_WTI_ENTRY(n) \180 ASM_ENTRY(x86_xcu_wti_ ## n) \181 pushq $0 ; \182 pushq $T_ASTFLT ; \183 INTR_SAVE_REGS ; \184 ; \185 call hal_do_interrupt; \186 ; \187 INTR_RESTORE_REGS ; \188 addq $16,%rsp ; \189 iretq190 191 #define XCU_HWI_ENTRY(n) \192 ASM_ENTRY(x86_xcu_hwi_ ## n) \193 pushq $0 ; \194 pushq $T_ASTFLT ; \195 INTR_SAVE_REGS ; \196 ; \197 call hal_do_interrupt; \198 ; \199 INTR_RESTORE_REGS ; \200 addq $16,%rsp ; \201 iretq202 203 #define XCU_PTI_ENTRY(n) \204 ASM_ENTRY(x86_xcu_pti_ ## n) \205 pushq $0 ; \206 pushq $T_ASTFLT ; \207 INTR_SAVE_REGS ; \208 ; \209 call hal_do_interrupt; \210 ; \211 INTR_RESTORE_REGS ; \212 addq $16,%rsp ; \213 iretq214 215 XCU_WTI_ENTRY(0)216 XCU_HWI_ENTRY(0)217 XCU_PTI_ENTRY(0)218 174 219 175 /* … … 259 215 x86_intrs: 260 216 .quad x86_lapic_spurious 261 .quad x86_xcu_wti_0262 .quad x86_xcu_hwi_0263 .quad x86_xcu_pti_0264 265 217 .quad x86_lapic_timer 266 218 .quad x86_ioapic_com1 -
trunk/hal/x86_64/core/hal_segmentation.h
r167 r203 205 205 #define CPUVEC_MAX 32 /* reserved entries for CPU exceptions */ 206 206 207 #define DYNVEC_MIN CPUVEC_MAX208 #define DYNVEC_MAX ( DYNVEC_MIN + 7)207 #define DYNVEC_MIN (CPUVEC_MAX + 0) 208 #define DYNVEC_MAX (CPUVEC_MAX + 4) 209 209 210 210 #define VECTOR_APIC_SPURIOU (DYNVEC_MIN + 0) 211 #define VECTOR_APIC_XCU_WTI (DYNVEC_MIN + 1)212 #define VECTOR_APIC_XCU_HWI (DYNVEC_MIN + 2)213 #define VECTOR_APIC_XCU_PTI (DYNVEC_MIN + 3)214 211 215 212 /* debug only, will be moved soon */ 216 #define LAPIC_TIMER_VECTOR (DYNVEC_MIN + 4)217 #define IOAPIC_COM1_VECTOR (DYNVEC_MIN + 5)218 #define IOAPIC_KEYBOARD_VECTOR (DYNVEC_MIN + 6)213 #define LAPIC_TIMER_VECTOR (DYNVEC_MIN + 1) 214 #define IOAPIC_COM1_VECTOR (DYNVEC_MIN + 2) 215 #define IOAPIC_KEYBOARD_VECTOR (DYNVEC_MIN + 3) 219 216 220 217 #define NIDT 256 /* total number of IDT entries */ 221 218 222
Note: See TracChangeset
for help on using the changeset viewer.