[zion] Move the final syscalls to the new format.

This commit is contained in:
Drew Galbraith 2023-06-20 15:03:33 -07:00
parent bd431b94ce
commit 1edd5023ce
10 changed files with 45 additions and 52 deletions

View file

@ -0,0 +1,13 @@
#include "syscall/capability.h"
#include "scheduler/scheduler.h"
z_err_t CapDuplicate(ZCapDuplicateReq* req) {
auto& proc = gScheduler->CurrentProcess();
auto cap = proc.GetCapability(req->cap_in);
if (!cap) {
return Z_ERR_CAP_NOT_FOUND;
}
*req->cap_out = proc.AddExistingCapability(cap);
return Z_OK;
}

View file

@ -0,0 +1,5 @@
#pragma once
#include "include/zcall.h"
z_err_t CapDuplicate(ZCapDuplicateReq* req);

8
zion/syscall/debug.cpp Normal file
View file

@ -0,0 +1,8 @@
#include "syscall/debug.h"
#include "debug/debug.h"
z_err_t Debug(ZDebugReq* req) {
dbgln("[Debug] %s", req->message);
return Z_OK;
}

5
zion/syscall/debug.h Normal file
View file

@ -0,0 +1,5 @@
#pragma once
#include "include/zcall.h"
z_err_t Debug(ZDebugReq* req);

View file

@ -13,7 +13,9 @@
#include "scheduler/process_manager.h"
#include "scheduler/scheduler.h"
#include "syscall/address_space.h"
#include "syscall/capability.h"
#include "syscall/channel.h"
#include "syscall/debug.h"
#include "syscall/memory_object.h"
#include "syscall/port.h"
#include "syscall/process.h"
@ -63,16 +65,6 @@ z_err_t ValidateCap(const RefPtr<Capability>& cap, uint64_t permissions) {
return Z_OK;
}
z_err_t CapDuplicate(ZCapDuplicateReq* req, ZCapDuplicateResp* resp) {
auto& proc = gScheduler->CurrentProcess();
auto cap = proc.GetCapability(req->cap);
if (!cap) {
return Z_ERR_CAP_NOT_FOUND;
}
resp->cap = proc.AddExistingCapability(cap);
return Z_OK;
}
#define CASE(name) \
case kZion##name: \
return name(reinterpret_cast<Z##name##Req*>(req));
@ -104,13 +96,10 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req, void* resp) {
CASE(PortRecv);
CASE(PortPoll);
CASE(IrqRegister);
case Z_CAP_DUPLICATE:
return CapDuplicate(reinterpret_cast<ZCapDuplicateReq*>(req),
reinterpret_cast<ZCapDuplicateResp*>(resp));
case Z_DEBUG_PRINT:
dbgln("[Debug] %s", req);
return Z_OK;
break;
// syscall/capability.h
CASE(CapDuplicate);
// syscall/debug.h
CASE(Debug);
default:
panic("Unhandled syscall number: %x", call_id);
}