Changeset 3e828ea in mainline for kernel/arch/amd64/src
- Timestamp:
- 2019-09-23T12:49:29Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9be2358
- Parents:
- 9259d20 (diff), 1a4ec93f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Jiri Svoboda <jiri@…> (2019-09-22 12:49:07)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-09-23 12:49:29)
- Location:
- kernel/arch/amd64/src
- Files:
-
- 5 edited
-
amd64.c (modified) (5 diffs)
-
asm.S (modified) (2 diffs)
-
debug/stacktrace.c (modified) (1 diff)
-
interrupt.c (modified) (10 diffs)
-
userspace.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/src/amd64.c
r9259d20 r3e828ea 60 60 #include <arch/vreg.h> 61 61 #include <arch/kseg.h> 62 #include <genarch/pic/pic_ops.h> 62 63 63 64 #ifdef CONFIG_SMP … … 121 122 /* PIC */ 122 123 i8259_init((i8259_t *) I8259_PIC0_BASE, 123 (i8259_t *) I8259_PIC1_BASE, IRQ_PIC1, IVT_IRQBASE, 124 IVT_IRQBASE + 8); 125 126 /* 127 * Set the enable/disable IRQs handlers. 128 * Set the End-of-Interrupt handler. 129 */ 130 enable_irqs_function = pic_enable_irqs; 131 disable_irqs_function = pic_disable_irqs; 132 eoi_function = pic_eoi; 133 irqs_info = "i8259"; 124 (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE); 125 126 /* Set PIC operations. */ 127 pic_ops = &i8259_pic_ops; 134 128 } 135 129 } … … 210 204 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 211 205 i8042_wire(i8042_instance, kbrd); 212 trap_virtual_enable_irqs(1 << IRQ_KBD);213 trap_virtual_enable_irqs(1 << IRQ_MOUSE);206 pic_ops->enable_irqs(1 << IRQ_KBD); 207 pic_ops->enable_irqs(1 << IRQ_MOUSE); 214 208 } 215 209 } … … 236 230 indev_t *srln = srln_wire(srln_instance, sink); 237 231 ns16550_wire(ns16550_instance, srln); 238 trap_virtual_enable_irqs(1 << IRQ_NS16550);232 pic_ops->enable_irqs(1 << IRQ_NS16550); 239 233 } 240 234 #endif … … 247 241 #endif 248 242 249 if (irqs_info != NULL) 250 sysinfo_set_item_val(irqs_info, NULL, true); 243 sysinfo_set_item_val(pic_ops->get_name(), NULL, true); 251 244 } 252 245 -
kernel/arch/amd64/src/asm.S
r9259d20 r3e828ea 398 398 .asciz "Invalid instruction pointer." 399 399 400 /** Print Unicode character to EGA display. 401 * 402 * If CONFIG_EGA is undefined or CONFIG_FB is defined 403 * then this function does nothing. 400 /** Print Unicode character to an early display device. 404 401 * 405 402 * Since the EGA can only display Extended ASCII (usually … … 413 410 */ 414 411 FUNCTION_BEGIN(early_putwchar) 412 413 #if (defined(CONFIG_L4RE_UVMM_EARLY_PRINT)) 414 xorl %eax, %eax /* RAX==0: uvmm's print hypercall */ 415 mov %rdi, %rcx /* RCX: printed character */ 416 vmcall 417 #endif 418 415 419 #if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB))) 416 420 -
kernel/arch/amd64/src/debug/stacktrace.c
r9259d20 r3e828ea 69 69 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 70 70 { 71 return !copy_from_uspace( (void *)prev,72 (uint64_t *) ctx->fp +FRAME_OFFSET_FP_PREV, sizeof(*prev));71 return !copy_from_uspace(prev, 72 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev)); 73 73 } 74 74 75 75 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 76 76 { 77 return !copy_from_uspace( (void *)ra,78 (uint64_t *) ctx->fp +FRAME_OFFSET_RA, sizeof(*ra));77 return !copy_from_uspace(ra, 78 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra)); 79 79 } 80 80 -
kernel/arch/amd64/src/interrupt.c
r9259d20 r3e828ea 38 38 #include <panic.h> 39 39 #include <genarch/drivers/i8259/i8259.h> 40 #include <genarch/pic/pic_ops.h> 40 41 #include <halt.h> 41 42 #include <cpu.h> … … 57 58 * Interrupt and exception dispatching. 58 59 */ 59 60 void (*disable_irqs_function)(uint16_t irqmask) = NULL; 61 void (*enable_irqs_function)(uint16_t irqmask) = NULL; 62 void (*eoi_function)(void) = NULL; 63 const char *irqs_info = NULL; 60 pic_ops_t *pic_ops = NULL; 64 61 65 62 void istate_decode(istate_t *istate) … … 89 86 "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n", 90 87 istate->r12, istate->r13, istate->r14, istate->r15); 91 }92 93 static void trap_virtual_eoi(void)94 {95 if (eoi_function)96 eoi_function();97 else98 panic("No eoi_function.");99 100 88 } 101 89 … … 157 145 static void tlb_shootdown_ipi(unsigned int n, istate_t *istate) 158 146 { 159 trap_virtual_eoi();147 pic_ops->eoi(0); 160 148 tlb_shootdown_ipi_recv(); 161 149 } … … 172 160 bool ack = false; 173 161 assert(inum < IRQ_COUNT); 174 assert( (inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));162 assert(inum != IRQ_PIC1); 175 163 176 164 irq_t *irq = irq_dispatch_and_lock(inum); … … 182 170 if (irq->preack) { 183 171 /* Send EOI before processing the interrupt */ 184 trap_virtual_eoi();172 pic_ops->eoi(inum); 185 173 ack = true; 186 174 } … … 188 176 irq_spinlock_unlock(&irq->lock, false); 189 177 } else { 190 /*191 * Spurious interrupt.192 */193 178 #ifdef CONFIG_DEBUG 194 log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious interrupt (inum=%u)",195 CPU->id,inum);179 log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ %u", CPU->id, 180 inum); 196 181 #endif 197 182 } 198 183 199 184 if (!ack) 200 trap_virtual_eoi(); 185 pic_ops->eoi(inum); 186 } 187 188 static void pic_spurious(unsigned int n, istate_t *istate) 189 { 190 unsigned int inum = n - IVT_IRQBASE; 191 if (!pic_ops->is_spurious(inum)) { 192 /* This is actually not a spurious IRQ, so proceed as usual. */ 193 irq_interrupt(n, istate); 194 return; 195 } 196 pic_ops->handle_spurious(n); 197 #ifdef CONFIG_DEBUG 198 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id, 199 inum); 200 #endif 201 201 } 202 202 … … 209 209 210 210 for (i = 0; i < IRQ_COUNT; i++) { 211 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1)) 211 if ((i != IRQ_PIC0_SPUR) && (i != IRQ_PIC1_SPUR) && 212 (i != IRQ_PIC1)) 212 213 exc_register(IVT_IRQBASE + i, "irq", true, 213 214 (iroutine_t) irq_interrupt); … … 218 219 exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault); 219 220 exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault); 221 exc_register(VECTOR_PIC0_SPUR, "pic0_spurious", true, 222 (iroutine_t) pic_spurious); 223 exc_register(VECTOR_PIC1_SPUR, "pic1_spurious", true, 224 (iroutine_t) pic_spurious); 220 225 221 226 #ifdef CONFIG_SMP … … 225 230 } 226 231 227 void trap_virtual_enable_irqs(uint16_t irqmask)228 {229 if (enable_irqs_function)230 enable_irqs_function(irqmask);231 else232 panic("No enable_irqs_function.");233 }234 235 void trap_virtual_disable_irqs(uint16_t irqmask)236 {237 if (disable_irqs_function)238 disable_irqs_function(irqmask);239 else240 panic("No disable_irqs_function.");241 }242 243 232 /** @} 244 233 */ -
kernel/arch/amd64/src/userspace.c
r9259d20 r3e828ea 66 66 "iretq\n" 67 67 :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 68 [stack_top] "r" ( (uint8_t *)kernel_uarg->uspace_stack +68 [stack_top] "r" (kernel_uarg->uspace_stack + 69 69 kernel_uarg->uspace_stack_size), 70 70 [rflags] "r" (rflags),
Note:
See TracChangeset
for help on using the changeset viewer.
