- Timestamp:
- 2016-05-22T19:19:43Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b272c67a
- Parents:
- 153c7a29 (diff), af2254ec (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:
-
- 6 added
- 50 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
r153c7a29 r0dc2fec 48 48 # 49 49 50 AGDEPEND = Makefile.ag.depend 50 51 DEPEND = Makefile.depend 51 52 DEPEND_PREV = $(DEPEND).prev … … 138 139 -include genarch/Makefile.inc 139 140 -include $(DEPEND) 141 -include $(AGDEPEND) 140 142 141 143 ## The at-sign … … 377 379 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES))) 378 380 381 GENARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(GENARCH_AUTOGENS_AG))) 382 GENARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(GENARCH_AUTOGENS_AG))) 383 GENARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(GENARCH_AUTOGENS_AG))) 384 379 385 ARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(ARCH_AUTOGENS_AG))) 380 386 ARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(ARCH_AUTOGENS_AG))) 381 387 ARCH_AUTOGENS_PROBE_S := $(addsuffix .ag.probe.s,$(basename $(ARCH_AUTOGENS_AG))) 388 389 AUTOGENS_H := $(ARCH_AUTOGENS_H) $(GENARCH_AUTOGENS_H) 390 AUTOGENS_AG := $(ARCH_AUTOGENS_AG) $(GENARCH_AUTOGENS_AG) 382 391 383 392 LFLAGS_LTO := $(addprefix -Xlinker ,$(LFLAGS)) … … 460 469 $(GENMAP) $(MAP_PREV) $(DUMP) $@ 461 470 462 $(DEPEND): $(COMMON_HEADER_ARCH) $(ARCH_AUTOGENS_H) 471 $(AUTOGENS_H): $(AGDEPEND) 472 473 $(AGDEPEND): $(AUTOGENS_AG) 474 echo "# DO NOT EDIT" >$@ 475 for g in $^; do \ 476 h=`dirname $$g`/`basename $$g .ag`.h; \ 477 for l in `$(AUTOGEN) depend $$g`; do \ 478 echo "$$h: $$l" >>$@; \ 479 done \ 480 done 481 482 $(DEPEND): $(COMMON_HEADER_ARCH) $(AUTOGENS_H) 463 483 makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null 464 484 -[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@ … … 469 489 autogen_clean: 470 490 -rm $(ARCH_AUTOGENS_H) $(ARCH_AUTOGENS_PROBE_C) $(ARCH_AUTOGENS_PROBE_S) 491 -rm $(GENARCH_AUTOGENS_H) $(GENARCH_AUTOGENS_PROBE_C) $(GENARCH_AUTOGENS_PROBE_S) 492 -rm $(AGDEPEND) -
kernel/arch/abs32le/include/arch/barrier.h
r153c7a29 r0dc2fec 47 47 #define write_barrier() 48 48 49 #ifdef KERNEL 50 49 51 #define smc_coherence(addr) 50 52 #define smc_coherence_block(addr, size) 53 54 #endif /* KERNEL*/ 51 55 52 56 #endif -
kernel/arch/amd64/Makefile.inc
r153c7a29 r0dc2fec 93 93 arch/$(KARCH)/include/arch/istate_struct.ag \ 94 94 arch/$(KARCH)/include/arch/context_struct.ag \ 95 arch/$(KARCH)/include/arch/kseg_struct.ag 95 arch/$(KARCH)/include/arch/kseg_struct.ag \ 96 arch/$(KARCH)/include/arch/boot/memmap_struct.ag -
kernel/arch/amd64/include/arch/asm.h
r153c7a29 r0dc2fec 208 208 } 209 209 210 /** Enable interrupts. 211 * 212 * Enable interrupts and return previous 213 * value of EFLAGS. 214 * 215 * @return Old interrupt priority level. 216 * 217 */ 218 NO_TRACE static inline ipl_t interrupts_enable(void) { 219 ipl_t v; 220 210 NO_TRACE static inline uint64_t read_rflags(void) 211 { 212 uint64_t rflags; 213 221 214 asm volatile ( 222 215 "pushfq\n" 223 216 "popq %[v]\n" 224 "sti\n" 225 : [v] "=r" (v) 226 ); 227 228 return v; 217 : [v] "=r" (rflags) 218 ); 219 220 return rflags; 221 } 222 223 NO_TRACE static inline void write_rflags(uint64_t rflags) 224 { 225 asm volatile ( 226 "pushq %[v]\n" 227 "popfq\n" 228 :: [v] "r" (rflags) 229 ); 230 } 231 232 /** Return interrupt priority level. 233 * 234 * Return the current interrupt priority level. 235 * 236 * @return Current interrupt priority level. 237 */ 238 NO_TRACE static inline ipl_t interrupts_read(void) { 239 return (ipl_t) read_rflags(); 240 } 241 242 /** Enable interrupts. 243 * 244 * Enable interrupts and return the previous interrupt priority level. 245 * 246 * @return Old interrupt priority level. 247 */ 248 NO_TRACE static inline ipl_t interrupts_enable(void) { 249 ipl_t ipl = interrupts_read(); 250 251 asm volatile ("sti\n"); 252 253 return ipl; 229 254 } 230 255 231 256 /** Disable interrupts. 232 257 * 233 * Disable interrupts and return previous 234 * value of EFLAGS. 258 * Disable interrupts and return the previous interrupt priority level. 235 259 * 236 260 * @return Old interrupt priority level. 237 *238 261 */ 239 262 NO_TRACE static inline ipl_t interrupts_disable(void) { 240 ipl_t v; 241 242 asm volatile ( 243 "pushfq\n" 244 "popq %[v]\n" 245 "cli\n" 246 : [v] "=r" (v) 247 ); 248 249 return v; 263 ipl_t ipl = interrupts_read(); 264 265 asm volatile ("cli\n"); 266 267 return ipl; 250 268 } 251 269 252 270 /** Restore interrupt priority level. 253 271 * 254 * Restore EFLAGS.272 * Restore the previously save interrupt priority level. 255 273 * 256 274 * @param ipl Saved interrupt priority level. … … 258 276 */ 259 277 NO_TRACE static inline void interrupts_restore(ipl_t ipl) { 260 asm volatile ( 261 "pushq %[ipl]\n" 262 "popfq\n" 263 :: [ipl] "r" (ipl) 264 ); 265 } 266 267 /** Return interrupt priority level. 268 * 269 * Return EFLAFS. 270 * 271 * @return Current interrupt priority level. 272 * 273 */ 274 NO_TRACE static inline ipl_t interrupts_read(void) { 275 ipl_t v; 276 277 asm volatile ( 278 "pushfq\n" 279 "popq %[v]\n" 280 : [v] "=r" (v) 281 ); 282 283 return v; 278 write_rflags((uint64_t) ipl); 284 279 } 285 280 … … 291 286 NO_TRACE static inline bool interrupts_disabled(void) 292 287 { 293 ipl_t v; 294 295 asm volatile ( 296 "pushfq\n" 297 "popq %[v]\n" 298 : [v] "=r" (v) 299 ); 300 301 return ((v & RFLAGS_IF) == 0); 288 return ((read_rflags() & RFLAGS_IF) == 0); 302 289 } 303 290 … … 324 311 325 312 return ((uint64_t) dx << 32) | ax; 326 }327 328 /** Enable local APIC329 *330 * Enable local APIC in MSR.331 *332 */333 NO_TRACE static inline void enable_l_apic_in_msr(void)334 {335 asm volatile (336 "movl $0x1b, %%ecx\n"337 "rdmsr\n"338 "orl $(1 << 11),%%eax\n"339 "orl $(0xfee00000),%%eax\n"340 "wrmsr\n"341 ::: "%eax", "%ecx", "%edx"342 );343 313 } 344 314 … … 426 396 427 397 GEN_READ_REG(cr0) 398 GEN_WRITE_REG(cr0) 428 399 GEN_READ_REG(cr2) 429 400 GEN_READ_REG(cr3) 430 401 GEN_WRITE_REG(cr3) 402 GEN_READ_REG(cr4) 403 GEN_WRITE_REG(cr4) 431 404 432 405 GEN_READ_REG(dr0) … … 512 485 extern uintptr_t int_63; 513 486 487 extern void enable_l_apic_in_msr(void); 488 514 489 #endif 515 490 -
kernel/arch/amd64/include/arch/cpu.h
r153c7a29 r0dc2fec 36 36 #define KERN_amd64_CPU_H_ 37 37 38 #define RFLAGS_CF (1 << 0) 39 #define RFLAGS_PF (1 << 2) 40 #define RFLAGS_AF (1 << 4) 41 #define RFLAGS_ZF (1 << 6) 42 #define RFLAGS_SF (1 << 7) 43 #define RFLAGS_TF (1 << 8) 44 #define RFLAGS_IF (1 << 9) 45 #define RFLAGS_DF (1 << 10) 46 #define RFLAGS_OF (1 << 11) 47 #define RFLAGS_NT (1 << 14) 48 #define RFLAGS_RF (1 << 16) 38 #define RFLAGS_CF (1 << 0) 39 #define RFLAGS_PF (1 << 2) 40 #define RFLAGS_AF (1 << 4) 41 #define RFLAGS_ZF (1 << 6) 42 #define RFLAGS_SF (1 << 7) 43 #define RFLAGS_TF (1 << 8) 44 #define RFLAGS_IF (1 << 9) 45 #define RFLAGS_DF (1 << 10) 46 #define RFLAGS_OF (1 << 11) 47 #define RFLAGS_IOPL (3 << 12) 48 #define RFLAGS_NT (1 << 14) 49 #define RFLAGS_RF (1 << 16) 50 #define RFLAGS_ID (1 << 21) 49 51 50 #define EFER_MSR_NUM 0xc0000080 51 #define AMD_SCE_FLAG 0 52 #define AMD_LME_FLAG 8 53 #define AMD_LMA_FLAG 10 54 #define AMD_FFXSR_FLAG 14 55 #define AMD_NXE_FLAG 11 52 #define CR0_PE (1 << 0) 53 #define CR0_MP (1 << 1) 54 #define CR0_EM (1 << 2) 55 #define CR0_TS (1 << 3) 56 #define CR0_AM (1 << 18) 57 #define CR0_PG (1 << 31) 58 59 #define CR4_PAE (1 << 5) 60 #define CR4_OSFXSR (1 << 9) 61 62 /* EFER bits */ 63 #define AMD_SCE (1 << 0) 64 #define AMD_LME (1 << 8) 65 #define AMD_LMA (1 << 10) 66 #define AMD_NXE (1 << 11) 67 #define AMD_FFXSR (1 << 14) 68 69 #define AMD_APIC_BASE_GE (1 << 11) 56 70 57 71 /* MSR registers */ 72 #define AMD_MSR_APIC_BASE 0x0000001b 73 #define AMD_MSR_EFER 0xc0000080 58 74 #define AMD_MSR_STAR 0xc0000081 59 75 #define AMD_MSR_LSTAR 0xc0000082 … … 85 101 }; 86 102 87 extern void set_efer_flag(int flag);88 extern uint64_t read_efer_flag(void);89 103 void cpu_setup_fpu(void); 90 104 -
kernel/arch/amd64/include/arch/interrupt.h
r153c7a29 r0dc2fec 50 50 #define IVT_FREEBASE (IVT_IRQBASE + IRQ_COUNT) 51 51 52 #define EXC_DE 0 53 #define EXC_NM 7 54 #define EXC_SS 12 55 #define EXC_GP 13 56 #define EXC_PF 14 57 52 58 #define IRQ_CLK 0 53 59 #define IRQ_KBD 1 … … 65 71 #endif 66 72 67 #define VECTOR_DEBUG 1 73 #define VECTOR_DE (IVT_EXCBASE + EXC_DE) 74 #define VECTOR_NM (IVT_EXCBASE + EXC_NM) 75 #define VECTOR_SS (IVT_EXCBASE + EXC_SS) 76 #define VECTOR_GP (IVT_EXCBASE + EXC_GP) 77 #define VECTOR_PF (IVT_EXCBASE + EXC_PF) 68 78 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 69 79 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) -
kernel/arch/amd64/src/amd64.c
r153c7a29 r0dc2fec 64 64 #endif 65 65 66 /** Disable I/O on non-privileged levels67 *68 * Clean IOPL(12,13) and NT(14) flags in EFLAGS register69 */70 static void clean_IOPL_NT_flags(void)71 {72 asm volatile (73 "pushfq\n"74 "pop %%rax\n"75 "and $~(0x7000), %%rax\n"76 "pushq %%rax\n"77 "popfq\n"78 ::: "%rax"79 );80 }81 82 /** Disable alignment check83 *84 * Clean AM(18) flag in CR0 register85 */86 static void clean_AM_flag(void)87 {88 asm volatile (89 "mov %%cr0, %%rax\n"90 "and $~(0x40000), %%rax\n"91 "mov %%rax, %%cr0\n"92 ::: "%rax"93 );94 }95 96 66 /** Perform amd64-specific initialization before main_bsp() is called. 97 67 * … … 116 86 { 117 87 /* Enable no-execute pages */ 118 set_efer_flag(AMD_NXE_FLAG);88 write_msr(AMD_MSR_EFER, read_msr(AMD_MSR_EFER) | AMD_NXE); 119 89 /* Enable FPU */ 120 90 cpu_setup_fpu(); … … 123 93 pm_init(); 124 94 125 /* Disable I/O on nonprivileged levels 126 * clear the NT (nested-thread) flag 127 */ 128 clean_IOPL_NT_flags(); 95 /* Disable I/O on nonprivileged levels, clear the nested-thread flag */ 96 write_rflags(read_rflags() & ~(RFLAGS_IOPL | RFLAGS_NT)); 129 97 /* Disable alignment check */ 130 clean_AM_flag();98 write_cr0(read_cr0() & ~CR0_AM); 131 99 132 100 if (config.cpu_active == 1) { -
kernel/arch/amd64/src/asm.S
r153c7a29 r0dc2fec 33 33 #include <arch/kseg_struct.h> 34 34 #include <arch/cpu.h> 35 #include <arch/smp/apic.h> 35 36 36 37 .text … … 93 94 94 95 /* Flip the ID bit */ 95 btcl $21, %edx96 xorl $RFLAGS_ID, %edx 96 97 97 98 /* Store RFLAGS */ … … 102 103 /* Get the ID bit again */ 103 104 popq %rdx 104 andl $ (1 << 21), %eax105 andl $ (1 << 21), %edx105 andl $RFLAGS_ID, %eax 106 andl $RFLAGS_ID, %edx 106 107 107 108 /* 0 if not supported, 1 if supported */ … … 127 128 FUNCTION_END(cpuid) 128 129 129 FUNCTION_BEGIN(set_efer_flag) 130 movl $0xc0000080, %ecx 130 /** Enable local APIC 131 * 132 * Enable local APIC in MSR. 133 * 134 */ 135 FUNCTION_BEGIN(enable_l_apic_in_msr) 136 movl $AMD_MSR_APIC_BASE, %ecx 131 137 rdmsr 132 btsl %edi, %eax138 orl $(L_APIC_BASE | AMD_APIC_BASE_GE), %eax 133 139 wrmsr 134 140 ret 135 FUNCTION_END(set_efer_flag) 136 137 FUNCTION_BEGIN(read_efer_flag) 138 movl $0xc0000080, %ecx 139 rdmsr 140 ret 141 FUNCTION_END(read_efer_flag) 141 FUNCTION_END(enable_l_apic_in_msr) 142 142 143 143 /* … … 541 541 ret 542 542 FUNCTION_END(early_putchar) 543 -
kernel/arch/amd64/src/boot/multiboot.S
r153c7a29 r0dc2fec 168 168 169 169 movl %cr4, %eax 170 btsl $5, %eax170 orl $CR4_PAE, %eax 171 171 movl %eax, %cr4 172 172 … … 176 176 177 177 /* Enable long mode */ 178 movl $ EFER_MSR_NUM, %ecx178 movl $AMD_MSR_EFER, %ecx 179 179 rdmsr /* read EFER */ 180 btsl $AMD_LME_FLAG, %eax/* set LME = 1 */180 orl $AMD_LME, %eax /* set LME = 1 */ 181 181 wrmsr 182 182 183 183 /* Enable paging to activate long mode (set CR0.PG = 1) */ 184 184 movl %cr0, %eax 185 btsl $31, %eax185 orl $CR0_PG, %eax 186 186 movl %eax, %cr0 187 187 -
kernel/arch/amd64/src/boot/multiboot2.S
r153c7a29 r0dc2fec 209 209 210 210 movl %cr4, %eax 211 btsl $5, %eax211 orl $CR4_PAE, %eax 212 212 movl %eax, %cr4 213 213 … … 217 217 218 218 /* Enable long mode */ 219 movl $ EFER_MSR_NUM, %ecx219 movl $AMD_MSR_EFER, %ecx 220 220 rdmsr /* read EFER */ 221 btsl $AMD_LME_FLAG, %eax/* set LME = 1 */221 orl $AMD_LME, %eax /* set LME = 1 */ 222 222 wrmsr 223 223 224 224 /* Enable paging to activate long mode (set CR0.PG = 1) */ 225 225 movl %cr0, %eax 226 btsl $31, %eax226 orl $CR0_PG, %eax 227 227 movl %eax, %cr0 228 228 -
kernel/arch/amd64/src/context.S
r153c7a29 r0dc2fec 39 39 # 40 40 FUNCTION_BEGIN(context_save_arch) 41 movq (%rsp), %rdx # the caller's return % eip41 movq (%rsp), %rdx # the caller's return %rip 42 42 43 # 1st argument passed in %edi44 43 movq %rdx, CONTEXT_OFFSET_PC(%rdi) 45 44 movq %rsp, CONTEXT_OFFSET_SP(%rdi) … … 75 74 movq CONTEXT_OFFSET_RBX(%rdi), %rbx 76 75 77 movq CONTEXT_OFFSET_SP(%rdi), %rsp # ctx->sp -> %rsp76 movq CONTEXT_OFFSET_SP(%rdi), %rsp 78 77 79 78 movq CONTEXT_OFFSET_PC(%rdi), %rdx -
kernel/arch/amd64/src/cpu/cpu.c
r153c7a29 r0dc2fec 76 76 void cpu_setup_fpu(void) 77 77 { 78 asm volatile ( 79 "movq %%cr0, %%rax\n" 80 "btsq $1, %%rax\n" /* cr0.mp */ 81 "btrq $2, %%rax\n" /* cr0.em */ 82 "movq %%rax, %%cr0\n" 83 84 "movq %%cr4, %%rax\n" 85 "bts $9, %%rax\n" /* cr4.osfxsr */ 86 "movq %%rax, %%cr4\n" 87 ::: "%rax" 88 ); 78 write_cr0((read_cr0() & ~CR0_EM) | CR0_MP); 79 write_cr4(read_cr4() | CR4_OSFXSR); 89 80 } 90 81 … … 97 88 void fpu_disable(void) 98 89 { 99 asm volatile ( 100 "mov %%cr0, %%rax\n" 101 "bts $3, %%rax\n" 102 "mov %%rax, %%cr0\n" 103 ::: "%rax" 104 ); 90 write_cr0(read_cr0() | CR0_TS); 105 91 } 106 92 107 93 void fpu_enable(void) 108 94 { 109 asm volatile ( 110 "mov %%cr0, %%rax\n" 111 "btr $3, %%rax\n" 112 "mov %%rax, %%cr0\n" 113 ::: "%rax" 114 ); 95 write_cr0(read_cr0() & ~CR0_TS); 115 96 } 116 97 -
kernel/arch/amd64/src/interrupt.c
r153c7a29 r0dc2fec 222 222 } 223 223 224 exc_register( 0, "de_fault", true, (iroutine_t) de_fault);225 exc_register( 7, "nm_fault", true, (iroutine_t) nm_fault);226 exc_register( 12, "ss_fault", true, (iroutine_t) ss_fault);227 exc_register( 13, "gp_fault", true, (iroutine_t) gp_fault);224 exc_register(VECTOR_DE, "de_fault", true, (iroutine_t) de_fault); 225 exc_register(VECTOR_NM, "nm_fault", true, (iroutine_t) nm_fault); 226 exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault); 227 exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault); 228 228 229 229 #ifdef CONFIG_SMP -
kernel/arch/amd64/src/mm/page.c
r153c7a29 r0dc2fec 72 72 page_table_unlock(AS_KERNEL, true); 73 73 74 exc_register( 14, "page_fault", true, (iroutine_t) page_fault);74 exc_register(VECTOR_PF, "page_fault", true, (iroutine_t) page_fault); 75 75 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 76 76 } -
kernel/arch/amd64/src/pm.c
r153c7a29 r0dc2fec 49 49 50 50 descriptor_t gdt[GDT_ITEMS] = { 51 /* NULL descriptor */ 52 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 53 /* KTEXT descriptor */ 54 { .limit_0_15 = 0xffffU, 55 .base_0_15 = 0, 56 .base_16_23 = 0, 57 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 58 .limit_16_19 = 0x0fU, 59 .available = 0, 60 .longmode = 1, 61 .special = 0, 62 .granularity = 1, 63 .base_24_31 = 0 }, 64 /* KDATA descriptor */ 65 { .limit_0_15 = 0xffffU, 66 .base_0_15 = 0, 67 .base_16_23 = 0, 68 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 69 .limit_16_19 = 0x0fU, 70 .available = 0, 71 .longmode = 0, 72 .special = 0, 73 .granularity = 1, 74 .base_24_31 = 0 }, 75 /* UDATA descriptor */ 76 { .limit_0_15 = 0xffffU, 77 .base_0_15 = 0, 78 .base_16_23 = 0, 79 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 80 .limit_16_19 = 0x0fU, 81 .available = 0, 82 .longmode = 0, 83 .special = 1, 84 .granularity = 1, 85 .base_24_31 = 0 }, 86 /* UTEXT descriptor */ 87 { .limit_0_15 = 0xffffU, 88 .base_0_15 = 0, 89 .base_16_23 = 0, 90 .access = AR_PRESENT | AR_CODE | DPL_USER, 91 .limit_16_19 = 0x0fU, 92 .available = 0, 93 .longmode = 1, 94 .special = 0, 95 .granularity = 1, 96 .base_24_31 = 0 }, 97 /* KTEXT 32-bit protected, for protected mode before long mode */ 98 { .limit_0_15 = 0xffffU, 99 .base_0_15 = 0, 100 .base_16_23 = 0, 101 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 102 .limit_16_19 = 0x0fU, 103 .available = 0, 104 .longmode = 0, 105 .special = 1, 106 .granularity = 1, 107 .base_24_31 = 0 }, 108 /* TSS descriptor - set up will be completed later, 109 * on AMD64 it is 64-bit - 2 items in table */ 110 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 111 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 51 [NULL_DES] = { 52 0 53 }, 54 [KTEXT_DES] = { 55 .limit_0_15 = 0xffffU, 56 .limit_16_19 = 0xfU, 57 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 58 .longmode = 1, 59 .granularity = 1 60 }, 61 [KDATA_DES] = { 62 .limit_0_15 = 0xffffU, 63 .limit_16_19 = 0xfU, 64 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 65 .granularity = 1 66 }, 67 [UDATA_DES] = { 68 .limit_0_15 = 0xffffU, 69 .limit_16_19 = 0xfU, 70 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 71 .special = 1, 72 .granularity = 1 73 }, 74 [UTEXT_DES] = { 75 .limit_0_15 = 0xffffU, 76 .limit_16_19 = 0xfU, 77 .access = AR_PRESENT | AR_CODE | DPL_USER, 78 .longmode = 1, 79 .granularity = 1 80 }, 81 [KTEXT32_DES] = { 82 .limit_0_15 = 0xffffU, 83 .limit_16_19 = 0xfU, 84 .access = AR_PRESENT | AR_CODE | DPL_KERNEL | AR_READABLE, 85 .special = 1, 86 .granularity = 1 87 }, 88 /* 89 * TSS descriptor - set up will be completed later, 90 * on AMD64 it is 64-bit - 2 items in the table 91 */ 92 [TSS_DES] = { 93 0 94 }, 95 [TSS_DES + 1] = { 96 0 97 }, 112 98 /* VESA Init descriptor */ 113 99 #ifdef CONFIG_FB 114 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }, 115 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 } 100 [VESA_INIT_CODE_DES] = { 101 .limit_0_15 = 0xffff, 102 .limit_16_19 = 0xf, 103 .base_16_23 = VESA_INIT_SEGMENT >> 12, 104 .access = AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL 105 }, 106 [VESA_INIT_DATA_DES] = { 107 .limit_0_15 = 0xffff, 108 .limit_16_19 = 0xf, 109 .base_16_23 = VESA_INIT_SEGMENT >> 12, 110 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL 111 } 116 112 #endif 117 113 }; … … 119 115 idescriptor_t idt[IDT_ITEMS]; 120 116 121 ptr_16_64_t gdtr = {.limit = sizeof(gdt), .base = (uint64_t) gdt }; 122 ptr_16_64_t idtr = {.limit = sizeof(idt), .base = (uint64_t) idt }; 117 ptr_16_64_t gdtr = { 118 .limit = sizeof(gdt), 119 .base = (uint64_t) gdt 120 }; 121 ptr_16_64_t idtr = { 122 .limit = sizeof(idt), 123 .base = (uint64_t) idt 124 }; 123 125 124 126 static tss_t tss; -
kernel/arch/amd64/src/smp/ap.S
r153c7a29 r0dc2fec 39 39 #include <arch/cpu.h> 40 40 #include <arch/cpuid.h> 41 #include <arch/context_struct.h> 41 42 42 43 .section K_TEXT_START, "ax" … … 58 59 59 60 movl %cr0, %eax 60 orl $ 1, %eax61 orl $CR0_PE, %eax 61 62 movl %eax, %cr0 # switch to protected mode 62 63 jmpl $GDT_SELECTOR(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET … … 75 76 76 77 movl %cr4, %eax 77 btsl $5, %eax78 orl $CR4_PAE, %eax 78 79 movl %eax, %cr4 79 80 … … 82 83 83 84 # Enable long mode 84 movl $ EFER_MSR_NUM, %ecx # EFER MSR number85 movl $AMD_MSR_EFER, %ecx # EFER MSR number 85 86 rdmsr # Read EFER 86 btsl $AMD_LME_FLAG, %eax# Set LME=187 orl $AMD_LME, %eax # Set LME=1 87 88 wrmsr # Write EFER 88 89 89 90 # Enable paging to activate long mode (set CR0.PG = 1) 90 91 movl %cr0, %eax 91 btsl $31, %eax92 orl $CR0_PG, %eax 92 93 movl %eax, %cr0 93 94 … … 98 99 start64: 99 100 movabsq $ctx, %rsp 100 movq (%rsp), %rsp101 movq CONTEXT_OFFSET_SP(%rsp), %rsp 101 102 102 103 pushq $0 -
kernel/arch/amd64/src/syscall.c
r153c7a29 r0dc2fec 48 48 { 49 49 /* Enable SYSCALL/SYSRET */ 50 set_efer_flag(AMD_SCE_FLAG);50 write_msr(AMD_MSR_EFER, read_msr(AMD_MSR_EFER) | AMD_SCE); 51 51 52 52 /* Setup syscall entry address */ -
kernel/arch/amd64/src/userspace.c
r153c7a29 r0dc2fec 48 48 void userspace(uspace_arg_t *kernel_uarg) 49 49 { 50 ipl_t ipl = interrupts_disable();50 uint64_t rflags = read_rflags(); 51 51 52 ipl &= ~(RFLAGS_CF | RFLAGS_PF | RFLAGS_AF | RFLAGS_ZF | RFLAGS_SF |53 RFLAGS_DF | RFLAGS_OF);52 rflags &= ~RFLAGS_NT; 53 rflags |= RFLAGS_IF; 54 54 55 55 asm volatile ( 56 56 "pushq %[udata_des]\n" 57 57 "pushq %[stack_top]\n" 58 "pushq %[ ipl]\n"58 "pushq %[rflags]\n" 59 59 "pushq %[utext_des]\n" 60 60 "pushq %[entry]\n" … … 67 67 [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack + 68 68 kernel_uarg->uspace_stack_size), 69 [ ipl] "r" (ipl),69 [rflags] "r" (rflags), 70 70 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), 71 71 [entry] "r" (kernel_uarg->uspace_entry), -
kernel/arch/arm32/include/arch/barrier.h
r153c7a29 r0dc2fec 97 97 #endif 98 98 99 #ifdef KERNEL 100 99 101 /* 100 102 * There are multiple ways ICache can be implemented on ARM machines. Namely … … 134 136 #endif 135 137 138 #endif /* KERNEL */ 136 139 137 140 #endif -
kernel/arch/ia32/Makefile.inc
r153c7a29 r0dc2fec 110 110 ARCH_AUTOGENS_AG = \ 111 111 arch/$(KARCH)/include/arch/istate_struct.ag \ 112 arch/$(KARCH)/include/arch/context_struct.ag 112 arch/$(KARCH)/include/arch/context_struct.ag \ 113 arch/$(KARCH)/include/arch/boot/memmap_struct.ag 113 114 -
kernel/arch/ia32/include/arch/asm.h
r153c7a29 r0dc2fec 87 87 GEN_WRITE_REG(cr3) 88 88 89 GEN_WRITE_REG(cr0) 90 89 91 GEN_READ_REG(dr0) 90 92 GEN_READ_REG(dr1) … … 232 234 } 233 235 234 /** Enable interrupts. 235 * 236 * Enable interrupts and return previous 237 * value of EFLAGS. 238 * 239 * @return Old interrupt priority level. 240 * 241 */ 242 NO_TRACE static inline ipl_t interrupts_enable(void) 243 { 244 ipl_t v; 245 236 NO_TRACE static inline uint32_t read_eflags(void) 237 { 238 uint32_t eflags; 239 246 240 asm volatile ( 247 241 "pushf\n" 248 242 "popl %[v]\n" 249 "sti\n" 250 : [v] "=r" (v) 251 ); 252 253 return v; 243 : [v] "=r" (eflags) 244 ); 245 246 return eflags; 247 } 248 249 NO_TRACE static inline void write_eflags(uint32_t eflags) 250 { 251 asm volatile ( 252 "pushl %[v]\n" 253 "popf\n" 254 :: [v] "r" (eflags) 255 ); 256 } 257 258 /** Return interrupt priority level. 259 * 260 * @return Current interrupt priority level. 261 */ 262 NO_TRACE static inline ipl_t interrupts_read(void) 263 { 264 return (ipl_t) read_eflags(); 265 } 266 267 /** Enable interrupts. 268 * 269 * Enable interrupts and return the previous interrupt priority level. 270 * 271 * @return Old interrupt priority level. 272 */ 273 NO_TRACE static inline ipl_t interrupts_enable(void) 274 { 275 ipl_t ipl = interrupts_read(); 276 277 asm volatile ("sti\n"); 278 279 return ipl; 254 280 } 255 281 256 282 /** Disable interrupts. 257 283 * 258 * Disable interrupts and return previous 259 * value of EFLAGS. 284 * Disable interrupts and return the previous interrupt priority level. 260 285 * 261 286 * @return Old interrupt priority level. 262 *263 287 */ 264 288 NO_TRACE static inline ipl_t interrupts_disable(void) 265 289 { 266 ipl_t v; 267 268 asm volatile ( 269 "pushf\n" 270 "popl %[v]\n" 271 "cli\n" 272 : [v] "=r" (v) 273 ); 274 275 return v; 290 ipl_t ipl = interrupts_read(); 291 292 asm volatile ("cli\n"); 293 294 return ipl; 276 295 } 277 296 278 297 /** Restore interrupt priority level. 279 298 * 280 * Restore EFLAGS.299 * Restore a saved interrupt priority level. 281 300 * 282 301 * @param ipl Saved interrupt priority level. … … 285 304 NO_TRACE static inline void interrupts_restore(ipl_t ipl) 286 305 { 287 asm volatile ( 288 "pushl %[ipl]\n" 289 "popf\n" 290 :: [ipl] "r" (ipl) 291 ); 292 } 293 294 /** Return interrupt priority level. 295 * 296 * @return EFLAFS. 297 * 298 */ 299 NO_TRACE static inline ipl_t interrupts_read(void) 300 { 301 ipl_t v; 302 303 asm volatile ( 304 "pushf\n" 305 "popl %[v]\n" 306 : [v] "=r" (v) 307 ); 308 309 return v; 306 write_eflags((uint32_t) ipl); 310 307 } 311 308 … … 317 314 NO_TRACE static inline bool interrupts_disabled(void) 318 315 { 319 ipl_t v; 320 321 asm volatile ( 322 "pushf\n" 323 "popl %[v]\n" 324 : [v] "=r" (v) 325 ); 326 327 return ((v & EFLAGS_IF) == 0); 316 return ((read_eflags() & EFLAGS_IF) == 0); 328 317 } 329 318 -
kernel/arch/ia32/include/arch/barrier.h
r153c7a29 r0dc2fec 98 98 #endif 99 99 100 #ifdef KERNEL 101 100 102 /* 101 103 * On ia32, the hardware takes care about instruction and data cache coherence, … … 107 109 #define smc_coherence_block(a, l) write_barrier() 108 110 111 #endif /* KERNEL */ 112 109 113 #endif 110 114 -
kernel/arch/ia32/include/arch/boot/memmap.h
r153c7a29 r0dc2fec 36 36 #define KERN_ia32_MEMMAP_H_ 37 37 38 #include <arch/boot/memmap_struct.h> 39 38 40 /* E820h memory range types */ 39 41 … … 63 65 #include <typedefs.h> 64 66 65 typedef struct {66 uint64_t base_address;67 uint64_t size;68 uint32_t type;69 } __attribute__ ((packed)) e820memmap_t;70 71 67 extern e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 72 68 extern uint8_t e820counter; -
kernel/arch/ia32/include/arch/cpu.h
r153c7a29 r0dc2fec 36 36 #define KERN_ia32_CPU_H_ 37 37 38 #define EFLAGS_IF (1 << 9) 39 #define EFLAGS_DF (1 << 10) 40 #define EFLAGS_NT (1 << 14) 41 #define EFLAGS_RF (1 << 16) 38 #define EFLAGS_IF (1 << 9) 39 #define EFLAGS_DF (1 << 10) 40 #define EFLAGS_IOPL (3 << 12) 41 #define EFLAGS_NT (1 << 14) 42 #define EFLAGS_RF (1 << 16) 43 #define EFLAGS_ID (1 << 21) 42 44 43 #define CR4_OSFXSR_MASK (1 << 9) 44 #define CR4_OSXMMEXCPT_MASK (1 << 10) 45 #define CR0_PE (1 << 0) 46 #define CR0_TS (1 << 3) 47 #define CR0_AM (1 << 18) 48 #define CR0_NW (1 << 29) 49 #define CR0_CD (1 << 30) 50 #define CR0_PG (1 << 31) 51 52 #define CR4_PSE (1 << 4) 53 #define CR4_PAE (1 << 5) 54 #define CR4_OSFXSR (1 << 9) 55 #define CR4_OSXMMEXCPT (1 << 10) 56 57 #define IA32_APIC_BASE_GE (1 << 11) 58 59 #define IA32_MSR_APIC_BASE 0x01b 45 60 46 61 /* Support for SYSENTER and SYSEXIT */ 47 #define IA32_MSR_SYSENTER_CS 0x174U48 #define IA32_MSR_SYSENTER_ESP 0x175U49 #define IA32_MSR_SYSENTER_EIP 0x176U62 #define IA32_MSR_SYSENTER_CS 0x174 63 #define IA32_MSR_SYSENTER_ESP 0x175 64 #define IA32_MSR_SYSENTER_EIP 0x176 50 65 51 66 #ifndef __ASM__ -
kernel/arch/ia32/include/arch/cpuid.h
r153c7a29 r0dc2fec 44 44 45 45 #include <typedefs.h> 46 #include <arch/cpu.h> 46 47 47 48 typedef struct { … … 84 85 85 86 asm volatile ( 86 "pushf\n" 87 "pushf\n" /* read flags */ 87 88 "popl %[ret]\n" 88 89 "movl %[ret], %[val]\n" 89 90 90 " btcl $21, %[val]\n"/* swap the ID bit */91 "xorl %[eflags_id], %[val]\n" /* swap the ID bit */ 91 92 92 "pushl %[val]\n" 93 "pushl %[val]\n" /* propagate the change into flags */ 93 94 "popf\n" 94 95 "pushf\n" 95 96 "popl %[val]\n" 96 97 97 "andl $(1 << 21), %[ret]\n"/* interrested only in ID bit */98 "andl $(1 << 21), %[val]\n"98 "andl %[eflags_id], %[ret]\n" /* interrested only in ID bit */ 99 "andl %[eflags_id], %[val]\n" 99 100 "xorl %[val], %[ret]\n" 100 101 : [ret] "=r" (ret), [val] "=r" (val) 102 : [eflags_id] "i" (EFLAGS_ID) 101 103 ); 102 104 -
kernel/arch/ia32/include/arch/interrupt.h
r153c7a29 r0dc2fec 50 50 #define IVT_FREEBASE (IVT_IRQBASE + IRQ_COUNT) 51 51 52 #define EXC_DE 0 53 #define EXC_NM 7 54 #define EXC_SS 12 55 #define EXC_GP 13 56 #define EXC_PF 14 57 #define EXC_XM 19 58 52 59 #define IRQ_CLK 0 53 60 #define IRQ_KBD 1 … … 65 72 #endif 66 73 67 #define VECTOR_DEBUG 1 74 #define VECTOR_DE (IVT_EXCBASE + EXC_DE) 75 #define VECTOR_NM (IVT_EXCBASE + EXC_NM) 76 #define VECTOR_SS (IVT_EXCBASE + EXC_SS) 77 #define VECTOR_GP (IVT_EXCBASE + EXC_GP) 78 #define VECTOR_PF (IVT_EXCBASE + EXC_PF) 79 #define VECTOR_XM (IVT_EXCBASE + EXC_XM) 68 80 #define VECTOR_CLK (IVT_IRQBASE + IRQ_CLK) 69 81 #define VECTOR_PIC_SPUR (IVT_IRQBASE + IRQ_PIC_SPUR) -
kernel/arch/ia32/include/arch/mm/page.h
r153c7a29 r0dc2fec 42 42 #define PAGE_SIZE FRAME_SIZE 43 43 44 #define PTE_P (1 << 0) 45 #define PTE_RW (1 << 1) 46 47 #define PDE_P (1 << 0) 48 #define PDE_RW (1 << 1) 49 #define PDE_4M (1 << 7) 50 44 51 #ifndef __ASM__ 45 52 -
kernel/arch/ia32/include/arch/smp/apic.h
r153c7a29 r0dc2fec 36 36 #define KERN_ia32_APIC_H_ 37 37 38 #define L_APIC_BASE 0xfee00000 39 #define IO_APIC_BASE 0xfec00000 40 41 #ifndef __ASM__ 42 38 43 #include <typedefs.h> 39 44 #include <cpu.h> … … 364 369 extern void io_apic_enable_irqs(uint16_t); 365 370 371 #endif /* __ASM__ */ 372 366 373 #endif 367 374 -
kernel/arch/ia32/src/asm.S
r153c7a29 r0dc2fec 36 36 #include <arch/mm/page.h> 37 37 #include <arch/istate_struct.h> 38 #include <arch/smp/apic.h> 38 39 39 40 .text … … 110 111 FUNCTION_BEGIN(paging_on) 111 112 movl %cr0, %edx 112 orl $ (1 << 31), %edx /* paging on */113 orl $CR0_PG, %edx /* paging on */ 113 114 114 115 /* Clear Cache Disable and not Write Though */ 115 andl $~( (1 << 30) | (1 << 29)), %edx116 andl $~(CR0_CD | CR0_NW), %edx 116 117 movl %edx, %cr0 117 118 jmp 0f … … 127 128 */ 128 129 FUNCTION_BEGIN(enable_l_apic_in_msr) 129 movl $ 0x1b, %ecx130 movl $IA32_MSR_APIC_BASE, %ecx 130 131 rdmsr 131 orl $(1 << 11), %eax 132 orl $(0xfee00000), %eax 132 orl $(L_APIC_BASE | IA32_APIC_BASE_GE), %eax 133 133 wrmsr 134 134 ret -
kernel/arch/ia32/src/boot/multiboot.S
r153c7a29 r0dc2fec 31 31 #include <abi/asmtool.h> 32 32 #include <arch/boot/boot.h> 33 #include <arch/boot/memmap.h> 33 34 #include <arch/mm/page.h> 34 35 #include <arch/pm.h> 35 36 #include <genarch/multiboot/multiboot.h> 36 37 #include <arch/cpuid.h> 38 #include <arch/cpu.h> 37 39 38 40 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) … … 166 168 /* Paging features */ 167 169 movl %cr4, %ecx 168 orl $ (1 << 4), %ecx/* PSE on */169 andl $ (~(1 << 5)), %ecx/* PAE off */170 orl $CR4_PSE, %ecx /* PSE on */ 171 andl $~CR4_PAE, %ecx /* PAE off */ 170 172 movl %ecx, %cr4 171 173 … … 176 178 177 179 floop_pse: 178 movl $( (1 << 7) | (1 << 1) | (1 << 0)), %eax180 movl $(PDE_4M | PDE_RW | PDE_P), %eax 179 181 orl %ebx, %eax 180 182 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ … … 191 193 192 194 movl %cr0, %ebx 193 orl $ (1 << 31), %ebx/* paging on */195 orl $CR0_PG, %ebx /* paging on */ 194 196 movl %ebx, %cr0 195 197 ret … … 205 207 /* Paging features */ 206 208 movl %cr4, %ecx 207 andl $ (~(1 << 5)), %ecx /* PAE off */209 andl $~CR4_PAE, %ecx /* PAE off */ 208 210 movl %ecx, %cr4 209 211 … … 220 222 221 223 /* Align address down to 4k */ 222 andl $(~ 4095), %esi224 andl $(~(PAGE_SIZE - 1)), %esi 223 225 224 226 use_kernel_end: 225 227 226 228 /* Align address to 4k */ 227 addl $ 4095, %esi228 andl $(~ 4095), %esi229 addl $(PAGE_SIZE - 1), %esi 230 andl $(~(PAGE_SIZE - 1)), %esi 229 231 230 232 /* Allocate space for page tables */ 231 233 movl %esi, pt_loc 232 movl $ballocs, %edi 233 andl $0x7fffffff, %edi 234 movl $KA2PA(ballocs), %edi 234 235 235 236 movl %esi, (%edi) … … 242 243 243 244 floop_pt: 244 movl $( (1 << 1) | (1 << 0)), %eax245 movl $(PTE_RW | PTE_P), %eax 245 246 orl %ebx, %eax 246 247 movl %eax, (%esi, %ecx, 4) 247 addl $ (4 * 1024), %ebx248 addl $PAGE_SIZE, %ebx 248 249 249 250 incl %ecx … … 259 260 260 261 floop: 261 movl $( (1 << 1) | (1 << 0)), %eax262 movl $(PDE_RW | PDE_P), %eax 262 263 orl %ebx, %eax 263 264 … … 267 268 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 268 269 movl %eax, (%edi, %ecx, 4) 269 addl $ (4 * 1024), %ebx270 addl $PAGE_SIZE, %ebx 270 271 271 272 incl %ecx … … 277 278 278 279 movl %cr0, %ebx 279 orl $ (1 << 31), %ebx /* paging on */280 orl $CR0_PG, %ebx /* paging on */ 280 281 movl %ebx, %cr0 281 282 … … 285 286 /** Calculate unmapped address of the end of the kernel. */ 286 287 calc_kernel_end: 287 movl $hardcoded_load_address, %edi 288 andl $0x7fffffff, %edi 288 movl $KA2PA(hardcoded_load_address), %edi 289 289 movl (%edi), %esi 290 andl $0x7fffffff, %esi 291 292 movl $hardcoded_ktext_size, %edi 293 andl $0x7fffffff, %edi 290 leal KA2PA(0)(%esi), %esi 291 292 movl $KA2PA(hardcoded_ktext_size), %edi 294 293 addl (%edi), %esi 295 andl $0x7fffffff, %esi 296 297 movl $hardcoded_kdata_size, %edi 298 andl $0x7fffffff, %edi 294 leal KA2PA(0)(%esi), %esi 295 296 movl $KA2PA(hardcoded_kdata_size), %edi 299 297 addl (%edi), %esi 300 andl $0x7fffffff, %esi298 leal KA2PA(0)(%esi), %esi 301 299 movl %esi, kernel_end 302 300 … … 318 316 /* Check if memory map flag is present */ 319 317 movl (%ebx), %edx 320 andl $ (1 << 6), %edx318 andl $MULTIBOOT_INFO_FLAGS_MMAP, %edx 321 319 jnz use_multiboot_map 322 320 … … 326 324 327 325 /* Copy address of the memory map to edx */ 328 movl 48(%ebx), %edx326 movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx 329 327 movl %edx, %ecx 330 328 331 addl 44(%ebx), %ecx329 addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx 332 330 333 331 /* Find a free region at least 2M in size */ … … 335 333 336 334 /* Is this a free region? */ 337 cmp $1, 20(%edx)335 cmpl $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx) 338 336 jnz next_region 339 337 340 338 /* Check size */ 341 cmp $0, 16(%edx)339 cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx) 342 340 jnz next_region 343 344 cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx) 341 cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx) 345 342 jbe next_region 346 343 347 cmp $0, 8(%edx)344 cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx) 348 345 jz found_region 349 346 … … 357 354 next_region_do: 358 355 359 addl (%edx), %edx360 addl $ 4, %edx356 addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx 357 addl $MULTIBOOT_MEMMAP_SIZE_SIZE, %edx 361 358 jmp check_memmap_loop 362 359 … … 364 361 365 362 /* Use end of the found region */ 366 mov 4(%edx), %ecx367 add 12(%edx), %ecx363 mov MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS(%edx), %ecx 364 add MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx), %ecx 368 365 sub $(2 * 1024 * 1024), %ecx 369 366 mov %ecx, free_area -
kernel/arch/ia32/src/boot/vesa_real.inc
r153c7a29 r0dc2fec 49 49 vesa_init_real: 50 50 mov %cr0, %eax 51 and $~ 1, %eax51 and $~CR0_PE, %eax 52 52 mov %eax, %cr0 53 53 … … 352 352 353 353 mov %cr0, %ecx 354 or $ 1, %ecx354 or $CR0_PE, %ecx 355 355 mov %ecx, %cr0 356 356 -
kernel/arch/ia32/src/cpu/cpu.c
r153c7a29 r0dc2fec 72 72 void fpu_disable(void) 73 73 { 74 asm volatile ( 75 "mov %%cr0, %%eax\n" 76 "or $8, %%eax\n" 77 "mov %%eax, %%cr0\n" 78 ::: "%eax" 79 ); 74 write_cr0(read_cr0() & ~CR0_TS); 80 75 } 81 76 82 77 void fpu_enable(void) 83 78 { 84 asm volatile ( 85 "mov %%cr0, %%eax\n" 86 "and $0xffFFffF7, %%eax\n" 87 "mov %%eax,%%cr0\n" 88 ::: "%eax" 89 ); 79 write_cr0(read_cr0() | CR0_TS); 90 80 } 91 81 … … 115 105 "mov %[help], %%cr4\n" 116 106 : [help] "+r" (help) 117 : [mask] "i" (CR4_OSFXSR _MASK | CR4_OSXMMEXCPT_MASK)107 : [mask] "i" (CR4_OSFXSR | CR4_OSXMMEXCPT) 118 108 ); 119 109 } -
kernel/arch/ia32/src/interrupt.c
r153c7a29 r0dc2fec 229 229 } 230 230 231 exc_register( 0, "de_fault", true, (iroutine_t) de_fault);232 exc_register( 7, "nm_fault", true, (iroutine_t) nm_fault);233 exc_register( 12, "ss_fault", true, (iroutine_t) ss_fault);234 exc_register( 13, "gp_fault", true, (iroutine_t) gp_fault);235 exc_register( 19, "simd_fp", true, (iroutine_t) simd_fp_exception);231 exc_register(VECTOR_DE, "de_fault", true, (iroutine_t) de_fault); 232 exc_register(VECTOR_NM, "nm_fault", true, (iroutine_t) nm_fault); 233 exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault); 234 exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault); 235 exc_register(VECTOR_XM, "simd_fp", true, (iroutine_t) simd_fp_exception); 236 236 237 237 #ifdef CONFIG_SMP -
kernel/arch/ia32/src/mm/page.c
r153c7a29 r0dc2fec 76 76 page_table_unlock(AS_KERNEL, true); 77 77 78 exc_register( 14, "page_fault", true, (iroutine_t) page_fault);78 exc_register(VECTOR_PF, "page_fault", true, (iroutine_t) page_fault); 79 79 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table); 80 80 -
kernel/arch/ia32/src/pm.c
r153c7a29 r0dc2fec 47 47 #include <arch/boot/boot.h> 48 48 #include <interrupt.h> 49 #include <arch/cpu.h> 49 50 50 51 /* … … 61 62 */ 62 63 descriptor_t gdt[GDT_ITEMS] = { 63 /* NULL descriptor */ 64 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 65 /* KTEXT descriptor */ 66 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 67 /* KDATA descriptor */ 68 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 1, 1, 0 }, 69 /* UTEXT descriptor */ 70 { 0xffff, 0, 0, AR_PRESENT | AR_CODE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 71 /* UDATA descriptor */ 72 { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 73 /* TSS descriptor - set up will be completed later */ 74 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 75 /* VREG descriptor - segment used for virtual registers, will be reinitialized later */ 76 { 0xffff, 0 , 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 }, 64 [NULL_DES] = { 65 0 66 }, 67 [KTEXT_DES] = { 68 .limit_0_15 = 0xffff, 69 .limit_16_19 = 0xf, 70 .access = AR_PRESENT | AR_CODE | DPL_KERNEL, 71 .special = 1, 72 .granularity = 1 73 }, 74 [KDATA_DES] = { 75 .limit_0_15 = 0xffff, 76 .limit_16_19 = 0xf, 77 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 78 .special = 1, 79 .granularity = 1 80 }, 81 [UTEXT_DES] = { 82 .limit_0_15 = 0xffff, 83 .limit_16_19 = 0xf, 84 .access = AR_PRESENT | AR_CODE | DPL_USER, 85 .special = 1, 86 .granularity = 1 87 }, 88 [UDATA_DES] = { 89 .limit_0_15 = 0xffff, 90 .limit_16_19 = 0xf, 91 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 92 .special = 1, 93 .granularity = 1 94 }, 95 [TSS_DES] = { /* set up will be completed later */ 96 0, 97 }, 98 [VREG_DES] = { /* will be reinitialized later */ 99 .limit_0_15 = 0xffff, 100 .limit_16_19 = 0xf, 101 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 102 .special = 1, 103 .granularity = 1 104 }, 77 105 /* VESA Init descriptor */ 78 106 #ifdef CONFIG_FB 79 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 }, 80 { 0xffff, 0, VESA_INIT_SEGMENT >> 12, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL, 0xf, 0, 0, 0, 0, 0 } 107 [VESA_INIT_CODE_DES] = { 108 .limit_0_15 = 0xffff, 109 .limit_16_19 = 0xf, 110 .base_16_23 = VESA_INIT_SEGMENT >> 12, 111 .access = AR_PRESENT | AR_CODE | AR_READABLE | DPL_KERNEL 112 }, 113 [VESA_INIT_DATA_DES] = { 114 .limit_0_15 = 0xffff, 115 .limit_16_19 = 0xf, 116 .base_16_23 = VESA_INIT_SEGMENT >> 12, 117 .access = AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_KERNEL 118 } 81 119 #endif 82 120 }; … … 219 257 } 220 258 221 /* Clean IOPL(12,13) and NT(14) flags in EFLAGS register */222 static void clean_IOPL_NT_flags(void)223 {224 asm volatile (225 "pushfl\n"226 "pop %%eax\n"227 "and $0xffff8fff, %%eax\n"228 "push %%eax\n"229 "popfl\n"230 ::: "eax"231 );232 }233 234 /* Clean AM(18) flag in CR0 register */235 static void clean_AM_flag(void)236 {237 asm volatile (238 "mov %%cr0, %%eax\n"239 "and $0xfffbffff, %%eax\n"240 "mov %%eax, %%cr0\n"241 ::: "eax"242 );243 }244 245 259 void pm_init(void) 246 260 { … … 289 303 tr_load(GDT_SELECTOR(TSS_DES)); 290 304 291 clean_IOPL_NT_flags(); /* Disable I/O on nonprivileged levels and clear NT flag. */ 292 clean_AM_flag(); /* Disable alignment check */ 305 /* Disable I/O on nonprivileged levels and clear NT flag. */ 306 write_eflags(read_eflags() & ~(EFLAGS_IOPL | EFLAGS_NT)); 307 308 /* Disable alignment check */ 309 write_cr0(read_cr0() & ~CR0_AM); 293 310 } 294 311 -
kernel/arch/ia32/src/smp/ap.S
r153c7a29 r0dc2fec 37 37 #include <arch/mm/page.h> 38 38 #include <arch/pm.h> 39 #include <arch/cpu.h> 40 #include <arch/context_struct.h> 39 41 40 42 .section K_TEXT_START, "ax" … … 63 65 /* switch to protected mode */ 64 66 movl %cr0, %eax 65 orl $ 1, %eax67 orl $CR0_PE, %eax 66 68 movl %eax, %cr0 67 69 jmpl $KTEXT, $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET … … 73 75 movw %ax, %es 74 76 movw %ax, %ss 75 movl $KA2PA(ctx), %eax 76 movl (%eax), %esp77 subl $0x80000000, %esp/* KA2PA(ctx.sp) */77 movl $KA2PA(ctx), %eax /* KA2PA((uintptr_t) &ctx) */ 78 movl CONTEXT_OFFSET_SP(%eax), %esp 79 leal KA2PA(0)(%esp), %esp /* KA2PA(ctx.sp) */ 78 80 79 81 /* … … 83 85 call map_kernel_pse 84 86 85 addl $ 0x80000000, %esp /*PA2KA(ctx.sp) */87 addl $PA2KA(0), %esp /* PA2KA(ctx.sp) */ 86 88 87 89 /* create the first stack frame */ -
kernel/arch/ia32/src/smp/apic.c
r153c7a29 r0dc2fec 72 72 * 73 73 */ 74 volatile uint32_t *l_apic = (uint32_t *) UINT32_C(0xfee00000);75 volatile uint32_t *io_apic = (uint32_t *) UINT32_C(0xfec00000);74 volatile uint32_t *l_apic = (uint32_t *) L_APIC_BASE; 75 volatile uint32_t *io_apic = (uint32_t *) IO_APIC_BASE; 76 76 77 77 uint32_t apic_id_mask = 0; -
kernel/arch/ia32/src/userspace.c
r153c7a29 r0dc2fec 39 39 #include <abi/proc/uarg.h> 40 40 #include <mm/as.h> 41 #include <arch/cpu.h> 42 #include <arch/asm.h> 41 43 42 44 /** Enter userspace … … 47 49 void userspace(uspace_arg_t *kernel_uarg) 48 50 { 49 ipl_t ipl = interrupts_disable();51 uint32_t eflags = read_eflags(); 50 52 51 53 asm volatile ( 52 /*53 * Clear nested task flag.54 */55 "pushfl\n"56 "pop %%eax\n"57 "and $0xffffbfff, %%eax\n"58 "push %%eax\n"59 "popfl\n"60 61 54 /* Set up GS register (virtual register segment) */ 62 55 "movl %[vreg_des], %%gs\n" … … 64 57 "pushl %[udata_des]\n" 65 58 "pushl %[stack_top]\n" 66 "pushl %[ ipl]\n"59 "pushl %[eflags]\n" 67 60 "pushl %[utext_des]\n" 68 61 "pushl %[entry]\n" … … 74 67 "iret\n" 75 68 : 76 : [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 69 : [eflags_mask] "i" (~EFLAGS_NT), 70 [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER), 77 71 [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack + 78 72 kernel_uarg->uspace_stack_size), 79 [ ipl] "r" (ipl),73 [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF), 80 74 [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER), 81 75 [entry] "r" (kernel_uarg->uspace_entry), -
kernel/arch/ia64/include/arch/barrier.h
r153c7a29 r0dc2fec 56 56 asm volatile (";; sync.i\n" ::: "memory") 57 57 58 #ifdef KERNEL 59 58 60 #define smc_coherence(a) \ 59 61 { \ … … 73 75 } 74 76 77 #endif /* KERNEL */ 78 75 79 #endif 76 80 -
kernel/arch/ia64/include/arch/mm/page.h
r153c7a29 r0dc2fec 59 59 #define REGION_REGISTERS 8 60 60 61 #define KA2PA(x) (( uintptr_t) ((x) - (VRN_KERNEL << VRN_SHIFT)))62 #define PA2KA(x) (( uintptr_t) ((x) + (VRN_KERNEL << VRN_SHIFT)))61 #define KA2PA(x) (((uintptr_t) (x)) - (VRN_KERNEL << VRN_SHIFT)) 62 #define PA2KA(x) (((uintptr_t) (x)) + (VRN_KERNEL << VRN_SHIFT)) 63 63 64 64 #define VHPT_WIDTH 20 /* 1M */ -
kernel/arch/mips32/include/arch/barrier.h
r153c7a29 r0dc2fec 46 46 #define write_barrier() asm volatile ("" ::: "memory") 47 47 48 #ifdef KERNEL 49 48 50 #define smc_coherence(a) 49 51 #define smc_coherence_block(a, l) 52 53 #endif /* KERNEL */ 50 54 51 55 #endif -
kernel/arch/ppc32/include/arch/barrier.h
r153c7a29 r0dc2fec 51 51 ) 52 52 53 #ifdef KERNEL 54 53 55 #define COHERENCE_INVAL_MIN 4 54 56 … … 93 95 } 94 96 97 #endif /* KERNEL */ 98 95 99 #endif 96 100 -
kernel/arch/sparc32/include/arch/barrier.h
r153c7a29 r0dc2fec 70 70 ) 71 71 72 #ifdef KERNEL 72 73 #define smc_coherence(addr) 73 74 #define smc_coherence_block(addr, size) 75 #endif /* KERNEL */ 74 76 75 77 #endif -
kernel/arch/sparc64/include/arch/barrier.h
r153c7a29 r0dc2fec 116 116 } 117 117 118 #if defined (US) 118 #ifdef KERNEL 119 120 #if defined(US) 119 121 120 122 #define FLUSH_INVAL_MIN 4 … … 151 153 #endif /* defined(US3) */ 152 154 155 #endif /* KERNEL */ 156 153 157 #endif 154 158 -
kernel/genarch/Makefile.inc
r153c7a29 r0dc2fec 30 30 31 31 ifeq ($(CONFIG_ACPI),y) 32 33 34 32 GENARCH_SOURCES += \ 33 genarch/src/acpi/acpi.c \ 34 genarch/src/acpi/madt.c 35 35 endif 36 36 37 37 ifeq ($(CONFIG_PAGE_PT),y) 38 39 40 38 GENARCH_SOURCES += \ 39 genarch/src/mm/page_pt.c \ 40 genarch/src/mm/as_pt.c 41 41 endif 42 42 43 43 ifeq ($(CONFIG_PAGE_HT),y) 44 45 46 44 GENARCH_SOURCES += \ 45 genarch/src/mm/page_ht.c \ 46 genarch/src/mm/as_ht.c 47 47 endif 48 48 49 49 ifeq ($(CONFIG_ASID),y) 50 51 50 GENARCH_SOURCES += \ 51 genarch/src/mm/asid.c 52 52 endif 53 53 54 54 ifeq ($(CONFIG_ASID_FIFO),y) 55 56 55 GENARCH_SOURCES += \ 56 genarch/src/mm/asid_fifo.c 57 57 endif 58 58 59 59 ifeq ($(CONFIG_SOFTINT),y) 60 61 62 60 GENARCH_SOURCES += \ 61 genarch/src/softint/division.c \ 62 genarch/src/softint/multiplication.c 63 63 endif 64 64 65 65 ifeq ($(CONFIG_FB),y) 66 67 68 69 66 GENARCH_SOURCES += \ 67 genarch/src/fb/font-8x16.c \ 68 genarch/src/fb/fb.c \ 69 genarch/src/fb/bfb.c 70 70 endif 71 71 72 72 ifeq ($(CONFIG_DSRLNIN),y) 73 74 73 GENARCH_SOURCES += \ 74 genarch/src/drivers/dsrln/dsrlnin.c 75 75 endif 76 76 77 77 ifeq ($(CONFIG_DSRLNOUT),y) 78 79 78 GENARCH_SOURCES += \ 79 genarch/src/drivers/dsrln/dsrlnout.c 80 80 endif 81 81 82 82 ifeq ($(CONFIG_I8042),y) 83 84 83 GENARCH_SOURCES += \ 84 genarch/src/drivers/i8042/i8042.c 85 85 endif 86 86 87 87 ifeq ($(CONFIG_NS16550),y) 88 89 88 GENARCH_SOURCES += \ 89 genarch/src/drivers/ns16550/ns16550.c 90 90 endif 91 91 92 92 ifeq ($(CONFIG_PL011_UART),y) 93 94 93 GENARCH_SOURCES += \ 94 genarch/src/drivers/pl011/pl011.c 95 95 endif 96 96 97 97 ifeq ($(CONFIG_S3C24XX_IRQC),y) 98 99 98 GENARCH_SOURCES += \ 99 genarch/src/drivers/s3c24xx/irqc.c 100 100 endif 101 101 102 102 ifeq ($(CONFIG_S3C24XX_UART),y) 103 104 103 GENARCH_SOURCES += \ 104 genarch/src/drivers/s3c24xx/uart.c 105 105 endif 106 106 107 107 ifeq ($(CONFIG_OMAP_UART),y) 108 109 108 GENARCH_SOURCES += \ 109 genarch/src/drivers/omap/uart.c 110 110 endif 111 111 112 112 ifeq ($(CONFIG_GRLIB_UART),y) 113 114 113 GENARCH_SOURCES += \ 114 genarch/src/drivers/grlib/uart.c 115 115 endif 116 116 117 117 ifeq ($(CONFIG_GRLIB_IRQMP),y) 118 119 118 GENARCH_SOURCES += \ 119 genarch/src/drivers/grlib/irqmp.c 120 120 endif 121 121 122 122 ifeq ($(CONFIG_AM335X_TIMERS),y) 123 124 123 GENARCH_SOURCES += \ 124 genarch/src/drivers/am335x/timer.c 125 125 endif 126 126 127 127 ifeq ($(CONFIG_BCM2835_MAILBOX),y) 128 129 128 GENARCH_SOURCES += \ 129 genarch/src/drivers/bcm2835/mbox.c 130 130 endif 131 131 132 132 ifeq ($(CONFIG_VIA_CUDA),y) 133 134 133 GENARCH_SOURCES += \ 134 genarch/src/drivers/via-cuda/cuda.c 135 135 endif 136 136 137 137 ifeq ($(CONFIG_PC_KBD),y) 138 GENARCH_SOURCES += \ 139 genarch/src/kbrd/kbrd.c \ 140 genarch/src/kbrd/scanc_pc.c 138 GENARCH_SOURCES += \ 139 genarch/src/kbrd/kbrd.c \ 140 genarch/src/kbrd/scanc_pc.c 141 endif 142 143 ifeq ($(CONFIG_AT_KBD),y) 144 GENARCH_SOURCES += \ 145 genarch/src/kbrd/kbrd_at.c \ 146 genarch/src/kbrd/scanc_at.c 141 147 endif 142 148 143 149 ifeq ($(CONFIG_SUN_KBD),y) 144 145 146 150 GENARCH_SOURCES += \ 151 genarch/src/kbrd/kbrd.c \ 152 genarch/src/kbrd/scanc_sun.c 147 153 endif 148 154 149 155 ifeq ($(CONFIG_MAC_KBD),y) 150 151 152 156 GENARCH_SOURCES += \ 157 genarch/src/kbrd/kbrd.c \ 158 genarch/src/kbrd/scanc_mac.c 153 159 endif 154 160 155 161 ifeq ($(CONFIG_SRLN),y) 156 157 162 GENARCH_SOURCES += \ 163 genarch/src/srln/srln.c 158 164 endif 159 165 160 166 ifeq ($(CONFIG_OFW_TREE),y) 161 162 167 GENARCH_SOURCES += \ 168 genarch/src/ofw/ofw_tree.c 163 169 endif 164 170 165 171 ifeq ($(CONFIG_OFW_PCI),y) 166 167 168 169 170 172 GENARCH_SOURCES += \ 173 genarch/src/ofw/ebus.c \ 174 genarch/src/ofw/pci.c \ 175 genarch/src/ofw/sbus.c \ 176 genarch/src/ofw/upa.c 171 177 endif 172 178 173 179 ifeq ($(CONFIG_MULTIBOOT), y) 174 GENARCH_SOURCES += \ 175 genarch/src/multiboot/multiboot.c \ 176 genarch/src/multiboot/multiboot2.c 180 GENARCH_SOURCES += \ 181 genarch/src/multiboot/multiboot.c \ 182 genarch/src/multiboot/multiboot2.c 183 GENARCH_AUTOGENS_AG += \ 184 genarch/include/genarch/multiboot/multiboot_memmap_struct.ag \ 185 genarch/include/genarch/multiboot/multiboot_info_struct.ag 177 186 endif 178 187 179 188 ifeq ($(CONFIG_EGA), y) 180 181 189 GENARCH_SOURCES += \ 190 genarch/src/drivers/ega/ega.c 182 191 endif 183 192 184 193 ifeq ($(CONFIG_IOMAP_BITMAP), y) 185 186 194 GENARCH_SOURCES += \ 195 genarch/src/ddi/ddi-bitmap.c 187 196 endif 188 197 189 198 ifeq ($(CONFIG_IOMAP_DUMMY), y) 190 191 192 endif 193 199 GENARCH_SOURCES += \ 200 genarch/src/ddi/ddi-dummy.c 201 endif 202 -
kernel/genarch/include/genarch/kbrd/scanc_at.h
r153c7a29 r0dc2fec 32 32 /** 33 33 * @file 34 * @brief Scan codes for pl050keyboards.34 * @brief Scan codes for PC/AT keyboards. 35 35 */ 36 36 37 #ifndef KERN_SCANC_ PL050_H_38 #define KERN_SCANC_ PL050_H_37 #ifndef KERN_SCANC_AT_H_ 38 #define KERN_SCANC_AT_H_ 39 39 40 40 #define SC_SCAN_ESCAPE 0xE0 -
kernel/genarch/include/genarch/multiboot/multiboot.h
r153c7a29 r0dc2fec 36 36 #define KERN_MULTIBOOT_H_ 37 37 38 #include <genarch/multiboot/multiboot_memmap_struct.h> 39 #include <genarch/multiboot/multiboot_info_struct.h> 40 38 41 #define MULTIBOOT_HEADER_MAGIC 0x1badb002 39 42 #define MULTIBOOT_HEADER_FLAGS 0x00010003 40 43 41 44 #define MULTIBOOT_LOADER_MAGIC 0x2badb002 45 46 #define MULTIBOOT_INFO_FLAGS_MEM 0x01 47 #define MULTIBOOT_INFO_FLAGS_BOOT 0x02 48 #define MULTIBOOT_INFO_FLAGS_CMDLINE 0x04 49 #define MULTIBOOT_INFO_FLAGS_MODS 0x08 50 #define MULTIBOOT_INFO_FLAGS_SYMS1 0x10 51 #define MULTIBOOT_INFO_FLAGS_SYMS2 0x20 52 #define MULTIBOOT_INFO_FLAGS_MMAP 0x40 42 53 43 54 #ifndef __ASM__ … … 60 71 } __attribute__((packed)) multiboot_module_t; 61 72 62 /** Multiboot mmap structure */63 typedef struct {64 uint32_t size;65 e820memmap_t mm_info;66 } __attribute__((packed)) multiboot_memmap_t;67 68 /** Multiboot information structure */69 typedef struct {70 uint32_t flags;71 uint32_t mem_lower;72 uint32_t mem_upper;73 74 uint32_t boot_device;75 uint32_t cmdline;76 77 uint32_t mods_count;78 mbaddr_t mods_addr;79 80 uint32_t syms[4];81 82 uint32_t mmap_length;83 mbaddr_t mmap_addr;84 85 /* ... */86 } __attribute__((packed)) multiboot_info_t;87 88 enum multiboot_info_flags {89 MULTIBOOT_INFO_FLAGS_MEM = 0x01,90 MULTIBOOT_INFO_FLAGS_BOOT = 0x02,91 MULTIBOOT_INFO_FLAGS_CMDLINE = 0x04,92 MULTIBOOT_INFO_FLAGS_MODS = 0x08,93 MULTIBOOT_INFO_FLAGS_SYMS1 = 0x10,94 MULTIBOOT_INFO_FLAGS_SYMS2 = 0x20,95 MULTIBOOT_INFO_FLAGS_MMAP = 0x4096 97 /* ... */98 };99 100 73 extern void multiboot_extract_command(char *, size_t, const char *); 101 74 extern void multiboot_extract_argument(char *, size_t, const char *); -
kernel/genarch/src/drivers/grlib/uart.c
r153c7a29 r0dc2fec 52 52 grlib_uart_status_t *status; 53 53 grlib_uart_t *uart = (grlib_uart_t *) dev->data; 54 uint32_t reg; 54 55 55 56 /* Wait for space becoming available in Tx FIFO. */ 56 57 do { 57 uint32_treg = pio_read_32(&uart->io->status);58 reg = pio_read_32(&uart->io->status); 58 59 status = (grlib_uart_status_t *) ® 59 60 } while (status->tf != 0); -
kernel/generic/include/adt/list.h
r153c7a29 r0dc2fec 76 76 #define list_foreach(list, member, itype, iterator) \ 77 77 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \ 78 79 iterator = list_get_instance(_link, itype, member), \80 _link != &(list).head; _link = _link->next)78 for (link_t *_link = (list).head.next; \ 79 iterator = list_get_instance(_link, itype, member), \ 80 _link != &(list).head; _link = _link->next) 81 81 82 82 #define list_foreach_rev(list, member, itype, iterator) \ 83 83 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \ 84 85 iterator = list_get_instance(_link, itype, member), \86 _link != &(list).head; _link = _link->prev)84 for (link_t *_link = (list).head.prev; \ 85 iterator = list_get_instance(_link, itype, member), \ 86 _link != &(list).head; _link = _link->prev) 87 87 88 88 /** Unlike list_foreach(), allows removing items while traversing a list. … … 113 113 #define list_foreach_safe(list, iterator, next_iter) \ 114 114 for (link_t *iterator = (list).head.next, \ 115 116 117 115 *next_iter = iterator->next; \ 116 iterator != &(list).head; \ 117 iterator = next_iter, next_iter = iterator->next) 118 118 119 119 -
kernel/generic/src/adt/cht.c
r153c7a29 r0dc2fec 526 526 ASSERT(op && op->hash && op->key_hash && op->equal && op->key_equal); 527 527 /* Memoized hashes are stored in the rcu_link.func function pointer. */ 528 ASSERT(sizeof(size_t) == sizeof(rcu_func_t));528 STATIC_ASSERT(sizeof(size_t) == sizeof(rcu_func_t)); 529 529 ASSERT(sentinel.hash == (uintptr_t)sentinel.rcu_link.func); 530 530 … … 1311 1311 } 1312 1312 } else { 1313 ASSERT(N_JOIN == N_JOIN_FOLLOWS);1313 STATIC_ASSERT(N_JOIN == N_JOIN_FOLLOWS); 1314 1314 1315 1315 /* Keep the N_JOIN/N_JOIN_FOLLOWS mark but strip N_DELETED. */ -
kernel/generic/src/main/kinit.c
r153c7a29 r0dc2fec 240 240 name = "<unknown>"; 241 241 242 ASSERT(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN);242 STATIC_ASSERT(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN); 243 243 str_cpy(namebuf, TASK_NAME_BUFLEN, INIT_PREFIX); 244 244 str_cpy(namebuf + INIT_PREFIX_LEN,
Note:
See TracChangeset
for help on using the changeset viewer.