diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-02 14:01:46 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-09-02 14:06:16 +0300 |
| commit | d9b427cab53849c503306af1ebebed30c35fb81f (patch) | |
| tree | 1ac2fee12c2bede1a1ef722a59c4d94faf213e2d /arch | |
| parent | 9398194058eeb365bfc985b31b4049ccfd44ac45 (diff) | |
| download | kmi-d9b427cab53849c503306af1ebebed30c35fb81f.tar.gz kmi-d9b427cab53849c503306af1ebebed30c35fb81f.zip | |
reserve more space for fw
+ Doesn't seem to be specified anywhere, but I'll stick with 2MB for
now, working on the assumption that the FW is at the start of the
physical RAM.
Possible TODOs: generate apos.its automatically from init.elf,
allocate root_branch statically?
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/riscv64/conf/apos.its | 4 | ||||
| -rw-r--r-- | arch/riscv64/config.h | 12 | ||||
| -rw-r--r-- | arch/riscv64/init/init.c | 11 |
3 files changed, 19 insertions, 8 deletions
diff --git a/arch/riscv64/conf/apos.its b/arch/riscv64/conf/apos.its index da48860..026fb45 100644 --- a/arch/riscv64/conf/apos.its +++ b/arch/riscv64/conf/apos.its @@ -12,8 +12,8 @@ arch = "riscv"; os = "apos"; compression = "none"; - load = <0x80080000>; - entry = <0x80080000>; + load = <0x80240000>; + entry = <0x80240000>; hash-1 { algo = "sha1"; }; diff --git a/arch/riscv64/config.h b/arch/riscv64/config.h index 0421341..5ea5482 100644 --- a/arch/riscv64/config.h +++ b/arch/riscv64/config.h @@ -27,13 +27,19 @@ /* don't touch >:( */ -/** Physical address to where the kernel proper will be relocated. */ -#define PM_KERN_BASE (RAM_BASE + SZ_512K) +/** + * How much space to reserve for possible firmware region. + * Assumed to be at start of RAM. + */ +#define FW_MAX_SIZE (SZ_2M) /** Maximum size of the kernel proper. Largely arbitrary. */ /** \todo UBSAN is getting pretty close to this limit, should it be raised? */ #define PM_KERN_SIZE (SZ_256K) +/** Physical address to where the kernel proper will be relocated. */ +#define PM_KERN_BASE (RAM_BASE + FW_MAX_SIZE + PM_KERN_SIZE) + /** Highest allowed physical address where kernel stuff may lie. */ #define PM_KERN_TOP (PM_KERN_BASE + PM_KERN_SIZE) @@ -53,7 +59,7 @@ #define VM_DMAP (0xffffffc000000000) /* testing for now */ /** Virtual address of kernel proper inside direct mapping. */ -#define VM_KERN (VM_DMAP + SZ_256K) +#define VM_KERN (VM_DMAP + FW_MAX_SIZE) /** Page reserved for kernel I/O. */ #define IO_PAGE 511UL diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c index 2c71ea4..c91d192 100644 --- a/arch/riscv64/init/init.c +++ b/arch/riscv64/init/init.c @@ -33,9 +33,14 @@ static void init_bootmem() { size_t flags = VM_V | VM_X | VM_R | VM_W; - extern char *__init_start; - root_branch = (struct vmem *)align_down( - (uintptr_t)&__init_start - SZ_4K, SZ_4K); + extern char *__init_end; + extern char *__kernel_size; + uintptr_t top = (uintptr_t)&__init_end + (uintptr_t)&__kernel_size; + + /* this could be risky, as we might overwrite some bits of initrd or fdt + * if they're allocated too close to the kernel payload. + * @todo Allocate root_branch statically? */ + root_branch = (struct vmem *)align_up(top, SZ_4K); /* direct mapping (temp) */ for (size_t i = 0; i < CSTACK_PAGE; ++i) |
