[Mammoth] Move most classes to the mmth namespace.
This commit is contained in:
parent
5f8d577948
commit
8d730c67c1
42 changed files with 130 additions and 60 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
namespace {
|
||||
|
||||
uint64_t strlen(const char* ptr) {
|
||||
|
|
@ -55,3 +56,5 @@ z_err_t CreateChannels(Channel& c1, Channel& c2) {
|
|||
c2.adopt_cap(chan2);
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class Channel {
|
||||
public:
|
||||
Channel() {}
|
||||
|
|
@ -45,3 +47,5 @@ z_err_t Channel::ReadStructAndCap(T* obj, uint64_t* cap) {
|
|||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#include "ipc/endpoint_server.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::UniquePtr<EndpointClient> EndpointClient::AdoptEndpoint(z_cap_t cap) {
|
||||
return glcr::UniquePtr<EndpointClient>(new EndpointClient(cap));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <zcall.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class EndpointClient {
|
||||
public:
|
||||
EndpointClient() = delete;
|
||||
|
|
@ -63,3 +65,5 @@ glcr::ErrorOr<Resp> EndpointClient::CallEndpoint(const Req& req) {
|
|||
|
||||
return resp;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
// Declared as friend in EndpointServer.
|
||||
void EndpointServerThreadBootstrap(void* endpoint_server) {
|
||||
reinterpret_cast<EndpointServer*>(endpoint_server)->ServerThread();
|
||||
|
|
@ -40,3 +41,5 @@ void EndpointServer::ServerThread() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "mammoth/ipc/response_context.h"
|
||||
#include "mammoth/proc/thread.h"
|
||||
|
||||
namespace mmth {
|
||||
class EndpointServer {
|
||||
public:
|
||||
EndpointServer() = delete;
|
||||
|
|
@ -34,3 +35,5 @@ class EndpointServer {
|
|||
friend void EndpointServerThreadBootstrap(void* endpoint_server);
|
||||
void ServerThread();
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
PortClient PortClient::AdoptPort(z_cap_t cap) { return PortClient(cap); }
|
||||
PortClient::PortClient(z_cap_t port_cap) : port_cap_(port_cap) {}
|
||||
|
||||
|
|
@ -12,3 +14,5 @@ glcr::ErrorCode PortClient::WriteString(glcr::String str, z_cap_t cap) {
|
|||
return static_cast<glcr::ErrorCode>(
|
||||
ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class PortClient {
|
||||
public:
|
||||
PortClient() {}
|
||||
|
|
@ -29,3 +31,5 @@ template <typename T>
|
|||
z_err_t PortClient::WriteMessage(const T& obj, z_cap_t cap) {
|
||||
return ZPortSend(port_cap_, sizeof(obj), &obj, 1, &cap);
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::ErrorOr<PortServer> PortServer::Create() {
|
||||
z_cap_t port;
|
||||
RET_ERR(ZPortCreate(&port));
|
||||
|
|
@ -44,3 +46,5 @@ glcr::ErrorCode PortServer::PollForIntCap(uint64_t *msg, uint64_t *cap) {
|
|||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "mammoth/ipc/port_client.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class PortServer {
|
||||
public:
|
||||
static glcr::ErrorOr<PortServer> Create();
|
||||
|
|
@ -22,3 +24,5 @@ class PortServer {
|
|||
|
||||
PortServer(z_cap_t cap);
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#define MAM_PROC_DEBUG 0
|
||||
|
||||
namespace mmth {
|
||||
namespace {
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -140,3 +141,5 @@ glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
|||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -4,5 +4,9 @@
|
|||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
||||
z_cap_t yellowstone_client);
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
Mutex::Mutex(Mutex&& other) : mutex_cap_(other.mutex_cap_) {
|
||||
other.mutex_cap_ = 0;
|
||||
}
|
||||
|
|
@ -25,3 +27,5 @@ glcr::ErrorCode Mutex::Lock() {
|
|||
glcr::ErrorCode Mutex::Release() {
|
||||
return static_cast<glcr::ErrorCode>(ZMutexRelease(mutex_cap_));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class Mutex {
|
||||
public:
|
||||
Mutex(const Mutex&) = delete;
|
||||
|
|
@ -19,3 +21,5 @@ class Mutex {
|
|||
|
||||
Mutex(z_cap_t mutex_cap) : mutex_cap_(mutex_cap) {}
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -4,8 +4,12 @@
|
|||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
Semaphore::Semaphore() { check(ZSemaphoreCreate(&semaphore_cap_)); }
|
||||
Semaphore::~Semaphore() { check(ZCapRelease(semaphore_cap_)); }
|
||||
|
||||
void Semaphore::Wait() { check(ZSemaphoreWait(semaphore_cap_)); }
|
||||
void Semaphore::Signal() { check(ZSemaphoreSignal(semaphore_cap_)); }
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class Semaphore {
|
||||
public:
|
||||
Semaphore();
|
||||
|
|
@ -13,3 +15,5 @@ class Semaphore {
|
|||
private:
|
||||
z_cap_t semaphore_cap_;
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ uint64_t gBootPciVmmoCap = 0;
|
|||
uint64_t gBootFramebufferVmmoCap = 0;
|
||||
|
||||
z_err_t ParseInitPort(uint64_t init_port_cap) {
|
||||
PortServer port = PortServer::AdoptCap(init_port_cap);
|
||||
mmth::PortServer port = mmth::PortServer::AdoptCap(init_port_cap);
|
||||
z_err_t ret;
|
||||
uint64_t init_sig, init_cap;
|
||||
while ((ret = port.PollForIntCap(&init_sig, &init_cap)) != glcr::EMPTY) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include "util/debug.h"
|
||||
#include "util/init.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
OwnedMemoryRegion::OwnedMemoryRegion(OwnedMemoryRegion&& other)
|
||||
: OwnedMemoryRegion(other.vmmo_cap_, other.vaddr_, other.size_) {
|
||||
other.vmmo_cap_ = 0;
|
||||
|
|
@ -68,3 +70,5 @@ z_cap_t OwnedMemoryRegion::DuplicateCap() {
|
|||
check(ZCapDuplicate(vmmo_cap_, kZionPerm_All, &cap));
|
||||
return cap;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
/*
|
||||
* Memory Region class that unmaps its memory and releases its
|
||||
* capability when it goes out of scope.
|
||||
|
|
@ -41,3 +42,5 @@ class OwnedMemoryRegion {
|
|||
// TODO: We may want to differentiate between VMMO size and mapped size?
|
||||
uint64_t size_ = 0;
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue