Changeset 128359eb in mainline
- Timestamp:
- 2020-06-12T16:46:32Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ffccdff0
- Parents:
- 94e75cf
- Location:
- kernel
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/arch/asm.h
r94e75cf r128359eb 188 188 } 189 189 190 _NO_TRACE static inline uintptr_t get_stack_base(void)191 {192 /*193 * On real hardware this returns the address of the bottom194 * of the current CPU stack. The current_t structure is stored195 * on the bottom of stack and this is used to identify the196 * current CPU, current task, current thread and current197 * address space.198 */199 200 return 0;201 }202 203 190 #endif 204 191 -
kernel/arch/amd64/include/arch/asm.h
r94e75cf r128359eb 42 42 43 43 #define IO_SPACE_BOUNDARY ((void *) (64 * 1024)) 44 45 /** Return base address of current stack.46 *47 * Return the base address of the current stack.48 * The stack is assumed to be STACK_SIZE bytes long.49 * The stack must start on page boundary.50 *51 */52 _NO_TRACE static inline uintptr_t get_stack_base(void)53 {54 uintptr_t v;55 56 asm volatile (57 "andq %%rsp, %[v]\n"58 : [v] "=r" (v)59 : "0" (~((uint64_t) STACK_SIZE - 1))60 );61 62 return v;63 }64 44 65 45 _NO_TRACE static inline void cpu_sleep(void) -
kernel/arch/arm32/include/arch/asm.h
r94e75cf r128359eb 95 95 } 96 96 97 /** Return base address of current stack.98 *99 * Return the base address of the current stack.100 * The stack is assumed to be STACK_SIZE bytes long.101 * The stack must start on page boundary.102 *103 */104 _NO_TRACE static inline uintptr_t get_stack_base(void)105 {106 uintptr_t v;107 108 asm volatile (109 "and %[v], sp, %[size]\n"110 : [v] "=r" (v)111 : [size] "r" (~(STACK_SIZE - 1))112 );113 114 return v;115 }116 117 97 extern void cpu_halt(void) __attribute__((noreturn)); 118 98 extern void asm_delay_loop(uint32_t t); -
kernel/arch/arm32/include/arch/context.h
r94e75cf r128359eb 42 42 #include <arch/regutils.h> 43 43 44 /* Put one item onto the stack to support get_stack_base()and align it up. */44 /* Put one item onto the stack to support CURRENT and align it up. */ 45 45 #define SP_DELTA (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)) 46 46 -
kernel/arch/arm64/include/arch/asm.h
r94e75cf r128359eb 52 52 { 53 53 asm volatile ("wfe"); 54 }55 56 /** Return base address of current stack.57 *58 * Return the base address of the current stack.59 * The stack is assumed to be STACK_SIZE bytes long.60 * The stack must start on page boundary.61 */62 _NO_TRACE static inline uintptr_t get_stack_base(void)63 {64 uintptr_t v;65 66 asm volatile (67 "mov %[v], sp\n"68 "and %[v], %[v], %[size]\n"69 : [v] "=&r" (v)70 : [size] "r" (~((uint64_t) STACK_SIZE - 1))71 );72 73 return v;74 54 } 75 55 -
kernel/arch/arm64/include/arch/context.h
r94e75cf r128359eb 41 41 #include <arch/stack.h> 42 42 43 /* Put one item onto the stack to support get_stack_base()and align it up. */43 /* Put one item onto the stack to support CURRENT and align it up. */ 44 44 #define SP_DELTA (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)) 45 45 -
kernel/arch/ia32/include/arch/asm.h
r94e75cf r128359eb 348 348 349 349 #endif /* PROCESSOR_i486 */ 350 351 /** Return base address of current stack352 *353 * Return the base address of the current stack.354 * The stack is assumed to be STACK_SIZE bytes long.355 * The stack must start on page boundary.356 *357 */358 _NO_TRACE static inline uintptr_t get_stack_base(void)359 {360 uintptr_t v;361 362 asm volatile (363 "andl %%esp, %[v]\n"364 : [v] "=r" (v)365 : "0" (~(STACK_SIZE - 1))366 );367 368 return v;369 }370 350 371 351 /** Invalidate TLB Entry. -
kernel/arch/ia32/include/arch/context.h
r94e75cf r128359eb 45 45 * First for pop of the saved register, second during ret instruction. 46 46 * 47 * One item is put onto stack to support get_stack_base().47 * One item is put onto stack to support CURRENT. 48 48 */ 49 49 #define SP_DELTA (8 + STACK_ITEM_SIZE) -
kernel/arch/ia64/include/arch/asm.h
r94e75cf r128359eb 160 160 } 161 161 162 /** Return base address of current memory stack.163 *164 * The memory stack is assumed to be STACK_SIZE / 2 long. Note that there is165 * also the RSE stack, which takes up the upper half of STACK_SIZE.166 * The memory stack must start on page boundary.167 */168 _NO_TRACE static inline uintptr_t get_stack_base(void)169 {170 uint64_t value;171 172 asm volatile (173 "mov %[value] = r12"174 : [value] "=r" (value)175 );176 177 return (value & (~(STACK_SIZE / 2 - 1)));178 }179 180 162 /** Return Processor State Register. 181 163 * -
kernel/arch/ia64/include/arch/context.h
r94e75cf r128359eb 46 46 * No need to allocate scratch area. 47 47 * 48 * One item is put onto the stack to support get_stack_base().48 * One item is put onto the stack to support CURRENT. 49 49 */ 50 50 #define SP_DELTA (0 + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)) -
kernel/arch/mips32/include/arch/asm.h
r94e75cf r128359eb 45 45 } 46 46 47 /** Return base address of current stack48 *49 * Return the base address of the current stack.50 * The stack is assumed to be STACK_SIZE bytes long.51 * The stack must start on page boundary.52 *53 */54 _NO_TRACE static inline uintptr_t get_stack_base(void)55 {56 uintptr_t base;57 58 asm volatile (59 "and %[base], $29, %[mask]\n"60 : [base] "=r" (base)61 : [mask] "r" (~(STACK_SIZE - 1))62 );63 64 return base;65 }66 67 47 _NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v) 68 48 { -
kernel/arch/mips32/include/arch/context.h
r94e75cf r128359eb 41 41 42 42 /* 43 * Put one item onto the stack to support get_stack_base()and align it up.43 * Put one item onto the stack to support CURRENT and align it up. 44 44 */ 45 45 #define SP_DELTA (ABI_STACK_FRAME + ALIGN_UP(STACK_ITEM_SIZE, STACK_ALIGNMENT)) -
kernel/arch/ppc32/include/arch/asm.h
r94e75cf r128359eb 163 163 } 164 164 165 /** Return base address of current stack.166 *167 * Return the base address of the current stack.168 * The stack is assumed to be STACK_SIZE bytes long.169 * The stack must start on page boundary.170 *171 */172 _NO_TRACE static inline uintptr_t get_stack_base(void)173 {174 uintptr_t base;175 176 asm volatile (177 "and %[base], %%sp, %[mask]\n"178 : [base] "=r" (base)179 : [mask] "r" (~(STACK_SIZE - 1))180 );181 182 return base;183 }184 185 165 _NO_TRACE static inline void cpu_sleep(void) 186 166 { -
kernel/arch/riscv64/include/arch/asm.h
r94e75cf r128359eb 91 91 } 92 92 93 _NO_TRACE static inline uintptr_t get_stack_base(void)94 {95 uintptr_t base;96 97 asm volatile (98 "and %[base], sp, %[mask]\n"99 : [base] "=r" (base)100 : [mask] "r" (~(STACK_SIZE - 1))101 );102 103 return base;104 }105 106 93 _NO_TRACE static inline void cpu_sleep(void) 107 94 { -
kernel/arch/sparc64/include/arch/asm.h
r94e75cf r128359eb 382 382 } 383 383 384 /** Return base address of current stack.385 *386 * Return the base address of the current stack.387 * The stack is assumed to be STACK_SIZE bytes long.388 * The stack must start on page boundary.389 *390 */391 _NO_TRACE static inline uintptr_t get_stack_base(void)392 {393 uintptr_t unbiased_sp;394 395 asm volatile (396 "add %%sp, %[stack_bias], %[unbiased_sp]\n"397 : [unbiased_sp] "=r" (unbiased_sp)398 : [stack_bias] "i" (STACK_BIAS)399 );400 401 return ALIGN_DOWN(unbiased_sp, STACK_SIZE);402 }403 404 384 /** Read Version Register. 405 385 * -
kernel/generic/include/arch.h
r94e75cf r128359eb 36 36 #define KERN_ARCH_H_ 37 37 38 #include <arch/asm.h> /* get_stack_base() */39 38 #include <config.h> 40 39 41 /* 40 /** Return the current_t structure 41 * 42 42 * The current_t structure holds pointers to various parts of the current 43 43 * execution state, like running task, thread, address space, etc. 44 * 45 * The current_t structure is located at the base address of the current 46 * stack. The stack is assumed to be STACK_SIZE bytes long. The stack base 47 * address must be aligned to STACK_SIZE. 48 * 44 49 */ 45 #define CURRENT ((current_t * )(get_stack_base())) 50 #define CURRENT \ 51 ((current_t *) (((uintptr_t) __builtin_frame_address(0)) & \ 52 (~((uintptr_t) STACK_SIZE - 1)))) 46 53 47 #define MAGIC 54 #define MAGIC UINT32_C(0xfacefeed) 48 55 49 56 #define container_check(ctn1, ctn2) ((ctn1) == (ctn2)) … … 59 66 struct as; 60 67 61 /** 68 /** Current structure 69 * 62 70 * For each possible kernel stack, structure 63 71 * of the following type will be placed at 64 72 * the base address of the stack. 73 * 65 74 */ 66 75 typedef struct { 67 size_t preemption; /**< Preemption disabled counter and flag. */68 struct thread *thread; /**< Current thread. */69 struct task *task; /**< Current task. */70 struct cpu *cpu; /**< Executing cpu. */71 struct as *as; /**< Current address space. */72 uint32_t magic; /**< Magic value*/76 size_t preemption; /**< Preemption disabled counter and flag. */ 77 struct thread *thread; /**< Current thread. */ 78 struct task *task; /**< Current task. */ 79 struct cpu *cpu; /**< Executing CPU. */ 80 struct as *as; /**< Current address space. */ 81 uint32_t magic; /**< Magic value. */ 73 82 } current_t; 74 83 … … 89 98 } while (0) 90 99 91 #define ARCH_OP(op) 100 #define ARCH_OP(op) ARCH_STRUCT_OP(arch_ops, op) 92 101 93 102 extern void current_initialize(current_t *); -
kernel/generic/src/cpu/cpu.c
r94e75cf r128359eb 71 71 memsetb(cpus, sizeof(cpu_t) * config.cpu_count, 0); 72 72 73 // NOTE: All kernel stacks must be aligned to STACK_SIZE, 74 // see get_stack_base(). 75 size_t i; 76 for (i = 0; i < config.cpu_count; i++) { 73 /* 74 * NOTE: All kernel stacks must be aligned to STACK_SIZE, 75 * see CURRENT. 76 */ 77 for (size_t i = 0; i < config.cpu_count; i++) { 77 78 uintptr_t stack_phys = frame_alloc(STACK_FRAMES, 78 79 FRAME_LOWMEM | FRAME_ATOMIC, STACK_SIZE - 1); -
kernel/generic/src/main/main.c
r94e75cf r128359eb 170 170 ALIGN_UP((uintptr_t) kdata_end - config.base, PAGE_SIZE); 171 171 172 // NOTE: All kernel stacks must be aligned to STACK_SIZE, 173 // see get_stack_base(). 172 /* 173 * NOTE: All kernel stacks must be aligned to STACK_SIZE, 174 * see CURRENT. 175 */ 174 176 175 177 /* Place the stack after the kernel, init and ballocs. */ -
kernel/generic/src/proc/thread.c
r94e75cf r128359eb 191 191 kmflags &= ~FRAME_HIGHMEM; 192 192 193 // NOTE: All kernel stacks must be aligned to STACK_SIZE, 194 // see get_stack_base(). 193 /* 194 * NOTE: All kernel stacks must be aligned to STACK_SIZE, 195 * see CURRENT. 196 */ 195 197 196 198 uintptr_t stack_phys =
Note:
See TracChangeset
for help on using the changeset viewer.