Compare commits
No commits in common. "6212aef3365ac67f2d55e5f3e2ed3857f1dd2d9d" and "4e25a7e3b9c767c368402f090ea91bfd93b5f704" have entirely different histories.
6212aef336
...
4e25a7e3b9
|
|
@ -3,7 +3,6 @@
|
||||||
#include <glacier/string/str_split.h>
|
#include <glacier/string/str_split.h>
|
||||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||||
#include <yellowstone/yellowstone.yunq.client.h>
|
#include <yellowstone/yellowstone.yunq.client.h>
|
||||||
#include <zcall.h>
|
|
||||||
#include <zglobal.h>
|
#include <zglobal.h>
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
@ -11,19 +10,11 @@
|
||||||
namespace mmth {
|
namespace mmth {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using yellowstone::Endpoint;
|
|
||||||
using yellowstone::GetEndpointRequest;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
VFSClient* gVfsClient = nullptr;
|
VFSClient* gVfsClient = nullptr;
|
||||||
|
|
||||||
void GetVfsClientIfNeeded() {
|
void GetVfsClientIfNeeded() {
|
||||||
if (gVfsClient == nullptr) {
|
if (gVfsClient == nullptr) {
|
||||||
// TODO: Add an unowned client so we don't have to duplicate this cap every
|
YellowstoneClient client(gInitEndpointCap);
|
||||||
// time.
|
|
||||||
uint64_t dup_cap;
|
|
||||||
check(ZCapDuplicate(gInitEndpointCap, kZionPerm_All, &dup_cap));
|
|
||||||
YellowstoneClient client(dup_cap);
|
|
||||||
|
|
||||||
GetEndpointRequest yreq;
|
GetEndpointRequest yreq;
|
||||||
yreq.set_endpoint_name("victoriafalls");
|
yreq.set_endpoint_name("victoriafalls");
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,6 @@
|
||||||
namespace mmth {
|
namespace mmth {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using yellowstone::Endpoint;
|
|
||||||
using yellowstone::GetEndpointRequest;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
void KeyboardListenerEntry(void* keyboard_base) {
|
void KeyboardListenerEntry(void* keyboard_base) {
|
||||||
reinterpret_cast<KeyboardListenerBase*>(keyboard_base)->ListenLoop();
|
reinterpret_cast<KeyboardListenerBase*>(keyboard_base)->ListenLoop();
|
||||||
}
|
}
|
||||||
|
|
@ -28,9 +24,7 @@ KeyboardListenerBase::KeyboardListenerBase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardListenerBase::Register() {
|
void KeyboardListenerBase::Register() {
|
||||||
uint64_t dup_cap;
|
YellowstoneClient client(gInitEndpointCap);
|
||||||
check(ZCapDuplicate(gInitEndpointCap, kZionPerm_All, &dup_cap));
|
|
||||||
YellowstoneClient client(dup_cap);
|
|
||||||
|
|
||||||
GetEndpointRequest req;
|
GetEndpointRequest req;
|
||||||
req.set_endpoint_name("voyageurs");
|
req.set_endpoint_name("voyageurs");
|
||||||
|
|
@ -46,7 +40,8 @@ void KeyboardListenerBase::Register() {
|
||||||
crash("Failed to create client", client_or.error());
|
crash("Failed to create client", client_or.error());
|
||||||
}
|
}
|
||||||
listn.set_port_capability(client_or.value().cap());
|
listn.set_port_capability(client_or.value().cap());
|
||||||
check(vclient.RegisterKeyboardListener(listn));
|
None n;
|
||||||
|
check(vclient.RegisterKeyboardListener(listn, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread KeyboardListenerBase::Listen() {
|
Thread KeyboardListenerBase::Listen() {
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,13 @@
|
||||||
#include "ahci/ahci_driver.h"
|
#include "ahci/ahci_driver.h"
|
||||||
#include "denali_server.h"
|
#include "denali_server.h"
|
||||||
|
|
||||||
using yellowstone::AhciInfo;
|
|
||||||
using yellowstone::RegisterEndpointRequest;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
uint64_t main(uint64_t init_port_cap) {
|
uint64_t main(uint64_t init_port_cap) {
|
||||||
check(ParseInitPort(init_port_cap));
|
check(ParseInitPort(init_port_cap));
|
||||||
|
|
||||||
YellowstoneClient stub(gInitEndpointCap);
|
YellowstoneClient stub(gInitEndpointCap);
|
||||||
|
Empty empty;
|
||||||
AhciInfo ahci;
|
AhciInfo ahci;
|
||||||
RET_ERR(stub.GetAhciInfo(ahci));
|
RET_ERR(stub.GetAhciInfo(empty, ahci));
|
||||||
mmth::OwnedMemoryRegion ahci_region =
|
mmth::OwnedMemoryRegion ahci_region =
|
||||||
mmth::OwnedMemoryRegion::FromCapability(ahci.ahci_region());
|
mmth::OwnedMemoryRegion::FromCapability(ahci.ahci_region());
|
||||||
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region)));
|
ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region)));
|
||||||
|
|
@ -24,13 +21,14 @@ uint64_t main(uint64_t init_port_cap) {
|
||||||
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
|
ASSIGN_OR_RETURN(glcr::UniquePtr<DenaliServer> server,
|
||||||
DenaliServer::Create(*driver));
|
DenaliServer::Create(*driver));
|
||||||
|
|
||||||
|
ASSIGN_OR_RETURN(DenaliClient client, server->CreateClient());
|
||||||
|
|
||||||
Thread server_thread = server->RunServer();
|
Thread server_thread = server->RunServer();
|
||||||
|
|
||||||
RegisterEndpointRequest req;
|
RegisterEndpointRequest req;
|
||||||
req.set_endpoint_name("denali");
|
req.set_endpoint_name("denali");
|
||||||
ASSIGN_OR_RETURN(z_cap_t client_cap, server->CreateClientCap());
|
req.set_endpoint_capability(client.Capability());
|
||||||
req.set_endpoint_capability(client_cap);
|
check(stub.RegisterEndpoint(req, empty));
|
||||||
check(stub.RegisterEndpoint(req));
|
|
||||||
|
|
||||||
check(server_thread.Join());
|
check(server_thread.Join());
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DenaliClient::~DenaliClient() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode DenaliClient::Read(const ReadRequest& request, ReadResponse& response) {
|
glcr::ErrorCode DenaliClient::Read(const ReadRequest& request, ReadResponse& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -28,10 +17,7 @@ glcr::ErrorCode DenaliClient::Read(const ReadRequest& request, ReadResponse& res
|
||||||
buffer_.WriteAt<uint64_t>(8, 0);
|
buffer_.WriteAt<uint64_t>(8, 0);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -47,18 +33,14 @@ glcr::ErrorCode DenaliClient::Read(const ReadRequest& request, ReadResponse& res
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse& response) {
|
glcr::ErrorCode DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -67,10 +49,7 @@ glcr::ErrorCode DenaliClient::ReadMany(const ReadManyRequest& request, ReadRespo
|
||||||
buffer_.WriteAt<uint64_t>(8, 1);
|
buffer_.WriteAt<uint64_t>(8, 1);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -86,13 +65,9 @@ glcr::ErrorCode DenaliClient::ReadMany(const ReadManyRequest& request, ReadRespo
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,19 @@
|
||||||
|
|
||||||
#include "denali.yunq.h"
|
#include "denali.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
class DenaliClient {
|
class DenaliClient {
|
||||||
public:
|
public:
|
||||||
DenaliClient(z_cap_t Denali_cap) : endpoint_(Denali_cap) {}
|
DenaliClient(z_cap_t Denali_cap) : endpoint_(Denali_cap) {}
|
||||||
DenaliClient(const DenaliClient&) = delete;
|
DenaliClient(const DenaliClient&) = delete;
|
||||||
DenaliClient(DenaliClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
DenaliClient(DenaliClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~DenaliClient();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode Read(const ReadRequest& request, ReadResponse& response);
|
[[nodiscard]] glcr::ErrorCode Read(const ReadRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
[[nodiscard]] glcr::ErrorCode ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
uint64_t kBufferSize = 0x1000;
|
uint64_t kBufferSize = 0x1000;
|
||||||
|
|
@ -34,4 +28,3 @@ class DenaliClient {
|
||||||
uint64_t kCapBufferSize = 0x10;
|
uint64_t kCapBufferSize = 0x10;
|
||||||
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "denali.yunq.h"
|
#include "denali.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -250,4 +249,3 @@ uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
#include <glacier/container/vector.h>
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
class ReadRequest {
|
class ReadRequest {
|
||||||
public:
|
public:
|
||||||
ReadRequest() {}
|
ReadRequest() {}
|
||||||
|
|
@ -86,4 +84,3 @@ class ReadResponse {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -30,18 +29,6 @@ void DenaliServerBaseThreadBootstrap(void* server_base) {
|
||||||
((DenaliServerBase*)server_base)->ServerThread();
|
((DenaliServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
DenaliServerBase::~DenaliServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> DenaliServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<DenaliClient> DenaliServerBase::CreateClient() {
|
glcr::ErrorOr<DenaliClient> DenaliServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -100,43 +87,25 @@ glcr::ErrorCode DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
|
|
||||||
ReadRequest yunq_request;
|
ReadRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ReadResponse yunq_response;
|
ReadResponse yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(HandleRead(yunq_request, yunq_response));
|
RET_ERR(HandleRead(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
|
|
||||||
ReadManyRequest yunq_request;
|
ReadManyRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ReadResponse yunq_response;
|
ReadResponse yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(HandleReadMany(yunq_request, yunq_response));
|
RET_ERR(HandleReadMany(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -145,5 +114,3 @@ glcr::ErrorCode DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,30 +10,22 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DenaliServerBase {
|
class DenaliServerBase {
|
||||||
public:
|
public:
|
||||||
DenaliServerBase(z_cap_t Denali_cap) : endpoint_(Denali_cap) {}
|
DenaliServerBase(z_cap_t Denali_cap) : endpoint_(Denali_cap) {}
|
||||||
DenaliServerBase(const DenaliServerBase&) = delete;
|
DenaliServerBase(const DenaliServerBase&) = delete;
|
||||||
DenaliServerBase(DenaliServerBase&&) = delete;
|
DenaliServerBase(DenaliServerBase&&) = delete;
|
||||||
virtual ~DenaliServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<DenaliClient> CreateClient();
|
glcr::ErrorOr<DenaliClient> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
||||||
|
|
@ -45,5 +37,3 @@ class DenaliServerBase {
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "framebuffer/framebuffer.h"
|
#include "framebuffer/framebuffer.h"
|
||||||
|
|
||||||
Framebuffer::Framebuffer(const yellowstone::FramebufferInfo& info)
|
Framebuffer::Framebuffer(const FramebufferInfo& info)
|
||||||
: fb_info_(info), cursor_pos_(0) {
|
: fb_info_(info), cursor_pos_(0) {
|
||||||
uint64_t buff_size_bytes = fb_info_.height() * fb_info_.pitch();
|
uint64_t buff_size_bytes = fb_info_.height() * fb_info_.pitch();
|
||||||
fb_memory_ = mmth::OwnedMemoryRegion::DirectPhysical(fb_info_.address_phys(),
|
fb_memory_ = mmth::OwnedMemoryRegion::DirectPhysical(fb_info_.address_phys(),
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class Framebuffer {
|
class Framebuffer {
|
||||||
public:
|
public:
|
||||||
Framebuffer(const yellowstone::FramebufferInfo& info);
|
Framebuffer(const FramebufferInfo& info);
|
||||||
|
|
||||||
void DrawPixel(uint32_t row, uint32_t col, uint32_t pixel);
|
void DrawPixel(uint32_t row, uint32_t col, uint32_t pixel);
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ class Framebuffer {
|
||||||
private:
|
private:
|
||||||
// FIXME: Implement Yunq copy or move so we
|
// FIXME: Implement Yunq copy or move so we
|
||||||
// don't have to store a reference here.
|
// don't have to store a reference here.
|
||||||
const yellowstone::FramebufferInfo& fb_info_;
|
const FramebufferInfo& fb_info_;
|
||||||
|
|
||||||
mmth::OwnedMemoryRegion fb_memory_;
|
mmth::OwnedMemoryRegion fb_memory_;
|
||||||
uint32_t* fb_;
|
uint32_t* fb_;
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,6 @@
|
||||||
#include "framebuffer/psf.h"
|
#include "framebuffer/psf.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
|
||||||
using yellowstone::FramebufferInfo;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
uint64_t main(uint64_t init_port) {
|
uint64_t main(uint64_t init_port) {
|
||||||
ParseInitPort(init_port);
|
ParseInitPort(init_port);
|
||||||
|
|
||||||
|
|
@ -21,7 +18,7 @@ uint64_t main(uint64_t init_port) {
|
||||||
YellowstoneClient client(gInitEndpointCap);
|
YellowstoneClient client(gInitEndpointCap);
|
||||||
|
|
||||||
FramebufferInfo framebuffer;
|
FramebufferInfo framebuffer;
|
||||||
RET_ERR(client.GetFramebufferInfo(framebuffer));
|
RET_ERR(client.GetFramebufferInfo({}, framebuffer));
|
||||||
dbgln("FB addr {x}, bpp {}, width {} , height {}, pitch {}",
|
dbgln("FB addr {x}, bpp {}, width {} , height {}, pitch {}",
|
||||||
framebuffer.address_phys(), framebuffer.bpp(), framebuffer.width(),
|
framebuffer.address_phys(), framebuffer.bpp(), framebuffer.width(),
|
||||||
framebuffer.height(), framebuffer.pitch());
|
framebuffer.height(), framebuffer.pitch());
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
|
|
||||||
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||||
const yellowstone::DenaliInfo& denali_info) {
|
const DenaliInfo& denali_info) {
|
||||||
// Read 1024 bytes from 1024 offset.
|
// Read 1024 bytes from 1024 offset.
|
||||||
// FIXME: Don't assume 512 byte sectors somehow.
|
// FIXME: Don't assume 512 byte sectors somehow.
|
||||||
DenaliClient client(denali_info.denali_endpoint());
|
DenaliClient client(denali_info.denali_endpoint());
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
class Ext2BlockReader {
|
class Ext2BlockReader {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
||||||
const yellowstone::DenaliInfo& denali_info);
|
const DenaliInfo& denali_info);
|
||||||
|
|
||||||
// TODO: Consider creating a new class wrapper with these computations.
|
// TODO: Consider creating a new class wrapper with these computations.
|
||||||
Superblock* GetSuperblock();
|
Superblock* GetSuperblock();
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
|
|
||||||
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(
|
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(const DenaliInfo& denali_info) {
|
||||||
const yellowstone::DenaliInfo& denali_info) {
|
|
||||||
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
||||||
Ext2BlockReader::Init(glcr::Move(denali_info)));
|
Ext2BlockReader::Init(glcr::Move(denali_info)));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
class Ext2Driver {
|
class Ext2Driver {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<Ext2Driver> Init(
|
static glcr::ErrorOr<Ext2Driver> Init(const DenaliInfo& denali_info);
|
||||||
const yellowstone::DenaliInfo& denali_info);
|
|
||||||
|
|
||||||
glcr::ErrorCode ProbePartition();
|
glcr::ErrorCode ProbePartition();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VFSClient::~VFSClient() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode VFSClient::OpenFile(const OpenFileRequest& request, OpenFileResponse& response) {
|
glcr::ErrorCode VFSClient::OpenFile(const OpenFileRequest& request, OpenFileResponse& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -28,10 +17,7 @@ glcr::ErrorCode VFSClient::OpenFile(const OpenFileRequest& request, OpenFileResp
|
||||||
buffer_.WriteAt<uint64_t>(8, 0);
|
buffer_.WriteAt<uint64_t>(8, 0);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -47,18 +33,14 @@ glcr::ErrorCode VFSClient::OpenFile(const OpenFileRequest& request, OpenFileResp
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode VFSClient::GetDirectory(const GetDirectoryRequest& request, Directory& response) {
|
glcr::ErrorCode VFSClient::GetDirectory(const GetDirectoryRequest& request, Directory& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -67,10 +49,7 @@ glcr::ErrorCode VFSClient::GetDirectory(const GetDirectoryRequest& request, Dire
|
||||||
buffer_.WriteAt<uint64_t>(8, 1);
|
buffer_.WriteAt<uint64_t>(8, 1);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -86,13 +65,9 @@ glcr::ErrorCode VFSClient::GetDirectory(const GetDirectoryRequest& request, Dire
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,19 @@
|
||||||
|
|
||||||
#include "victoriafalls.yunq.h"
|
#include "victoriafalls.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
class VFSClient {
|
class VFSClient {
|
||||||
public:
|
public:
|
||||||
VFSClient(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
VFSClient(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
||||||
VFSClient(const VFSClient&) = delete;
|
VFSClient(const VFSClient&) = delete;
|
||||||
VFSClient(VFSClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
VFSClient(VFSClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~VFSClient();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode OpenFile(const OpenFileRequest& request, OpenFileResponse& response);
|
[[nodiscard]] glcr::ErrorCode OpenFile(const OpenFileRequest& request, OpenFileResponse& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode GetDirectory(const GetDirectoryRequest& request, Directory& response);
|
[[nodiscard]] glcr::ErrorCode GetDirectory(const GetDirectoryRequest& request, Directory& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
uint64_t kBufferSize = 0x1000;
|
uint64_t kBufferSize = 0x1000;
|
||||||
|
|
@ -34,4 +28,3 @@ class VFSClient {
|
||||||
uint64_t kCapBufferSize = 0x10;
|
uint64_t kCapBufferSize = 0x10;
|
||||||
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "victoriafalls.yunq.h"
|
#include "victoriafalls.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -285,4 +284,3 @@ uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, g
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
#include <glacier/container/vector.h>
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
class OpenFileRequest {
|
class OpenFileRequest {
|
||||||
public:
|
public:
|
||||||
OpenFileRequest() {}
|
OpenFileRequest() {}
|
||||||
|
|
@ -94,4 +92,3 @@ class Directory {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -30,18 +29,6 @@ void VFSServerBaseThreadBootstrap(void* server_base) {
|
||||||
((VFSServerBase*)server_base)->ServerThread();
|
((VFSServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
VFSServerBase::~VFSServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> VFSServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<VFSClient> VFSServerBase::CreateClient() {
|
glcr::ErrorOr<VFSClient> VFSServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -100,43 +87,25 @@ glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
|
|
||||||
OpenFileRequest yunq_request;
|
OpenFileRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OpenFileResponse yunq_response;
|
OpenFileResponse yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(HandleOpenFile(yunq_request, yunq_response));
|
RET_ERR(HandleOpenFile(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
|
|
||||||
GetDirectoryRequest yunq_request;
|
GetDirectoryRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Directory yunq_response;
|
Directory yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(HandleGetDirectory(yunq_request, yunq_response));
|
RET_ERR(HandleGetDirectory(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -145,5 +114,3 @@ glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,30 +10,22 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VFSServerBase {
|
class VFSServerBase {
|
||||||
public:
|
public:
|
||||||
VFSServerBase(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
VFSServerBase(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
||||||
VFSServerBase(const VFSServerBase&) = delete;
|
VFSServerBase(const VFSServerBase&) = delete;
|
||||||
VFSServerBase(VFSServerBase&&) = delete;
|
VFSServerBase(VFSServerBase&&) = delete;
|
||||||
virtual ~VFSServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<VFSClient> CreateClient();
|
glcr::ErrorOr<VFSClient> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleOpenFile(const OpenFileRequest&, OpenFileResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleOpenFile(const OpenFileRequest&, OpenFileResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetDirectory(const GetDirectoryRequest&, Directory&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetDirectory(const GetDirectoryRequest&, Directory&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
||||||
|
|
@ -45,5 +37,3 @@ class VFSServerBase {
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,15 @@
|
||||||
#include "fs/ext2/ext2_driver.h"
|
#include "fs/ext2/ext2_driver.h"
|
||||||
#include "victoriafalls_server.h"
|
#include "victoriafalls_server.h"
|
||||||
|
|
||||||
using yellowstone::DenaliInfo;
|
|
||||||
using yellowstone::RegisterEndpointRequest;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
uint64_t main(uint64_t init_cap) {
|
uint64_t main(uint64_t init_cap) {
|
||||||
ParseInitPort(init_cap);
|
ParseInitPort(init_cap);
|
||||||
|
|
||||||
dbgln("VFs Started");
|
dbgln("VFs Started");
|
||||||
|
|
||||||
YellowstoneClient yellowstone(gInitEndpointCap);
|
YellowstoneClient yellowstone(gInitEndpointCap);
|
||||||
|
Empty empty;
|
||||||
DenaliInfo denali_info;
|
DenaliInfo denali_info;
|
||||||
RET_ERR(yellowstone.GetDenali(denali_info));
|
RET_ERR(yellowstone.GetDenali(empty, denali_info));
|
||||||
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(denali_info));
|
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(denali_info));
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(auto server, VFSServer::Create(ext2));
|
ASSIGN_OR_RETURN(auto server, VFSServer::Create(ext2));
|
||||||
|
|
@ -25,9 +22,9 @@ uint64_t main(uint64_t init_cap) {
|
||||||
|
|
||||||
RegisterEndpointRequest req;
|
RegisterEndpointRequest req;
|
||||||
req.set_endpoint_name("victoriafalls");
|
req.set_endpoint_name("victoriafalls");
|
||||||
ASSIGN_OR_RETURN(auto client_cap, server->CreateClientCap());
|
ASSIGN_OR_RETURN(auto client, server->CreateClient());
|
||||||
req.set_endpoint_capability(client_cap);
|
req.set_endpoint_capability(client.Capability());
|
||||||
check(yellowstone.RegisterEndpoint(req));
|
check(yellowstone.RegisterEndpoint(req, empty));
|
||||||
|
|
||||||
RET_ERR(server_thread.Join());
|
RET_ERR(server_thread.Join());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
interface Voyageurs {
|
interface Voyageurs {
|
||||||
method RegisterKeyboardListener(KeyboardListener) -> ();
|
method RegisterKeyboardListener(KeyboardListener) -> (None);
|
||||||
}
|
}
|
||||||
|
|
||||||
message KeyboardListener {
|
message KeyboardListener {
|
||||||
capability port_capability;
|
capability port_capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message None {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VoyageursClient::~VoyageursClient() {
|
glcr::ErrorCode VoyageursClient::RegisterKeyboardListener(const KeyboardListener& request, None& response) {
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode VoyageursClient::RegisterKeyboardListener(const KeyboardListener& request) {
|
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -28,10 +17,7 @@ glcr::ErrorCode VoyageursClient::RegisterKeyboardListener(const KeyboardListener
|
||||||
buffer_.WriteAt<uint64_t>(8, 0);
|
buffer_.WriteAt<uint64_t>(8, 0);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -47,11 +33,9 @@ glcr::ErrorCode VoyageursClient::RegisterKeyboardListener(const KeyboardListener
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,20 +8,16 @@
|
||||||
|
|
||||||
#include "voyageurs.yunq.h"
|
#include "voyageurs.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
class VoyageursClient {
|
class VoyageursClient {
|
||||||
public:
|
public:
|
||||||
VoyageursClient(z_cap_t Voyageurs_cap) : endpoint_(Voyageurs_cap) {}
|
VoyageursClient(z_cap_t Voyageurs_cap) : endpoint_(Voyageurs_cap) {}
|
||||||
VoyageursClient(const VoyageursClient&) = delete;
|
VoyageursClient(const VoyageursClient&) = delete;
|
||||||
VoyageursClient(VoyageursClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
VoyageursClient(VoyageursClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~VoyageursClient();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::ErrorCode RegisterKeyboardListener(const KeyboardListener& request, None& response);
|
||||||
[[nodiscard]] glcr::ErrorCode RegisterKeyboardListener(const KeyboardListener& request);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
@ -30,4 +26,3 @@ class VoyageursClient {
|
||||||
uint64_t kCapBufferSize = 0x10;
|
uint64_t kCapBufferSize = 0x10;
|
||||||
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "voyageurs.yunq.h"
|
#include "voyageurs.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -76,4 +75,36 @@ uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
void None::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void None::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void None::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
|
CheckHeader(bytes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t None::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
uint32_t next_extension = header_size + 8 * 0;
|
||||||
|
const uint32_t core_size = next_extension;
|
||||||
|
|
||||||
|
// The next extension pointer is the length of the message.
|
||||||
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
|
return next_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t None::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||||
|
uint32_t next_extension = header_size + 8 * 0;
|
||||||
|
const uint32_t core_size = next_extension;
|
||||||
|
uint64_t next_cap = 0;
|
||||||
|
|
||||||
|
// The next extension pointer is the length of the message.
|
||||||
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
|
return next_extension;
|
||||||
|
}
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
#include <glacier/container/vector.h>
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
class KeyboardListener {
|
class KeyboardListener {
|
||||||
public:
|
public:
|
||||||
KeyboardListener() {}
|
KeyboardListener() {}
|
||||||
|
|
@ -28,4 +26,20 @@ class KeyboardListener {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
class None {
|
||||||
|
public:
|
||||||
|
None() {}
|
||||||
|
// Delete copy and move until implemented.
|
||||||
|
None(const None&) = delete;
|
||||||
|
None(None&&) = delete;
|
||||||
|
|
||||||
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||||
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||||
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
|
};
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -30,18 +29,6 @@ void VoyageursServerBaseThreadBootstrap(void* server_base) {
|
||||||
((VoyageursServerBase*)server_base)->ServerThread();
|
((VoyageursServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
VoyageursServerBase::~VoyageursServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> VoyageursServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<VoyageursClient> VoyageursServerBase::CreateClient() {
|
glcr::ErrorOr<VoyageursClient> VoyageursServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -100,21 +87,14 @@ glcr::ErrorCode VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& reque
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
|
|
||||||
KeyboardListener yunq_request;
|
KeyboardListener yunq_request;
|
||||||
|
None yunq_response;
|
||||||
|
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
RET_ERR(HandleRegisterKeyboardListener(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
|
|
||||||
RET_ERR(HandleRegisterKeyboardListener(yunq_request));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = 0;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -123,5 +103,3 @@ glcr::ErrorCode VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& reque
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,18 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VoyageursServerBase {
|
class VoyageursServerBase {
|
||||||
public:
|
public:
|
||||||
VoyageursServerBase(z_cap_t Voyageurs_cap) : endpoint_(Voyageurs_cap) {}
|
VoyageursServerBase(z_cap_t Voyageurs_cap) : endpoint_(Voyageurs_cap) {}
|
||||||
VoyageursServerBase(const VoyageursServerBase&) = delete;
|
VoyageursServerBase(const VoyageursServerBase&) = delete;
|
||||||
VoyageursServerBase(VoyageursServerBase&&) = delete;
|
VoyageursServerBase(VoyageursServerBase&&) = delete;
|
||||||
virtual ~VoyageursServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<VoyageursClient> CreateClient();
|
glcr::ErrorOr<VoyageursClient> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterKeyboardListener(const KeyboardListener&, None&) = 0;
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterKeyboardListener(const KeyboardListener&) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -41,5 +35,3 @@ class VoyageursServerBase {
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@
|
||||||
#include "keyboard/keyboard_driver.h"
|
#include "keyboard/keyboard_driver.h"
|
||||||
#include "voyageurs_server.h"
|
#include "voyageurs_server.h"
|
||||||
|
|
||||||
using yellowstone::RegisterEndpointRequest;
|
|
||||||
using yellowstone::YellowstoneClient;
|
|
||||||
|
|
||||||
uint64_t main(uint64_t init_port) {
|
uint64_t main(uint64_t init_port) {
|
||||||
ParseInitPort(init_port);
|
ParseInitPort(init_port);
|
||||||
|
|
||||||
|
|
@ -28,9 +25,10 @@ uint64_t main(uint64_t init_port) {
|
||||||
|
|
||||||
RegisterEndpointRequest req;
|
RegisterEndpointRequest req;
|
||||||
req.set_endpoint_name("voyageurs");
|
req.set_endpoint_name("voyageurs");
|
||||||
ASSIGN_OR_RETURN(z_cap_t client_cap, server->CreateClientCap());
|
ASSIGN_OR_RETURN(VoyageursClient client, server->CreateClient());
|
||||||
req.set_endpoint_capability(client_cap);
|
req.set_endpoint_capability(client.Capability());
|
||||||
check(yellowstone.RegisterEndpoint(req));
|
Empty empty;
|
||||||
|
check(yellowstone.RegisterEndpoint(req, empty));
|
||||||
|
|
||||||
check(server_thread.Join());
|
check(server_thread.Join());
|
||||||
check(keyboard_thread.Join());
|
check(keyboard_thread.Join());
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ glcr::ErrorOr<glcr::UniquePtr<VoyageursServer>> VoyageursServer::Create(
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::ErrorCode VoyageursServer::HandleRegisterKeyboardListener(
|
glcr::ErrorCode VoyageursServer::HandleRegisterKeyboardListener(
|
||||||
const KeyboardListener& listener) {
|
const KeyboardListener& listener, None&) {
|
||||||
keyboard_driver_.RegisterListener(listener.port_capability());
|
keyboard_driver_.RegisterListener(listener.port_capability());
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class VoyageursServer : public VoyageursServerBase {
|
||||||
KeyboardDriver& keyboard_driver);
|
KeyboardDriver& keyboard_driver);
|
||||||
|
|
||||||
virtual glcr::ErrorCode HandleRegisterKeyboardListener(
|
virtual glcr::ErrorCode HandleRegisterKeyboardListener(
|
||||||
const KeyboardListener& listener) override;
|
const KeyboardListener& listener, None&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeyboardDriver& keyboard_driver_;
|
KeyboardDriver& keyboard_driver_;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
package yellowstone;
|
|
||||||
|
|
||||||
interface Yellowstone {
|
interface Yellowstone {
|
||||||
method RegisterEndpoint(RegisterEndpointRequest) -> ();
|
method RegisterEndpoint(RegisterEndpointRequest) -> (Empty);
|
||||||
method GetEndpoint(GetEndpointRequest) -> (Endpoint);
|
method GetEndpoint(GetEndpointRequest) -> (Endpoint);
|
||||||
method GetAhciInfo() -> (AhciInfo);
|
method GetAhciInfo(Empty) -> (AhciInfo);
|
||||||
method GetFramebufferInfo() -> (FramebufferInfo);
|
method GetFramebufferInfo(Empty) -> (FramebufferInfo);
|
||||||
method GetDenali() -> (DenaliInfo);
|
method GetDenali(Empty) -> (DenaliInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
message RegisterEndpointRequest {
|
message RegisterEndpointRequest {
|
||||||
|
|
@ -13,6 +11,10 @@ message RegisterEndpointRequest {
|
||||||
capability endpoint_capability;
|
capability endpoint_capability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Empty {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
message GetEndpointRequest {
|
message GetEndpointRequest {
|
||||||
string endpoint_name;
|
string endpoint_name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
|
|
||||||
|
glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response) {
|
||||||
YellowstoneClient::~YellowstoneClient() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request) {
|
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -30,10 +17,7 @@ glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointReques
|
||||||
buffer_.WriteAt<uint64_t>(8, 0);
|
buffer_.WriteAt<uint64_t>(8, 0);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -49,16 +33,14 @@ glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointReques
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, Endpoint& response) {
|
glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, Endpoint& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -67,10 +49,7 @@ glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request
|
||||||
buffer_.WriteAt<uint64_t>(8, 1);
|
buffer_.WriteAt<uint64_t>(8, 1);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -86,18 +65,14 @@ glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& response) {
|
||||||
glcr::ErrorCode YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -106,10 +81,7 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||||
buffer_.WriteAt<uint64_t>(8, 2);
|
buffer_.WriteAt<uint64_t>(8, 2);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
uint64_t length = 0;
|
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -125,18 +97,14 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(const Empty& request, FramebufferInfo& response) {
|
||||||
glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
|
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -145,10 +113,7 @@ glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response)
|
||||||
buffer_.WriteAt<uint64_t>(8, 3);
|
buffer_.WriteAt<uint64_t>(8, 3);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
uint64_t length = 0;
|
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -164,18 +129,14 @@ glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response)
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& response) {
|
||||||
glcr::ErrorCode YellowstoneClient::GetDenali(DenaliInfo& response) {
|
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -184,10 +145,7 @@ glcr::ErrorCode YellowstoneClient::GetDenali(DenaliInfo& response) {
|
||||||
buffer_.WriteAt<uint64_t>(8, 4);
|
buffer_.WriteAt<uint64_t>(8, 4);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
uint64_t length = 0;
|
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -203,15 +161,9 @@ glcr::ErrorCode YellowstoneClient::GetDenali(DenaliInfo& response) {
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -8,38 +8,24 @@
|
||||||
|
|
||||||
#include "yellowstone.yunq.h"
|
#include "yellowstone.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
class YellowstoneClient {
|
class YellowstoneClient {
|
||||||
public:
|
public:
|
||||||
YellowstoneClient(z_cap_t Yellowstone_cap) : endpoint_(Yellowstone_cap) {}
|
YellowstoneClient(z_cap_t Yellowstone_cap) : endpoint_(Yellowstone_cap) {}
|
||||||
YellowstoneClient(const YellowstoneClient&) = delete;
|
YellowstoneClient(const YellowstoneClient&) = delete;
|
||||||
YellowstoneClient(YellowstoneClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
YellowstoneClient(YellowstoneClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~YellowstoneClient();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response);
|
||||||
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode GetEndpoint(const GetEndpointRequest& request, Endpoint& response);
|
[[nodiscard]] glcr::ErrorCode GetEndpoint(const GetEndpointRequest& request, Endpoint& response);
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::ErrorCode GetAhciInfo(const Empty& request, AhciInfo& response);
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(const Empty& request, FramebufferInfo& response);
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode GetAhciInfo(AhciInfo& response);
|
[[nodiscard]] glcr::ErrorCode GetDenali(const Empty& request, DenaliInfo& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(FramebufferInfo& response);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode GetDenali(DenaliInfo& response);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
@ -48,6 +34,3 @@ class YellowstoneClient {
|
||||||
uint64_t kCapBufferSize = 0x10;
|
uint64_t kCapBufferSize = 0x10;
|
||||||
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "yellowstone.yunq.h"
|
#include "yellowstone.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -104,6 +101,39 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Empty::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
|
CheckHeader(bytes);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
uint32_t next_extension = header_size + 8 * 0;
|
||||||
|
const uint32_t core_size = next_extension;
|
||||||
|
|
||||||
|
// The next extension pointer is the length of the message.
|
||||||
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
|
return next_extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||||
|
uint32_t next_extension = header_size + 8 * 0;
|
||||||
|
const uint32_t core_size = next_extension;
|
||||||
|
uint64_t next_cap = 0;
|
||||||
|
|
||||||
|
// The next extension pointer is the length of the message.
|
||||||
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
|
return next_extension;
|
||||||
|
}
|
||||||
void GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
ParseFromBytesInternal(bytes, offset);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
}
|
}
|
||||||
|
|
@ -430,6 +460,3 @@ uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@
|
||||||
#include <glacier/container/vector.h>
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
class RegisterEndpointRequest {
|
class RegisterEndpointRequest {
|
||||||
public:
|
public:
|
||||||
RegisterEndpointRequest() {}
|
RegisterEndpointRequest() {}
|
||||||
|
|
@ -33,6 +29,23 @@ class RegisterEndpointRequest {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
class Empty {
|
||||||
|
public:
|
||||||
|
Empty() {}
|
||||||
|
// Delete copy and move until implemented.
|
||||||
|
Empty(const Empty&) = delete;
|
||||||
|
Empty(Empty&&) = delete;
|
||||||
|
|
||||||
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||||
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||||
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
|
};
|
||||||
class GetEndpointRequest {
|
class GetEndpointRequest {
|
||||||
public:
|
public:
|
||||||
GetEndpointRequest() {}
|
GetEndpointRequest() {}
|
||||||
|
|
@ -175,6 +188,3 @@ class DenaliInfo {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -32,18 +29,6 @@ void YellowstoneServerBaseThreadBootstrap(void* server_base) {
|
||||||
((YellowstoneServerBase*)server_base)->ServerThread();
|
((YellowstoneServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
YellowstoneServerBase::~YellowstoneServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> YellowstoneServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<YellowstoneClient> YellowstoneServerBase::CreateClient() {
|
glcr::ErrorOr<YellowstoneClient> YellowstoneServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -102,92 +87,58 @@ glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& req
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
|
|
||||||
RegisterEndpointRequest yunq_request;
|
RegisterEndpointRequest yunq_request;
|
||||||
|
Empty yunq_response;
|
||||||
|
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
RET_ERR(HandleRegisterEndpoint(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
|
|
||||||
RET_ERR(HandleRegisterEndpoint(yunq_request));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = 0;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
||||||
|
|
||||||
GetEndpointRequest yunq_request;
|
GetEndpointRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Endpoint yunq_response;
|
Endpoint yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(HandleGetEndpoint(yunq_request, yunq_response));
|
RET_ERR(HandleGetEndpoint(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
|
Empty yunq_request;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AhciInfo yunq_response;
|
AhciInfo yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
RET_ERR(HandleGetAhciInfo(yunq_request, yunq_response));
|
||||||
RET_ERR(HandleGetAhciInfo(yunq_response));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
|
Empty yunq_request;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FramebufferInfo yunq_response;
|
FramebufferInfo yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
RET_ERR(HandleGetFramebufferInfo(yunq_request, yunq_response));
|
||||||
RET_ERR(HandleGetFramebufferInfo(yunq_response));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
|
Empty yunq_request;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DenaliInfo yunq_response;
|
DenaliInfo yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
RET_ERR(HandleGetDenali(yunq_request, yunq_response));
|
||||||
RET_ERR(HandleGetDenali(yunq_response));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -196,7 +147,3 @@ glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& req
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -9,43 +9,27 @@
|
||||||
#include "yellowstone.yunq.client.h"
|
#include "yellowstone.yunq.client.h"
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class YellowstoneServerBase {
|
class YellowstoneServerBase {
|
||||||
public:
|
public:
|
||||||
YellowstoneServerBase(z_cap_t Yellowstone_cap) : endpoint_(Yellowstone_cap) {}
|
YellowstoneServerBase(z_cap_t Yellowstone_cap) : endpoint_(Yellowstone_cap) {}
|
||||||
YellowstoneServerBase(const YellowstoneServerBase&) = delete;
|
YellowstoneServerBase(const YellowstoneServerBase&) = delete;
|
||||||
YellowstoneServerBase(YellowstoneServerBase&&) = delete;
|
YellowstoneServerBase(YellowstoneServerBase&&) = delete;
|
||||||
virtual ~YellowstoneServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<YellowstoneClient> CreateClient();
|
glcr::ErrorOr<YellowstoneClient> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&, Empty&) = 0;
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(const Empty&, AhciInfo&) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetFramebufferInfo(const Empty&, FramebufferInfo&) = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(AhciInfo&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetDenali(const Empty&, DenaliInfo&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetFramebufferInfo(FramebufferInfo&) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetDenali(DenaliInfo&) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -59,7 +43,3 @@ class YellowstoneServerBase {
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,16 @@ uint64_t main(uint64_t port_cap) {
|
||||||
check(ParseInitPort(port_cap));
|
check(ParseInitPort(port_cap));
|
||||||
dbgln("Yellowstone Initializing.");
|
dbgln("Yellowstone Initializing.");
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(auto server, yellowstone::YellowstoneServer::Create());
|
ASSIGN_OR_RETURN(auto server, YellowstoneServer::Create());
|
||||||
Thread server_thread = server->RunServer();
|
Thread server_thread = server->RunServer();
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(uint64_t client_cap, server->CreateClientCap());
|
ASSIGN_OR_RETURN(YellowstoneClient client1, server->CreateClient());
|
||||||
check(SpawnProcess(gBootDenaliVmmoCap, client_cap));
|
check(SpawnProcess(gBootDenaliVmmoCap, client1.Capability()));
|
||||||
|
|
||||||
server->WaitDenaliRegistered();
|
server->WaitDenaliRegistered();
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(client_cap, server->CreateClientCap());
|
ASSIGN_OR_RETURN(YellowstoneClient client2, server->CreateClient());
|
||||||
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client_cap));
|
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client2.Capability()));
|
||||||
|
|
||||||
server->WaitVictoriaFallsRegistered();
|
server->WaitVictoriaFallsRegistered();
|
||||||
|
|
||||||
|
|
@ -47,9 +47,9 @@ uint64_t main(uint64_t port_cap) {
|
||||||
mmth::File binary =
|
mmth::File binary =
|
||||||
mmth::File::Open(glcr::StrFormat("/bin/{}", files[i]));
|
mmth::File::Open(glcr::StrFormat("/bin/{}", files[i]));
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(client_cap, server->CreateClientCap());
|
ASSIGN_OR_RETURN(YellowstoneClient client3, server->CreateClient());
|
||||||
check(mmth::SpawnProcessFromElfRegion((uint64_t)binary.raw_ptr(),
|
check(mmth::SpawnProcessFromElfRegion((uint64_t)binary.raw_ptr(),
|
||||||
client_cap));
|
client3.Capability()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
#include "hw/gpt.h"
|
#include "hw/gpt.h"
|
||||||
#include "hw/pcie.h"
|
#include "hw/pcie.h"
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct PartitionInfo {
|
struct PartitionInfo {
|
||||||
|
|
@ -42,14 +41,15 @@ glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> YellowstoneServer::Create() {
|
||||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
||||||
: YellowstoneServerBase(endpoint_cap) {}
|
: YellowstoneServerBase(endpoint_cap) {}
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(AhciInfo& info) {
|
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&,
|
||||||
|
AhciInfo& info) {
|
||||||
info.set_ahci_region(pci_reader_.GetAhciVmmo());
|
info.set_ahci_region(pci_reader_.GetAhciVmmo());
|
||||||
info.set_region_length(kPcieConfigurationSize);
|
info.set_region_length(kPcieConfigurationSize);
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneServer::HandleGetFramebufferInfo(
|
glcr::ErrorCode YellowstoneServer::HandleGetFramebufferInfo(
|
||||||
FramebufferInfo& info) {
|
const Empty&, FramebufferInfo& info) {
|
||||||
// FIXME: Don't do this for each request.
|
// FIXME: Don't do this for each request.
|
||||||
mmth::OwnedMemoryRegion region =
|
mmth::OwnedMemoryRegion region =
|
||||||
mmth::OwnedMemoryRegion::FromCapability(gBootFramebufferVmmoCap);
|
mmth::OwnedMemoryRegion::FromCapability(gBootFramebufferVmmoCap);
|
||||||
|
|
@ -71,7 +71,8 @@ glcr::ErrorCode YellowstoneServer::HandleGetFramebufferInfo(
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneServer::HandleGetDenali(DenaliInfo& info) {
|
glcr::ErrorCode YellowstoneServer::HandleGetDenali(const Empty&,
|
||||||
|
DenaliInfo& info) {
|
||||||
if (!endpoint_map_.Contains("denali")) {
|
if (!endpoint_map_.Contains("denali")) {
|
||||||
return glcr::NOT_FOUND;
|
return glcr::NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
@ -84,13 +85,11 @@ glcr::ErrorCode YellowstoneServer::HandleGetDenali(DenaliInfo& info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
||||||
const RegisterEndpointRequest& req) {
|
const RegisterEndpointRequest& req, Empty&) {
|
||||||
dbgln("Registering {}.", req.endpoint_name().view());
|
dbgln("Registering {}.", req.endpoint_name().view());
|
||||||
check(endpoint_map_.Insert(req.endpoint_name(), req.endpoint_capability()));
|
check(endpoint_map_.Insert(req.endpoint_name(), req.endpoint_capability()));
|
||||||
if (req.endpoint_name() == "denali") {
|
if (req.endpoint_name() == "denali") {
|
||||||
z_cap_t dup_cap;
|
auto part_info_or = HandleDenaliRegistration(req.endpoint_capability());
|
||||||
check(ZCapDuplicate(req.endpoint_capability(), kZionPerm_All, &dup_cap));
|
|
||||||
auto part_info_or = HandleDenaliRegistration(dup_cap);
|
|
||||||
if (!part_info_or.ok()) {
|
if (!part_info_or.ok()) {
|
||||||
check(part_info_or.error());
|
check(part_info_or.error());
|
||||||
}
|
}
|
||||||
|
|
@ -126,5 +125,3 @@ void YellowstoneServer::WaitDenaliRegistered() { has_denali_semaphore_.Wait(); }
|
||||||
void YellowstoneServer::WaitVictoriaFallsRegistered() {
|
void YellowstoneServer::WaitVictoriaFallsRegistered() {
|
||||||
has_victoriafalls_semaphore_.Wait();
|
has_victoriafalls_semaphore_.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,16 @@
|
||||||
#include "hw/pcie.h"
|
#include "hw/pcie.h"
|
||||||
#include "lib/yellowstone/yellowstone.yunq.server.h"
|
#include "lib/yellowstone/yellowstone.yunq.server.h"
|
||||||
|
|
||||||
namespace yellowstone {
|
|
||||||
|
|
||||||
class YellowstoneServer : public YellowstoneServerBase {
|
class YellowstoneServer : public YellowstoneServerBase {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> Create();
|
static glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> Create();
|
||||||
|
|
||||||
glcr::ErrorCode HandleGetAhciInfo(AhciInfo&) override;
|
glcr::ErrorCode HandleGetAhciInfo(const Empty&, AhciInfo&) override;
|
||||||
glcr::ErrorCode HandleGetFramebufferInfo(FramebufferInfo&) override;
|
glcr::ErrorCode HandleGetFramebufferInfo(const Empty&,
|
||||||
glcr::ErrorCode HandleGetDenali(DenaliInfo&) override;
|
FramebufferInfo&) override;
|
||||||
glcr::ErrorCode HandleRegisterEndpoint(
|
glcr::ErrorCode HandleGetDenali(const Empty&, DenaliInfo&) override;
|
||||||
const RegisterEndpointRequest&) override;
|
glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&,
|
||||||
|
Empty&) override;
|
||||||
glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&,
|
glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&,
|
||||||
Endpoint&) override;
|
Endpoint&) override;
|
||||||
|
|
||||||
|
|
@ -41,5 +40,3 @@ class YellowstoneServer : public YellowstoneServerBase {
|
||||||
|
|
||||||
YellowstoneServer(z_cap_t endpoint_cap);
|
YellowstoneServer(z_cap_t endpoint_cap);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace yellowstone
|
|
||||||
|
|
|
||||||
|
|
@ -3,29 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
{% for interface in interfaces %}
|
{% for interface in interfaces %}
|
||||||
|
|
||||||
{{interface.name}}Client::~{{interface.name}}Client() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
|
|
||||||
{% if method.request == None %}
|
|
||||||
glcr::ErrorCode {{interface.name}}Client::{{method.name}}({{method.response}}& response) {
|
|
||||||
{% elif method.response == None %}
|
|
||||||
glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request}}& request) {
|
|
||||||
{% else %}
|
|
||||||
glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request}}& request, {{method.response}}& response) {
|
glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request}}& request, {{method.response}}& response) {
|
||||||
{% endif %}
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -34,12 +17,7 @@ glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request
|
||||||
buffer_.WriteAt<uint64_t>(8, {{loop.index0}});
|
buffer_.WriteAt<uint64_t>(8, {{loop.index0}});
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
{% if method.request == None %}
|
|
||||||
uint64_t length = 0;
|
|
||||||
{% else %}
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -55,16 +33,10 @@ glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
{% if method.response != None %}
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
|
|
@ -8,27 +8,17 @@
|
||||||
|
|
||||||
#include "{{file}}.h"
|
#include "{{file}}.h"
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
{% for interface in interfaces -%}
|
{% for interface in interfaces -%}
|
||||||
class {{interface.name}}Client {
|
class {{interface.name}}Client {
|
||||||
public:
|
public:
|
||||||
{{interface.name}}Client(z_cap_t {{interface.name}}_cap) : endpoint_({{interface.name}}_cap) {}
|
{{interface.name}}Client(z_cap_t {{interface.name}}_cap) : endpoint_({{interface.name}}_cap) {}
|
||||||
{{interface.name}}Client(const {{interface.name}}Client&) = delete;
|
{{interface.name}}Client(const {{interface.name}}Client&) = delete;
|
||||||
{{interface.name}}Client({{interface.name}}Client&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
{{interface.name}}Client({{interface.name}}Client&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~{{interface.name}}Client();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
{% if method.request == None %}
|
|
||||||
[[nodiscard]] glcr::ErrorCode {{method.name}}({{method.response}}& response);
|
|
||||||
{% elif method.response == None %}
|
|
||||||
[[nodiscard]] glcr::ErrorCode {{method.name}}(const {{method.request}}& request);
|
|
||||||
{% else %}
|
|
||||||
[[nodiscard]] glcr::ErrorCode {{method.name}}(const {{method.request}}& request, {{method.response}}& response);
|
[[nodiscard]] glcr::ErrorCode {{method.name}}(const {{method.request}}& request, {{method.response}}& response);
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
@ -40,6 +30,3 @@ class {{interface.name}}Client {
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
package srv.file;
|
|
||||||
|
|
||||||
interface VFS {
|
interface VFS {
|
||||||
method open (OpenFileRequest) -> (File);
|
method open (OpenFileRequest) -> (File);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,12 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
#include <mammoth/util/debug.h>
|
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VFSClient::~VFSClient() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response) {
|
glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response) {
|
||||||
|
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
|
||||||
|
|
@ -30,10 +17,7 @@ glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response)
|
||||||
buffer_.WriteAt<uint64_t>(8, 0);
|
buffer_.WriteAt<uint64_t>(8, 0);
|
||||||
|
|
||||||
cap_buffer_.Reset();
|
cap_buffer_.Reset();
|
||||||
|
|
||||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||||
|
|
||||||
z_cap_t reply_port_cap;
|
z_cap_t reply_port_cap;
|
||||||
|
|
@ -49,15 +33,9 @@ glcr::ErrorCode VFSClient::open(const OpenFileRequest& request, File& response)
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,17 @@
|
||||||
|
|
||||||
#include "example.yunq.h"
|
#include "example.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
class VFSClient {
|
class VFSClient {
|
||||||
public:
|
public:
|
||||||
VFSClient(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
VFSClient(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
||||||
VFSClient(const VFSClient&) = delete;
|
VFSClient(const VFSClient&) = delete;
|
||||||
VFSClient(VFSClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
VFSClient(VFSClient&& other) : endpoint_(other.endpoint_) {other.endpoint_ = 0;};
|
||||||
~VFSClient();
|
|
||||||
|
|
||||||
z_cap_t Capability() { return endpoint_; }
|
z_cap_t Capability() { return endpoint_; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::ErrorCode open(const OpenFileRequest& request, File& response);
|
[[nodiscard]] glcr::ErrorCode open(const OpenFileRequest& request, File& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
uint64_t kBufferSize = 0x1000;
|
uint64_t kBufferSize = 0x1000;
|
||||||
|
|
@ -32,6 +26,3 @@ class VFSClient {
|
||||||
uint64_t kCapBufferSize = 0x10;
|
uint64_t kCapBufferSize = 0x10;
|
||||||
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
glcr::CapBuffer cap_buffer_{kCapBufferSize};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "example.yunq.h"
|
#include "example.yunq.h"
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -47,9 +44,9 @@ void OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint
|
||||||
// Parse options.
|
// Parse options.
|
||||||
auto options_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
auto options_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
||||||
|
|
||||||
options_.Resize(options_pointer.length / sizeof(uint64_t));
|
options_.Resize(options_pointer.length);
|
||||||
for (uint64_t i = offset + options_pointer.offset;
|
for (uint64_t i = offset + options_pointer.offset;
|
||||||
i < offset + options_pointer.offset + options_pointer.length;
|
i < offset + options_pointer.offset + (sizeof(uint64_t) * options_pointer.length);
|
||||||
i += sizeof(uint64_t)) {
|
i += sizeof(uint64_t)) {
|
||||||
options_.PushBack(bytes.At<uint64_t>(i));
|
options_.PushBack(bytes.At<uint64_t>(i));
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +202,3 @@ uint64_t File::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,6 @@
|
||||||
#include <glacier/container/vector.h>
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
class OpenFileRequest {
|
class OpenFileRequest {
|
||||||
public:
|
public:
|
||||||
OpenFileRequest() {}
|
OpenFileRequest() {}
|
||||||
|
|
@ -21,7 +17,7 @@ class OpenFileRequest {
|
||||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||||
const glcr::String& path() const { return path_; }
|
glcr::String path() const { return path_; }
|
||||||
void set_path(const glcr::String& value) { path_ = value; }
|
void set_path(const glcr::String& value) { path_ = value; }
|
||||||
const glcr::Vector<uint64_t>& options() const { return options_; }
|
const glcr::Vector<uint64_t>& options() const { return options_; }
|
||||||
void add_options(const uint64_t& value) { options_.PushBack(value); }
|
void add_options(const uint64_t& value) { options_.PushBack(value); }
|
||||||
|
|
@ -44,11 +40,11 @@ class File {
|
||||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||||
const glcr::String& path() const { return path_; }
|
glcr::String path() const { return path_; }
|
||||||
void set_path(const glcr::String& value) { path_ = value; }
|
void set_path(const glcr::String& value) { path_ = value; }
|
||||||
const uint64_t& attrs() const { return attrs_; }
|
uint64_t attrs() const { return attrs_; }
|
||||||
void set_attrs(const uint64_t& value) { attrs_ = value; }
|
void set_attrs(const uint64_t& value) { attrs_ = value; }
|
||||||
const z_cap_t& mem_cap() const { return mem_cap_; }
|
z_cap_t mem_cap() const { return mem_cap_; }
|
||||||
void set_mem_cap(const z_cap_t& value) { mem_cap_ = value; }
|
void set_mem_cap(const z_cap_t& value) { mem_cap_ = value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -59,6 +55,3 @@ class File {
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "example.yunq.server.h"
|
#include "example.yunq.server.h"
|
||||||
|
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -32,18 +29,6 @@ void VFSServerBaseThreadBootstrap(void* server_base) {
|
||||||
((VFSServerBase*)server_base)->ServerThread();
|
((VFSServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
VFSServerBase::~VFSServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> VFSServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<VFSClient> VFSServerBase::CreateClient() {
|
glcr::ErrorOr<VFSClient> VFSServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -102,23 +87,14 @@ glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
case 0: {
|
case 0: {
|
||||||
|
|
||||||
|
|
||||||
OpenFileRequest yunq_request;
|
OpenFileRequest yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File yunq_response;
|
File yunq_response;
|
||||||
|
|
||||||
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
RET_ERR(Handleopen(yunq_request, yunq_response));
|
RET_ERR(Handleopen(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
@ -127,7 +103,3 @@ glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
}
|
}
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -2,36 +2,28 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
#include "example.yunq.h"
|
#include "example.yunq.h"
|
||||||
#include "example.yunq.client.h"
|
#include "example.yunq.client.h"
|
||||||
|
|
||||||
|
|
||||||
namespace srv::file {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class VFSServerBase {
|
class VFSServerBase {
|
||||||
public:
|
public:
|
||||||
VFSServerBase(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
VFSServerBase(z_cap_t VFS_cap) : endpoint_(VFS_cap) {}
|
||||||
VFSServerBase(const VFSServerBase&) = delete;
|
VFSServerBase(const VFSServerBase&) = delete;
|
||||||
VFSServerBase(VFSServerBase&&) = delete;
|
VFSServerBase(VFSServerBase&&) = delete;
|
||||||
virtual ~VFSServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<VFSClient> CreateClient();
|
glcr::ErrorOr<VFSClient> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode Handleopen(const OpenFileRequest&, File&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode Handleopen(const OpenFileRequest&, File&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
||||||
|
|
@ -43,7 +35,3 @@ class VFSServerBase {
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namepace srv::file
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "{{file}}.h"
|
#include "{{file}}.h"
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
const uint64_t header_size = 24; // 4x uint32, 1x uint64
|
||||||
|
|
@ -191,7 +188,3 @@ uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- for message in messages %}
|
{%- for message in messages %}
|
||||||
class {{message.name}} {
|
class {{message.name}} {
|
||||||
|
|
@ -47,7 +44,3 @@ class {{message.name}} {
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ class LexemeType(Enum):
|
||||||
RIGHT_PAREN = 6
|
RIGHT_PAREN = 6
|
||||||
ARROW = 7
|
ARROW = 7
|
||||||
SEMICOLON = 8
|
SEMICOLON = 8
|
||||||
DOT = 9
|
|
||||||
|
|
||||||
|
|
||||||
class Lexeme():
|
class Lexeme():
|
||||||
|
|
@ -56,8 +55,6 @@ def lexer(program: str):
|
||||||
tokens.append(Lexeme(LexemeType.RIGHT_PAREN))
|
tokens.append(Lexeme(LexemeType.RIGHT_PAREN))
|
||||||
elif curr == ';':
|
elif curr == ';':
|
||||||
tokens.append(Lexeme(LexemeType.SEMICOLON))
|
tokens.append(Lexeme(LexemeType.SEMICOLON))
|
||||||
elif curr == '.':
|
|
||||||
tokens.append(Lexeme(LexemeType.DOT))
|
|
||||||
elif curr == '-':
|
elif curr == '-':
|
||||||
current += 1
|
current += 1
|
||||||
if program[current] == '>':
|
if program[current] == '>':
|
||||||
|
|
@ -80,12 +77,6 @@ def lexer(program: str):
|
||||||
|
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
class Package():
|
|
||||||
def __init__(self, names: list[str]):
|
|
||||||
self.names = names
|
|
||||||
|
|
||||||
def cpp_namespace(self):
|
|
||||||
return "::".join(self.names)
|
|
||||||
|
|
||||||
class Method():
|
class Method():
|
||||||
def __init__(self, name: str, request: str, response: str):
|
def __init__(self, name: str, request: str, response: str):
|
||||||
|
|
@ -183,25 +174,11 @@ class Parser():
|
||||||
token = self.consume()
|
token = self.consume()
|
||||||
if token.type != LexemeType.NAME:
|
if token.type != LexemeType.NAME:
|
||||||
sys.exit("Unexpected token: %s", token)
|
sys.exit("Unexpected token: %s", token)
|
||||||
if token.value == "package":
|
|
||||||
# TODO: Enforce that package decl comes before all messages and interface.
|
|
||||||
return self.package()
|
|
||||||
if token.value == "message":
|
if token.value == "message":
|
||||||
return self.message()
|
return self.message()
|
||||||
elif token.value == "interface":
|
elif token.value == "interface":
|
||||||
return self.interface()
|
return self.interface()
|
||||||
sys.exit("Unexpected identifier '%s', expected package, message, interface" % token.value)
|
sys.exit("Unexpected identifier '%s', expected message or interface" % token.value)
|
||||||
|
|
||||||
def package(self):
|
|
||||||
names = [self.consume_identifier()]
|
|
||||||
|
|
||||||
while self.peektype() == LexemeType.DOT:
|
|
||||||
self.consume_check(LexemeType.DOT)
|
|
||||||
names += [self.consume_identifier()]
|
|
||||||
|
|
||||||
self.consume_check(LexemeType.SEMICOLON)
|
|
||||||
|
|
||||||
return Package(names)
|
|
||||||
|
|
||||||
def interface(self):
|
def interface(self):
|
||||||
# "interface" consumed by decl.
|
# "interface" consumed by decl.
|
||||||
|
|
@ -234,19 +211,12 @@ class Parser():
|
||||||
|
|
||||||
self.consume_check(LexemeType.LEFT_PAREN)
|
self.consume_check(LexemeType.LEFT_PAREN)
|
||||||
|
|
||||||
request = None
|
|
||||||
# FIXME: Fix error handling here (and for response). We want to show
|
|
||||||
# "expected rparen or identifier" if type is wrong rather than just
|
|
||||||
# "expected rparen".
|
|
||||||
if self.peektype() == LexemeType.NAME:
|
|
||||||
request = self.consume_identifier()
|
request = self.consume_identifier()
|
||||||
|
|
||||||
self.consume_check(LexemeType.RIGHT_PAREN)
|
self.consume_check(LexemeType.RIGHT_PAREN)
|
||||||
self.consume_check(LexemeType.ARROW)
|
self.consume_check(LexemeType.ARROW)
|
||||||
self.consume_check(LexemeType.LEFT_PAREN)
|
self.consume_check(LexemeType.LEFT_PAREN)
|
||||||
|
|
||||||
response = None
|
|
||||||
if self.peektype() == LexemeType.NAME:
|
|
||||||
response = self.consume_identifier()
|
response = self.consume_identifier()
|
||||||
|
|
||||||
self.consume_check(LexemeType.RIGHT_PAREN)
|
self.consume_check(LexemeType.RIGHT_PAREN)
|
||||||
|
|
@ -296,19 +266,13 @@ class Parser():
|
||||||
return Field(field_type, name, repeated)
|
return Field(field_type, name, repeated)
|
||||||
|
|
||||||
def type_check(decls: list[Decl]):
|
def type_check(decls: list[Decl]):
|
||||||
if sum(1 for decl in decls if type(decl) is Package) > 1:
|
|
||||||
sys.exit("Cannot have more than one package declaration")
|
|
||||||
for decl in decls:
|
for decl in decls:
|
||||||
if type(decl) is Interface:
|
if type(decl) is Interface:
|
||||||
for method in decl.methods:
|
for method in decl.methods:
|
||||||
if method.request is None and method.response is None:
|
|
||||||
sys.exit("Method '%s.%s' cannot have empty request and response" % (decl.name, method.name))
|
|
||||||
if method.request is not None:
|
|
||||||
if method.request not in name_dict.keys():
|
if method.request not in name_dict.keys():
|
||||||
sys.exit("Request type '%s' for '%s.%s' does not exist" % (method.request, decl.name, method.name))
|
sys.exit("Request type '%s' for '%s.%s' does not exist" % (method.request, decl.name, method.name))
|
||||||
if type(name_dict[method.request]) is not Message:
|
if type(name_dict[method.request]) is not Message:
|
||||||
sys.exit("Request type '%s' for '%s.%s' should be a message" % (method.request, decl.name, method.name))
|
sys.exit("Request type '%s' for '%s.%s' should be a message" % (method.request, decl.name, method.name))
|
||||||
if method.response is not None:
|
|
||||||
if method.response not in name_dict.keys():
|
if method.response not in name_dict.keys():
|
||||||
sys.exit("Response type '%s' for '%s.%s' does not exist" % (method.response, decl.name, method.name))
|
sys.exit("Response type '%s' for '%s.%s' does not exist" % (method.response, decl.name, method.name))
|
||||||
if type(name_dict[method.response]) is not Message:
|
if type(name_dict[method.response]) is not Message:
|
||||||
|
|
@ -316,9 +280,7 @@ def type_check(decls: list[Decl]):
|
||||||
|
|
||||||
def print_ast(decls: list[Decl]):
|
def print_ast(decls: list[Decl]):
|
||||||
for decl in decls:
|
for decl in decls:
|
||||||
if type(decl) is Package:
|
if type(decl) is Interface:
|
||||||
print("%s (Package)" % decl.cpp_namespace())
|
|
||||||
elif type(decl) is Interface:
|
|
||||||
print("%s (Interface)" % decl.name)
|
print("%s (Interface)" % decl.name)
|
||||||
for method in decl.methods:
|
for method in decl.methods:
|
||||||
print("\t%s (%s -> %s)" % (method.name, method.request, method.response))
|
print("\t%s (%s -> %s)" % (method.name, method.request, method.response))
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,6 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||||
|
|
@ -32,18 +29,6 @@ void {{interface.name}}ServerBaseThreadBootstrap(void* server_base) {
|
||||||
(({{interface.name}}ServerBase*)server_base)->ServerThread();
|
(({{interface.name}}ServerBase*)server_base)->ServerThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
{{interface.name}}ServerBase::~{{interface.name}}ServerBase() {
|
|
||||||
if (endpoint_ != 0) {
|
|
||||||
check(ZCapRelease(endpoint_));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> {{interface.name}}ServerBase::CreateClientCap() {
|
|
||||||
uint64_t client_cap;
|
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
|
||||||
return client_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::ErrorOr<{{interface.name}}Client> {{interface.name}}ServerBase::CreateClient() {
|
glcr::ErrorOr<{{interface.name}}Client> {{interface.name}}ServerBase::CreateClient() {
|
||||||
uint64_t client_cap;
|
uint64_t client_cap;
|
||||||
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
RET_ERR(ZCapDuplicate(endpoint_, ~(kZionPerm_Read), &client_cap));
|
||||||
|
|
@ -103,29 +88,14 @@ glcr::ErrorCode {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuff
|
||||||
switch(method_select) {
|
switch(method_select) {
|
||||||
{%- for method in interface.methods %}
|
{%- for method in interface.methods %}
|
||||||
case {{loop.index0}}: {
|
case {{loop.index0}}: {
|
||||||
|
|
||||||
{% if method.request != None %}
|
|
||||||
{{method.request}} yunq_request;
|
{{method.request}} yunq_request;
|
||||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if method.response != None %}
|
|
||||||
{{method.response}} yunq_response;
|
{{method.response}} yunq_response;
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if method.request == None %}
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
RET_ERR(Handle{{method.name}}(yunq_response));
|
|
||||||
{% elif method.response == None %}
|
|
||||||
RET_ERR(Handle{{method.name}}(yunq_request));
|
|
||||||
{% else %}
|
|
||||||
RET_ERR(Handle{{method.name}}(yunq_request, yunq_response));
|
RET_ERR(Handle{{method.name}}(yunq_request, yunq_response));
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if method.response != None %}
|
|
||||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
{% else %}
|
|
||||||
resp_length = 0;
|
|
||||||
{% endif %}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
@ -136,7 +106,3 @@ glcr::ErrorCode {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuff
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,6 @@
|
||||||
#include "{{file}}.h"
|
#include "{{file}}.h"
|
||||||
#include "{{file}}.client.h"
|
#include "{{file}}.client.h"
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
namespace {{package.cpp_namespace()}} {
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% for interface in interfaces %}
|
{% for interface in interfaces %}
|
||||||
|
|
||||||
class {{interface.name}}ServerBase {
|
class {{interface.name}}ServerBase {
|
||||||
|
|
@ -19,21 +15,13 @@ class {{interface.name}}ServerBase {
|
||||||
{{interface.name}}ServerBase(z_cap_t {{interface.name}}_cap) : endpoint_({{interface.name}}_cap) {}
|
{{interface.name}}ServerBase(z_cap_t {{interface.name}}_cap) : endpoint_({{interface.name}}_cap) {}
|
||||||
{{interface.name}}ServerBase(const {{interface.name}}ServerBase&) = delete;
|
{{interface.name}}ServerBase(const {{interface.name}}ServerBase&) = delete;
|
||||||
{{interface.name}}ServerBase({{interface.name}}ServerBase&&) = delete;
|
{{interface.name}}ServerBase({{interface.name}}ServerBase&&) = delete;
|
||||||
virtual ~{{interface.name}}ServerBase();
|
|
||||||
|
|
||||||
glcr::ErrorOr<z_cap_t> CreateClientCap();
|
|
||||||
glcr::ErrorOr<{{interface.name}}Client> CreateClient();
|
glcr::ErrorOr<{{interface.name}}Client> CreateClient();
|
||||||
|
|
||||||
[[nodiscard]] Thread RunServer();
|
[[nodiscard]] Thread RunServer();
|
||||||
|
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
{% if method.request == None %}
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}({{method.response}}&) = 0;
|
|
||||||
{% elif method.response == None %}
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&) = 0;
|
|
||||||
{% else %}
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&, {{method.response}}&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&, {{method.response}}&) = 0;
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -48,7 +36,3 @@ class {{interface.name}}ServerBase {
|
||||||
};
|
};
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if package != None %}
|
|
||||||
} // namepace {{package.cpp_namespace()}}
|
|
||||||
{% endif %}
|
|
||||||
|
|
|
||||||
18
yunq/yunq.py
18
yunq/yunq.py
|
|
@ -21,48 +21,42 @@ def main():
|
||||||
|
|
||||||
parser = Parser(lexemes)
|
parser = Parser(lexemes)
|
||||||
ast = parser.parse()
|
ast = parser.parse()
|
||||||
print_ast(ast)
|
|
||||||
type_check(ast)
|
type_check(ast)
|
||||||
|
|
||||||
messages = [m for m in ast if type(m) is Message]
|
messages = [m for m in ast if type(m) is Message]
|
||||||
interfaces = [i for i in ast if type(i) is Interface]
|
interfaces = [i for i in ast if type(i) is Interface]
|
||||||
# We know there is only one package decl from the type_check.
|
|
||||||
packages = [p for p in ast if type(p) is Package]
|
|
||||||
package = None
|
|
||||||
if len(packages) == 1:
|
|
||||||
package = packages[0]
|
|
||||||
|
|
||||||
jinja_env = Environment(loader=FileSystemLoader(pathlib.Path(__file__).parent.resolve()))
|
jinja_env = Environment(loader=FileSystemLoader(pathlib.Path(__file__).parent.resolve()))
|
||||||
|
|
||||||
message_header_tmpl = jinja_env.get_template("message.h.jinja")
|
message_header_tmpl = jinja_env.get_template("message.h.jinja")
|
||||||
with open(filename + '.h', mode='w') as f:
|
with open(filename + '.h', mode='w') as f:
|
||||||
message_header = message_header_tmpl.render(messages=messages, package=package)
|
message_header = message_header_tmpl.render(messages=messages)
|
||||||
f.write(message_header)
|
f.write(message_header)
|
||||||
|
|
||||||
message_impl_tmpl = jinja_env.get_template("message.cpp.jinja")
|
message_impl_tmpl = jinja_env.get_template("message.cpp.jinja")
|
||||||
message_impl_tmpl.globals['Type'] = Type
|
message_impl_tmpl.globals['Type'] = Type
|
||||||
with open(filename + '.cpp', mode='w') as f:
|
with open(filename + '.cpp', mode='w') as f:
|
||||||
message_impl = message_impl_tmpl.render(file=filebase, messages=messages, package=package)
|
message_impl = message_impl_tmpl.render(file=filebase, messages=messages)
|
||||||
f.write(message_impl)
|
f.write(message_impl)
|
||||||
|
|
||||||
client_header_tmpl = jinja_env.get_template("client.h.jinja")
|
client_header_tmpl = jinja_env.get_template("client.h.jinja")
|
||||||
with open(filename + '.client.h', mode='w') as f:
|
with open(filename + '.client.h', mode='w') as f:
|
||||||
client_header = client_header_tmpl.render(file=filebase, interfaces=interfaces, package=package)
|
client_header = client_header_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(client_header)
|
f.write(client_header)
|
||||||
|
|
||||||
client_impl_tmpl = jinja_env.get_template("client.cpp.jinja")
|
client_impl_tmpl = jinja_env.get_template("client.cpp.jinja")
|
||||||
with open(filename + '.client.cpp', mode='w') as f:
|
with open(filename + '.client.cpp', mode='w') as f:
|
||||||
client_impl = client_impl_tmpl.render(file=filebase, interfaces=interfaces, package=package)
|
client_impl = client_impl_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(client_impl)
|
f.write(client_impl)
|
||||||
|
|
||||||
server_header_tmpl = jinja_env.get_template("server.h.jinja")
|
server_header_tmpl = jinja_env.get_template("server.h.jinja")
|
||||||
with open(filename + '.server.h', mode='w') as f:
|
with open(filename + '.server.h', mode='w') as f:
|
||||||
server_header = server_header_tmpl.render(file=filebase, interfaces=interfaces, package=package)
|
server_header = server_header_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(server_header)
|
f.write(server_header)
|
||||||
|
|
||||||
server_impl_tmpl = jinja_env.get_template("server.cpp.jinja")
|
server_impl_tmpl = jinja_env.get_template("server.cpp.jinja")
|
||||||
with open(filename + '.server.cpp', mode='w') as f:
|
with open(filename + '.server.cpp', mode='w') as f:
|
||||||
server_impl = server_impl_tmpl.render(file=filebase, interfaces=interfaces, package=package)
|
server_impl = server_impl_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(server_impl)
|
f.write(server_impl)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ target_link_libraries(zion
|
||||||
# -mno-red-zone -- Don't put data below the stack pointer (clobbered by interrupts).
|
# -mno-red-zone -- Don't put data below the stack pointer (clobbered by interrupts).
|
||||||
# -mcmodel=kernel -- Assume the kernel code is running in the higher half.
|
# -mcmodel=kernel -- Assume the kernel code is running in the higher half.
|
||||||
# -mgeneral-regs-only -- Prevent GCC from using a whole host of nonsense registers (that we have to enable).
|
# -mgeneral-regs-only -- Prevent GCC from using a whole host of nonsense registers (that we have to enable).
|
||||||
set(_Z_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -c -ffreestanding -fno-rtti -fno-exceptions -fno-use-cxa-atexit -nostdlib -mabi=sysv -mno-red-zone -mcmodel=kernel -mgeneral-regs-only -Wall -Werror")
|
set(_Z_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -c -ffreestanding -fno-rtti -fno-exceptions -fno-use-cxa-atexit -nostdlib -mabi=sysv -mno-red-zone -mcmodel=kernel -mgeneral-regs-only")
|
||||||
|
|
||||||
set(_Z_LINK_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")
|
set(_Z_LINK_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/linker.ld")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ bool checksum(uint8_t* addr, uint8_t num_bytes) {
|
||||||
return check_cnt == 0;
|
return check_cnt == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if K_ACPI_DEBUG
|
|
||||||
void dbgsz(const char* c, uint8_t cnt) {
|
void dbgsz(const char* c, uint8_t cnt) {
|
||||||
char cl[cnt + 1];
|
char cl[cnt + 1];
|
||||||
|
|
||||||
|
|
@ -106,7 +105,6 @@ void dbgsz(const char* c, uint8_t cnt) {
|
||||||
cl[cnt] = '\0';
|
cl[cnt] = '\0';
|
||||||
dbgln(cl);
|
dbgln(cl);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t* SdtDataStart(SdtHeader* sdt) {
|
uint8_t* SdtDataStart(SdtHeader* sdt) {
|
||||||
return reinterpret_cast<uint8_t*>(sdt) + sizeof(SdtHeader);
|
return reinterpret_cast<uint8_t*>(sdt) + sizeof(SdtHeader);
|
||||||
|
|
@ -159,8 +157,8 @@ void ParseMadt(SdtHeader* rsdt) {
|
||||||
while (reinterpret_cast<uint64_t>(entry) < max_addr) {
|
while (reinterpret_cast<uint64_t>(entry) < max_addr) {
|
||||||
switch (entry->type) {
|
switch (entry->type) {
|
||||||
case 0: {
|
case 0: {
|
||||||
#if K_ACPI_DEBUG
|
|
||||||
MadtLocalApic* local = reinterpret_cast<MadtLocalApic*>(entry);
|
MadtLocalApic* local = reinterpret_cast<MadtLocalApic*>(entry);
|
||||||
|
#if K_ACPI_DEBUG
|
||||||
dbgln("Local APIC (Proc id, id, flags): {x}, {x}, {x}",
|
dbgln("Local APIC (Proc id, id, flags): {x}, {x}, {x}",
|
||||||
local->processor_id, local->apic_id, +local->flags);
|
local->processor_id, local->apic_id, +local->flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -179,9 +177,9 @@ void ParseMadt(SdtHeader* rsdt) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
#if K_ACPI_DEBUG
|
|
||||||
MadtIoApicInterruptSource* src =
|
MadtIoApicInterruptSource* src =
|
||||||
reinterpret_cast<MadtIoApicInterruptSource*>(entry);
|
reinterpret_cast<MadtIoApicInterruptSource*>(entry);
|
||||||
|
#if K_ACPI_DEBUG
|
||||||
dbgln("IO Source (Bus, IRQ, GSI, flags): {x}, {x}, {x}, {x}",
|
dbgln("IO Source (Bus, IRQ, GSI, flags): {x}, {x}, {x}, {x}",
|
||||||
src->bus_source, src->irq_source, +src->global_system_interrupt,
|
src->bus_source, src->irq_source, +src->global_system_interrupt,
|
||||||
+src->flags);
|
+src->flags);
|
||||||
|
|
@ -189,9 +187,9 @@ void ParseMadt(SdtHeader* rsdt) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
#if K_ACPI_DEBUG
|
|
||||||
MadtLocalApicNonMaskable* lnmi =
|
MadtLocalApicNonMaskable* lnmi =
|
||||||
reinterpret_cast<MadtLocalApicNonMaskable*>(entry);
|
reinterpret_cast<MadtLocalApicNonMaskable*>(entry);
|
||||||
|
#if K_ACPI_DEBUG
|
||||||
dbgln("Local NMI (proc id, flags, lint#): {x}, {x}, {x}",
|
dbgln("Local NMI (proc id, flags, lint#): {x}, {x}, {x}",
|
||||||
lnmi->apic_processor_id, +lnmi->flags, lnmi->lint_num);
|
lnmi->apic_processor_id, +lnmi->flags, lnmi->lint_num);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ static TaskStateSegment gTaskStateSegment;
|
||||||
extern "C" void ReloadSegments();
|
extern "C" void ReloadSegments();
|
||||||
|
|
||||||
uint64_t CreateSegment(uint64_t access, uint64_t flags) {
|
uint64_t CreateSegment(uint64_t access, uint64_t flags) {
|
||||||
|
uint64_t base = 0;
|
||||||
access &= 0xFF;
|
access &= 0xFF;
|
||||||
flags &= 0xF0;
|
flags &= 0xF0;
|
||||||
flags |= 0xF; // For the highest 4 bits of the limit.
|
flags |= 0xF; // For the highest 4 bits of the limit.
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,12 @@ void dbgputchar(char c) {
|
||||||
outb(COM1, c);
|
outb(COM1, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dbgcstr(const char* str) {
|
||||||
|
for (; *str != '\0'; str++) {
|
||||||
|
dbgputchar(*str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dbg(const glcr::StringView& str) {
|
void dbg(const glcr::StringView& str) {
|
||||||
for (uint64_t i = 0; i < str.size(); i++) {
|
for (uint64_t i = 0; i < str.size(); i++) {
|
||||||
dbgputchar(str[i]);
|
dbgputchar(str[i]);
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,20 @@ uint64_t LoadElfProgram(Process& dest_proc, uint64_t base, uint64_t offset) {
|
||||||
return header->entry;
|
return header->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool streq(const char* a, const char* b) {
|
||||||
|
while (true) {
|
||||||
|
if (*a == '\0' && *b == '\0') return true;
|
||||||
|
if (*a == '\0' || *b == '\0') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (*a != *b) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
a++;
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DumpModules() {
|
void DumpModules() {
|
||||||
#if K_INIT_DEBUG
|
#if K_INIT_DEBUG
|
||||||
const limine_module_response& resp = boot::GetModules();
|
const limine_module_response& resp = boot::GetModules();
|
||||||
|
|
@ -174,7 +188,7 @@ void LoadInitProgram() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start process.
|
// Start process.
|
||||||
limine_file init_prog = GetInitProgram("/sys/yellowstone");
|
const limine_file& init_prog = GetInitProgram("/sys/yellowstone");
|
||||||
uint64_t entry = LoadElfProgram(
|
uint64_t entry = LoadElfProgram(
|
||||||
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
|
*proc, reinterpret_cast<uint64_t>(init_prog.address), init_prog.size);
|
||||||
proc->CreateThread()->Start(entry, port_cap, 0);
|
proc->CreateThread()->Start(entry, port_cap, 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue