[zion] Add a direct port write for the kernel
This commit is contained in:
parent
0a909eae0e
commit
2ea1f90690
|
@ -130,25 +130,11 @@ void LoadInitProgram() {
|
|||
prog2_vmmo->CopyBytesToObject(reinterpret_cast<uint64_t>(prog2.address),
|
||||
prog2.size);
|
||||
|
||||
// TODO: Probably add a way for the kernel to write caps directly rather than
|
||||
// by installing them first.
|
||||
uint64_t vmmo_cap =
|
||||
gScheduler->CurrentProcess().AddNewCapability(prog2_vmmo, ZC_WRITE);
|
||||
|
||||
auto port = MakeRefCounted<Port>();
|
||||
uint64_t port_cap = proc->AddNewCapability(port, ZC_READ | ZC_WRITE);
|
||||
|
||||
uint64_t vmmo_id = Z_BOOT_DENALI_VMMO;
|
||||
ZMessage vmmo_msg{
|
||||
.type = 0,
|
||||
.num_bytes = 8,
|
||||
.bytes = reinterpret_cast<uint8_t*>(&vmmo_id),
|
||||
.num_caps = 1,
|
||||
.caps = &vmmo_cap,
|
||||
};
|
||||
if (port->Write(vmmo_msg) != Z_OK) {
|
||||
panic("Failed to write cap");
|
||||
}
|
||||
port->WriteKernel(Z_BOOT_DENALI_VMMO,
|
||||
MakeRefCounted<Capability>(prog2_vmmo, ZC_READ | ZC_WRITE));
|
||||
|
||||
proc->CreateThread()->Start(entry, port_cap, 0);
|
||||
}
|
||||
|
|
|
@ -74,6 +74,23 @@ z_err_t Port::Read(ZMessage& msg) {
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
void Port::WriteKernel(uint64_t init, RefPtr<Capability> cap) {
|
||||
MutexHolder h(mutex_);
|
||||
|
||||
auto msg = MakeShared<Message>();
|
||||
msg->type = 0;
|
||||
msg->bytes = new uint8_t[8];
|
||||
msg->num_bytes = sizeof(init);
|
||||
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(&init);
|
||||
for (uint8_t i = 0; i < sizeof(init); i++) {
|
||||
msg->bytes[i] = data[i];
|
||||
}
|
||||
msg->caps.PushBack(cap);
|
||||
|
||||
pending_messages_.PushBack(msg);
|
||||
}
|
||||
|
||||
bool Port::HasMessages() {
|
||||
MutexHolder h(mutex_);
|
||||
return pending_messages_.size() != 0;
|
||||
|
|
|
@ -24,6 +24,8 @@ class Port : public KernelObject {
|
|||
z_err_t Write(const ZMessage& msg);
|
||||
z_err_t Read(ZMessage& msg);
|
||||
|
||||
void WriteKernel(uint64_t init, RefPtr<Capability> cap);
|
||||
|
||||
bool HasMessages();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue