Changeset 203 for trunk/hal/x86_64/drivers/pic_apic.c
- Timestamp:
- Jul 13, 2017, 3:24:38 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/drivers/pic_apic.c
r197 r203 27 27 #include <vfs.h> 28 28 29 void pic_apic_init( chdev_t * pic ) 29 #include <hal_internal.h> 30 #include <hal_segmentation.h> 31 #include <hal_apic.h> 32 33 extern iopic_input_t iopic_input; 34 35 static void 36 idt_set_seg(struct idt_seg *seg, void *func, int ist, int type, int dpl, int sel) 30 37 { 31 x86_panic((char *)__func__); 38 seg->gd_looffset = (uint64_t)func & 0xffff; 39 seg->gd_selector = sel; 40 seg->gd_ist = ist; 41 seg->gd_type = type; 42 seg->gd_dpl = dpl; 43 seg->gd_p = 1; 44 seg->gd_hioffset = (uint64_t)func >> 16; 45 seg->gd_zero = 0; 46 seg->gd_xx1 = 0; 47 seg->gd_xx2 = 0; 48 seg->gd_xx3 = 0; 49 } 50 51 /* -------------------------------------------------------------------------- */ 52 53 extern uint8_t *idtstore; 54 55 void pic_apic_init(chdev_t *pic) 56 { 57 /* XXX APIC already initialized earlier */ 32 58 } 33 59 … … 37 63 } 38 64 39 void pic_apic_bind_irq( lid_t lid, 40 chdev_t * src_chdev ) 65 void pic_apic_bind_irq(lid_t lid, chdev_t *src_chdev) 41 66 { 42 x86_panic((char *)__func__); 67 struct idt_seg seg, *idt; 68 void *isr; 69 int slot; 70 71 /* get the source chdev functional type, channel, and direction */ 72 uint32_t func = src_chdev->func; 73 uint32_t channel = src_chdev->channel; 74 75 /* get external IRQ index */ 76 uint32_t irq_id; 77 if (func == DEV_FUNC_IOC) 78 irq_id = iopic_input.ioc[channel]; 79 else if (func == DEV_FUNC_TXT) 80 irq_id = iopic_input.txt[channel]; 81 else 82 assert(false, __FUNCTION__, "unsupported device\n"); 83 84 /* get the ISR pointer */ 85 isr = src_chdev->isr; 86 87 /* create the IDT entry, and register it */ 88 idt_set_seg(&seg, isr, 0, SDT_SYS386IGT, SEL_KPL, 89 GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL)); 90 slot = idt_slot_alloc(); 91 idt = (struct idt_seg *)&idtstore; 92 memcpy(&idt[slot], &seg, sizeof(struct idt_seg)); 93 94 /* Bind the IRQ line in IOAPIC */ 95 hal_ioapic_bind_irq(irq_id, slot, lid); 96 97 x86_printf("-> allocated %z\n", (uint64_t)slot); 43 98 } 44 99 … … 46 101 chdev_t * src_chdev ) 47 102 { 48 x86_panic((char *)__func__); 103 uint32_t func = src_chdev->func; 104 uint32_t channel = src_chdev->channel; 105 uint32_t irq_id; 106 107 /* get external IRQ index */ 108 if (func == DEV_FUNC_IOC) 109 irq_id = iopic_input.ioc[channel]; 110 else if (func == DEV_FUNC_TXT) 111 irq_id = iopic_input.txt[channel]; 112 else 113 assert(false, __FUNCTION__, "unsupported device\n"); 114 115 /* enable the line */ 116 hal_ioapic_enable_irq(irq_id); 49 117 } 50 118 … … 53 121 { 54 122 x86_panic((char *)__func__); 123 124 uint32_t func = src_chdev->func; 125 uint32_t channel = src_chdev->channel; 126 uint32_t irq_id; 127 128 /* get external IRQ index */ 129 if (func == DEV_FUNC_IOC) 130 irq_id = iopic_input.ioc[channel]; 131 else if (func == DEV_FUNC_TXT) 132 irq_id = iopic_input.txt[channel]; 133 else 134 assert(false, __FUNCTION__, "unsupported device\n"); 135 136 /* disable the line */ 137 hal_ioapic_disable_irq(irq_id); 55 138 } 56 139
Note: See TracChangeset
for help on using the changeset viewer.