[Yellowstone] Add a method to get the framebuffer info from yellowstone.
This commit is contained in:
parent
d13e1a238f
commit
9e05b3b3dd
10 changed files with 267 additions and 8 deletions
|
|
@ -1,6 +1,7 @@
|
|||
interface Yellowstone {
|
||||
method RegisterEndpoint(RegisterEndpointRequest) -> (Empty);
|
||||
method GetAhciInfo(Empty) -> (AhciInfo);
|
||||
method GetFramebufferInfo(Empty) -> (FramebufferInfo);
|
||||
method GetDenali(Empty) -> (DenaliInfo);
|
||||
}
|
||||
|
||||
|
|
@ -18,6 +19,23 @@ message AhciInfo {
|
|||
u64 region_length;
|
||||
}
|
||||
|
||||
message FramebufferInfo {
|
||||
u64 address_phys;
|
||||
u64 width;
|
||||
u64 height;
|
||||
u64 pitch;
|
||||
// TODO: Add u16 & u8 to the yunq language so
|
||||
// the following can be appropriate widths.
|
||||
u64 bpp;
|
||||
u64 memory_model;
|
||||
u64 red_mask_size;
|
||||
u64 red_mask_shift;
|
||||
u64 green_mask_size;
|
||||
u64 green_mask_shift;
|
||||
u64 blue_mask_size;
|
||||
u64 blue_mask_shift;
|
||||
}
|
||||
|
||||
message DenaliInfo {
|
||||
capability denali_endpoint;
|
||||
u64 device_id;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ glcr::ErrorCode YellowstoneClient::GetAhciInfo(const Empty& request, AhciInfo& r
|
|||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& response) {
|
||||
glcr::ErrorCode YellowstoneClient::GetFramebufferInfo(const Empty& request, FramebufferInfo& response) {
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
|
|
@ -103,3 +103,35 @@ glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& r
|
|||
}
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode YellowstoneClient::GetDenali(const Empty& request, DenaliInfo& response) {
|
||||
uint64_t buffer_size = kBufferSize;
|
||||
uint64_t cap_size = kCapBufferSize;
|
||||
|
||||
const uint32_t kSentinel = 0xBEEFDEAD;
|
||||
buffer_.WriteAt<uint32_t>(0, kSentinel);
|
||||
buffer_.WriteAt<uint64_t>(8, 3);
|
||||
|
||||
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;
|
||||
RET_ERR(ZEndpointSend(endpoint_, 16 + length, buffer_.RawPtr(), cap_buffer_.UsedSlots(), cap_buffer_.RawPtr(), &reply_port_cap));
|
||||
|
||||
// FIXME: Add a way to zero out the first buffer.
|
||||
RET_ERR(ZReplyPortRecv(reply_port_cap, &buffer_size, buffer_.RawPtr(), &cap_size, cap_buffer_.RawPtr()));
|
||||
|
||||
if (buffer_.At<uint32_t>(0) != kSentinel) {
|
||||
return glcr::INVALID_RESPONSE;
|
||||
}
|
||||
|
||||
// Check Response Code.
|
||||
RET_ERR(buffer_.At<uint64_t>(8));
|
||||
|
||||
response.ParseFromBytes(buffer_, 16, cap_buffer_);
|
||||
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class YellowstoneClient {
|
|||
|
||||
[[nodiscard]] glcr::ErrorCode GetAhciInfo(const Empty& request, AhciInfo& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetFramebufferInfo(const Empty& request, FramebufferInfo& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode GetDenali(const Empty& request, DenaliInfo& response);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -175,6 +175,130 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
|
|||
|
||||
return next_extension;
|
||||
}
|
||||
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse address_phys.
|
||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse width.
|
||||
set_width(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse height.
|
||||
set_height(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
// Parse pitch.
|
||||
set_pitch(bytes.At<uint64_t>(offset + header_size + (8 * 3)));
|
||||
// Parse bpp.
|
||||
set_bpp(bytes.At<uint64_t>(offset + header_size + (8 * 4)));
|
||||
// Parse memory_model.
|
||||
set_memory_model(bytes.At<uint64_t>(offset + header_size + (8 * 5)));
|
||||
// Parse red_mask_size.
|
||||
set_red_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 6)));
|
||||
// Parse red_mask_shift.
|
||||
set_red_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 7)));
|
||||
// Parse green_mask_size.
|
||||
set_green_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 8)));
|
||||
// Parse green_mask_shift.
|
||||
set_green_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 9)));
|
||||
// Parse blue_mask_size.
|
||||
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
|
||||
// Parse blue_mask_shift.
|
||||
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
||||
}
|
||||
|
||||
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
// Parse address_phys.
|
||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse width.
|
||||
set_width(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse height.
|
||||
set_height(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
// Parse pitch.
|
||||
set_pitch(bytes.At<uint64_t>(offset + header_size + (8 * 3)));
|
||||
// Parse bpp.
|
||||
set_bpp(bytes.At<uint64_t>(offset + header_size + (8 * 4)));
|
||||
// Parse memory_model.
|
||||
set_memory_model(bytes.At<uint64_t>(offset + header_size + (8 * 5)));
|
||||
// Parse red_mask_size.
|
||||
set_red_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 6)));
|
||||
// Parse red_mask_shift.
|
||||
set_red_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 7)));
|
||||
// Parse green_mask_size.
|
||||
set_green_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 8)));
|
||||
// Parse green_mask_shift.
|
||||
set_green_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 9)));
|
||||
// Parse blue_mask_size.
|
||||
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
|
||||
// Parse blue_mask_shift.
|
||||
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
||||
}
|
||||
|
||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 12;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write address_phys.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), address_phys());
|
||||
// Write width.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), width());
|
||||
// Write height.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), height());
|
||||
// Write pitch.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), pitch());
|
||||
// Write bpp.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 4), bpp());
|
||||
// Write memory_model.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 5), memory_model());
|
||||
// Write red_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 6), red_mask_size());
|
||||
// Write red_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 7), red_mask_shift());
|
||||
// Write green_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 8), green_mask_size());
|
||||
// Write green_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 9), green_mask_shift());
|
||||
// Write blue_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 10), blue_mask_size());
|
||||
// Write blue_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 12;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write address_phys.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), address_phys());
|
||||
// Write width.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), width());
|
||||
// Write height.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), height());
|
||||
// Write pitch.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), pitch());
|
||||
// Write bpp.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 4), bpp());
|
||||
// Write memory_model.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 5), memory_model());
|
||||
// Write red_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 6), red_mask_size());
|
||||
// Write red_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 7), red_mask_shift());
|
||||
// Write green_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 8), green_mask_size());
|
||||
// Write green_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 9), green_mask_shift());
|
||||
// Write blue_mask_size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 10), blue_mask_size());
|
||||
// Write blue_mask_shift.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 11), blue_mask_shift());
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse denali_endpoint.
|
||||
|
|
|
|||
|
|
@ -61,6 +61,57 @@ class AhciInfo {
|
|||
z_cap_t ahci_region_;
|
||||
uint64_t region_length_;
|
||||
|
||||
};
|
||||
class FramebufferInfo {
|
||||
public:
|
||||
FramebufferInfo() {}
|
||||
// Delete copy and move until implemented.
|
||||
FramebufferInfo(const FramebufferInfo&) = delete;
|
||||
FramebufferInfo(FramebufferInfo&&) = 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;
|
||||
uint64_t address_phys() const { return address_phys_; }
|
||||
void set_address_phys(const uint64_t& value) { address_phys_ = value; }
|
||||
uint64_t width() const { return width_; }
|
||||
void set_width(const uint64_t& value) { width_ = value; }
|
||||
uint64_t height() const { return height_; }
|
||||
void set_height(const uint64_t& value) { height_ = value; }
|
||||
uint64_t pitch() const { return pitch_; }
|
||||
void set_pitch(const uint64_t& value) { pitch_ = value; }
|
||||
uint64_t bpp() const { return bpp_; }
|
||||
void set_bpp(const uint64_t& value) { bpp_ = value; }
|
||||
uint64_t memory_model() const { return memory_model_; }
|
||||
void set_memory_model(const uint64_t& value) { memory_model_ = value; }
|
||||
uint64_t red_mask_size() const { return red_mask_size_; }
|
||||
void set_red_mask_size(const uint64_t& value) { red_mask_size_ = value; }
|
||||
uint64_t red_mask_shift() const { return red_mask_shift_; }
|
||||
void set_red_mask_shift(const uint64_t& value) { red_mask_shift_ = value; }
|
||||
uint64_t green_mask_size() const { return green_mask_size_; }
|
||||
void set_green_mask_size(const uint64_t& value) { green_mask_size_ = value; }
|
||||
uint64_t green_mask_shift() const { return green_mask_shift_; }
|
||||
void set_green_mask_shift(const uint64_t& value) { green_mask_shift_ = value; }
|
||||
uint64_t blue_mask_size() const { return blue_mask_size_; }
|
||||
void set_blue_mask_size(const uint64_t& value) { blue_mask_size_ = value; }
|
||||
uint64_t blue_mask_shift() const { return blue_mask_shift_; }
|
||||
void set_blue_mask_shift(const uint64_t& value) { blue_mask_shift_ = value; }
|
||||
|
||||
private:
|
||||
uint64_t address_phys_;
|
||||
uint64_t width_;
|
||||
uint64_t height_;
|
||||
uint64_t pitch_;
|
||||
uint64_t bpp_;
|
||||
uint64_t memory_model_;
|
||||
uint64_t red_mask_size_;
|
||||
uint64_t red_mask_shift_;
|
||||
uint64_t green_mask_size_;
|
||||
uint64_t green_mask_shift_;
|
||||
uint64_t blue_mask_size_;
|
||||
uint64_t blue_mask_shift_;
|
||||
|
||||
};
|
||||
class DenaliInfo {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -109,6 +109,17 @@ glcr::ErrorCode YellowstoneServerBase::HandleRequest(const glcr::ByteBuffer& req
|
|||
break;
|
||||
}
|
||||
case 2: {
|
||||
Empty yunq_request;
|
||||
FramebufferInfo yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleGetFramebufferInfo(yunq_request, yunq_response));
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
Empty yunq_request;
|
||||
DenaliInfo yunq_response;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ class YellowstoneServerBase {
|
|||
|
||||
[[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;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue