[Sys] Successfully spin up a new process from disk.
This commit is contained in:
parent
e5568450c2
commit
7c105c8a31
22 changed files with 415 additions and 191 deletions
|
|
@ -28,16 +28,14 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
|||
|
||||
} // namespace
|
||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
|
|
@ -45,6 +43,7 @@ void ReadRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset,
|
|||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
|
|
@ -79,45 +78,117 @@ uint64_t ReadRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset,
|
|||
|
||||
return next_extension;
|
||||
}
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadManyRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
}
|
||||
|
||||
void ReadManyRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
auto lba_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 1));
|
||||
|
||||
lba_.Resize(lba_pointer.length / sizeof(uint64_t));
|
||||
for (uint64_t i = offset + lba_pointer.offset;
|
||||
i < offset + lba_pointer.offset + lba_pointer.length;
|
||||
i += sizeof(uint64_t)) {
|
||||
lba_.PushBack(bytes.At<uint64_t>(i));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
ExtPointer lba_ptr{
|
||||
.offset = next_extension,
|
||||
.length = (uint32_t)(lba().size() * sizeof(uint64_t)),
|
||||
};
|
||||
|
||||
next_extension += lba_ptr.length;
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 1), lba_ptr);
|
||||
|
||||
for (uint64_t i = 0; i < lba().size(); i++) {
|
||||
uint32_t ext_offset = offset + lba_ptr.offset + (i * sizeof(uint64_t));
|
||||
bytes.WriteAt<uint64_t>(ext_offset, lba().at(i));
|
||||
}
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t ReadManyRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
ExtPointer lba_ptr{
|
||||
.offset = next_extension,
|
||||
.length = (uint32_t)(lba().size() * sizeof(uint64_t)),
|
||||
};
|
||||
|
||||
next_extension += lba_ptr.length;
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 1), lba_ptr);
|
||||
|
||||
for (uint64_t i = 0; i < lba().size(); i++) {
|
||||
uint32_t ext_offset = offset + lba_ptr.offset + (i * sizeof(uint64_t));
|
||||
bytes.WriteAt<uint64_t>(ext_offset, lba().at(i));
|
||||
}
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_memory(0);
|
||||
}
|
||||
|
||||
void ReadResponse::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse lba.
|
||||
set_lba(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
ParseFromBytesInternal(bytes, offset);
|
||||
// Parse memory.
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 3));
|
||||
uint64_t memory_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
|
||||
set_memory(caps.At(memory_ptr));
|
||||
}
|
||||
|
||||
void ReadResponse::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
// Parse device_id.
|
||||
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
|
||||
// Parse size.
|
||||
set_size(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse memory.
|
||||
// Skip Cap.
|
||||
|
||||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
|
||||
uint32_t next_extension = header_size + 8 * 4;
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), lba());
|
||||
// Write size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||
// Write memory.
|
||||
// FIXME: Implement inbuffer capabilities.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), 0);
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
|
@ -126,18 +197,16 @@ uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset
|
|||
}
|
||||
|
||||
uint64_t ReadResponse::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) const {
|
||||
uint32_t next_extension = header_size + 8 * 4;
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write device_id.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 0), device_id());
|
||||
// Write lba.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), lba());
|
||||
// Write size.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), size());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), size());
|
||||
// Write memory.
|
||||
caps.WriteAt(next_cap, memory());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 3), next_cap++);
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue