This commit is contained in:
2026-08-18 01:28:35 +02:00
parent ac9d47fa16
commit cf3f1f9e99
11 changed files with 110 additions and 59 deletions
+13 -13
View File
@@ -15,8 +15,8 @@
#include <stdatomic.h>
zn_status_t syscall_vmo_create(struct arch_context* ctx) {
size_t length = ctx->ARCH_CTX_A0;
__user zn_handle_t* out = (__user zn_handle_t*)ctx->ARCH_CTX_A1;
size_t length = ctx->a0;
__user zn_handle_t* out = (__user zn_handle_t*)ctx->a1;
// Allocate new VMO.
struct paged_vmo* vmo;
@@ -43,9 +43,9 @@ zn_status_t syscall_vmo_create(struct arch_context* ctx) {
}
zn_status_t syscall_vmo_create_phys(struct arch_context* ctx) {
uintptr_t addr = ctx->ARCH_CTX_A0;
size_t length = ctx->ARCH_CTX_A1;
__user zn_handle_t* out = (__user zn_handle_t*)ctx->ARCH_CTX_A2;
uintptr_t addr = ctx->a0;
size_t length = ctx->a1;
__user zn_handle_t* out = (__user zn_handle_t*)ctx->a2;
struct vmo* vmo;
zn_status_t status = vmo_new_phys_range(addr, length, &vmo);
@@ -71,12 +71,12 @@ zn_status_t syscall_vmo_create_phys(struct arch_context* ctx) {
}
zn_status_t syscall_vmo_map(struct arch_context* ctx) {
zn_handle_t vmo_handle = ctx->ARCH_CTX_A0;
zn_handle_t vas_handle = ctx->ARCH_CTX_A1;
uintptr_t vmo_offset = ctx->ARCH_CTX_A2;
__user uintptr_t* addr = (__user uintptr_t*)ctx->ARCH_CTX_A3;
size_t bytes = ctx->ARCH_CTX_A4;
enum zn_vm_flags flags = ctx->ARCH_CTX_A5;
zn_handle_t vmo_handle = ctx->a0;
zn_handle_t vas_handle = ctx->a1;
uintptr_t vmo_offset = ctx->a2;
auto addr = (__user uintptr_t*)ctx->a3;
size_t bytes = ctx->a4;
enum zn_vm_flags flags = ctx->a5;
struct task* current = percpu_get()->sched.current;
@@ -112,8 +112,8 @@ zn_status_t syscall_vmo_map(struct arch_context* ctx) {
// TODO: Use actual allocator for user task.
if (target_addr == 0) {
static uintptr_t map_offset = 0xA000'0000;
target_addr = atomic_fetch_add(&map_offset, ALIGN_UP(bytes, arch_mem_page_size()));
static _Atomic uintptr_t map_offset = 0xA000'0000;
target_addr = atomic_fetch_add((volatile uintptr_t*)&map_offset, ALIGN_UP(bytes, arch_mem_page_size()));
}
if (addr != nullptr) {