Changeset 65f3117 in mainline for kernel/generic/src/main/main.c
- Timestamp:
- 2023-02-25T13:16:38Z (14 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6188fee
- Parents:
- 4f84ee42
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-14 13:38:14)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-25 13:16:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/main/main.c
r4f84ee42 r65f3117 137 137 uintptr_t stack_safe = 0; 138 138 139 // NOTE: All kernel stacks must be aligned to STACK_SIZE, see CURRENT. 140 const size_t bootstrap_stack_size = STACK_SIZE; 141 _Alignas(STACK_SIZE) uint8_t bootstrap_stack[STACK_SIZE]; 142 /* Just a convenient value for some assembly code. */ 143 const uint8_t *bootstrap_stack_top = bootstrap_stack + STACK_SIZE; 144 139 145 /* 140 146 * These two functions prevent stack from underflowing during the … … 170 176 ALIGN_UP((uintptr_t) kdata_end - config.base, PAGE_SIZE); 171 177 172 /*173 * NOTE: All kernel stacks must be aligned to STACK_SIZE,174 * see CURRENT.175 */176 177 /* Place the stack after the kernel, init and ballocs. */178 config.stack_base =179 ALIGN_UP(config.base + config.kernel_size, STACK_SIZE);180 config.stack_size = STACK_SIZE;181 182 /* Avoid placing stack on top of init */183 size_t i;184 for (i = 0; i < init.cnt; i++) {185 uintptr_t p = init.tasks[i].paddr + init.tasks[i].size;186 uintptr_t bottom = PA2KA(ALIGN_UP(p, STACK_SIZE));187 188 if (config.stack_base < bottom)189 config.stack_base = bottom;190 }191 192 /* Avoid placing stack on top of boot allocations. */193 if (ballocs.size) {194 uintptr_t bottom =195 ALIGN_UP(ballocs.base + ballocs.size, STACK_SIZE);196 if (config.stack_base < bottom)197 config.stack_base = bottom;198 }199 200 if (config.stack_base < stack_safe)201 config.stack_base = ALIGN_UP(stack_safe, STACK_SIZE);202 203 178 context_save(&ctx); 204 179 context_set(&ctx, FADDR(main_bsp_separated_stack), 205 config.stack_base, STACK_SIZE);180 bootstrap_stack, bootstrap_stack_size); 206 181 context_restore(&ctx); 207 182 /* not reached */
Note:
See TracChangeset
for help on using the changeset viewer.