Fixed incorrect heap bounds

This commit is contained in:
Max Wash
2021-03-11 10:12:33 +00:00
parent ad355938a5
commit 28071cd3c6

View File

@@ -14,19 +14,20 @@ static uintptr_t heap_alloc_point = 0;
static size_t heap_sz = 0;
static mx_handle_t heap_vmo = MX_NULL_HANDLE;
void __crt_heap_init(size_t heap_sz)
void __crt_heap_init(size_t sz)
{
mx_status_t status = mx_vmo_create(
heap_sz,
sz,
MX_VM_CAN_MAP_READ | MX_VM_CAN_MAP_WRITE | MX_VM_CAN_MAP_SPECIFIC,
&heap_vmo);
mx_vaddr_t heap = 0;
mx_vmar_map(mx_get_startup_handle(MX_B_VMAR_ROOT),
MX_VM_PERM_READ | MX_VM_PERM_WRITE,
0, heap_vmo, 0, heap_sz,
0, heap_vmo, 0, sz,
&heap);
heap_sz = sz;
heap_start = heap;
heap_end = heap + heap_sz;
heap_alloc_point = heap_start;
@@ -41,20 +42,20 @@ void *__crt_heap_extend(size_t sz)
sz += MX_PAGE_SIZE;
}
if (!sz) {
return (void *)heap_end;
}
if (!heap_start) {
__crt_heap_init(sz);
return (void *)heap_start;
}
if (!sz) {
return (void *)heap_end;
}
mx_vmo_set_size(heap_vmo, heap_sz + sz);
mx_vaddr_t vmar_base, alloc_base;
mx_vmar_bounds(mx_get_startup_handle(MX_B_VMAR_ROOT), &vmar_base, NULL);
mx_vaddr_t offset = heap_end - vmar_base;
size_t offset = heap_end - vmar_base;
mx_vmar_map(mx_get_startup_handle(MX_B_VMAR_ROOT),
MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC,