- Timestamp:
- 2010-09-02T20:55:28Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0c39b96
- Parents:
- 0c61955 (diff), 3249673 (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:
-
- 7 added
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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/Makefile.inc
r0c61955 r20235a3 60 60 arch/$(KARCH)/src/ras.c 61 61 62 ifeq ($(MACHINE),gta02) 63 ARCH_SOURCES += arch/$(KARCH)/src/mach/gta02/gta02.c 64 endif 65 62 66 ifeq ($(MACHINE),testarm) 63 67 ARCH_SOURCES += arch/$(KARCH)/src/mach/testarm/testarm.c -
kernel/arch/arm32/_link.ld.in
r0c61955 r20235a3 7 7 */ 8 8 9 #ifdef MACHINE_gta02 10 #define KERNEL_LOAD_ADDRESS 0xb0a08000 11 #else 9 12 #define KERNEL_LOAD_ADDRESS 0x80a00000 13 #endif 10 14 11 15 OUTPUT_ARCH(arm) -
kernel/arch/arm32/include/mach/integratorcp/integratorcp.h
r0c61955 r20235a3 103 103 extern void icp_cpu_halt(void); 104 104 extern void icp_irq_exception(unsigned int, istate_t *); 105 extern uintptr_t icp_get_memory_size(void);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; 110 111 /** Size of IntegratorCP IRQ number range (starting from 0) */ 112 #define ICP_IRQ_COUNT 8 109 113 110 114 #endif -
kernel/arch/arm32/include/mach/testarm/testarm.h
r0c61955 r20235a3 42 42 #include <arch/machine_func.h> 43 43 44 /** Last interrupt number (beginning from 0) whose status is probed 45 * from interrupt controller 46 */ 47 #define GXEMUL_IRQC_MAX_IRQ 8 48 #define GXEMUL_KBD_IRQ 2 49 #define GXEMUL_TIMER_IRQ 4 44 /** Size of GXemul IRQ number range (starting from 0) */ 45 #define GXEMUL_IRQ_COUNT 32 46 #define GXEMUL_KBD_IRQ 2 47 #define GXEMUL_TIMER_IRQ 4 50 48 51 49 /** Timer frequency */ … … 73 71 extern void gxemul_cpu_halt(void); 74 72 extern void gxemul_irq_exception(unsigned int, istate_t *); 75 extern uintptr_t gxemul_get_memory_size(void);73 extern void gxemul_get_memory_extents(uintptr_t *, uintptr_t *); 76 74 extern void gxemul_frame_init(void); 75 extern size_t gxemul_get_irq_count(void); 77 76 78 77 extern struct arm_machine_ops gxemul_machine_ops; -
kernel/arch/arm32/include/machine_func.h
r0c61955 r20235a3 47 47 48 48 struct arm_machine_ops { 49 void (*machine_init)(void); 50 void (*machine_timer_irq_start)(void); 51 void (*machine_cpu_halt)(void); 52 uintptr_t (*machine_get_memory_size)(void); 53 void (*machine_irq_exception)(unsigned int, istate_t*); 54 void (*machine_frame_init)(void); 55 void (*machine_output_init)(void); 56 void (*machine_input_init)(void); 49 void (*machine_init)(void); 50 void (*machine_timer_irq_start)(void); 51 void (*machine_cpu_halt)(void); 52 void (*machine_get_memory_extents)(uintptr_t *, uintptr_t *); 53 void (*machine_irq_exception)(unsigned int, istate_t *); 54 void (*machine_frame_init)(void); 55 void (*machine_output_init)(void); 56 void (*machine_input_init)(void); 57 size_t (*machine_get_irq_count)(void); 57 58 }; 58 59 … … 74 75 extern void machine_cpu_halt(void); 75 76 76 77 /** Returns size of available memory. 77 /** Get extents of available memory. 78 78 * 79 * @return Size of available memory. 79 * @param start Place to store memory start address. 80 * @param size Place to store memory size. 80 81 */ 81 extern uintptr_t machine_get_memory_size(void); 82 82 extern void machine_get_memory_extents(uintptr_t *start, uintptr_t *size); 83 83 84 84 /** Interrupt exception handler. … … 105 105 extern void machine_input_init(void); 106 106 107 extern size_t machine_get_irq_count(void); 108 107 109 #endif 108 110 -
kernel/arch/arm32/include/mm/frame.h
r0c61955 r20235a3 46 46 47 47 #define BOOT_PAGE_TABLE_SIZE 0x4000 48 #define BOOT_PAGE_TABLE_ADDRESS 0x8000 48 49 #ifdef MACHINE_gta02 50 #define BOOT_PAGE_TABLE_ADDRESS 0x30010000 51 #else 52 #define BOOT_PAGE_TABLE_ADDRESS 0x00008000 53 #endif 49 54 50 55 #define BOOT_PAGE_TABLE_START_FRAME (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH) 51 56 #define BOOT_PAGE_TABLE_SIZE_IN_FRAMES (BOOT_PAGE_TABLE_SIZE >> FRAME_WIDTH) 57 58 #ifdef MACHINE_gta02 59 #define PHYSMEM_START_ADDR 0x30008000 60 #else 61 #define PHYSMEM_START_ADDR 0x00000000 62 #endif 52 63 53 64 extern uintptr_t last_frame; -
kernel/arch/arm32/src/exc_handler.S
r0c61955 r20235a3 96 96 ldmfd r3!, {r4-r7} 97 97 stmfd r13!, {r4-r7} 98 stmfd r13!, {r13, lr}^ 98 mov r4, r13 99 stmfd r4, {r13, lr}^ 100 nop /* Cannot access r13 immediately after stm(2) */ 101 sub r13, r13, #8 99 102 stmfd r13!, {r2} 100 103 … … 137 140 138 141 # return to user mode 139 ldmfd r13!, {r13, lr}^ 142 mov r0, r13 143 ldmfd r0, {r13, lr}^ 144 nop /* Cannot access r13 immediately after ldm(2) */ 145 add r13, r13, #8 140 146 b 2f 141 147 -
kernel/arch/arm32/src/interrupt.c
r0c61955 r20235a3 40 40 #include <ddi/device.h> 41 41 #include <interrupt.h> 42 43 /** Initial size of a table holding interrupt handlers. */44 #define IRQ_COUNT 845 42 46 43 /** Disable interrupts. … … 105 102 void interrupt_init(void) 106 103 { 107 irq_init(IRQ_COUNT, IRQ_COUNT); 104 size_t irq_count; 105 106 irq_count = machine_get_irq_count(); 107 irq_init(irq_count, irq_count); 108 108 109 machine_timer_irq_start(); 109 110 } -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
r0c61955 r20235a3 60 60 icp_timer_irq_start, 61 61 icp_cpu_halt, 62 icp_get_memory_ size,62 icp_get_memory_extents, 63 63 icp_irq_exception, 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 … … 214 215 } 215 216 216 /** Returns the size of emulated memory. 217 * 218 * @return Size in bytes. 219 */ 220 size_t icp_get_memory_size(void) 221 { 217 /** Get extents of available memory. 218 * 219 * @param start Place to store memory start address. 220 * @param size Place to store memory size. 221 */ 222 void icp_get_memory_extents(uintptr_t *start, uintptr_t *size) 223 { 224 *start = 0; 225 222 226 if (hw_map_init_called) { 223 return (sdram[((*(uint32_t *)icp_hw_map.sdramcr & ICP_SDRAM_MASK) >> 2)]); 227 *size = (sdram[((*(uint32_t *)icp_hw_map.sdramcr & 228 ICP_SDRAM_MASK) >> 2)]); 224 229 } else { 225 return SDRAM_SIZE; 226 } 227 230 *size = SDRAM_SIZE; 231 } 228 232 } 229 233 … … 333 337 } 334 338 339 size_t icp_get_irq_count(void) 340 { 341 return ICP_IRQ_COUNT; 342 } 335 343 336 344 /** @} -
kernel/arch/arm32/src/mach/testarm/testarm.c
r0c61955 r20235a3 60 60 gxemul_timer_irq_start, 61 61 gxemul_cpu_halt, 62 gxemul_get_memory_ size,62 gxemul_get_memory_extents, 63 63 gxemul_irq_exception, 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 * … … 185 191 } 186 192 187 /** Returns the size of emulated memory. 188 * 189 * @return Size in bytes. 190 */ 191 uintptr_t gxemul_get_memory_size(void) 192 { 193 return *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 194 } 195 193 /** Get extents of available memory. 194 * 195 * @param start Place to store memory start address. 196 * @param size Place to store memory size. 197 */ 198 void gxemul_get_memory_extents(uintptr_t *start, uintptr_t *size) 199 { 200 *start = 0; 201 *size = *((uintptr_t *) (GXEMUL_MP_ADDRESS + GXEMUL_MP_MEMSIZE_OFFSET)); 202 } 196 203 197 204 /** Returns the mask of active interrupts. */ … … 210 217 unsigned int i; 211 218 212 for (i = 0; i < GXEMUL_IRQ C_MAX_IRQ; i++) {219 for (i = 0; i < GXEMUL_IRQ_COUNT; i++) { 213 220 if (sources & (1 << i)) { 214 221 irq_t *irq = irq_dispatch_and_lock(i); -
kernel/arch/arm32/src/machine_func.c
r0c61955 r20235a3 39 39 40 40 #include <arch/machine_func.h> 41 #include <arch/mach/gta02/gta02.h> 41 42 #include <arch/mach/integratorcp/integratorcp.h> 42 43 #include <arch/mach/testarm/testarm.h> … … 48 49 void machine_ops_init(void) 49 50 { 50 #if defined(MACHINE_testarm) 51 #if defined(MACHINE_gta02) 52 machine_ops = >a02_machine_ops; 53 #elif defined(MACHINE_testarm) 51 54 machine_ops = &gxemul_machine_ops; 52 55 #elif defined(MACHINE_integratorcp) … … 77 80 } 78 81 79 80 /** Returns size of available memory. 82 /** Get extents of available memory. 81 83 * 82 * @return Size of available memory. 84 * @param start Place to store memory start address. 85 * @param size Place to store memory size. 83 86 */ 84 uintptr_t machine_get_memory_size(void)87 void machine_get_memory_extents(uintptr_t *start, uintptr_t *size) 85 88 { 86 return (machine_ops->machine_get_memory_size)();89 (machine_ops->machine_get_memory_extents)(start, size); 87 90 } 88 91 … … 122 125 } 123 126 127 /** Get IRQ number range used by machine. */ 128 size_t machine_get_irq_count(void) 129 { 130 return (machine_ops->machine_get_irq_count)(); 131 } 132 124 133 /** @} 125 134 */ -
kernel/arch/arm32/src/mm/frame.c
r0c61955 r20235a3 38 38 #include <arch/machine_func.h> 39 39 #include <config.h> 40 #include <align.h> 40 41 41 42 /** Address of the last frame in the memory. */ … … 45 46 void frame_arch_init(void) 46 47 { 47 last_frame = machine_get_memory_size(); 48 uintptr_t mem_start, mem_size; 49 uintptr_t first_frame; 50 uintptr_t num_frames; 51 52 machine_get_memory_extents(&mem_start, &mem_size); 53 first_frame = ALIGN_UP(mem_start, FRAME_SIZE); 54 last_frame = ALIGN_DOWN(mem_start + mem_size, FRAME_SIZE); 55 num_frames = (last_frame - first_frame) >> FRAME_WIDTH; 48 56 49 57 /* All memory as one zone */ 50 zone_create( 0, ADDR2PFN(last_frame),58 zone_create(first_frame >> FRAME_WIDTH, num_frames, 51 59 BOOT_PAGE_TABLE_START_FRAME + BOOT_PAGE_TABLE_SIZE_IN_FRAMES, 0); 52 60 -
kernel/arch/arm32/src/mm/page.c
r0c61955 r20235a3 58 58 uintptr_t cur; 59 59 /* Kernel identity mapping */ 60 for (cur = 0; cur < last_frame; cur += FRAME_SIZE)60 for (cur = PHYSMEM_START_ADDR; cur < last_frame; cur += FRAME_SIZE) 61 61 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 62 62 … … 68 68 #error "Only high exception vector supported now" 69 69 #endif 70 cur = ALIGN_DOWN(0x50008010, FRAME_SIZE); 71 page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, flags); 70 72 71 73 page_table_unlock(AS_KERNEL, true); -
kernel/arch/arm32/src/userspace.c
r0c61955 r20235a3 97 97 "mov sp, %[ustate]\n" 98 98 "msr spsr_c, %[user_mode]\n" 99 "ldmfd sp!, {r0-r12, sp, lr}^\n" 99 "ldmfd sp, {r0-r12, sp, lr}^\n" 100 "nop\n" /* Cannot access sp immediately after ldm(2) */ 101 "add sp, sp, #(15*4)\n" 100 102 "ldmfd sp!, {pc}^\n" 101 103 :: [ustate] "r" (&ustate), [user_mode] "r" (user_mode) -
kernel/arch/ia32/include/bios/bios.h
r0c61955 r20235a3 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
r0c61955 r20235a3 27 27 */ 28 28 29 /** @addtogroup ia32mm 29 /** @addtogroup ia32mm 30 30 * @{ 31 31 */ -
kernel/arch/ia32/include/mm/page.h
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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
r0c61955 r20235a3 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/genarch/Makefile.inc
r0c61955 r20235a3 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 97 ifeq ($(CONFIG_S3C24XX_UART),y) 98 GENARCH_SOURCES += \ 99 genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c 100 endif 101 92 102 ifeq ($(CONFIG_Z8530),y) 93 103 GENARCH_SOURCES += \ -
kernel/generic/include/macros.h
r0c61955 r20235a3 47 47 * @param s2 Start address of the second interval. 48 48 * @param sz2 Size of the second interval. 49 * 49 50 */ 50 NO_TRACE static inline int overlaps(uint ptr_t s1, size_t sz1, uintptr_t s2,51 size_t sz2)51 NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2, 52 uint64_t sz2) 52 53 { 53 uint ptr_t e1 = s1 + sz1;54 uint ptr_t e2 = s2 + sz2;54 uint64_t e1 = s1 + sz1; 55 uint64_t e2 = s2 + sz2; 55 56 56 57 return ((s1 < e2) && (s2 < e1)); 58 } 59 60 /** Return true if the second interval is within the first interval. 61 * 62 * @param s1 Start address of the first interval. 63 * @param sz1 Size of the first interval. 64 * @param s2 Start address of the second interval. 65 * @param sz2 Size of the second interval. 66 * 67 */ 68 NO_TRACE static inline int iswithin(uint64_t s1, uint64_t sz1, uint64_t s2, 69 uint64_t sz2) 70 { 71 uint64_t e1 = s1 + sz1; 72 uint64_t e2 = s2 + sz2; 73 74 return ((s1 <= s2) && (e1 >= e2)); 57 75 } 58 76 … … 74 92 75 93 /* Compute overlapping of physical addresses */ 76 #define PA_ overlaps(x, szx, y, szy) \94 #define PA_OVERLAPS(x, szx, y, szy) \ 77 95 overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy)) 78 96 -
kernel/generic/src/main/main.c
r0c61955 r20235a3 147 147 size_t i; 148 148 for (i = 0; i < init.cnt; i++) { 149 if (PA_ overlaps(config.stack_base, config.stack_size,149 if (PA_OVERLAPS(config.stack_base, config.stack_size, 150 150 init.tasks[i].addr, init.tasks[i].size)) 151 151 config.stack_base = ALIGN_UP(init.tasks[i].addr + … … 155 155 /* Avoid placing stack on top of boot allocations. */ 156 156 if (ballocs.size) { 157 if (PA_ overlaps(config.stack_base, config.stack_size,157 if (PA_OVERLAPS(config.stack_base, config.stack_size, 158 158 ballocs.base, ballocs.size)) 159 159 config.stack_base = ALIGN_UP(ballocs.base + -
kernel/generic/src/mm/frame.c
r0c61955 r20235a3 121 121 * 122 122 */ 123 NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count) 123 NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count, 124 zone_flags_t flags) 124 125 { 125 126 if (zones.count + 1 == ZONES_MAX) { … … 131 132 for (i = 0; i < zones.count; i++) { 132 133 /* Check for overlap */ 133 if (overlaps(base, count, 134 zones.info[i].base, zones.info[i].count)) { 135 printf("Zone (%p, %p) overlaps with zone (%p, %p)!\n", 136 PFN2ADDR(base), PFN2ADDR(base + count), 137 PFN2ADDR(zones.info[i].base), 138 PFN2ADDR(zones.info[i].base + zones.info[i].count)); 134 if (overlaps(zones.info[i].base, zones.info[i].count, 135 base, count)) { 136 137 /* 138 * If the overlaping zones are of the same type 139 * and the new zone is completely within the previous 140 * one, then quietly ignore the new zone. 141 * 142 */ 143 144 if ((zones.info[i].flags != flags) || 145 (!iswithin(zones.info[i].base, zones.info[i].count, 146 base, count))) { 147 printf("Zone (%p, %p) overlaps with previous zone (%p, %p)!\n", 148 PFN2ADDR(base), PFN2ADDR(count), 149 PFN2ADDR(zones.info[i].base), 150 PFN2ADDR(zones.info[i].count)); 151 } 152 139 153 return (size_t) -1; 140 154 } … … 147 161 for (j = zones.count; j > i; j--) { 148 162 zones.info[j] = zones.info[j - 1]; 149 zones.info[j].buddy_system->data = 150 (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]; 151 166 } 152 167 … … 748 763 for (i = z2 + 1; i < zones.count; i++) { 749 764 zones.info[i - 1] = zones.info[i]; 750 zones.info[i - 1].buddy_system->data = 751 (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]; 752 768 } 753 769 … … 898 914 } 899 915 900 size_t znum = zones_insert_zone(start, count );916 size_t znum = zones_insert_zone(start, count, flags); 901 917 if (znum == (size_t) -1) { 902 918 irq_spinlock_unlock(&zones.lock, true); … … 921 937 922 938 /* Non-available zone */ 923 size_t znum = zones_insert_zone(start, count );939 size_t znum = zones_insert_zone(start, count, flags); 924 940 if (znum == (size_t) -1) { 925 941 irq_spinlock_unlock(&zones.lock, true);
Note:
See TracChangeset
for help on using the changeset viewer.