diff --git a/lib/glacier/container/vector.h b/lib/glacier/container/vector.h index 5544436..b4b994c 100644 --- a/lib/glacier/container/vector.h +++ b/lib/glacier/container/vector.h @@ -47,6 +47,7 @@ class Vector { template void EmplaceBack(Args&&... args); + T& PeekBack(); T&& PopBack(); typedef ArrayIterator Iterator; @@ -130,6 +131,11 @@ void Vector::EmplaceBack(Args&&... args) { data_[size_++] = T(args...); } +template +T& Vector::PeekBack() { + return data_[size_ - 1]; +} + template T&& Vector::PopBack() { size_--; diff --git a/lib/yunq/message_view.cpp b/lib/yunq/message_view.cpp index 5e74430..960f8c4 100644 --- a/lib/yunq/message_view.cpp +++ b/lib/yunq/message_view.cpp @@ -19,6 +19,10 @@ glcr::Status MessageView::CheckHeader() const { return glcr::Status::Ok(); } +uint32_t MessageView::MessageLength() const { + return buffer_.At(offset_ + 8); +} + template <> glcr::ErrorOr MessageView::ReadField( uint64_t field_index) const { diff --git a/lib/yunq/message_view.h b/lib/yunq/message_view.h index 069c00c..78a11ea 100644 --- a/lib/yunq/message_view.h +++ b/lib/yunq/message_view.h @@ -16,6 +16,7 @@ class MessageView { : buffer_(buffer), offset_(offset) {} [[nodiscard]] glcr::Status CheckHeader() const; + uint32_t MessageLength() const; // TODO: Implement glcr::StatusOr template @@ -31,6 +32,10 @@ class MessageView { template glcr::Status ReadMessage(uint64_t field_index, T& message) const; + template + glcr::Status ReadRepeatedMessage(uint64_t field_index, + glcr::Vector& messages) const; + private: const glcr::ByteBuffer& buffer_; uint64_t offset_; @@ -61,4 +66,22 @@ glcr::Status MessageView::ReadMessage(uint64_t field_index, T& message) const { return message.ParseFromBytes(subview); } +template +glcr::Status MessageView::ReadRepeatedMessage(uint64_t field_index, + glcr::Vector& messages) const { + ExtensionPointer ptr = + buffer_.At(field_offset(field_index)); + + uint64_t ext_offset = ptr.offset; + + while (ext_offset < ptr.offset + ptr.length) { + MessageView subview(buffer_, offset_ + ext_offset); + messages.EmplaceBack(); + RETURN_ERROR(messages.PeekBack().ParseFromBytes(subview)); + ext_offset += subview.MessageLength(); + } + + return glcr::Status::Ok(); +} + } // namespace yunq diff --git a/lib/yunq/serialize.h b/lib/yunq/serialize.h index ac0b2ff..b19ea4b 100644 --- a/lib/yunq/serialize.h +++ b/lib/yunq/serialize.h @@ -41,6 +41,9 @@ class Serializer { template void WriteMessage(uint64_t field_index, const T& value); + template + void WriteRepeatedMessage(uint64_t field_index, const glcr::Vector& value); + void WriteHeader(); uint64_t size() const { return next_extension_; } @@ -90,4 +93,32 @@ void Serializer::WriteMessage(uint64_t field_index, const T& value) { buffer_.WriteAt(field_offset(field_index), ptr); } +template +void Serializer::WriteRepeatedMessage(uint64_t field_index, + const glcr::Vector& value) { + uint64_t next_offset = next_extension_; + uint64_t length = 0; + + for (T& message : value) { + uint64_t msg_length = 0; + if (caps_) { + msg_length = message.SerializeToBytes(buffer_, offset_ + next_offset, + caps_.value().get()); + } else { + msg_length = message.SerializeToBytes(buffer_, offset_ + next_offset); + } + length += msg_length; + next_offset += msg_length; + } + + ExtensionPointer ptr{ + .offset = (uint32_t)next_extension_, + .length = (uint32_t)length, + }; + + next_extension_ += length; + + buffer_.WriteAt(field_offset(field_index), ptr); +} + } // namespace yunq diff --git a/sys/denali/denali_server.cpp b/sys/denali/denali_server.cpp index 1b3cbc7..c245bec 100644 --- a/sys/denali/denali_server.cpp +++ b/sys/denali/denali_server.cpp @@ -35,26 +35,21 @@ glcr::Status DenaliServer::HandleReadMany(const ReadManyRequest& req, ReadResponse& resp) { ASSIGN_OR_RETURN(AhciPort * device, driver_.GetDevice(req.device_id())); - if (req.lba().size() != req.sector_cnt().size()) { - return glcr::InvalidArgument("LBA and Sector Cnt must be the same length."); - } - uint64_t sector_cnt = 0; - for (uint64_t cnt : req.sector_cnt()) { - sector_cnt += cnt; + for (auto& block : req.blocks()) { + sector_cnt += block.size(); } uint64_t region_paddr; mmth::OwnedMemoryRegion region = mmth::OwnedMemoryRegion::ContiguousPhysical( sector_cnt * 512, ®ion_paddr); - for (uint64_t i = 0; i < req.lba().size(); i++) { - uint64_t lba = req.lba().at(i); - uint64_t size = req.sector_cnt().at(i); - ASSIGN_OR_RETURN(auto semaphore, - device->IssueRead(lba, size, region_paddr)); + for (auto& block : req.blocks()) { + ASSIGN_OR_RETURN( + auto semaphore, + device->IssueRead(block.lba(), block.size(), region_paddr)); semaphore->Wait(); - region_paddr += size * 512; + region_paddr += block.size() * 512; } resp.set_device_id(req.device_id()); diff --git a/sys/denali/lib/denali/denali.yunq b/sys/denali/lib/denali/denali.yunq index cc3225b..450870c 100644 --- a/sys/denali/lib/denali/denali.yunq +++ b/sys/denali/lib/denali/denali.yunq @@ -16,10 +16,7 @@ message ReadRequest { message ReadManyRequest { u64 device_id; - // FIXME: Add repeated message fields. - // Must be the same length. - repeated u64 lba; - repeated u64 sector_cnt; + repeated DiskBlock blocks; } message ReadResponse { diff --git a/sys/denali/lib/denali/denali.yunq.cpp b/sys/denali/lib/denali/denali.yunq.cpp index 81e82f0..de259cc 100644 --- a/sys/denali/lib/denali/denali.yunq.cpp +++ b/sys/denali/lib/denali/denali.yunq.cpp @@ -109,33 +109,28 @@ glcr::Status ReadManyRequest::ParseFromBytesInternal(const yunq::MessageView& me RETURN_ERROR(message.CheckHeader()); // Parse device_id. ASSIGN_OR_RETURN(device_id_, message.ReadField(0)); - // Parse lba. - ASSIGN_OR_RETURN(lba_, message.ReadRepeated(1)); - - // Parse sector_cnt. - ASSIGN_OR_RETURN(sector_cnt_, message.ReadRepeated(2)); + // Parse blocks. + message.ReadRepeatedMessage(1, blocks_); return glcr::Status::Ok(); } uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const { - yunq::Serializer serializer(bytes, offset, 3); + yunq::Serializer serializer(bytes, offset, 2); return SerializeInternal(serializer); } uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const { - yunq::Serializer serializer(bytes, offset, 3, caps); + yunq::Serializer serializer(bytes, offset, 2, caps); return SerializeInternal(serializer); } uint64_t ReadManyRequest::SerializeInternal(yunq::Serializer& serializer) const { // Write device_id. serializer.WriteField(0, device_id_); - // Write lba. - serializer.WriteRepeated(1, lba_); - // Write sector_cnt. - serializer.WriteRepeated(2, sector_cnt_); + // Write blocks. + serializer.WriteRepeatedMessage(1, blocks_); serializer.WriteHeader(); diff --git a/sys/denali/lib/denali/denali.yunq.h b/sys/denali/lib/denali/denali.yunq.h index 2707234..7874c91 100644 --- a/sys/denali/lib/denali/denali.yunq.h +++ b/sys/denali/lib/denali/denali.yunq.h @@ -16,15 +16,20 @@ class DiskBlock { DiskBlock() {} // Delete copy and move until implemented. DiskBlock(const DiskBlock&) = delete; - DiskBlock(DiskBlock&&) = delete; + DiskBlock(DiskBlock&&) = default; + DiskBlock& operator=(DiskBlock&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const uint64_t& lba() const { return lba_; } + uint64_t& mutable_lba() { return lba_; } void set_lba(const uint64_t& value) { lba_ = value; } + const uint64_t& size() const { return size_; } + uint64_t& mutable_size() { return size_; } void set_size(const uint64_t& value) { size_ = value; } private: @@ -41,14 +46,18 @@ class ReadRequest { ReadRequest() {} // Delete copy and move until implemented. ReadRequest(const ReadRequest&) = delete; - ReadRequest(ReadRequest&&) = delete; + ReadRequest(ReadRequest&&) = default; + ReadRequest& operator=(ReadRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const uint64_t& device_id() const { return device_id_; } - void set_device_id(const uint64_t& value) { device_id_ = value; } + uint64_t& mutable_device_id() { return device_id_; } + void set_device_id(const uint64_t& value) { device_id_ = value; } + const DiskBlock& block() const { return block_; } DiskBlock& mutable_block() { return block_; } @@ -66,23 +75,25 @@ class ReadManyRequest { ReadManyRequest() {} // Delete copy and move until implemented. ReadManyRequest(const ReadManyRequest&) = delete; - ReadManyRequest(ReadManyRequest&&) = delete; + ReadManyRequest(ReadManyRequest&&) = default; + ReadManyRequest& operator=(ReadManyRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const uint64_t& device_id() const { return device_id_; } + uint64_t& mutable_device_id() { return device_id_; } void set_device_id(const uint64_t& value) { device_id_ = value; } - const glcr::Vector& lba() const { return lba_; } - void add_lba(const uint64_t& value) { lba_.PushBack(value); } - const glcr::Vector& sector_cnt() const { return sector_cnt_; } - void add_sector_cnt(const uint64_t& value) { sector_cnt_.PushBack(value); } + + const glcr::Vector& blocks() const { return blocks_; } + glcr::Vector& mutable_blocks() { return blocks_; } + void add_blocks(DiskBlock&& value) { blocks_.PushBack(glcr::Move(value)); } private: uint64_t device_id_; - glcr::Vector lba_; - glcr::Vector sector_cnt_; + glcr::Vector blocks_; // Parses everything except for caps. glcr::Status ParseFromBytesInternal(const yunq::MessageView& message); @@ -94,17 +105,24 @@ class ReadResponse { ReadResponse() {} // Delete copy and move until implemented. ReadResponse(const ReadResponse&) = delete; - ReadResponse(ReadResponse&&) = delete; + ReadResponse(ReadResponse&&) = default; + ReadResponse& operator=(ReadResponse&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const uint64_t& device_id() const { return device_id_; } + uint64_t& mutable_device_id() { return device_id_; } void set_device_id(const uint64_t& value) { device_id_ = value; } + const uint64_t& size() const { return size_; } + uint64_t& mutable_size() { return size_; } void set_size(const uint64_t& value) { size_ = value; } + const z_cap_t& memory() const { return memory_; } + z_cap_t& mutable_memory() { return memory_; } void set_memory(const z_cap_t& value) { memory_ = value; } private: diff --git a/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp b/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp index 9de13f8..80308c6 100644 --- a/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp +++ b/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp @@ -94,8 +94,10 @@ glcr::ErrorOr Ext2BlockReader::ReadBlocks( i++; curr_run_len++; } - req.add_lba(curr_start); - req.add_sector_cnt(curr_run_len * SectorsPerBlock()); + DiskBlock block; + block.set_lba(curr_start); + block.set_size(curr_run_len * SectorsPerBlock()); + req.add_blocks(glcr::Move(block)); } ReadResponse resp; auto status = denali_.ReadMany(req, resp); diff --git a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h index aaf87c9..52daf7a 100644 --- a/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h +++ b/sys/victoriafalls/lib/victoriafalls/victoriafalls.yunq.h @@ -16,13 +16,16 @@ class OpenFileRequest { OpenFileRequest() {} // Delete copy and move until implemented. OpenFileRequest(const OpenFileRequest&) = delete; - OpenFileRequest(OpenFileRequest&&) = delete; + OpenFileRequest(OpenFileRequest&&) = default; + OpenFileRequest& operator=(OpenFileRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& path() const { return path_; } + glcr::String& mutable_path() { return path_; } void set_path(const glcr::String& value) { path_ = value; } private: @@ -38,17 +41,24 @@ class OpenFileResponse { OpenFileResponse() {} // Delete copy and move until implemented. OpenFileResponse(const OpenFileResponse&) = delete; - OpenFileResponse(OpenFileResponse&&) = delete; + OpenFileResponse(OpenFileResponse&&) = default; + OpenFileResponse& operator=(OpenFileResponse&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& path() const { return path_; } + glcr::String& mutable_path() { return path_; } void set_path(const glcr::String& value) { path_ = value; } + const uint64_t& size() const { return size_; } + uint64_t& mutable_size() { return size_; } void set_size(const uint64_t& value) { size_ = value; } + const z_cap_t& memory() const { return memory_; } + z_cap_t& mutable_memory() { return memory_; } void set_memory(const z_cap_t& value) { memory_ = value; } private: @@ -66,13 +76,16 @@ class GetDirectoryRequest { GetDirectoryRequest() {} // Delete copy and move until implemented. GetDirectoryRequest(const GetDirectoryRequest&) = delete; - GetDirectoryRequest(GetDirectoryRequest&&) = delete; + GetDirectoryRequest(GetDirectoryRequest&&) = default; + GetDirectoryRequest& operator=(GetDirectoryRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& path() const { return path_; } + glcr::String& mutable_path() { return path_; } void set_path(const glcr::String& value) { path_ = value; } private: @@ -88,13 +101,16 @@ class Directory { Directory() {} // Delete copy and move until implemented. Directory(const Directory&) = delete; - Directory(Directory&&) = delete; + Directory(Directory&&) = default; + Directory& operator=(Directory&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& filenames() const { return filenames_; } + glcr::String& mutable_filenames() { return filenames_; } void set_filenames(const glcr::String& value) { filenames_ = value; } private: diff --git a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h index 2b2c618..af8eca1 100644 --- a/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h +++ b/sys/voyageurs/lib/voyageurs/voyageurs.yunq.h @@ -16,13 +16,16 @@ class KeyboardListener { KeyboardListener() {} // Delete copy and move until implemented. KeyboardListener(const KeyboardListener&) = delete; - KeyboardListener(KeyboardListener&&) = delete; + KeyboardListener(KeyboardListener&&) = default; + KeyboardListener& operator=(KeyboardListener&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const z_cap_t& port_capability() const { return port_capability_; } + z_cap_t& mutable_port_capability() { return port_capability_; } void set_port_capability(const z_cap_t& value) { port_capability_ = value; } private: diff --git a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h index 93f05e8..fff090e 100644 --- a/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h +++ b/sys/yellowstone/lib/yellowstone/yellowstone.yunq.h @@ -18,15 +18,20 @@ class RegisterEndpointRequest { RegisterEndpointRequest() {} // Delete copy and move until implemented. RegisterEndpointRequest(const RegisterEndpointRequest&) = delete; - RegisterEndpointRequest(RegisterEndpointRequest&&) = delete; + RegisterEndpointRequest(RegisterEndpointRequest&&) = default; + RegisterEndpointRequest& operator=(RegisterEndpointRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& endpoint_name() const { return endpoint_name_; } + glcr::String& mutable_endpoint_name() { return endpoint_name_; } void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; } + const z_cap_t& endpoint_capability() const { return endpoint_capability_; } + z_cap_t& mutable_endpoint_capability() { return endpoint_capability_; } void set_endpoint_capability(const z_cap_t& value) { endpoint_capability_ = value; } private: @@ -43,13 +48,16 @@ class GetEndpointRequest { GetEndpointRequest() {} // Delete copy and move until implemented. GetEndpointRequest(const GetEndpointRequest&) = delete; - GetEndpointRequest(GetEndpointRequest&&) = delete; + GetEndpointRequest(GetEndpointRequest&&) = default; + GetEndpointRequest& operator=(GetEndpointRequest&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const glcr::String& endpoint_name() const { return endpoint_name_; } + glcr::String& mutable_endpoint_name() { return endpoint_name_; } void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; } private: @@ -65,13 +73,16 @@ class Endpoint { Endpoint() {} // Delete copy and move until implemented. Endpoint(const Endpoint&) = delete; - Endpoint(Endpoint&&) = delete; + Endpoint(Endpoint&&) = default; + Endpoint& operator=(Endpoint&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const z_cap_t& endpoint() const { return endpoint_; } + z_cap_t& mutable_endpoint() { return endpoint_; } void set_endpoint(const z_cap_t& value) { endpoint_ = value; } private: @@ -87,15 +98,20 @@ class AhciInfo { AhciInfo() {} // Delete copy and move until implemented. AhciInfo(const AhciInfo&) = delete; - AhciInfo(AhciInfo&&) = delete; + AhciInfo(AhciInfo&&) = default; + AhciInfo& operator=(AhciInfo&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const z_cap_t& ahci_region() const { return ahci_region_; } + z_cap_t& mutable_ahci_region() { return ahci_region_; } void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; } + const uint64_t& region_length() const { return region_length_; } + uint64_t& mutable_region_length() { return region_length_; } void set_region_length(const uint64_t& value) { region_length_ = value; } private: @@ -112,35 +128,60 @@ class FramebufferInfo { FramebufferInfo() {} // Delete copy and move until implemented. FramebufferInfo(const FramebufferInfo&) = delete; - FramebufferInfo(FramebufferInfo&&) = delete; + FramebufferInfo(FramebufferInfo&&) = default; + FramebufferInfo& operator=(FramebufferInfo&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const uint64_t& address_phys() const { return address_phys_; } + uint64_t& mutable_address_phys() { return address_phys_; } void set_address_phys(const uint64_t& value) { address_phys_ = value; } + const uint64_t& width() const { return width_; } + uint64_t& mutable_width() { return width_; } void set_width(const uint64_t& value) { width_ = value; } + const uint64_t& height() const { return height_; } + uint64_t& mutable_height() { return height_; } void set_height(const uint64_t& value) { height_ = value; } + const uint64_t& pitch() const { return pitch_; } + uint64_t& mutable_pitch() { return pitch_; } void set_pitch(const uint64_t& value) { pitch_ = value; } + const uint64_t& bpp() const { return bpp_; } + uint64_t& mutable_bpp() { return bpp_; } void set_bpp(const uint64_t& value) { bpp_ = value; } + const uint64_t& memory_model() const { return memory_model_; } + uint64_t& mutable_memory_model() { return memory_model_; } void set_memory_model(const uint64_t& value) { memory_model_ = value; } + const uint64_t& red_mask_size() const { return red_mask_size_; } + uint64_t& mutable_red_mask_size() { return red_mask_size_; } void set_red_mask_size(const uint64_t& value) { red_mask_size_ = value; } + const uint64_t& red_mask_shift() const { return red_mask_shift_; } + uint64_t& mutable_red_mask_shift() { return red_mask_shift_; } void set_red_mask_shift(const uint64_t& value) { red_mask_shift_ = value; } + const uint64_t& green_mask_size() const { return green_mask_size_; } + uint64_t& mutable_green_mask_size() { return green_mask_size_; } void set_green_mask_size(const uint64_t& value) { green_mask_size_ = value; } + const uint64_t& green_mask_shift() const { return green_mask_shift_; } + uint64_t& mutable_green_mask_shift() { return green_mask_shift_; } void set_green_mask_shift(const uint64_t& value) { green_mask_shift_ = value; } + const uint64_t& blue_mask_size() const { return blue_mask_size_; } + uint64_t& mutable_blue_mask_size() { return blue_mask_size_; } void set_blue_mask_size(const uint64_t& value) { blue_mask_size_ = value; } + const uint64_t& blue_mask_shift() const { return blue_mask_shift_; } + uint64_t& mutable_blue_mask_shift() { return blue_mask_shift_; } void set_blue_mask_shift(const uint64_t& value) { blue_mask_shift_ = value; } private: @@ -167,17 +208,24 @@ class DenaliInfo { DenaliInfo() {} // Delete copy and move until implemented. DenaliInfo(const DenaliInfo&) = delete; - DenaliInfo(DenaliInfo&&) = delete; + DenaliInfo(DenaliInfo&&) = default; + DenaliInfo& operator=(DenaliInfo&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[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, glcr::CapBuffer&) const; + const z_cap_t& denali_endpoint() const { return denali_endpoint_; } + z_cap_t& mutable_denali_endpoint() { return denali_endpoint_; } void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; } + const uint64_t& device_id() const { return device_id_; } + uint64_t& mutable_device_id() { return device_id_; } void set_device_id(const uint64_t& value) { device_id_ = value; } + const uint64_t& lba_offset() const { return lba_offset_; } + uint64_t& mutable_lba_offset() { return lba_offset_; } void set_lba_offset(const uint64_t& value) { lba_offset_ = value; } private: diff --git a/yunq/message.cpp.jinja b/yunq/message.cpp.jinja index cf96c8c..d58c707 100644 --- a/yunq/message.cpp.jinja +++ b/yunq/message.cpp.jinja @@ -63,7 +63,7 @@ glcr::Status {{message.name}}::ParseFromBytesInternal(const yunq::MessageView& m {%- if not field.repeated %} message.ReadMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); {%- else %} - message.ReadMessageRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); + message.ReadRepeatedMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); {% endif %} {%- elif field.type != Type.CAPABILITY %} @@ -105,10 +105,12 @@ uint64_t {{message.name}}::SerializeInternal(yunq::Serializer& serializer) const {%- else %} -{%- if field.type != Type.CAPABILITY %} - serializer.WriteRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); -{%- else %} +{%- if field.type == Type.MESSAGE %} + serializer.WriteRepeatedMessage<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); +{%- elif field.type != Type.CAPABILITY %} serializer.WriteRepeatedCapability({{field.number}}, {{field.name}}_); +{%- else %} + serializer.WriteRepeated<{{field.cpp_type()}}>({{field.number}}, {{field.name}}_); {%- endif %} {%- endif %} diff --git a/yunq/message.h.jinja b/yunq/message.h.jinja index 5274771..2cca2c2 100644 --- a/yunq/message.h.jinja +++ b/yunq/message.h.jinja @@ -20,7 +20,8 @@ class {{message.name}} { {{message.name}}() {} // Delete copy and move until implemented. {{message.name}}(const {{message.name}}&) = delete; - {{message.name}}({{message.name}}&&) = delete; + {{message.name}}({{message.name}}&&) = default; + {{message.name}}& operator=({{message.name}}&&) = default; [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message); [[nodiscard]] glcr::Status ParseFromBytes(const yunq::MessageView& message, const glcr::CapBuffer&); @@ -28,19 +29,24 @@ class {{message.name}} { uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const; {%- for field in message.fields %} - {%- if field.type == Type.MESSAGE %} + {%- if not field.repeated %} + const {{field.cpp_type()}}& {{field.name}}() const { return {{field.name}}_; } {{field.cpp_type()}}& mutable_{{field.name}}() { return {{field.name}}_; } + {%- if field.type != Type.MESSAGE %} + void set_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_ = value; } + {%- endif %} + {%- else %} - {%- if not field.repeated %} - const {{field.cpp_type()}}& {{field.name}}() const { return {{field.name}}_; } - void set_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_ = value; } - {%- else %} const glcr::Vector<{{field.cpp_type()}}>& {{field.name}}() const { return {{field.name}}_; } + glcr::Vector<{{field.cpp_type()}}>& mutable_{{field.name}}() { return {{field.name}}_; } + + {%- if field.type != Type.MESSAGE %} void add_{{field.name}}(const {{field.cpp_type()}}& value) { {{field.name}}_.PushBack(value); } {%- endif %} + void add_{{field.name}}({{field.cpp_type()}}&& value) { {{field.name}}_.PushBack(glcr::Move(value)); } {%- endif %} {%- endfor %}