[mammoth] Create a method for getting initial caps.

This commit is contained in:
Drew Galbraith 2023-06-16 23:51:49 -07:00
parent 4c936623b5
commit 528723e490
15 changed files with 108 additions and 22 deletions

View file

@ -2,6 +2,7 @@
#include <mammoth/debug.h>
#include <zcall.h>
#include <zinit.h>
namespace {

View file

@ -1,27 +1,19 @@
#include <denali/denali.h>
#include <mammoth/channel.h>
#include <mammoth/debug.h>
#include <mammoth/init.h>
#include <mammoth/process.h>
#include <zcall.h>
#include <zinit.h>
#include "hw/pcie.h"
uint64_t main(uint64_t port_cap) {
dbgln("Yellowstone Initializing.");
uint64_t msg_type, type, cap, bytes, caps;
check(ZPortRecv(port_cap, 8, reinterpret_cast<uint8_t*>(&msg_type), 1, &cap,
&type, &bytes, &caps));
uint64_t vmmo_cap = 0;
if (bytes != 8 || caps != 1) {
crash("Invalid boot msg", Z_ERR_INVALID);
}
if (msg_type == Z_INIT_BOOT_VMMO) {
vmmo_cap = cap;
} else {
crash("Missing vmmo cap", Z_ERR_UNIMPLEMENTED);
}
check(ParseInitPort(port_cap));
uint64_t vaddr;
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, vmmo_cap, &vaddr));
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, gBootDenaliVmmoCap, &vaddr));
Channel local;
check(SpawnProcessFromElfRegion(vaddr, local));
@ -35,7 +27,7 @@ uint64_t main(uint64_t port_cap) {
reinterpret_cast<uint8_t*>(&read), 0, nullptr));
DenaliReadResponse resp;
uint64_t mem_cap;
uint64_t mem_cap, type, bytes, caps;
check(ZChannelRecv(local.cap(), sizeof(resp),
reinterpret_cast<uint8_t*>(&resp), 1, &mem_cap, &type,