Compare commits
10 Commits
5eb72da9c8
...
0135d8d844
| Author | SHA1 | Date |
|---|---|---|
|
|
0135d8d844 | |
|
|
75d84a0fa5 | |
|
|
0e6aa532a1 | |
|
|
30b220b2fb | |
|
|
9e9ef21a3d | |
|
|
8a711266ef | |
|
|
7b8528ea99 | |
|
|
e7cc98a20c | |
|
|
be392252a4 | |
|
|
d74918409c |
|
|
@ -18,9 +18,8 @@ class HashMap {
|
||||||
HashMap() = default;
|
HashMap() = default;
|
||||||
HashMap(const HashMap&) = delete;
|
HashMap(const HashMap&) = delete;
|
||||||
HashMap& operator=(const HashMap&) = delete;
|
HashMap& operator=(const HashMap&) = delete;
|
||||||
// TODO: Implement Move.
|
HashMap(HashMap&&);
|
||||||
HashMap(HashMap&&) = delete;
|
HashMap& operator=(HashMap&&);
|
||||||
HashMap& operator=(HashMap&&) = delete;
|
|
||||||
|
|
||||||
// Accessors.
|
// Accessors.
|
||||||
uint64_t size() { return size_; }
|
uint64_t size() { return size_; }
|
||||||
|
|
@ -63,6 +62,21 @@ class HashMap {
|
||||||
void ResizeIfNecessary();
|
void ResizeIfNecessary();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V, class H>
|
||||||
|
HashMap<K, V, H>::HashMap(HashMap&& other) {
|
||||||
|
data_ = glcr::Move(other.data_);
|
||||||
|
size_ = other.size_;
|
||||||
|
other.size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename K, typename V, class H>
|
||||||
|
HashMap<K, V, H>& HashMap<K, V, H>::operator=(HashMap&& other) {
|
||||||
|
data_ = glcr::Move(other.data_);
|
||||||
|
size_ = other.size_;
|
||||||
|
other.size_ = 0;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename K, typename V, class H>
|
template <typename K, typename V, class H>
|
||||||
V& HashMap<K, V, H>::at(const K& key) {
|
V& HashMap<K, V, H>::at(const K& key) {
|
||||||
uint64_t hc = H()(key);
|
uint64_t hc = H()(key);
|
||||||
|
|
@ -74,7 +88,8 @@ V& HashMap<K, V, H>::at(const K& key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Add a failure mode here instead of constructing an object.
|
// TODO: Add a failure mode here instead of constructing an object.
|
||||||
ll.PushFront({key, {}});
|
K k2 = key;
|
||||||
|
ll.PushFront({glcr::Move(k2), {}});
|
||||||
return ll.PeekFront().second();
|
return ll.PeekFront().second();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,8 @@ z_cap_t OwnedMemoryRegion::DuplicateCap() {
|
||||||
return cap;
|
return cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OwnedMemoryRegion OwnedMemoryRegion::Duplicate() {
|
||||||
|
return OwnedMemoryRegion::FromCapability(DuplicateCap());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mmth
|
} // namespace mmth
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ class OwnedMemoryRegion {
|
||||||
|
|
||||||
z_cap_t cap() const { return vmmo_cap_; }
|
z_cap_t cap() const { return vmmo_cap_; }
|
||||||
z_cap_t DuplicateCap();
|
z_cap_t DuplicateCap();
|
||||||
|
OwnedMemoryRegion Duplicate();
|
||||||
|
|
||||||
bool empty() const { return vmmo_cap_ == 0; }
|
bool empty() const { return vmmo_cap_ == 0; }
|
||||||
explicit operator bool() const { return vmmo_cap_ != 0; }
|
explicit operator bool() const { return vmmo_cap_ != 0; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
set(yunq_files
|
set(yunq_files
|
||||||
|
message_view.cpp
|
||||||
serialize.cpp
|
serialize.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
#include "message_view.h"
|
||||||
|
|
||||||
|
namespace yunq {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const uint64_t kIdentByte = 0x33441122;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
glcr::Status MessageView::CheckHeader() const {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<uint64_t> MessageView::ReadField<uint64_t>(
|
||||||
|
uint64_t field_index) const {
|
||||||
|
return buffer_.At<uint64_t>(field_offset(field_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<glcr::String> MessageView::ReadField<glcr::String>(
|
||||||
|
uint64_t field_index) const {
|
||||||
|
ExtensionPointer ptr =
|
||||||
|
buffer_.At<ExtensionPointer>(field_offset(field_index));
|
||||||
|
|
||||||
|
return buffer_.StringAt(offset_ + ptr.offset, ptr.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<glcr::Vector<uint64_t>> MessageView::ReadRepeated<uint64_t>(
|
||||||
|
uint64_t field_index) const {
|
||||||
|
ExtensionPointer pointer =
|
||||||
|
buffer_.At<ExtensionPointer>(field_offset(field_index));
|
||||||
|
|
||||||
|
glcr::Vector<uint64_t> v;
|
||||||
|
v.Resize(pointer.length / sizeof(uint64_t));
|
||||||
|
for (uint64_t i = offset_ + pointer.offset;
|
||||||
|
i < offset_ + pointer.offset + pointer.length; i += sizeof(uint64_t)) {
|
||||||
|
v.PushBack(buffer_.At<uint64_t>(i));
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
glcr::ErrorOr<uint64_t> MessageView::ReadCapability(
|
||||||
|
uint64_t field_index) const {
|
||||||
|
return buffer_.At<uint64_t>(field_offset(field_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
glcr::ErrorOr<uint64_t> MessageView::ReadCapability(
|
||||||
|
uint64_t field_index, const glcr::CapBuffer& caps) const {
|
||||||
|
uint64_t offset = buffer_.At<uint64_t>(field_offset(field_index));
|
||||||
|
return caps.At(offset);
|
||||||
|
}
|
||||||
|
} // namespace yunq
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
|
#include <glacier/container/vector.h>
|
||||||
|
#include <glacier/status/error_or.h>
|
||||||
|
#include <glacier/status/status.h>
|
||||||
|
|
||||||
|
namespace yunq {
|
||||||
|
|
||||||
|
const uint64_t kHeaderSize = 24; // 4x uint32, 1x uint64
|
||||||
|
|
||||||
|
struct MessageHeader {
|
||||||
|
uint32_t ident;
|
||||||
|
uint32_t core_length;
|
||||||
|
uint32_t length;
|
||||||
|
uint32_t crc32;
|
||||||
|
uint64_t options;
|
||||||
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
struct ExtensionPointer {
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t length;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MessageView {
|
||||||
|
public:
|
||||||
|
MessageView(const glcr::ByteBuffer& buffer, uint64_t offset)
|
||||||
|
: buffer_(buffer), offset_(offset) {}
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::Status CheckHeader() const;
|
||||||
|
|
||||||
|
// TODO: Implement glcr::StatusOr
|
||||||
|
template <typename T>
|
||||||
|
glcr::ErrorOr<T> ReadField(uint64_t field_index) const;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
glcr::ErrorOr<glcr::Vector<T>> ReadRepeated(uint64_t field_index) const;
|
||||||
|
|
||||||
|
glcr::ErrorOr<uint64_t> ReadCapability(uint64_t field_index) const;
|
||||||
|
glcr::ErrorOr<uint64_t> ReadCapability(uint64_t field_index,
|
||||||
|
const glcr::CapBuffer& caps) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const glcr::ByteBuffer& buffer_;
|
||||||
|
uint64_t offset_;
|
||||||
|
|
||||||
|
uint64_t field_offset(uint64_t field_index) const {
|
||||||
|
return offset_ + kHeaderSize + (8 * field_index);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<uint64_t> MessageView::ReadField<uint64_t>(
|
||||||
|
uint64_t field_index) const;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<glcr::String> MessageView::ReadField<glcr::String>(
|
||||||
|
uint64_t field_index) const;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
glcr::ErrorOr<glcr::Vector<uint64_t>> MessageView::ReadRepeated<uint64_t>(
|
||||||
|
uint64_t field_index) const;
|
||||||
|
|
||||||
|
} // namespace yunq
|
||||||
|
|
@ -7,17 +7,6 @@ const uint64_t kIdentByte = 0x33441122;
|
||||||
|
|
||||||
} // namespace
|
} // 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,
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
|
||||||
uint32_t extension_size) {
|
uint32_t extension_size) {
|
||||||
bytes.WriteAt<uint32_t>(offset + 0, kIdentByte);
|
bytes.WriteAt<uint32_t>(offset + 0, kIdentByte);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,6 @@
|
||||||
|
|
||||||
namespace yunq {
|
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,
|
void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size,
|
||||||
uint32_t extension_size);
|
uint32_t extension_size);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ glcr::Status DenaliClient::Read(const ReadRequest& request, ReadResponse& respon
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
@ -87,7 +88,8 @@ glcr::Status DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "denali.yunq.h"
|
#include "denali.yunq.h"
|
||||||
|
|
||||||
|
#include <yunq/message_view.h>
|
||||||
#include <yunq/serialize.h>
|
#include <yunq/serialize.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,24 +15,24 @@ struct ExtPointer {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status ReadRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||||
// Parse lba.
|
// Parse lba.
|
||||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(lba_, message.ReadField<uint64_t>(1));
|
||||||
// Parse size.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
ASSIGN_OR_RETURN(size_, message.ReadField<uint64_t>(2));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -68,39 +69,25 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status ReadManyRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadManyRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||||
// Parse lba.
|
// Parse lba.
|
||||||
auto lba_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
ASSIGN_OR_RETURN(lba_, message.ReadRepeated<uint64_t>(1));
|
||||||
|
|
||||||
lba_.Resize(lba_pointer.length / sizeof(uint64_t));
|
|
||||||
for (uint64_t i = offset + lba_pointer.offset;
|
|
||||||
i < offset + lba_pointer.offset + lba_pointer.length;
|
|
||||||
i += sizeof(uint64_t)) {
|
|
||||||
lba_.PushBack(bytes.At<uint64_t>(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse sector_cnt.
|
// Parse sector_cnt.
|
||||||
auto sector_cnt_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 2));
|
ASSIGN_OR_RETURN(sector_cnt_, message.ReadRepeated<uint64_t>(2));
|
||||||
|
|
||||||
sector_cnt_.Resize(sector_cnt_pointer.length / sizeof(uint64_t));
|
|
||||||
for (uint64_t i = offset + sector_cnt_pointer.offset;
|
|
||||||
i < offset + sector_cnt_pointer.offset + sector_cnt_pointer.length;
|
|
||||||
i += sizeof(uint64_t)) {
|
|
||||||
sector_cnt_.PushBack(bytes.At<uint64_t>(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
|
|
@ -182,31 +169,27 @@ uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2));
|
||||||
set_memory(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status ReadResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps));
|
||||||
|
|
||||||
set_memory(caps.At(memory_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status ReadResponse::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(0));
|
||||||
// Parse size.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(size_, message.ReadField<uint64_t>(1));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// Skip Cap.
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <glacier/status/status.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 <yunq/message_view.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,8 +17,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +34,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class ReadManyRequest {
|
class ReadManyRequest {
|
||||||
public:
|
public:
|
||||||
|
|
@ -42,8 +43,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +60,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class ReadResponse {
|
class ReadResponse {
|
||||||
public:
|
public:
|
||||||
|
|
@ -68,8 +69,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +86,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
ReadRequest yunq_request;
|
ReadRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,7 +125,8 @@ glcr::Status DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
ReadManyRequest yunq_request;
|
ReadManyRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,22 +56,12 @@ glcr::ErrorOr<glcr::Vector<DirEntry>> Ext2Driver::ReadDirectory(
|
||||||
dbgln("Reading non directory.");
|
dbgln("Reading non directory.");
|
||||||
return glcr::INVALID_ARGUMENT;
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
ASSIGN_OR_RETURN(mmth::OwnedMemoryRegion dir, ReadInode(inode_number, inode));
|
||||||
// This calculation is cursed.
|
|
||||||
uint64_t real_block_cnt =
|
|
||||||
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
|
||||||
|
|
||||||
if (real_block_cnt > 12) {
|
|
||||||
dbgln("Cant handle indirect blocks yet");
|
|
||||||
return glcr::FAILED_PRECONDITION;
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::Vector<DirEntry> directory;
|
glcr::Vector<DirEntry> directory;
|
||||||
for (uint64_t i = 0; i < real_block_cnt; i++) {
|
|
||||||
ASSIGN_OR_RETURN(mmth::OwnedMemoryRegion block,
|
uint64_t addr = dir.vaddr();
|
||||||
ext2_reader_->ReadBlock(inode->block[i]));
|
while (addr < dir.vaddr() + ext2_reader_->BlockSize()) {
|
||||||
uint64_t addr = block.vaddr();
|
|
||||||
while (addr < block.vaddr() + ext2_reader_->BlockSize()) {
|
|
||||||
DirEntry* entry = reinterpret_cast<DirEntry*>(addr);
|
DirEntry* entry = reinterpret_cast<DirEntry*>(addr);
|
||||||
directory.PushBack(*entry);
|
directory.PushBack(*entry);
|
||||||
glcr::StringView name(entry->name, entry->name_len);
|
glcr::StringView name(entry->name, entry->name_len);
|
||||||
|
|
@ -89,7 +79,6 @@ glcr::ErrorOr<glcr::Vector<DirEntry>> Ext2Driver::ReadDirectory(
|
||||||
#endif
|
#endif
|
||||||
addr += entry->record_length;
|
addr += entry->record_length;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,7 +90,14 @@ glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2Driver::ReadFile(
|
||||||
dbgln("Reading non file.");
|
dbgln("Reading non file.");
|
||||||
return glcr::INVALID_ARGUMENT;
|
return glcr::INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
return ReadInode(inode_number, inode);
|
||||||
|
}
|
||||||
|
|
||||||
|
glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2Driver::ReadInode(uint64_t inode_num,
|
||||||
|
Inode* inode) {
|
||||||
|
if (inode_cache_.Contains(inode_num)) {
|
||||||
|
return inode_cache_.at(inode_num).Duplicate();
|
||||||
|
}
|
||||||
// This calculation is cursed.
|
// This calculation is cursed.
|
||||||
uint64_t real_block_cnt =
|
uint64_t real_block_cnt =
|
||||||
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
||||||
|
|
@ -158,5 +154,7 @@ glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2Driver::ReadFile(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ext2_reader_->ReadBlocks(blocks_to_read);
|
ASSIGN_OR_RETURN(auto inode_mem, ext2_reader_->ReadBlocks(blocks_to_read));
|
||||||
|
RET_ERR(inode_cache_.Insert(glcr::Move(inode_num), inode_mem.Duplicate()));
|
||||||
|
return inode_mem;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glacier/container/hash_map.h>
|
||||||
#include <glacier/memory/move.h>
|
#include <glacier/memory/move.h>
|
||||||
#include <glacier/memory/unique_ptr.h>
|
#include <glacier/memory/unique_ptr.h>
|
||||||
#include <yellowstone/yellowstone.yunq.h>
|
#include <yellowstone/yellowstone.yunq.h>
|
||||||
|
|
@ -24,8 +25,12 @@ class Ext2Driver {
|
||||||
private:
|
private:
|
||||||
glcr::SharedPtr<Ext2BlockReader> ext2_reader_;
|
glcr::SharedPtr<Ext2BlockReader> ext2_reader_;
|
||||||
glcr::UniquePtr<InodeTable> inode_table_;
|
glcr::UniquePtr<InodeTable> inode_table_;
|
||||||
|
glcr::HashMap<uint64_t, mmth::OwnedMemoryRegion> inode_cache_;
|
||||||
|
|
||||||
Ext2Driver(const glcr::SharedPtr<Ext2BlockReader>& reader,
|
Ext2Driver(const glcr::SharedPtr<Ext2BlockReader>& reader,
|
||||||
glcr::UniquePtr<InodeTable> inode_table)
|
glcr::UniquePtr<InodeTable> inode_table)
|
||||||
: ext2_reader_(reader), inode_table_(glcr::Move(inode_table)) {}
|
: ext2_reader_(reader), inode_table_(glcr::Move(inode_table)) {}
|
||||||
|
|
||||||
|
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadInode(uint64_t inode_num,
|
||||||
|
Inode* inode);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ glcr::Status VFSClient::OpenFile(const OpenFileRequest& request, OpenFileRespons
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
@ -87,7 +88,8 @@ glcr::Status VFSClient::GetDirectory(const GetDirectoryRequest& request, Directo
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "victoriafalls.yunq.h"
|
#include "victoriafalls.yunq.h"
|
||||||
|
|
||||||
|
#include <yunq/message_view.h>
|
||||||
#include <yunq/serialize.h>
|
#include <yunq/serialize.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,22 +15,20 @@ struct ExtPointer {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status OpenFileRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status OpenFileRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(path_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -76,33 +75,27 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2));
|
||||||
set_memory(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status OpenFileResponse::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
ASSIGN_OR_RETURN(memory_, message.ReadCapability(2, caps));
|
||||||
|
|
||||||
set_memory(caps.At(memory_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status OpenFileResponse::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(path_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
|
||||||
// Parse size.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(size_, message.ReadField<uint64_t>(1));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// Skip Cap.
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -159,22 +152,20 @@ uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t of
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status GetDirectoryRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetDirectoryRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status GetDirectoryRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(path_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -221,22 +212,20 @@ uint64_t GetDirectoryRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Directory::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status Directory::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Directory::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status Directory::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse filenames.
|
// Parse filenames.
|
||||||
auto filenames_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(filenames_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_filenames(bytes.StringAt(offset + filenames_pointer.offset, filenames_pointer.length));
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <glacier/status/status.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 <yunq/message_view.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,8 +17,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +28,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class OpenFileResponse {
|
class OpenFileResponse {
|
||||||
public:
|
public:
|
||||||
|
|
@ -36,8 +37,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +54,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class GetDirectoryRequest {
|
class GetDirectoryRequest {
|
||||||
public:
|
public:
|
||||||
|
|
@ -62,8 +63,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +74,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class Directory {
|
class Directory {
|
||||||
public:
|
public:
|
||||||
|
|
@ -82,8 +83,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +94,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
OpenFileRequest yunq_request;
|
OpenFileRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,7 +125,8 @@ glcr::Status VFSServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
GetDirectoryRequest yunq_request;
|
GetDirectoryRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "voyageurs.yunq.h"
|
#include "voyageurs.yunq.h"
|
||||||
|
|
||||||
|
#include <yunq/message_view.h>
|
||||||
#include <yunq/serialize.h>
|
#include <yunq/serialize.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -14,27 +15,23 @@ struct ExtPointer {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0));
|
||||||
set_port_capability(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status KeyboardListener::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status KeyboardListener::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
uint64_t port_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(port_capability_, message.ReadCapability(0, caps));
|
||||||
|
|
||||||
set_port_capability(caps.At(port_capability_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status KeyboardListener::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status KeyboardListener::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse port_capability.
|
// Parse port_capability.
|
||||||
// Skip Cap.
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <glacier/status/status.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 <yunq/message_view.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,8 +17,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +28,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ glcr::Status VoyageursServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
||||||
|
|
||||||
|
|
||||||
KeyboardListener yunq_request;
|
KeyboardListener yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ glcr::Status YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, E
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
@ -126,7 +127,8 @@ glcr::Status YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
@ -165,7 +167,8 @@ glcr::Status YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
@ -204,7 +207,8 @@ glcr::Status YellowstoneClient::GetDenali(DenaliInfo& response) {
|
||||||
RET_ERR(buffer_.At<uint64_t>(8));
|
RET_ERR(buffer_.At<uint64_t>(8));
|
||||||
|
|
||||||
|
|
||||||
RETURN_ERROR(response.ParseFromBytes(buffer_, 16, cap_buffer_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
|
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "yellowstone.yunq.h"
|
#include "yellowstone.yunq.h"
|
||||||
|
|
||||||
|
#include <yunq/message_view.h>
|
||||||
#include <yunq/serialize.h>
|
#include <yunq/serialize.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,31 +17,25 @@ struct ExtPointer {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1));
|
||||||
set_endpoint_capability(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status RegisterEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
ASSIGN_OR_RETURN(endpoint_capability_, message.ReadCapability(1, caps));
|
||||||
|
|
||||||
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status RegisterEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status RegisterEndpointRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse endpoint_name.
|
// Parse endpoint_name.
|
||||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(endpoint_name_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
|
||||||
// Parse endpoint_capability.
|
// Parse endpoint_capability.
|
||||||
// Skip Cap.
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -93,22 +88,20 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status GetEndpointRequest::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status GetEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status GetEndpointRequest::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse endpoint_name.
|
// Parse endpoint_name.
|
||||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(endpoint_name_, message.ReadField<glcr::String>(0));
|
||||||
|
|
||||||
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -155,27 +148,23 @@ uint64_t GetEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0));
|
||||||
set_endpoint(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Endpoint::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status Endpoint::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
uint64_t endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(endpoint_, message.ReadCapability(0, caps));
|
||||||
|
|
||||||
set_endpoint(caps.At(endpoint_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status Endpoint::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status Endpoint::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse endpoint.
|
// Parse endpoint.
|
||||||
// Skip Cap.
|
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -206,29 +195,25 @@ uint64_t Endpoint::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0));
|
||||||
set_ahci_region(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status AhciInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(ahci_region_, message.ReadCapability(0, caps));
|
||||||
|
|
||||||
set_ahci_region(caps.At(ahci_region_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status AhciInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status AhciInfo::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
// Skip Cap.
|
|
||||||
// Parse region_length.
|
// Parse region_length.
|
||||||
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(region_length_, message.ReadField<uint64_t>(1));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -263,42 +248,42 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status FramebufferInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status FramebufferInfo::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse address_phys.
|
// Parse address_phys.
|
||||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
ASSIGN_OR_RETURN(address_phys_, message.ReadField<uint64_t>(0));
|
||||||
// Parse width.
|
// Parse width.
|
||||||
set_width(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(width_, message.ReadField<uint64_t>(1));
|
||||||
// Parse height.
|
// Parse height.
|
||||||
set_height(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
ASSIGN_OR_RETURN(height_, message.ReadField<uint64_t>(2));
|
||||||
// Parse pitch.
|
// Parse pitch.
|
||||||
set_pitch(bytes.At<uint64_t>(offset + header_size + (8 * 3)));
|
ASSIGN_OR_RETURN(pitch_, message.ReadField<uint64_t>(3));
|
||||||
// Parse bpp.
|
// Parse bpp.
|
||||||
set_bpp(bytes.At<uint64_t>(offset + header_size + (8 * 4)));
|
ASSIGN_OR_RETURN(bpp_, message.ReadField<uint64_t>(4));
|
||||||
// Parse memory_model.
|
// Parse memory_model.
|
||||||
set_memory_model(bytes.At<uint64_t>(offset + header_size + (8 * 5)));
|
ASSIGN_OR_RETURN(memory_model_, message.ReadField<uint64_t>(5));
|
||||||
// Parse red_mask_size.
|
// Parse red_mask_size.
|
||||||
set_red_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 6)));
|
ASSIGN_OR_RETURN(red_mask_size_, message.ReadField<uint64_t>(6));
|
||||||
// Parse red_mask_shift.
|
// Parse red_mask_shift.
|
||||||
set_red_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 7)));
|
ASSIGN_OR_RETURN(red_mask_shift_, message.ReadField<uint64_t>(7));
|
||||||
// Parse green_mask_size.
|
// Parse green_mask_size.
|
||||||
set_green_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 8)));
|
ASSIGN_OR_RETURN(green_mask_size_, message.ReadField<uint64_t>(8));
|
||||||
// Parse green_mask_shift.
|
// Parse green_mask_shift.
|
||||||
set_green_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 9)));
|
ASSIGN_OR_RETURN(green_mask_shift_, message.ReadField<uint64_t>(9));
|
||||||
// Parse blue_mask_size.
|
// Parse blue_mask_size.
|
||||||
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
|
ASSIGN_OR_RETURN(blue_mask_size_, message.ReadField<uint64_t>(10));
|
||||||
// Parse blue_mask_shift.
|
// Parse blue_mask_shift.
|
||||||
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
ASSIGN_OR_RETURN(blue_mask_shift_, message.ReadField<uint64_t>(11));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
@ -371,31 +356,27 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0));
|
||||||
set_denali_endpoint(0);
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
glcr::Status DenaliInfo::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
ASSIGN_OR_RETURN(denali_endpoint_, message.ReadCapability(0, caps));
|
||||||
|
|
||||||
set_denali_endpoint(caps.At(denali_endpoint_ptr));
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::Status DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status DenaliInfo::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
RETURN_ERROR(message.CheckHeader());
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
// Skip Cap.
|
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
ASSIGN_OR_RETURN(device_id_, message.ReadField<uint64_t>(1));
|
||||||
// Parse lba_offset.
|
// Parse lba_offset.
|
||||||
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
ASSIGN_OR_RETURN(lba_offset_, message.ReadField<uint64_t>(2));
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <glacier/status/status.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 <yunq/message_view.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,8 +19,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +33,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class GetEndpointRequest {
|
class GetEndpointRequest {
|
||||||
public:
|
public:
|
||||||
|
|
@ -41,8 +42,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +53,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class Endpoint {
|
class Endpoint {
|
||||||
public:
|
public:
|
||||||
|
|
@ -61,8 +62,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +73,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class AhciInfo {
|
class AhciInfo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -81,8 +82,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +96,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class FramebufferInfo {
|
class FramebufferInfo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -104,8 +105,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +149,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
class DenaliInfo {
|
class DenaliInfo {
|
||||||
public:
|
public:
|
||||||
|
|
@ -157,8 +158,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +175,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
RegisterEndpointRequest yunq_request;
|
RegisterEndpointRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -124,7 +125,8 @@ glcr::Status YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& reques
|
||||||
|
|
||||||
|
|
||||||
GetEndpointRequest yunq_request;
|
GetEndpointRequest yunq_request;
|
||||||
RETURN_ERROR(yunq_request.ParseFromBytes(request, kHeaderSize, req_caps));
|
yunq::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ glcr::Status {{interface.name}}Client::{{method.name}}(const {{method.request}}&
|
||||||
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_));
|
yunq::MessageView resp_view(buffer_, 16);
|
||||||
|
RETURN_ERROR(response.ParseFromBytes(resp_view, cap_buffer_));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Generated file -- DO NOT MODIFY.
|
// Generated file -- DO NOT MODIFY.
|
||||||
#include "{{file}}.h"
|
#include "{{file}}.h"
|
||||||
|
|
||||||
|
#include <yunq/message_view.h>
|
||||||
#include <yunq/serialize.h>
|
#include <yunq/serialize.h>
|
||||||
|
|
||||||
{% if package != None %}
|
{% if package != None %}
|
||||||
|
|
@ -18,62 +19,54 @@ struct ExtPointer {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
{%- for message in messages %}
|
{%- for message in messages %}
|
||||||
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message) {
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
{%- for field in message.fields %}
|
||||||
{%- if field.type == Type.CAPABILITY %}
|
{%- if field.type == Type.CAPABILITY %}
|
||||||
// Parse {{field.name}}.
|
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
|
||||||
set_{{field.name}}(0);
|
|
||||||
{%- endif %}
|
|
||||||
{%- endfor %}
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::Status {{message.name}}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
|
||||||
RETURN_ERROR(ParseFromBytesInternal(bytes, offset));
|
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
|
||||||
{%- if field.type == Type.CAPABILITY %}
|
|
||||||
// Parse {{field.name}}.
|
|
||||||
uint64_t {{field.name}}_ptr = bytes.At<uint64_t>(offset + header_size + (8 * {{loop.index0}}));
|
|
||||||
|
|
||||||
set_{{field.name}}(caps.At({{field.name}}_ptr));
|
|
||||||
{%- endif %}
|
|
||||||
{%- endfor %}
|
|
||||||
return glcr::Status::Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
glcr::Status {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
|
||||||
RETURN_ERROR(yunq::CheckHeader(bytes, offset));
|
|
||||||
|
|
||||||
{%- for field in message.fields %}
|
|
||||||
// Parse {{field.name}}.
|
|
||||||
{%- if not field.repeated %}
|
{%- if not field.repeated %}
|
||||||
{%- if field.type == Type.U64 %}
|
// Parse {{field.name}}.
|
||||||
set_{{field.name}}(bytes.At<uint64_t>(offset + header_size + (8 * {{loop.index0}})));
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadCapability({{loop.index0}}));
|
||||||
{%- elif field.type == Type.I64 %}
|
|
||||||
set_{{field.name}}(bytes.At<int64_t>(offset + header_size + (8 * {{loop.index0}})));
|
|
||||||
{%- elif field.type == Type.STRING %}
|
|
||||||
auto {{field.name}}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {{loop.index0}}));
|
|
||||||
|
|
||||||
set_{{field.name}}(bytes.StringAt(offset + {{field.name}}_pointer.offset, {{field.name}}_pointer.length));
|
|
||||||
{%- elif field.type == Type.CAPABILITY %}
|
|
||||||
// Skip Cap.
|
|
||||||
{%- else %}
|
{%- else %}
|
||||||
// TODO: Unimplemented parsing {{field.type}}
|
// Parse {{field.name}}.
|
||||||
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeatedCapability({{loop.index0}}));
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- else %}
|
{%- endif %}
|
||||||
auto {{field.name}}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {{loop.index0}}));
|
{%- endfor %}
|
||||||
|
return glcr::Status::Ok();
|
||||||
{{field.name}}_.Resize({{field.name}}_pointer.length / sizeof({{field.cpp_type()}}));
|
|
||||||
for (uint64_t i = offset + {{field.name}}_pointer.offset;
|
|
||||||
i < offset + {{field.name}}_pointer.offset + {{field.name}}_pointer.length;
|
|
||||||
i += sizeof({{field.cpp_type()}})) {
|
|
||||||
{{field.name}}_.PushBack(bytes.At<{{field.cpp_type()}}>(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glcr::Status {{message.name}}::ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer& caps) {
|
||||||
|
RETURN_ERROR(ParseFromBytesInternal(message));
|
||||||
|
|
||||||
|
{%- for field in message.fields %}
|
||||||
|
{%- if field.type == Type.CAPABILITY %}
|
||||||
|
{%- if not field.repeated %}
|
||||||
|
// Parse {{field.name}}.
|
||||||
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadCapability({{loop.index0}}, caps));
|
||||||
|
{%- else %}
|
||||||
|
// Parse {{field.name}}.
|
||||||
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeatedCapability({{loop.index0}}, caps));
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
return glcr::Status::Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
glcr::Status {{message.name}}::ParseFromBytesInternal(const yunq::MessageView& message) {
|
||||||
|
RETURN_ERROR(message.CheckHeader());
|
||||||
|
|
||||||
|
{%- for field in message.fields %}
|
||||||
|
// Parse {{field.name}}.
|
||||||
|
{%- if field.type != Type.CAPABILITY %}
|
||||||
|
|
||||||
|
{%- if not field.repeated %}
|
||||||
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadField<{{field.cpp_type()}}>({{loop.index0}}));
|
||||||
|
{%- else %}
|
||||||
|
ASSIGN_OR_RETURN({{field.name}}_, message.ReadRepeated<{{field.cpp_type()}}>({{loop.index0}}));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
return glcr::Status::Ok();
|
return glcr::Status::Ok();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <glacier/status/status.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 <yunq/message_view.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
|
|
||||||
{% if package != None %}
|
{% if package != None %}
|
||||||
|
|
@ -20,8 +21,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);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message);
|
||||||
[[nodiscard]] glcr::Status ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
[[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, 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 +46,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);
|
glcr::Status ParseFromBytesInternal(const yunq::MessageView& message);
|
||||||
};
|
};
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ 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::MessageView request_view(request, kHeaderSize);
|
||||||
|
RETURN_ERROR(yunq_request.ParseFromBytes(request_view, req_caps));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if method.response != None %}
|
{% if method.response != None %}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,8 @@ void DumpModules() {
|
||||||
dbgln("[boot] Dumping bootloader modules.");
|
dbgln("[boot] Dumping bootloader modules.");
|
||||||
for (uint64_t i = 0; i < resp.module_count; i++) {
|
for (uint64_t i = 0; i < resp.module_count; i++) {
|
||||||
const limine_file& file = *resp.modules[i];
|
const limine_file& file = *resp.modules[i];
|
||||||
dbgln(" {},{x},{}", file.path, file.address, file.size);
|
dbgln(" {},{x},{x}", glcr::String(file.path), (uint64_t)file.address,
|
||||||
|
file.size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +112,8 @@ void WriteInitProgram(glcr::RefPtr<Port> port, glcr::String name, uint64_t id) {
|
||||||
const limine_file& prog = GetInitProgram(name);
|
const limine_file& prog = GetInitProgram(name);
|
||||||
glcr::RefPtr<VariableMemoryObject> prog_vmmo =
|
glcr::RefPtr<VariableMemoryObject> prog_vmmo =
|
||||||
glcr::MakeRefCounted<VariableMemoryObject>(prog.size);
|
glcr::MakeRefCounted<VariableMemoryObject>(prog.size);
|
||||||
|
// TODO: These seem to be page aligned we should just construct an object
|
||||||
|
// around them.
|
||||||
prog_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog.address),
|
prog_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog.address),
|
||||||
prog.size);
|
prog.size);
|
||||||
port->WriteKernel(id, MakeRefCounted<Capability>(prog_vmmo));
|
port->WriteKernel(id, MakeRefCounted<Capability>(prog_vmmo));
|
||||||
|
|
@ -121,6 +124,10 @@ glcr::ErrorCode WritePciVmmo(glcr::RefPtr<Port> port, uint64_t id) {
|
||||||
auto vmmo =
|
auto vmmo =
|
||||||
glcr::MakeRefCounted<ViewMemoryObject>(config.base, config.offset);
|
glcr::MakeRefCounted<ViewMemoryObject>(config.base, config.offset);
|
||||||
|
|
||||||
|
#if K_INIT_DEBUG
|
||||||
|
dbgln("PCI Configuration found at: {x}:{x}", config.base, config.offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
port->WriteKernel(id, MakeRefCounted<Capability>(vmmo));
|
port->WriteKernel(id, MakeRefCounted<Capability>(vmmo));
|
||||||
|
|
||||||
return glcr::OK;
|
return glcr::OK;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue