- Timestamp:
- 2010-10-19T20:55:53Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a93d79a
- Parents:
- 1882525 (diff), a7a85d16 (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. - Location:
- kernel
- Files:
-
- 1 added
- 51 edited
- 1 moved
-
Makefile (modified) (2 diffs)
-
arch/amd64/_link.ld.in (modified) (1 diff)
-
arch/amd64/include/pm.h (modified) (2 diffs)
-
arch/amd64/src/asm.S (modified) (1 diff)
-
arch/amd64/src/boot/boot.S (modified) (4 diffs)
-
arch/amd64/src/boot/vesa_ret.inc (modified) (2 diffs)
-
arch/amd64/src/ddi/ddi.c (modified) (1 diff)
-
arch/amd64/src/pm.c (modified) (2 diffs)
-
arch/amd64/src/smp/ap.S (modified) (2 diffs)
-
arch/amd64/src/syscall.c (modified) (1 diff)
-
arch/amd64/src/userspace.c (modified) (1 diff)
-
arch/arm32/include/mach/integratorcp/integratorcp.h (modified) (1 diff)
-
arch/arm32/include/mach/testarm/testarm.h (modified) (1 diff)
-
arch/arm32/include/machine_func.h (modified) (1 diff)
-
arch/arm32/src/mach/gta02/gta02.c (modified) (8 diffs)
-
arch/arm32/src/mach/integratorcp/integratorcp.c (modified) (2 diffs)
-
arch/arm32/src/mach/testarm/testarm.c (modified) (2 diffs)
-
arch/arm32/src/machine_func.c (modified) (1 diff)
-
arch/ia32/include/bios/bios.h (modified) (1 diff)
-
arch/ia32/include/mm/as.h (modified) (1 diff)
-
arch/ia32/include/mm/page.h (modified) (2 diffs)
-
arch/ia32/include/pm.h (modified) (2 diffs)
-
arch/ia32/src/asm.S (modified) (4 diffs)
-
arch/ia32/src/bios/bios.c (modified) (1 diff)
-
arch/ia32/src/boot/boot.S (modified) (3 diffs)
-
arch/ia32/src/boot/vesa_real.inc (modified) (2 diffs)
-
arch/ia32/src/boot/vesa_ret.inc (modified) (2 diffs)
-
arch/ia32/src/ddi/ddi.c (modified) (1 diff)
-
arch/ia32/src/mm/frame.c (modified) (3 diffs)
-
arch/ia32/src/pm.c (modified) (4 diffs)
-
arch/ia32/src/proc/scheduler.c (modified) (1 diff)
-
arch/ia32/src/syscall.c (modified) (1 diff)
-
arch/ia32/src/userspace.c (modified) (1 diff)
-
arch/mips32/include/context_offset.h (modified) (1 diff)
-
arch/mips32/include/exception.h (modified) (4 diffs)
-
arch/mips32/include/smp/dorder.h (moved) (moved from uspace/lib/net/include/netif_nil_bundle.h ) (2 diffs)
-
arch/mips32/src/debug/stacktrace.c (modified) (5 diffs)
-
arch/mips32/src/exception.c (modified) (2 diffs)
-
arch/mips32/src/interrupt.c (modified) (4 diffs)
-
arch/mips32/src/smp/dorder.c (modified) (1 diff)
-
arch/mips32/src/start.S (modified) (13 diffs)
-
genarch/Makefile.inc (modified) (1 diff)
-
genarch/include/drivers/s3c24xx_irqc/s3c24xx_irqc.h (modified) (2 diffs)
-
genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h (modified) (1 diff)
-
genarch/src/drivers/s3c24xx_irqc/s3c24xx_irqc.c (added)
-
genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c (modified) (7 diffs)
-
generic/include/ddi/ddi.h (modified) (1 diff)
-
generic/include/security/cap.h (modified) (1 diff)
-
generic/include/syscall/syscall.h (modified) (1 diff)
-
generic/src/ddi/ddi.c (modified) (1 diff)
-
generic/src/main/kinit.c (modified) (1 diff)
-
generic/src/mm/frame.c (modified) (2 diffs)
-
generic/src/syscall/syscall.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
r1882525 rf14291b 120 120 ifeq ($(CONFIG_LTO),y) 121 121 GCC_CFLAGS += -flto 122 endif 123 124 ifeq ($(CONFIG_LINE_DEBUG),y) 125 GCC_CFLAGS += -g 126 ICC_CFLAGS += -g 127 SUNCC_CFLAGS += -g 128 CLANG_CFLAGS += -g 122 129 endif 123 130 … … 401 408 402 409 $(DISASM): $(RAW) 410 ifeq ($(CONFIG_LINE_DEBUG),y) 411 $(OBJDUMP) -d -S $< > $@ 412 else 403 413 $(OBJDUMP) -d $< > $@ 414 endif 404 415 405 416 $(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS) -
kernel/arch/amd64/_link.ld.in
r1882525 rf14291b 53 53 } 54 54 55 #ifdef CONFIG_LINE_DEBUG 56 .comment 0 : { *(.comment); } 57 .debug_abbrev 0 : { *(.debug_abbrev); } 58 .debug_aranges 0 : { *(.debug_aranges); } 59 .debug_info 0 : { *(.debug_info); } 60 .debug_line 0 : { *(.debug_line); } 61 .debug_loc 0 : { *(.debug_loc); } 62 .debug_pubnames 0 : { *(.debug_pubnames); } 63 .debug_pubtypes 0 : { *(.debug_pubtypes); } 64 .debug_ranges 0 : { *(.debug_ranges); } 65 .debug_str 0 : { *(.debug_str); } 66 #endif 67 55 68 /DISCARD/ : { 56 69 *(*); -
kernel/arch/amd64/include/pm.h
r1882525 rf14291b 65 65 #endif /* CONFIG_FB */ 66 66 67 #define gdtselector(des) ((des) << 3) 68 #define idtselector(des) ((des) << 4) 67 #define GDT_SELECTOR(des) ((des) << 3) 69 68 70 69 #define PL_KERNEL 0 … … 168 167 169 168 extern ptr_16_64_t gdtr; 170 extern ptr_16_32_t bootstrap_gdtr;171 169 extern ptr_16_32_t protected_ap_gdtr; 172 170 -
kernel/arch/amd64/src/asm.S
r1882525 rf14291b 244 244 */ 245 245 xorq %rdx, %rdx 246 cmpq $( gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp)246 cmpq $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%rsp) 247 247 cmovnzq %rdx, %rbp 248 248 -
kernel/arch/amd64/src/boot/boot.S
r1882525 rf14291b 85 85 86 86 /* Kernel data + stack */ 87 movw $ gdtselector(KDATA_DES), %cx87 movw $GDT_SELECTOR(KDATA_DES), %cx 88 88 movw %cx, %es 89 89 movw %cx, %ds … … 94 94 * when _visible_ part of GS does not point to user-mode segment. 95 95 */ 96 movw $ gdtselector(UDATA_DES), %cx96 movw $GDT_SELECTOR(UDATA_DES), %cx 97 97 movw %cx, %fs 98 98 movw %cx, %gs 99 99 100 jmpl $ gdtselector(KTEXT32_DES), $multiboot_meeting_point100 jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot_meeting_point 101 101 multiboot_meeting_point: 102 102 … … 182 182 183 183 /* At this point we are in compatibility mode */ 184 jmpl $ gdtselector(KTEXT_DES), $start64184 jmpl $GDT_SELECTOR(KTEXT_DES), $start64 185 185 186 186 /** Print string to EGA display (in light red) and halt. … … 645 645 .section K_DATA_START, "aw", @progbits 646 646 647 .global bootstrap_gdtr648 647 bootstrap_gdtr: 649 .word gdtselector(GDT_ITEMS)648 .word GDT_SELECTOR(GDT_ITEMS) 650 649 .long KA2PA(gdt) 651 650 -
kernel/arch/amd64/src/boot/vesa_ret.inc
r1882525 rf14291b 7 7 8 8 /* Kernel data + stack */ 9 movw $ gdtselector(KDATA_DES), %cx9 movw $GDT_SELECTOR(KDATA_DES), %cx 10 10 movw %cx, %es 11 11 movw %cx, %ds … … 17 17 */ 18 18 19 movw $ gdtselector(UDATA_DES), %cx19 movw $GDT_SELECTOR(UDATA_DES), %cx 20 20 movw %cx, %fs 21 21 movw %cx, %gs 22 22 23 jmpl $ gdtselector(KTEXT32_DES), $vesa_meeting_point23 jmpl $GDT_SELECTOR(KTEXT32_DES), $vesa_meeting_point -
kernel/arch/amd64/src/ddi/ddi.c
r1882525 rf14291b 153 153 tss_descriptor_t *tss_desc = (tss_descriptor_t *) &gdt_p[TSS_DES]; 154 154 tss_desc->type = AR_TSS; 155 tr_load( gdtselector(TSS_DES));155 tr_load(GDT_SELECTOR(TSS_DES)); 156 156 157 157 /* -
kernel/arch/amd64/src/pm.c
r1882525 rf14291b 171 171 172 172 d->unused = 0; 173 d->selector = gdtselector(KTEXT_DES);173 d->selector = GDT_SELECTOR(KTEXT_DES); 174 174 175 175 d->present = 1; … … 291 291 * to its own TSS. We just need to load the TR register. 292 292 */ 293 tr_load( gdtselector(TSS_DES));293 tr_load(GDT_SELECTOR(TSS_DES)); 294 294 } 295 295 -
kernel/arch/amd64/src/smp/ap.S
r1882525 rf14291b 61 61 orl $1, %eax 62 62 movl %eax, %cr0 # switch to protected mode 63 jmpl $ gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET63 jmpl $GDT_SELECTOR(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET 64 64 65 65 jump_to_kernel: 66 66 .code32 67 movw $ gdtselector(KDATA_DES), %ax67 movw $GDT_SELECTOR(KDATA_DES), %ax 68 68 movw %ax, %ds 69 69 movw %ax, %es 70 70 movw %ax, %ss 71 movw $ gdtselector(UDATA_DES), %ax71 movw $GDT_SELECTOR(UDATA_DES), %ax 72 72 movw %ax, %gs 73 73 … … 94 94 95 95 # At this point we are in compatibility mode 96 jmpl $ gdtselector(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET96 jmpl $GDT_SELECTOR(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET 97 97 98 98 .code64 -
kernel/arch/amd64/src/syscall.c
r1882525 rf14291b 58 58 */ 59 59 write_msr(AMD_MSR_STAR, 60 ((uint64_t) (gdtselector(KDATA_DES) | PL_USER) << 48) |61 ((uint64_t) (gdtselector(KTEXT_DES) | PL_KERNEL) << 32));60 ((uint64_t) (GDT_SELECTOR(KDATA_DES) | PL_USER) << 48) | 61 ((uint64_t) (GDT_SELECTOR(KTEXT_DES) | PL_KERNEL) << 32)); 62 62 write_msr(AMD_MSR_LSTAR, (uint64_t)syscall_entry); 63 63 /* Mask RFLAGS on syscall -
kernel/arch/amd64/src/userspace.c
r1882525 rf14291b 65 65 "xorq %%rdi, %%rdi\n" 66 66 "iretq\n" 67 :: [udata_des] "i" ( gdtselector(UDATA_DES) | PL_USER),67 :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 68 68 [stack_size] "r" (kernel_uarg->uspace_stack + THREAD_STACK_SIZE), 69 69 [ipl] "r" (ipl), 70 [utext_des] "i" ( gdtselector(UTEXT_DES) | PL_USER),70 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), 71 71 [entry] "r" (kernel_uarg->uspace_entry), 72 72 [uarg] "r" (kernel_uarg->uspace_uarg) -
kernel/arch/arm32/include/mach/integratorcp/integratorcp.h
r1882525 rf14291b 105 105 extern void icp_get_memory_extents(uintptr_t *, uintptr_t *); 106 106 extern void icp_frame_init(void); 107 extern size_t icp_get_irq_count(void); 107 108 108 109 extern struct arm_machine_ops icp_machine_ops; -
kernel/arch/arm32/include/mach/testarm/testarm.h
r1882525 rf14291b 73 73 extern void gxemul_get_memory_extents(uintptr_t *, uintptr_t *); 74 74 extern void gxemul_frame_init(void); 75 extern size_t gxemul_get_irq_count(void); 75 76 76 77 extern struct arm_machine_ops gxemul_machine_ops; -
kernel/arch/arm32/include/machine_func.h
r1882525 rf14291b 55 55 void (*machine_output_init)(void); 56 56 void (*machine_input_init)(void); 57 size_t (*machine_get_irq_count)(void); 57 58 }; 58 59 -
kernel/arch/arm32/src/mach/gta02/gta02.c
r1882525 rf14291b 43 43 #include <genarch/drivers/s3c24xx_irqc/s3c24xx_irqc.h> 44 44 #include <genarch/drivers/s3c24xx_timer/s3c24xx_timer.h> 45 #include <genarch/srln/srln.h> 46 #include <sysinfo/sysinfo.h> 45 47 #include <interrupt.h> 46 48 #include <ddi/ddi.h> … … 68 70 static void gta02_output_init(void); 69 71 static void gta02_input_init(void); 72 static size_t gta02_get_irq_count(void); 70 73 71 74 static void gta02_timer_irq_init(void); … … 74 77 static void gta02_timer_irq_handler(irq_t *irq); 75 78 76 static void *gta02_scons_out;77 static s3c24xx_irqc_t *gta02_irqc;79 static outdev_t *gta02_scons_dev; 80 static s3c24xx_irqc_t gta02_irqc; 78 81 static s3c24xx_timer_t *gta02_timer; 79 82 … … 88 91 gta02_frame_init, 89 92 gta02_output_init, 90 gta02_input_init 93 gta02_input_init, 94 gta02_get_irq_count 91 95 }; 92 96 93 97 static void gta02_init(void) 94 98 { 95 gta02_scons_out = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);96 gta02_irqc = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE); 99 s3c24xx_irqc_regs_t *irqc_regs; 100 97 101 gta02_timer = (void *) hw_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE); 98 99 /* Make all interrupt sources use IRQ mode (not FIQ). */ 100 pio_write_32(>a02_irqc->intmod, 0x00000000); 101 102 /* Disable all interrupt sources. */ 103 pio_write_32(>a02_irqc->intmsk, 0xffffffff); 104 105 /* Disable interrupts from all sub-sources. */ 106 pio_write_32(>a02_irqc->intsubmsk, 0xffffffff); 102 irqc_regs = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE); 103 104 /* Initialize interrupt controller. */ 105 s3c24xx_irqc_init(>a02_irqc, irqc_regs); 107 106 } 108 107 … … 132 131 uint32_t inum; 133 132 134 inum = pio_read_32(>a02_irqc->intoffset); 133 /* Determine IRQ number. */ 134 inum = s3c24xx_irqc_inum_get(>a02_irqc); 135 136 /* Clear interrupt condition in the interrupt controller. */ 137 s3c24xx_irqc_clear(>a02_irqc, inum); 135 138 136 139 irq_t *irq = irq_dispatch_and_lock(inum); … … 144 147 CPU->id, inum); 145 148 } 146 147 /* Clear interrupt condition in the interrupt controller. */148 pio_write_32(>a02_irqc->srcpnd, S3C24XX_INT_BIT(inum));149 pio_write_32(>a02_irqc->intpnd, S3C24XX_INT_BIT(inum));150 149 } 151 150 … … 176 175 } 177 176 #endif 178 outdev_t *scons_dev; 179 180 scons_dev = s3c24xx_uart_init((ioport8_t *) gta02_scons_out); 181 if (scons_dev) 182 stdout_wire(scons_dev); 177 178 /* Initialize serial port of the debugging console. */ 179 s3c24xx_uart_io_t *scons_io; 180 181 scons_io = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE); 182 gta02_scons_dev = s3c24xx_uart_init(scons_io, S3C24XX_INT_UART2); 183 184 if (gta02_scons_dev) { 185 /* Create output device. */ 186 stdout_wire(gta02_scons_dev); 187 } 188 189 /* 190 * This is the necessary evil until the userspace driver is entirely 191 * self-sufficient. 192 */ 193 sysinfo_set_item_val("s3c24xx_uart", NULL, true); 194 sysinfo_set_item_val("s3c24xx_uart.inr", NULL, S3C24XX_INT_UART2); 195 sysinfo_set_item_val("s3c24xx_uart.address.physical", NULL, 196 (uintptr_t) GTA02_SCONS_BASE); 197 183 198 } 184 199 185 200 static void gta02_input_init(void) 186 201 { 202 s3c24xx_uart_t *scons_inst; 203 204 if (gta02_scons_dev) { 205 /* Create input device. */ 206 scons_inst = (void *) gta02_scons_dev->data; 207 208 srln_instance_t *srln_instance = srln_init(); 209 if (srln_instance) { 210 indev_t *sink = stdin_wire(); 211 indev_t *srln = srln_wire(srln_instance, sink); 212 s3c24xx_uart_input_wire(scons_inst, srln); 213 214 /* Enable interrupts from UART2 */ 215 s3c24xx_irqc_src_enable(>a02_irqc, 216 S3C24XX_INT_UART2); 217 218 /* Enable interrupts from UART2 RXD */ 219 s3c24xx_irqc_subsrc_enable(>a02_irqc, 220 S3C24XX_SUBINT_RXD2); 221 } 222 } 223 224 /* Enable interrupts from ADC */ 225 s3c24xx_irqc_src_enable(>a02_irqc, S3C24XX_INT_ADC); 226 227 /* Enable interrupts from ADC sub-sources */ 228 s3c24xx_irqc_subsrc_enable(>a02_irqc, S3C24XX_SUBINT_ADC_S); 229 s3c24xx_irqc_subsrc_enable(>a02_irqc, S3C24XX_SUBINT_TC); 230 } 231 232 size_t gta02_get_irq_count(void) 233 { 234 return GTA02_IRQ_COUNT; 187 235 } 188 236 … … 248 296 249 297 /* Enable interrupts from timer0 */ 250 pio_write_32(>a02_irqc->intmsk, pio_read_32(>a02_irqc->intmsk) & 251 ~S3C24XX_INT_BIT(S3C24XX_INT_TIMER0)); 298 s3c24xx_irqc_src_enable(>a02_irqc, S3C24XX_INT_TIMER0); 252 299 253 300 /* Load data from tcntb0/tcmpb0 into tcnt0/tcmp0. */ -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
r1882525 rf14291b 64 64 icp_frame_init, 65 65 icp_output_init, 66 icp_input_init 66 icp_input_init, 67 icp_get_irq_count 67 68 }; 68 69 … … 336 337 } 337 338 339 size_t icp_get_irq_count(void) 340 { 341 return ICP_IRQ_COUNT; 342 } 338 343 339 344 /** @} -
kernel/arch/arm32/src/mach/testarm/testarm.c
r1882525 rf14291b 64 64 gxemul_frame_init, 65 65 gxemul_output_init, 66 gxemul_input_init 66 gxemul_input_init, 67 gxemul_get_irq_count 67 68 }; 68 69 … … 126 127 } 127 128 129 size_t gxemul_get_irq_count(void) 130 { 131 return GXEMUL_IRQ_COUNT; 132 } 133 128 134 /** Starts gxemul Real Time Clock device, which asserts regular interrupts. 129 135 * -
kernel/arch/arm32/src/machine_func.c
r1882525 rf14291b 128 128 size_t machine_get_irq_count(void) 129 129 { 130 size_t irq_count; 131 132 #if defined(MACHINE_gta02) 133 irq_count = GTA02_IRQ_COUNT; 134 #elif defined(MACHINE_testarm) 135 irq_count = GXEMUL_IRQ_COUNT; 136 #elif defined(MACHINE_integratorcp) 137 irq_count = ICP_IRQ_COUNT; 138 #else 139 #error Machine type not defined. 140 #endif 141 return irq_count; 130 return (machine_ops->machine_get_irq_count)(); 142 131 } 143 132 -
kernel/arch/ia32/include/bios/bios.h
r1882525 rf14291b 38 38 #include <typedefs.h> 39 39 40 #define BIOS_EBDA_PTR 0x40e41 42 40 extern uintptr_t ebda; 43 41 -
kernel/arch/ia32/include/mm/as.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ -
kernel/arch/ia32/include/mm/page.h
r1882525 rf14291b 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ … … 106 106 107 107 /* Set PTE flags accessors for each level. */ 108 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \108 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x) \ 109 109 set_pt_flags((pte_t *) (ptl0), (size_t) (i), (x)) 110 110 #define SET_PTL2_FLAGS_ARCH(ptl1, i, x) -
kernel/arch/ia32/include/pm.h
r1882525 rf14291b 58 58 #endif /* CONFIG_FB */ 59 59 60 #define gdtselector(des) ((des) << 3)60 #define GDT_SELECTOR(des) ((des) << 3) 61 61 62 62 #define PL_KERNEL 0 … … 153 153 154 154 extern ptr_16_32_t gdtr; 155 extern ptr_16_32_t bootstrap_gdtr;156 155 extern ptr_16_32_t protected_ap_gdtr; 157 156 extern tss_t *tss_p; -
kernel/arch/ia32/src/asm.S
r1882525 rf14291b 225 225 * Switch to kernel selectors. 226 226 */ 227 movw $( gdtselector(KDATA_DES)), %ax227 movw $(GDT_SELECTOR(KDATA_DES)), %ax 228 228 movw %ax, %ds 229 229 movw %ax, %es … … 304 304 * Switch to kernel selectors. 305 305 */ 306 movl $( gdtselector(KDATA_DES)), %eax306 movl $(GDT_SELECTOR(KDATA_DES)), %eax 307 307 movl %eax, %ds 308 308 movl %eax, %es … … 407 407 * Switch to kernel selectors. 408 408 */ 409 movl $( gdtselector(KDATA_DES)), %eax409 movl $(GDT_SELECTOR(KDATA_DES)), %eax 410 410 movl %eax, %ds 411 411 movl %eax, %es … … 416 416 */ 417 417 xorl %eax, %eax 418 cmpl $( gdtselector(KTEXT_DES)), ISTATE_OFFSET_CS(%esp)418 cmpl $(GDT_SELECTOR(KTEXT_DES)), ISTATE_OFFSET_CS(%esp) 419 419 cmovnzl %eax, %ebp 420 420 -
kernel/arch/ia32/src/bios/bios.c
r1882525 rf14291b 36 36 #include <typedefs.h> 37 37 38 #define BIOS_EBDA_PTR 0x40e 39 38 40 uintptr_t ebda = 0; 39 41 -
kernel/arch/ia32/src/boot/boot.S
r1882525 rf14291b 78 78 79 79 /* Initialize Global Descriptor Table register */ 80 lgdtl KA2PA(bootstrap_gdtr)80 lgdtl bootstrap_gdtr 81 81 82 82 /* Kernel data + stack */ 83 movw $ gdtselector(KDATA_DES), %cx83 movw $GDT_SELECTOR(KDATA_DES), %cx 84 84 movw %cx, %es 85 85 movw %cx, %fs … … 88 88 movw %cx, %ss 89 89 90 jmpl $ gdtselector(KTEXT_DES), $multiboot_meeting_point90 jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot_meeting_point 91 91 multiboot_meeting_point: 92 92 … … 514 514 page_directory: 515 515 .space 4096, 0 516 517 bootstrap_gdtr: 518 .word GDT_SELECTOR(GDT_ITEMS) 519 .long KA2PA(gdt) 516 520 517 521 grub_eax: -
kernel/arch/ia32/src/boot/vesa_real.inc
r1882525 rf14291b 30 30 .code32 31 31 vesa_init: 32 jmp $ gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init32 jmp $GDT_SELECTOR(VESA_INIT_DES), $vesa_init_real - vesa_init 33 33 34 34 .code16 … … 335 335 vesa_leave_real2: 336 336 337 ljmpl $ gdtselector(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4)337 ljmpl $GDT_SELECTOR(KTEXT32_DES), $(vesa_init_protected - vesa_init + VESA_INIT_SEGMENT << 4) 338 338 339 339 no_mode: -
kernel/arch/ia32/src/boot/vesa_ret.inc
r1882525 rf14291b 7 7 8 8 /* Kernel data + stack */ 9 movw $ gdtselector(KDATA_DES), %cx9 movw $GDT_SELECTOR(KDATA_DES), %cx 10 10 movw %cx, %es 11 11 movw %cx, %fs … … 14 14 movw %cx, %ss 15 15 16 jmpl $ gdtselector(KTEXT_DES), $vesa_meeting_point16 jmpl $GDT_SELECTOR(KTEXT_DES), $vesa_meeting_point -
kernel/arch/ia32/src/ddi/ddi.c
r1882525 rf14291b 153 153 */ 154 154 gdt_p[TSS_DES].access = AR_PRESENT | AR_TSS | DPL_KERNEL; 155 tr_load( gdtselector(TSS_DES));155 tr_load(GDT_SELECTOR(TSS_DES)); 156 156 157 157 /* -
kernel/arch/ia32/src/mm/frame.c
r1882525 rf14291b 131 131 if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE)) 132 132 last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE); 133 } 134 135 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) { 133 } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) || 134 (e820table[i].type == MEMMAP_MEMORY_NVS)) { 135 /* To be safe, make the firmware zone possibly larger */ 136 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 137 uint64_t new_size = ALIGN_UP(size + (base - new_base), 138 FRAME_SIZE); 139 140 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 141 ZONE_FIRMWARE); 142 } else { 136 143 /* To be safe, make the reserved zone possibly larger */ 137 144 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); … … 141 148 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 142 149 ZONE_RESERVED); 143 }144 145 if (e820table[i].type == MEMMAP_MEMORY_ACPI) {146 /* To be safe, make the firmware zone possibly larger */147 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);148 uint64_t new_size = ALIGN_UP(size + (base - new_base),149 FRAME_SIZE);150 151 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,152 ZONE_FIRMWARE);153 150 } 154 151 } … … 203 200 #ifdef CONFIG_SMP 204 201 /* Reserve AP real mode bootstrap memory */ 205 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 202 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 206 203 (hardcoded_unmapped_ktext_size + 207 204 hardcoded_unmapped_kdata_size) >> FRAME_WIDTH); -
kernel/arch/ia32/src/pm.c
r1882525 rf14291b 75 75 /* VESA Init descriptor */ 76 76 #ifdef CONFIG_FB 77 { 0xffff, 0, VESA_INIT_SEGMENT >>12, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }78 #endif 77 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 } 78 #endif 79 79 }; 80 80 … … 86 86 87 87 /* gdtr is changed by kmp before next CPU is initialized */ 88 ptr_16_32_t bootstrap_gdtr = { .limit = sizeof(gdt), .base = KA2PA((uintptr_t) gdt) }; 89 ptr_16_32_t gdtr = { .limit = sizeof(gdt), .base = (uintptr_t) gdt }; 88 ptr_16_32_t gdtr = { 89 .limit = sizeof(gdt), 90 .base = (uintptr_t) gdt 91 }; 90 92 91 93 void gdt_setbase(descriptor_t *d, uintptr_t base) … … 128 130 129 131 d->unused = 0; 130 d->selector = gdtselector(KTEXT_DES);132 d->selector = GDT_SELECTOR(KTEXT_DES); 131 133 132 134 if (i == VECTOR_SYSCALL) { … … 283 285 * to its own TSS. We just need to load the TR register. 284 286 */ 285 tr_load( gdtselector(TSS_DES));287 tr_load(GDT_SELECTOR(TSS_DES)); 286 288 287 289 clean_IOPL_NT_flags(); /* Disable I/O on nonprivileged levels and clear NT flag. */ -
kernel/arch/ia32/src/proc/scheduler.c
r1882525 rf14291b 67 67 /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */ 68 68 CPU->arch.tss->esp0 = kstk; 69 CPU->arch.tss->ss0 = gdtselector(KDATA_DES);69 CPU->arch.tss->ss0 = GDT_SELECTOR(KDATA_DES); 70 70 71 71 /* Set up TLS in GS register */ -
kernel/arch/ia32/src/syscall.c
r1882525 rf14291b 45 45 46 46 /* set kernel mode CS selector */ 47 write_msr(IA32_MSR_SYSENTER_CS, gdtselector(KTEXT_DES));47 write_msr(IA32_MSR_SYSENTER_CS, GDT_SELECTOR(KTEXT_DES)); 48 48 /* set kernel mode entry point */ 49 49 write_msr(IA32_MSR_SYSENTER_EIP, (uint32_t) sysenter_handler); -
kernel/arch/ia32/src/userspace.c
r1882525 rf14291b 75 75 "iret\n" 76 76 : 77 : [udata_des] "i" ( gdtselector(UDATA_DES) | PL_USER),77 : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 78 78 [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE), 79 79 [ipl] "r" (ipl), 80 [utext_des] "i" ( gdtselector(UTEXT_DES) | PL_USER),80 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), 81 81 [entry] "r" (kernel_uarg->uspace_entry), 82 82 [uarg] "r" (kernel_uarg->uspace_uarg), 83 [tls_des] "r" ( gdtselector(TLS_DES))83 [tls_des] "r" (GDT_SELECTOR(TLS_DES)) 84 84 : "eax"); 85 85 -
kernel/arch/mips32/include/context_offset.h
r1882525 rf14291b 60 60 # define OFFSET_F30 0x5c 61 61 #endif /* KERNEL */ 62 63 /* istate_t */64 #define EOFFSET_AT 0x065 #define EOFFSET_V0 0x466 #define EOFFSET_V1 0x867 #define EOFFSET_A0 0xc68 #define EOFFSET_A1 0x1069 #define EOFFSET_A2 0x1470 #define EOFFSET_A3 0x1871 #define EOFFSET_T0 0x1c72 #define EOFFSET_T1 0x2073 #define EOFFSET_T2 0x2474 #define EOFFSET_T3 0x2875 #define EOFFSET_T4 0x2c76 #define EOFFSET_T5 0x3077 #define EOFFSET_T6 0x3478 #define EOFFSET_T7 0x3879 #define EOFFSET_T8 0x3c80 #define EOFFSET_T9 0x4081 #define EOFFSET_GP 0x4482 #define EOFFSET_SP 0x4883 #define EOFFSET_RA 0x4c84 #define EOFFSET_LO 0x5085 #define EOFFSET_HI 0x5486 #define EOFFSET_STATUS 0x5887 #define EOFFSET_EPC 0x5c88 #define EOFFSET_K1 0x6089 #define REGISTER_SPACE 104 /* respect stack alignment */90 62 91 63 #ifdef __ASM__ -
kernel/arch/mips32/include/exception.h
r1882525 rf14291b 60 60 61 61 typedef struct istate { 62 /* 63 * The first seven registers are arranged so that the istate structure 64 * can be used both for exception handlers and for the syscall handler. 65 */ 66 uint32_t a0; /* arg1 */ 67 uint32_t a1; /* arg2 */ 68 uint32_t a2; /* arg3 */ 69 uint32_t a3; /* arg4 */ 70 uint32_t t0; /* arg5 */ 71 uint32_t t1; /* arg6 */ 72 uint32_t v0; /* arg7 */ 73 uint32_t v1; 62 74 uint32_t at; 63 uint32_t v0;64 uint32_t v1;65 uint32_t a0;66 uint32_t a1;67 uint32_t a2;68 uint32_t a3;69 uint32_t t0;70 uint32_t t1;71 75 uint32_t t2; 72 76 uint32_t t3; … … 75 79 uint32_t t6; 76 80 uint32_t t7; 81 uint32_t s0; 82 uint32_t s1; 83 uint32_t s2; 84 uint32_t s3; 85 uint32_t s4; 86 uint32_t s5; 87 uint32_t s6; 88 uint32_t s7; 77 89 uint32_t t8; 78 90 uint32_t t9; 91 uint32_t kt0; 92 uint32_t kt1; /* We use it as thread-local pointer */ 79 93 uint32_t gp; 80 94 uint32_t sp; 95 uint32_t s8; 81 96 uint32_t ra; 82 97 … … 84 99 uint32_t hi; 85 100 86 uint32_t status; /* cp0_status */ 87 uint32_t epc; /* cp0_epc */ 88 uint32_t k1; /* We use it as thread-local pointer */ 101 uint32_t status; /* cp0_status */ 102 uint32_t epc; /* cp0_epc */ 103 104 uint32_t alignment; /* to make sizeof(istate_t) a multiple of 8 */ 89 105 } istate_t; 90 106 … … 108 124 NO_TRACE static inline unative_t istate_get_fp(istate_t *istate) 109 125 { 110 /* FIXME */ 111 112 return 0; 126 return istate->sp; 113 127 } 114 128 -
kernel/arch/mips32/include/smp/dorder.h
r1882525 rf14291b 1 1 /* 2 * Copyright (c) 20 10Martin Decky2 * Copyright (c) 2007 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup netif_standalone 30 * @{ 29 /** @addtogroup mips32 30 * @{ 31 */ 32 /** @file 31 33 */ 32 34 33 #ifndef __NETIF_NIL_BUNDLE_H__34 #define __NETIF_NIL_BUNDLE_H__35 #ifndef KERN_mips32_DORDER_H_ 36 #define KERN_mips32_DORDER_H_ 35 37 36 #include <ipc/ipc.h> 37 #include <async.h> 38 #include <typedefs.h> 38 39 39 extern int netif_nil_module_message(const char *, ipc_callid_t, ipc_call_t *, 40 ipc_call_t *, int *); 41 extern int netif_nil_module_start(async_client_conn_t); 40 extern uint32_t dorder_cpuid(void); 41 extern void dorder_ipi_ack(uint32_t); 42 42 43 43 #endif -
kernel/arch/mips32/src/debug/stacktrace.c
r1882525 rf14291b 31 31 */ 32 32 /** @file 33 */ 34 35 /* 36 * This stack tracing code is based on the suggested algorithm described on page 37 * 3-27 and 3-28 of: 38 * 39 * SYSTEM V 40 * APPLICATION BINARY INTERFACE 41 * 42 * MIPS RISC Processor 43 * Supplement 44 * 3rd Edition 45 * 46 * Unfortunately, GCC generates code which is not entirely compliant with this 47 * method. For example, it places the "jr ra" instruction quite arbitrarily in 48 * the middle of the function which makes the original algorithm unapplicable. 49 * 50 * We deal with this problem by simply not using those parts of the algorithm 51 * that rely on the "jr ra" instruction occurring in the last basic block of a 52 * function, which gives us still usable, but less reliable stack tracer. The 53 * unreliability stems from the fact that under some circumstances it can become 54 * confused and produce incorrect or incomplete stack trace. We apply extra 55 * sanity checks so that the algorithm is still safe and should not crash the 56 * system. 57 * 58 * Even though not perfect, our solution is pretty lightweight, especially when 59 * compared with a prospective alternative solution based on additional 60 * debugging information stored directly in the kernel image. 33 61 */ 34 62 … … 96 124 extern char ktext_end; 97 125 126 static bool bounds_check(uintptr_t pc) 127 { 128 return (pc >= (uintptr_t) &ktext_start) && 129 (pc < (uintptr_t) &ktext_end); 130 } 131 98 132 static bool 99 133 scan(stack_trace_context_t *ctx, uintptr_t *prev_fp, uintptr_t *prev_ra) … … 106 140 do { 107 141 inst--; 142 if (!bounds_check((uintptr_t) inst)) 143 return false; 108 144 #if 0 109 145 /* … … 180 216 return false; 181 217 /* too big offsets are suspicious */ 182 if ( offset > 32 * 4)218 if ((size_t) offset > sizeof(istate_t)) 183 219 return false; 184 220 … … 207 243 { 208 244 return !((ctx->fp == 0) || ((ctx->fp % 8) != 0) || 209 (ctx->pc % 4 != 0) || (ctx->pc < (uintptr_t) &ktext_start) || 210 (ctx->pc >= (uintptr_t) &ktext_end)); 245 (ctx->pc % 4 != 0) || !bounds_check(ctx->pc)); 211 246 } 212 247 -
kernel/arch/mips32/src/exception.c
r1882525 rf14291b 74 74 void istate_decode(istate_t *istate) 75 75 { 76 printf("at=%p\tv0=%p\tv1=%p\n", istate->at, istate->v0, istate->v1); 77 printf("a0=%p\ta1=%p\ta2=%p\n", istate->a0, istate->a1, istate->a2); 78 printf("a3=%p\tt0=%p\tt1=%p\n", istate->a3, istate->t0, istate->t1); 79 printf("t2=%p\tt3=%p\tt4=%p\n", istate->t2, istate->t3, istate->t4); 80 printf("t5=%p\tt6=%p\tt7=%p\n", istate->t5, istate->t6, istate->t7); 81 printf("t8=%p\tt9=%p\tgp=%p\n", istate->t8, istate->t9, istate->gp); 82 printf("sp=%p\tra=%p\t\n", istate->sp, istate->ra); 83 printf("lo=%p\thi=%p\t\n", istate->lo, istate->hi); 84 printf("cp0_status=%p\tcp0_epc=%p\tk1=%p\n", 85 istate->status, istate->epc, istate->k1); 76 printf("epc=%p\tsta=%p\tlo =%p\thi =%p\n", 77 istate->epc, istate->status, istate->lo, istate->hi); 78 printf("a0 =%p\ta1 =%p\ta2 =%p\ta3 =%p\n", 79 istate->a0, istate->a1, istate->a2, istate->a3); 80 printf("t0 =%p\tt1 =%p\tt2 =%p\tt3 =%p\n", 81 istate->t0, istate->t1, istate->t2, istate->t3); 82 printf("t4 =%p\tt5 =%p\tt6 =%p\tt7 =%p\n", 83 istate->t4, istate->t5, istate->t6, istate->t7); 84 printf("t8 =%p\tt9 =%p\tv0 =%p\tv1 =%p\n", 85 istate->t8, istate->t9, istate->v0, istate->v1); 86 printf("s0 =%p\ts1 =%p\ts2 =%p\ts3 =%p\n", 87 istate->s0, istate->s1, istate->s2, istate->s3); 88 printf("s4 =%p\ts5 =%p\ts6 =%p\ts7 =%p\n", 89 istate->s4, istate->s5, istate->s6, istate->s7); 90 printf("s8 =%p\tat =%p\tkt0=%p\tkt1=%p\n", 91 istate->s8, istate->at, istate->kt0, istate->kt1); 92 printf("sp =%p\tra =%p\tgp =%p\n", 93 istate->sp, istate->ra, istate->gp); 86 94 } 87 95 … … 97 105 ASSERT(THREAD); 98 106 istate->epc += 4; 99 istate->v1 = istate->k 1;107 istate->v1 = istate->kt1; 100 108 } else 101 109 unhandled_exception(n, istate); -
kernel/arch/mips32/src/interrupt.c
r1882525 rf14291b 38 38 #include <arch.h> 39 39 #include <arch/cp0.h> 40 #include <arch/smp/dorder.h> 40 41 #include <time/clock.h> 41 42 #include <ipc/sysipc.h> … … 48 49 function virtual_timer_fnc = NULL; 49 50 static irq_t timer_irq; 51 static irq_t dorder_irq; 50 52 51 53 // TODO: This is SMP unsafe!!! … … 149 151 } 150 152 153 static irq_ownership_t dorder_claim(irq_t *irq) 154 { 155 return IRQ_ACCEPT; 156 } 157 158 static void dorder_irq_handler(irq_t *irq) 159 { 160 dorder_ipi_ack(1 << dorder_cpuid()); 161 } 162 151 163 /* Initialize basic tables for exception dispatching */ 152 164 void interrupt_init(void) … … 163 175 timer_start(); 164 176 cp0_unmask_int(TIMER_IRQ); 177 178 irq_initialize(&dorder_irq); 179 dorder_irq.devno = device_assign_devno(); 180 dorder_irq.inr = DORDER_IRQ; 181 dorder_irq.claim = dorder_claim; 182 dorder_irq.handler = dorder_irq_handler; 183 irq_register(&dorder_irq); 184 185 cp0_unmask_int(DORDER_IRQ); 165 186 } 166 187 -
kernel/arch/mips32/src/smp/dorder.c
r1882525 rf14291b 33 33 */ 34 34 35 #include <typedefs.h> 35 36 #include <smp/ipi.h> 37 #include <arch/smp/dorder.h> 38 39 #define MSIM_DORDER_ADDRESS 0xB0000004 36 40 37 41 #ifdef CONFIG_SMP 38 42 39 #define MSIM_DORDER_ADDRESS 0xB000000440 41 43 void ipi_broadcast_arch(int ipi) 42 44 { 43 *((volatile u nsigned int *) MSIM_DORDER_ADDRESS) = 0x7FFFFFFF;45 *((volatile uint32_t *) MSIM_DORDER_ADDRESS) = 0x7fffffff; 44 46 } 45 47 46 48 #endif 47 49 50 uint32_t dorder_cpuid(void) 51 { 52 return *((volatile uint32_t *) MSIM_DORDER_ADDRESS); 53 } 54 55 void dorder_ipi_ack(uint32_t mask) 56 { 57 *((volatile uint32_t *) (MSIM_DORDER_ADDRESS + 4)) = mask; 58 } 59 48 60 /** @} 49 61 */ -
kernel/arch/mips32/src/start.S
r1882525 rf14291b 46 46 47 47 /* 48 * Which status bits shouldare thread-local:48 * Which status bits are thread-local: 49 49 * KSU(UM), EXL, ERL, IE 50 50 */ 51 51 #define REG_SAVE_MASK 0x1f 52 53 #define ISTATE_OFFSET_A0 0 54 #define ISTATE_OFFSET_A1 4 55 #define ISTATE_OFFSET_A2 8 56 #define ISTATE_OFFSET_A3 12 57 #define ISTATE_OFFSET_T0 16 58 #define ISTATE_OFFSET_T1 20 59 #define ISTATE_OFFSET_V0 24 60 #define ISTATE_OFFSET_V1 28 61 #define ISTATE_OFFSET_AT 32 62 #define ISTATE_OFFSET_T2 36 63 #define ISTATE_OFFSET_T3 40 64 #define ISTATE_OFFSET_T4 44 65 #define ISTATE_OFFSET_T5 48 66 #define ISTATE_OFFSET_T6 52 67 #define ISTATE_OFFSET_T7 56 68 #define ISTATE_OFFSET_S0 60 69 #define ISTATE_OFFSET_S1 64 70 #define ISTATE_OFFSET_S2 68 71 #define ISTATE_OFFSET_S3 72 72 #define ISTATE_OFFSET_S4 76 73 #define ISTATE_OFFSET_S5 80 74 #define ISTATE_OFFSET_S6 84 75 #define ISTATE_OFFSET_S7 88 76 #define ISTATE_OFFSET_T8 92 77 #define ISTATE_OFFSET_T9 96 78 #define ISTATE_OFFSET_KT0 100 79 #define ISTATE_OFFSET_KT1 104 80 #define ISTATE_OFFSET_GP 108 81 #define ISTATE_OFFSET_SP 112 82 #define ISTATE_OFFSET_S8 116 83 #define ISTATE_OFFSET_RA 120 84 #define ISTATE_OFFSET_LO 124 85 #define ISTATE_OFFSET_HI 128 86 #define ISTATE_OFFSET_STATUS 132 87 #define ISTATE_OFFSET_EPC 136 88 #define ISTATE_OFFSET_ALIGNMENT 140 89 90 #define ISTATE_SOFT_SIZE 144 91 92 /* 93 * The fake ABI prologue is never executed and may not be part of the 94 * procedure's body. Instead, it should be immediately preceding the procedure's 95 * body. Its only purpose is to trick the stack trace walker into thinking that 96 * the exception is more or less just a normal function call. 97 */ 98 .macro FAKE_ABI_PROLOGUE 99 sub $sp, ISTATE_SOFT_SIZE 100 sw $ra, ISTATE_OFFSET_EPC($sp) 101 .endm 52 102 53 103 /* … … 58 108 */ 59 109 .macro REGISTERS_STORE_AND_EXC_RESET r 60 sw $at, EOFFSET_AT(\r) 61 sw $v0, EOFFSET_V0(\r) 62 sw $v1, EOFFSET_V1(\r) 63 sw $a0, EOFFSET_A0(\r) 64 sw $a1, EOFFSET_A1(\r) 65 sw $a2, EOFFSET_A2(\r) 66 sw $a3, EOFFSET_A3(\r) 67 sw $t0, EOFFSET_T0(\r) 68 sw $t1, EOFFSET_T1(\r) 69 sw $t2, EOFFSET_T2(\r) 70 sw $t3, EOFFSET_T3(\r) 71 sw $t4, EOFFSET_T4(\r) 72 sw $t5, EOFFSET_T5(\r) 73 sw $t6, EOFFSET_T6(\r) 74 sw $t7, EOFFSET_T7(\r) 75 sw $t8, EOFFSET_T8(\r) 76 sw $t9, EOFFSET_T9(\r) 110 sw $at, ISTATE_OFFSET_AT(\r) 111 sw $v0, ISTATE_OFFSET_V0(\r) 112 sw $v1, ISTATE_OFFSET_V1(\r) 113 sw $a0, ISTATE_OFFSET_A0(\r) 114 sw $a1, ISTATE_OFFSET_A1(\r) 115 sw $a2, ISTATE_OFFSET_A2(\r) 116 sw $a3, ISTATE_OFFSET_A3(\r) 117 sw $t0, ISTATE_OFFSET_T0(\r) 118 sw $t1, ISTATE_OFFSET_T1(\r) 119 sw $t2, ISTATE_OFFSET_T2(\r) 120 sw $t3, ISTATE_OFFSET_T3(\r) 121 sw $t4, ISTATE_OFFSET_T4(\r) 122 sw $t5, ISTATE_OFFSET_T5(\r) 123 sw $t6, ISTATE_OFFSET_T6(\r) 124 sw $t7, ISTATE_OFFSET_T7(\r) 125 sw $t8, ISTATE_OFFSET_T8(\r) 126 sw $t9, ISTATE_OFFSET_T9(\r) 127 sw $s0, ISTATE_OFFSET_S0(\r) 128 sw $s1, ISTATE_OFFSET_S1(\r) 129 sw $s2, ISTATE_OFFSET_S2(\r) 130 sw $s3, ISTATE_OFFSET_S3(\r) 131 sw $s4, ISTATE_OFFSET_S4(\r) 132 sw $s5, ISTATE_OFFSET_S5(\r) 133 sw $s6, ISTATE_OFFSET_S6(\r) 134 sw $s7, ISTATE_OFFSET_S7(\r) 135 sw $s8, ISTATE_OFFSET_S8(\r) 77 136 78 137 mflo $at 79 sw $at, EOFFSET_LO(\r)138 sw $at, ISTATE_OFFSET_LO(\r) 80 139 mfhi $at 81 sw $at, EOFFSET_HI(\r) 82 83 sw $gp, EOFFSET_GP(\r) 84 sw $ra, EOFFSET_RA(\r) 85 sw $k1, EOFFSET_K1(\r) 140 sw $at, ISTATE_OFFSET_HI(\r) 141 142 sw $gp, ISTATE_OFFSET_GP(\r) 143 sw $ra, ISTATE_OFFSET_RA(\r) 144 sw $k0, ISTATE_OFFSET_KT0(\r) 145 sw $k1, ISTATE_OFFSET_KT1(\r) 86 146 87 147 mfc0 $t0, $status … … 95 155 and $t0, $t0, $t3 96 156 97 sw $t2, EOFFSET_STATUS(\r)98 sw $t1, EOFFSET_EPC(\r)157 sw $t2, ISTATE_OFFSET_STATUS(\r) 158 sw $t1, ISTATE_OFFSET_EPC(\r) 99 159 mtc0 $t0, $status 100 160 .endm … … 106 166 */ 107 167 mfc0 $t0, $status 108 lw $t1, EOFFSET_STATUS(\r)168 lw $t1, ISTATE_OFFSET_STATUS(\r) 109 169 110 170 /* mask UM, EXL, ERL, IE */ … … 116 176 mtc0 $t0, $status 117 177 118 lw $v0, EOFFSET_V0(\r)119 lw $v1, EOFFSET_V1(\r)120 lw $a0, EOFFSET_A0(\r)121 lw $a1, EOFFSET_A1(\r)122 lw $a2, EOFFSET_A2(\r)123 lw $a3, EOFFSET_A3(\r)124 lw $t0, EOFFSET_T0(\r)125 lw $t1, EOFFSET_T1(\r)126 lw $t2, EOFFSET_T2(\r)127 lw $t3, EOFFSET_T3(\r)128 lw $t4, EOFFSET_T4(\r)129 lw $t5, EOFFSET_T5(\r)130 lw $t6, EOFFSET_T6(\r)131 lw $t7, EOFFSET_T7(\r)132 lw $t8, EOFFSET_T8(\r)133 lw $t9, EOFFSET_T9(\r)134 135 lw $gp, EOFFSET_GP(\r)136 lw $ra, EOFFSET_RA(\r)137 lw $k1, EOFFSET_K1(\r)138 139 lw $at, EOFFSET_LO(\r)178 lw $v0, ISTATE_OFFSET_V0(\r) 179 lw $v1, ISTATE_OFFSET_V1(\r) 180 lw $a0, ISTATE_OFFSET_A0(\r) 181 lw $a1, ISTATE_OFFSET_A1(\r) 182 lw $a2, ISTATE_OFFSET_A2(\r) 183 lw $a3, ISTATE_OFFSET_A3(\r) 184 lw $t0, ISTATE_OFFSET_T0(\r) 185 lw $t1, ISTATE_OFFSET_T1(\r) 186 lw $t2, ISTATE_OFFSET_T2(\r) 187 lw $t3, ISTATE_OFFSET_T3(\r) 188 lw $t4, ISTATE_OFFSET_T4(\r) 189 lw $t5, ISTATE_OFFSET_T5(\r) 190 lw $t6, ISTATE_OFFSET_T6(\r) 191 lw $t7, ISTATE_OFFSET_T7(\r) 192 lw $t8, ISTATE_OFFSET_T8(\r) 193 lw $t9, ISTATE_OFFSET_T9(\r) 194 195 lw $gp, ISTATE_OFFSET_GP(\r) 196 lw $ra, ISTATE_OFFSET_RA(\r) 197 lw $k1, ISTATE_OFFSET_KT1(\r) 198 199 lw $at, ISTATE_OFFSET_LO(\r) 140 200 mtlo $at 141 lw $at, EOFFSET_HI(\r)201 lw $at, ISTATE_OFFSET_HI(\r) 142 202 mthi $at 143 203 144 lw $at, EOFFSET_EPC(\r)204 lw $at, ISTATE_OFFSET_EPC(\r) 145 205 mtc0 $at, $epc 146 206 147 lw $at, EOFFSET_AT(\r)148 lw $sp, EOFFSET_SP(\r)207 lw $at, ISTATE_OFFSET_AT(\r) 208 lw $sp, ISTATE_OFFSET_SP(\r) 149 209 .endm 150 210 … … 159 219 160 220 beq $k0, $0, 1f 161 add $k0, $sp, 0221 move $k0, $sp 162 222 163 223 /* move $k0 pointer to kernel stack */ … … 166 226 167 227 /* move $k0 (supervisor_sp) */ 168 lw $k0, 0($k0)228 lw $k0, ($k0) 169 229 170 230 1: … … 202 262 nop 203 263 264 FAKE_ABI_PROLOGUE 204 265 exception_handler: 205 266 KERNEL_STACK_TO_K0 206 267 207 sub $k0, REGISTER_SPACE208 sw $sp, EOFFSET_SP($k0)268 sub $k0, ISTATE_SOFT_SIZE 269 sw $sp, ISTATE_OFFSET_SP($k0) 209 270 move $sp, $k0 210 271 … … 227 288 /* the $sp is automatically restored to former value */ 228 289 eret 229 230 #define SS_SP EOFFSET_SP231 #define SS_STATUS EOFFSET_STATUS232 #define SS_EPC EOFFSET_EPC233 #define SS_K1 EOFFSET_K1234 290 235 291 /** Syscall entry … … 249 305 */ 250 306 syscall_shortcut: 251 /* we have a lot of space on the stack, with free use */252 307 mfc0 $t3, $epc 253 308 mfc0 $t2, $status 254 sw $t3, SS_EPC($sp) /* save EPC */255 sw $k1, SS_K1($sp)/* save $k1 not saved on context switch */309 sw $t3, ISTATE_OFFSET_EPC($sp) /* save EPC */ 310 sw $k1, ISTATE_OFFSET_KT1($sp) /* save $k1 not saved on context switch */ 256 311 257 312 and $t4, $t2, REG_SAVE_MASK /* save only KSU, EXL, ERL, IE */ … … 260 315 ori $t2, $t2, 0x1 /* set IE */ 261 316 262 sw $t4, SS_STATUS($sp)317 sw $t4, ISTATE_OFFSET_STATUS($sp) 263 318 mtc0 $t2, $status 264 319 265 320 /* 266 321 * Call the higher level system call handler. 267 * We are going to reuse part of the unused exception stack frame.268 322 * 269 323 */ 270 sw $t0, STACK_ARG4($sp) /* save the 5th argument on the stack */271 sw $t1, STACK_ARG5($sp) /* save the 6th argument on the stack */324 sw $t0, ISTATE_OFFSET_T0($sp) /* save the 5th argument on the stack */ 325 sw $t1, ISTATE_OFFSET_T1($sp) /* save the 6th argument on the stack */ 272 326 jal syscall_handler 273 sw $v0, STACK_ARG6($sp) /* save the syscall number on the stack */327 sw $v0, ISTATE_OFFSET_V0($sp) /* save the syscall number on the stack */ 274 328 275 329 /* restore status */ 276 330 mfc0 $t2, $status 277 lw $t3, SS_STATUS($sp)331 lw $t3, ISTATE_OFFSET_STATUS($sp) 278 332 279 333 /* … … 288 342 289 343 /* restore epc + 4 */ 290 lw $t2, SS_EPC($sp)291 lw $k1, SS_K1($sp)344 lw $t2, ISTATE_OFFSET_EPC($sp) 345 lw $k1, ISTATE_OFFSET_KT1($sp) 292 346 addi $t2, $t2, 4 293 347 mtc0 $t2, $epc 294 348 295 lw $sp, SS_SP($sp) /* restore $sp */ 296 eret 297 349 lw $sp, ISTATE_OFFSET_SP($sp) /* restore $sp */ 350 eret 351 352 FAKE_ABI_PROLOGUE 298 353 tlb_refill_handler: 299 354 KERNEL_STACK_TO_K0 300 sub $k0, REGISTER_SPACE355 sub $k0, ISTATE_SOFT_SIZE 301 356 REGISTERS_STORE_AND_EXC_RESET $k0 302 sw $sp, EOFFSET_SP($k0)303 add $sp, $k0,0357 sw $sp, ISTATE_OFFSET_SP($k0) 358 move $sp, $k0 304 359 305 360 jal tlb_refill 306 add $a0, $sp, 0361 move $a0, $sp 307 362 308 363 REGISTERS_LOAD $sp 309 364 eret 310 365 366 FAKE_ABI_PROLOGUE 311 367 cache_error_handler: 312 368 KERNEL_STACK_TO_K0 313 sub $k0, REGISTER_SPACE369 sub $k0, ISTATE_SOFT_SIZE 314 370 REGISTERS_STORE_AND_EXC_RESET $k0 315 sw $sp, EOFFSET_SP($k0)316 add $sp, $k0,0371 sw $sp, ISTATE_OFFSET_SP($k0) 372 move $sp, $k0 317 373 318 374 jal cache_error 319 add $a0, $sp, 0375 move $a0, $sp 320 376 321 377 REGISTERS_LOAD $sp … … 323 379 324 380 userspace_asm: 325 add $sp, $a0,0326 add $v0, $a1, 0327 add $t9, $a2, 0/* set up correct entry into PIC code */381 move $sp, $a0 382 move $v0, $a1 383 move $t9, $a2 /* set up correct entry into PIC code */ 328 384 xor $a0, $a0, $a0 /* $a0 is defined to hold pcb_ptr */ 329 385 /* set it to 0 */ -
kernel/genarch/Makefile.inc
r1882525 rf14291b 90 90 endif 91 91 92 ifeq ($(CONFIG_S3C24XX_IRQC),y) 93 GENARCH_SOURCES += \ 94 genarch/src/drivers/s3c24xx_irqc/s3c24xx_irqc.c 95 endif 96 92 97 ifeq ($(CONFIG_S3C24XX_UART),y) 93 98 GENARCH_SOURCES += \ -
kernel/genarch/include/drivers/s3c24xx_irqc/s3c24xx_irqc.h
r1882525 rf14291b 53 53 ioport32_t subsrcpnd; /**< Sub source pending */ 54 54 ioport32_t intsubmsk; /** Interrupt sub mask */ 55 } s3c24xx_irqc_ t;55 } s3c24xx_irqc_regs_t; 56 56 57 57 /** S3C24xx Interrupt source numbers. … … 120 120 #define S3C24XX_SUBINT_BIT(subsource) (1 << (subsource)) 121 121 122 typedef struct { 123 s3c24xx_irqc_regs_t *regs; 124 } s3c24xx_irqc_t; 125 126 extern void s3c24xx_irqc_init(s3c24xx_irqc_t *, s3c24xx_irqc_regs_t *); 127 extern unsigned s3c24xx_irqc_inum_get(s3c24xx_irqc_t *); 128 extern void s3c24xx_irqc_clear(s3c24xx_irqc_t *, unsigned); 129 extern void s3c24xx_irqc_src_enable(s3c24xx_irqc_t *, unsigned); 130 extern void s3c24xx_irqc_src_disable(s3c24xx_irqc_t *, unsigned); 131 extern void s3c24xx_irqc_subsrc_enable(s3c24xx_irqc_t *, unsigned); 132 extern void s3c24xx_irqc_subsrc_disable(s3c24xx_irqc_t *, unsigned); 133 122 134 #endif 123 135 -
kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h
r1882525 rf14291b 38 38 #define KERN_S3C24XX_UART_H_ 39 39 40 #include <ddi/irq.h> 41 #include <console/chardev.h> 40 42 #include <typedefs.h> 41 #include <console/chardev.h>42 43 43 extern outdev_t *s3c24xx_uart_init(ioport8_t *); 44 /** S3C24xx UART I/O */ 45 typedef struct { 46 uint32_t ulcon; 47 uint32_t ucon; 48 uint32_t ufcon; 49 uint32_t umcon; 50 51 uint32_t utrstat; 52 uint32_t uerstat; 53 uint32_t ufstat; 54 uint32_t umstat; 55 56 uint32_t utxh; 57 uint32_t urxh; 58 59 uint32_t ubrdiv; 60 } s3c24xx_uart_io_t; 61 62 /* Bits in UTRSTAT register */ 63 #define S3C24XX_UTRSTAT_TX_EMPTY 0x4 64 #define S3C24XX_UTRSTAT_RDATA 0x1 65 66 /* Bits in UFSTAT register */ 67 #define S3C24XX_UFSTAT_TX_FULL 0x4000 68 #define S3C24XX_UFSTAT_RX_FULL 0x0040 69 #define S3C24XX_UFSTAT_RX_COUNT 0x002f 70 71 /* Bits in UCON register */ 72 #define UCON_RX_INT_LEVEL 0x100 73 74 /* Bits in UFCON register */ 75 #define UFCON_TX_FIFO_TLEVEL_EMPTY 0x00 76 #define UFCON_RX_FIFO_TLEVEL_1B 0x00 77 #define UFCON_FIFO_ENABLE 0x01 78 79 80 /** S3C24xx UART instance */ 81 typedef struct { 82 s3c24xx_uart_io_t *io; 83 indev_t *indev; 84 irq_t irq; 85 } s3c24xx_uart_t; 86 87 extern outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *, inr_t inr); 88 extern void s3c24xx_uart_input_wire(s3c24xx_uart_t *, 89 indev_t *); 44 90 45 91 #endif -
kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c
r1882525 rf14291b 40 40 #include <genarch/drivers/s3c24xx_uart/s3c24xx_uart.h> 41 41 #include <console/chardev.h> 42 #include <console/console.h> 43 #include <ddi/device.h> 42 44 #include <arch/asm.h> 43 45 #include <mm/slab.h> 44 #include <console/console.h>45 46 #include <sysinfo/sysinfo.h> 46 47 #include <str.h> 47 48 48 /** S3C24xx UART register offsets */49 #define S3C24XX_UTRSTAT 0x1050 #define S3C24XX_UTXH 0x2051 52 /* Bits in UTXH register */53 #define S3C24XX_UTXH_TX_EMPTY 0x454 55 typedef struct {56 ioport8_t *base;57 } s3c24xx_uart_instance_t;58 59 49 static void s3c24xx_uart_sendb(outdev_t *dev, uint8_t byte) 60 50 { 61 s3c24xx_uart_instance_t *instance = 62 (s3c24xx_uart_instance_t *) dev->data; 63 ioport32_t *utrstat, *utxh; 51 s3c24xx_uart_t *uart = 52 (s3c24xx_uart_t *) dev->data; 64 53 65 utrstat = (ioport32_t *) (instance->base + S3C24XX_UTRSTAT); 66 utxh = (ioport32_t *) (instance->base + S3C24XX_UTXH); 67 68 /* Wait for transmitter to be empty. */ 69 while ((pio_read_32(utrstat) & S3C24XX_UTXH_TX_EMPTY) == 0) 54 /* Wait for space becoming available in Tx FIFO. */ 55 while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_TX_FULL) != 0) 70 56 ; 71 57 72 pio_write_32( utxh, byte);58 pio_write_32(&uart->io->utxh, byte); 73 59 } 74 60 … … 86 72 } 87 73 74 static irq_ownership_t s3c24xx_uart_claim(irq_t *irq) 75 { 76 return IRQ_ACCEPT; 77 } 78 79 static void s3c24xx_uart_irq_handler(irq_t *irq) 80 { 81 s3c24xx_uart_t *uart = irq->instance; 82 83 while ((pio_read_32(&uart->io->ufstat) & S3C24XX_UFSTAT_RX_COUNT) != 0) { 84 uint32_t data = pio_read_32(&uart->io->urxh); 85 pio_read_32(&uart->io->uerstat); 86 indev_push_character(uart->indev, data & 0xff); 87 } 88 } 89 88 90 static outdev_operations_t s3c24xx_uart_ops = { 89 91 .write = s3c24xx_uart_putchar, … … 91 93 }; 92 94 93 outdev_t *s3c24xx_uart_init( ioport8_t *base)95 outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *io, inr_t inr) 94 96 { 95 97 outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); … … 97 99 return NULL; 98 100 99 s3c24xx_uart_ instance_t *instance=100 malloc(sizeof(s3c24xx_uart_ instance_t), FRAME_ATOMIC);101 if (! instance) {101 s3c24xx_uart_t *uart = 102 malloc(sizeof(s3c24xx_uart_t), FRAME_ATOMIC); 103 if (!uart) { 102 104 free(uart_dev); 103 105 return NULL; … … 105 107 106 108 outdev_initialize("s3c24xx_uart_dev", uart_dev, &s3c24xx_uart_ops); 107 uart_dev->data = instance;109 uart_dev->data = uart; 108 110 109 instance->base = base; 111 uart->io = io; 112 uart->indev = NULL; 113 114 /* Initialize IRQ structure. */ 115 irq_initialize(&uart->irq); 116 uart->irq.devno = device_assign_devno(); 117 uart->irq.inr = inr; 118 uart->irq.claim = s3c24xx_uart_claim; 119 uart->irq.handler = s3c24xx_uart_irq_handler; 120 uart->irq.instance = uart; 121 122 /* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */ 123 pio_write_32(&uart->io->ufcon, UFCON_FIFO_ENABLE | 124 UFCON_TX_FIFO_TLEVEL_EMPTY | UFCON_RX_FIFO_TLEVEL_1B); 125 126 /* Set RX interrupt to pulse mode */ 127 pio_write_32(&uart->io->ucon, 128 pio_read_32(&uart->io->ucon) & ~UCON_RX_INT_LEVEL); 110 129 111 130 if (!fb_exported) { … … 116 135 sysinfo_set_item_val("fb", NULL, true); 117 136 sysinfo_set_item_val("fb.kind", NULL, 3); 118 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA( base));137 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io)); 119 138 120 139 fb_exported = true; … … 124 143 } 125 144 145 void s3c24xx_uart_input_wire(s3c24xx_uart_t *uart, indev_t *indev) 146 { 147 ASSERT(uart); 148 ASSERT(indev); 149 150 uart->indev = indev; 151 irq_register(&uart->irq); 152 } 153 126 154 /** @} 127 155 */ -
kernel/generic/include/ddi/ddi.h
r1882525 rf14291b 54 54 extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t); 55 55 extern unative_t sys_iospace_enable(ddi_ioarg_t *); 56 extern unative_t sys_preempt_control(int);57 56 58 57 /* -
kernel/generic/include/security/cap.h
r1882525 rf14291b 70 70 71 71 /** 72 * CAP_PREEMPT_CONTROL allows its holder to disable/enable preemption.73 */74 #define CAP_PREEMPT_CONTROL (1<<3)75 76 /**77 72 * CAP_IRQ_REG entitles its holder to register IRQ handlers. 78 73 */ 79 #define CAP_IRQ_REG (1<< 4)74 #define CAP_IRQ_REG (1<<3) 80 75 81 76 typedef uint32_t cap_t; -
kernel/generic/include/syscall/syscall.h
r1882525 rf14291b 80 80 SYS_PHYSMEM_MAP, 81 81 SYS_IOSPACE_ENABLE, 82 SYS_PREEMPT_CONTROL,83 82 84 83 SYS_SYSINFO_GET_TAG, -
kernel/generic/src/ddi/ddi.c
r1882525 rf14291b 258 258 } 259 259 260 /** Disable or enable preemption.261 *262 * @param enable If non-zero, the preemption counter will be decremented,263 * leading to potential enabling of preemption. Otherwise264 * the preemption counter will be incremented, preventing265 * preemption from occurring.266 *267 * @return Zero on success or EPERM if callers capabilities are not sufficient.268 *269 */270 unative_t sys_preempt_control(int enable)271 {272 if (!(cap_get(TASK) & CAP_PREEMPT_CONTROL))273 return EPERM;274 275 if (enable)276 preemption_enable();277 else278 preemption_disable();279 280 return 0;281 }282 283 260 /** @} 284 261 */ -
kernel/generic/src/main/kinit.c
r1882525 rf14291b 208 208 */ 209 209 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER | 210 CAP_IO_MANAGER | CAP_ PREEMPT_CONTROL | CAP_IRQ_REG);210 CAP_IO_MANAGER | CAP_IRQ_REG); 211 211 212 212 if (!ipc_phone_0) -
kernel/generic/src/mm/frame.c
r1882525 rf14291b 161 161 for (j = zones.count; j > i; j--) { 162 162 zones.info[j] = zones.info[j - 1]; 163 zones.info[j].buddy_system->data = 164 (void *) &zones.info[j - 1]; 163 if (zones.info[j].buddy_system != NULL) 164 zones.info[j].buddy_system->data = 165 (void *) &zones.info[j]; 165 166 } 166 167 … … 762 763 for (i = z2 + 1; i < zones.count; i++) { 763 764 zones.info[i - 1] = zones.info[i]; 764 zones.info[i - 1].buddy_system->data = 765 (void *) &zones.info[i - 1]; 765 if (zones.info[i - 1].buddy_system != NULL) 766 zones.info[i - 1].buddy_system->data = 767 (void *) &zones.info[i - 1]; 766 768 } 767 769 -
kernel/generic/src/syscall/syscall.c
r1882525 rf14291b 159 159 (syshandler_t) sys_physmem_map, 160 160 (syshandler_t) sys_iospace_enable, 161 (syshandler_t) sys_preempt_control,162 161 163 162 /* Sysinfo syscalls */
Note:
See TracChangeset
for help on using the changeset viewer.
