Endpoint syscalls implemented
This commit is contained in:
parent
69501bfe01
commit
c064af5fa7
27 changed files with 391 additions and 42 deletions
35
zion/syscall/endpoint.cpp
Normal file
35
zion/syscall/endpoint.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "syscall/endpoint.h"
|
||||
|
||||
#include "object/endpoint.h"
|
||||
#include "object/reply_port.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
glcr::ErrorCode EndpointCreate(ZEndpointCreateReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
*req->endpoint_cap =
|
||||
proc.AddNewCapability(Endpoint::Create(), ZC_READ | ZC_WRITE);
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode EndpointSend(ZEndpointSendReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
|
||||
auto endpoint_cap = proc.GetCapability(req->endpoint_cap);
|
||||
ValidateCapability<Endpoint>(endpoint_cap, ZC_WRITE);
|
||||
auto endpoint = endpoint_cap->obj<Endpoint>();
|
||||
|
||||
auto reply_port = ReplyPort::Create();
|
||||
*req->reply_port_cap = proc.AddNewCapability(reply_port, ZC_READ);
|
||||
uint64_t reply_port_cap_to_send = proc.AddNewCapability(reply_port, ZC_WRITE);
|
||||
return endpoint->Write(req->num_bytes, req->data, reply_port_cap_to_send);
|
||||
}
|
||||
|
||||
glcr::ErrorCode EndpointRecv(ZEndpointRecvReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
|
||||
auto endpoint_cap = proc.GetCapability(req->endpoint_cap);
|
||||
ValidateCapability<Endpoint>(endpoint_cap, ZC_READ);
|
||||
auto endpoint = endpoint_cap->obj<Endpoint>();
|
||||
|
||||
return endpoint->Read(req->num_bytes, req->data, req->reply_port_cap);
|
||||
}
|
||||
11
zion/syscall/endpoint.h
Normal file
11
zion/syscall/endpoint.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
|
||||
#include "include/zcall.h"
|
||||
|
||||
glcr::ErrorCode EndpointCreate(ZEndpointCreateReq* req);
|
||||
|
||||
glcr::ErrorCode EndpointSend(ZEndpointSendReq* req);
|
||||
|
||||
glcr::ErrorCode EndpointRecv(ZEndpointRecvReq* req);
|
||||
22
zion/syscall/reply_port.cpp
Normal file
22
zion/syscall/reply_port.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "syscall/reply_port.h"
|
||||
|
||||
#include "object/reply_port.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
glcr::ErrorCode ReplyPortSend(ZReplyPortSendReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto reply_port_cap = proc.GetCapability(req->reply_port_cap);
|
||||
ValidateCapability<ReplyPort>(reply_port_cap, ZC_WRITE);
|
||||
auto reply_port = reply_port_cap->obj<ReplyPort>();
|
||||
|
||||
return reply_port->Write(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
glcr::ErrorCode ReplyPortRecv(ZReplyPortRecvReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
|
||||
auto reply_port_cap = proc.GetCapability(req->reply_port_cap);
|
||||
ValidateCapability<ReplyPort>(reply_port_cap, ZC_READ);
|
||||
auto reply_port = reply_port_cap->obj<ReplyPort>();
|
||||
|
||||
return reply_port->Read(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
9
zion/syscall/reply_port.h
Normal file
9
zion/syscall/reply_port.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
|
||||
#include "include/zcall.h"
|
||||
|
||||
glcr::ErrorCode ReplyPortSend(ZReplyPortSendReq* req);
|
||||
|
||||
glcr::ErrorCode ReplyPortRecv(ZReplyPortRecvReq* req);
|
||||
|
|
@ -8,9 +8,11 @@
|
|||
#include "syscall/capability.h"
|
||||
#include "syscall/channel.h"
|
||||
#include "syscall/debug.h"
|
||||
#include "syscall/endpoint.h"
|
||||
#include "syscall/memory_object.h"
|
||||
#include "syscall/port.h"
|
||||
#include "syscall/process.h"
|
||||
#include "syscall/reply_port.h"
|
||||
#include "syscall/thread.h"
|
||||
|
||||
#define EFER 0xC0000080
|
||||
|
|
@ -73,6 +75,13 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) {
|
|||
CASE(PortRecv);
|
||||
CASE(PortPoll);
|
||||
CASE(IrqRegister);
|
||||
// syscall/endpoint.h
|
||||
CASE(EndpointCreate);
|
||||
CASE(EndpointSend);
|
||||
CASE(EndpointRecv);
|
||||
// syscall/reply_port.h
|
||||
CASE(ReplyPortSend);
|
||||
CASE(ReplyPortRecv);
|
||||
// syscall/capability.h
|
||||
CASE(CapDuplicate);
|
||||
// syscall/debug.h
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue