[Glacier] Convert ErrorCode into an Enum.
This commit is contained in:
parent
bcd9cf09bc
commit
e66706d381
14 changed files with 77 additions and 66 deletions
|
|
@ -48,8 +48,8 @@ glcr::RefPtr<T> Capability::obj() {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
z_err_t ValidateCapability(const glcr::RefPtr<Capability>& cap,
|
||||
uint64_t permissions) {
|
||||
glcr::ErrorCode ValidateCapability(const glcr::RefPtr<Capability>& cap,
|
||||
uint64_t permissions) {
|
||||
if (!cap) {
|
||||
return glcr::CAP_NOT_FOUND;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@
|
|||
#include "debug/debug.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
z_err_t UnboundedMessageQueue::PushBack(uint64_t num_bytes, const void* bytes,
|
||||
uint64_t num_caps, const z_cap_t* caps,
|
||||
z_cap_t reply_cap) {
|
||||
glcr::ErrorCode UnboundedMessageQueue::PushBack(uint64_t num_bytes,
|
||||
const void* bytes,
|
||||
uint64_t num_caps,
|
||||
const z_cap_t* caps,
|
||||
z_cap_t reply_cap) {
|
||||
if (num_bytes > 0x1000) {
|
||||
dbgln("Large message size unimplemented: %x", num_bytes);
|
||||
return glcr::UNIMPLEMENTED;
|
||||
|
|
@ -51,9 +53,10 @@ z_err_t UnboundedMessageQueue::PushBack(uint64_t num_bytes, const void* bytes,
|
|||
return glcr::OK;
|
||||
}
|
||||
|
||||
z_err_t UnboundedMessageQueue::PopFront(uint64_t* num_bytes, void* bytes,
|
||||
uint64_t* num_caps, z_cap_t* caps,
|
||||
z_cap_t* reply_cap) {
|
||||
glcr::ErrorCode UnboundedMessageQueue::PopFront(uint64_t* num_bytes,
|
||||
void* bytes, uint64_t* num_caps,
|
||||
z_cap_t* caps,
|
||||
z_cap_t* reply_cap) {
|
||||
mutex_->Lock();
|
||||
while (pending_messages_.empty()) {
|
||||
auto thread = gScheduler->CurrentThread();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#include "object/reply_port.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
z_err_t ChannelCreate(ZChannelCreateReq* req) {
|
||||
glcr::ErrorCode ChannelCreate(ZChannelCreateReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto chan_pair = Channel::CreateChannelPair();
|
||||
*req->channel1 = proc.AddNewCapability(chan_pair.first());
|
||||
|
|
@ -14,7 +14,7 @@ z_err_t ChannelCreate(ZChannelCreateReq* req) {
|
|||
return glcr::OK;
|
||||
}
|
||||
|
||||
z_err_t ChannelSend(ZChannelSendReq* req) {
|
||||
glcr::ErrorCode ChannelSend(ZChannelSendReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto chan_cap = proc.GetCapability(req->chan_cap);
|
||||
RET_ERR(ValidateCapability<Channel>(chan_cap, kZionPerm_Write));
|
||||
|
|
@ -23,7 +23,7 @@ z_err_t ChannelSend(ZChannelSendReq* req) {
|
|||
return chan->Send(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
|
||||
z_err_t ChannelRecv(ZChannelRecvReq* req) {
|
||||
glcr::ErrorCode ChannelRecv(ZChannelRecvReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto chan_cap = proc.GetCapability(req->chan_cap);
|
||||
RET_ERR(ValidateCapability<Channel>(chan_cap, kZionPerm_Read));
|
||||
|
|
@ -32,14 +32,14 @@ z_err_t ChannelRecv(ZChannelRecvReq* req) {
|
|||
return chan->Recv(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
|
||||
z_err_t PortCreate(ZPortCreateReq* req) {
|
||||
glcr::ErrorCode PortCreate(ZPortCreateReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port = glcr::MakeRefCounted<Port>();
|
||||
*req->port_cap = proc.AddNewCapability(port);
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
z_err_t PortSend(ZPortSendReq* req) {
|
||||
glcr::ErrorCode PortSend(ZPortSendReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port_cap = proc.GetCapability(req->port_cap);
|
||||
RET_ERR(ValidateCapability<Port>(port_cap, kZionPerm_Write));
|
||||
|
|
@ -48,7 +48,7 @@ z_err_t PortSend(ZPortSendReq* req) {
|
|||
return port->Send(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
|
||||
z_err_t PortRecv(ZPortRecvReq* req) {
|
||||
glcr::ErrorCode PortRecv(ZPortRecvReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port_cap = proc.GetCapability(req->port_cap);
|
||||
RET_ERR(ValidateCapability<Port>(port_cap, kZionPerm_Read));
|
||||
|
|
@ -63,7 +63,7 @@ z_err_t PortRecv(ZPortRecvReq* req) {
|
|||
return port->Recv(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
|
||||
z_err_t PortPoll(ZPortPollReq* req) {
|
||||
glcr::ErrorCode PortPoll(ZPortPollReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
auto port_cap = proc.GetCapability(req->port_cap);
|
||||
RET_ERR(ValidateCapability<Port>(port_cap, kZionPerm_Read));
|
||||
|
|
@ -77,7 +77,7 @@ z_err_t PortPoll(ZPortPollReq* req) {
|
|||
return port->Recv(req->num_bytes, req->data, req->num_caps, req->caps);
|
||||
}
|
||||
|
||||
z_err_t IrqRegister(ZIrqRegisterReq* req) {
|
||||
glcr::ErrorCode IrqRegister(ZIrqRegisterReq* req) {
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
if (req->irq_num != Z_IRQ_PCI_BASE) {
|
||||
// FIXME: Don't hardcode this nonsense.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue