[Sys] Successfully spin up a new process from disk.

This commit is contained in:
Drew Galbraith 2023-11-15 09:47:32 -08:00
parent e5568450c2
commit 7c105c8a31
22 changed files with 415 additions and 191 deletions

View file

@ -28,26 +28,29 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
} // namespace
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse endpoint_name.
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
ParseFromBytesInternal(bytes, offset);
// Parse endpoint_capability.
// FIXME: Implement in-buffer capabilities for inprocess serialization.
set_endpoint_capability(0);
}
void RegisterEndpointRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
ParseFromBytesInternal(bytes, offset);
// Parse endpoint_capability.
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
set_endpoint_capability(caps.At(endpoint_capability_ptr));
}
void RegisterEndpointRequest::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse endpoint_name.
auto endpoint_name_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
set_endpoint_name(bytes.StringAt(offset + endpoint_name_pointer.offset, endpoint_name_pointer.length));
// Parse endpoint_capability.
uint64_t endpoint_capability_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 1));
// Skip Cap.
set_endpoint_capability(caps.At(endpoint_capability_ptr));
}
uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
@ -99,11 +102,16 @@ uint64_t RegisterEndpointRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint
return next_extension;
}
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
ParseFromBytesInternal(bytes, offset);
}
void Empty::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
ParseFromBytesInternal(bytes, offset);
}
void Empty::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
}
uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
@ -127,22 +135,27 @@ uint64_t Empty::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr:
return next_extension;
}
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
ParseFromBytesInternal(bytes, offset);
// Parse ahci_region.
// FIXME: Implement in-buffer capabilities for inprocess serialization.
set_ahci_region(0);
// Parse region_length.
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
}
void AhciInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
CheckHeader(bytes);
ParseFromBytesInternal(bytes, offset);
// Parse ahci_region.
uint64_t ahci_region_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
set_ahci_region(caps.At(ahci_region_ptr));
}
void AhciInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse ahci_region.
// Skip Cap.
// Parse region_length.
set_region_length(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
}
uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
@ -176,34 +189,14 @@ uint64_t AhciInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, gl
return next_extension;
}
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse address_phys.
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
// Parse width.
set_width(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
// Parse height.
set_height(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
// Parse pitch.
set_pitch(bytes.At<uint64_t>(offset + header_size + (8 * 3)));
// Parse bpp.
set_bpp(bytes.At<uint64_t>(offset + header_size + (8 * 4)));
// Parse memory_model.
set_memory_model(bytes.At<uint64_t>(offset + header_size + (8 * 5)));
// Parse red_mask_size.
set_red_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 6)));
// Parse red_mask_shift.
set_red_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 7)));
// Parse green_mask_size.
set_green_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 8)));
// Parse green_mask_shift.
set_green_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 9)));
// Parse blue_mask_size.
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
// Parse blue_mask_shift.
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
ParseFromBytesInternal(bytes, offset);
}
void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
ParseFromBytesInternal(bytes, offset);
}
void FramebufferInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse address_phys.
set_address_phys(bytes.At<uint64_t>(offset + header_size + (8 * 0)));
@ -229,6 +222,7 @@ void FramebufferInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t off
set_blue_mask_size(bytes.At<uint64_t>(offset + header_size + (8 * 10)));
// Parse blue_mask_shift.
set_blue_mask_shift(bytes.At<uint64_t>(offset + header_size + (8 * 11)));
}
uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {
@ -300,26 +294,29 @@ uint64_t FramebufferInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t off
return next_extension;
}
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
ParseFromBytesInternal(bytes, offset);
// Parse denali_endpoint.
// FIXME: Implement in-buffer capabilities for inprocess serialization.
set_denali_endpoint(0);
// Parse device_id.
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
// Parse lba_offset.
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
}
void DenaliInfo::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
CheckHeader(bytes);
ParseFromBytesInternal(bytes, offset);
// Parse denali_endpoint.
uint64_t denali_endpoint_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 0));
set_denali_endpoint(caps.At(denali_endpoint_ptr));
}
void DenaliInfo::ParseFromBytesInternal(const glcr::ByteBuffer& bytes, uint64_t offset) {
CheckHeader(bytes);
// Parse denali_endpoint.
// Skip Cap.
// Parse device_id.
set_device_id(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
// Parse lba_offset.
set_lba_offset(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
}
uint64_t DenaliInfo::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) const {

View file

@ -3,6 +3,7 @@
#include <glacier/buffer/byte_buffer.h>
#include <glacier/buffer/cap_buffer.h>
#include <glacier/container/vector.h>
#include <glacier/string/string.h>
#include <ztypes.h>
class RegisterEndpointRequest {
@ -15,9 +16,9 @@ class RegisterEndpointRequest {
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
glcr::String endpoint_name() const { return endpoint_name_; }
void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; }
void set_endpoint_name(const glcr::String& value) { endpoint_name_ = value; }
z_cap_t endpoint_capability() const { return endpoint_capability_; }
void set_endpoint_capability(const z_cap_t& value) { endpoint_capability_ = value; }
@ -25,6 +26,8 @@ class RegisterEndpointRequest {
glcr::String endpoint_name_;
z_cap_t endpoint_capability_;
// Parses everything except for caps.
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
};
class Empty {
public:
@ -40,6 +43,8 @@ class Empty {
private:
// Parses everything except for caps.
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
};
class AhciInfo {
public:
@ -51,9 +56,9 @@ class AhciInfo {
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
z_cap_t ahci_region() const { return ahci_region_; }
void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; }
void set_ahci_region(const z_cap_t& value) { ahci_region_ = value; }
uint64_t region_length() const { return region_length_; }
void set_region_length(const uint64_t& value) { region_length_ = value; }
@ -61,6 +66,8 @@ class AhciInfo {
z_cap_t ahci_region_;
uint64_t region_length_;
// Parses everything except for caps.
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
};
class FramebufferInfo {
public:
@ -72,29 +79,29 @@ class FramebufferInfo {
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
uint64_t address_phys() const { return address_phys_; }
void set_address_phys(const uint64_t& value) { address_phys_ = value; }
void set_address_phys(const uint64_t& value) { address_phys_ = value; }
uint64_t width() const { return width_; }
void set_width(const uint64_t& value) { width_ = value; }
void set_width(const uint64_t& value) { width_ = value; }
uint64_t height() const { return height_; }
void set_height(const uint64_t& value) { height_ = value; }
void set_height(const uint64_t& value) { height_ = value; }
uint64_t pitch() const { return pitch_; }
void set_pitch(const uint64_t& value) { pitch_ = value; }
void set_pitch(const uint64_t& value) { pitch_ = value; }
uint64_t bpp() const { return bpp_; }
void set_bpp(const uint64_t& value) { bpp_ = value; }
void set_bpp(const uint64_t& value) { bpp_ = value; }
uint64_t memory_model() const { return memory_model_; }
void set_memory_model(const uint64_t& value) { memory_model_ = value; }
void set_memory_model(const uint64_t& value) { memory_model_ = value; }
uint64_t red_mask_size() const { return red_mask_size_; }
void set_red_mask_size(const uint64_t& value) { red_mask_size_ = value; }
void set_red_mask_size(const uint64_t& value) { red_mask_size_ = value; }
uint64_t red_mask_shift() const { return red_mask_shift_; }
void set_red_mask_shift(const uint64_t& value) { red_mask_shift_ = value; }
void set_red_mask_shift(const uint64_t& value) { red_mask_shift_ = value; }
uint64_t green_mask_size() const { return green_mask_size_; }
void set_green_mask_size(const uint64_t& value) { green_mask_size_ = value; }
void set_green_mask_size(const uint64_t& value) { green_mask_size_ = value; }
uint64_t green_mask_shift() const { return green_mask_shift_; }
void set_green_mask_shift(const uint64_t& value) { green_mask_shift_ = value; }
void set_green_mask_shift(const uint64_t& value) { green_mask_shift_ = value; }
uint64_t blue_mask_size() const { return blue_mask_size_; }
void set_blue_mask_size(const uint64_t& value) { blue_mask_size_ = value; }
void set_blue_mask_size(const uint64_t& value) { blue_mask_size_ = value; }
uint64_t blue_mask_shift() const { return blue_mask_shift_; }
void set_blue_mask_shift(const uint64_t& value) { blue_mask_shift_ = value; }
@ -112,6 +119,8 @@ class FramebufferInfo {
uint64_t blue_mask_size_;
uint64_t blue_mask_shift_;
// Parses everything except for caps.
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
};
class DenaliInfo {
public:
@ -123,11 +132,11 @@ class DenaliInfo {
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset);
void ParseFromBytes(const glcr::ByteBuffer&, uint64_t offset, const glcr::CapBuffer&);
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
uint64_t SerializeToBytes(glcr::ByteBuffer&, uint64_t offset, glcr::CapBuffer&) const;
z_cap_t denali_endpoint() const { return denali_endpoint_; }
void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; }
void set_denali_endpoint(const z_cap_t& value) { denali_endpoint_ = value; }
uint64_t device_id() const { return device_id_; }
void set_device_id(const uint64_t& value) { device_id_ = value; }
void set_device_id(const uint64_t& value) { device_id_ = value; }
uint64_t lba_offset() const { return lba_offset_; }
void set_lba_offset(const uint64_t& value) { lba_offset_ = value; }
@ -136,4 +145,6 @@ class DenaliInfo {
uint64_t device_id_;
uint64_t lba_offset_;
// Parses everything except for caps.
void ParseFromBytesInternal(const glcr::ByteBuffer&, uint64_t offset);
};