Migrate to error constants in glacier

This commit is contained in:
Drew Galbraith 2023-06-21 18:28:54 -07:00
parent 3ab9b4d818
commit 0b86a94f14
30 changed files with 171 additions and 114 deletions

View File

@ -0,0 +1,39 @@
#pragma once
#include <stdint.h>
namespace glcr {
typedef uint64_t ErrorCode;
#define RET_ERR(expr) \
{ \
z_err_t _tmp_err = expr; \
if (_tmp_err != glcr::OK) { \
return _tmp_err; \
} \
}
static const uint64_t OK = 0x0;
// First set of error codes generally indicate user errors.
static const uint64_t INVALID_ARGUMENT = 0x1;
static const uint64_t NOT_FOUND = 0x2;
static const uint64_t PERMISSION_DENIED = 0x3;
static const uint64_t NULL_PTR = 0x4;
static const uint64_t EMPTY = 0x5;
static const uint64_t ALREADY_EXISTS = 0x6;
static const uint64_t BUFFER_SIZE = 0x7;
static const uint64_t FAILED_PRECONDITION = 0x8;
// Second set of error codes generally indicate service errors.
static const uint64_t INTERNAL = 0x100;
static const uint64_t UNIMPLEMENTED = 0x101;
static const uint64_t EXHAUSTED = 0x102;
// Kernel specific error codes (relating to capabilities).
static const uint64_t CAP_NOT_FOUND = 0x1000;
static const uint64_t CAP_WRONG_TYPE = 0x1001;
static const uint64_t CAP_PERMISSION_DENIED = 0x1002;
} // namespace glcr

View File

@ -0,0 +1,41 @@
#pragma once
#include <glacier/status/error.h>
namespace glcr {
template <typename T>
class ErrorOr {
public:
ErrorOr() = delete;
ErrorOr(const ErrorOr&) = delete;
ErrorOr(ErrorOr&&) = delete;
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
ErrorOr(T obj) : obj_(obj), ok_(true) {}
ErrorOr(T&& obj) : obj_(obj), ok_(true) {}
bool ok() { return ok_; }
operator bool() { return ok_; }
T& value() { return obj_; }
ErrorCode error() { return error_; }
private:
union {
ErrorCode error_;
T obj_;
};
bool ok_;
};
#define ASSIGN_OR_RETURN(lhs, rhs) \
\
auto e##__LINE__ = rhs; \
if (!e##__LINE__.ok()) { \
return e##__LINE__.error(); \
} \
lhs = rhs.value();
} // namespace glcr

View File

@ -13,6 +13,7 @@ target_include_directories(mammoth_lib
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(mammoth_lib
glacier
c
zion_lib)

View File

@ -1,5 +1,6 @@
#pragma once
#include <glacier/status/error.h>
#include <stdint.h>
#include <zcall.h>
@ -37,13 +38,10 @@ template <typename T>
z_err_t Channel::ReadStructAndCap(T* obj, uint64_t* cap) {
uint64_t num_bytes = sizeof(T);
uint64_t num_caps = 1;
uint64_t ret = ZChannelRecv(chan_cap_, &num_bytes, obj, &num_caps, cap);
RET_ERR(ZChannelRecv(chan_cap_, &num_bytes, obj, &num_caps, cap));
if (ret != Z_OK) {
return ret;
}
if (num_caps != 1 || num_bytes != sizeof(T)) {
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
return Z_OK;
return glcr::OK;
}

View File

@ -10,11 +10,3 @@ void dbgln(const char* fmt, ...);
void check(uint64_t);
void crash(const char*, z_err_t);
#define RET_ERR(expr) \
{ \
z_err_t _tmp_err = expr; \
if (_tmp_err != Z_OK) { \
return _tmp_err; \
} \
}

View File

@ -19,7 +19,7 @@ uint64_t strlen(const char* ptr) {
void Channel::adopt_cap(uint64_t id) {
if (chan_cap_ != 0) {
crash("Adopting over channel.", Z_ERR_EXISTS);
crash("Adopting over channel.", glcr::ALREADY_EXISTS);
}
chan_cap_ = id;
}
@ -33,14 +33,14 @@ z_cap_t Channel::cap() { return chan_cap_; }
z_err_t Channel::WriteStr(const char* msg) {
if (!chan_cap_) {
return Z_ERR_NULL;
return glcr::NULL_PTR;
}
return ZChannelSend(chan_cap_, strlen(msg), msg, 0, nullptr);
}
z_err_t Channel::ReadStr(char* buffer, uint64_t* size) {
if (!chan_cap_) {
return Z_ERR_NULL;
return glcr::NULL_PTR;
}
uint64_t num_caps = 0;
return ZChannelRecv(chan_cap_, size, reinterpret_cast<uint8_t*>(buffer),
@ -49,12 +49,9 @@ z_err_t Channel::ReadStr(char* buffer, uint64_t* size) {
z_err_t CreateChannels(Channel& c1, Channel& c2) {
z_cap_t chan1, chan2;
z_err_t err = ZChannelCreate(&chan1, &chan2);
if (err != Z_OK) {
return err;
}
RET_ERR(ZChannelCreate(&chan1, &chan2));
c1.adopt_cap(chan1);
c2.adopt_cap(chan2);
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,6 @@
#include "include/mammoth/debug.h"
#include <glacier/status/error.h>
#include <stdarg.h>
#include <stdio.h>
#include <zcall.h>
@ -25,18 +26,18 @@ void dbgln(const char* fmt, ...) {
void check(uint64_t code) {
switch (code) {
case Z_OK:
case glcr::OK:
return;
case Z_ERR_UNIMPLEMENTED:
case glcr::UNIMPLEMENTED:
dbgln("crash: UNIMPLEMENTED");
break;
case Z_ERR_CAP_NOT_FOUND:
case glcr::CAP_NOT_FOUND:
dbgln("crash: missing capability");
break;
case Z_ERR_CAP_TYPE:
case glcr::CAP_WRONG_TYPE:
dbgln("crash: capability of the wrong type");
break;
case Z_ERR_CAP_DENIED:
case glcr::CAP_PERMISSION_DENIED:
dbgln("crash: capability permissions error");
break;
default:

View File

@ -1,5 +1,6 @@
#include "mammoth/init.h"
#include <glacier/status/error.h>
#include <ztypes.h>
#include "mammoth/debug.h"
@ -16,7 +17,7 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
Port port(init_port_cap);
z_err_t ret;
uint64_t init_sig, init_cap;
while ((ret = port.PollForIntCap(&init_sig, &init_cap)) != Z_ERR_EMPTY) {
while ((ret = port.PollForIntCap(&init_sig, &init_cap)) != glcr::EMPTY) {
RET_ERR(ret);
switch (init_sig) {
case Z_INIT_SELF_PROC:
@ -39,5 +40,5 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
}
}
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,6 @@
#include "mammoth/port.h"
#include <glacier/status/error.h>
#include <zcall.h>
#include "mammoth/debug.h"
@ -13,10 +14,10 @@ z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
cap));
if (bytes != sizeof(uint64_t)) {
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
if (caps != 1) {
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,6 @@
#include "mammoth/process.h"
#include <glacier/status/error.h>
#include <zcall.h>
#include "mammoth/channel.h"
@ -133,5 +134,5 @@ uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
#endif
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,6 @@
#include "ahci/ahci_device.h"
#include <glacier/status/error.h>
#include <mammoth/debug.h>
#include <string.h>
#include <zcall.h>
@ -12,7 +13,7 @@ AhciDevice::AhciDevice(AhciPort* port) : port_struct_(port) {
uint64_t fis_page = port_struct_->fis_base & (~0xFFF);
if (cl_page != fis_page) {
crash("Non adjacent cl & fis", Z_ERR_UNIMPLEMENTED);
crash("Non adjacent cl & fis", glcr::UNIMPLEMENTED);
}
command_structures_ = MappedMemoryRegion::DirectPhysical(cl_page, 0x1000);
@ -48,7 +49,7 @@ z_err_t AhciDevice::IssueCommand(Command* command) {
commands_issued_ |= 1;
port_struct_->command_issue |= 1;
return Z_OK;
return glcr::OK;
}
void AhciDevice::DumpInfo() {

View File

@ -1,5 +1,6 @@
#include "ahci/ahci_driver.h"
#include <glacier/status/error.h>
#include <mammoth/debug.h>
#include <stdint.h>
#include <zcall.h>
@ -16,7 +17,7 @@ void interrupt_thread(void* void_driver) {
driver->InterruptLoop();
crash("Driver returned from interrupt loop", Z_ERR_UNIMPLEMENTED);
crash("Driver returned from interrupt loop", glcr::INTERNAL);
}
} // namespace
@ -30,20 +31,20 @@ z_err_t AhciDriver::Init() {
RET_ERR(LoadDevices());
// DumpCapabilities();
// DumpPorts();
return Z_OK;
return glcr::OK;
}
z_err_t AhciDriver::GetDevice(uint64_t id, AhciDevice** device) {
if (id >= 32) {
return Z_ERR_INVALID;
return glcr::INVALID_ARGUMENT;
}
if (devices_[id] != nullptr && !devices_[id]->IsInit()) {
return Z_ERR_NOT_FOUND;
return glcr::NOT_FOUND;
}
*device = devices_[id];
return Z_OK;
return glcr::OK;
}
void AhciDriver::DumpCapabilities() {
@ -156,13 +157,13 @@ void AhciDriver::InterruptLoop() {
z_err_t AhciDriver::LoadPciDeviceHeader() {
pci_region_ = MappedMemoryRegion::DirectPhysical(kSataPciPhys, kPciSize);
pci_device_header_ = reinterpret_cast<PciDeviceHeader*>(pci_region_.vaddr());
return Z_OK;
return glcr::OK;
}
z_err_t AhciDriver::LoadCapabilities() {
if (!(pci_device_header_->status_reg & 0x10)) {
dbgln("No caps!");
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
uint8_t* base = reinterpret_cast<uint8_t*>(pci_device_header_);
uint16_t offset = pci_device_header_->cap_ptr;
@ -185,7 +186,7 @@ z_err_t AhciDriver::LoadCapabilities() {
offset = (*cap & 0xFF00) >> 8;
} while (offset);
return Z_OK;
return glcr::OK;
}
z_err_t AhciDriver::RegisterIrq() {
@ -195,7 +196,7 @@ z_err_t AhciDriver::RegisterIrq() {
uint64_t irq_num = Z_IRQ_PCI_BASE + pci_device_header_->interrupt_pin - 1;
RET_ERR(ZIrqRegister(irq_num, &irq_port_cap_));
irq_thread_ = Thread(interrupt_thread, this);
return Z_OK;
return glcr::OK;
}
z_err_t AhciDriver::LoadHbaRegisters() {
@ -205,7 +206,7 @@ z_err_t AhciDriver::LoadHbaRegisters() {
num_ports_ = (ahci_hba_->capabilities & 0x1F) + 1;
num_commands_ = ((ahci_hba_->capabilities & 0x1F00) >> 8) + 1;
return Z_OK;
return glcr::OK;
}
z_err_t AhciDriver::LoadDevices() {
@ -217,5 +218,5 @@ z_err_t AhciDriver::LoadDevices() {
reinterpret_cast<uint64_t>(ahci_hba_) + 0x100 + (0x80 * i);
devices_[i] = new AhciDevice(reinterpret_cast<AhciPort*>(port_addr));
}
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,6 @@
#include "denali_server.h"
#include <glacier/status/error.h>
#include <mammoth/debug.h>
#include <zcall.h>
@ -38,7 +39,7 @@ z_err_t DenaliServer::RunServer() {
}
default:
dbgln("Invalid message type.");
return Z_ERR_UNIMPLEMENTED;
return glcr::UNIMPLEMENTED;
}
}
}
@ -50,7 +51,7 @@ z_err_t DenaliServer::HandleRead(const DenaliRead& read) {
device->IssueCommand(
new DmaReadCommand(read.lba, read.size, ::HandleResponse));
return Z_OK;
return glcr::OK;
}
void DenaliServer::HandleResponse(uint64_t lba, uint64_t size, uint64_t cap) {

View File

@ -1,5 +1,6 @@
#include "hw/gpt.h"
#include <glacier/status/error.h>
#include <mammoth/debug.h>
#include <zcall.h>
#include <zglobal.h>
@ -52,17 +53,17 @@ z_err_t GptReader::ParsePartitionTables() {
MappedMemoryRegion lba_1_and_2 = denali_.ReadSectors(0, 0, 2);
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
if (*mbr_sig != 0xAA55) {
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
MbrPartition* first_partition =
reinterpret_cast<MbrPartition*>(lba_1_and_2.vaddr() + 0x1BE);
if (first_partition->boot_indicator != 0) {
dbgln("Boot indicator set: %u", first_partition->boot_indicator);
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
if (first_partition->os_type != 0xEE) {
dbgln("Incorrect OS type: %x", first_partition->os_type);
return Z_ERR_INVALID;
return glcr::FAILED_PRECONDITION;
}
dbgln("LBAs: (%x, %x)", first_partition->starting_lba,
first_partition->ending_lba);
@ -97,5 +98,5 @@ z_err_t GptReader::ParsePartitionTables() {
}
}
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,7 @@
#include "boot/acpi.h"
#include <glacier/status/error.h>
#include "boot/boot_info.h"
#include "debug/debug.h"
@ -255,10 +257,10 @@ void ProbeRsdp() {
z_err_t GetPciExtendedConfiguration(uint64_t* base, uint64_t* offset) {
if (gPcieEcSize == 0) {
return Z_ERR_NOT_FOUND;
return glcr::NOT_FOUND;
}
*base = gPcieEcBase;
*offset = gPcieEcSize;
return Z_OK;
return glcr::OK;
}

View File

@ -2,6 +2,7 @@
#include <glacier/memory/ref_counted.h>
#include <glacier/memory/ref_ptr.h>
#include <glacier/status/error.h>
#include <stdint.h>
#include "include/ztypes.h"
@ -46,18 +47,18 @@ template <typename T>
z_err_t ValidateCapability(const glcr::RefPtr<Capability>& cap,
uint64_t permissions) {
if (!cap) {
return Z_ERR_CAP_NOT_FOUND;
return glcr::CAP_NOT_FOUND;
}
if (cap->raw_obj()->TypeTag() != KernelObjectTag<T>::type) {
return Z_ERR_CAP_TYPE;
return glcr::CAP_WRONG_TYPE;
}
if (!cap->HasPermissions(permissions)) {
return Z_ERR_CAP_DENIED;
return glcr::CAP_PERMISSION_DENIED;
}
return Z_OK;
return glcr::OK;
}
#define RET_IF_NULL(expr) \

View File

@ -8,14 +8,6 @@ void dbg(const char* fmt, ...);
void dbgln(const char* str, ...);
void panic(const char* str, ...);
#define RET_ERR(expr) \
{ \
z_err_t _tmp_err = expr; \
if (_tmp_err != Z_OK) { \
return _tmp_err; \
} \
}
#define UNREACHABLE \
panic("Unreachable %s, %s", __FILE__, __LINE__); \
__builtin_unreachable();

View File

@ -2,27 +2,7 @@
#include <stdint.h>
/* ------------------------------
* Error Types
*
* Bit 31 always set to 1 to
* distinguish from user-space errors.
* ------------------------------*/
#define Z_OK 0x0
#define Z_ERR_NOT_FOUND 0x1000'0001
#define Z_ERR_INVALID 0x1000'0002
#define Z_ERR_DENIED 0x1000'0003
#define Z_ERR_UNIMPLEMENTED 0x1000'0004
#define Z_ERR_BUFF_SIZE 001000'0005
#define Z_ERR_NULL 0x1000'0006
#define Z_ERR_EXISTS 0x1000'0007
#define Z_ERR_EMPTY 0x1000'0008
#define Z_ERR_CAP_NOT_FOUND 0x1001'0000
#define Z_ERR_CAP_TYPE 0x1001'0001
#define Z_ERR_CAP_DENIED 0x1001'0002
// Error codes defined in glacier/status/error.h
typedef uint64_t z_err_t;
/* ------------------------------

View File

@ -7,7 +7,7 @@ z_err_t UnboundedMessageQueue::PushBack(uint64_t num_bytes, const void* bytes,
const z_cap_t* caps) {
if (num_bytes > 0x1000) {
dbgln("Large message size unimplemented: %x", num_bytes);
return Z_ERR_UNIMPLEMENTED;
return glcr::UNIMPLEMENTED;
}
auto message = glcr::MakeShared<Message>();
@ -21,23 +21,23 @@ z_err_t UnboundedMessageQueue::PushBack(uint64_t num_bytes, const void* bytes,
// FIXME: This would feel safer closer to the relevant syscall.
auto cap = gScheduler->CurrentProcess().ReleaseCapability(caps[i]);
if (!cap) {
return Z_ERR_CAP_NOT_FOUND;
return glcr::CAP_NOT_FOUND;
}
message->caps.PushBack(cap);
}
pending_messages_.PushBack(message);
return Z_OK;
return glcr::OK;
}
z_err_t UnboundedMessageQueue::PopFront(uint64_t* num_bytes, void* bytes,
uint64_t* num_caps, z_cap_t* caps) {
auto next_msg = pending_messages_.PeekFront();
if (next_msg->num_bytes > *num_bytes) {
return Z_ERR_BUFF_SIZE;
return glcr::BUFFER_SIZE;
}
if (next_msg->caps.size() > *num_caps) {
return Z_ERR_BUFF_SIZE;
return glcr::BUFFER_SIZE;
}
next_msg = pending_messages_.PopFront();
@ -53,7 +53,7 @@ z_err_t UnboundedMessageQueue::PopFront(uint64_t* num_bytes, void* bytes,
for (uint64_t i = 0; i < *num_caps; i++) {
caps[i] = proc.AddExistingCapability(next_msg->caps.PopFront());
}
return Z_OK;
return glcr::OK;
}
void UnboundedMessageQueue::WriteKernel(uint64_t init,

View File

@ -44,5 +44,5 @@ z_err_t Channel::WriteInternal(uint64_t num_bytes, const void* bytes,
thread->SetState(Thread::RUNNABLE);
gScheduler->Enqueue(thread);
}
return Z_OK;
return glcr::OK;
}

View File

@ -13,7 +13,7 @@ z_err_t Port::Write(uint64_t num_bytes, const void* bytes, uint64_t num_caps,
thread->SetState(Thread::RUNNABLE);
gScheduler->Enqueue(thread);
}
return Z_OK;
return glcr::OK;
}
z_err_t Port::Read(uint64_t* num_bytes, void* bytes, uint64_t* num_caps,

View File

@ -20,5 +20,5 @@ z_err_t AddressSpaceMap(ZAddressSpaceMapReq* req) {
} else {
*req->vaddr = vmas->MapInMemoryObject(vmmo);
}
return Z_OK;
return glcr::OK;
}

View File

@ -1,13 +1,15 @@
#include "syscall/capability.h"
#include <glacier/status/error.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;
return glcr::CAP_NOT_FOUND;
}
*req->cap_out = proc.AddExistingCapability(cap);
return Z_OK;
return glcr::OK;
}

View File

@ -9,7 +9,7 @@ z_err_t ChannelCreate(ZChannelCreateReq* req) {
*req->channel1 = proc.AddNewCapability(chan_pair.first(), ZC_WRITE | ZC_READ);
*req->channel2 =
proc.AddNewCapability(chan_pair.second(), ZC_WRITE | ZC_READ);
return Z_OK;
return glcr::OK;
}
z_err_t ChannelSend(ZChannelSendReq* req) {

View File

@ -1,8 +1,10 @@
#include "syscall/debug.h"
#include <glacier/status/error.h>
#include "debug/debug.h"
z_err_t Debug(ZDebugReq* req) {
dbgln("[Debug] %s", req->message);
return Z_OK;
return glcr::OK;
}

View File

@ -8,7 +8,7 @@ z_err_t MemoryObjectCreate(ZMemoryObjectCreateReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
*req->vmmo_cap = curr_proc.AddNewCapability(
glcr::MakeRefCounted<MemoryObject>(req->size), ZC_WRITE);
return Z_OK;
return glcr::OK;
}
z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req) {
@ -17,7 +17,7 @@ z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req) {
auto vmmo_ref = glcr::MakeRefCounted<FixedMemoryObject>(paddr, req->size);
*req->vmmo_cap = curr_proc.AddNewCapability(
StaticCastRefPtr<MemoryObject>(vmmo_ref), ZC_WRITE);
return Z_OK;
return glcr::OK;
}
z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) {
@ -27,7 +27,7 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) {
*req->vmmo_cap = curr_proc.AddNewCapability(
StaticCastRefPtr<MemoryObject>(vmmo_ref), ZC_WRITE);
*req->paddr = paddr;
return Z_OK;
return glcr::OK;
}
z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req) {
@ -38,5 +38,5 @@ z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req) {
*req->vmmo_cap = curr_proc.AddNewCapability(
StaticCastRefPtr<MemoryObject>(vmmo_ref), ZC_WRITE);
*req->vmmo_size = pci_size;
return Z_OK;
return glcr::OK;
}

View File

@ -1,5 +1,7 @@
#include "syscall/port.h"
#include <glacier/status/error.h>
#include "capability/capability.h"
#include "interrupt/interrupt.h"
#include "scheduler/scheduler.h"
@ -8,7 +10,7 @@ z_err_t PortCreate(ZPortCreateReq* req) {
auto& proc = gScheduler->CurrentProcess();
auto port = glcr::MakeRefCounted<Port>();
*req->port_cap = proc.AddNewCapability(port, ZC_WRITE | ZC_READ);
return Z_OK;
return glcr::OK;
}
z_err_t PortSend(ZPortSendReq* req) {
@ -44,7 +46,7 @@ z_err_t PortPoll(ZPortPollReq* req) {
// FIXME: Race condition here where this call could block if the last message
// is removed between this check and the port read.
if (!port->HasMessages()) {
return Z_ERR_EMPTY;
return glcr::EMPTY;
}
return port->Read(req->num_bytes, req->data, req->num_caps, req->caps);
}
@ -53,10 +55,10 @@ z_err_t IrqRegister(ZIrqRegisterReq* req) {
auto& proc = gScheduler->CurrentProcess();
if (req->irq_num != Z_IRQ_PCI_BASE) {
// FIXME: Don't hardcode this nonsense.
return Z_ERR_UNIMPLEMENTED;
return glcr::UNIMPLEMENTED;
}
glcr::RefPtr<Port> port = glcr::MakeRefCounted<Port>();
*req->port_cap = proc.AddNewCapability(port, ZC_READ | ZC_WRITE);
RegisterPciPort(port);
return Z_OK;
return glcr::OK;
}

View File

@ -10,7 +10,7 @@ z_err_t ProcessExit(ZProcessExitReq* req) {
// FIXME: kill process here.
curr_thread->Exit();
panic("Returned from thread exit");
return Z_ERR_UNIMPLEMENTED;
return glcr::UNIMPLEMENTED;
}
z_err_t ProcessSpawn(ZProcessSpawnReq* req) {
@ -28,11 +28,11 @@ z_err_t ProcessSpawn(ZProcessSpawnReq* req) {
if (req->bootstrap_cap != 0) {
auto cap = curr_proc.ReleaseCapability(req->bootstrap_cap);
if (!cap) {
return Z_ERR_CAP_NOT_FOUND;
return glcr::CAP_NOT_FOUND;
}
// FIXME: Check permissions.
*req->new_bootstrap_cap = proc->AddExistingCapability(cap);
}
return Z_OK;
return glcr::OK;
}

View File

@ -79,7 +79,7 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) {
CASE(Debug);
default:
dbgln("Unhandled syscall number: %x", call_id);
return Z_ERR_UNIMPLEMENTED;
return glcr::UNIMPLEMENTED;
}
UNREACHABLE
}

View File

@ -11,7 +11,7 @@ z_err_t ThreadCreate(ZThreadCreateReq* req) {
auto parent_proc = cap->obj<Process>();
auto thread = parent_proc->CreateThread();
*req->thread_cap = curr_proc.AddNewCapability(thread, ZC_WRITE);
return Z_OK;
return glcr::OK;
}
z_err_t ThreadStart(ZThreadStartReq* req) {
@ -22,7 +22,7 @@ z_err_t ThreadStart(ZThreadStartReq* req) {
auto thread = cap->obj<Thread>();
// FIXME: validate entry point is in user space.
thread->Start(req->entry, req->arg1, req->arg2);
return Z_OK;
return glcr::OK;
}
z_err_t ThreadExit(ZThreadExitReq*) {