Move userspace to a templated StrFormat.

This commit is contained in:
Drew Galbraith 2023-11-03 02:48:21 -07:00
parent d9df1212b7
commit 26b61db021
25 changed files with 263 additions and 217 deletions

View file

@ -66,36 +66,36 @@ glcr::ErrorCode GptReader::ParsePartitionTables() {
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);
dbgln("Invalid MBR Sig: {x}", *mbr_sig);
return glcr::FAILED_PRECONDITION;
}
MbrPartition* first_partition =
reinterpret_cast<MbrPartition*>(lba_1_and_2.vaddr() + 0x1BE);
if (first_partition->boot_indicator != 0) {
dbgln("Boot indicator set: %u", first_partition->boot_indicator);
dbgln("Boot indicator set: {}", first_partition->boot_indicator);
return glcr::FAILED_PRECONDITION;
}
if (first_partition->os_type != 0xEE) {
dbgln("Incorrect OS type: %x", first_partition->os_type);
dbgln("Incorrect OS type: {x}", first_partition->os_type);
return glcr::FAILED_PRECONDITION;
}
dbgln("LBAs: (%x, %x)", first_partition->starting_lba,
dbgln("LBAs: ({x}, {x})", first_partition->starting_lba,
first_partition->ending_lba);
// FIXME: Don't hardcode sector size.
ParititionHeader* header =
reinterpret_cast<ParititionHeader*>(lba_1_and_2.vaddr() + 512);
dbgln("signature %lx", header->signature);
dbgln("signature {}", header->signature);
uint64_t num_partitions = header->num_partitions;
uint64_t entry_size = header->parition_entry_size;
uint64_t num_blocks = (num_partitions * entry_size) / 512;
dbgln("lba_partition_entries %lx", header->lba_partition_entries);
dbgln("num_partitions: %x", num_partitions);
dbgln("partition_entry_size: %x", entry_size);
dbgln("Num blocks: %x", num_blocks);
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);
req.set_device_id(0);
req.set_lba(header->lba_partition_entries);
@ -108,11 +108,11 @@ glcr::ErrorCode GptReader::ParsePartitionTables() {
PartitionEntry* entry = reinterpret_cast<PartitionEntry*>(
part_table.vaddr() + (i * entry_size));
if (entry->type_guid_low != 0 || entry->type_guid_high != 0) {
dbgln("Entry %u", i);
dbgln("T Guid: %lx-%lx", entry->type_guid_high, entry->type_guid_low);
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);
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);
// 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

View file

@ -18,7 +18,7 @@ PciReader::PciReader() {
dbgln("Creating addr space");
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootPciVmmoCap, &vaddr));
dbgln("Addr %lx", vaddr);
dbgln("Addr {x}", vaddr);
dbgln("Dumping PCI");
PciDump(vaddr);
@ -41,8 +41,8 @@ void PciReader::FunctionDump(uint64_t base, uint64_t bus, uint64_t dev,
return;
}
dbgln(
"[%u.%u.%u] (Vendor, Device): (%x, %x), (Type, Class, Sub, PIF): (%u, "
"%x, %x, %x)",
"[{}.{}.{}] (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);
@ -50,7 +50,7 @@ void PciReader::FunctionDump(uint64_t base, uint64_t bus, uint64_t dev,
dbgln("FIXME: Handle PCI to PCI bridge.");
}
if (hdr->class_code == 0x1) {
dbgln("SATA Device at: %lx", reinterpret_cast<uint64_t>(hdr) - base);
dbgln("SATA Device at: {x}", reinterpret_cast<uint64_t>(hdr) - base);
achi_device_offset_ = reinterpret_cast<uint64_t>(hdr) - base;
}
}

View file

@ -1,3 +1,4 @@
#include <glacier/string/str_format.h>
#include <mammoth/debug.h>
#include <mammoth/endpoint_client.h>
#include <mammoth/init.h>
@ -16,8 +17,8 @@ glcr::ErrorCode SpawnProcess(z_cap_t vmmo_cap, z_cap_t yellowstone_cap) {
}
uint64_t main(uint64_t port_cap) {
dbgln("Yellowstone Initializing.");
check(ParseInitPort(port_cap));
dbgln("Yellowstone Initializing.");
ASSIGN_OR_RETURN(auto server, YellowstoneServer::Create());
Thread server_thread = server->RunServer();
@ -45,7 +46,7 @@ uint64_t main(uint64_t port_cap) {
glcr::String file(reinterpret_cast<const char*>(filemem.vaddr()),
response.size());
dbgln("Test: '%s'", file.cstr());
dbgln("Test: '{}'", file.cstr());
check(server_thread.Join());
dbgln("Yellowstone Finished Successfully.");

View file

@ -90,7 +90,7 @@ glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
vfs_client_ = glcr::MakeShared<VFSClient>(victoria_falls_cap_);
check(has_victoriafalls_mutex_.Release());
} else {
dbgln("[WARN] Got endpoint cap type: %s", req.endpoint_name().cstr());
dbgln("[WARN] Got endpoint cap type: {}", req.endpoint_name().cstr());
}
return glcr::OK;
}