Compare commits
No commits in common. "7c105c8a314404735782271fbeb3c2ff860d22c5" and "52142afeb8a3a8adf24c07ff9497fa42c810f6eb" have entirely different histories.
7c105c8a31
...
52142afeb8
|
@ -1,5 +1,3 @@
|
||||||
builddbg/
|
builddbg/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|
||||||
sysroot/bin
|
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
Command::~Command() {}
|
Command::~Command() {}
|
||||||
|
|
||||||
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
DmaReadCommand::DmaReadCommand(uint64_t lba, uint64_t sector_cnt,
|
||||||
uint64_t paddr, Mutex& callback_mutex)
|
Mutex& callback_mutex)
|
||||||
: lba_(lba),
|
: lba_(lba), sector_cnt_(sector_cnt), callback_mutex_(callback_mutex) {
|
||||||
sector_cnt_(sector_cnt),
|
region_ = MappedMemoryRegion::ContiguousPhysical(sector_cnt * 512);
|
||||||
paddr_(paddr),
|
}
|
||||||
callback_mutex_(callback_mutex) {}
|
|
||||||
|
|
||||||
DmaReadCommand::~DmaReadCommand() {}
|
DmaReadCommand::~DmaReadCommand() {}
|
||||||
|
|
||||||
|
@ -44,7 +43,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 = paddr_;
|
prdt[0].region_address = region_.paddr();
|
||||||
prdt[0].byte_count = sector_cnt_ * 512;
|
prdt[0].byte_count = region_.size();
|
||||||
}
|
}
|
||||||
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
void DmaReadCommand::Callback() { callback_mutex_.Release(); }
|
||||||
|
|
|
@ -17,8 +17,7 @@ class Command {
|
||||||
|
|
||||||
class DmaReadCommand : public Command {
|
class DmaReadCommand : public Command {
|
||||||
public:
|
public:
|
||||||
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, uint64_t dest_paddr,
|
DmaReadCommand(uint64_t lba, uint64_t sector_cnt, Mutex& callback_mutex);
|
||||||
Mutex& callback_mutex);
|
|
||||||
|
|
||||||
virtual ~DmaReadCommand() override;
|
virtual ~DmaReadCommand() override;
|
||||||
|
|
||||||
|
@ -27,9 +26,11 @@ 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,10 +18,7 @@ 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());
|
||||||
|
|
||||||
MappedMemoryRegion region =
|
DmaReadCommand command(req.lba(), req.size(), mutex);
|
||||||
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.
|
||||||
|
@ -29,40 +26,8 @@ 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(region.cap());
|
resp.set_memory(command.GetMemoryRegion());
|
||||||
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,8 +13,6 @@ 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,6 +1,5 @@
|
||||||
interface Denali {
|
interface Denali {
|
||||||
method Read(ReadRequest) -> (ReadResponse);
|
method Read(ReadRequest) -> (ReadResponse);
|
||||||
method ReadMany(ReadManyRequest) -> (ReadResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReadRequest {
|
message ReadRequest {
|
||||||
|
@ -9,14 +8,9 @@ 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,35 +39,3 @@ 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,8 +19,6 @@ 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,14 +28,6 @@ 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) {
|
||||||
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);
|
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)));
|
||||||
|
@ -43,7 +35,16 @@ void ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t
|
||||||
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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadRequest::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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -78,117 +79,45 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
||||||
|
|
||||||
return next_extension;
|
return next_extension;
|
||||||
}
|
}
|
||||||
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
void ReadResponse::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.
|
||||||
auto lba_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
|
// Parse size.
|
||||||
lba_.Resize(lba_pointer.length / sizeof(uint64_t));
|
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
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) {
|
||||||
ParseFromBytesInternal(bytes, 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)));
|
||||||
// Parse memory.
|
// Parse memory.
|
||||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 3));
|
||||||
|
|
||||||
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 * 3;
|
uint32_t next_extension = header_size + 8 * 4;
|
||||||
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 * 1), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||||
// Write memory.
|
// Write memory.
|
||||||
// FIXME: Implement inbuffer capabilities.
|
// FIXME: Implement inbuffer capabilities.
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), 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);
|
||||||
|
@ -197,16 +126,18 @@ 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 * 3;
|
uint32_t next_extension = header_size + 8 * 4;
|
||||||
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 * 1), size());
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||||
// Write memory.
|
// Write memory.
|
||||||
caps.WriteAt(next_cap, memory());
|
caps.WriteAt(next_cap, memory());
|
||||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), 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,7 +3,6 @@
|
||||||
|
|
||||||
#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 {
|
||||||
|
@ -29,31 +28,6 @@ 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:
|
||||||
|
@ -68,6 +42,8 @@ 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_; }
|
||||||
|
@ -75,9 +51,8 @@ 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,17 +97,6 @@ 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,8 +23,6 @@ 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_;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#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,22 +3,12 @@
|
||||||
#include "mammoth/debug.h"
|
#include "mammoth/debug.h"
|
||||||
|
|
||||||
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||||
const DenaliInfo& denali_info) {
|
ScopedDenaliClient&& denali) {
|
||||||
// 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.
|
||||||
DenaliClient client(denali_info.denali_endpoint());
|
ASSIGN_OR_RETURN(MappedMemoryRegion superblock, denali.ReadSectors(2, 2));
|
||||||
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(client), denali_info.device_id(),
|
new Ext2BlockReader(glcr::Move(denali), superblock));
|
||||||
denali_info.lba_offset(), superblock));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Superblock* Ext2BlockReader::GetSuperblock() {
|
Superblock* Ext2BlockReader::GetSuperblock() {
|
||||||
|
@ -61,40 +51,15 @@ uint64_t Ext2BlockReader::InodeTableBlockSize() {
|
||||||
|
|
||||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlock(
|
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlock(
|
||||||
uint64_t block_number) {
|
uint64_t block_number) {
|
||||||
return ReadBlocks(block_number, 1);
|
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
||||||
|
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) {
|
||||||
ReadRequest req;
|
return denali_.ReadSectors(block_number * SectorsPerBlock(),
|
||||||
req.set_device_id(device_id_);
|
num_blocks * SectorsPerBlock());
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glcr::ErrorOr<MappedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
Ext2BlockReader::Ext2BlockReader(ScopedDenaliClient&& denali,
|
||||||
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)),
|
: denali_(glcr::Move(denali)), super_block_region_(super_block) {}
|
||||||
device_id_(device_id),
|
|
||||||
lba_offset_(lba_offset),
|
|
||||||
super_block_region_(super_block) {}
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <denali/denali.yunq.client.h>
|
#include <denali/scoped_denali_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"
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@
|
||||||
class Ext2BlockReader {
|
class Ext2BlockReader {
|
||||||
public:
|
public:
|
||||||
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
static glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Init(
|
||||||
const DenaliInfo& denali_info);
|
ScopedDenaliClient&& denali);
|
||||||
|
|
||||||
// TODO: Consider creating a new class wrapper with these computations.
|
// TODO: Consider creating a new class wrapper with these computations.
|
||||||
Superblock* GetSuperblock();
|
Superblock* GetSuperblock();
|
||||||
|
@ -33,17 +32,11 @@ 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:
|
||||||
DenaliClient denali_;
|
ScopedDenaliClient denali_;
|
||||||
uint64_t device_id_;
|
|
||||||
uint64_t lba_offset_;
|
|
||||||
MappedMemoryRegion super_block_region_;
|
MappedMemoryRegion super_block_region_;
|
||||||
|
|
||||||
Ext2BlockReader(DenaliClient&& denali, uint64_t device_id,
|
Ext2BlockReader(ScopedDenaliClient&& denali, MappedMemoryRegion super_block);
|
||||||
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(const DenaliInfo& denali_info) {
|
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(ScopedDenaliClient&& denali) {
|
||||||
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
||||||
Ext2BlockReader::Init(glcr::Move(denali_info)));
|
Ext2BlockReader::Init(glcr::Move(denali)));
|
||||||
|
|
||||||
ASSIGN_OR_RETURN(
|
ASSIGN_OR_RETURN(
|
||||||
MappedMemoryRegion bgdt,
|
MappedMemoryRegion bgdt,
|
||||||
|
@ -99,31 +99,10 @@ 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 (inode->block[14]) {
|
if (real_block_cnt > 1) {
|
||||||
dbgln("Can't handle triply-indirect blocks yet.");
|
dbgln("Can't handle scatter-gather yet.");
|
||||||
return glcr::UNIMPLEMENTED;
|
return glcr::UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inode->block[13]) {
|
return ext2_reader_->ReadBlock(inode->block[0]);
|
||||||
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(const DenaliInfo& denali_info);
|
static glcr::ErrorOr<Ext2Driver> Init(ScopedDenaliClient&& denali);
|
||||||
|
|
||||||
glcr::ErrorCode ProbePartition();
|
glcr::ErrorCode ProbePartition();
|
||||||
|
|
||||||
|
|
|
@ -28,20 +28,19 @@ 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) {
|
||||||
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);
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
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 {
|
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -87,21 +86,6 @@ 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) {
|
||||||
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);
|
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));
|
||||||
|
@ -110,8 +94,22 @@ void OpenFileResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uin
|
||||||
// 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.
|
||||||
// Skip Cap.
|
// 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) {
|
||||||
|
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)));
|
||||||
|
// Parse memory.
|
||||||
|
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||||
|
|
||||||
|
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,7 +3,6 @@
|
||||||
|
|
||||||
#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 {
|
||||||
|
@ -23,8 +22,6 @@ 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:
|
||||||
|
@ -49,6 +46,4 @@ 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,3 +1,4 @@
|
||||||
|
#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>
|
||||||
|
@ -14,7 +15,10 @@ 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));
|
||||||
ASSIGN_OR_RETURN(Ext2Driver ext2, Ext2Driver::Init(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(auto server, VFSServer::Create(ext2));
|
ASSIGN_OR_RETURN(auto server, VFSServer::Create(ext2));
|
||||||
|
|
||||||
|
|
|
@ -28,29 +28,26 @@ 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) {
|
||||||
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);
|
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.
|
||||||
// Skip Cap.
|
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||||
|
set_endpoint_capability(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
CheckHeader(bytes);
|
||||||
|
// Parse endpoint_name.
|
||||||
|
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||||
|
|
||||||
|
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
|
||||||
|
// Parse endpoint_capability.
|
||||||
|
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
|
||||||
|
|
||||||
|
set_endpoint_capability(caps.At(endpoint_capability_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -102,16 +99,11 @@ 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) {
|
||||||
ParseFromBytesInternal(bytes, offset);
|
CheckHeader(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -135,27 +127,22 @@ 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) {
|
||||||
ParseFromBytesInternal(bytes, offset);
|
CheckHeader(bytes);
|
||||||
// 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) {
|
||||||
ParseFromBytesInternal(bytes, offset);
|
CheckHeader(bytes);
|
||||||
// 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 {
|
||||||
|
@ -189,14 +176,6 @@ 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) {
|
||||||
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);
|
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)));
|
||||||
|
@ -222,7 +201,34 @@ void FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint
|
||||||
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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
CheckHeader(bytes);
|
||||||
|
// Parse address_phys.
|
||||||
|
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||||
|
// Parse width.
|
||||||
|
set_width(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||||
|
// Parse height.
|
||||||
|
set_height(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||||
|
// Parse pitch.
|
||||||
|
set_pitch(bytes.At<uint64_t>(offset + header_size + (8 * 3)));
|
||||||
|
// Parse bpp.
|
||||||
|
set_bpp(bytes.At<uint64_t>(offset + header_size + (8 * 4)));
|
||||||
|
// Parse memory_model.
|
||||||
|
set_memory_model(bytes.At<uint64_t>(offset + header_size + (8 * 5)));
|
||||||
|
// Parse red_mask_size.
|
||||||
|
set_red_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 6)));
|
||||||
|
// Parse red_mask_shift.
|
||||||
|
set_red_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 7)));
|
||||||
|
// Parse green_mask_size.
|
||||||
|
set_green_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 8)));
|
||||||
|
// Parse green_mask_shift.
|
||||||
|
set_green_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 9)));
|
||||||
|
// Parse blue_mask_size.
|
||||||
|
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
|
||||||
|
// Parse blue_mask_shift.
|
||||||
|
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
@ -294,29 +300,26 @@ 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) {
|
||||||
ParseFromBytesInternal(bytes, offset);
|
CheckHeader(bytes);
|
||||||
// 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);
|
||||||
}
|
|
||||||
|
|
||||||
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
|
||||||
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.
|
// 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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||||
|
CheckHeader(bytes);
|
||||||
|
// 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));
|
||||||
|
// 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 {
|
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#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 {
|
||||||
|
@ -26,8 +25,6 @@ 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:
|
||||||
|
@ -43,8 +40,6 @@ class Empty {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Parses everything except for caps.
|
|
||||||
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
|
|
||||||
};
|
};
|
||||||
class AhciInfo {
|
class AhciInfo {
|
||||||
public:
|
public:
|
||||||
|
@ -66,8 +61,6 @@ 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:
|
||||||
|
@ -119,8 +112,6 @@ 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:
|
||||||
|
@ -145,6 +136,4 @@ 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,6 +63,8 @@ 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,27 +43,21 @@ void* KernelHeap::Allocate(uint64_t size) {
|
||||||
if (ptr_or.ok()) {
|
if (ptr_or.ok()) {
|
||||||
return ptr_or.value();
|
return ptr_or.value();
|
||||||
}
|
}
|
||||||
#if K_HEAP_DEBUG
|
dbgln("Failed allocation (slab 8): {x}", ptr_or.error());
|
||||||
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();
|
||||||
}
|
}
|
||||||
#if K_HEAP_DEBUG
|
dbgln("Failed allocation (slab 16): {x}", ptr_or.error());
|
||||||
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();
|
||||||
}
|
}
|
||||||
#if K_HEAP_DEBUG
|
dbgln("Failed allocation (slab 32): {x}", ptr_or.error());
|
||||||
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