[Yellowstone][Mammoth] Delete unused cpp code.
This commit is contained in:
parent
d58cbed0df
commit
c1db6cb11f
24 changed files with 0 additions and 1590 deletions
|
|
@ -1,25 +1,2 @@
|
|||
add_executable(yellowstone
|
||||
hw/gpt.cpp
|
||||
hw/pcie.cpp
|
||||
yellowstone.cpp
|
||||
yellowstone_server.cpp
|
||||
)
|
||||
|
||||
target_include_directories(yellowstone
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(yellowstone
|
||||
denali_yunq
|
||||
mammoth
|
||||
glacier
|
||||
victoriafalls_yunq
|
||||
yellowstone_yunq
|
||||
)
|
||||
|
||||
set_target_properties(yellowstone PROPERTIES
|
||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||
)
|
||||
|
||||
yunq_gen(lib/yellowstone lib yellowstone)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,134 +0,0 @@
|
|||
#include "hw/gpt.h"
|
||||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#define GPT_DEBUG 0
|
||||
|
||||
const uint64_t kSectorSize = 512;
|
||||
|
||||
const uint64_t kGptPartitionSignature = 0x54524150'20494645;
|
||||
|
||||
const uint64_t kLfsDataLow = 0x477284830fc63daf;
|
||||
const uint64_t kLfsDataHigh = 0xe47d47d8693d798e;
|
||||
|
||||
struct MbrPartition {
|
||||
uint8_t boot_indicator;
|
||||
uint8_t starting_chs[3];
|
||||
uint8_t os_type;
|
||||
uint8_t ending_chs[3];
|
||||
uint32_t starting_lba;
|
||||
uint32_t ending_lba;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct ParititionHeader {
|
||||
uint64_t signature;
|
||||
uint32_t revision;
|
||||
uint32_t header_size;
|
||||
uint32_t crc_32;
|
||||
uint32_t reserved;
|
||||
uint64_t lba_self;
|
||||
uint64_t lba_mirror;
|
||||
uint64_t lba_min;
|
||||
uint64_t lba_max;
|
||||
uint64_t guid_low;
|
||||
uint64_t guid_high;
|
||||
uint64_t lba_partition_entries;
|
||||
uint32_t num_partitions;
|
||||
uint32_t parition_entry_size;
|
||||
uint32_t partition_entry_crc32;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct PartitionEntry {
|
||||
uint64_t type_guid_low;
|
||||
uint64_t type_guid_high;
|
||||
uint64_t part_guid_low;
|
||||
uint64_t part_guid_high;
|
||||
uint64_t lba_start;
|
||||
uint64_t lba_end;
|
||||
uint64_t attributes;
|
||||
char partition_name[72];
|
||||
} __attribute__((packed));
|
||||
|
||||
GptReader::GptReader(glcr::UniquePtr<DenaliClient> denali)
|
||||
: denali_(glcr::Move(denali)) {}
|
||||
|
||||
glcr::Status GptReader::ParsePartitionTables() {
|
||||
ReadRequest req;
|
||||
req.set_device_id(0);
|
||||
req.mutable_block().set_lba(0);
|
||||
req.mutable_block().set_size(2);
|
||||
ReadResponse resp;
|
||||
RETURN_ERROR(denali_->Read(req, resp));
|
||||
mmth::OwnedMemoryRegion lba_1_and_2 =
|
||||
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
|
||||
if (*mbr_sig != 0xAA55) {
|
||||
return glcr::FailedPrecondition(
|
||||
glcr::StrFormat("Invalid MBR Sig: {x}", *mbr_sig));
|
||||
}
|
||||
MbrPartition* first_partition =
|
||||
reinterpret_cast<MbrPartition*>(lba_1_and_2.vaddr() + 0x1BE);
|
||||
|
||||
if (first_partition->boot_indicator != 0) {
|
||||
// FIXME: This shouldn't be set but I can't figure out why it is.
|
||||
dbgln("WARN: Boot indicator set: {}", first_partition->boot_indicator);
|
||||
}
|
||||
if (first_partition->os_type != 0xEE) {
|
||||
return glcr::FailedPrecondition(
|
||||
glcr::StrFormat("Incorrect OS type: {x}", first_partition->os_type));
|
||||
}
|
||||
#if GPT_DEBUG
|
||||
dbgln("LBAs: ({x}, {x})", first_partition->starting_lba,
|
||||
first_partition->ending_lba);
|
||||
#endif
|
||||
|
||||
// FIXME: Don't hardcode sector size.
|
||||
ParititionHeader* header =
|
||||
reinterpret_cast<ParititionHeader*>(lba_1_and_2.vaddr() + 512);
|
||||
|
||||
uint64_t num_partitions = header->num_partitions;
|
||||
uint64_t entry_size = header->parition_entry_size;
|
||||
uint64_t num_blocks = (num_partitions * entry_size) / 512;
|
||||
|
||||
#if GPT_DEBUG
|
||||
dbgln("signature {}", header->signature);
|
||||
dbgln("lba_partition_entries {x}", header->lba_partition_entries);
|
||||
dbgln("num_partitions: {x}", num_partitions);
|
||||
dbgln("partition_entry_size: {x}", entry_size);
|
||||
dbgln("Num blocks: {x}", num_blocks);
|
||||
#endif
|
||||
|
||||
req.set_device_id(0);
|
||||
req.mutable_block().set_lba(header->lba_partition_entries);
|
||||
req.mutable_block().set_size(num_blocks);
|
||||
RETURN_ERROR(denali_->Read(req, resp));
|
||||
mmth::OwnedMemoryRegion part_table =
|
||||
mmth::OwnedMemoryRegion::FromCapability(resp.memory());
|
||||
for (uint64_t i = 0; i < num_partitions; i++) {
|
||||
PartitionEntry* entry = reinterpret_cast<PartitionEntry*>(
|
||||
part_table.vaddr() + (i * entry_size));
|
||||
if (entry->type_guid_low != 0 || entry->type_guid_high != 0) {
|
||||
#if GPT_DEBUG
|
||||
dbgln("Entry {}", i);
|
||||
dbgln("T Guid: {x}-{x}", entry->type_guid_high, entry->type_guid_low);
|
||||
dbgln("P Guid: {x}-{x}", entry->part_guid_high, entry->part_guid_low);
|
||||
dbgln("LBA: {x}, {x}", entry->lba_start, entry->lba_end);
|
||||
dbgln("Attrs: {x}", entry->attributes);
|
||||
#endif
|
||||
// For now we hardcode these values to the type that is
|
||||
// created in our setup script.
|
||||
// FIXME: Set up our own root partition type guid at some
|
||||
// point.
|
||||
if (entry->type_guid_low == kLfsDataLow &&
|
||||
entry->type_guid_high == kLfsDataHigh) {
|
||||
primary_partition_lba_ = entry->lba_start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <denali/denali.yunq.client.h>
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
class GptReader {
|
||||
public:
|
||||
GptReader(glcr::UniquePtr<DenaliClient> denali);
|
||||
|
||||
glcr::Status ParsePartitionTables();
|
||||
|
||||
uint64_t GetPrimaryPartitionLba() { return primary_partition_lba_; }
|
||||
|
||||
private:
|
||||
glcr::UniquePtr<DenaliClient> denali_;
|
||||
uint64_t primary_partition_lba_;
|
||||
};
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
#include "hw/pcie.h"
|
||||
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#define PCI_DEBUG 1
|
||||
|
||||
namespace {
|
||||
|
||||
PciDeviceHeader* PciHeader(uint64_t base, uint64_t bus, uint64_t dev,
|
||||
uint64_t fun) {
|
||||
return reinterpret_cast<PciDeviceHeader*>(base + (bus << 20) + (dev << 15) +
|
||||
(fun << 12));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PciReader::PciReader() {
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootPciVmmoCap, 0, &vaddr));
|
||||
|
||||
PciDump(vaddr);
|
||||
|
||||
header_ = PciHeader(vaddr, 0, 0, 0);
|
||||
}
|
||||
|
||||
z_cap_t PciReader::GetAhciVmmo() {
|
||||
uint64_t new_cap;
|
||||
check(ZMemoryObjectDuplicate(gBootPciVmmoCap, achi_device_offset_,
|
||||
kPcieConfigurationSize, &new_cap));
|
||||
return new_cap;
|
||||
}
|
||||
|
||||
z_cap_t PciReader::GetXhciVmmo() {
|
||||
uint64_t new_cap;
|
||||
check(ZMemoryObjectDuplicate(gBootPciVmmoCap, xhci_device_offset_,
|
||||
kPcieConfigurationSize, &new_cap));
|
||||
return new_cap;
|
||||
}
|
||||
|
||||
void PciReader::FunctionDump(uint64_t base, uint64_t bus, uint64_t dev,
|
||||
uint64_t fun) {
|
||||
PciDeviceHeader* hdr = PciHeader(base, bus, dev, fun);
|
||||
if (hdr->vendor_id == 0xFFFF) {
|
||||
return;
|
||||
}
|
||||
#if PCI_DEBUG
|
||||
dbgln(
|
||||
"[{}.{}.{}] (Vendor, Device): ({x}, {x}), (Type, Class, Sub, PIF): ({}, "
|
||||
"{x}, {x}, {x})",
|
||||
bus, dev, fun, hdr->vendor_id, hdr->device_id, hdr->header_type,
|
||||
hdr->class_code, hdr->subclass, hdr->prog_interface);
|
||||
#endif
|
||||
|
||||
if ((hdr->class_code == 0x6) && (hdr->subclass == 0x4)) {
|
||||
dbgln("FIXME: Handle PCI to PCI bridge.");
|
||||
}
|
||||
if (hdr->class_code == 0x1) {
|
||||
#if PCI_DEBUG
|
||||
dbgln("SATA Device at: {x}", reinterpret_cast<uint64_t>(hdr) - base);
|
||||
#endif
|
||||
achi_device_offset_ = reinterpret_cast<uint64_t>(hdr) - base;
|
||||
}
|
||||
|
||||
if (hdr->class_code == 0xC && hdr->subclass == 0x3) {
|
||||
if (hdr->prog_interface == 0x30) {
|
||||
xhci_device_offset_ = reinterpret_cast<uint64_t>(hdr) - base;
|
||||
} else {
|
||||
dbgln("WARN: Non-XHCI USB Controller found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PciReader::DeviceDump(uint64_t base, uint64_t bus, uint64_t dev) {
|
||||
PciDeviceHeader* hdr = PciHeader(base, bus, dev, 0);
|
||||
if (hdr->vendor_id == 0xFFFF) {
|
||||
return;
|
||||
}
|
||||
|
||||
FunctionDump(base, bus, dev, 0);
|
||||
|
||||
// Device is multifunction.
|
||||
if (hdr->header_type & 0x80) {
|
||||
for (uint64_t f = 1; f < 0x8; f++) {
|
||||
FunctionDump(base, bus, dev, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PciReader::BusDump(uint64_t base, uint64_t bus) {
|
||||
for (uint64_t dev = 0; dev < 0x20; dev++) {
|
||||
DeviceDump(base, bus, dev);
|
||||
}
|
||||
}
|
||||
|
||||
void PciReader::PciDump(uint64_t base) {
|
||||
PciDeviceHeader* hdr = PciHeader(base, 0, 0, 0);
|
||||
if ((hdr->header_type & 0x80) == 0) {
|
||||
// Single bus system.
|
||||
BusDump(base, 0);
|
||||
} else {
|
||||
for (uint64_t f = 0; f < 8; f++) {
|
||||
PciDeviceHeader* f_hdr = PciHeader(base, 0, 0, f);
|
||||
if (f_hdr->vendor_id != 0xFFFF) {
|
||||
BusDump(base, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
struct PciDeviceHeader {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint16_t command_reg;
|
||||
uint16_t status_reg;
|
||||
uint8_t revision;
|
||||
uint8_t prog_interface;
|
||||
uint8_t subclass;
|
||||
uint8_t class_code;
|
||||
uint8_t cache_line_size;
|
||||
uint8_t latency_timer;
|
||||
uint8_t header_type;
|
||||
uint8_t bist;
|
||||
} __attribute__((packed));
|
||||
|
||||
// TODO: Figure out if it safe to hardcode this.
|
||||
// For the memory mapped access to PCI, it may be true that
|
||||
// each configuration item is always the size of a single page.
|
||||
const uint64_t kPcieConfigurationSize = 0x1000;
|
||||
|
||||
class PciReader {
|
||||
public:
|
||||
PciReader();
|
||||
|
||||
z_cap_t GetAhciVmmo();
|
||||
z_cap_t GetXhciVmmo();
|
||||
|
||||
private:
|
||||
PciDeviceHeader* header_;
|
||||
|
||||
uint64_t achi_device_offset_ = 0;
|
||||
uint64_t xhci_device_offset_ = 0;
|
||||
|
||||
void PciDump(uint64_t vaddr);
|
||||
void BusDump(uint64_t base, uint64_t bus);
|
||||
void DeviceDump(uint64_t base, uint64_t bus, uint64_t dev);
|
||||
void FunctionDump(uint64_t base, uint64_t bus, uint64_t dev, uint64_t fun);
|
||||
};
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#include <glacier/string/str_format.h>
|
||||
#include <glacier/string/str_split.h>
|
||||
#include <mammoth/file/file.h>
|
||||
#include <mammoth/proc/process.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "hw/gpt.h"
|
||||
#include "hw/pcie.h"
|
||||
#include "yellowstone_server.h"
|
||||
|
||||
glcr::ErrorCode SpawnProcess(z_cap_t vmmo_cap, z_cap_t yellowstone_cap) {
|
||||
mmth::OwnedMemoryRegion region =
|
||||
mmth::OwnedMemoryRegion::FromCapability(vmmo_cap);
|
||||
auto error_or =
|
||||
mmth::SpawnProcessFromElfRegion(region.vaddr(), yellowstone_cap);
|
||||
if (error_or.ok()) {
|
||||
return glcr::OK;
|
||||
}
|
||||
return error_or.error();
|
||||
}
|
||||
|
||||
uint64_t main(uint64_t port_cap) {
|
||||
check(ParseInitPort(port_cap));
|
||||
dbgln("Yellowstone Initializing.");
|
||||
|
||||
ASSIGN_OR_RETURN(auto server, yellowstone::YellowstoneServer::Create());
|
||||
Thread server_thread = server->RunServer();
|
||||
|
||||
ASSIGN_OR_RETURN(uint64_t client_cap, server->CreateClientCap());
|
||||
check(SpawnProcess(gBootDenaliVmmoCap, client_cap));
|
||||
|
||||
server->WaitDenaliRegistered();
|
||||
|
||||
ASSIGN_OR_RETURN(client_cap, server->CreateClientCap());
|
||||
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client_cap));
|
||||
|
||||
server->WaitVictoriaFallsRegistered();
|
||||
|
||||
dbgln("VFS Available.");
|
||||
|
||||
mmth::File init_file = mmth::File::Open("/init.txt");
|
||||
|
||||
glcr::Vector<glcr::StringView> files =
|
||||
glcr::StrSplit(init_file.as_str(), '\n');
|
||||
|
||||
for (glcr::StringView& file : files) {
|
||||
if (!file.empty()) {
|
||||
// TODO: Implement startup dependencies.
|
||||
if (file == "teton") {
|
||||
server->WaitVoyageursRegistered();
|
||||
}
|
||||
mmth::File binary = mmth::File::Open(glcr::StrFormat("/bin/{}", file));
|
||||
|
||||
ASSIGN_OR_RETURN(client_cap, server->CreateClientCap());
|
||||
auto error_or = mmth::SpawnProcessFromElfRegion(
|
||||
(uint64_t)binary.raw_ptr(), client_cap);
|
||||
if (!error_or.ok()) {
|
||||
check(error_or.error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check(server_thread.Join());
|
||||
dbgln("Yellowstone Finished Successfully.");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
#include "yellowstone_server.h"
|
||||
|
||||
#include <denali/denali.yunq.client.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <mammoth/file/file.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#include "hw/gpt.h"
|
||||
#include "hw/pcie.h"
|
||||
|
||||
namespace yellowstone {
|
||||
namespace {
|
||||
|
||||
struct PartitionInfo {
|
||||
uint64_t device_id;
|
||||
uint64_t partition_lba;
|
||||
};
|
||||
|
||||
glcr::ErrorOr<PartitionInfo> HandleDenaliRegistration(z_cap_t endpoint_cap) {
|
||||
GptReader reader(
|
||||
glcr::UniquePtr<DenaliClient>(new DenaliClient(endpoint_cap)));
|
||||
|
||||
auto status = reader.ParsePartitionTables();
|
||||
if (!status.ok()) {
|
||||
dbgln("GPT Reader: {}", status.message());
|
||||
return status.code();
|
||||
}
|
||||
|
||||
return PartitionInfo{.device_id = 0,
|
||||
.partition_lba = reader.GetPrimaryPartitionLba()};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> YellowstoneServer::Create() {
|
||||
z_cap_t endpoint_cap;
|
||||
RET_ERR(ZEndpointCreate(&endpoint_cap));
|
||||
|
||||
return glcr::UniquePtr<YellowstoneServer>(
|
||||
new YellowstoneServer(endpoint_cap));
|
||||
}
|
||||
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
||||
: YellowstoneServerBase(endpoint_cap) {}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleGetAhciInfo(AhciInfo& info) {
|
||||
info.set_ahci_region(pci_reader_.GetAhciVmmo());
|
||||
info.set_region_length(kPcieConfigurationSize);
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleGetXhciInfo(XhciInfo& info) {
|
||||
info.set_xhci_region(pci_reader_.GetXhciVmmo());
|
||||
info.set_region_length(kPcieConfigurationSize);
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleGetFramebufferInfo(
|
||||
FramebufferInfo& info) {
|
||||
// FIXME: Don't do this for each request.
|
||||
mmth::OwnedMemoryRegion region =
|
||||
mmth::OwnedMemoryRegion::FromCapability(gBootFramebufferVmmoCap);
|
||||
ZFramebufferInfo* fb = reinterpret_cast<ZFramebufferInfo*>(region.vaddr());
|
||||
|
||||
info.set_address_phys(fb->address_phys);
|
||||
info.set_width(fb->width);
|
||||
info.set_height(fb->height);
|
||||
info.set_pitch(fb->pitch);
|
||||
info.set_bpp(fb->bpp);
|
||||
info.set_memory_model(fb->memory_model);
|
||||
info.set_red_mask_size(fb->red_mask_size);
|
||||
info.set_red_mask_shift(fb->red_mask_shift);
|
||||
info.set_green_mask_size(fb->green_mask_size);
|
||||
info.set_green_mask_shift(fb->green_mask_shift);
|
||||
info.set_blue_mask_size(fb->blue_mask_size);
|
||||
info.set_blue_mask_shift(fb->blue_mask_shift);
|
||||
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleGetDenali(DenaliInfo& info) {
|
||||
if (!endpoint_map_.Contains("denali")) {
|
||||
return glcr::NotFound("Denali Capability Not registered");
|
||||
}
|
||||
z_cap_t new_denali;
|
||||
check(ZCapDuplicate(endpoint_map_.at("denali"), kZionPerm_All, &new_denali));
|
||||
info.set_denali_endpoint(new_denali);
|
||||
info.set_device_id(device_id_);
|
||||
info.set_lba_offset(lba_offset_);
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleRegisterEndpoint(
|
||||
const RegisterEndpointRequest& req) {
|
||||
dbgln("Registering {}.", req.endpoint_name().view());
|
||||
check(endpoint_map_.Insert(req.endpoint_name(), req.endpoint_capability()));
|
||||
if (req.endpoint_name() == "denali") {
|
||||
z_cap_t dup_cap;
|
||||
check(ZCapDuplicate(req.endpoint_capability(), kZionPerm_All, &dup_cap));
|
||||
auto part_info_or = HandleDenaliRegistration(dup_cap);
|
||||
if (!part_info_or.ok()) {
|
||||
check(part_info_or.error());
|
||||
}
|
||||
device_id_ = part_info_or.value().device_id;
|
||||
lba_offset_ = part_info_or.value().partition_lba;
|
||||
|
||||
has_denali_semaphore_.Signal();
|
||||
} else if (req.endpoint_name() == "victoriafalls") {
|
||||
// FIXME: Probably make a separate copy for use within yellowstone vs
|
||||
// transmit to other processes.
|
||||
mmth::SetVfsCap(req.endpoint_capability());
|
||||
has_victoriafalls_semaphore_.Signal();
|
||||
} else if (req.endpoint_name() == "voyageurs") {
|
||||
has_voyageurs_.Signal();
|
||||
} else {
|
||||
dbgln("[WARN] Got endpoint cap type: {}", req.endpoint_name().cstr());
|
||||
}
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
glcr::Status YellowstoneServer::HandleGetEndpoint(const GetEndpointRequest& req,
|
||||
Endpoint& resp) {
|
||||
if (!endpoint_map_.Contains(req.endpoint_name())) {
|
||||
return glcr::NotFound(
|
||||
glcr::StrFormat("Endpoint '{}' not found.", req.endpoint_name()));
|
||||
}
|
||||
z_cap_t cap = endpoint_map_.at(req.endpoint_name());
|
||||
z_cap_t new_cap;
|
||||
check(ZCapDuplicate(cap, kZionPerm_All, &new_cap));
|
||||
resp.set_endpoint(new_cap);
|
||||
return glcr::Status::Ok();
|
||||
}
|
||||
|
||||
void YellowstoneServer::WaitDenaliRegistered() { has_denali_semaphore_.Wait(); }
|
||||
|
||||
void YellowstoneServer::WaitVictoriaFallsRegistered() {
|
||||
has_victoriafalls_semaphore_.Wait();
|
||||
}
|
||||
|
||||
void YellowstoneServer::WaitVoyageursRegistered() { has_voyageurs_.Wait(); }
|
||||
|
||||
} // namespace yellowstone
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/hash_map.h>
|
||||
#include <glacier/memory/shared_ptr.h>
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/sync/semaphore.h>
|
||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||
|
||||
#include "hw/pcie.h"
|
||||
#include "lib/yellowstone/yellowstone.yunq.server.h"
|
||||
|
||||
namespace yellowstone {
|
||||
|
||||
class YellowstoneServer : public YellowstoneServerBase {
|
||||
public:
|
||||
static glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> Create();
|
||||
|
||||
glcr::Status HandleGetAhciInfo(AhciInfo&) override;
|
||||
glcr::Status HandleGetXhciInfo(XhciInfo&) override;
|
||||
glcr::Status HandleGetFramebufferInfo(FramebufferInfo&) override;
|
||||
glcr::Status HandleGetDenali(DenaliInfo&) override;
|
||||
glcr::Status HandleRegisterEndpoint(const RegisterEndpointRequest&) override;
|
||||
glcr::Status HandleGetEndpoint(const GetEndpointRequest&, Endpoint&) override;
|
||||
|
||||
void WaitDenaliRegistered();
|
||||
void WaitVictoriaFallsRegistered();
|
||||
void WaitVoyageursRegistered();
|
||||
|
||||
private:
|
||||
glcr::HashMap<glcr::String, z_cap_t> endpoint_map_;
|
||||
|
||||
uint64_t device_id_ = 0;
|
||||
uint64_t lba_offset_ = 0;
|
||||
glcr::SharedPtr<VFSClient> vfs_client_;
|
||||
|
||||
PciReader pci_reader_;
|
||||
|
||||
mmth::Semaphore has_denali_semaphore_;
|
||||
mmth::Semaphore has_victoriafalls_semaphore_;
|
||||
mmth::Semaphore has_voyageurs_;
|
||||
|
||||
YellowstoneServer(z_cap_t endpoint_cap);
|
||||
};
|
||||
|
||||
} // namespace yellowstone
|
||||
Loading…
Add table
Add a link
Reference in a new issue