Compare commits
3 Commits
52142afeb8
...
7c105c8a31
Author | SHA1 | Date |
---|---|---|
|
7c105c8a31 | |
|
e5568450c2 | |
|
43f19d7a26 |
|
@ -1,3 +1,5 @@
|
||||||
builddbg/
|
builddbg/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|
||||||
|
sysroot/bin
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
Command::~Command() {}
|
Command::~Command() {}
|
||||||
|
|
||||||
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
||||||
Mutex& callback_mutex)
|
uint64_t paddr, Mutex& callback_mutex)
|
||||||
: lba_(lba), sector_cnt_(sector_cnt), callback_mutex_(callback_mutex) {
|
: lba_(lba),
|
||||||
region_ = MappedMemoryRegion::ContiguousPhysical(sector_cnt * 512);
|
sector_cnt_(sector_cnt),
|
||||||
}
|
paddr_(paddr),
|
||||||
|
callback_mutex_(callback_mutex) {}
|
||||||
|
|
||||||
DmaReadCommand::~DmaReadCommand() {}
|
DmaReadCommand::~DmaReadCommand() {}
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ void DmaReadCommand::PopulateFis(uint8_t* command_fis) {
|
||||||
memcpy(command_fis, &fis, sizeof(fis));
|
memcpy(command_fis, &fis, sizeof(fis));
|
||||||
}
|
}
|
||||||
void DmaReadCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) {
|
void DmaReadCommand::PopulatePrdt(PhysicalRegionDescriptor* prdt) {
|
||||||
prdt[0].region_address = region_.paddr();
|
prdt[0].region_address = paddr_;
|
||||||
prdt[0].byte_count = region_.size();
|
prdt[0].byte_count = sector_cnt_ * 512;
|
||||||
}
|
}
|
||||||
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
||||||
|
|
|
@ -17,7 +17,8 @@ class Command {
|
||||||
|
|
||||||
class DmaReadCommand : public Command {
|
class DmaReadCommand : public Command {
|
||||||
public:
|
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;
|
virtual ~DmaReadCommand() override;
|
||||||
|
|
||||||
|
@ -26,11 +27,9 @@ class DmaReadCommand : public Command {
|
||||||
|
|
||||||
void Callback() override;
|
void Callback() override;
|
||||||
|
|
||||||
z_cap_t GetMemoryRegion() { return region_.cap(); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t lba_;
|
uint64_t lba_;
|
||||||
uint64_t sector_cnt_;
|
uint64_t sector_cnt_;
|
||||||
|
uint64_t paddr_;
|
||||||
Mutex& callback_mutex_;
|
Mutex& callback_mutex_;
|
||||||
MappedMemoryRegion region_;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,10 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
||||||
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
ASSIGN_OR_RETURN(Mutex mutex, Mutex::Create());
|
||||||
RET_ERR(mutex.Lock());
|
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);
|
device->IssueCommand(&command);
|
||||||
|
|
||||||
// Wait for read operation to complete.
|
// Wait for read operation to complete.
|
||||||
|
@ -26,8 +29,40 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req,
|
||||||
RET_ERR(mutex.Release());
|
RET_ERR(mutex.Release());
|
||||||
|
|
||||||
resp.set_device_id(req.device_id());
|
resp.set_device_id(req.device_id());
|
||||||
resp.set_lba(req.lba());
|
|
||||||
resp.set_size(req.size());
|
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;
|
return glcr::OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ class DenaliServer : public DenaliServerBase {
|
||||||
|
|
||||||
glcr::ErrorCode HandleRead(const ReadRequest& req,
|
glcr::ErrorCode HandleRead(const ReadRequest& req,
|
||||||
ReadResponse& resp) override;
|
ReadResponse& resp) override;
|
||||||
|
glcr::ErrorCode HandleReadMany(const ReadManyRequest& req,
|
||||||
|
ReadResponse& resp) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint64_t kBuffSize = 1024;
|
static const uint64_t kBuffSize = 1024;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
interface Denali {
|
interface Denali {
|
||||||
method Read(ReadRequest) -> (ReadResponse);
|
method Read(ReadRequest) -> (ReadResponse);
|
||||||
|
method ReadMany(ReadManyRequest) -> (ReadResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReadRequest {
|
message ReadRequest {
|
||||||
|
@ -8,9 +9,14 @@ message ReadRequest {
|
||||||
u64 size;
|
u64 size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ReadManyRequest {
|
||||||
|
u64 device_id;
|
||||||
|
repeated u64 lba;
|
||||||
|
}
|
||||||
|
|
||||||
message ReadResponse {
|
message ReadResponse {
|
||||||
u64 device_id;
|
u64 device_id;
|
||||||
u64 lba;
|
|
||||||
u64 size;
|
u64 size;
|
||||||
capability memory;
|
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 Read(const ReadRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
|
[[nodiscard]] glcr::ErrorCode ReadMany(const ReadManyRequest& request, ReadResponse& response);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
z_cap_t endpoint_;
|
||||||
uint64_t kBufferSize = 0x1000;
|
uint64_t kBufferSize = 0x1000;
|
||||||
|
|
|
@ -28,16 +28,14 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// 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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
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)));
|
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
// Parse size.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
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;
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse device_id.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
// Parse lba.
|
// Parse lba.
|
||||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
auto lba_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
||||||
// Parse size.
|
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
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.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_memory(0);
|
set_memory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// 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)));
|
|
||||||
// Parse memory.
|
// 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));
|
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 {
|
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;
|
const uint32_t core_size = next_extension;
|
||||||
// Write device_id.
|
// Write device_id.
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 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.
|
// Write size.
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||||
// Write memory.
|
// Write memory.
|
||||||
// FIXME: Implement inbuffer capabilities.
|
// 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.
|
// The next extension pointer is the length of the message.
|
||||||
WriteHeader(bytes, offset, core_size, next_extension);
|
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 {
|
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;
|
const uint32_t core_size = next_extension;
|
||||||
uint64_t next_cap = 0;
|
uint64_t next_cap = 0;
|
||||||
// Write device_id.
|
// Write device_id.
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), 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.
|
// Write size.
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||||
// Write memory.
|
// Write memory.
|
||||||
caps.WriteAt(next_cap, 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.
|
// The next extension pointer is the length of the message.
|
||||||
WriteHeader(bytes, offset, core_size, next_extension);
|
WriteHeader(bytes, offset, core_size, next_extension);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
class ReadRequest {
|
class ReadRequest {
|
||||||
|
@ -28,6 +29,31 @@ class ReadRequest {
|
||||||
uint64_t lba_;
|
uint64_t lba_;
|
||||||
uint64_t size_;
|
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 {
|
class ReadResponse {
|
||||||
public:
|
public:
|
||||||
|
@ -42,8 +68,6 @@ class ReadResponse {
|
||||||
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_; }
|
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; }
|
|
||||||
uint64_t size() const { return size_; }
|
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_; }
|
z_cap_t memory() const { return memory_; }
|
||||||
|
@ -51,8 +75,9 @@ class ReadResponse {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t device_id_;
|
uint64_t device_id_;
|
||||||
uint64_t lba_;
|
|
||||||
uint64_t size_;
|
uint64_t size_;
|
||||||
z_cap_t memory_;
|
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);
|
resp_length = yunq_response.SerializeToBytes(response, kHeaderSize, resp_caps);
|
||||||
break;
|
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: {
|
default: {
|
||||||
return glcr::UNIMPLEMENTED;
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ class DenaliServerBase {
|
||||||
|
|
||||||
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
[[nodiscard]] virtual glcr::ErrorCode HandleRead(const ReadRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
[[nodiscard]] virtual glcr::ErrorCode HandleReadMany(const ReadManyRequest&, ReadResponse&) = 0;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
z_cap_t endpoint_;
|
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"
|
#include "mammoth/debug.h"
|
||||||
|
|
||||||
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||||
ScopedDenaliClient&& denali) {
|
const DenaliInfo& denali_info) {
|
||||||
// Read 1024 bytes from 1024 offset.
|
// Read 1024 bytes from 1024 offset.
|
||||||
// FIXME: Don't assume 512 byte sectors somehow.
|
// 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>(
|
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() {
|
Superblock* Ext2BlockReader::GetSuperblock() {
|
||||||
|
@ -51,15 +61,40 @@ uint64_t Ext2BlockReader::InodeTableBlockSize() {
|
||||||
|
|
||||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlock(
|
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlock(
|
||||||
uint64_t block_number) {
|
uint64_t block_number) {
|
||||||
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
return ReadBlocks(block_number, 1);
|
||||||
SectorsPerBlock());
|
|
||||||
}
|
}
|
||||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||||
uint64_t block_number, uint64_t num_blocks) {
|
uint64_t block_number, uint64_t num_blocks) {
|
||||||
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
ReadRequest req;
|
||||||
num_blocks * SectorsPerBlock());
|
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)
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <denali/scoped_denali_client.h>
|
#include <denali/denali.yunq.client.h>
|
||||||
#include <glacier/memory/shared_ptr.h>
|
#include <glacier/memory/shared_ptr.h>
|
||||||
#include <glacier/status/error_or.h>
|
#include <glacier/status/error_or.h>
|
||||||
#include <mammoth/memory_region.h>
|
#include <mammoth/memory_region.h>
|
||||||
|
#include <yellowstone/yellowstone.yunq.h>
|
||||||
|
|
||||||
#include "fs/ext2/ext2.h"
|
#include "fs/ext2/ext2.h"
|
||||||
|
|
||||||
|
@ -15,7 +16,7 @@
|
||||||
class Ext2BlockReader {
|
class Ext2BlockReader {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
||||||
ScopedDenaliClient&& denali);
|
const DenaliInfo& denali_info);
|
||||||
|
|
||||||
// TODO: Consider creating a new class wrapper with these computations.
|
// TODO: Consider creating a new class wrapper with these computations.
|
||||||
Superblock* GetSuperblock();
|
Superblock* GetSuperblock();
|
||||||
|
@ -32,11 +33,17 @@ class Ext2BlockReader {
|
||||||
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(uint64_t block_number,
|
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(uint64_t block_number,
|
||||||
uint64_t num_blocks);
|
uint64_t num_blocks);
|
||||||
|
|
||||||
|
glcr::ErrorOr<MappedMemoryRegion> ReadBlocks(
|
||||||
|
const glcr::Vector<uint64_t>& block_list);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScopedDenaliClient denali_;
|
DenaliClient denali_;
|
||||||
|
uint64_t device_id_;
|
||||||
|
uint64_t lba_offset_;
|
||||||
MappedMemoryRegion super_block_region_;
|
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();
|
uint64_t SectorsPerBlock();
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <mammoth/debug.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,
|
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
||||||
Ext2BlockReader::Init(glcr::Move(denali)));
|
Ext2BlockReader::Init(glcr::Move(denali_info)));
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(
|
ASSIGN_OR_RETURN(
|
||||||
MappedMemoryRegion bgdt,
|
MappedMemoryRegion bgdt,
|
||||||
|
@ -99,10 +99,31 @@ glcr::ErrorOr<MappedMemoryRegion> Ext2Driver::ReadFile(uint64_t inode_number) {
|
||||||
uint64_t real_block_cnt =
|
uint64_t real_block_cnt =
|
||||||
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
(inode->blocks - 1) / (ext2_reader_->BlockSize() / 512) + 1;
|
||||||
|
|
||||||
if (real_block_cnt > 1) {
|
if (inode->block[14]) {
|
||||||
dbgln("Can't handle scatter-gather yet.");
|
dbgln("Can't handle triply-indirect blocks yet.");
|
||||||
return glcr::UNIMPLEMENTED;
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <denali/scoped_denali_client.h>
|
|
||||||
#include <glacier/memory/move.h>
|
#include <glacier/memory/move.h>
|
||||||
#include <glacier/memory/unique_ptr.h>
|
#include <glacier/memory/unique_ptr.h>
|
||||||
|
#include <yellowstone/yellowstone.yunq.h>
|
||||||
|
|
||||||
#include "fs/ext2/ext2.h"
|
#include "fs/ext2/ext2.h"
|
||||||
#include "fs/ext2/ext2_block_reader.h"
|
#include "fs/ext2/ext2_block_reader.h"
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
class Ext2Driver {
|
class Ext2Driver {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<Ext2Driver> Init(ScopedDenaliClient&& denali);
|
static glcr::ErrorOr<Ext2Driver> Init(const DenaliInfo& denali_info);
|
||||||
|
|
||||||
glcr::ErrorCode ProbePartition();
|
glcr::ErrorCode ProbePartition();
|
||||||
|
|
||||||
|
|
|
@ -28,19 +28,20 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse path.
|
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
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;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// 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)));
|
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_memory(0);
|
set_memory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenFileResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse path.
|
// Parse path.
|
||||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
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.
|
// Parse size.
|
||||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
// Parse memory.
|
// 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 {
|
uint64_t OpenFileResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
class OpenFileRequest {
|
class OpenFileRequest {
|
||||||
|
@ -22,6 +23,8 @@ class OpenFileRequest {
|
||||||
private:
|
private:
|
||||||
glcr::String path_;
|
glcr::String path_;
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class OpenFileResponse {
|
class OpenFileResponse {
|
||||||
public:
|
public:
|
||||||
|
@ -46,4 +49,6 @@ class OpenFileResponse {
|
||||||
uint64_t size_;
|
uint64_t size_;
|
||||||
z_cap_t memory_;
|
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/debug.h>
|
||||||
#include <mammoth/init.h>
|
#include <mammoth/init.h>
|
||||||
#include <yellowstone/yellowstone.yunq.client.h>
|
#include <yellowstone/yellowstone.yunq.client.h>
|
||||||
|
@ -15,10 +14,7 @@ uint64_t main(uint64_t init_cap) {
|
||||||
Empty empty;
|
Empty empty;
|
||||||
DenaliInfo denali_info;
|
DenaliInfo denali_info;
|
||||||
RET_ERR(yellowstone.GetDenali(empty, denali_info));
|
RET_ERR(yellowstone.GetDenali(empty, denali_info));
|
||||||
dbgln("LBA (recv): {x}", denali_info.lba_offset());
|
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(denali_info));
|
||||||
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(auto server, VFSServer::Create(ext2));
|
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
|
} // namespace
|
||||||
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// 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.
|
// Parse endpoint_capability.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_endpoint_capability(0);
|
set_endpoint_capability(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse endpoint_name.
|
// Parse endpoint_name.
|
||||||
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
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));
|
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
||||||
// Parse endpoint_capability.
|
// 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 {
|
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;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
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) {
|
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);
|
CheckHeader(bytes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
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;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_ahci_region(0);
|
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) {
|
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse ahci_region.
|
// Parse ahci_region.
|
||||||
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_ahci_region(caps.At(ahci_region_ptr));
|
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.
|
// Parse region_length.
|
||||||
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
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;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// 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) {
|
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);
|
CheckHeader(bytes);
|
||||||
// Parse address_phys.
|
// Parse address_phys.
|
||||||
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
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)));
|
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
|
||||||
// Parse blue_mask_shift.
|
// Parse blue_mask_shift.
|
||||||
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
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;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
set_denali_endpoint(0);
|
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) {
|
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
CheckHeader(bytes);
|
ParseFromBytesInternal(bytes, offset);
|
||||||
// Parse denali_endpoint.
|
// Parse denali_endpoint.
|
||||||
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
set_denali_endpoint(caps.At(denali_endpoint_ptr));
|
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.
|
// Parse device_id.
|
||||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
// Parse lba_offset.
|
// Parse lba_offset.
|
||||||
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <glacier/buffer/byte_buffer.h>
|
#include <glacier/buffer/byte_buffer.h>
|
||||||
#include <glacier/buffer/cap_buffer.h>
|
#include <glacier/buffer/cap_buffer.h>
|
||||||
|
#include <glacier/container/vector.h>
|
||||||
#include <glacier/string/string.h>
|
#include <glacier/string/string.h>
|
||||||
#include <ztypes.h>
|
#include <ztypes.h>
|
||||||
class RegisterEndpointRequest {
|
class RegisterEndpointRequest {
|
||||||
|
@ -25,6 +26,8 @@ class RegisterEndpointRequest {
|
||||||
glcr::String endpoint_name_;
|
glcr::String endpoint_name_;
|
||||||
z_cap_t endpoint_capability_;
|
z_cap_t endpoint_capability_;
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class Empty {
|
class Empty {
|
||||||
public:
|
public:
|
||||||
|
@ -40,6 +43,8 @@ class Empty {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class AhciInfo {
|
class AhciInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -61,6 +66,8 @@ class AhciInfo {
|
||||||
z_cap_t ahci_region_;
|
z_cap_t ahci_region_;
|
||||||
uint64_t region_length_;
|
uint64_t region_length_;
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class FramebufferInfo {
|
class FramebufferInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -112,6 +119,8 @@ class FramebufferInfo {
|
||||||
uint64_t blue_mask_size_;
|
uint64_t blue_mask_size_;
|
||||||
uint64_t blue_mask_shift_;
|
uint64_t blue_mask_shift_;
|
||||||
|
|
||||||
|
// Parses everything except for caps.
|
||||||
|
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
||||||
};
|
};
|
||||||
class DenaliInfo {
|
class DenaliInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -136,4 +145,6 @@ class DenaliInfo {
|
||||||
uint64_t device_id_;
|
uint64_t device_id_;
|
||||||
uint64_t lba_offset_;
|
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());
|
check(server_thread.Join());
|
||||||
dbgln("Yellowstone Finished Successfully.");
|
dbgln("Yellowstone Finished Successfully.");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Binary file not shown.
|
@ -43,21 +43,27 @@ void* KernelHeap::Allocate(uint64_t size) {
|
||||||
if (ptr_or.ok()) {
|
if (ptr_or.ok()) {
|
||||||
return ptr_or.value();
|
return ptr_or.value();
|
||||||
}
|
}
|
||||||
dbgln("Failed allocation (slab 8): {x}", ptr_or.error());
|
#if K_HEAP_DEBUG
|
||||||
|
dbgln("Skipped allocation (slab 8): {x}", ptr_or.error());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if ((size <= 16) && slab_16_) {
|
if ((size <= 16) && slab_16_) {
|
||||||
auto ptr_or = slab_16_->Allocate();
|
auto ptr_or = slab_16_->Allocate();
|
||||||
if (ptr_or.ok()) {
|
if (ptr_or.ok()) {
|
||||||
return ptr_or.value();
|
return ptr_or.value();
|
||||||
}
|
}
|
||||||
dbgln("Failed allocation (slab 16): {x}", ptr_or.error());
|
#if K_HEAP_DEBUG
|
||||||
|
dbgln("Skipped allocation (slab 16): {x}", ptr_or.error());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if ((size <= 32) && slab_32_) {
|
if ((size <= 32) && slab_32_) {
|
||||||
auto ptr_or = slab_32_->Allocate();
|
auto ptr_or = slab_32_->Allocate();
|
||||||
if (ptr_or.ok()) {
|
if (ptr_or.ok()) {
|
||||||
return ptr_or.value();
|
return ptr_or.value();
|
||||||
}
|
}
|
||||||
dbgln("Failed allocation (slab 32): {x}", ptr_or.error());
|
#if K_HEAP_DEBUG
|
||||||
|
dbgln("Skipped allocation (slab 32): {x}", ptr_or.error());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (next_addr_ + size >= upper_bound_) {
|
if (next_addr_ + size >= upper_bound_) {
|
||||||
panic("Kernel Heap Overrun (next, size, max): {x}, {x}, {x}", next_addr_,
|
panic("Kernel Heap Overrun (next, size, max): {x}, {x}, {x}", next_addr_,
|
||||||
|
|
Loading…
Reference in New Issue