[zion] Finish cleaning up process capability interface.
Make all functions generic and specify existing/vs new cap.
This commit is contained in:
parent
fc94bc5bf5
commit
242a18ae3c
|
@ -127,7 +127,7 @@ void LoadInitProgram() {
|
|||
RefPtr<MemoryObject> prog2_vmmo = MakeRefCounted<MemoryObject>(prog2.size);
|
||||
prog2_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog2.address),
|
||||
prog2.size);
|
||||
proc->AddCapability(Z_INIT_BOOT_VMMO, prog2_vmmo);
|
||||
proc->AddNewCapabilityWithId(Z_INIT_BOOT_VMMO, prog2_vmmo, ZC_WRITE);
|
||||
|
||||
proc->CreateThread()->Start(entry, 0, 0);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ z_err_t Channel::Read(ZMessage& msg) {
|
|||
msg.num_caps = next_msg->caps.size();
|
||||
auto& proc = gScheduler->CurrentProcess();
|
||||
for (uint64_t i = 0; i < msg.num_caps; i++) {
|
||||
msg.caps[i] = proc.AddCapability(next_msg->caps.PopFront());
|
||||
msg.caps[i] = proc.AddExistingCapability(next_msg->caps.PopFront());
|
||||
}
|
||||
|
||||
pending_messages_.PopFront();
|
||||
|
|
|
@ -22,9 +22,9 @@ RefPtr<Process> Process::RootProcess() {
|
|||
}
|
||||
RefPtr<Process> Process::Create() {
|
||||
auto proc = MakeRefCounted<Process>();
|
||||
proc->caps_.AddNewCapabilityWithId(Z_INIT_PROC_SELF, proc,
|
||||
proc->AddNewCapabilityWithId(Z_INIT_PROC_SELF, proc,
|
||||
ZC_PROC_SPAWN_PROC | ZC_PROC_SPAWN_THREAD);
|
||||
proc->caps_.AddNewCapabilityWithId(Z_INIT_VMAS_SELF, proc->vmas(), ZC_WRITE);
|
||||
proc->AddNewCapabilityWithId(Z_INIT_VMAS_SELF, proc->vmas(), ZC_WRITE);
|
||||
return proc;
|
||||
}
|
||||
|
||||
|
@ -71,10 +71,6 @@ RefPtr<Capability> Process::GetCapability(uint64_t cid) {
|
|||
return caps_.GetCapability(cid);
|
||||
}
|
||||
|
||||
uint64_t Process::AddCapability(const RefPtr<Capability>& cap) {
|
||||
uint64_t Process::AddExistingCapability(const RefPtr<Capability>& cap) {
|
||||
return caps_.AddExistingCapability(cap);
|
||||
}
|
||||
|
||||
void Process::AddCapability(uint64_t cap_id, const RefPtr<MemoryObject>& vmmo) {
|
||||
caps_.AddNewCapabilityWithId(cap_id, vmmo, ZC_WRITE);
|
||||
}
|
||||
|
|
|
@ -39,15 +39,19 @@ class Process : public KernelObject {
|
|||
|
||||
RefPtr<Capability> ReleaseCapability(uint64_t cid);
|
||||
RefPtr<Capability> GetCapability(uint64_t cid);
|
||||
// FIXME: We can't reset the cap id here.
|
||||
uint64_t AddCapability(const RefPtr<Capability>& cap);
|
||||
|
||||
void AddCapability(uint64_t cap_id, const RefPtr<MemoryObject>& vmmo);
|
||||
|
||||
template <typename T>
|
||||
uint64_t AddNewCapability(const RefPtr<T>& obj, uint64_t permissions) {
|
||||
return caps_.AddNewCapability(obj, permissions);
|
||||
}
|
||||
uint64_t AddExistingCapability(const RefPtr<Capability>& cap);
|
||||
|
||||
// FIXME: Eliminate reliance on this.
|
||||
template <typename T>
|
||||
void AddNewCapabilityWithId(uint64_t id, const RefPtr<T>& obj,
|
||||
uint64_t permissions) {
|
||||
return caps_.AddNewCapabilityWithId(id, obj, permissions);
|
||||
}
|
||||
|
||||
// Checks the state of all child threads and transitions to
|
||||
// finished if all have finished.
|
||||
|
|
|
@ -81,7 +81,7 @@ z_err_t ProcessSpawn(ZProcessSpawnReq* req, ZProcessSpawnResp* resp) {
|
|||
return Z_ERR_CAP_NOT_FOUND;
|
||||
}
|
||||
// FIXME: Check permissions.
|
||||
resp->bootstrap_cap = proc->AddCapability(cap);
|
||||
resp->bootstrap_cap = proc->AddExistingCapability(cap);
|
||||
}
|
||||
|
||||
return Z_OK;
|
||||
|
|
Loading…
Reference in New Issue