mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-12-24 04:23:04 +00:00
display: Factor out top of memory allocation
Move it into utils.c before we reuse it for SIO data. Signed-off-by: Martin Povišer <povik@cutebit.org>
This commit is contained in:
parent
9e616021d6
commit
b74218f2ae
3 changed files with 22 additions and 6 deletions
|
@ -369,12 +369,7 @@ int display_configure(const char *config)
|
|||
return -1;
|
||||
}
|
||||
|
||||
cur_boot_args.mem_size -= size;
|
||||
fb_pa = cur_boot_args.phys_base + cur_boot_args.mem_size;
|
||||
/* add guard page between RAM and framebuffer */
|
||||
// TODO: update mapping?
|
||||
cur_boot_args.mem_size -= SZ_16K;
|
||||
|
||||
fb_pa = top_of_memory_alloc(size);
|
||||
memset((void *)fb_pa, 0, size);
|
||||
|
||||
tmp_dva = iova_alloc(dcp->iovad_dcp, size);
|
||||
|
|
20
src/utils.c
20
src/utils.c
|
@ -180,3 +180,23 @@ bool is_heap(void *addr)
|
|||
|
||||
return p > top_of_kernel_data && p < top_of_ram;
|
||||
}
|
||||
|
||||
// TODO: update mapping?
|
||||
u64 top_of_memory_alloc(size_t size)
|
||||
{
|
||||
static bool guard_page_inserted = false;
|
||||
cur_boot_args.mem_size -= ALIGN_UP(size, SZ_16K);
|
||||
u64 ret = cur_boot_args.phys_base + cur_boot_args.mem_size;
|
||||
|
||||
if (!guard_page_inserted) {
|
||||
cur_boot_args.mem_size -= SZ_16K;
|
||||
guard_page_inserted = true;
|
||||
} else {
|
||||
// If the guard page was already there, move it down and allocate
|
||||
// above it -- this is accomplished by simply shifting the allocated
|
||||
// region by one page up.
|
||||
ret += SZ_16K;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -440,5 +440,6 @@ extern struct vector_args next_stage;
|
|||
void deep_wfi(void);
|
||||
|
||||
bool is_heap(void *addr);
|
||||
u64 top_of_memory_alloc(size_t size);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue