* <!-- description --> * @brief This function maps the microkernel's stack into the microkernel's * root page tables. * * <!-- inputs/outputs --> * @param stack a pointer to a span_t that stores the stack * being mapped * @param virt provide the virtual address that the stack * should be mapped to. * @param pmut_rpt the root page table to map the stack into * @retur
| 45 | * @return LOADER_SUCCESS on success, LOADER_FAILURE on failure. |
| 46 | */ |
| 47 | NODISCARD int64_t |
| 48 | map_mk_stack( |
| 49 | struct span_t const *const stack, |
| 50 | uint64_t const virt, |
| 51 | root_page_table_t *const pmut_rpt) NOEXCEPT |
| 52 | { |
| 53 | uint64_t mut_i; |
| 54 | |
| 55 | for (mut_i = ((uint64_t)0); mut_i < stack->size; mut_i += HYPERVISOR_PAGE_SIZE) { |
| 56 | uint64_t const phys = platform_virt_to_phys(stack->addr + mut_i); |
| 57 | if (((uint64_t)0) == phys) { |
| 58 | bferror("platform_virt_to_phys failed"); |
| 59 | return LOADER_FAILURE; |
| 60 | } |
| 61 | |
| 62 | if (map_4k_page_rw((void *)(virt + mut_i), phys, pmut_rpt)) { |
| 63 | bferror("map_4k_page_rw failed"); |
| 64 | return LOADER_FAILURE; |
| 65 | } |
| 66 | |
| 67 | bf_touch(); |
| 68 | } |
| 69 | |
| 70 | return LOADER_SUCCESS; |
| 71 | } |
no test coverage detected