Changeset 3e828ea in mainline for kernel/arch
- Timestamp:
- 2019-09-23T12:49:29Z (7 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
- Files:
-
- 55 added
- 6 deleted
- 58 edited
- 7 moved
-
abs32le/include/arch/mm/as.h (modified) (1 diff)
-
abs32le/meson.build (added)
-
abs32le/src/abs32le.c (modified) (1 diff)
-
amd64/Makefile.inc (deleted)
-
amd64/include/arch/interrupt.h (modified) (2 diffs)
-
amd64/include/arch/mm/as.h (modified) (1 diff)
-
amd64/include/arch/mm/page.h (modified) (2 diffs)
-
amd64/meson.build (added)
-
amd64/src/amd64.c (modified) (5 diffs)
-
amd64/src/asm.S (modified) (2 diffs)
-
amd64/src/debug/stacktrace.c (modified) (1 diff)
-
amd64/src/interrupt.c (modified) (10 diffs)
-
amd64/src/userspace.c (modified) (1 diff)
-
arm32/Makefile.inc (deleted)
-
arm32/include/arch/mm/as.h (modified) (1 diff)
-
arm32/meson.build (added)
-
arm32/src/debug/stacktrace.c (modified) (1 diff)
-
arm32/src/userspace.c (modified) (2 diffs)
-
arm64/_link.ld.in (added)
-
arm64/include/arch/arch.h (added)
-
arm64/include/arch/asm.h (added)
-
arm64/include/arch/barrier.h (added)
-
arm64/include/arch/boot/boot.h (added)
-
arm64/include/arch/context.h (added)
-
arm64/include/arch/context_struct.h (moved) (moved from uspace/lib/cpp/include/__bits/result_of.hpp ) (2 diffs)
-
arm64/include/arch/cpu.h (added)
-
arm64/include/arch/cycle.h (added)
-
arm64/include/arch/exception.h (added)
-
arm64/include/arch/faddr.h (added)
-
arm64/include/arch/fpu_context.h (added)
-
arm64/include/arch/fpu_context_struct.h (added)
-
arm64/include/arch/interrupt.h (added)
-
arm64/include/arch/istate.h (added)
-
arm64/include/arch/istate_struct.h (added)
-
arm64/include/arch/mach/virt/virt.h (added)
-
arm64/include/arch/machine_func.h (added)
-
arm64/include/arch/mm/as.h (added)
-
arm64/include/arch/mm/asid.h (added)
-
arm64/include/arch/mm/frame.h (added)
-
arm64/include/arch/mm/km.h (added)
-
arm64/include/arch/mm/page.h (added)
-
arm64/include/arch/mm/tlb.h (added)
-
arm64/include/arch/proc/task.h (added)
-
arm64/include/arch/proc/thread.h (added)
-
arm64/include/arch/regutils.h (added)
-
arm64/include/arch/stack.h (added)
-
arm64/include/arch/types.h (moved) (moved from uspace/lib/draw/cursor/embedded.h ) (2 diffs)
-
arm64/meson.build (added)
-
arm64/src/arm64.c (added)
-
arm64/src/asm.S (added)
-
arm64/src/context.S (added)
-
arm64/src/cpu/cpu.c (added)
-
arm64/src/debug/stacktrace.c (added)
-
arm64/src/debug/stacktrace_asm.S (added)
-
arm64/src/exception.c (added)
-
arm64/src/fpu.S (added)
-
arm64/src/fpu_context.c (added)
-
arm64/src/interrupt.c (added)
-
arm64/src/mach/virt/virt.c (added)
-
arm64/src/machine_func.c (added)
-
arm64/src/mm/as.c (added)
-
arm64/src/mm/frame.c (added)
-
arm64/src/mm/km.c (added)
-
arm64/src/mm/page.c (added)
-
arm64/src/mm/tlb.c (added)
-
arm64/src/smc.c (added)
-
arm64/src/smp/ipi.c (added)
-
arm64/src/smp/smp.c (added)
-
arm64/src/start.S (added)
-
ia32/Makefile.inc (deleted)
-
ia32/include/arch/interrupt.h (modified) (2 diffs)
-
ia32/include/arch/mm/as.h (modified) (1 diff)
-
ia32/include/arch/mm/page.h (modified) (2 diffs)
-
ia32/include/arch/smp/apic.h (modified) (3 diffs)
-
ia32/meson.build (added)
-
ia32/src/debug/stacktrace.c (modified) (1 diff)
-
ia32/src/drivers/i8254.c (modified) (2 diffs)
-
ia32/src/ia32.c (modified) (5 diffs)
-
ia32/src/interrupt.c (modified) (10 diffs)
-
ia32/src/smp/apic.c (modified) (6 diffs)
-
ia32/src/smp/smp.c (modified) (1 diff)
-
ia32/src/userspace.c (modified) (1 diff)
-
ia64/include/arch/interrupt.h (modified) (1 diff)
-
ia64/include/arch/istate.h (modified) (1 diff)
-
ia64/include/arch/mm/as.h (modified) (1 diff)
-
ia64/include/arch/mm/page.h (modified) (2 diffs)
-
ia64/include/arch/register.h (modified) (1 diff)
-
ia64/meson.build (added)
-
ia64/src/ia64.c (modified) (1 diff)
-
ia64/src/interrupt.c (modified) (1 diff)
-
ia64/src/mm/tlb.c (modified) (8 diffs)
-
mips32/include/arch/arch.h (modified) (2 diffs)
-
mips32/include/arch/exception.h (modified) (1 diff)
-
mips32/include/arch/mach/malta/malta.h (modified) (2 diffs)
-
mips32/include/arch/machine_func.h (modified) (1 diff)
-
mips32/include/arch/mm/as.h (modified) (1 diff)
-
mips32/meson.build (moved) (moved from uspace/srv/loader/Makefile ) (2 diffs)
-
mips32/src/exception.c (modified) (3 diffs)
-
mips32/src/interrupt.c (modified) (5 diffs)
-
mips32/src/mach/malta/malta.c (modified) (4 diffs)
-
mips32/src/mach/msim/msim.c (modified) (2 diffs)
-
mips32/src/mips32.c (modified) (3 diffs)
-
ppc32/Makefile.inc (deleted)
-
ppc32/include/arch/mm/as.h (modified) (1 diff)
-
ppc32/include/arch/mm/page.h (modified) (2 diffs)
-
ppc32/meson.build (moved) (moved from uspace/lib/c/arch/amd64/Makefile.common ) (1 diff)
-
ppc32/src/debug/stacktrace.c (modified) (1 diff)
-
ppc32/src/drivers/pic.c (modified) (4 diffs)
-
ppc32/src/interrupt.c (modified) (1 diff)
-
ppc32/src/ppc32.c (modified) (1 diff)
-
riscv64/Makefile.inc (deleted)
-
riscv64/_link.ld.in (modified) (1 diff)
-
riscv64/include/arch/mm/as.h (modified) (1 diff)
-
riscv64/meson.build (moved) (moved from boot/arch/riscv64/Makefile.inc ) (1 diff)
-
riscv64/src/riscv64.c (modified) (1 diff)
-
sparc64/Makefile.inc (deleted)
-
sparc64/include/arch/drivers/tty.h (moved) (moved from uspace/lib/draw/font/pcf.h ) (2 diffs)
-
sparc64/include/arch/mm/sun4u/as.h (modified) (1 diff)
-
sparc64/include/arch/mm/sun4v/as.h (modified) (1 diff)
-
sparc64/meson.build (moved) (moved from kernel/arch/mips32/Makefile.inc ) (1 diff)
-
sparc64/src/console.c (modified) (2 diffs)
-
sparc64/src/drivers/kbd.c (modified) (3 diffs)
-
sparc64/src/drivers/tty.c (added)
-
sparc64/src/mm/sun4u/tlb.c (modified) (1 diff)
-
sparc64/src/sun4u/sparc64.c (modified) (1 diff)
-
sparc64/src/sun4v/sparc64.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/arch/mm/as.h
r9259d20 r3e828ea 37 37 38 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 #define KERNEL_SEPARATE_PTL0_ARCH 0 39 40 40 41 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) -
kernel/arch/abs32le/src/abs32le.c
r9259d20 r3e828ea 126 126 } 127 127 128 uintptr_t memcpy_from_uspace(void *dst, const void *uspace_src, size_t size)128 uintptr_t memcpy_from_uspace(void *dst, uspace_addr_t uspace_src, size_t size) 129 129 { 130 130 return 0; 131 131 } 132 132 133 uintptr_t memcpy_to_uspace( void *uspace_dst, const void *src, size_t size)133 uintptr_t memcpy_to_uspace(uspace_addr_t uspace_dst, const void *src, size_t size) 134 134 { 135 135 return 0; -
kernel/arch/amd64/include/arch/interrupt.h
r9259d20 r3e828ea 61 61 /* NS16550 at COM1 */ 62 62 #define IRQ_NS16550 4 63 #define IRQ_PIC _SPUR763 #define IRQ_PIC0_SPUR 7 64 64 #define IRQ_MOUSE 12 65 #define IRQ_PIC1_SPUR 15 65 66 66 67 /* This one must have four least significant bits set to ones */ … … 77 78 #define VECTOR_PF (IVT_EXCBASE + EXC_PF) 78 79 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 79 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) 80 #define VECTOR_PIC0_SPUR (IVT_IRQBASE + IRQ_PIC0_SPUR) 81 #define VECTOR_PIC1_SPUR (IVT_IRQBASE + IRQ_PIC1_SPUR) 80 82 #define VECTOR_SYSCALL IVT_FREEBASE 81 83 #define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE + 1) 82 84 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 83 85 84 extern void (*disable_irqs_function)(uint16_t);85 extern void (*enable_irqs_function)(uint16_t);86 extern void (*eoi_function)(void);87 extern const char *irqs_info;88 89 86 extern void interrupt_init(void); 90 extern void trap_virtual_enable_irqs(uint16_t);91 extern void trap_virtual_disable_irqs(uint16_t);92 87 93 88 #endif -
kernel/arch/amd64/include/arch/mm/as.h
r9259d20 r3e828ea 40 40 41 41 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 42 #define KERNEL_SEPARATE_PTL0_ARCH 0 42 43 43 44 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT64_C(0xffff800000000000) -
kernel/arch/amd64/include/arch/mm/page.h
r9259d20 r3e828ea 37 37 38 38 #include <arch/mm/frame.h> 39 #include <trace.h>40 39 41 40 #define PAGE_WIDTH FRAME_WIDTH … … 164 163 #ifndef __ASSEMBLER__ 165 164 165 #include <arch/interrupt.h> 166 166 #include <mm/mm.h> 167 #include < arch/interrupt.h>167 #include <trace.h> 168 168 #include <typedefs.h> 169 169 -
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), -
kernel/arch/arm32/include/arch/mm/as.h
r9259d20 r3e828ea 38 38 39 39 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 40 #define KERNEL_SEPARATE_PTL0_ARCH 0 40 41 41 42 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) -
kernel/arch/arm32/src/debug/stacktrace.c
r9259d20 r3e828ea 68 68 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 69 69 { 70 return !copy_from_uspace( (void *)prev,71 (uint32_t *) ctx->fp +FRAME_OFFSET_FP_PREV, sizeof(*prev));70 return !copy_from_uspace(prev, 71 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev)); 72 72 } 73 73 74 74 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 75 75 { 76 return !copy_from_uspace( (void *)ra,77 (uint32_t *) ctx->fp +FRAME_OFFSET_RA, sizeof(*ra));76 return !copy_from_uspace(ra, 77 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra)); 78 78 } 79 79 -
kernel/arch/arm32/src/userspace.c
r9259d20 r3e828ea 71 71 72 72 /* set first parameter */ 73 ustate.r0 = (uintptr_t)kernel_uarg->uspace_uarg;73 ustate.r0 = kernel_uarg->uspace_uarg; 74 74 75 75 /* %r1 is defined to hold pcb_ptr - set it to 0 */ … … 93 93 94 94 /* set user stack */ 95 ustate.sp = ((uint32_t) kernel_uarg->uspace_stack)+95 ustate.sp = kernel_uarg->uspace_stack + 96 96 kernel_uarg->uspace_stack_size; 97 97 98 98 /* set where uspace execution starts */ 99 ustate.pc = (uintptr_t)kernel_uarg->uspace_entry;99 ustate.pc = kernel_uarg->uspace_entry; 100 100 101 101 /* status register in user mode */ -
kernel/arch/arm64/include/arch/context_struct.h
r9259d20 r3e828ea 1 1 /* 2 * Copyright (c) 201 8 Jaroslav Jindrak3 * All rights reserved.2 * Copyright (c) 2015 Petr Pavlu 3 * All rights preserved. 4 4 * 5 5 * Redistribution and use in source and binary forms, with or without … … 27 27 */ 28 28 29 #ifndef LIBCPP_BITS_RESULT_OF30 #define LIBCPP_BITS_RESULT_OF29 #ifndef KERN_ARCH_CONTEXT_STRUCT_H_ 30 #define KERN_ARCH_CONTEXT_STRUCT_H_ 31 31 32 /** 33 * TODO: We have two implementations and I can't remember which 34 * one is the correnct one, investigate! 32 #define CONTEXT_OFFSET_SP 0x00 33 #define CONTEXT_OFFSET_PC 0x08 34 #define CONTEXT_OFFSET_X19 0x10 35 #define CONTEXT_OFFSET_X20 0x18 36 #define CONTEXT_OFFSET_X21 0x20 37 #define CONTEXT_OFFSET_X22 0x28 38 #define CONTEXT_OFFSET_X23 0x30 39 #define CONTEXT_OFFSET_X24 0x38 40 #define CONTEXT_OFFSET_X25 0x40 41 #define CONTEXT_OFFSET_X26 0x48 42 #define CONTEXT_OFFSET_X27 0x50 43 #define CONTEXT_OFFSET_X28 0x58 44 #define CONTEXT_OFFSET_X29 0x60 45 #define CONTEXT_OFFSET_IPL 0x68 46 #define CONTEXT_SIZE 0x70 47 48 #ifndef __ASSEMBLER__ 49 50 #include <typedefs.h> 51 52 /* 53 * Thread context containing registers that must be preserved across function 54 * calls. 35 55 */ 36 #include <__bits/invoke.hpp> 37 38 namespace std 39 { 40 /** 41 * Note: This doesn't work, C++14 standard allows for F 42 * to be any complete type, our implementation 43 * currently works like the C++11 version where 44 * F has to be callable. 45 * TODO: Fix this. 46 */ 47 48 template<class> 49 struct result_of; 50 51 template<class F, class... Args> 52 class result_of<F(Args...)>: aux::type_is< 53 decltype(aux::invoke(declval<F>(), declval<ArgTypes>()...)) 54 > 55 { /* DUMMY BODY */ }; 56 57 template<class T> 58 using result_of_t = typename result_of<T>::type; 59 } 56 typedef struct context { 57 uint64_t sp; 58 uint64_t pc; 59 uint64_t x19; 60 uint64_t x20; 61 uint64_t x21; 62 uint64_t x22; 63 uint64_t x23; 64 uint64_t x24; 65 uint64_t x25; 66 uint64_t x26; 67 uint64_t x27; 68 uint64_t x28; 69 uint64_t x29; 70 ipl_t ipl; 71 } context_t; 60 72 61 73 #endif 74 #endif -
kernel/arch/arm64/include/arch/types.h
r9259d20 r3e828ea 1 1 /* 2 * Copyright (c) 201 2 Petr Koupy2 * Copyright (c) 2015 Petr Pavlu 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup draw29 /** @addtogroup kernel_arm64 30 30 * @{ 31 31 */ 32 /** 33 * @file 32 /** @file 34 33 */ 35 34 36 #ifndef DRAW_CURSOR_EMBEDDED_H_37 #define DRAW_CURSOR_EMBEDDED_H_35 #ifndef KERN_arm64_TYPES_H_ 36 #define KERN_arm64_TYPES_H_ 38 37 39 #include "../cursor.h"38 #include <_bits/all.h> 40 39 41 extern cursor_decoder_t cd_embedded; 40 typedef struct { 41 } fncptr_t; 42 42 43 43 #endif -
kernel/arch/ia32/include/arch/interrupt.h
r9259d20 r3e828ea 63 63 /* NS16550 at COM1 */ 64 64 #define IRQ_NS16550 4 65 #define IRQ_PIC _SPUR765 #define IRQ_PIC0_SPUR 7 66 66 #define IRQ_MOUSE 12 67 #define IRQ_PIC1_SPUR 15 67 68 68 69 /* This one must have four least significant bits set to ones */ … … 81 82 #define VECTOR_XM (IVT_EXCBASE + EXC_XM) 82 83 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 83 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) 84 #define VECTOR_PIC0_SPUR (IVT_IRQBASE + IRQ_PIC0_SPUR) 85 #define VECTOR_PIC1_SPUR (IVT_IRQBASE + IRQ_PIC1_SPUR) 84 86 #define VECTOR_SYSCALL IVT_FREEBASE 85 87 #define VECTOR_TLB_SHOOTDOWN_IPI (IVT_FREEBASE + 1) 86 88 #define VECTOR_DEBUG_IPI (IVT_FREEBASE + 2) 87 89 88 extern void (*disable_irqs_function)(uint16_t);89 extern void (*enable_irqs_function)(uint16_t);90 extern void (*eoi_function)(void);91 extern const char *irqs_info;92 93 90 extern void interrupt_init(void); 94 extern void trap_virtual_enable_irqs(uint16_t);95 extern void trap_virtual_disable_irqs(uint16_t);96 91 97 92 #endif -
kernel/arch/ia32/include/arch/mm/as.h
r9259d20 r3e828ea 37 37 38 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 #define KERNEL_SEPARATE_PTL0_ARCH 0 39 40 40 41 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) -
kernel/arch/ia32/include/arch/mm/page.h
r9259d20 r3e828ea 38 38 #include <arch/mm/frame.h> 39 39 #include <stdbool.h> 40 #include <trace.h>41 40 42 41 #define PAGE_WIDTH FRAME_WIDTH … … 147 146 #include <arch/interrupt.h> 148 147 #include <stddef.h> 148 #include <trace.h> 149 149 150 150 /* Page fault error codes. */ -
kernel/arch/ia32/include/arch/smp/apic.h
r9259d20 r3e828ea 43 43 #include <cpu.h> 44 44 #include <stdint.h> 45 #include <genarch/pic/pic_ops.h> 45 46 46 47 #define FIXED (0 << 0) … … 347 348 } io_apic_id_t; 348 349 350 extern pic_ops_t apic_pic_ops; 351 349 352 extern volatile uint32_t *l_apic; 350 353 extern volatile uint32_t *io_apic; … … 356 359 357 360 extern void l_apic_init(void); 358 extern void l_apic_eoi( void);361 extern void l_apic_eoi(unsigned int); 359 362 extern int l_apic_send_custom_ipi(uint8_t, uint8_t); 360 363 extern int l_apic_broadcast_custom_ipi(uint8_t); -
kernel/arch/ia32/src/debug/stacktrace.c
r9259d20 r3e828ea 67 67 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 68 68 { 69 return !copy_from_uspace( (void *)prev,70 (uint32_t *) ctx->fp +FRAME_OFFSET_FP_PREV, sizeof(*prev));69 return !copy_from_uspace(prev, 70 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev)); 71 71 } 72 72 73 73 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 74 74 { 75 return !copy_from_uspace( (void *)ra,76 (uint32_t *) ctx->fp +FRAME_OFFSET_RA, sizeof(*ra));75 return !copy_from_uspace(ra, 76 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra)); 77 77 } 78 78 -
kernel/arch/ia32/src/drivers/i8254.c
r9259d20 r3e828ea 96 96 { 97 97 pio_write_8(CLK_PORT4, 0x36); 98 pic_disable_irqs(1 << IRQ_CLK);98 i8259_disable_irqs(1 << IRQ_CLK); 99 99 pio_write_8(CLK_PORT1, (CLK_CONST / HZ) & 0xf); 100 100 pio_write_8(CLK_PORT1, (CLK_CONST / HZ) >> 8); 101 pic_enable_irqs(1 << IRQ_CLK);101 i8259_enable_irqs(1 << IRQ_CLK); 102 102 } 103 103 … … 143 143 o2 |= pio_read_8(CLK_PORT1) << 8; 144 144 145 uint32_t delta = (t1 - t2) - (o1 - o2); 146 if (!delta) 147 delta = 1; 148 145 149 CPU->delay_loop_const = 146 ((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2))+147 (((MAGIC_NUMBER * LOOPS) / 1000) % ((t1 - t2) - (o1 - o2))? 1 : 0);150 ((MAGIC_NUMBER * LOOPS) / 1000) / delta + 151 (((MAGIC_NUMBER * LOOPS) / 1000) % delta ? 1 : 0); 148 152 149 153 uint64_t clk1 = get_cycle(); -
kernel/arch/ia32/src/ia32.c
r9259d20 r3e828ea 58 58 #include <genarch/multiboot/multiboot.h> 59 59 #include <genarch/multiboot/multiboot2.h> 60 #include <genarch/pic/pic_ops.h> 60 61 #include <arch/pm.h> 61 62 #include <arch/vreg.h> … … 110 111 /* PIC */ 111 112 i8259_init((i8259_t *) I8259_PIC0_BASE, 112 (i8259_t *) I8259_PIC1_BASE, IRQ_PIC1, IVT_IRQBASE, 113 IVT_IRQBASE + 8); 114 115 /* 116 * Set the enable/disable IRQs handlers. 117 * Set the End-of-Interrupt handler. 118 */ 119 enable_irqs_function = pic_enable_irqs; 120 disable_irqs_function = pic_disable_irqs; 121 eoi_function = pic_eoi; 122 irqs_info = "i8259"; 113 (i8259_t *) I8259_PIC1_BASE, IVT_IRQBASE); 114 115 /* Set PIC operations. */ 116 pic_ops = &i8259_pic_ops; 123 117 } 124 118 } … … 195 189 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 196 190 i8042_wire(i8042_instance, kbrd); 197 trap_virtual_enable_irqs(1 << IRQ_KBD);198 trap_virtual_enable_irqs(1 << IRQ_MOUSE);191 pic_ops->enable_irqs(1 << IRQ_KBD); 192 pic_ops->enable_irqs(1 << IRQ_MOUSE); 199 193 } 200 194 } … … 221 215 indev_t *srln = srln_wire(srln_instance, sink); 222 216 ns16550_wire(ns16550_instance, srln); 223 trap_virtual_enable_irqs(1 << IRQ_NS16550);217 pic_ops->enable_irqs(1 << IRQ_NS16550); 224 218 } 225 219 #endif … … 232 226 #endif 233 227 234 if (irqs_info != NULL) 235 sysinfo_set_item_val(irqs_info, NULL, true); 228 sysinfo_set_item_val(pic_ops->get_name(), NULL, true); 236 229 } 237 230 -
kernel/arch/ia32/src/interrupt.c
r9259d20 r3e828ea 40 40 #include <panic.h> 41 41 #include <genarch/drivers/i8259/i8259.h> 42 #include <genarch/pic/pic_ops.h> 42 43 #include <halt.h> 43 44 #include <cpu.h> … … 61 62 */ 62 63 63 void (*disable_irqs_function)(uint16_t irqmask) = NULL; 64 void (*enable_irqs_function)(uint16_t irqmask) = NULL; 65 void (*eoi_function)(void) = NULL; 66 const char *irqs_info = NULL; 64 pic_ops_t *pic_ops = NULL; 67 65 68 66 void istate_decode(istate_t *istate) … … 88 86 istate_from_uspace(istate) ? istate->esp : 89 87 (uint32_t) &istate->esp); 90 }91 92 static void trap_virtual_eoi(void)93 {94 if (eoi_function)95 eoi_function();96 else97 panic("No eoi_function.");98 99 88 } 100 89 … … 179 168 istate_t *istate __attribute__((unused))) 180 169 { 181 trap_virtual_eoi();170 pic_ops->eoi(0); 182 171 tlb_shootdown_ipi_recv(); 183 172 } … … 192 181 bool ack = false; 193 182 assert(inum < IRQ_COUNT); 194 assert( (inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));183 assert(inum != IRQ_PIC1); 195 184 196 185 irq_t *irq = irq_dispatch_and_lock(inum); … … 202 191 if (irq->preack) { 203 192 /* Send EOI before processing the interrupt */ 204 trap_virtual_eoi();193 pic_ops->eoi(inum); 205 194 ack = true; 206 195 } … … 208 197 irq_spinlock_unlock(&irq->lock, false); 209 198 } else { 210 /*211 * Spurious interrupt.212 */213 199 #ifdef CONFIG_DEBUG 214 printf("cpu%u: spurious interrupt (inum=%u)\n", CPU->id, inum); 200 log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ %u", CPU->id, 201 inum); 215 202 #endif 216 203 } 217 204 218 205 if (!ack) 219 trap_virtual_eoi(); 206 pic_ops->eoi(inum); 207 } 208 209 static void pic_spurious(unsigned int n, istate_t *istate) 210 { 211 unsigned int inum = n - IVT_IRQBASE; 212 if (!pic_ops->is_spurious(inum)) { 213 /* This is actually not a spurious IRQ, so proceed as usual. */ 214 irq_interrupt(n, istate); 215 return; 216 } 217 pic_ops->handle_spurious(n); 218 #ifdef CONFIG_DEBUG 219 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", CPU->id, 220 inum); 221 #endif 220 222 } 221 223 … … 228 230 229 231 for (i = 0; i < IRQ_COUNT; i++) { 230 if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1)) 232 if ((i != IRQ_PIC0_SPUR) && (i != IRQ_PIC1_SPUR) && 233 (i != IRQ_PIC1)) 231 234 exc_register(IVT_IRQBASE + i, "irq", true, 232 235 (iroutine_t) irq_interrupt); … … 239 242 exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault); 240 243 exc_register(VECTOR_XM, "simd_fp", true, (iroutine_t) simd_fp_exception); 244 exc_register(VECTOR_PIC0_SPUR, "pic0_spurious", true, 245 (iroutine_t) pic_spurious); 246 exc_register(VECTOR_PIC1_SPUR, "pic1_spurious", true, 247 (iroutine_t) pic_spurious); 241 248 242 249 #ifdef CONFIG_SMP … … 246 253 } 247 254 248 void trap_virtual_enable_irqs(uint16_t irqmask)249 {250 if (enable_irqs_function)251 enable_irqs_function(irqmask);252 else253 panic("No enable_irqs_function.");254 }255 256 void trap_virtual_disable_irqs(uint16_t irqmask)257 {258 if (disable_irqs_function)259 disable_irqs_function(irqmask);260 else261 panic("No disable_irqs_function.");262 }263 264 255 /** @} 265 256 */ -
kernel/arch/ia32/src/smp/apic.c
r9259d20 r3e828ea 47 47 #include <arch.h> 48 48 #include <ddi/irq.h> 49 #include <genarch/pic/pic_ops.h> 49 50 50 51 #ifdef CONFIG_SMP … … 63 64 */ 64 65 66 static const char *apic_get_name(void); 67 static bool l_apic_is_spurious(unsigned int); 68 static void l_apic_handle_spurious(unsigned int); 69 70 pic_ops_t apic_pic_ops = { 71 .get_name = apic_get_name, 72 .enable_irqs = io_apic_enable_irqs, 73 .disable_irqs = io_apic_disable_irqs, 74 .eoi = l_apic_eoi, 75 .is_spurious = l_apic_is_spurious, 76 .handle_spurious = l_apic_handle_spurious, 77 }; 78 65 79 /* 66 80 * These variables either stay configured as initilalized, or are changed by … … 125 139 #endif /* LAPIC_VERBOSE */ 126 140 141 const char *apic_get_name(void) 142 { 143 return "apic"; 144 } 145 146 bool l_apic_is_spurious(unsigned int n) 147 { 148 return n == VECTOR_APIC_SPUR; 149 } 150 151 void l_apic_handle_spurious(unsigned int n) 152 { 153 } 154 127 155 /** APIC spurious interrupt handler. 128 156 * … … 134 162 istate_t *istate __attribute__((unused))) 135 163 { 136 #ifdef CONFIG_DEBUG137 log(LF_ARCH, LVL_DEBUG, "cpu%u: APIC spurious interrupt", CPU->id);138 #endif139 164 } 140 165 … … 175 200 (iroutine_t) apic_spurious); 176 201 177 enable_irqs_function = io_apic_enable_irqs; 178 disable_irqs_function = io_apic_disable_irqs; 179 eoi_function = l_apic_eoi; 180 irqs_info = "apic"; 202 pic_ops = &apic_pic_ops; 181 203 182 204 /* … … 508 530 509 531 /** Local APIC End of Interrupt. */ 510 void l_apic_eoi( void)532 void l_apic_eoi(unsigned int ignored) 511 533 { 512 534 l_apic[EOI] = 0; -
kernel/arch/ia32/src/smp/smp.c
r9259d20 r3e828ea 130 130 pio_write_8((ioport8_t *) 0x71, 0xa); 131 131 132 pic_disable_irqs(0xffff);132 i8259_disable_irqs(0xffff); 133 133 apic_init(); 134 134 -
kernel/arch/ia32/src/userspace.c
r9259d20 r3e828ea 70 70 : [eflags_mask] "i" (~EFLAGS_NT), 71 71 [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 72 [stack_top] "r" ( (uint8_t *)kernel_uarg->uspace_stack +72 [stack_top] "r" (kernel_uarg->uspace_stack + 73 73 kernel_uarg->uspace_stack_size), 74 74 [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF), -
kernel/arch/ia64/include/arch/interrupt.h
r9259d20 r3e828ea 92 92 extern void disabled_fp_register(unsigned int, istate_t *); 93 93 94 extern void trap_virtual_enable_irqs(uint16_t);95 96 94 void exception_init(void); 97 95 #endif -
kernel/arch/ia64/include/arch/istate.h
r9259d20 r3e828ea 71 71 _NO_TRACE static inline int istate_from_uspace(istate_t *istate) 72 72 { 73 return (istate->cr_iip) < 0xe000000000000000ULL;73 return istate->cr_ipsr.cpl == PSR_CPL_USER; 74 74 } 75 75 -
kernel/arch/ia64/include/arch/mm/as.h
r9259d20 r3e828ea 37 37 38 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 #define KERNEL_SEPARATE_PTL0_ARCH 0 39 40 40 41 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT64_C(0xe000000000000000) -
kernel/arch/ia64/include/arch/mm/page.h
r9259d20 r3e828ea 38 38 39 39 #include <arch/mm/frame.h> 40 #include <arch/register.h> 40 41 41 42 #ifndef __ASSEMBLER__ … … 76 77 77 78 /** Privilege Levels. Only the most and the least privileged ones are ever used. */ 78 #define PL_KERNEL 0x0079 #define PL_USER 0x0379 #define PL_KERNEL PSR_CPL_KERNEL 80 #define PL_USER PSR_CPL_USER 80 81 81 82 /* Access Rigths. Only certain combinations are used by the kernel. */ -
kernel/arch/ia64/include/arch/register.h
r9259d20 r3e828ea 57 57 #define PSR_RT_MASK (1 << 27) 58 58 #define PSR_IT_MASK (1 << 36) 59 60 #define PSR_CPL_USER 3 61 #define PSR_CPL_KERNEL 0 59 62 60 63 #define PSR_CPL_SHIFT 32 -
kernel/arch/ia64/src/ia64.c
r9259d20 r3e828ea 244 244 * uspace_stack_size / 2 bytes. 245 245 */ 246 switch_to_userspace( (uintptr_t)kernel_uarg->uspace_entry,247 ((uintptr_t) kernel_uarg->uspace_stack)+246 switch_to_userspace(kernel_uarg->uspace_entry, 247 kernel_uarg->uspace_stack + 248 248 kernel_uarg->uspace_stack_size / 2 - 249 249 ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT), 250 ((uintptr_t) kernel_uarg->uspace_stack)+250 kernel_uarg->uspace_stack + 251 251 kernel_uarg->uspace_stack_size / 2, 252 (uintptr_t)kernel_uarg->uspace_uarg, psr.value, rsc.value);252 kernel_uarg->uspace_uarg, psr.value, rsc.value); 253 253 254 254 while (true) -
kernel/arch/ia64/src/interrupt.c
r9259d20 r3e828ea 301 301 } 302 302 303 void trap_virtual_enable_irqs(uint16_t irqmask)304 {305 }306 307 303 void exception_init(void) 308 304 { -
kernel/arch/ia64/src/mm/tlb.c
r9259d20 r3e828ea 464 464 } 465 465 466 static bool is_kernel_fault( uintptr_t va)466 static bool is_kernel_fault(istate_t *istate, uintptr_t va) 467 467 { 468 468 region_register_t rr; 469 470 if (istate_from_uspace(istate)) 471 return false; 469 472 470 473 rr.word = rr_read(VA2VRN(va)); … … 484 487 pte_t t; 485 488 489 assert(istate_from_uspace(istate)); 490 486 491 va = istate->cr_ifa; /* faulting address */ 487 488 assert(!is_kernel_fault(va));489 492 490 493 bool found = page_mapping_find(AS, va, true, &t); … … 587 590 as_t *as = AS; 588 591 589 if (is_kernel_fault( va)) {592 if (is_kernel_fault(istate, va)) { 590 593 if (va < end_of_identity) { 591 594 /* … … 648 651 va = istate->cr_ifa; /* faulting address */ 649 652 650 if (is_kernel_fault( va))653 if (is_kernel_fault(istate, va)) 651 654 as = AS_KERNEL; 652 655 … … 680 683 pte_t t; 681 684 685 assert(istate_from_uspace(istate)); 686 682 687 va = istate->cr_ifa; /* faulting address */ 683 684 assert(!is_kernel_fault(va));685 688 686 689 bool found = page_mapping_find(AS, va, true, &t); … … 716 719 va = istate->cr_ifa; /* faulting address */ 717 720 718 if (is_kernel_fault( va))721 if (is_kernel_fault(istate, va)) 719 722 as = AS_KERNEL; 720 723 … … 752 755 pte_t t; 753 756 757 assert(istate_from_uspace(istate)); 758 754 759 va = istate->cr_ifa; /* faulting address */ 755 756 assert(!is_kernel_fault(va));757 760 758 761 /* … … 779 782 pte_t t; 780 783 784 assert(istate_from_uspace(istate)); 785 781 786 va = istate->cr_ifa; /* faulting address */ 782 783 assert(!is_kernel_fault(va));784 787 785 788 bool found = page_mapping_find(AS, va, true, &t); -
kernel/arch/mips32/include/arch/arch.h
r9259d20 r3e828ea 42 42 #define CPUMAP_MAX_RECORDS 32 43 43 #define BOOTINFO_TASK_NAME_BUFLEN 32 44 #define BOOTINFO_BOOTARGS_BUFLEN 256 44 45 45 46 extern size_t cpu_count; … … 66 67 uint32_t cpumap; 67 68 taskmap_t taskmap; 69 char bootargs[BOOTINFO_BOOTARGS_BUFLEN]; 68 70 } bootinfo_t; 69 71 -
kernel/arch/mips32/include/arch/exception.h
r9259d20 r3e828ea 57 57 #define EXC_VCED 31 58 58 59 #define INT_SW0 0 60 #define INT_SW1 1 61 #define INT_HW0 2 62 #define INT_HW1 3 63 #define INT_HW2 4 64 #define INT_HW3 5 65 #define INT_HW4 6 66 #define INT_TIMER 7 67 68 #define MIPS_INTERRUPTS 8 69 #define HW_INTERRUPTS (MIPS_INTERRUPTS - 3) 70 71 typedef void (*int_handler_t)(unsigned int); 72 extern int_handler_t int_handler[]; 73 59 74 extern void exception(istate_t *istate); 60 75 extern void tlb_refill_entry(void); -
kernel/arch/mips32/include/arch/mach/malta/malta.h
r9259d20 r3e828ea 39 39 #include <arch/machine_func.h> 40 40 #include <arch/mm/page.h> 41 #include <typedefs.h> 41 42 42 #define MALTA_PCI_BASE PA2KSEG1(0x18000000UL) 43 #define MALTA_PCI_PHYSBASE 0x18000000UL 44 45 #define MALTA_PCI_BASE PA2KSEG1(MALTA_PCI_PHYSBASE) 43 46 #define MALTA_GT64120_BASE PA2KSEG1(0x1be00000UL) 44 47 … … 46 49 #define PIC1_BASE (MALTA_PCI_BASE + 0xa0) 47 50 48 #define TTY_BASE (MALTA_PCI_BASE + 0x3f8) 49 #define TTY_CPU_INT 2 51 #define ISA_IRQ_COUNT 16 52 53 #define TTY_BASE (MALTA_PCI_PHYSBASE + 0x3f8) 50 54 #define TTY_ISA_IRQ 4 51 55 52 #define GT64120_PCI0_INTACK ( MALTA_GT64120_BASE + 0xc34)56 #define GT64120_PCI0_INTACK ((ioport32_t *) (MALTA_GT64120_BASE + 0xc34)) 53 57 54 58 extern struct mips32_machine_ops malta_machine_ops; -
kernel/arch/mips32/include/arch/machine_func.h
r9259d20 r3e828ea 43 43 44 44 #include <typedefs.h> 45 #include <stdbool.h> 45 46 46 47 struct mips32_machine_ops { -
kernel/arch/mips32/include/arch/mm/as.h
r9259d20 r3e828ea 37 37 38 38 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 39 #define KERNEL_SEPARATE_PTL0_ARCH 0 39 40 40 41 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) -
kernel/arch/mips32/meson.build
r9259d20 r3e828ea 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar4 3 # All rights reserved. 5 4 # … … 28 27 # 29 28 30 USPACE_PREFIX = ../.. 31 ROOT_PATH = $(USPACE_PREFIX)/.. 32 CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config 29 arch_src += files( 30 'src/start.S', 31 'src/context.S', 32 'src/mips32.c', 33 'src/asm.S', 34 'src/exception.c', 35 'src/interrupt.c', 36 'src/cache.c', 37 'src/debugger.c', 38 'src/cpu/cpu.c', 39 'src/debug/stacktrace.c', 40 'src/debug/stacktrace_asm.S', 41 'src/mm/km.c', 42 'src/mm/frame.c', 43 'src/mm/page.c', 44 'src/mm/tlb.c', 45 'src/mm/as.c', 46 'src/fpu_context.c', 47 'src/smc.c', 48 'src/smp/smp.c', 49 'src/machine_func.c', 50 ) 33 51 34 include $(CONFIG_MAKEFILE) 52 if MACHINE == 'lmalta' or MACHINE == 'bmalta' 53 arch_src += files('src/mach/malta/malta.c') 35 54 36 ifeq ($(UARCH),ia64) 37 # IA64 has a peculiar linker script with a fixed data segment address. 38 # Because the loader is a separate nonrelocatable binary in the same 39 # address space as the application, we provide a modified copy of 40 # the default linker script to work around that. 41 EXTRA_LDFLAGS = -T elf64_ia64_loader.x 42 else 43 # On all other architectures, we can simply move the text segment. 44 EXTRA_LDFLAGS = -Wl,-Ttext-segment=0x70000000 55 elif MACHINE == 'msim' 56 arch_src += files( 57 'src/mach/msim/msim.c', 58 'src/mach/msim/dorder.c', 59 ) 60 45 61 endif 46 62 47 BINARY = loader48 STATIC_ONLY = y49 63 50 GENERIC_SOURCES = \ 51 main.c 64 _check_headers = [ 65 'include/arch/istate_struct.h', 66 'include/arch/context_struct.h', 67 'include/arch/fpu_context_struct.h', 68 ] 52 69 53 SOURCES = \ 54 $(GENERIC_SOURCES) \ 55 $(ARCH_SOURCES) 56 57 include $(USPACE_PREFIX)/Makefile.common 70 foreach h : _check_headers 71 arch_src += [ autocheck.process(h) ] 72 endforeach -
kernel/arch/mips32/src/exception.c
r9259d20 r3e828ea 47 47 #include <symtab.h> 48 48 #include <log.h> 49 #include <arch/machine_func.h> 49 50 50 51 static const char *exctable[] = { … … 174 175 175 176 unsigned int i; 176 for (i = 0; i < 8; i++) {177 for (i = 0; i < MIPS_INTERRUPTS; i++) { 177 178 178 179 /* … … 183 184 */ 184 185 if (im & ip & (1 << i)) { 185 irq_t *irq = irq_dispatch_and_lock(i); 186 if (irq) { 187 /* 188 * The IRQ handler was found. 189 */ 190 irq->handler(irq); 191 if (irq->cir) 192 irq->cir(irq->cir_arg, i); 193 irq_spinlock_unlock(&irq->lock, false); 194 } else { 186 if (int_handler[i]) 187 int_handler[i](i); 188 else { 195 189 /* 196 190 * Spurious interrupt. -
kernel/arch/mips32/src/interrupt.c
r9259d20 r3e828ea 41 41 #include <ipc/sysipc.h> 42 42 43 #define IRQ_COUNT 844 #define TIMER_IRQ 745 46 function virtual_timer_fnc = NULL;47 static irq_t timer_irq;48 49 43 // TODO: This is SMP unsafe!!! 50 44 … … 52 46 static unsigned long nextcount; 53 47 static unsigned long lastcount; 48 49 /** Table of interrupt handlers. */ 50 int_handler_t int_handler[MIPS_INTERRUPTS] = { }; 54 51 55 52 /** Disable interrupts. … … 113 110 } 114 111 115 static irq_ownership_t timer_claim(irq_t *irq) 116 { 117 return IRQ_ACCEPT; 118 } 119 120 static void timer_irq_handler(irq_t *irq) 112 static void timer_interrupt_handler(unsigned int intr) 121 113 { 122 114 if (cp0_count_read() < lastcount) … … 135 127 cp0_compare_write(nextcount); 136 128 137 /*138 * We are holding a lock which prevents preemption.139 * Release the lock, call clock() and reacquire the lock again.140 */141 irq_spinlock_unlock(&irq->lock, false);142 129 clock(); 143 irq_spinlock_lock(&irq->lock, false);144 145 if (virtual_timer_fnc != NULL)146 virtual_timer_fnc();147 130 } 148 131 … … 150 133 void interrupt_init(void) 151 134 { 152 irq_init(IRQ_COUNT, IRQ_COUNT); 153 154 irq_initialize(&timer_irq); 155 timer_irq.inr = TIMER_IRQ; 156 timer_irq.claim = timer_claim; 157 timer_irq.handler = timer_irq_handler; 158 irq_register(&timer_irq); 135 int_handler[INT_TIMER] = timer_interrupt_handler; 159 136 160 137 timer_start(); 161 cp0_unmask_int( TIMER_IRQ);138 cp0_unmask_int(INT_TIMER); 162 139 } 163 140 -
kernel/arch/mips32/src/mach/malta/malta.c
r9259d20 r3e828ea 42 42 #include <genarch/srln/srln.h> 43 43 #include <arch/interrupt.h> 44 #include <stdbool.h> 45 #include <byteorder.h> 46 #include <sysinfo/sysinfo.h> 47 #include <log.h> 44 48 45 49 static void malta_init(void); … … 68 72 #endif 69 73 70 #ifdef CONFIG_NS16550 71 static void tty_clear_interrupt(void *arg, inr_t inr) 74 static void malta_isa_irq_handler(unsigned int i) 72 75 { 73 (void) pio_read_8((ioport8_t *) GT64120_PCI0_INTACK); 74 pic_eoi(); 76 uint8_t isa_irq = host2uint32_t_le(pio_read_32(GT64120_PCI0_INTACK)); 77 if (i8259_is_spurious(isa_irq)) { 78 i8259_handle_spurious(isa_irq); 79 #ifdef CONFIG_DEBUG 80 log(LF_ARCH, LVL_DEBUG, "cpu%u: PIC spurious interrupt %u", 81 CPU->id, isa_irq); 82 return; 83 #endif 84 } 85 irq_t *irq = irq_dispatch_and_lock(isa_irq); 86 if (irq) { 87 irq->handler(irq); 88 irq_spinlock_unlock(&irq->lock, false); 89 } else { 90 #ifdef CONFIG_DEBUG 91 log(LF_ARCH, LVL_DEBUG, "cpu%u: unhandled IRQ (irq=%u)", 92 CPU->id, isa_irq); 93 #endif 94 } 95 i8259_eoi(isa_irq); 75 96 } 76 #endif77 97 78 98 void malta_init(void) 79 99 { 80 i8259_init((i8259_t *) PIC0_BASE, (i8259_t *) PIC1_BASE, 2, 0, 8); 100 irq_init(ISA_IRQ_COUNT, ISA_IRQ_COUNT); 101 102 i8259_init((i8259_t *) PIC0_BASE, (i8259_t *) PIC1_BASE, 0); 103 sysinfo_set_item_val("i8259", NULL, true); 104 105 int_handler[INT_HW0] = malta_isa_irq_handler; 106 cp0_unmask_int(INT_HW0); 81 107 82 108 #if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT)) … … 86 112 outdev_t **tty_out_ptr = NULL; 87 113 #endif 88 tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_ CPU_INT,89 tty_clear_interrupt, NULL, tty_out_ptr);114 tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_ISA_IRQ, 115 NULL, NULL, tty_out_ptr); 90 116 #endif 91 117 } … … 120 146 indev_t *srln = srln_wire(srln_instance, sink); 121 147 ns16550_wire(tty_instance, srln); 122 pic_enable_irqs(1 << TTY_ISA_IRQ); 123 cp0_unmask_int(TTY_CPU_INT); 148 i8259_enable_irqs(1 << TTY_ISA_IRQ); 124 149 } 125 150 } -
kernel/arch/mips32/src/mach/msim/msim.c
r9259d20 r3e828ea 41 41 #include <genarch/drivers/dsrln/dsrlnout.h> 42 42 #include <genarch/srln/srln.h> 43 #include <stdbool.h> 43 44 44 45 static void msim_init(void); … … 60 61 }; 61 62 63 static void msim_irq_handler(unsigned int i) 64 { 65 irq_t *irq = irq_dispatch_and_lock(i); 66 if (irq) { 67 irq->handler(irq); 68 irq_spinlock_unlock(&irq->lock, false); 69 } else { 70 #ifdef CONFIG_DEBUG 71 log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious IRQ (irq=%u)", 72 CPU->id, i); 73 #endif 74 } 75 } 76 62 77 void msim_init(void) 63 78 { 79 irq_init(HW_INTERRUPTS, HW_INTERRUPTS); 80 81 int_handler[INT_HW0] = msim_irq_handler; 82 int_handler[INT_HW1] = msim_irq_handler; 83 int_handler[INT_HW2] = msim_irq_handler; 84 int_handler[INT_HW3] = msim_irq_handler; 85 int_handler[INT_HW4] = msim_irq_handler; 86 64 87 dorder_init(); 65 88 cp0_unmask_int(MSIM_DDISK_IRQ); -
kernel/arch/mips32/src/mips32.c
r9259d20 r3e828ea 71 71 arch_ops_t *arch_ops = &mips32_ops; 72 72 73 /*74 * Why the linker moves the variable 64K away in assembler75 * when not in .text section?76 */77 78 73 /* Stack pointer saved when entering user mode */ 79 uintptr_t supervisor_sp __attribute__((section(".text"))); 74 // FIXME: This won't work with SMP unless thread creation is globally serialized. 75 uintptr_t supervisor_sp; 80 76 81 77 size_t cpu_count = 0; … … 107 103 #endif 108 104 105 str_cpy(bargs, CONFIG_BOOT_ARGUMENTS_BUFLEN, bootinfo->bootargs); 106 109 107 /* Initialize machine_ops pointer. */ 110 108 machine_ops_init(); … … 169 167 cp0_status_write(cp0_status_read() | (cp0_status_exl_exception_bit | 170 168 cp0_status_um_bit | cp0_status_ie_enabled_bit)); 171 cp0_epc_write( (uintptr_t)kernel_uarg->uspace_entry);172 userspace_asm( ((uintptr_t)kernel_uarg->uspace_stack +173 kernel_uarg->uspace_stack_size ),174 (uintptr_t)kernel_uarg->uspace_uarg,175 (uintptr_t)kernel_uarg->uspace_entry);169 cp0_epc_write(kernel_uarg->uspace_entry); 170 userspace_asm(kernel_uarg->uspace_stack + 171 kernel_uarg->uspace_stack_size, 172 kernel_uarg->uspace_uarg, 173 kernel_uarg->uspace_entry); 176 174 177 175 while (true) -
kernel/arch/ppc32/include/arch/mm/as.h
r9259d20 r3e828ea 39 39 40 40 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 41 #define KERNEL_SEPARATE_PTL0_ARCH 0 41 42 42 43 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT32_C(0x80000000) -
kernel/arch/ppc32/include/arch/mm/page.h
r9259d20 r3e828ea 37 37 38 38 #include <arch/mm/frame.h> 39 #include <trace.h>40 39 41 40 #define PAGE_WIDTH FRAME_WIDTH … … 150 149 #include <mm/mm.h> 151 150 #include <arch/interrupt.h> 151 #include <trace.h> 152 152 153 153 /** Page Table Entry. */ -
kernel/arch/ppc32/meson.build
r9259d20 r3e828ea 27 27 # 28 28 29 # TODO: We need to implement DWARF unwinding and get rid of this flag. 30 COMMON_CFLAGS += -fno-omit-frame-pointer -Wl,-z,max-page-size=0x1000 29 arch_src += files( 30 'src/context.S', 31 'src/debug/stacktrace.c', 32 'src/debug/stacktrace_asm.S', 33 'src/fpu_context.S', 34 'src/boot/boot.S', 35 'src/ppc32.c', 36 'src/dummy.S', 37 'src/exception.S', 38 'src/interrupt.c', 39 'src/asm.S', 40 'src/cpu/cpu.c', 41 'src/proc/scheduler.c', 42 'src/smc.c', 43 'src/mm/km.c', 44 'src/mm/as.c', 45 'src/mm/frame.c', 46 'src/mm/page.c', 47 'src/mm/pht.c', 48 'src/mm/tlb.c', 49 'src/drivers/pic.c', 50 ) 31 51 32 # XXX: This architecture requires unoptimized TLS pointer access,33 # as with the GCC option `-mno-tls-direct-seg-refs`.34 # The `amd64-helenos` target defaults to this behavior.35 52 36 LDFLAGS += -Wl,--gc-sections 53 _check_headers = [ 54 'include/arch/istate_struct.h', 55 'include/arch/context_struct.h', 56 'include/arch/fpu_context_struct.h', 57 ] 37 58 38 ENDIANESS = LE 39 40 BFD_NAME = elf64-x86-64 41 BFD_ARCH = i386:x86-64 59 foreach h : _check_headers 60 arch_src += [ autocheck.process(h) ] 61 endforeach -
kernel/arch/ppc32/src/debug/stacktrace.c
r9259d20 r3e828ea 67 67 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 68 68 { 69 return !copy_from_uspace( (void *)prev,70 (uint32_t *) ctx->fp +FRAME_OFFSET_FP_PREV, sizeof(*prev));69 return !copy_from_uspace(prev, 70 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_FP_PREV, sizeof(*prev)); 71 71 } 72 72 73 73 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 74 74 { 75 return !copy_from_uspace( (void *)ra,76 (uint32_t *) ctx->fp +FRAME_OFFSET_RA, sizeof(*ra));75 return !copy_from_uspace(ra, 76 ctx->fp + sizeof(uintptr_t) * FRAME_OFFSET_RA, sizeof(*ra)); 77 77 } 78 78 -
kernel/arch/ppc32/src/drivers/pic.c
r9259d20 r3e828ea 37 37 #include <byteorder.h> 38 38 #include <bitops.h> 39 #include <typedefs.h> 39 40 40 static volatile uint32_t *pic = NULL;41 static ioport32_t *pic = NULL; 41 42 42 43 void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg) … … 50 51 void pic_enable_interrupt(inr_t intnum) 51 52 { 52 if (pic) { 53 if (intnum < 32) 54 pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] | (1 << intnum); 55 else 56 pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] | (1 << (intnum - 32)); 53 if (!pic) 54 return; 55 56 if (intnum < 32) { 57 pio_write_32(&pic[PIC_MASK_LOW], 58 pio_read_32(&pic[PIC_MASK_LOW]) | (1 << intnum)); 59 } else { 60 pio_write_32(&pic[PIC_MASK_HIGH], 61 pio_read_32(&pic[PIC_MASK_HIGH]) | (1 << (intnum - 32))); 57 62 } 58 59 63 } 60 64 61 65 void pic_disable_interrupt(inr_t intnum) 62 66 { 63 if (pic) { 64 if (intnum < 32) 65 pic[PIC_MASK_LOW] = pic[PIC_MASK_LOW] & (~(1 << intnum)); 66 else 67 pic[PIC_MASK_HIGH] = pic[PIC_MASK_HIGH] & (~(1 << (intnum - 32))); 67 if (!pic) 68 return; 69 70 if (intnum < 32) { 71 pio_write_32(&pic[PIC_MASK_LOW], 72 pio_read_32(&pic[PIC_MASK_LOW]) & (~(1 << intnum))); 73 } else { 74 pio_write_32(&pic[PIC_MASK_HIGH], 75 pio_read_32(&pic[PIC_MASK_HIGH]) & (~(1 << (intnum - 32)))); 68 76 } 69 77 } … … 71 79 void pic_ack_interrupt(void *arg, inr_t intnum) 72 80 { 73 if (pic) { 74 if (intnum < 32) 75 pic[PIC_ACK_LOW] = 1 << intnum; 76 else 77 pic[PIC_ACK_HIGH] = 1 << (intnum - 32); 81 if (!pic) 82 return; 83 84 if (intnum < 32) { 85 pio_write_32(&pic[PIC_ACK_LOW], 1 << intnum); 86 } else { 87 pio_write_32(&pic[PIC_ACK_HIGH], 1 << (intnum - 32)); 78 88 } 79 89 } … … 87 97 uint32_t pending; 88 98 89 pending = pi c[PIC_PENDING_LOW];99 pending = pio_read_32(&pic[PIC_PENDING_LOW]); 90 100 if (pending != 0) 91 101 return fnzb32(pending); 92 102 93 pending = pi c[PIC_PENDING_HIGH];103 pending = pio_read_32(&pic[PIC_PENDING_HIGH]); 94 104 if (pending != 0) 95 105 return fnzb32(pending) + 32; -
kernel/arch/ppc32/src/interrupt.c
r9259d20 r3e828ea 141 141 " (inum=%" PRIu8 ")", CPU->id, inum); 142 142 #endif 143 pic_ack_interrupt(NULL, inum); 144 break; 143 145 } 144 146 } -
kernel/arch/ppc32/src/ppc32.c
r9259d20 r3e828ea 292 292 void userspace(uspace_arg_t *kernel_uarg) 293 293 { 294 userspace_asm( (uintptr_t)kernel_uarg->uspace_uarg,295 (uintptr_t)kernel_uarg->uspace_stack +294 userspace_asm(kernel_uarg->uspace_uarg, 295 kernel_uarg->uspace_stack + 296 296 kernel_uarg->uspace_stack_size - SP_DELTA, 297 (uintptr_t)kernel_uarg->uspace_entry);297 kernel_uarg->uspace_entry); 298 298 299 299 unreachable(); -
kernel/arch/riscv64/_link.ld.in
r9259d20 r3e828ea 16 16 kernel_load_address = PA2KA(BOOT_OFFSET); 17 17 18 .image (PA2KA(BOOT_OFFSET) + SIZEOF_HEADERS) : AT ( SIZEOF_HEADERS) {18 .image (PA2KA(BOOT_OFFSET) + SIZEOF_HEADERS) : AT (BOOT_OFFSET + SIZEOF_HEADERS) { 19 19 ktext_start = .; 20 20 *(K_TEXT_START); -
kernel/arch/riscv64/include/arch/mm/as.h
r9259d20 r3e828ea 40 40 41 41 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 0 42 #define KERNEL_SEPARATE_PTL0_ARCH 0 42 43 43 44 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT64_C(0xffff800000000000) -
kernel/arch/riscv64/meson.build
r9259d20 r3e828ea 27 27 # 28 28 29 BFD_NAME = elf64-littleriscv 30 BFD_OUTPUT = $(BFD_NAME) 31 BFD_ARCH = riscv 29 arch_src += files( 30 'src/boot/boot.S', 31 'src/asm.S', 32 'src/context.S', 33 'src/debug/stacktrace.c', 34 'src/drivers/ucb.c', 35 'src/proc/scheduler.c', 36 'src/proc/task.c', 37 'src/proc/thread.c', 38 'src/riscv64.c', 39 'src/userspace.c', 40 'src/smc.c', 41 'src/cpu/cpu.c', 42 'src/mm/km.c', 43 'src/mm/as.c', 44 'src/mm/frame.c', 45 'src/mm/page.c', 46 'src/mm/tlb.c', 47 ) 32 48 33 BITS = 6434 ENDIANESS = LE35 EXTRA_CFLAGS = -mcmodel=medany36 49 37 SOURCES = \ 38 arch/$(BARCH)/src/asm.S \ 39 arch/$(BARCH)/src/main.c \ 40 arch/$(BARCH)/src/ucb.c \ 41 arch/$(BARCH)/src/putchar.c \ 42 $(COMPS).o \ 43 generic/src/memstr.c \ 44 generic/src/printf_core.c \ 45 generic/src/vprintf.c \ 46 generic/src/printf.c \ 47 generic/src/str.c \ 48 generic/src/version.c \ 49 generic/src/inflate.c \ 50 generic/src/gzip.c \ 51 generic/src/tar.c \ 52 generic/src/kernel.c \ 53 generic/src/payload.c 50 _check_headers = [ 51 'include/arch/istate_struct.h', 52 'include/arch/context_struct.h', 53 ] 54 55 foreach h : _check_headers 56 arch_src += [ autocheck.process(h) ] 57 endforeach -
kernel/arch/riscv64/src/riscv64.c
r9259d20 r3e828ea 143 143 } 144 144 145 uintptr_t memcpy_from_uspace(void *dst, const void *uspace_src, size_t size)145 uintptr_t memcpy_from_uspace(void *dst, uspace_addr_t uspace_src, size_t size) 146 146 { 147 147 return 0; 148 148 } 149 149 150 uintptr_t memcpy_to_uspace( void *uspace_dst, const void *src, size_t size)150 uintptr_t memcpy_to_uspace(uspace_addr_t uspace_dst, const void *src, size_t size) 151 151 { 152 152 return 0; -
kernel/arch/sparc64/include/arch/drivers/tty.h
r9259d20 r3e828ea 1 1 /* 2 * Copyright (c) 201 4 Martin Sucha2 * Copyright (c) 2019 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup draw29 /** @addtogroup kernel_sparc64 30 30 * @{ 31 31 */ 32 /** 33 * @file 32 /** @file 34 33 */ 35 34 36 #ifndef DRAW_FONT_PBF_H_37 #define DRAW_FONT_PBF_H_35 #ifndef KERN_sparc64_TTY_H_ 36 #define KERN_sparc64_TTY_H_ 38 37 39 #include "../font.h"38 #include <genarch/ofw/ofw_tree.h> 40 39 41 extern errno_t pcf_font_create(font_t **, char *path, uint16_t points);40 extern void tty_init(ofw_tree_node_t *node); 42 41 43 42 #endif -
kernel/arch/sparc64/include/arch/mm/sun4u/as.h
r9259d20 r3e828ea 39 39 40 40 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 1 41 #define KERNEL_SEPARATE_PTL0_ARCH 0 41 42 42 43 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT64_C(0x0000000000000000) -
kernel/arch/sparc64/include/arch/mm/sun4v/as.h
r9259d20 r3e828ea 41 41 42 42 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 1 43 #define KERNEL_SEPARATE_PTL0_ARCH 0 43 44 44 45 #define KERNEL_ADDRESS_SPACE_START_ARCH UINT64_C(0x0000000000000000) -
kernel/arch/sparc64/meson.build
r9259d20 r3e828ea 27 27 # 28 28 29 COMMON_CFLAGS += -msoft-float -mno-abicalls -G 0 -fno-zero-initialized-in-bss -mabi=32 30 AS_PROLOG = .module softfloat; 31 32 BITS = 32 33 34 ## Accepted MACHINEs 35 # 36 37 ifeq ($(MACHINE),msim) 38 ENDIANESS = LE 39 COMMON_CFLAGS += -march=r4000 40 endif 41 ifeq ($(MACHINE),bmalta) 42 ENDIANESS = BE 43 COMMON_CFLAGS += -D__BE__ -march=4kc 44 endif 45 ifeq ($(MACHINE),lmalta) 46 ENDIANESS = LE 47 COMMON_CFLAGS += -march=4kc 29 if PROCESSOR == 'us' or PROCESSOR == 'us3' 30 USARCH = 'sun4u' 31 elif PROCESSOR == 'sun4v' 32 USARCH = 'sun4v' 33 else 34 error('Unknown PROCESSOR: ' + PROCESSOR) 48 35 endif 49 36 50 ARCH_SOURCES = \ 51 arch/$(KARCH)/src/start.S \ 52 arch/$(KARCH)/src/context.S \ 53 arch/$(KARCH)/src/mips32.c \ 54 arch/$(KARCH)/src/asm.S \ 55 arch/$(KARCH)/src/exception.c \ 56 arch/$(KARCH)/src/interrupt.c \ 57 arch/$(KARCH)/src/cache.c \ 58 arch/$(KARCH)/src/debugger.c \ 59 arch/$(KARCH)/src/cpu/cpu.c \ 60 arch/$(KARCH)/src/debug/stacktrace.c \ 61 arch/$(KARCH)/src/debug/stacktrace_asm.S \ 62 arch/$(KARCH)/src/mm/km.c \ 63 arch/$(KARCH)/src/mm/frame.c \ 64 arch/$(KARCH)/src/mm/page.c \ 65 arch/$(KARCH)/src/mm/tlb.c \ 66 arch/$(KARCH)/src/mm/as.c \ 67 arch/$(KARCH)/src/fpu_context.c \ 68 arch/$(KARCH)/src/smc.c \ 69 arch/$(KARCH)/src/smp/smp.c \ 70 arch/$(KARCH)/src/machine_func.c 37 arch_src += files( 38 'src/sparc64.c', 39 'src/cpu' / USARCH / 'cpu.c', 40 'src/debug/stacktrace.c', 41 'src/debug/stacktrace_asm.S', 42 'src/asm.S', 43 'src' / USARCH / 'asm.S', 44 'src/console.c', 45 'src/context.S', 46 'src/fpu_context.c', 47 'src/dummy.S', 48 'src/mm' / USARCH / 'km.c', 49 'src/mm' / USARCH / 'as.c', 50 'src/mm' / USARCH / 'frame.c', 51 'src/mm/page.c', 52 'src/mm' / USARCH / 'tlb.c', 53 'src' / USARCH / 'sparc64.c', 54 'src' / USARCH / 'start.S', 55 'src/proc' / USARCH / 'scheduler.c', 56 'src/proc/thread.c', 57 'src/smc.c', 58 'src/trap' / USARCH / 'mmu.S', 59 'src/trap' / USARCH / 'trap_table.S', 60 'src/trap/trap.c', 61 'src/trap/exception.c', 62 'src/trap/interrupt.c', 63 'src/drivers/tick.c', 64 'src/drivers/kbd.c', 65 'src/drivers/tty.c', 66 'src/drivers/pci.c', 67 'src/trap' / USARCH / 'interrupt.c', 68 ) 71 69 72 ifeq ($(MACHINE),$(filter lmalta bmalta,$(MACHINE))) 73 ARCH_SOURCES += arch/$(KARCH)/src/mach/malta/malta.c 70 if USARCH == 'sun4v' 71 arch_src += files( 72 'src/drivers/niagara.c', 73 'src/sun4v/md.c', 74 ) 74 75 endif 75 76 76 if eq ($(MACHINE),msim)77 ARCH_SOURCES += \78 arch/$(KARCH)/src/mach/msim/msim.c \79 arch/$(KARCH)/src/mach/msim/dorder.c77 if CONFIG_FB 78 arch_src += files( 79 'src/drivers/scr.c', 80 ) 80 81 endif 81 82 82 ARCH_AUTOCHECK_HEADERS = \ 83 arch/$(KARCH)/include/arch/istate_struct.h \ 84 arch/$(KARCH)/include/arch/context_struct.h \ 85 arch/$(KARCH)/include/arch/fpu_context_struct.h 83 if CONFIG_SMP 84 arch_src += files( 85 'src/smp' / USARCH / 'smp.c', 86 'src/smp' / USARCH / 'ipi.c', 87 ) 88 endif 89 90 if CONFIG_TSB 91 arch_src += files( 92 'src/mm' / USARCH / 'tsb.c', 93 ) 94 endif 95 96 97 _check_headers = [ 98 'include/arch/istate_struct.h', 99 'include/arch/context_struct.h', 100 ] 101 102 foreach h : _check_headers 103 arch_src += [ autocheck.process(h) ] 104 endforeach -
kernel/arch/sparc64/src/console.c
r9259d20 r3e828ea 37 37 #include <arch/drivers/scr.h> 38 38 #include <arch/drivers/kbd.h> 39 #include <arch/drivers/tty.h> 39 40 #include <genarch/srln/srln.h> 40 41 #include <console/chardev.h> … … 84 85 kbd_init(keyboard); 85 86 #endif 87 88 #ifdef CONFIG_SUN_TTY 89 ofw_tree_property_t *prop_tty = ofw_tree_getprop(aliases, "ttya"); 90 if (prop_tty && prop_tty->value) { 91 ofw_tree_node_t *tty = ofw_tree_lookup(prop_tty->value); 92 if (tty) 93 tty_init(tty); 94 } 95 #endif 86 96 } 87 97 -
kernel/arch/sparc64/src/drivers/kbd.c
r9259d20 r3e828ea 38 38 #include <console/console.h> 39 39 #include <ddi/irq.h> 40 #include <mm/page.h>41 #include <arch/mm/page.h>42 #include <mm/km.h>43 40 #include <typedefs.h> 44 41 #include <align.h> … … 88 85 } 89 86 90 size_t size = ((ofw_ebus_reg_t *) prop->value)->size;91 92 87 uintptr_t pa = 0; // Prevent -Werror=maybe-uninitialized 93 88 if (!ofw_ebus_apply_ranges(node->parent, … … 109 104 } 110 105 111 ioport8_t *ns16550 = (ioport8_t *) km_map(pa, size, 112 KM_NATURAL_ALIGNMENT, PAGE_WRITE | PAGE_NOT_CACHEABLE); 113 114 ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, 0, inr, cir, 115 cir_arg, NULL); 106 ns16550_instance_t *ns16550_instance = ns16550_init((ioport8_t *) pa, 0, 107 inr, cir, cir_arg, NULL); 116 108 if (ns16550_instance) { 117 109 kbrd_instance_t *kbrd_instance = kbrd_init(); -
kernel/arch/sparc64/src/mm/sun4u/tlb.c
r9259d20 r3e828ea 311 311 t.a = true; 312 312 t.d = true; 313 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_SECONDARY, 313 dtlb_demap(TLB_DEMAP_PAGE, 314 (as == AS_KERNEL) ? TLB_DEMAP_PRIMARY : TLB_DEMAP_SECONDARY, 314 315 page_16k + index * MMU_PAGE_SIZE); 315 316 dtlb_pte_copy(&t, index, false); -
kernel/arch/sparc64/src/sun4u/sparc64.c
r9259d20 r3e828ea 163 163 { 164 164 (void) interrupts_disable(); 165 switch_to_userspace( (uintptr_t)kernel_uarg->uspace_entry,166 ((uintptr_t) kernel_uarg->uspace_stack)+165 switch_to_userspace(kernel_uarg->uspace_entry, 166 kernel_uarg->uspace_stack + 167 167 kernel_uarg->uspace_stack_size - 168 168 (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 169 (uintptr_t)kernel_uarg->uspace_uarg);169 kernel_uarg->uspace_uarg); 170 170 171 171 /* Not reached */ -
kernel/arch/sparc64/src/sun4v/sparc64.c
r9259d20 r3e828ea 161 161 { 162 162 (void) interrupts_disable(); 163 switch_to_userspace( (uintptr_t)kernel_uarg->uspace_entry,164 ((uintptr_t) kernel_uarg->uspace_stack)+163 switch_to_userspace(kernel_uarg->uspace_entry, 164 kernel_uarg->uspace_stack + 165 165 kernel_uarg->uspace_stack_size - 166 166 (ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT) + STACK_BIAS), 167 (uintptr_t)kernel_uarg->uspace_uarg);167 kernel_uarg->uspace_uarg); 168 168 169 169 /* Not reached */
Note:
See TracChangeset
for help on using the changeset viewer.
