[Yellowstone] Use yunq native empty requests and responses for service.
This commit is contained in:
parent
cc4b5bd811
commit
b95c736825
13 changed files with 140 additions and 113 deletions
|
|
@ -1,9 +1,9 @@
|
|||
interface Yellowstone {
|
||||
method RegisterEndpoint(RegisterEndpointRequest) -> (Empty);
|
||||
method RegisterEndpoint(RegisterEndpointRequest) -> ();
|
||||
method GetEndpoint(GetEndpointRequest) -> (Endpoint);
|
||||
method GetAhciInfo(Empty) -> (AhciInfo);
|
||||
method GetFramebufferInfo(Empty) -> (FramebufferInfo);
|
||||
method GetDenali(Empty) -> (DenaliInfo);
|
||||
method GetAhciInfo() -> (AhciInfo);
|
||||
method GetFramebufferInfo() -> (FramebufferInfo);
|
||||
method GetDenali() -> (DenaliInfo);
|
||||
}
|
||||
|
||||
message RegisterEndpointRequest {
|
||||
|
|
@ -11,10 +11,6 @@ message RegisterEndpointRequest {
|
|||
capability endpoint_capability;
|
||||
}
|
||||
|
||||
message Empty {
|
||||
|
||||
}
|
||||
|
||||
message GetEndpointRequest {
|
||||
string endpoint_name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response) {
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointRequest& request) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -17,7 +19,10 @@ glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointReques
|
|||
buffer_.WriteAt<uint64_t>(8, 0);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -33,14 +38,16 @@ glcr::ErrorCode YellowstoneClient::RegisterEndpoint(const RegisterEndpointReques
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request, Endpoint& response) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -49,7 +56,10 @@ glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request
|
|||
buffer_.WriteAt<uint64_t>(8, 1);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -65,14 +75,18 @@ glcr::ErrorCode YellowstoneClient::GetEndpoint(const GetEndpointRequest& request
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& response) {
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetAhciInfo(AhciInfo& response) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -81,7 +95,10 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& r
|
|||
buffer_.WriteAt<uint64_t>(8, 2);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
uint64_t length = 0;
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -97,14 +114,18 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& r
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(const Empty& request, FramebufferInfo& response) {
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(FramebufferInfo& response) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -113,7 +134,10 @@ glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(const Empty& request, Fram
|
|||
buffer_.WriteAt<uint64_t>(8, 3);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
uint64_t length = 0;
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -129,14 +153,18 @@ glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(const Empty& request, Fram
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& response) {
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetDenali(DenaliInfo& response) {
|
||||
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -145,7 +173,10 @@ glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& r
|
|||
buffer_.WriteAt<uint64_t>(8, 4);
|
||||
|
||||
cap_buffer_.Reset();
|
||||
uint64_t length = request.SerializeToBytes(buffer_, /*offset=*/16, cap_buffer_);
|
||||
|
||||
uint64_t length = 0;
|
||||
|
||||
|
||||
buffer_.WriteAt<uint32_t>(4, 16 + length);
|
||||
|
||||
z_cap_t reply_port_cap;
|
||||
|
|
@ -161,8 +192,10 @@ glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& r
|
|||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,25 @@ class YellowstoneClient {
|
|||
z_cap_t Capability() { return endpoint_; }
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request, Empty& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode RegisterEndpoint(const RegisterEndpointRequest& request);
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetEndpoint(const GetEndpointRequest& request, Endpoint& response);
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetAhciInfo(const Empty& request, AhciInfo& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetAhciInfo(AhciInfo& response);
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(const Empty& request, FramebufferInfo& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(FramebufferInfo& response);
|
||||
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetDenali(const Empty& request, DenaliInfo& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetDenali(DenaliInfo& response);
|
||||
|
||||
|
||||
private:
|
||||
z_cap_t endpoint_;
|
||||
|
|
|
|||
|
|
@ -101,39 +101,6 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
|||
|
||||
return next_extension;
|
||||
}
|
||||
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void Empty::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
|
||||
}
|
||||
|
||||
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 0;
|
||||
const uint32_t core_size = next_extension;
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 0;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void GetEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,23 +29,6 @@ class RegisterEndpointRequest {
|
|||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class Empty {
|
||||
public:
|
||||
Empty() {}
|
||||
// Delete copy and move until implemented.
|
||||
Empty(const Empty&) = delete;
|
||||
Empty(Empty&&) = delete;
|
||||
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
|
||||
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
|
||||
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
|
||||
private:
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class GetEndpointRequest {
|
||||
public:
|
||||
GetEndpointRequest() {}
|
||||
|
|
|
|||
|
|
@ -87,58 +87,92 @@ glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& req
|
|||
|
||||
switch(method_select) {
|
||||
case 0: {
|
||||
|
||||
|
||||
RegisterEndpointRequest yunq_request;
|
||||
Empty yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
|
||||
RET_ERR(HandleRegisterEndpoint(yunq_request, yunq_response));
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
|
||||
RET_ERR(HandleRegisterEndpoint(yunq_request));
|
||||
|
||||
|
||||
|
||||
resp_length = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
||||
|
||||
GetEndpointRequest yunq_request;
|
||||
Endpoint yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
|
||||
|
||||
Endpoint yunq_response;
|
||||
|
||||
|
||||
|
||||
RET_ERR(HandleGetEndpoint(yunq_request, yunq_response));
|
||||
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Empty yunq_request;
|
||||
|
||||
|
||||
|
||||
|
||||
AhciInfo yunq_response;
|
||||
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleGetAhciInfo(yunq_request, yunq_response));
|
||||
|
||||
RET_ERR(HandleGetAhciInfo(yunq_response));
|
||||
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
Empty yunq_request;
|
||||
|
||||
|
||||
|
||||
|
||||
FramebufferInfo yunq_response;
|
||||
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleGetFramebufferInfo(yunq_request, yunq_response));
|
||||
|
||||
RET_ERR(HandleGetFramebufferInfo(yunq_response));
|
||||
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
Empty yunq_request;
|
||||
|
||||
|
||||
|
||||
|
||||
DenaliInfo yunq_response;
|
||||
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleGetDenali(yunq_request, yunq_response));
|
||||
|
||||
RET_ERR(HandleGetDenali(yunq_response));
|
||||
|
||||
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
|
|
@ -21,15 +21,25 @@ class YellowstoneServerBase {
|
|||
[[nodiscard]] Thread RunServer();
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&, Empty&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&) = 0;
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(const Empty&, AhciInfo&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetFramebufferInfo(const Empty&, FramebufferInfo&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetDenali(const Empty&, DenaliInfo&) = 0;
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetAhciInfo(AhciInfo&) = 0;
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetFramebufferInfo(FramebufferInfo&) = 0;
|
||||
|
||||
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleGetDenali(DenaliInfo&) = 0;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue