diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-05-11 22:55:31 +0300 |
| commit | 27ffa747f36aee9c1d5bbc61395a078238366070 (patch) | |
| tree | f37c544aaca6bebd1cc146d1eb002483c7cfd474 /include | |
| parent | 3109effe7297232e17c1792e63c3a9c7d129a4eb (diff) | |
| download | kmi-27ffa747f36aee9c1d5bbc61395a078238366070.tar.gz kmi-27ffa747f36aee9c1d5bbc61395a078238366070.zip | |
arbitrary load address and RAM base detection
+ Both kind of go hand in hand, made sense to do both at the same time.
Some parts feel slightly hacky, the loader works by placing everything
on the stack and avoiding global values. Still, seems to work?
Diffstat (limited to 'include')
| -rw-r--r-- | include/kmi/mem.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/kmi/mem.h b/include/kmi/mem.h index a6c6bfa..f43ee08 100644 --- a/include/kmi/mem.h +++ b/include/kmi/mem.h @@ -92,7 +92,7 @@ * @param x Physical address. * @return Corresponding virtual address. */ -#define __va(x) (void *)(((uintptr_t)(x)) + VM_DMAP - RAM_BASE) +#define __va(x) (void *)(((uintptr_t)(x)) + VM_DMAP - get_ram_base()) /** * Convert virtual address to physical address in direct mapping. @@ -100,7 +100,7 @@ * @param x Virtual address. * @return Corresponding physical address. */ -#define __pa(x) (void *)(((uintptr_t)(x)) - VM_DMAP + RAM_BASE) +#define __pa(x) (void *)(((uintptr_t)(x)) - VM_DMAP + get_ram_base()) /** * Get page number of physical address. @@ -213,6 +213,22 @@ enum mm_order nearest_order(size_t size); */ void init_mem(size_t max_order, size_t shifts[10], size_t page_shift); +/** + * Set RAM base address for global access. + * For now supports only one RAM bank. + * + * @param base RAM base address. + */ +void set_ram_base(pm_t base); + +/** + * Get RAM base address. + * Very much assumes set_ram_base() has been called beforehand. + * + * @return RAM base address. + */ +pm_t get_ram_base(); + /** Base page size. */ #define BASE_PAGE_SIZE (order_size(BASE_PAGE)) |
