lib: c: update libheap to use new address-space api
This commit is contained in:
@@ -38,14 +38,10 @@ static kern_status_t init_heap_region(heap_t *heap)
|
|||||||
task_get_address_space(self, &address_space);
|
task_get_address_space(self, &address_space);
|
||||||
kern_handle_close(self);
|
kern_handle_close(self);
|
||||||
|
|
||||||
kern_status_t status = vm_region_create(
|
kern_status_t status = address_space_reserve(
|
||||||
address_space,
|
address_space,
|
||||||
"libc-heap",
|
MAP_ADDRESS_ANY,
|
||||||
9,
|
|
||||||
VM_REGION_ANY_OFFSET,
|
|
||||||
HEAP_REGION_SIZE,
|
HEAP_REGION_SIZE,
|
||||||
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_USER,
|
|
||||||
&heap->heap_region,
|
|
||||||
&heap->heap_base);
|
&heap->heap_base);
|
||||||
|
|
||||||
kern_handle_close(address_space);
|
kern_handle_close(address_space);
|
||||||
@@ -72,9 +68,14 @@ static kern_status_t expand_heap(heap_t *heap)
|
|||||||
|
|
||||||
virt_addr_t base = 0;
|
virt_addr_t base = 0;
|
||||||
|
|
||||||
status = vm_region_map_relative(
|
kern_handle_t self, address_space;
|
||||||
heap->heap_region,
|
task_self(&self);
|
||||||
heap->heap_sys_alloc,
|
task_get_address_space(self, &address_space);
|
||||||
|
kern_handle_close(self);
|
||||||
|
|
||||||
|
status = address_space_map(
|
||||||
|
address_space,
|
||||||
|
heap->heap_base + heap->heap_sys_alloc,
|
||||||
vmo,
|
vmo,
|
||||||
0,
|
0,
|
||||||
HEAP_EXPAND_INCREMENT,
|
HEAP_EXPAND_INCREMENT,
|
||||||
@@ -90,7 +91,7 @@ static kern_status_t expand_heap(heap_t *heap)
|
|||||||
void *heap_expand(heap_t *heap, size_t size)
|
void *heap_expand(heap_t *heap, size_t size)
|
||||||
{
|
{
|
||||||
kern_status_t status = KERN_OK;
|
kern_status_t status = KERN_OK;
|
||||||
if (heap->heap_region == KERN_HANDLE_INVALID) {
|
if (!heap->heap_base) {
|
||||||
status = init_heap_region(heap);
|
status = init_heap_region(heap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ struct liballoc_minor;
|
|||||||
|
|
||||||
#define HEAP_INIT \
|
#define HEAP_INIT \
|
||||||
{ \
|
{ \
|
||||||
.heap_region = KERN_HANDLE_INVALID, \
|
|
||||||
.heap_liballoc = { \
|
.heap_liballoc = { \
|
||||||
.l_pageSize = 4096, \
|
.l_pageSize = 4096, \
|
||||||
.l_pageCount = 16, \
|
.l_pageCount = 16, \
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ typedef enum heap_result {
|
|||||||
} heap_result_t;
|
} heap_result_t;
|
||||||
|
|
||||||
typedef struct heap {
|
typedef struct heap {
|
||||||
kern_handle_t heap_region;
|
|
||||||
/* amount of space requested from the heap by the user */
|
/* amount of space requested from the heap by the user */
|
||||||
size_t heap_req_alloc;
|
size_t heap_req_alloc;
|
||||||
/* amount of space requested from the system by the heap */
|
/* amount of space requested from the system by the heap */
|
||||||
|
|||||||
Reference in New Issue
Block a user