[zion] Add a port send syscall
This commit is contained in:
parent
cc191cd6bb
commit
857b7fae03
|
@ -94,6 +94,9 @@ void ZThreadExit();
|
|||
uint64_t* actual_caps);
|
||||
|
||||
[[nodiscard]] z_err_t ZPortCreate(uint64_t* port_cap);
|
||||
[[nodiscard]] z_err_t ZPortSend(uint64_t port_cap, uint64_t num_bytes,
|
||||
const uint8_t* bytes, uint64_t num_caps,
|
||||
uint64_t* caps);
|
||||
[[nodiscard]] z_err_t ZPortRecv(uint64_t port_cap, uint64_t num_bytes,
|
||||
uint8_t* bytes, uint64_t num_caps,
|
||||
uint64_t* caps, uint64_t* type,
|
||||
|
|
|
@ -204,6 +204,16 @@ z_err_t PortCreate(ZPortCreateResp* resp) {
|
|||
return proc.AddNewCapability(port, ZC_WRITE | ZC_READ);
|
||||
}
|
||||
|
||||
z_err_t PortSend(ZPortSendReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port_cap = proc.GetCapability(req->port_cap);
|
||||
RET_ERR(ValidateCap(port_cap, ZC_WRITE));
|
||||
|
||||
auto port = port_cap->obj<Port>();
|
||||
RET_IF_NULL(port);
|
||||
return port->Write(req->message);
|
||||
}
|
||||
|
||||
z_err_t PortRecv(ZPortRecvReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port_cap = proc.GetCapability(req->port_cap);
|
||||
|
@ -293,6 +303,8 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req, void* resp) {
|
|||
return ChannelRecv(reinterpret_cast<ZChannelRecvReq*>(req));
|
||||
case Z_PORT_CREATE:
|
||||
return PortCreate(reinterpret_cast<ZPortCreateResp*>(resp));
|
||||
case Z_PORT_SEND:
|
||||
return PortSend(reinterpret_cast<ZPortSendReq*>(req));
|
||||
case Z_PORT_RECV:
|
||||
return PortRecv(reinterpret_cast<ZPortRecvReq*>(req));
|
||||
case Z_PORT_POLL:
|
||||
|
|
|
@ -170,6 +170,19 @@ z_err_t ZPortCreate(uint64_t* port_cap) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
z_err_t ZPortSend(uint64_t port_cap, uint64_t num_bytes, const uint8_t* bytes,
|
||||
uint64_t num_caps, uint64_t* caps) {
|
||||
ZPortSendReq req{.port_cap = port_cap,
|
||||
.message = {
|
||||
.type = 0,
|
||||
.num_bytes = num_bytes,
|
||||
.bytes = const_cast<uint8_t*>(bytes),
|
||||
.num_caps = num_caps,
|
||||
.caps = caps,
|
||||
}};
|
||||
return SysCall1(Z_PORT_SEND, &req);
|
||||
}
|
||||
|
||||
z_err_t ZPortRecv(uint64_t port_cap, uint64_t num_bytes, uint8_t* bytes,
|
||||
uint64_t num_caps, uint64_t* caps, uint64_t* type,
|
||||
uint64_t* actual_bytes, uint64_t* actual_caps) {
|
||||
|
|
|
@ -90,6 +90,11 @@ struct ZPortCreateResp {
|
|||
uint64_t port_cap;
|
||||
};
|
||||
|
||||
struct ZPortSendReq {
|
||||
uint64_t port_cap;
|
||||
ZMessage message;
|
||||
};
|
||||
|
||||
struct ZPortRecvReq {
|
||||
uint64_t port_cap;
|
||||
ZMessage message;
|
||||
|
|
Loading…
Reference in New Issue