[denali] Get all caps from the init port.
This allows us to remove the bootstrap capabilities for good woo hoo!
This commit is contained in:
parent
6e86ce67f0
commit
7dcbbd671e
11 changed files with 62 additions and 28 deletions
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <zerrors.h>
|
||||
|
||||
extern uint64_t gSelfProcCap;
|
||||
extern uint64_t gSelfVmasCap;
|
||||
|
||||
extern uint64_t gBootDenaliVmmoCap;
|
||||
#include <zglobal.h>
|
||||
|
||||
z_err_t ParseInitPort(uint64_t init_port_cap);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
#include <zerrors.h>
|
||||
|
||||
class Port {
|
||||
|
|
@ -9,6 +10,15 @@ class Port {
|
|||
|
||||
z_err_t PollForIntCap(uint64_t* msg, uint64_t* cap);
|
||||
|
||||
template <typename T>
|
||||
z_err_t WriteMessage(const T& obj, uint64_t cap);
|
||||
|
||||
private:
|
||||
uint64_t port_cap_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
z_err_t Port::WriteMessage(const T& obj, uint64_t cap) {
|
||||
return ZPortSend(port_cap_, sizeof(obj),
|
||||
reinterpret_cast<const uint8_t*>(&obj), 1, &cap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
uint64_t gSelfProcCap = 0;
|
||||
uint64_t gSelfVmasCap = 0;
|
||||
|
||||
uint64_t gInitChannelCap = 0;
|
||||
|
||||
uint64_t gBootDenaliVmmoCap = 0;
|
||||
|
||||
z_err_t ParseInitPort(uint64_t init_port_cap) {
|
||||
|
|
@ -25,6 +27,9 @@ z_err_t ParseInitPort(uint64_t init_port_cap) {
|
|||
dbgln("received vmas");
|
||||
gSelfVmasCap = init_cap;
|
||||
break;
|
||||
case Z_INIT_CHANNEL:
|
||||
gInitChannelCap = init_cap;
|
||||
break;
|
||||
case Z_BOOT_DENALI_VMMO:
|
||||
dbgln("received denali");
|
||||
gBootDenaliVmmoCap = init_cap;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <zinit.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/init.h"
|
||||
|
||||
MappedMemoryRegion MappedMemoryRegion::DirectPhysical(uint64_t paddr,
|
||||
uint64_t size) {
|
||||
|
|
@ -11,7 +12,7 @@ MappedMemoryRegion MappedMemoryRegion::DirectPhysical(uint64_t paddr,
|
|||
check(ZMemoryObjectCreatePhysical(paddr, size, &vmmo_cap));
|
||||
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, vmmo_cap, &vaddr));
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
|
||||
|
||||
return MappedMemoryRegion(vmmo_cap, paddr, vaddr, size);
|
||||
}
|
||||
|
|
@ -21,7 +22,7 @@ MappedMemoryRegion MappedMemoryRegion::ContiguousPhysical(uint64_t size) {
|
|||
check(ZMemoryObjectCreateContiguous(size, &vmmo_cap, &paddr));
|
||||
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, vmmo_cap, &vaddr));
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
|
||||
|
||||
return MappedMemoryRegion(vmmo_cap, paddr, vaddr, size);
|
||||
}
|
||||
|
|
@ -31,7 +32,7 @@ MappedMemoryRegion MappedMemoryRegion::Default(uint64_t size) {
|
|||
check(ZMemoryObjectCreate(size, &vmmo_cap));
|
||||
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(Z_INIT_VMAS_SELF, 0, vmmo_cap, &vaddr));
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
|
||||
|
||||
return MappedMemoryRegion(vmmo_cap, 0, vaddr, size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "mammoth/channel.h"
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/init.h"
|
||||
#include "mammoth/port.h"
|
||||
|
||||
#define MAM_PROC_DEBUG 0
|
||||
|
||||
|
|
@ -99,26 +100,40 @@ uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
|
|||
Channel foreign;
|
||||
check(CreateChannels(local, foreign));
|
||||
|
||||
uint64_t proc_cap;
|
||||
uint64_t as_cap;
|
||||
uint64_t foreign_port_id;
|
||||
uint64_t port_cap;
|
||||
#if MAM_PROC_DEBUG
|
||||
dbgln("Port Create");
|
||||
#endif
|
||||
check(ZPortCreate(&port_cap));
|
||||
uint64_t port_cap_donate;
|
||||
check(ZCapDuplicate(port_cap, &port_cap_donate));
|
||||
|
||||
#if MAM_PROC_DEBUG
|
||||
dbgln("Spawn");
|
||||
#endif
|
||||
uint64_t proc_cap;
|
||||
uint64_t as_cap;
|
||||
uint64_t foreign_chan_id;
|
||||
check(ZProcessSpawn(gSelfProcCap, foreign.release_cap(), &proc_cap, &as_cap,
|
||||
&foreign_chan_id));
|
||||
check(ZProcessSpawn(gSelfProcCap, port_cap_donate, &proc_cap, &as_cap,
|
||||
&foreign_port_id));
|
||||
|
||||
uint64_t entry_point = LoadElfProgram(program, as_cap);
|
||||
|
||||
#if MAM_PROC_DEBUG
|
||||
dbgln("Thread Create");
|
||||
#endif
|
||||
uint64_t thread_cap;
|
||||
check(ZThreadCreate(proc_cap, &thread_cap));
|
||||
|
||||
Port p(port_cap);
|
||||
check(p.WriteMessage<uint64_t>(Z_INIT_SELF_PROC, proc_cap));
|
||||
check(p.WriteMessage<uint64_t>(Z_INIT_SELF_VMAS, as_cap));
|
||||
check(p.WriteMessage<uint64_t>(Z_INIT_CHANNEL, foreign.release_cap()));
|
||||
|
||||
#if MAM_PROC_DEBUG
|
||||
dbgln("Thread start");
|
||||
#endif
|
||||
check(ZThreadStart(thread_cap, entry_point, foreign_chan_id, 0));
|
||||
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <zinit.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/init.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ extern "C" void thread_entry(Thread::Entry entry, void* arg1) {
|
|||
} // namespace
|
||||
|
||||
Thread::Thread(Entry e, const void* arg1) {
|
||||
check(ZThreadCreate(Z_INIT_PROC_SELF, &thread_cap_));
|
||||
check(ZThreadCreate(gSelfProcCap, &thread_cap_));
|
||||
check(ZThreadStart(thread_cap_, reinterpret_cast<uint64_t>(thread_entry),
|
||||
reinterpret_cast<uint64_t>(e),
|
||||
reinterpret_cast<uint64_t>(arg1)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue