[Yellowstone] Move registration service to the main yellowstone service
This commit is contained in:
parent
b516087922
commit
05e12aaa7d
13 changed files with 143 additions and 156 deletions
|
|
@ -1,17 +1,18 @@
|
|||
interface Yellowstone {
|
||||
method GetRegister(Empty) -> (RegisterInfo);
|
||||
method RegisterEndpoint(RegisterEndpointRequest) -> (Empty);
|
||||
method GetAhciInfo(Empty) -> (AhciInfo);
|
||||
method GetDenali(Empty) -> (DenaliInfo);
|
||||
}
|
||||
|
||||
message RegisterEndpointRequest {
|
||||
string endpoint_name;
|
||||
capability endpoint_capability;
|
||||
}
|
||||
|
||||
message Empty {
|
||||
|
||||
}
|
||||
|
||||
message RegisterInfo {
|
||||
capability register_port;
|
||||
}
|
||||
|
||||
message AhciInfo {
|
||||
capability ahci_region;
|
||||
u64 region_length;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetRegister(const Empty& request, RegisterInfo& response) {
|
||||
glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response) {
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ glcr::ErrorCode YellowstoneClient::GetRegister(const Empty& request, RegisterInf
|
|||
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
||||
buffer_.WriteAt<uint64_t>(8, 0);
|
||||
|
||||
// FIXME: We need to reset the cap buffer here.
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& r
|
|||
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
||||
buffer_.WriteAt<uint64_t>(8, 1);
|
||||
|
||||
// FIXME: We need to reset the cap buffer here.
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& r
|
|||
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
||||
buffer_.WriteAt<uint64_t>(8, 2);
|
||||
|
||||
// FIXME: We need to reset the cap buffer here.
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class YellowstoneClient {
|
|||
z_cap_t Capability() { return endpoint_; }
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetRegister(const Empty& request, RegisterInfo& response);
|
||||
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetAhciInfo(const Empty& request, AhciInfo& response);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,77 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
|||
}
|
||||
|
||||
} // namespace
|
||||
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse endpoint_name.
|
||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
||||
// Parse endpoint_capability.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_endpoint_capability(0);
|
||||
}
|
||||
|
||||
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
// Parse endpoint_name.
|
||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
||||
// Parse endpoint_capability.
|
||||
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
||||
|
||||
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
||||
}
|
||||
|
||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write endpoint_name.
|
||||
ExtPointer endpoint_name_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)endpoint_name().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, endpoint_name());
|
||||
next_extension += endpoint_name_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
||||
// Write endpoint_capability.
|
||||
// FIXME: Implement inbuffer capabilities.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), 0);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write endpoint_name.
|
||||
ExtPointer endpoint_name_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)endpoint_name().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, endpoint_name());
|
||||
next_extension += endpoint_name_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), endpoint_name_ptr);
|
||||
// Write endpoint_capability.
|
||||
caps.WriteAt(next_cap, endpoint_capability());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), next_cap++);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
}
|
||||
|
|
@ -55,47 +126,6 @@ uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr:
|
|||
|
||||
return next_extension;
|
||||
}
|
||||
void RegisterInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse register_port.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_register_port(0);
|
||||
}
|
||||
|
||||
void RegisterInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
// Parse register_port.
|
||||
uint64_t register_port_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||
|
||||
set_register_port(caps.At(register_port_ptr));
|
||||
}
|
||||
|
||||
uint64_t RegisterInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 1;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write register_port.
|
||||
// FIXME: Implement inbuffer capabilities.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 0);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t RegisterInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 1;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write register_port.
|
||||
caps.WriteAt(next_cap, register_port());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), next_cap++);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse ahci_region.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,27 @@
|
|||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <ztypes.h>
|
||||
class RegisterEndpointRequest {
|
||||
public:
|
||||
RegisterEndpointRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
RegisterEndpointRequest(const RegisterEndpointRequest&) = delete;
|
||||
RegisterEndpointRequest(RegisterEndpointRequest&&) = delete;
|
||||
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
glcr::String endpoint_name() const { return endpoint_name_; }
|
||||
void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; }
|
||||
z_cap_t endpoint_capability() const { return endpoint_capability_; }
|
||||
void set_endpoint_capability(const z_cap_t& value) { endpoint_capability_ = value; }
|
||||
|
||||
private:
|
||||
glcr::String endpoint_name_;
|
||||
z_cap_t endpoint_capability_;
|
||||
|
||||
};
|
||||
class Empty {
|
||||
public:
|
||||
Empty() {}
|
||||
|
|
@ -19,24 +40,6 @@ class Empty {
|
|||
|
||||
private:
|
||||
|
||||
};
|
||||
class RegisterInfo {
|
||||
public:
|
||||
RegisterInfo() {}
|
||||
// Delete copy and move until implemented.
|
||||
RegisterInfo(const RegisterInfo&) = delete;
|
||||
RegisterInfo(RegisterInfo&&) = delete;
|
||||
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
z_cap_t register_port() const { return register_port_; }
|
||||
void set_register_port(const z_cap_t& value) { register_port_ = value; }
|
||||
|
||||
private:
|
||||
z_cap_t register_port_;
|
||||
|
||||
};
|
||||
class AhciInfo {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& req
|
|||
|
||||
switch(method_select) {
|
||||
case 0: {
|
||||
Empty yunq_request;
|
||||
RegisterInfo yunq_response;
|
||||
RegisterEndpointRequest yunq_request;
|
||||
Empty yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleGetRegister(yunq_request, yunq_response));
|
||||
RET_ERR(HandleRegisterEndpoint(yunq_request, yunq_response));
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class YellowstoneServerBase {
|
|||
[[nodiscard]] Thread RunServer();
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetRegister(const Empty&, RegisterInfo&) = 0;
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&, Empty&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(const Empty&, AhciInfo&) = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue