[kernel] Spit out vm_area types
The vm_space allow() functionality was a bit janky; using VMAs for all regions would be a lot cleaner. To that end, this change: - Adds a "static array" ctor to kutil::vector for setting the kernel address space's VMA list. This way a kernel heap VMA can be created without the heap already existing. - Splits vm_area into different subclasses depending on desired behavior - Splits out the concept of vm_mapper which maps vm_areas to vm_spaces, so that some kinds of VMA can be inherently single-space - Implements VMA resizing so that userspace can grow allocations. - Obsolete page_table_indices is removed Also, the following bugs were fixed: - kutil::map iterators on empty maps no longer break - memory::page_count was doing page-align, not page-count See: Github bug #242 See: [frobozz blog post](https://jsix.dev/posts/frobozz/) Tags:
This commit is contained in:
@@ -11,17 +11,19 @@
|
||||
namespace syscalls {
|
||||
|
||||
j6_status_t
|
||||
vma_create(j6_handle_t *handle, size_t size)
|
||||
vma_create(j6_handle_t *handle, size_t size, uint32_t flags)
|
||||
{
|
||||
construct_handle<vm_area>(handle, size);
|
||||
vm_flags f = vm_flags::user_mask & flags;
|
||||
construct_handle<vm_area_shared>(handle, size, f);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
vma_create_map(j6_handle_t *handle, size_t size, uintptr_t base)
|
||||
vma_create_map(j6_handle_t *handle, size_t size, uintptr_t base, uint32_t flags)
|
||||
{
|
||||
vm_area *a = construct_handle<vm_area>(handle, size);
|
||||
a->add_to(&process::current().space(), base);
|
||||
vm_flags f = vm_flags::user_mask & flags;
|
||||
vm_area *a = construct_handle<vm_area_shared>(handle, size, f);
|
||||
process::current().space().add(base, a);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
@@ -31,7 +33,7 @@ vma_map(j6_handle_t handle, uintptr_t base)
|
||||
vm_area *a = get_handle<vm_area>(handle);
|
||||
if (!a) return j6_err_invalid_arg;
|
||||
|
||||
a->add_to(&process::current().space(), base);
|
||||
process::current().space().add(base, a);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
@@ -41,7 +43,7 @@ vma_unmap(j6_handle_t handle)
|
||||
vm_area *a = get_handle<vm_area>(handle);
|
||||
if (!a) return j6_err_invalid_arg;
|
||||
|
||||
a->remove_from(&process::current().space());
|
||||
process::current().space().remove(a);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
@@ -56,6 +58,19 @@ vma_close(j6_handle_t handle)
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
vma_resize(j6_handle_t handle, size_t *size)
|
||||
{
|
||||
if (!size)
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
vm_area *a = get_handle<vm_area>(handle);
|
||||
if (!a) return j6_err_invalid_arg;
|
||||
|
||||
*size = a->resize(*size);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace syscalls
|
||||
|
||||
Reference in New Issue
Block a user