* <!-- description --> * @brief Allocates a chunk of memory for the stack used by the * microkernel. Note that the "size" parameter is in total pages and * not in bytes. If the provided size is 0, this function will allocate * a default number of pages. * * <!-- inputs/outputs --> * @param pmut_stack the span_t to store the stack addr/size. * @return LOADER_SUCCESS on suc
| 42 | * @return LOADER_SUCCESS on success, LOADER_FAILURE on failure. |
| 43 | */ |
| 44 | NODISCARD int64_t |
| 45 | alloc_mk_stack(struct span_t *const pmut_stack) NOEXCEPT |
| 46 | { |
| 47 | pmut_stack->size = HYPERVISOR_MK_STACK_SIZE; |
| 48 | pmut_stack->addr = (uint8_t *)platform_alloc(pmut_stack->size); |
| 49 | if (NULLPTR == pmut_stack->addr) { |
| 50 | bferror("platform_alloc failed"); |
| 51 | goto platform_alloc_failed; |
| 52 | } |
| 53 | |
| 54 | return LOADER_SUCCESS; |
| 55 | |
| 56 | platform_alloc_failed: |
| 57 | |
| 58 | platform_memset(pmut_stack, ((uint8_t)0), sizeof(struct span_t)); |
| 59 | return LOADER_FAILURE; |
| 60 | } |
no test coverage detected