[yellowstone] Recieve all caps via init port.

This commit is contained in:
Drew Galbraith 2023-06-17 00:17:43 -07:00
parent 2ea1f90690
commit 09ac87e6f5
6 changed files with 18 additions and 8 deletions

View File

@ -17,11 +17,11 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
while ((ret = port.PollForIntCap(&init_sig, &init_cap)) != Z_ERR_EMPTY) {
RET_ERR(ret);
switch (init_sig) {
case Z_INIT_PROC_SELF:
case Z_INIT_SELF_PROC:
dbgln("received proc");
gSelfProcCap = init_cap;
break;
case Z_INIT_VMAS_SELF:
case Z_INIT_SELF_VMAS:
dbgln("received vmas");
gSelfVmasCap = init_cap;
break;

View File

@ -6,6 +6,7 @@
#include "mammoth/channel.h"
#include "mammoth/debug.h"
#include "mammoth/init.h"
#define MAM_PROC_DEBUG 0
@ -77,7 +78,7 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
dbgln("Map Local");
#endif
uint64_t vaddr;
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, mem_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, mem_cap, &vaddr));
#if MAM_PROC_DEBUG
dbgln("Copy");
@ -104,8 +105,8 @@ uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
uint64_t proc_cap;
uint64_t as_cap;
uint64_t foreign_chan_id;
check(ZProcessSpawn(Z_INIT_PROC_SELF, foreign.release_cap(), &proc_cap,
&as_cap, &foreign_chan_id));
check(ZProcessSpawn(gSelfProcCap, foreign.release_cap(), &proc_cap, &as_cap,
&foreign_chan_id));
uint64_t entry_point = LoadElfProgram(program, as_cap);
#if MAM_PROC_DEBUG

View File

@ -1,6 +1,7 @@
#include "hw/pcie.h"
#include <mammoth/debug.h>
#include <mammoth/init.h>
#include <zcall.h>
#include <zinit.h>
@ -92,7 +93,7 @@ void DumpPciEDevices() {
dbgln("Creating addr space");
uint64_t vaddr;
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, vmmo_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
dbgln("Addr %lx", vaddr);
dbgln("Dumping PCI");

View File

@ -13,7 +13,7 @@ uint64_t main(uint64_t port_cap) {
check(ParseInitPort(port_cap));
uint64_t vaddr;
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, gBootDenaliVmmoCap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
Channel local;
check(SpawnProcessFromElfRegion(vaddr, local));
@ -35,7 +35,7 @@ uint64_t main(uint64_t port_cap) {
dbgln("Resp: %u", type);
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, mem_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, mem_cap, &vaddr));
uint32_t* mbr = reinterpret_cast<uint32_t*>(vaddr + 0x1FE);
dbgln("MBR: %x", *mbr);

View File

@ -3,4 +3,7 @@
#define Z_INIT_PROC_SELF 0x00
#define Z_INIT_VMAS_SELF 0x01
#define Z_INIT_SELF_PROC 0x100
#define Z_INIT_SELF_VMAS 0x101
#define Z_BOOT_DENALI_VMMO 0x1000

View File

@ -133,6 +133,11 @@ void LoadInitProgram() {
auto port = MakeRefCounted<Port>();
uint64_t port_cap = proc->AddNewCapability(port, ZC_READ | ZC_WRITE);
port->WriteKernel(Z_INIT_SELF_PROC,
MakeRefCounted<Capability>(
proc, ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD));
port->WriteKernel(Z_INIT_SELF_VMAS,
MakeRefCounted<Capability>(proc->vmas(), ZC_WRITE));
port->WriteKernel(Z_BOOT_DENALI_VMMO,
MakeRefCounted<Capability>(prog2_vmmo, ZC_READ | ZC_WRITE));