[Sys] Successfully spin up a new process from disk.
This commit is contained in:
parent
e5568450c2
commit
7c105c8a31
|
@ -7,10 +7,11 @@
|
|||
Command::~Command() {}
|
||||
|
||||
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
||||
Mutex& callback_mutex)
|
||||
: lba_(lba), sector_cnt_(sector_cnt), callback_mutex_(callback_mutex) {
|
||||
region_ = MappedMemoryRegion::ContiguousPhysical(sector_cnt * 512);
|
||||
}
|
||||
uint64_t paddr, Mutex& callback_mutex)
|
||||
: lba_(lba),
|
||||
sector_cnt_(sector_cnt),
|
||||
paddr_(paddr),
|
||||
callback_mutex_(callback_mutex) {}
|
||||
|
||||
DmaReadCommand::~DmaReadCommand() {}
|
||||
|
||||
|
@ -43,7 +44,7 @@ void DmaReadCommand::PopulateFis(uint8_t* command_fis) {
|
|||
memcpy(command_fis, &fis, sizeof(fis));
|
||||
}
|
||||
void DmaReadCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) {
|
||||
prdt[0].region_address = region_.paddr();
|
||||
prdt[0].byte_count = region_.size();
|
||||
prdt[0].region_address = paddr_;
|
||||
prdt[0].byte_count = sector_cnt_ * 512;
|
||||
}
|
||||
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
||||
|
|
|
@ -17,7 +17,8 @@ class Command {
|
|||
|
||||
class DmaReadCommand : public Command {
|
||||
public:
|
||||
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, Mutex& callback_mutex);
|
||||
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, uint64_t dest_paddr,
|
||||
Mutex& callback_mutex);
|
||||
|
||||
virtual ~DmaReadCommand() override;
|
||||
|
||||
|
@ -26,11 +27,9 @@ class DmaReadCommand : public Command {
|
|||
|
||||
void Callback() override;
|
||||
|
||||
z_cap_t GetMemoryRegion() { return region_.cap(); }
|
||||
|
||||
private:
|
||||
uint64_t lba_;
|
||||
uint64_t sector_cnt_;
|
||||
uint64_t paddr_;
|
||||
Mutex& callback_mutex_;
|
||||
MappedMemoryRegion region_;
|
||||
};
|
||||
|
|
|
@ -18,7 +18,10 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
|||
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
||||
RET_ERR(mutex.Lock());
|
||||
|
||||
DmaReadCommand command(req.lba(), req.size(), mutex);
|
||||
MappedMemoryRegion region =
|
||||
MappedMemoryRegion::ContiguousPhysical(req.size() * 512);
|
||||
|
||||
DmaReadCommand command(req.lba(), req.size(), region.paddr(), mutex);
|
||||
device->IssueCommand(&command);
|
||||
|
||||
// Wait for read operation to complete.
|
||||
|
@ -26,8 +29,40 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
|||
RET_ERR(mutex.Release());
|
||||
|
||||
resp.set_device_id(req.device_id());
|
||||
resp.set_lba(req.lba());
|
||||
resp.set_size(req.size());
|
||||
resp.set_memory(command.GetMemoryRegion());
|
||||
resp.set_memory(region.cap());
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req,
|
||||
ReadResponse& resp) {
|
||||
ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id()));
|
||||
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
||||
RET_ERR(mutex.Lock());
|
||||
|
||||
MappedMemoryRegion region =
|
||||
MappedMemoryRegion::ContiguousPhysical(req.lba().size() * 512);
|
||||
|
||||
auto& vec = req.lba();
|
||||
uint64_t curr_run_start = 0;
|
||||
for (uint64_t i = 0; i < vec.size(); i++) {
|
||||
if (i + 1 < vec.size() && vec.at(i) + 1 == vec.at(i + 1)) {
|
||||
continue;
|
||||
}
|
||||
uint64_t lba = vec.at(curr_run_start);
|
||||
uint64_t size = (i - curr_run_start) + 1;
|
||||
uint64_t paddr = region.paddr() + curr_run_start * 512;
|
||||
DmaReadCommand command(lba, size, paddr, mutex);
|
||||
device->IssueCommand(&command);
|
||||
|
||||
// Wait for read operation to complete.
|
||||
RET_ERR(mutex.Lock());
|
||||
|
||||
curr_run_start = i + 1;
|
||||
}
|
||||
|
||||
resp.set_device_id(req.device_id());
|
||||
resp.set_size(req.lba().size());
|
||||
resp.set_memory(region.cap());
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ class DenaliServer : public DenaliServerBase {
|
|||
|
||||
glcr::ErrorCode HandleRead(const ReadRequest& req,
|
||||
ReadResponse& resp) override;
|
||||
glcr::ErrorCode HandleReadMany(const ReadManyRequest& req,
|
||||
ReadResponse& resp) override;
|
||||
|
||||
private:
|
||||
static const uint64_t kBuffSize = 1024;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
interface Denali {
|
||||
method Read(ReadRequest) -> (ReadResponse);
|
||||
method ReadMany(ReadManyRequest) -> (ReadResponse);
|
||||
}
|
||||
|
||||
message ReadRequest {
|
||||
|
@ -8,9 +9,14 @@ message ReadRequest {
|
|||
u64 size;
|
||||
}
|
||||
|
||||
message ReadManyRequest {
|
||||
u64 device_id;
|
||||
repeated u64 lba;
|
||||
}
|
||||
|
||||
message ReadResponse {
|
||||
u64 device_id;
|
||||
u64 lba;
|
||||
u64 size;
|
||||
capability memory;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,3 +39,35 @@ glcr::ErrorCode DenaliClient::Read(const ReadRequest& request, ReadResponse& res
|
|||
}
|
||||
|
||||
|
||||
|
||||
glcr::ErrorCode DenaliClient::ReadMany(const ReadManyRequest& request, ReadResponse& 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, 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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ class DenaliClient {
|
|||
|
||||
[[nodiscard]] glcr::ErrorCode Read(const ReadRequest& request, ReadResponse& response);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
||||
|
||||
private:
|
||||
z_cap_t endpoint_;
|
||||
uint64_t kBufferSize = 0x1000;
|
||||
|
|
|
@ -28,16 +28,14 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
|||
|
||||
} // namespace
|
||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
|
@ -45,6 +43,7 @@ void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset,
|
|||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
@ -79,45 +78,117 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
|||
|
||||
return next_extension;
|
||||
}
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
auto lba_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
ExtPointer lba_ptr{
|
||||
.offset = next_extension,
|
||||
.length = (uint32_t)(lba().size() * sizeof(uint64_t)),
|
||||
};
|
||||
|
||||
next_extension += lba_ptr.length;
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 1), lba_ptr);
|
||||
|
||||
for (uint64_t i = 0; i < lba().size(); i++) {
|
||||
uint32_t ext_offset = offset + lba_ptr.offset + (i * sizeof(uint64_t));
|
||||
bytes.WriteAt<uint64_t>(ext_offset, lba().at(i));
|
||||
}
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::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 device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
ExtPointer lba_ptr{
|
||||
.offset = next_extension,
|
||||
.length = (uint32_t)(lba().size() * sizeof(uint64_t)),
|
||||
};
|
||||
|
||||
next_extension += lba_ptr.length;
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 1), lba_ptr);
|
||||
|
||||
for (uint64_t i = 0; i < lba().size(); i++) {
|
||||
uint32_t ext_offset = offset + lba_ptr.offset + (i * sizeof(uint64_t));
|
||||
bytes.WriteAt<uint64_t>(ext_offset, lba().at(i));
|
||||
}
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_memory(0);
|
||||
}
|
||||
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 3));
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
|
||||
set_memory(caps.At(memory_ptr));
|
||||
}
|
||||
|
||||
void ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse memory.
|
||||
// Skip Cap.
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 4;
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), lba());
|
||||
// Write size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||
// Write memory.
|
||||
// FIXME: Implement inbuffer capabilities.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), 0);
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
@ -126,18 +197,16 @@ uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset
|
|||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 4;
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), lba());
|
||||
// Write size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||
// Write memory.
|
||||
caps.WriteAt(next_cap, memory());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), next_cap++);
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <glacier/buffer/byte_buffer.h>
|
||||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <ztypes.h>
|
||||
class ReadRequest {
|
||||
|
@ -15,11 +16,11 @@ class ReadRequest {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
uint64_t device_id() const { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
uint64_t lba() const { return lba_; }
|
||||
void set_lba(const uint64_t& value) { lba_ = value; }
|
||||
void set_lba(const uint64_t& value) { lba_ = value; }
|
||||
uint64_t size() const { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
|
||||
|
@ -28,6 +29,31 @@ class ReadRequest {
|
|||
uint64_t lba_;
|
||||
uint64_t size_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class ReadManyRequest {
|
||||
public:
|
||||
ReadManyRequest() {}
|
||||
// Delete copy and move until implemented.
|
||||
ReadManyRequest(const ReadManyRequest&) = delete;
|
||||
ReadManyRequest(ReadManyRequest&&) = 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 device_id() const { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
const glcr::Vector<uint64_t>& lba() const { return lba_; }
|
||||
void add_lba(const uint64_t& value) { lba_.PushBack(value); }
|
||||
|
||||
private:
|
||||
uint64_t device_id_;
|
||||
glcr::Vector<uint64_t> lba_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class ReadResponse {
|
||||
public:
|
||||
|
@ -39,20 +65,19 @@ class ReadResponse {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
uint64_t device_id() const { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
uint64_t lba() const { return lba_; }
|
||||
void set_lba(const uint64_t& value) { lba_ = value; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
uint64_t size() const { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
z_cap_t memory() const { return memory_; }
|
||||
void set_memory(const z_cap_t& value) { memory_ = value; }
|
||||
|
||||
private:
|
||||
uint64_t device_id_;
|
||||
uint64_t lba_;
|
||||
uint64_t size_;
|
||||
z_cap_t memory_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
|
@ -97,6 +97,17 @@ glcr::ErrorCode DenaliServerBase::HandleRequest(const glcr::ByteBuffer& request,
|
|||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
ReadManyRequest yunq_request;
|
||||
ReadResponse yunq_response;
|
||||
|
||||
yunq_request.ParseFromBytes(request, kHeaderSize, req_caps);
|
||||
|
||||
RET_ERR(HandleReadMany(yunq_request, yunq_response));
|
||||
|
||||
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return glcr::UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ class DenaliServerBase {
|
|||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
||||
|
||||
[[nodiscard]] virtual glcr::ErrorCode HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
||||
|
||||
|
||||
private:
|
||||
z_cap_t endpoint_;
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
|
||||
#include "denali.yunq.client.h"
|
||||
|
||||
class ScopedDenaliClient : protected DenaliClient {
|
||||
public:
|
||||
ScopedDenaliClient(z_cap_t endpoint_cap, uint64_t device_id,
|
||||
uint64_t lba_offset)
|
||||
: DenaliClient(endpoint_cap),
|
||||
device_id_(device_id),
|
||||
lba_offset_(lba_offset) {}
|
||||
|
||||
glcr::ErrorOr<MappedMemoryRegion> ReadSectors(uint64_t lba,
|
||||
uint64_t num_sectors) {
|
||||
ReadRequest req;
|
||||
req.set_device_id(device_id_);
|
||||
req.set_lba(lba_offset_ + lba);
|
||||
req.set_size(num_sectors);
|
||||
|
||||
ReadResponse resp;
|
||||
RET_ERR(DenaliClient::Read(req, resp));
|
||||
|
||||
return MappedMemoryRegion::FromCapability(resp.memory());
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t device_id_;
|
||||
uint64_t lba_offset_;
|
||||
};
|
|
@ -3,12 +3,22 @@
|
|||
#include "mammoth/debug.h"
|
||||
|
||||
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||
ScopedDenaliClient&& denali) {
|
||||
const DenaliInfo& denali_info) {
|
||||
// Read 1024 bytes from 1024 offset.
|
||||
// FIXME: Don't assume 512 byte sectors somehow.
|
||||
ASSIGN_OR_RETURN(MappedMemoryRegion superblock, denali.ReadSectors(2, 2));
|
||||
DenaliClient client(denali_info.denali_endpoint());
|
||||
ReadRequest req;
|
||||
req.set_device_id(denali_info.device_id());
|
||||
req.set_lba(denali_info.lba_offset() + 2);
|
||||
req.set_size(2);
|
||||
ReadResponse resp;
|
||||
RET_ERR(client.Read(req, resp));
|
||||
MappedMemoryRegion superblock =
|
||||
MappedMemoryRegion::FromCapability(resp.memory());
|
||||
|
||||
return glcr::SharedPtr<Ext2BlockReader>(
|
||||
new Ext2BlockReader(glcr::Move(denali), superblock));
|
||||
new Ext2BlockReader(glcr::Move(client), denali_info.device_id(),
|
||||
denali_info.lba_offset(), superblock));
|
||||
}
|
||||
|
||||
Superblock* Ext2BlockReader::GetSuperblock() {
|
||||
|
@ -51,15 +61,40 @@ uint64_t Ext2BlockReader::InodeTableBlockSize() {
|
|||
|
||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlock(
|
||||
uint64_t block_number) {
|
||||
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
||||
SectorsPerBlock());
|
||||
return ReadBlocks(block_number, 1);
|
||||
}
|
||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
uint64_t block_number, uint64_t num_blocks) {
|
||||
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
||||
num_blocks * SectorsPerBlock());
|
||||
ReadRequest req;
|
||||
req.set_device_id(device_id_);
|
||||
req.set_lba(lba_offset_ + block_number * SectorsPerBlock());
|
||||
req.set_size(num_blocks * SectorsPerBlock());
|
||||
ReadResponse resp;
|
||||
RET_ERR(denali_.Read(req, resp));
|
||||
return MappedMemoryRegion::FromCapability(resp.memory());
|
||||
}
|
||||
|
||||
Ext2BlockReader::Ext2BlockReader(ScopedDenaliClient&& denali,
|
||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
const glcr::Vector<uint64_t>& block_list) {
|
||||
ReadManyRequest req;
|
||||
req.set_device_id(device_id_);
|
||||
// FIXME: We should have better ergonomics for setting a repeated field in
|
||||
// Yunq.
|
||||
for (uint64_t i = 0; i < block_list.size(); i++) {
|
||||
uint64_t sector = lba_offset_ + block_list.at(i) * SectorsPerBlock();
|
||||
for (uint64_t j = 0; j < SectorsPerBlock(); j++) {
|
||||
req.add_lba(sector + j);
|
||||
}
|
||||
}
|
||||
ReadResponse resp;
|
||||
RET_ERR(denali_.ReadMany(req, resp));
|
||||
return MappedMemoryRegion::FromCapability(resp.memory());
|
||||
}
|
||||
|
||||
Ext2BlockReader::Ext2BlockReader(DenaliClient&& denali, uint64_t device_id,
|
||||
uint64_t lba_offset,
|
||||
MappedMemoryRegion super_block)
|
||||
: denali_(glcr::Move(denali)), super_block_region_(super_block) {}
|
||||
: denali_(glcr::Move(denali)),
|
||||
device_id_(device_id),
|
||||
lba_offset_(lba_offset),
|
||||
super_block_region_(super_block) {}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <denali/scoped_denali_client.h>
|
||||
#include <denali/denali.yunq.client.h>
|
||||
#include <glacier/memory/shared_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <yellowstone/yellowstone.yunq.h>
|
||||
|
||||
#include "fs/ext2/ext2.h"
|
||||
|
||||
|
@ -15,7 +16,7 @@
|
|||
class Ext2BlockReader {
|
||||
public:
|
||||
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
||||
ScopedDenaliClient&& denali);
|
||||
const DenaliInfo& denali_info);
|
||||
|
||||
// TODO: Consider creating a new class wrapper with these computations.
|
||||
Superblock* GetSuperblock();
|
||||
|
@ -32,11 +33,17 @@ class Ext2BlockReader {
|
|||
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(uint64_t block_number,
|
||||
uint64_t num_blocks);
|
||||
|
||||
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(
|
||||
const glcr::Vector<uint64_t>& block_list);
|
||||
|
||||
private:
|
||||
ScopedDenaliClient denali_;
|
||||
DenaliClient denali_;
|
||||
uint64_t device_id_;
|
||||
uint64_t lba_offset_;
|
||||
MappedMemoryRegion super_block_region_;
|
||||
|
||||
Ext2BlockReader(ScopedDenaliClient&& denali, MappedMemoryRegion super_block);
|
||||
Ext2BlockReader(DenaliClient&& denali, uint64_t device_id,
|
||||
uint64_t lba_offset, MappedMemoryRegion super_block);
|
||||
|
||||
uint64_t SectorsPerBlock();
|
||||
};
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include <glacier/string/string.h>
|
||||
#include <mammoth/debug.h>
|
||||
|
||||
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(ScopedDenaliClient&& denali) {
|
||||
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(const DenaliInfo& denali_info) {
|
||||
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
||||
Ext2BlockReader::Init(glcr::Move(denali)));
|
||||
Ext2BlockReader::Init(glcr::Move(denali_info)));
|
||||
|
||||
ASSIGN_OR_RETURN(
|
||||
MappedMemoryRegion bgdt,
|
||||
|
@ -99,10 +99,31 @@ glcr::ErrorOr<MappedMemoryRegion> Ext2Driver::ReadFile(uint64_t inode_number) {
|
|||
uint64_t real_block_cnt =
|
||||
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
||||
|
||||
if (real_block_cnt > 1) {
|
||||
dbgln("Can't handle scatter-gather yet.");
|
||||
if (inode->block[14]) {
|
||||
dbgln("Can't handle triply-indirect blocks yet.");
|
||||
return glcr::UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
return ext2_reader_->ReadBlock(inode->block[0]);
|
||||
if (inode->block[13]) {
|
||||
dbgln("Can't handle doubly-indirect blocks yet.");
|
||||
return glcr::UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
MappedMemoryRegion indirect_block;
|
||||
if (inode->block[12]) {
|
||||
ASSIGN_OR_RETURN(indirect_block, ext2_reader_->ReadBlock(inode->block[12]));
|
||||
}
|
||||
|
||||
glcr::Vector<uint64_t> blocks_to_read;
|
||||
for (uint64_t i = 0; i < 12 && i < real_block_cnt; i++) {
|
||||
blocks_to_read.PushBack(inode->block[i]);
|
||||
}
|
||||
|
||||
for (uint64_t i = 12; i < 268 && i < real_block_cnt; i++) {
|
||||
uint32_t* block_array = reinterpret_cast<uint32_t*>(indirect_block.vaddr());
|
||||
uint64_t offset = i - 12;
|
||||
blocks_to_read.PushBack(block_array[offset]);
|
||||
}
|
||||
|
||||
return ext2_reader_->ReadBlocks(blocks_to_read);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <denali/scoped_denali_client.h>
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <yellowstone/yellowstone.yunq.h>
|
||||
|
||||
#include "fs/ext2/ext2.h"
|
||||
#include "fs/ext2/ext2_block_reader.h"
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
class Ext2Driver {
|
||||
public:
|
||||
static glcr::ErrorOr<Ext2Driver> Init(ScopedDenaliClient&& denali);
|
||||
static glcr::ErrorOr<Ext2Driver> Init(const DenaliInfo& denali_info);
|
||||
|
||||
glcr::ErrorCode ProbePartition();
|
||||
|
||||
|
|
|
@ -28,19 +28,20 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
|||
|
||||
} // namespace
|
||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void OpenFileRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
|
||||
}
|
||||
|
||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
@ -86,19 +87,21 @@ uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
|||
return next_extension;
|
||||
}
|
||||
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_memory(0);
|
||||
}
|
||||
|
||||
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
|
||||
set_memory(caps.At(memory_ptr));
|
||||
}
|
||||
|
||||
void OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
@ -107,9 +110,8 @@ void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t of
|
|||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse memory.
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
// Skip Cap.
|
||||
|
||||
set_memory(caps.At(memory_ptr));
|
||||
}
|
||||
|
||||
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <glacier/buffer/byte_buffer.h>
|
||||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <ztypes.h>
|
||||
class OpenFileRequest {
|
||||
|
@ -15,13 +16,15 @@ class OpenFileRequest {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
glcr::String path() const { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
|
||||
private:
|
||||
glcr::String path_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class OpenFileResponse {
|
||||
public:
|
||||
|
@ -33,11 +36,11 @@ class OpenFileResponse {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
glcr::String path() const { return path_; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
void set_path(const glcr::String& value) { path_ = value; }
|
||||
uint64_t size() const { return size_; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
void set_size(const uint64_t& value) { size_ = value; }
|
||||
z_cap_t memory() const { return memory_; }
|
||||
void set_memory(const z_cap_t& value) { memory_ = value; }
|
||||
|
||||
|
@ -46,4 +49,6 @@ class OpenFileResponse {
|
|||
uint64_t size_;
|
||||
z_cap_t memory_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
#include <denali/scoped_denali_client.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
|
@ -15,10 +14,7 @@ uint64_t main(uint64_t init_cap) {
|
|||
Empty empty;
|
||||
DenaliInfo denali_info;
|
||||
RET_ERR(yellowstone.GetDenali(empty, denali_info));
|
||||
dbgln("LBA (recv): {x}", denali_info.lba_offset());
|
||||
ScopedDenaliClient denali(denali_info.denali_endpoint(),
|
||||
denali_info.device_id(), denali_info.lba_offset());
|
||||
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(glcr::Move(denali)));
|
||||
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(denali_info));
|
||||
|
||||
ASSIGN_OR_RETURN(auto server, VFSServer::Create(ext2));
|
||||
|
||||
|
|
|
@ -28,26 +28,29 @@ 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));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// 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) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// 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));
|
||||
}
|
||||
|
||||
void RegisterEndpointRequest::ParseFromBytesInternal(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.
|
||||
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
||||
// Skip Cap.
|
||||
|
||||
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
||||
}
|
||||
|
||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
@ -99,11 +102,16 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
|
|||
return next_extension;
|
||||
}
|
||||
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
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 {
|
||||
|
@ -127,22 +135,27 @@ uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr:
|
|||
return next_extension;
|
||||
}
|
||||
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse ahci_region.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_ahci_region(0);
|
||||
// Parse region_length.
|
||||
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
}
|
||||
|
||||
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse ahci_region.
|
||||
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||
|
||||
set_ahci_region(caps.At(ahci_region_ptr));
|
||||
}
|
||||
|
||||
void AhciInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse ahci_region.
|
||||
// Skip Cap.
|
||||
// Parse region_length.
|
||||
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
|
||||
}
|
||||
|
||||
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
@ -176,34 +189,14 @@ 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)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse address_phys.
|
||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
|
@ -229,6 +222,7 @@ void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t off
|
|||
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 {
|
||||
|
@ -300,26 +294,29 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
|
|||
return next_extension;
|
||||
}
|
||||
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse denali_endpoint.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_denali_endpoint(0);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse lba_offset.
|
||||
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
}
|
||||
|
||||
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse denali_endpoint.
|
||||
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||
|
||||
set_denali_endpoint(caps.At(denali_endpoint_ptr));
|
||||
}
|
||||
|
||||
void DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse denali_endpoint.
|
||||
// Skip Cap.
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse lba_offset.
|
||||
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
}
|
||||
|
||||
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <glacier/buffer/byte_buffer.h>
|
||||
#include <glacier/buffer/cap_buffer.h>
|
||||
#include <glacier/container/vector.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <ztypes.h>
|
||||
class RegisterEndpointRequest {
|
||||
|
@ -15,9 +16,9 @@ class RegisterEndpointRequest {
|
|||
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 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; }
|
||||
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; }
|
||||
|
||||
|
@ -25,6 +26,8 @@ class RegisterEndpointRequest {
|
|||
glcr::String endpoint_name_;
|
||||
z_cap_t endpoint_capability_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class Empty {
|
||||
public:
|
||||
|
@ -40,6 +43,8 @@ class Empty {
|
|||
|
||||
private:
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class AhciInfo {
|
||||
public:
|
||||
|
@ -51,9 +56,9 @@ class AhciInfo {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
z_cap_t ahci_region() const { return ahci_region_; }
|
||||
void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; }
|
||||
void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; }
|
||||
uint64_t region_length() const { return region_length_; }
|
||||
void set_region_length(const uint64_t& value) { region_length_ = value; }
|
||||
|
||||
|
@ -61,6 +66,8 @@ class AhciInfo {
|
|||
z_cap_t ahci_region_;
|
||||
uint64_t region_length_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class FramebufferInfo {
|
||||
public:
|
||||
|
@ -72,29 +79,29 @@ class FramebufferInfo {
|
|||
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 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; }
|
||||
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; }
|
||||
void set_width(const uint64_t& value) { width_ = value; }
|
||||
uint64_t height() const { return height_; }
|
||||
void set_height(const uint64_t& value) { height_ = value; }
|
||||
void set_height(const uint64_t& value) { height_ = value; }
|
||||
uint64_t pitch() const { return pitch_; }
|
||||
void set_pitch(const uint64_t& value) { pitch_ = value; }
|
||||
void set_pitch(const uint64_t& value) { pitch_ = value; }
|
||||
uint64_t bpp() const { return bpp_; }
|
||||
void set_bpp(const uint64_t& value) { bpp_ = value; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
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; }
|
||||
|
||||
|
@ -112,6 +119,8 @@ class FramebufferInfo {
|
|||
uint64_t blue_mask_size_;
|
||||
uint64_t blue_mask_shift_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
||||
class DenaliInfo {
|
||||
public:
|
||||
|
@ -123,11 +132,11 @@ class DenaliInfo {
|
|||
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 SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
|
||||
z_cap_t denali_endpoint() const { return denali_endpoint_; }
|
||||
void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; }
|
||||
void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; }
|
||||
uint64_t device_id() const { return device_id_; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
void set_device_id(const uint64_t& value) { device_id_ = value; }
|
||||
uint64_t lba_offset() const { return lba_offset_; }
|
||||
void set_lba_offset(const uint64_t& value) { lba_offset_ = value; }
|
||||
|
||||
|
@ -136,4 +145,6 @@ class DenaliInfo {
|
|||
uint64_t device_id_;
|
||||
uint64_t lba_offset_;
|
||||
|
||||
// Parses everything except for caps.
|
||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||
};
|
|
@ -63,8 +63,6 @@ uint64_t main(uint64_t port_cap) {
|
|||
}
|
||||
}
|
||||
|
||||
dbgln("Test: '{}'", file.cstr());
|
||||
|
||||
check(server_thread.Join());
|
||||
dbgln("Yellowstone Finished Successfully.");
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue