From 8f84f8c3ca693180148d9516af16979ab47979f6 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Tue, 1 Aug 2023 17:13:16 -0700 Subject: [PATCH] [zion] Remove temp PCI Memory Object create function. Pass the PCI memory space to the yellowstone init process instead. --- lib/mammoth/src/init.cpp | 5 +++++ sys/yellowstone/hw/pcie.cpp | 6 +----- zion/include/zcall.h | 1 - zion/include/zglobal.h | 1 + zion/include/ztypes.h | 3 +-- zion/loader/init_loader.cpp | 15 +++++++++++++++ zion/syscall/memory_object.cpp | 11 ----------- zion/syscall/memory_object.h | 1 - zion/syscall/syscall.cpp | 1 - 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/mammoth/src/init.cpp b/lib/mammoth/src/init.cpp index 474e5ab..56a441e 100644 --- a/lib/mammoth/src/init.cpp +++ b/lib/mammoth/src/init.cpp @@ -13,6 +13,7 @@ uint64_t gInitEndpointCap = 0; uint64_t gBootDenaliVmmoCap = 0; uint64_t gBootVictoriaFallsVmmoCap = 0; +uint64_t gBootPciVmmoCap = 0; z_err_t ParseInitPort(uint64_t init_port_cap) { PortServer port = PortServer::AdoptCap(init_port_cap); @@ -40,6 +41,10 @@ z_err_t ParseInitPort(uint64_t init_port_cap) { dbgln("received victoria falls"); gBootVictoriaFallsVmmoCap = init_cap; break; + case Z_BOOT_PCI_VMMO: + dbgln("received pci"); + gBootPciVmmoCap = init_cap; + break; default: dbgln("Unexpected init type %x, continuing.", init_sig); } diff --git a/sys/yellowstone/hw/pcie.cpp b/sys/yellowstone/hw/pcie.cpp index 8421589..9f08ab5 100644 --- a/sys/yellowstone/hw/pcie.cpp +++ b/sys/yellowstone/hw/pcie.cpp @@ -15,13 +15,9 @@ PciDeviceHeader* PciHeader(uint64_t base, uint64_t bus, uint64_t dev, } // namespace PciReader::PciReader() { - dbgln("Creating PCI obj"); - uint64_t vmmo_cap, vmmo_size; - check(ZTempPcieConfigObjectCreate(&vmmo_cap, &vmmo_size)); - dbgln("Creating addr space"); uint64_t vaddr; - check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr)); + check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootPciVmmoCap, &vaddr)); dbgln("Addr %lx", vaddr); dbgln("Dumping PCI"); diff --git a/zion/include/zcall.h b/zion/include/zcall.h index e3da8f1..bce4bd8 100644 --- a/zion/include/zcall.h +++ b/zion/include/zcall.h @@ -106,7 +106,6 @@ SYS3(MemoryObjectCreatePhysical, uint64_t, paddr, uint64_t, size, z_cap_t*, vmmo_cap); SYS3(MemoryObjectCreateContiguous, uint64_t, size, z_cap_t*, vmmo_cap, uint64_t*, paddr); -SYS2(TempPcieConfigObjectCreate, z_cap_t*, vmmo_cap, uint64_t*, vmmo_size); SYS2(ChannelCreate, z_cap_t*, channel1, z_cap_t*, channel2); SYS5(ChannelSend, z_cap_t, chan_cap, uint64_t, num_bytes, const void*, data, diff --git a/zion/include/zglobal.h b/zion/include/zglobal.h index 477520e..d7b2f61 100644 --- a/zion/include/zglobal.h +++ b/zion/include/zglobal.h @@ -9,3 +9,4 @@ extern uint64_t gInitEndpointCap; extern uint64_t gBootDenaliVmmoCap; extern uint64_t gBootVictoriaFallsVmmoCap; +extern uint64_t gBootPciVmmoCap; diff --git a/zion/include/ztypes.h b/zion/include/ztypes.h index a8268f3..c8ddaeb 100644 --- a/zion/include/ztypes.h +++ b/zion/include/ztypes.h @@ -27,8 +27,6 @@ const uint64_t kZionMemoryObjectCreate = 0x30; const uint64_t kZionMemoryObjectCreatePhysical = 0x31; const uint64_t kZionMemoryObjectCreateContiguous = 0x32; -const uint64_t kZionTempPcieConfigObjectCreate = 0x3F; - // IPC Calls const uint64_t kZionChannelCreate = 0x40; const uint64_t kZionChannelSend = 0x41; @@ -90,3 +88,4 @@ typedef uint64_t z_cap_t; #define Z_BOOT_DENALI_VMMO 0x4200'0000 #define Z_BOOT_VICTORIA_FALLS_VMMO 0x4200'0001 +#define Z_BOOT_PCI_VMMO 0x4200'0002 diff --git a/zion/loader/init_loader.cpp b/zion/loader/init_loader.cpp index 87b5426..14677ed 100644 --- a/zion/loader/init_loader.cpp +++ b/zion/loader/init_loader.cpp @@ -3,6 +3,7 @@ #include #include +#include "boot/acpi.h" #include "boot/boot_info.h" #include "debug/debug.h" #include "include/zcall.h" @@ -127,6 +128,16 @@ void WriteInitProgram(glcr::RefPtr port, glcr::String name, uint64_t id) { MakeRefCounted(prog_vmmo, ZC_READ | ZC_WRITE)); } +glcr::ErrorCode WritePciVmmo(glcr::RefPtr port, uint64_t id) { + ASSIGN_OR_RETURN(PcieConfiguration config, GetPciExtendedConfiguration()); + auto vmmo = + glcr::MakeRefCounted(config.base, config.offset); + + port->WriteKernel(id, MakeRefCounted(vmmo, ZC_READ | ZC_WRITE)); + + return glcr::OK; +} + } // namespace void LoadInitProgram() { @@ -147,6 +158,10 @@ void LoadInitProgram() { WriteInitProgram(port, "/sys/denali", Z_BOOT_DENALI_VMMO); WriteInitProgram(port, "/sys/victoriafalls", Z_BOOT_VICTORIA_FALLS_VMMO); + if (WritePciVmmo(port, Z_BOOT_PCI_VMMO) != glcr::OK) { + panic("Failed to provide PCI info to init."); + } + // Start process. const limine_file& init_prog = GetInitProgram("/sys/yellowstone"); uint64_t entry = LoadElfProgram( diff --git a/zion/syscall/memory_object.cpp b/zion/syscall/memory_object.cpp index a17ef00..c61c50d 100644 --- a/zion/syscall/memory_object.cpp +++ b/zion/syscall/memory_object.cpp @@ -29,14 +29,3 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) { *req->paddr = paddr; return glcr::OK; } - -z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req) { - auto& curr_proc = gScheduler->CurrentProcess(); - ASSIGN_OR_RETURN(PcieConfiguration config, GetPciExtendedConfiguration()); - auto vmmo_ref = - glcr::MakeRefCounted(config.base, config.offset); - *req->vmmo_cap = curr_proc.AddNewCapability( - StaticCastRefPtr(vmmo_ref), ZC_WRITE); - *req->vmmo_size = config.offset; - return glcr::OK; -} diff --git a/zion/syscall/memory_object.h b/zion/syscall/memory_object.h index 3b9a9c3..3938eea 100644 --- a/zion/syscall/memory_object.h +++ b/zion/syscall/memory_object.h @@ -5,4 +5,3 @@ z_err_t MemoryObjectCreate(ZMemoryObjectCreateReq* req); z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req); z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req); -z_err_t TempPcieConfigObjectCreate(ZTempPcieConfigObjectCreateReq* req); diff --git a/zion/syscall/syscall.cpp b/zion/syscall/syscall.cpp index 8e27fee..0a23048 100644 --- a/zion/syscall/syscall.cpp +++ b/zion/syscall/syscall.cpp @@ -63,7 +63,6 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) { CASE(MemoryObjectCreate); CASE(MemoryObjectCreatePhysical); CASE(MemoryObjectCreateContiguous); - CASE(TempPcieConfigObjectCreate); // syscall/ipc.h CASE(ChannelCreate); CASE(ChannelSend);