[Denali] Move denali server to yunq.

This commit is contained in:
Drew Galbraith 2023-10-25 20:28:28 -07:00
parent acfaf26391
commit 3e4fdfee84
25 changed files with 526 additions and 163 deletions

View file

@ -9,9 +9,9 @@ target_include_directories(yellowstone
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(yellowstone
denali_yunq
mammoth
glacier
denali_stub
yellowstone_yunq
)
@ -31,7 +31,6 @@ target_include_directories(yellowstone_yunq
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib")
target_link_libraries(yellowstone_yunq
denali_stub
mammoth
)

View file

@ -1,7 +1,9 @@
#include "hw/gpt.h"
#include <glacier/memory/move.h>
#include <glacier/status/error.h>
#include <mammoth/debug.h>
#include <mammoth/memory_region.h>
#include <zcall.h>
#include <zglobal.h>
@ -54,8 +56,14 @@ GptReader::GptReader(glcr::UniquePtr<DenaliClient> denali)
: denali_(glcr::Move(denali)) {}
glcr::ErrorCode GptReader::ParsePartitionTables() {
ASSIGN_OR_RETURN(MappedMemoryRegion lba_1_and_2,
denali_->ReadSectors(0, 0, 2));
ReadRequest req;
req.set_device_id(0);
req.set_lba(0);
req.set_size(2);
ReadResponse resp;
RET_ERR(denali_->Read(req, resp));
MappedMemoryRegion lba_1_and_2 =
MappedMemoryRegion::FromCapability(resp.memory());
uint16_t* mbr_sig = reinterpret_cast<uint16_t*>(lba_1_and_2.vaddr() + 0x1FE);
if (*mbr_sig != 0xAA55) {
dbgln("Invalid MBR Sig: %x", *mbr_sig);
@ -89,9 +97,12 @@ glcr::ErrorCode GptReader::ParsePartitionTables() {
dbgln("partition_entry_size: %x", entry_size);
dbgln("Num blocks: %x", num_blocks);
ASSIGN_OR_RETURN(
MappedMemoryRegion part_table,
denali_->ReadSectors(0, header->lba_partition_entries, num_blocks));
req.set_device_id(0);
req.set_lba(header->lba_partition_entries);
req.set_size(num_blocks);
RET_ERR(denali_->Read(req, resp));
MappedMemoryRegion part_table =
MappedMemoryRegion::FromCapability(resp.memory());
dbgln("Entries");
for (uint64_t i = 0; i < num_partitions; i++) {
PartitionEntry* entry = reinterpret_cast<PartitionEntry*>(
@ -102,9 +113,10 @@ glcr::ErrorCode GptReader::ParsePartitionTables() {
dbgln("P Guid: %lx-%lx", entry->part_guid_high, entry->part_guid_low);
dbgln("LBA: %lx, %lx", entry->lba_start, entry->lba_end);
dbgln("Attrs: %lx", entry->attributes);
// 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.
// 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;

View file

@ -1,6 +1,8 @@
#pragma once
#include <denali/denali_client.h>
#include <denali/denali.yunq.client.h>
#include <glacier/memory/unique_ptr.h>
#include <glacier/status/error.h>
#include <stdint.h>
#include <ztypes.h>

View file

@ -1,6 +1,6 @@
#include "yellowstone_server.h"
#include <denali/denali.h>
#include <denali/denali.yunq.client.h>
#include <glacier/string/string.h>
#include <mammoth/debug.h>
#include <mammoth/init.h>
@ -18,8 +18,8 @@ struct PartitionInfo {
};
glcr::ErrorOr<PartitionInfo> HandleDenaliRegistration(z_cap_t endpoint_cap) {
GptReader reader(glcr::UniquePtr<DenaliClient>(
new DenaliClient(EndpointClient::AdoptEndpoint(endpoint_cap))));
GptReader reader(
glcr::UniquePtr<DenaliClient>(new DenaliClient(endpoint_cap)));
RET_ERR(reader.ParsePartitionTables());