-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.h
More file actions
84 lines (69 loc) · 2.51 KB
/
Copy pathloader.h
File metadata and controls
84 lines (69 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#include <stdint.h>
#include "core/loader.h"
#include "core/vm.h"
#include "platform/mmu.h"
extern "C" uint8_t loader_begin_;
extern "C" uint8_t loader_end_;
namespace loader {
using core::mem::PageList;
using platform::mmu::PageDescriptor;
/// @brief Data passed by the loader to the kernel
extern LoaderData gLoaderData;
/// @brief List of pages allocated for the kernel (incl. page tables)
extern PageList KernelPages;
/// @brief List of pages allocated for the loader (incl. page tables)
extern PageList LoaderPages;
/**
* @brief Get the bootargs from the DTB (device tree blob).
*
* @param dtb Pointer to the DTB address
* @return const char* Boot arguments
*/
const char *get_dtb_bootargs(void *dtb);
/**
* @brief Parse the boot arguments into `gLoaderData`
*/
void parse_bootargs(char const* args);
/**
* @brief Bootstrap the PMM by setting up the PFNDB (Page Frame Number DB).
*
* @param initrd_end The physical end of the loader + initrd complex.
*/
void bootstrap_pmm(uintptr_t initrd_end);
/**
* @brief Create initial mappings, sets up paging registers, including
* writing to `TTBR0` and `TTBR1` the L0 structures.
*/
void bootstrap_paging();
/**
* @brief Allocate a physical page
*
* @param out The allocated page's PFNDB struct will be appended here
* @return uint64_t The physical address of the page
*/
uint64_t alloc_page_phys(PageList& out);
/**
* @brief
* Puts descriptor `pa` at the L3 table pointed by virtual address `va`.
* The lower 12 bits of `va` will be ignored. Any newly allocated pages
* will be appended to `out`.
*/
void map(uint64_t va, PageDescriptor pa, PageList& out);
/**
* @brief
* Map a range of contiguous physical addresses `pa` which is [start, end)
* into the virtual range [start + `offset`, end + `offset`). The entire
* range will have the flags given by `pd`. Any newly allocated pages will
* be appended to `out`.
*/
void map_range(Range pa, uint64_t offset, PageDescriptor pd, PageList& out);
/**
* @brief
* Creates and allocates a virtual address chunk defined by `va` and populate
* it with data copied from the physical address `copy_from`. The range will
* have the flags given by `pd`, and ALL newly allocated pages will be
* appended to the list given by `out`.
*/
void map_create_range(Range va, Range copy_from, PageDescriptor pd, PageList& out);
}; // namespace loader