mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[kernel] Add (wip) futex syscalls
Add the syscalls j6_futex_wait and j6_futex_wake. Currently marking this as WIP as they need more testing. Added to support futexes: - vm_area and vm_space support for looking up physical address for a virtual address - libj6 mutex implementation using futex system calls
This commit is contained in:
@@ -86,7 +86,7 @@ vm_area_fixed::resize(size_t size)
|
||||
}
|
||||
|
||||
bool
|
||||
vm_area_fixed::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
vm_area_fixed::get_page(uintptr_t offset, uintptr_t &phys, bool alloc)
|
||||
{
|
||||
if (offset > m_size)
|
||||
return false;
|
||||
@@ -106,11 +106,16 @@ vm_area_untracked::~vm_area_untracked()
|
||||
}
|
||||
|
||||
bool
|
||||
vm_area_untracked::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
vm_area_untracked::get_page(uintptr_t offset, uintptr_t &phys, bool alloc)
|
||||
{
|
||||
if (offset > m_size)
|
||||
return false;
|
||||
|
||||
if (!alloc) {
|
||||
phys = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return frame_allocator::get().allocate(1, &phys);
|
||||
}
|
||||
|
||||
@@ -136,9 +141,12 @@ vm_area_open::~vm_area_open()
|
||||
}
|
||||
|
||||
bool
|
||||
vm_area_open::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
vm_area_open::get_page(uintptr_t offset, uintptr_t &phys, bool alloc)
|
||||
{
|
||||
return page_tree::find_or_add(m_mapped, offset, phys);
|
||||
if (alloc)
|
||||
return page_tree::find_or_add(m_mapped, offset, phys);
|
||||
else
|
||||
return page_tree::find(m_mapped, offset, phys);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -171,7 +179,7 @@ vm_area_guarded::return_section(uintptr_t addr)
|
||||
}
|
||||
|
||||
bool
|
||||
vm_area_guarded::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
vm_area_guarded::get_page(uintptr_t offset, uintptr_t &phys, bool alloc)
|
||||
{
|
||||
if (offset >= m_stacks.end())
|
||||
return false;
|
||||
@@ -181,7 +189,7 @@ vm_area_guarded::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
if ((offset >> 12) % m_pages == 0)
|
||||
return false;
|
||||
|
||||
return vm_area_open::get_page(offset, phys);
|
||||
return vm_area_open::get_page(offset, phys, alloc);
|
||||
}
|
||||
|
||||
vm_area_ring::vm_area_ring(size_t size, vm_flags flags) :
|
||||
@@ -193,11 +201,11 @@ vm_area_ring::vm_area_ring(size_t size, vm_flags flags) :
|
||||
vm_area_ring::~vm_area_ring() {}
|
||||
|
||||
bool
|
||||
vm_area_ring::get_page(uintptr_t offset, uintptr_t &phys)
|
||||
vm_area_ring::get_page(uintptr_t offset, uintptr_t &phys, bool alloc)
|
||||
{
|
||||
if (offset > m_bufsize)
|
||||
offset -= m_bufsize;
|
||||
return vm_area_open::get_page(offset, phys);
|
||||
return vm_area_open::get_page(offset, phys, alloc);
|
||||
}
|
||||
|
||||
} // namespace obj
|
||||
|
||||
Reference in New Issue
Block a user