Compare commits
No commits in common. "642fc4d80d3cbfcdd8852717e2c571317976af9e" and "6212aef3365ac67f2d55e5f3e2ed3857f1dd2d9d" have entirely different histories.
642fc4d80d
...
6212aef336
|
@ -1,3 +1,2 @@
|
||||||
add_subdirectory(glacier)
|
add_subdirectory(glacier)
|
||||||
add_subdirectory(mammoth)
|
add_subdirectory(mammoth)
|
||||||
add_subdirectory(yunq)
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "glacier/status/error.h"
|
#include "status/error.h"
|
||||||
#include "glacier/string/string.h"
|
#include "string/string.h"
|
||||||
|
|
||||||
namespace glcr {
|
namespace glcr {
|
||||||
|
|
||||||
|
@ -11,67 +11,53 @@ class Status {
|
||||||
Status(ErrorCode code) : code_(code), message_() {}
|
Status(ErrorCode code) : code_(code), message_() {}
|
||||||
Status(ErrorCode code, StringView message) : code_(code), message_(message) {}
|
Status(ErrorCode code, StringView message) : code_(code), message_(message) {}
|
||||||
|
|
||||||
explicit operator bool() const { return ok(); }
|
explicit operator bool() { return ok(); }
|
||||||
bool ok() const { return code_ == OK; }
|
bool ok() { return code_ == OK; }
|
||||||
|
|
||||||
ErrorCode code() const { return code_; }
|
ErrorCode code() { return code_; }
|
||||||
StringView message() const { return message_; }
|
StringView message() { return message_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ErrorCode code_;
|
ErrorCode code_;
|
||||||
String message_;
|
String message_;
|
||||||
|
|
||||||
Status() : code_(OK) {}
|
Status();
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Status InvalidArgument(StringView message) {
|
Status InvalidArgument(StringView message) {
|
||||||
return Status(INVALID_ARGUMENT, message);
|
return Status(INVALID_ARGUMENT, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Status NotFound(StringView message) {
|
Status NotFound(StringView message) { return Status(NOT_FOUND, message); }
|
||||||
return Status(NOT_FOUND, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Status PermissionDenied(StringView message) {
|
Status PermissionDenied(StringView message) {
|
||||||
return Status(PERMISSION_DENIED, message);
|
return Status(PERMISSION_DENIED, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Status NullPtr(StringView message) { return Status(NULL_PTR, message); }
|
Status NullPtr(StringView message) { return Status(NULL_PTR, message); }
|
||||||
|
|
||||||
inline Status Empty(StringView message) { return Status(EMPTY, message); }
|
Status Empty(StringView message) { return Status(EMPTY, message); }
|
||||||
|
|
||||||
inline Status AlreadyExists(StringView message) {
|
Status AlreadyExists(StringView message) {
|
||||||
return Status(ALREADY_EXISTS, message);
|
return Status(ALREADY_EXISTS, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Status BufferSize(StringView message) {
|
Status BufferSize(StringView message) { return Status(BUFFER_SIZE, message); }
|
||||||
return Status(BUFFER_SIZE, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Status FailedPrecondition(StringView message) {
|
Status FailedPrecondition(StringView message) {
|
||||||
return Status(FAILED_PRECONDITION, message);
|
return Status(FAILED_PRECONDITION, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Status Internal(StringView message) { return Status(INTERNAL, message); }
|
Status Internal(StringView message) { return Status(INTERNAL, message); }
|
||||||
|
|
||||||
inline Status Unimplemented(StringView message) {
|
Status Unimplemented(StringView message) {
|
||||||
return Status(UNIMPLEMENTED, message);
|
return Status(UNIMPLEMENTED, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Status Exhausted(StringView message) {
|
Status Exhausted(StringView message) { return Status(EXHAUSTED, message); }
|
||||||
return Status(EXHAUSTED, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Status InvalidResponse(StringView message) {
|
Status InvalidResponse(StringView message) {
|
||||||
return Status(INVALID_RESPONSE, message);
|
return Status(INVALID_RESPONSE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RETURN_ERROR(expr) \
|
|
||||||
{ \
|
|
||||||
glcr::Status _tmp_err = expr; \
|
|
||||||
if (!_tmp_err) { \
|
|
||||||
return _tmp_err; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace glcr
|
} // namespace glcr
|
||||||
|
|
|
@ -72,12 +72,6 @@ void StrFormatValue(StringBuilder& builder, char const* const& value,
|
||||||
StrFormatInternal(builder, StringView(value));
|
StrFormatInternal(builder, StringView(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
|
||||||
void StrFormatValue(StringBuilder& builder, const String& value,
|
|
||||||
StringView opts) {
|
|
||||||
StrFormatInternal(builder, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void StrFormatValue(StringBuilder& builder, const StringView& value,
|
void StrFormatValue(StringBuilder& builder, const StringView& value,
|
||||||
StringView opts) {
|
StringView opts) {
|
||||||
|
|
|
@ -44,9 +44,6 @@ void StrFormatValue(StringBuilder& builder, char const* const& value,
|
||||||
StringView opts);
|
StringView opts);
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void StrFormatValue(StringBuilder& builder, const String& value,
|
|
||||||
StringView opts);
|
|
||||||
template <>
|
|
||||||
void StrFormatValue(StringBuilder& builder, const StringView& value,
|
void StrFormatValue(StringBuilder& builder, const StringView& value,
|
||||||
StringView opts);
|
StringView opts);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "file/file.h"
|
#include "file/file.h"
|
||||||
|
|
||||||
#include <glacier/string/str_split.h>
|
#include <glacier/string/str_split.h>
|
||||||
#include <mammoth/util/init.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 <zcall.h>
|
||||||
|
#include <zglobal.h>
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
||||||
|
@ -64,11 +64,7 @@ glcr::ErrorOr<glcr::Vector<glcr::String>> ListDirectory(glcr::StringView path) {
|
||||||
GetDirectoryRequest req;
|
GetDirectoryRequest req;
|
||||||
req.set_path(path);
|
req.set_path(path);
|
||||||
Directory dir;
|
Directory dir;
|
||||||
auto status = gVfsClient->GetDirectory(req, dir);
|
RET_ERR(gVfsClient->GetDirectory(req, dir));
|
||||||
if (!status.ok()) {
|
|
||||||
dbgln("Error in getting directory: {}", status.message());
|
|
||||||
return status.code();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto file_views = glcr::StrSplit(dir.filenames(), ',');
|
auto file_views = glcr::StrSplit(dir.filenames(), ',');
|
||||||
glcr::Vector<glcr::String> files;
|
glcr::Vector<glcr::String> files;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "input/keyboard.h"
|
#include "input/keyboard.h"
|
||||||
|
|
||||||
#include <mammoth/util/init.h>
|
|
||||||
#include <voyageurs/voyageurs.yunq.client.h>
|
#include <voyageurs/voyageurs.yunq.client.h>
|
||||||
#include <yellowstone/yellowstone.yunq.client.h>
|
#include <yellowstone/yellowstone.yunq.client.h>
|
||||||
|
#include <zglobal.h>
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,6 @@ void check(uint64_t code) {
|
||||||
(void)ZProcessExit(code);
|
(void)ZProcessExit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(const glcr::Status& status) {
|
|
||||||
if (status.ok()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dbgln("Crash: {}", status.message());
|
|
||||||
(void)ZProcessExit(status.code());
|
|
||||||
}
|
|
||||||
|
|
||||||
void crash(const char* str, uint64_t code) {
|
void crash(const char* str, uint64_t code) {
|
||||||
dbgln(str);
|
dbgln(str);
|
||||||
(void)ZProcessExit(code);
|
(void)ZProcessExit(code);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <glacier/string/str_format.h>
|
#include <glacier/string/str_format.h>
|
||||||
#include <glacier/string/string_view.h>
|
#include <glacier/string/string_view.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -17,6 +16,5 @@ void dbgln(const glcr::StringView& fmt, Args... args) {
|
||||||
// Checks that the code is ok.
|
// Checks that the code is ok.
|
||||||
// if not exits the process.
|
// if not exits the process.
|
||||||
void check(uint64_t);
|
void check(uint64_t);
|
||||||
void check(const glcr::Status&);
|
|
||||||
|
|
||||||
void crash(const char*, z_err_t);
|
void crash(const char*, z_err_t);
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <zglobal.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
extern uint64_t gSelfProcCap;
|
|
||||||
extern uint64_t gSelfVmasCap;
|
|
||||||
|
|
||||||
extern uint64_t gInitEndpointCap;
|
|
||||||
|
|
||||||
extern uint64_t gBootDenaliVmmoCap;
|
|
||||||
extern uint64_t gBootVictoriaFallsVmmoCap;
|
|
||||||
extern uint64_t gBootPciVmmoCap;
|
|
||||||
extern uint64_t gBootFramebufferVmmoCap;
|
|
||||||
|
|
||||||
z_err_t ParseInitPort(uint64_t init_port_cap);
|
z_err_t ParseInitPort(uint64_t init_port_cap);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include <glacier/container/intrusive_list.h>
|
#include <glacier/container/intrusive_list.h>
|
||||||
#include <glacier/string/str_format.h>
|
#include <glacier/string/str_format.h>
|
||||||
#include <mammoth/util/init.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
#include <zglobal.h>
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
set(yunq_files
|
|
||||||
serialize.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(yunq STATIC
|
|
||||||
${yunq_files}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(yunq
|
|
||||||
glacier)
|
|
||||||
|
|
||||||
target_include_directories(yunq
|
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
|
||||||
|
|
||||||
set_target_properties(yunq PROPERTIES
|
|
||||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}")
|
|
|
@ -1,29 +0,0 @@
|
||||||
#include "serialize.h"
|
|
||||||
|
|
||||||
namespace yunq {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const uint64_t kIdentByte = 0x33441122;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
glcr::Status CheckHeader(const glcr::ByteBuffer& buffer, uint64_t offset) {
|
|
||||||
if (buffer.At<uint32_t>(offset + 0) != kIdentByte) {
|
|
||||||
return glcr::InvalidArgument("Trying to parse an invalid yunq message.");
|
|
||||||
}
|
|
||||||
// TODO: Parse core size.
|
|
||||||
// TODO: Parse extension size.
|
|
||||||
// TODO: Check CRC32
|
|
||||||
// TODO: Parse options.
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
|
|
||||||
uint32_t extension_size) {
|
|
||||||
bytes.WriteAt<uint32_t>(offset + 0, kIdentByte);
|
|
||||||
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
|
||||||
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
|
||||||
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace yunq
|
|
|
@ -1,14 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
|
||||||
#include <glacier/status/status.h>
|
|
||||||
|
|
||||||
namespace yunq {
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status CheckHeader(const glcr::ByteBuffer& buffer,
|
|
||||||
uint64_t offset);
|
|
||||||
|
|
||||||
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
|
|
||||||
uint32_t extension_size);
|
|
||||||
|
|
||||||
} // namespace yunq
|
|
|
@ -16,7 +16,7 @@ uint64_t main(uint64_t init_port_cap) {
|
||||||
|
|
||||||
YellowstoneClient stub(gInitEndpointCap);
|
YellowstoneClient stub(gInitEndpointCap);
|
||||||
AhciInfo ahci;
|
AhciInfo ahci;
|
||||||
check(stub.GetAhciInfo(ahci));
|
RET_ERR(stub.GetAhciInfo(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)));
|
||||||
|
|
|
@ -12,8 +12,8 @@ glcr::ErrorOr<glcr::UniquePtr<DenaliServer>> DenaliServer::Create(
|
||||||
return glcr::UniquePtr<DenaliServer>(new DenaliServer(cap, driver));
|
return glcr::UniquePtr<DenaliServer>(new DenaliServer(cap, driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliServer::HandleRead(const ReadRequest& req,
|
glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
||||||
ReadResponse& resp) {
|
ReadResponse& resp) {
|
||||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||||
|
|
||||||
uint64_t paddr;
|
uint64_t paddr;
|
||||||
|
@ -28,15 +28,15 @@ glcr::Status DenaliServer::HandleRead(const ReadRequest& req,
|
||||||
resp.set_device_id(req.device_id());
|
resp.set_device_id(req.device_id());
|
||||||
resp.set_size(req.size());
|
resp.set_size(req.size());
|
||||||
resp.set_memory(region.DuplicateCap());
|
resp.set_memory(region.DuplicateCap());
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
||||||
ReadResponse& resp) {
|
ReadResponse& resp) {
|
||||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||||
|
|
||||||
if (req.lba().size() != req.sector_cnt().size()) {
|
if (req.lba().size() != req.sector_cnt().size()) {
|
||||||
return glcr::InvalidArgument("LBA and Sector Cnt must be the same length.");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t sector_cnt = 0;
|
uint64_t sector_cnt = 0;
|
||||||
|
@ -60,5 +60,5 @@ glcr::Status DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
||||||
resp.set_device_id(req.device_id());
|
resp.set_device_id(req.device_id());
|
||||||
resp.set_size(sector_cnt);
|
resp.set_size(sector_cnt);
|
||||||
resp.set_memory(region.DuplicateCap());
|
resp.set_memory(region.DuplicateCap());
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@ class DenaliServer : public DenaliServerBase {
|
||||||
static glcr::ErrorOr<glcr::UniquePtr<DenaliServer>> Create(
|
static glcr::ErrorOr<glcr::UniquePtr<DenaliServer>> Create(
|
||||||
AhciDriver& driver);
|
AhciDriver& driver);
|
||||||
|
|
||||||
glcr::Status HandleRead(const ReadRequest& req, ReadResponse& resp) override;
|
glcr::ErrorCode HandleRead(const ReadRequest& req,
|
||||||
glcr::Status HandleReadMany(const ReadManyRequest& req,
|
ReadResponse& resp) override;
|
||||||
ReadResponse& resp) override;
|
glcr::ErrorCode HandleReadMany(const ReadManyRequest& req,
|
||||||
|
ReadResponse& resp) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint64_t kBuffSize = 1024;
|
static const uint64_t kBuffSize = 1024;
|
||||||
|
|
|
@ -18,7 +18,7 @@ DenaliClient::~DenaliClient() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status 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;
|
||||||
|
@ -41,14 +41,14 @@ glcr::Status DenaliClient::Read(const ReadRequest& request, ReadResponse& respon
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
@ -57,7 +57,7 @@ glcr::Status DenaliClient::Read(const ReadRequest& request, ReadResponse& respon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status 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;
|
||||||
|
@ -80,14 +80,14 @@ glcr::Status DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
@ -20,11 +20,11 @@ class DenaliClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status Read(const ReadRequest& request, ReadResponse& response);
|
[[nodiscard]] glcr::ErrorCode Read(const ReadRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
[[nodiscard]] glcr::ErrorCode ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "denali.yunq.h"
|
#include "denali.yunq.h"
|
||||||
|
|
||||||
#include <yunq/serialize.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -13,19 +11,33 @@ struct ExtPointer {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CheckHeader(const glcr::ByteBuffer& bytes) {
|
||||||
|
// TODO: Check ident.
|
||||||
|
// TODO: Parse core size.
|
||||||
|
// TODO: Parse extension size.
|
||||||
|
// TODO: Check CRC32
|
||||||
|
// TODO: Parse options.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, uint32_t extension_size) {
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||||
|
bytes.WriteAt<uint64_t>(offset + 16, 0); // TODO: Add options.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
// Parse lba.
|
// Parse lba.
|
||||||
|
@ -33,7 +45,6 @@ glcr::Status ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes,
|
||||||
// Parse size.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -47,7 +58,7 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset)
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -64,22 +75,20 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
// Parse lba.
|
// Parse lba.
|
||||||
|
@ -103,7 +112,6 @@ glcr::Status ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& byt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -139,7 +147,7 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -178,29 +186,27 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_memory(0);
|
set_memory(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||||
|
|
||||||
set_memory(caps.At(memory_ptr));
|
set_memory(caps.At(memory_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
// Parse size.
|
// Parse size.
|
||||||
|
@ -208,7 +214,6 @@ glcr::Status ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes,
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -223,7 +228,7 @@ uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +246,7 @@ uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 <glacier/status/status.h>
|
|
||||||
#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>
|
||||||
|
@ -16,8 +15,8 @@ class ReadRequest {
|
||||||
ReadRequest(const ReadRequest&) = delete;
|
ReadRequest(const ReadRequest&) = delete;
|
||||||
ReadRequest(ReadRequest&&) = delete;
|
ReadRequest(ReadRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 uint64_t& device_id() const { return device_id_; }
|
const uint64_t& device_id() const { return device_id_; }
|
||||||
|
@ -33,7 +32,7 @@ class ReadRequest {
|
||||||
uint64_t size_;
|
uint64_t size_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class ReadManyRequest {
|
class ReadManyRequest {
|
||||||
public:
|
public:
|
||||||
|
@ -42,8 +41,8 @@ class ReadManyRequest {
|
||||||
ReadManyRequest(const ReadManyRequest&) = delete;
|
ReadManyRequest(const ReadManyRequest&) = delete;
|
||||||
ReadManyRequest(ReadManyRequest&&) = delete;
|
ReadManyRequest(ReadManyRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 uint64_t& device_id() const { return device_id_; }
|
const uint64_t& device_id() const { return device_id_; }
|
||||||
|
@ -59,7 +58,7 @@ class ReadManyRequest {
|
||||||
glcr::Vector<uint64_t> sector_cnt_;
|
glcr::Vector<uint64_t> sector_cnt_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class ReadResponse {
|
class ReadResponse {
|
||||||
public:
|
public:
|
||||||
|
@ -68,8 +67,8 @@ class ReadResponse {
|
||||||
ReadResponse(const ReadResponse&) = delete;
|
ReadResponse(const ReadResponse&) = delete;
|
||||||
ReadResponse(ReadResponse&&) = delete;
|
ReadResponse(ReadResponse&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 uint64_t& device_id() const { return device_id_; }
|
const uint64_t& device_id() const { return device_id_; }
|
||||||
|
@ -85,6 +84,6 @@ class ReadResponse {
|
||||||
z_cap_t memory_;
|
z_cap_t memory_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,9 @@ void DenaliServerBase::ServerThread() {
|
||||||
|
|
||||||
glcr::ErrorCode reply_err = glcr::OK;
|
glcr::ErrorCode reply_err = glcr::OK;
|
||||||
resp_cap.Reset();
|
resp_cap.Reset();
|
||||||
glcr::Status err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
glcr::ErrorCode err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
||||||
if (!err) {
|
if (err != glcr::OK) {
|
||||||
WriteError(resp_buffer, err.code());
|
WriteError(resp_buffer, err);
|
||||||
dbgln("Responding Error {}", err.message());
|
|
||||||
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
WriteHeader(resp_buffer, resp_length);
|
WriteHeader(resp_buffer, resp_length);
|
||||||
|
@ -89,12 +88,12 @@ void DenaliServerBase::ServerThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
glcr::ErrorCode DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
const glcr::CapBuffer& req_caps,
|
const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps) {
|
glcr::CapBuffer& resp_caps) {
|
||||||
if (request.At<uint32_t>(0) != kSentinel) {
|
if (request.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidArgument("Request Not Valid");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t method_select = request.At<uint64_t>(8);
|
uint64_t method_select = request.At<uint64_t>(8);
|
||||||
|
@ -104,7 +103,7 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
ReadRequest yunq_request;
|
ReadRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleRead(yunq_request, yunq_response));
|
RET_ERR(HandleRead(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
ReadManyRequest yunq_request;
|
ReadManyRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleReadMany(yunq_request, yunq_response));
|
RET_ERR(HandleReadMany(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,10 +140,10 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return glcr::Unimplemented("Method unimplemented by server.");
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/proc/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
@ -27,11 +26,11 @@ class DenaliServerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,9 +40,9 @@ class DenaliServerBase {
|
||||||
friend void DenaliServerBaseThreadBootstrap(void*);
|
friend void DenaliServerBaseThreadBootstrap(void*);
|
||||||
void ServerThread();
|
void ServerThread();
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <glacier/string/str_split.h>
|
#include <glacier/string/str_split.h>
|
||||||
#include <mammoth/file/file.h>
|
#include <mammoth/file/file.h>
|
||||||
#include <mammoth/proc/process.h>
|
#include <mammoth/proc/process.h>
|
||||||
#include <mammoth/util/init.h>
|
#include <zglobal.h>
|
||||||
|
|
||||||
void Terminal::HandleCharacter(char c) {
|
void Terminal::HandleCharacter(char c) {
|
||||||
console_.WriteChar(c);
|
console_.WriteChar(c);
|
||||||
|
|
|
@ -21,7 +21,7 @@ uint64_t main(uint64_t init_port) {
|
||||||
YellowstoneClient client(gInitEndpointCap);
|
YellowstoneClient client(gInitEndpointCap);
|
||||||
|
|
||||||
FramebufferInfo framebuffer;
|
FramebufferInfo framebuffer;
|
||||||
check(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());
|
||||||
|
|
|
@ -12,11 +12,7 @@ glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||||
req.set_lba(denali_info.lba_offset() + 2);
|
req.set_lba(denali_info.lba_offset() + 2);
|
||||||
req.set_size(2);
|
req.set_size(2);
|
||||||
ReadResponse resp;
|
ReadResponse resp;
|
||||||
auto status = client.Read(req, resp);
|
RET_ERR(client.Read(req, resp));
|
||||||
if (!status.ok()) {
|
|
||||||
dbgln("Failed to read superblock: {}", status.message());
|
|
||||||
return status.code();
|
|
||||||
}
|
|
||||||
mmth::OwnedMemoryRegion superblock =
|
mmth::OwnedMemoryRegion superblock =
|
||||||
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||||
|
|
||||||
|
@ -74,11 +70,7 @@ glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||||
req.set_lba(lba_offset_ + block_number * SectorsPerBlock());
|
req.set_lba(lba_offset_ + block_number * SectorsPerBlock());
|
||||||
req.set_size(num_blocks * SectorsPerBlock());
|
req.set_size(num_blocks * SectorsPerBlock());
|
||||||
ReadResponse resp;
|
ReadResponse resp;
|
||||||
auto status = denali_.Read(req, resp);
|
RET_ERR(denali_.Read(req, resp));
|
||||||
if (!status.ok()) {
|
|
||||||
dbgln("Failed to read blocks: {}", status.message());
|
|
||||||
return status.code();
|
|
||||||
}
|
|
||||||
return mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
return mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +92,7 @@ glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||||
}
|
}
|
||||||
dbgln("Read many: {x}", req.lba().size());
|
dbgln("Read many: {x}", req.lba().size());
|
||||||
ReadResponse resp;
|
ReadResponse resp;
|
||||||
auto status = denali_.ReadMany(req, resp);
|
RET_ERR(denali_.ReadMany(req, resp));
|
||||||
if (!status.ok()) {
|
|
||||||
dbgln("Failed to read blocks: {}", status.message());
|
|
||||||
return status.code();
|
|
||||||
}
|
|
||||||
return mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
return mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ VFSClient::~VFSClient() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status 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;
|
||||||
|
@ -41,14 +41,14 @@ glcr::Status VFSClient::OpenFile(const OpenFileRequest& request, OpenFileRespons
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
@ -57,7 +57,7 @@ glcr::Status VFSClient::OpenFile(const OpenFileRequest& request, OpenFileRespons
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status 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;
|
||||||
|
@ -80,14 +80,14 @@ glcr::Status VFSClient::GetDirectory(const GetDirectoryRequest& request, Directo
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
@ -20,11 +20,11 @@ class VFSClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status OpenFile(const OpenFileRequest& request, OpenFileResponse& response);
|
[[nodiscard]] glcr::ErrorCode OpenFile(const OpenFileRequest& request, OpenFileResponse& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status GetDirectory(const GetDirectoryRequest& request, Directory& response);
|
[[nodiscard]] glcr::ErrorCode GetDirectory(const GetDirectoryRequest& request, Directory& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "victoriafalls.yunq.h"
|
#include "victoriafalls.yunq.h"
|
||||||
|
|
||||||
#include <yunq/serialize.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -13,25 +11,38 @@ struct ExtPointer {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CheckHeader(const glcr::ByteBuffer& bytes) {
|
||||||
|
// TODO: Check ident.
|
||||||
|
// TODO: Parse core size.
|
||||||
|
// TODO: Parse extension size.
|
||||||
|
// TODO: Check CRC32
|
||||||
|
// TODO: Parse options.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, uint32_t extension_size) {
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||||
|
bytes.WriteAt<uint64_t>(offset + 16, 0); // TODO: Add options.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -50,7 +61,7 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -72,29 +83,27 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_memory(0);
|
set_memory(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||||
|
|
||||||
set_memory(caps.At(memory_ptr));
|
set_memory(caps.At(memory_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
|
@ -104,7 +113,6 @@ glcr::Status OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& by
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -128,7 +136,7 @@ uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -155,28 +163,25 @@ uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void GetDirectoryRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -195,7 +200,7 @@ uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -217,28 +222,25 @@ uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Directory::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void Directory::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse filenames.
|
// Parse filenames.
|
||||||
auto filenames_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto filenames_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_filenames(bytes.StringAt(offset + filenames_pointer.offset, filenames_pointer.length));
|
set_filenames(bytes.StringAt(offset + filenames_pointer.offset, filenames_pointer.length));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -257,7 +259,7 @@ uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) c
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), filenames_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), filenames_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +281,7 @@ uint64_t Directory::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, g
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), filenames_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), filenames_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 <glacier/status/status.h>
|
|
||||||
#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>
|
||||||
|
@ -16,8 +15,8 @@ class OpenFileRequest {
|
||||||
OpenFileRequest(const OpenFileRequest&) = delete;
|
OpenFileRequest(const OpenFileRequest&) = delete;
|
||||||
OpenFileRequest(OpenFileRequest&&) = delete;
|
OpenFileRequest(OpenFileRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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_; }
|
const glcr::String& path() const { return path_; }
|
||||||
|
@ -27,7 +26,7 @@ class OpenFileRequest {
|
||||||
glcr::String path_;
|
glcr::String path_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class OpenFileResponse {
|
class OpenFileResponse {
|
||||||
public:
|
public:
|
||||||
|
@ -36,8 +35,8 @@ class OpenFileResponse {
|
||||||
OpenFileResponse(const OpenFileResponse&) = delete;
|
OpenFileResponse(const OpenFileResponse&) = delete;
|
||||||
OpenFileResponse(OpenFileResponse&&) = delete;
|
OpenFileResponse(OpenFileResponse&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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_; }
|
const glcr::String& path() const { return path_; }
|
||||||
|
@ -53,7 +52,7 @@ class OpenFileResponse {
|
||||||
z_cap_t memory_;
|
z_cap_t memory_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class GetDirectoryRequest {
|
class GetDirectoryRequest {
|
||||||
public:
|
public:
|
||||||
|
@ -62,8 +61,8 @@ class GetDirectoryRequest {
|
||||||
GetDirectoryRequest(const GetDirectoryRequest&) = delete;
|
GetDirectoryRequest(const GetDirectoryRequest&) = delete;
|
||||||
GetDirectoryRequest(GetDirectoryRequest&&) = delete;
|
GetDirectoryRequest(GetDirectoryRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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_; }
|
const glcr::String& path() const { return path_; }
|
||||||
|
@ -73,7 +72,7 @@ class GetDirectoryRequest {
|
||||||
glcr::String path_;
|
glcr::String path_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class Directory {
|
class Directory {
|
||||||
public:
|
public:
|
||||||
|
@ -82,8 +81,8 @@ class Directory {
|
||||||
Directory(const Directory&) = delete;
|
Directory(const Directory&) = delete;
|
||||||
Directory(Directory&&) = delete;
|
Directory(Directory&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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& filenames() const { return filenames_; }
|
const glcr::String& filenames() const { return filenames_; }
|
||||||
|
@ -93,6 +92,6 @@ class Directory {
|
||||||
glcr::String filenames_;
|
glcr::String filenames_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,9 @@ void VFSServerBase::ServerThread() {
|
||||||
|
|
||||||
glcr::ErrorCode reply_err = glcr::OK;
|
glcr::ErrorCode reply_err = glcr::OK;
|
||||||
resp_cap.Reset();
|
resp_cap.Reset();
|
||||||
glcr::Status err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
glcr::ErrorCode err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
||||||
if (!err) {
|
if (err != glcr::OK) {
|
||||||
WriteError(resp_buffer, err.code());
|
WriteError(resp_buffer, err);
|
||||||
dbgln("Responding Error {}", err.message());
|
|
||||||
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
WriteHeader(resp_buffer, resp_length);
|
WriteHeader(resp_buffer, resp_length);
|
||||||
|
@ -89,12 +88,12 @@ void VFSServerBase::ServerThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
glcr::ErrorCode VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
const glcr::CapBuffer& req_caps,
|
const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps) {
|
glcr::CapBuffer& resp_caps) {
|
||||||
if (request.At<uint32_t>(0) != kSentinel) {
|
if (request.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidArgument("Request Not Valid");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t method_select = request.At<uint64_t>(8);
|
uint64_t method_select = request.At<uint64_t>(8);
|
||||||
|
@ -104,7 +103,7 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
OpenFileRequest yunq_request;
|
OpenFileRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleOpenFile(yunq_request, yunq_response));
|
RET_ERR(HandleOpenFile(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
GetDirectoryRequest yunq_request;
|
GetDirectoryRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleGetDirectory(yunq_request, yunq_response));
|
RET_ERR(HandleGetDirectory(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,10 +140,10 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return glcr::Unimplemented("Method unimplemented by server.");
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/proc/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
@ -27,11 +26,11 @@ class VFSServerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleOpenFile(const OpenFileRequest&, OpenFileResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleOpenFile(const OpenFileRequest&, OpenFileResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleGetDirectory(const GetDirectoryRequest&, Directory&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetDirectory(const GetDirectoryRequest&, Directory&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,9 +40,9 @@ class VFSServerBase {
|
||||||
friend void VFSServerBaseThreadBootstrap(void*);
|
friend void VFSServerBaseThreadBootstrap(void*);
|
||||||
void ServerThread();
|
void ServerThread();
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ uint64_t main(uint64_t init_cap) {
|
||||||
|
|
||||||
YellowstoneClient yellowstone(gInitEndpointCap);
|
YellowstoneClient yellowstone(gInitEndpointCap);
|
||||||
DenaliInfo denali_info;
|
DenaliInfo denali_info;
|
||||||
check(yellowstone.GetDenali(denali_info));
|
RET_ERR(yellowstone.GetDenali(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));
|
||||||
|
|
|
@ -11,13 +11,13 @@ glcr::ErrorOr<glcr::UniquePtr<VFSServer>> VFSServer::Create(
|
||||||
return glcr::UniquePtr<VFSServer>(new VFSServer(endpoint_cap, driver));
|
return glcr::UniquePtr<VFSServer>(new VFSServer(endpoint_cap, driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status VFSServer::HandleOpenFile(const OpenFileRequest& request,
|
glcr::ErrorCode VFSServer::HandleOpenFile(const OpenFileRequest& request,
|
||||||
OpenFileResponse& response) {
|
OpenFileResponse& response) {
|
||||||
auto path_tokens = glcr::StrSplit(request.path(), '/');
|
auto path_tokens = glcr::StrSplit(request.path(), '/');
|
||||||
// Require all paths to be absolute rather than relative.
|
// Require all paths to be absolute rather than relative.
|
||||||
// If the path starts with '/' then the first token will be empty.
|
// If the path starts with '/' then the first token will be empty.
|
||||||
if (path_tokens.at(0) != "") {
|
if (path_tokens.at(0) != "") {
|
||||||
return glcr::InvalidArgument("Open file supports only absolute paths.");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(auto files, driver_.ReadDirectory(2));
|
ASSIGN_OR_RETURN(auto files, driver_.ReadDirectory(2));
|
||||||
|
@ -31,8 +31,9 @@ glcr::Status VFSServer::HandleOpenFile(const OpenFileRequest& request,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found_token) {
|
if (!found_token) {
|
||||||
return glcr::NotFound(glcr::StrFormat("Directory '{}' not found.",
|
dbgln("Directory '{}' not found.",
|
||||||
glcr::String(path_tokens.at(i))));
|
glcr::String(path_tokens.at(i)).cstr());
|
||||||
|
return glcr::NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +48,8 @@ glcr::Status VFSServer::HandleOpenFile(const OpenFileRequest& request,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!region) {
|
if (!region) {
|
||||||
return glcr::NotFound(
|
dbgln("File '{}' not found.",
|
||||||
glcr::StrFormat("File '{}' not found.",
|
glcr::String(path_tokens.at(path_tokens.size() - 1)).cstr());
|
||||||
glcr::String(path_tokens.at(path_tokens.size() - 1))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.set_path(request.path());
|
response.set_path(request.path());
|
||||||
|
@ -61,15 +61,15 @@ glcr::Status VFSServer::HandleOpenFile(const OpenFileRequest& request,
|
||||||
ASSIGN_OR_RETURN(Inode * inode, driver_.GetInode(inode_num));
|
ASSIGN_OR_RETURN(Inode * inode, driver_.GetInode(inode_num));
|
||||||
// FIXME: This technically only sets the lower 32 bits.
|
// FIXME: This technically only sets the lower 32 bits.
|
||||||
response.set_size(inode->size);
|
response.set_size(inode->size);
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status VFSServer::HandleGetDirectory(const GetDirectoryRequest& request,
|
glcr::ErrorCode VFSServer::HandleGetDirectory(
|
||||||
Directory& response) {
|
const GetDirectoryRequest& request, Directory& response) {
|
||||||
auto path_tokens = glcr::StrSplit(request.path(), '/');
|
auto path_tokens = glcr::StrSplit(request.path(), '/');
|
||||||
|
|
||||||
if (path_tokens.at(0) != "") {
|
if (path_tokens.at(0) != "") {
|
||||||
return glcr::InvalidArgument("Get Directory only supports absolute path.");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a trailing slash we can get rid of the empty string.
|
// If there is a trailing slash we can get rid of the empty string.
|
||||||
|
@ -88,8 +88,9 @@ glcr::Status VFSServer::HandleGetDirectory(const GetDirectoryRequest& request,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found_token) {
|
if (!found_token) {
|
||||||
return glcr::NotFound(glcr::StrFormat("Directory '{}' not found.",
|
dbgln("Directory '{}' not found.",
|
||||||
glcr::String(path_tokens.at(i))));
|
glcr::String(path_tokens.at(i)).cstr());
|
||||||
|
return glcr::NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,5 +106,5 @@ glcr::Status VFSServer::HandleGetDirectory(const GetDirectoryRequest& request,
|
||||||
|
|
||||||
response.set_filenames(filelist.ToString());
|
response.set_filenames(filelist.ToString());
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ class VFSServer : public VFSServerBase {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::UniquePtr<VFSServer>> Create(Ext2Driver& driver);
|
static glcr::ErrorOr<glcr::UniquePtr<VFSServer>> Create(Ext2Driver& driver);
|
||||||
|
|
||||||
glcr::Status HandleOpenFile(const OpenFileRequest&,
|
glcr::ErrorCode HandleOpenFile(const OpenFileRequest&,
|
||||||
OpenFileResponse&) override;
|
OpenFileResponse&) override;
|
||||||
|
|
||||||
glcr::Status HandleGetDirectory(const GetDirectoryRequest&,
|
glcr::ErrorCode HandleGetDirectory(const GetDirectoryRequest&,
|
||||||
Directory&) override;
|
Directory&) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// FIXME: Don't store this as a reference.
|
// FIXME: Don't store this as a reference.
|
||||||
|
|
|
@ -18,7 +18,7 @@ VoyageursClient::~VoyageursClient() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status VoyageursClient::RegisterKeyboardListener(const KeyboardListener& request) {
|
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;
|
||||||
|
@ -41,7 +41,7 @@ glcr::Status VoyageursClient::RegisterKeyboardListener(const KeyboardListener& r
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
|
|
|
@ -20,7 +20,7 @@ class VoyageursClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status RegisterKeyboardListener(const KeyboardListener& request);
|
[[nodiscard]] glcr::ErrorCode RegisterKeyboardListener(const KeyboardListener& request);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "voyageurs.yunq.h"
|
#include "voyageurs.yunq.h"
|
||||||
|
|
||||||
#include <yunq/serialize.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -13,30 +11,43 @@ struct ExtPointer {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CheckHeader(const glcr::ByteBuffer& bytes) {
|
||||||
|
// TODO: Check ident.
|
||||||
|
// TODO: Parse core size.
|
||||||
|
// TODO: Parse extension size.
|
||||||
|
// TODO: Check CRC32
|
||||||
|
// TODO: Parse options.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, uint32_t extension_size) {
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||||
|
bytes.WriteAt<uint64_t>(offset + 16, 0); // TODO: Add options.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_port_capability(0);
|
set_port_capability(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
uint64_t port_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t port_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_port_capability(caps.At(port_capability_ptr));
|
set_port_capability(caps.At(port_capability_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status KeyboardListener::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void KeyboardListener::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -47,7 +58,7 @@ uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 0);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +72,7 @@ uint64_t KeyboardListener::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), next_cap++);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 <glacier/status/status.h>
|
|
||||||
#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>
|
||||||
|
@ -16,8 +15,8 @@ class KeyboardListener {
|
||||||
KeyboardListener(const KeyboardListener&) = delete;
|
KeyboardListener(const KeyboardListener&) = delete;
|
||||||
KeyboardListener(KeyboardListener&&) = delete;
|
KeyboardListener(KeyboardListener&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 z_cap_t& port_capability() const { return port_capability_; }
|
const z_cap_t& port_capability() const { return port_capability_; }
|
||||||
|
@ -27,6 +26,6 @@ class KeyboardListener {
|
||||||
z_cap_t port_capability_;
|
z_cap_t port_capability_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,9 @@ void VoyageursServerBase::ServerThread() {
|
||||||
|
|
||||||
glcr::ErrorCode reply_err = glcr::OK;
|
glcr::ErrorCode reply_err = glcr::OK;
|
||||||
resp_cap.Reset();
|
resp_cap.Reset();
|
||||||
glcr::Status err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
glcr::ErrorCode err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
||||||
if (!err) {
|
if (err != glcr::OK) {
|
||||||
WriteError(resp_buffer, err.code());
|
WriteError(resp_buffer, err);
|
||||||
dbgln("Responding Error {}", err.message());
|
|
||||||
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
WriteHeader(resp_buffer, resp_length);
|
WriteHeader(resp_buffer, resp_length);
|
||||||
|
@ -89,12 +88,12 @@ void VoyageursServerBase::ServerThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
glcr::ErrorCode VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
const glcr::CapBuffer& req_caps,
|
const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps) {
|
glcr::CapBuffer& resp_caps) {
|
||||||
if (request.At<uint32_t>(0) != kSentinel) {
|
if (request.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidArgument("Request Not Valid");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t method_select = request.At<uint64_t>(8);
|
uint64_t method_select = request.At<uint64_t>(8);
|
||||||
|
@ -104,13 +103,13 @@ glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
KeyboardListener yunq_request;
|
KeyboardListener yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleRegisterKeyboardListener(yunq_request));
|
RET_ERR(HandleRegisterKeyboardListener(yunq_request));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,10 +118,10 @@ glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return glcr::Unimplemented("Method unimplemented by server.");
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/proc/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ class VoyageursServerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleRegisterKeyboardListener(const KeyboardListener&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterKeyboardListener(const KeyboardListener&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,9 +36,9 @@ class VoyageursServerBase {
|
||||||
friend void VoyageursServerBaseThreadBootstrap(void*);
|
friend void VoyageursServerBaseThreadBootstrap(void*);
|
||||||
void ServerThread();
|
void ServerThread();
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ glcr::ErrorOr<glcr::UniquePtr<VoyageursServer>> VoyageursServer::Create(
|
||||||
new VoyageursServer(cap, keyboard_driver));
|
new VoyageursServer(cap, keyboard_driver));
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status VoyageursServer::HandleRegisterKeyboardListener(
|
glcr::ErrorCode VoyageursServer::HandleRegisterKeyboardListener(
|
||||||
const KeyboardListener& listener) {
|
const KeyboardListener& listener) {
|
||||||
keyboard_driver_.RegisterListener(listener.port_capability());
|
keyboard_driver_.RegisterListener(listener.port_capability());
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoyageursServer::VoyageursServer(z_cap_t voyageurs_cap,
|
VoyageursServer::VoyageursServer(z_cap_t voyageurs_cap,
|
||||||
|
|
|
@ -11,7 +11,7 @@ class VoyageursServer : public VoyageursServerBase {
|
||||||
static glcr::ErrorOr<glcr::UniquePtr<VoyageursServer>> Create(
|
static glcr::ErrorOr<glcr::UniquePtr<VoyageursServer>> Create(
|
||||||
KeyboardDriver& keyboard_driver);
|
KeyboardDriver& keyboard_driver);
|
||||||
|
|
||||||
virtual glcr::Status HandleRegisterKeyboardListener(
|
virtual glcr::ErrorCode HandleRegisterKeyboardListener(
|
||||||
const KeyboardListener& listener) override;
|
const KeyboardListener& listener) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <mammoth/util/debug.h>
|
#include <mammoth/util/debug.h>
|
||||||
#include <mammoth/util/memory_region.h>
|
#include <mammoth/util/memory_region.h>
|
||||||
#include <zcall.h>
|
#include <zcall.h>
|
||||||
|
#include <zglobal.h>
|
||||||
|
|
||||||
#define GPT_DEBUG 0
|
#define GPT_DEBUG 0
|
||||||
|
|
||||||
|
@ -56,29 +57,29 @@ struct PartitionEntry {
|
||||||
GptReader::GptReader(glcr::UniquePtr<DenaliClient> denali)
|
GptReader::GptReader(glcr::UniquePtr<DenaliClient> denali)
|
||||||
: denali_(glcr::Move(denali)) {}
|
: denali_(glcr::Move(denali)) {}
|
||||||
|
|
||||||
glcr::Status GptReader::ParsePartitionTables() {
|
glcr::ErrorCode GptReader::ParsePartitionTables() {
|
||||||
ReadRequest req;
|
ReadRequest req;
|
||||||
req.set_device_id(0);
|
req.set_device_id(0);
|
||||||
req.set_lba(0);
|
req.set_lba(0);
|
||||||
req.set_size(2);
|
req.set_size(2);
|
||||||
ReadResponse resp;
|
ReadResponse resp;
|
||||||
RETURN_ERROR(denali_->Read(req, resp));
|
RET_ERR(denali_->Read(req, resp));
|
||||||
mmth::OwnedMemoryRegion lba_1_and_2 =
|
mmth::OwnedMemoryRegion lba_1_and_2 =
|
||||||
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||||
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
|
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
|
||||||
if (*mbr_sig != 0xAA55) {
|
if (*mbr_sig != 0xAA55) {
|
||||||
return glcr::FailedPrecondition(
|
dbgln("Invalid MBR Sig: {x}", *mbr_sig);
|
||||||
glcr::StrFormat("Invalid MBR Sig: {x}", *mbr_sig));
|
return glcr::FAILED_PRECONDITION;
|
||||||
}
|
}
|
||||||
MbrPartition* first_partition =
|
MbrPartition* first_partition =
|
||||||
reinterpret_cast<MbrPartition*>(lba_1_and_2.vaddr() + 0x1BE);
|
reinterpret_cast<MbrPartition*>(lba_1_and_2.vaddr() + 0x1BE);
|
||||||
if (first_partition->boot_indicator != 0) {
|
if (first_partition->boot_indicator != 0) {
|
||||||
return glcr::FailedPrecondition(glcr::StrFormat(
|
dbgln("Boot indicator set: {}", first_partition->boot_indicator);
|
||||||
"Boot indicator set: {}", first_partition->boot_indicator));
|
return glcr::FAILED_PRECONDITION;
|
||||||
}
|
}
|
||||||
if (first_partition->os_type != 0xEE) {
|
if (first_partition->os_type != 0xEE) {
|
||||||
return glcr::FailedPrecondition(
|
dbgln("Incorrect OS type: {x}", first_partition->os_type);
|
||||||
glcr::StrFormat("Incorrect OS type: {x}", first_partition->os_type));
|
return glcr::FAILED_PRECONDITION;
|
||||||
}
|
}
|
||||||
#if GPT_DEBUG
|
#if GPT_DEBUG
|
||||||
dbgln("LBAs: ({x}, {x})", first_partition->starting_lba,
|
dbgln("LBAs: ({x}, {x})", first_partition->starting_lba,
|
||||||
|
@ -104,7 +105,7 @@ glcr::Status GptReader::ParsePartitionTables() {
|
||||||
req.set_device_id(0);
|
req.set_device_id(0);
|
||||||
req.set_lba(header->lba_partition_entries);
|
req.set_lba(header->lba_partition_entries);
|
||||||
req.set_size(num_blocks);
|
req.set_size(num_blocks);
|
||||||
RETURN_ERROR(denali_->Read(req, resp));
|
RET_ERR(denali_->Read(req, resp));
|
||||||
mmth::OwnedMemoryRegion part_table =
|
mmth::OwnedMemoryRegion part_table =
|
||||||
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||||
for (uint64_t i = 0; i < num_partitions; i++) {
|
for (uint64_t i = 0; i < num_partitions; i++) {
|
||||||
|
@ -129,5 +130,5 @@ glcr::Status GptReader::ParsePartitionTables() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ class GptReader {
|
||||||
public:
|
public:
|
||||||
GptReader(glcr::UniquePtr<DenaliClient> denali);
|
GptReader(glcr::UniquePtr<DenaliClient> denali);
|
||||||
|
|
||||||
glcr::Status ParsePartitionTables();
|
glcr::ErrorCode ParsePartitionTables();
|
||||||
|
|
||||||
uint64_t GetPrimaryPartitionLba() { return primary_partition_lba_; }
|
uint64_t GetPrimaryPartitionLba() { return primary_partition_lba_; }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ YellowstoneClient::~YellowstoneClient() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request) {
|
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;
|
||||||
|
@ -43,7 +43,7 @@ glcr::Status YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest&
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
|
@ -57,7 +57,7 @@ glcr::Status YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest&
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status 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;
|
||||||
|
@ -80,14 +80,14 @@ glcr::Status YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, E
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
@ -96,7 +96,7 @@ glcr::Status YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, E
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status YellowstoneClient::GetAhciInfo(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;
|
||||||
|
@ -119,14 +119,14 @@ glcr::Status YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
@ -135,7 +135,7 @@ glcr::Status YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status YellowstoneClient::GetFramebufferInfo(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;
|
||||||
|
@ -158,14 +158,14 @@ glcr::Status YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
@ -174,7 +174,7 @@ glcr::Status YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glcr::Status YellowstoneClient::GetDenali(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;
|
||||||
|
@ -197,14 +197,14 @@ glcr::Status YellowstoneClient::GetDenali(DenaliInfo& response) {
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
@ -22,23 +22,23 @@ class YellowstoneClient {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status RegisterEndpoint(const RegisterEndpointRequest& request);
|
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status GetEndpoint(const GetEndpointRequest& request, Endpoint& response);
|
[[nodiscard]] glcr::ErrorCode GetEndpoint(const GetEndpointRequest& request, Endpoint& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status GetAhciInfo(AhciInfo& response);
|
[[nodiscard]] glcr::ErrorCode GetAhciInfo(AhciInfo& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status GetFramebufferInfo(FramebufferInfo& response);
|
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(FramebufferInfo& response);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status GetDenali(DenaliInfo& response);
|
[[nodiscard]] glcr::ErrorCode GetDenali(DenaliInfo& response);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "yellowstone.yunq.h"
|
#include "yellowstone.yunq.h"
|
||||||
|
|
||||||
#include <yunq/serialize.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace yellowstone {
|
namespace yellowstone {
|
||||||
|
|
||||||
|
@ -15,26 +13,40 @@ struct ExtPointer {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CheckHeader(const glcr::ByteBuffer& bytes) {
|
||||||
|
// TODO: Check ident.
|
||||||
|
// TODO: Parse core size.
|
||||||
|
// TODO: Parse extension size.
|
||||||
|
// TODO: Check CRC32
|
||||||
|
// TODO: Parse options.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, uint32_t extension_size) {
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||||
|
bytes.WriteAt<uint64_t>(offset + 16, 0); // TODO: Add options.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_endpoint_capability(0);
|
set_endpoint_capability(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
||||||
|
|
||||||
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void RegisterEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse endpoint_name.
|
// Parse endpoint_name.
|
||||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
|
@ -42,7 +54,6 @@ glcr::Status RegisterEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuf
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -64,7 +75,7 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), 0);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -89,28 +100,25 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), next_cap++);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void GetEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse endpoint_name.
|
// Parse endpoint_name.
|
||||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -129,7 +137,7 @@ uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -151,33 +159,30 @@ uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_endpoint(0);
|
set_endpoint(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
uint64_t endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_endpoint(caps.At(endpoint_ptr));
|
set_endpoint(caps.At(endpoint_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Endpoint::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void Endpoint::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -188,7 +193,7 @@ uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) co
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 0);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -202,35 +207,32 @@ uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), next_cap++);
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_ahci_region(0);
|
set_ahci_region(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_ahci_region(caps.At(ahci_region_ptr));
|
set_ahci_region(caps.At(ahci_region_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status AhciInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void AhciInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
// Parse region_length.
|
// Parse region_length.
|
||||||
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -243,7 +245,7 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) co
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), region_length());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), region_length());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -259,22 +261,20 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), region_length());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), region_length());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse address_phys.
|
// Parse address_phys.
|
||||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
// Parse width.
|
// Parse width.
|
||||||
|
@ -300,7 +300,6 @@ glcr::Status FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& byt
|
||||||
// Parse blue_mask_shift.
|
// Parse blue_mask_shift.
|
||||||
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -332,7 +331,7 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -367,29 +366,27 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_denali_endpoint(0);
|
set_denali_endpoint(0);
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_denali_endpoint(caps.At(denali_endpoint_ptr));
|
set_denali_endpoint(caps.At(denali_endpoint_ptr));
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
// Skip Cap.
|
// Skip Cap.
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
|
@ -397,7 +394,6 @@ glcr::Status DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, u
|
||||||
// Parse lba_offset.
|
// Parse lba_offset.
|
||||||
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -412,7 +408,7 @@ uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset)
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), lba_offset());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), lba_offset());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -430,7 +426,7 @@ uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), lba_offset());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), lba_offset());
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 <glacier/status/status.h>
|
|
||||||
#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>
|
||||||
|
@ -18,8 +17,8 @@ class RegisterEndpointRequest {
|
||||||
RegisterEndpointRequest(const RegisterEndpointRequest&) = delete;
|
RegisterEndpointRequest(const RegisterEndpointRequest&) = delete;
|
||||||
RegisterEndpointRequest(RegisterEndpointRequest&&) = delete;
|
RegisterEndpointRequest(RegisterEndpointRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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& endpoint_name() const { return endpoint_name_; }
|
const glcr::String& endpoint_name() const { return endpoint_name_; }
|
||||||
|
@ -32,7 +31,7 @@ class RegisterEndpointRequest {
|
||||||
z_cap_t endpoint_capability_;
|
z_cap_t endpoint_capability_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class GetEndpointRequest {
|
class GetEndpointRequest {
|
||||||
public:
|
public:
|
||||||
|
@ -41,8 +40,8 @@ class GetEndpointRequest {
|
||||||
GetEndpointRequest(const GetEndpointRequest&) = delete;
|
GetEndpointRequest(const GetEndpointRequest&) = delete;
|
||||||
GetEndpointRequest(GetEndpointRequest&&) = delete;
|
GetEndpointRequest(GetEndpointRequest&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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& endpoint_name() const { return endpoint_name_; }
|
const glcr::String& endpoint_name() const { return endpoint_name_; }
|
||||||
|
@ -52,7 +51,7 @@ class GetEndpointRequest {
|
||||||
glcr::String endpoint_name_;
|
glcr::String endpoint_name_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class Endpoint {
|
class Endpoint {
|
||||||
public:
|
public:
|
||||||
|
@ -61,8 +60,8 @@ class Endpoint {
|
||||||
Endpoint(const Endpoint&) = delete;
|
Endpoint(const Endpoint&) = delete;
|
||||||
Endpoint(Endpoint&&) = delete;
|
Endpoint(Endpoint&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 z_cap_t& endpoint() const { return endpoint_; }
|
const z_cap_t& endpoint() const { return endpoint_; }
|
||||||
|
@ -72,7 +71,7 @@ class Endpoint {
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class AhciInfo {
|
class AhciInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -81,8 +80,8 @@ class AhciInfo {
|
||||||
AhciInfo(const AhciInfo&) = delete;
|
AhciInfo(const AhciInfo&) = delete;
|
||||||
AhciInfo(AhciInfo&&) = delete;
|
AhciInfo(AhciInfo&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 z_cap_t& ahci_region() const { return ahci_region_; }
|
const z_cap_t& ahci_region() const { return ahci_region_; }
|
||||||
|
@ -95,7 +94,7 @@ class AhciInfo {
|
||||||
uint64_t region_length_;
|
uint64_t region_length_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class FramebufferInfo {
|
class FramebufferInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -104,8 +103,8 @@ class FramebufferInfo {
|
||||||
FramebufferInfo(const FramebufferInfo&) = delete;
|
FramebufferInfo(const FramebufferInfo&) = delete;
|
||||||
FramebufferInfo(FramebufferInfo&&) = delete;
|
FramebufferInfo(FramebufferInfo&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 uint64_t& address_phys() const { return address_phys_; }
|
const uint64_t& address_phys() const { return address_phys_; }
|
||||||
|
@ -148,7 +147,7 @@ class FramebufferInfo {
|
||||||
uint64_t blue_mask_shift_;
|
uint64_t blue_mask_shift_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class DenaliInfo {
|
class DenaliInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -157,8 +156,8 @@ class DenaliInfo {
|
||||||
DenaliInfo(const DenaliInfo&) = delete;
|
DenaliInfo(const DenaliInfo&) = delete;
|
||||||
DenaliInfo(DenaliInfo&&) = delete;
|
DenaliInfo(DenaliInfo&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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 z_cap_t& denali_endpoint() const { return denali_endpoint_; }
|
const z_cap_t& denali_endpoint() const { return denali_endpoint_; }
|
||||||
|
@ -174,7 +173,7 @@ class DenaliInfo {
|
||||||
uint64_t lba_offset_;
|
uint64_t lba_offset_;
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,9 @@ void YellowstoneServerBase::ServerThread() {
|
||||||
|
|
||||||
glcr::ErrorCode reply_err = glcr::OK;
|
glcr::ErrorCode reply_err = glcr::OK;
|
||||||
resp_cap.Reset();
|
resp_cap.Reset();
|
||||||
glcr::Status err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
glcr::ErrorCode err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
||||||
if (!err) {
|
if (err != glcr::OK) {
|
||||||
WriteError(resp_buffer, err.code());
|
WriteError(resp_buffer, err);
|
||||||
dbgln("Responding Error {}", err.message());
|
|
||||||
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
WriteHeader(resp_buffer, resp_length);
|
WriteHeader(resp_buffer, resp_length);
|
||||||
|
@ -91,12 +90,12 @@ void YellowstoneServerBase::ServerThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
const glcr::CapBuffer& req_caps,
|
const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps) {
|
glcr::CapBuffer& resp_caps) {
|
||||||
if (request.At<uint32_t>(0) != kSentinel) {
|
if (request.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidArgument("Request Not Valid");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t method_select = request.At<uint64_t>(8);
|
uint64_t method_select = request.At<uint64_t>(8);
|
||||||
|
@ -106,13 +105,13 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
RegisterEndpointRequest yunq_request;
|
RegisterEndpointRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleRegisterEndpoint(yunq_request));
|
RET_ERR(HandleRegisterEndpoint(yunq_request));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
GetEndpointRequest yunq_request;
|
GetEndpointRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleGetEndpoint(yunq_request, yunq_response));
|
RET_ERR(HandleGetEndpoint(yunq_request, yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleGetAhciInfo(yunq_response));
|
RET_ERR(HandleGetAhciInfo(yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +165,7 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleGetFramebufferInfo(yunq_response));
|
RET_ERR(HandleGetFramebufferInfo(yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(HandleGetDenali(yunq_response));
|
RET_ERR(HandleGetDenali(yunq_response));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,10 +191,10 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return glcr::Unimplemented("Method unimplemented by server.");
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/proc/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
@ -29,23 +28,23 @@ class YellowstoneServerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleRegisterEndpoint(const RegisterEndpointRequest&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleGetAhciInfo(AhciInfo&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(AhciInfo&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleGetFramebufferInfo(FramebufferInfo&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetFramebufferInfo(FramebufferInfo&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::Status HandleGetDenali(DenaliInfo&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleGetDenali(DenaliInfo&) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,9 +54,9 @@ class YellowstoneServerBase {
|
||||||
friend void YellowstoneServerBaseThreadBootstrap(void*);
|
friend void YellowstoneServerBaseThreadBootstrap(void*);
|
||||||
void ServerThread();
|
void ServerThread();
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,7 @@ glcr::ErrorOr<PartitionInfo> HandleDenaliRegistration(z_cap_t endpoint_cap) {
|
||||||
GptReader reader(
|
GptReader reader(
|
||||||
glcr::UniquePtr<DenaliClient>(new DenaliClient(endpoint_cap)));
|
glcr::UniquePtr<DenaliClient>(new DenaliClient(endpoint_cap)));
|
||||||
|
|
||||||
auto status = reader.ParsePartitionTables();
|
RET_ERR(reader.ParsePartitionTables());
|
||||||
if (!status.ok()) {
|
|
||||||
dbgln("GPT Reader: {}", status.message());
|
|
||||||
return status.code();
|
|
||||||
}
|
|
||||||
|
|
||||||
return PartitionInfo{.device_id = 0,
|
return PartitionInfo{.device_id = 0,
|
||||||
.partition_lba = reader.GetPrimaryPartitionLba()};
|
.partition_lba = reader.GetPrimaryPartitionLba()};
|
||||||
|
@ -46,13 +42,13 @@ 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::Status YellowstoneServer::HandleGetAhciInfo(AhciInfo& info) {
|
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(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::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status YellowstoneServer::HandleGetFramebufferInfo(
|
glcr::ErrorCode YellowstoneServer::HandleGetFramebufferInfo(
|
||||||
FramebufferInfo& info) {
|
FramebufferInfo& info) {
|
||||||
// FIXME: Don't do this for each request.
|
// FIXME: Don't do this for each request.
|
||||||
mmth::OwnedMemoryRegion region =
|
mmth::OwnedMemoryRegion region =
|
||||||
|
@ -72,22 +68,22 @@ glcr::Status YellowstoneServer::HandleGetFramebufferInfo(
|
||||||
info.set_blue_mask_size(fb->blue_mask_size);
|
info.set_blue_mask_size(fb->blue_mask_size);
|
||||||
info.set_blue_mask_shift(fb->blue_mask_shift);
|
info.set_blue_mask_shift(fb->blue_mask_shift);
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status YellowstoneServer::HandleGetDenali(DenaliInfo& info) {
|
glcr::ErrorCode YellowstoneServer::HandleGetDenali(DenaliInfo& info) {
|
||||||
if (!endpoint_map_.Contains("denali")) {
|
if (!endpoint_map_.Contains("denali")) {
|
||||||
return glcr::NotFound("Denali Capability Not registered");
|
return glcr::NOT_FOUND;
|
||||||
}
|
}
|
||||||
z_cap_t new_denali;
|
z_cap_t new_denali;
|
||||||
check(ZCapDuplicate(endpoint_map_.at("denali"), kZionPerm_All, &new_denali));
|
check(ZCapDuplicate(endpoint_map_.at("denali"), kZionPerm_All, &new_denali));
|
||||||
info.set_denali_endpoint(new_denali);
|
info.set_denali_endpoint(new_denali);
|
||||||
info.set_device_id(device_id_);
|
info.set_device_id(device_id_);
|
||||||
info.set_lba_offset(lba_offset_);
|
info.set_lba_offset(lba_offset_);
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status YellowstoneServer::HandleRegisterEndpoint(
|
glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
||||||
const RegisterEndpointRequest& req) {
|
const RegisterEndpointRequest& req) {
|
||||||
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()));
|
||||||
|
@ -110,20 +106,19 @@ glcr::Status YellowstoneServer::HandleRegisterEndpoint(
|
||||||
} else {
|
} else {
|
||||||
dbgln("[WARN] Got endpoint cap type: {}", req.endpoint_name().cstr());
|
dbgln("[WARN] Got endpoint cap type: {}", req.endpoint_name().cstr());
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status YellowstoneServer::HandleGetEndpoint(const GetEndpointRequest& req,
|
glcr::ErrorCode YellowstoneServer::HandleGetEndpoint(
|
||||||
Endpoint& resp) {
|
const GetEndpointRequest& req, Endpoint& resp) {
|
||||||
if (!endpoint_map_.Contains(req.endpoint_name())) {
|
if (!endpoint_map_.Contains(req.endpoint_name())) {
|
||||||
return glcr::NotFound(
|
return glcr::NOT_FOUND;
|
||||||
glcr::StrFormat("Endpoint '{}' not found.", req.endpoint_name()));
|
|
||||||
}
|
}
|
||||||
z_cap_t cap = endpoint_map_.at(req.endpoint_name());
|
z_cap_t cap = endpoint_map_.at(req.endpoint_name());
|
||||||
z_cap_t new_cap;
|
z_cap_t new_cap;
|
||||||
check(ZCapDuplicate(cap, kZionPerm_All, &new_cap));
|
check(ZCapDuplicate(cap, kZionPerm_All, &new_cap));
|
||||||
resp.set_endpoint(new_cap);
|
resp.set_endpoint(new_cap);
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YellowstoneServer::WaitDenaliRegistered() { has_denali_semaphore_.Wait(); }
|
void YellowstoneServer::WaitDenaliRegistered() { has_denali_semaphore_.Wait(); }
|
||||||
|
|
|
@ -16,11 +16,13 @@ class YellowstoneServer : public YellowstoneServerBase {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> Create();
|
static glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> Create();
|
||||||
|
|
||||||
glcr::Status HandleGetAhciInfo(AhciInfo&) override;
|
glcr::ErrorCode HandleGetAhciInfo(AhciInfo&) override;
|
||||||
glcr::Status HandleGetFramebufferInfo(FramebufferInfo&) override;
|
glcr::ErrorCode HandleGetFramebufferInfo(FramebufferInfo&) override;
|
||||||
glcr::Status HandleGetDenali(DenaliInfo&) override;
|
glcr::ErrorCode HandleGetDenali(DenaliInfo&) override;
|
||||||
glcr::Status HandleRegisterEndpoint(const RegisterEndpointRequest&) override;
|
glcr::ErrorCode HandleRegisterEndpoint(
|
||||||
glcr::Status HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) override;
|
const RegisterEndpointRequest&) override;
|
||||||
|
glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&,
|
||||||
|
Endpoint&) override;
|
||||||
|
|
||||||
void WaitDenaliRegistered();
|
void WaitDenaliRegistered();
|
||||||
void WaitVictoriaFallsRegistered();
|
void WaitVictoriaFallsRegistered();
|
||||||
|
|
|
@ -17,8 +17,6 @@ macro(yunq_gen dir include_dir name)
|
||||||
|
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
mammoth
|
mammoth
|
||||||
glacier
|
|
||||||
yunq
|
|
||||||
)
|
)
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||||
|
|
|
@ -20,11 +20,11 @@ namespace {{package.cpp_namespace()}} {
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
|
|
||||||
{% if method.request == None %}
|
{% if method.request == None %}
|
||||||
glcr::Status {{interface.name}}Client::{{method.name}}({{method.response}}& response) {
|
glcr::ErrorCode {{interface.name}}Client::{{method.name}}({{method.response}}& response) {
|
||||||
{% elif method.response == None %}
|
{% elif method.response == None %}
|
||||||
glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}& request) {
|
glcr::ErrorCode {{interface.name}}Client::{{method.name}}(const {{method.request}}& request) {
|
||||||
{% else %}
|
{% else %}
|
||||||
glcr::Status {{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 %}
|
{% endif %}
|
||||||
uint64_t buffer_size = kBufferSize;
|
uint64_t buffer_size = kBufferSize;
|
||||||
uint64_t cap_size = kCapBufferSize;
|
uint64_t cap_size = kCapBufferSize;
|
||||||
|
@ -49,14 +49,14 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}&
|
||||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||||
|
|
||||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidResponse("Got an invalid response from server.");
|
return glcr::INVALID_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Response Code.
|
// Check Response Code.
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
{% if method.response != None %}
|
{% if method.response != None %}
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
@ -23,11 +23,11 @@ class {{interface.name}}Client {
|
||||||
|
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
{% if method.request == None %}
|
{% if method.request == None %}
|
||||||
[[nodiscard]] glcr::Status {{method.name}}({{method.response}}& response);
|
[[nodiscard]] glcr::ErrorCode {{method.name}}({{method.response}}& response);
|
||||||
{% elif method.response == None %}
|
{% elif method.response == None %}
|
||||||
[[nodiscard]] glcr::Status {{method.name}}(const {{method.request}}& request);
|
[[nodiscard]] glcr::ErrorCode {{method.name}}(const {{method.request}}& request);
|
||||||
{% else %}
|
{% else %}
|
||||||
[[nodiscard]] glcr::Status {{method.name}}(const {{method.request}}& request, {{method.response}}& response);
|
[[nodiscard]] glcr::ErrorCode {{method.name}}(const {{method.request}}& request, {{method.response}}& response);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "{{file}}.h"
|
#include "{{file}}.h"
|
||||||
|
|
||||||
#include <yunq/serialize.h>
|
|
||||||
|
|
||||||
{% if package != None %}
|
{% if package != None %}
|
||||||
namespace {{package.cpp_namespace()}} {
|
namespace {{package.cpp_namespace()}} {
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -15,11 +13,27 @@ struct ExtPointer {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void CheckHeader(const glcr::ByteBuffer& bytes) {
|
||||||
|
// TODO: Check ident.
|
||||||
|
// TODO: Parse core size.
|
||||||
|
// TODO: Parse extension size.
|
||||||
|
// TODO: Check CRC32
|
||||||
|
// TODO: Parse options.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, uint32_t extension_size) {
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 0, 0xDEADBEEF); // TODO: Chose a more unique ident sequence.
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 4, core_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 8, extension_size);
|
||||||
|
bytes.WriteAt<uint32_t>(offset + 12, 0); // TODO: Calculate CRC32.
|
||||||
|
bytes.WriteAt<uint64_t>(offset + 16, 0); // TODO: Add options.
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
{%- for message in messages %}
|
{%- for message in messages %}
|
||||||
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
{%- for field in message.fields %}
|
||||||
{%- if field.type == Type.CAPABILITY %}
|
{%- if field.type == Type.CAPABILITY %}
|
||||||
|
@ -28,11 +42,10 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
|
||||||
set_{{field.name}}(0);
|
set_{{field.name}}(0);
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
ParseFromBytesInternal(bytes, offset);
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
{%- for field in message.fields %}
|
||||||
{%- if field.type == Type.CAPABILITY %}
|
{%- if field.type == Type.CAPABILITY %}
|
||||||
|
@ -42,11 +55,10 @@ glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uin
|
||||||
set_{{field.name}}(caps.At({{field.name}}_ptr));
|
set_{{field.name}}(caps.At({{field.name}}_ptr));
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
CheckHeader(bytes);
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
{%- for field in message.fields %}
|
||||||
// Parse {{field.name}}.
|
// Parse {{field.name}}.
|
||||||
|
@ -76,7 +88,6 @@ glcr::Status {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& by
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -124,7 +135,7 @@ uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
@ -175,7 +186,7 @@ uint64_t {{message.name}}::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
// The next extension pointer is the length of the message.
|
// The next extension pointer is the length of the message.
|
||||||
yunq::WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 <glacier/status/status.h>
|
|
||||||
#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>
|
||||||
|
@ -20,8 +19,8 @@ class {{message.name}} {
|
||||||
{{message.name}}(const {{message.name}}&) = delete;
|
{{message.name}}(const {{message.name}}&) = delete;
|
||||||
{{message.name}}({{message.name}}&&) = delete;
|
{{message.name}}({{message.name}}&&) = delete;
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
[[nodiscard]] glcr::Status 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;
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ class {{message.name}} {
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
// Parses everything except for caps.
|
// Parses everything except for caps.
|
||||||
glcr::Status ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,9 @@ void {{interface.name}}ServerBase::ServerThread() {
|
||||||
|
|
||||||
glcr::ErrorCode reply_err = glcr::OK;
|
glcr::ErrorCode reply_err = glcr::OK;
|
||||||
resp_cap.Reset();
|
resp_cap.Reset();
|
||||||
glcr::Status err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
glcr::ErrorCode err = HandleRequest(recv_buffer, recv_cap, resp_buffer, resp_length, resp_cap);
|
||||||
if (!err) {
|
if (err != glcr::OK) {
|
||||||
WriteError(resp_buffer, err.code());
|
WriteError(resp_buffer, err);
|
||||||
dbgln("Responding Error {}", err.message());
|
|
||||||
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
reply_err = static_cast<glcr::ErrorCode>(ZReplyPortSend(reply_port_cap, kHeaderSize, resp_buffer.RawPtr(), 0, nullptr));
|
||||||
} else {
|
} else {
|
||||||
WriteHeader(resp_buffer, resp_length);
|
WriteHeader(resp_buffer, resp_length);
|
||||||
|
@ -91,12 +90,12 @@ void {{interface.name}}ServerBase::ServerThread() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
glcr::ErrorCode {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
const glcr::CapBuffer& req_caps,
|
const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps) {
|
glcr::CapBuffer& resp_caps) {
|
||||||
if (request.At<uint32_t>(0) != kSentinel) {
|
if (request.At<uint32_t>(0) != kSentinel) {
|
||||||
return glcr::InvalidArgument("Request Not Valid");
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t method_select = request.At<uint64_t>(8);
|
uint64_t method_select = request.At<uint64_t>(8);
|
||||||
|
@ -107,7 +106,7 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
|
||||||
|
|
||||||
{% if method.request != None %}
|
{% if method.request != None %}
|
||||||
{{method.request}} yunq_request;
|
{{method.request}} yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if method.response != None %}
|
{% if method.response != None %}
|
||||||
|
@ -115,11 +114,11 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if method.request == None %}
|
{% if method.request == None %}
|
||||||
RETURN_ERROR(Handle{{method.name}}(yunq_response));
|
RET_ERR(Handle{{method.name}}(yunq_response));
|
||||||
{% elif method.response == None %}
|
{% elif method.response == None %}
|
||||||
RETURN_ERROR(Handle{{method.name}}(yunq_request));
|
RET_ERR(Handle{{method.name}}(yunq_request));
|
||||||
{% else %}
|
{% else %}
|
||||||
RETURN_ERROR(Handle{{method.name}}(yunq_request, yunq_response));
|
RET_ERR(Handle{{method.name}}(yunq_request, yunq_response));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if method.response != None %}
|
{% if method.response != None %}
|
||||||
|
@ -131,10 +130,10 @@ glcr::Status {{interface.name}}ServerBase::HandleRequest(const glcr::ByteBuffer&
|
||||||
}
|
}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
default: {
|
default: {
|
||||||
return glcr::Unimplemented("Method unimplemented by server.");
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return glcr::Status::Ok();
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <glacier/status/status.h>
|
|
||||||
#include <mammoth/proc/thread.h>
|
#include <mammoth/proc/thread.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
@ -29,11 +28,11 @@ class {{interface.name}}ServerBase {
|
||||||
|
|
||||||
{% for method in interface.methods %}
|
{% for method in interface.methods %}
|
||||||
{% if method.request == None %}
|
{% if method.request == None %}
|
||||||
[[nodiscard]] virtual glcr::Status Handle{{method.name}}({{method.response}}&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}({{method.response}}&) = 0;
|
||||||
{% elif method.response == None %}
|
{% elif method.response == None %}
|
||||||
[[nodiscard]] virtual glcr::Status Handle{{method.name}}(const {{method.request}}&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&) = 0;
|
||||||
{% else %}
|
{% else %}
|
||||||
[[nodiscard]] virtual glcr::Status Handle{{method.name}}(const {{method.request}}&, {{method.response}}&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&, {{method.response}}&) = 0;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -43,9 +42,9 @@ class {{interface.name}}ServerBase {
|
||||||
friend void {{interface.name}}ServerBaseThreadBootstrap(void*);
|
friend void {{interface.name}}ServerBaseThreadBootstrap(void*);
|
||||||
void ServerThread();
|
void ServerThread();
|
||||||
|
|
||||||
[[nodiscard]] glcr::Status HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
|
||||||
glcr::ByteBuffer& response, uint64_t& resp_length,
|
glcr::ByteBuffer& response, uint64_t& resp_length,
|
||||||
glcr::CapBuffer& resp_caps);
|
glcr::CapBuffer& resp_caps);
|
||||||
};
|
};
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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]
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern uint64_t gSelfProcCap;
|
||||||
|
extern uint64_t gSelfVmasCap;
|
||||||
|
|
||||||
|
extern uint64_t gInitEndpointCap;
|
||||||
|
|
||||||
|
extern uint64_t gBootDenaliVmmoCap;
|
||||||
|
extern uint64_t gBootVictoriaFallsVmmoCap;
|
||||||
|
extern uint64_t gBootPciVmmoCap;
|
||||||
|
extern uint64_t gBootFramebufferVmmoCap;
|
Loading…
Reference in New Issue