Compare commits
No commits in common. "adfffdd3c3bc1a07c57afe22763495543f498356" and "4c04f9d561ccfcb40bbfff92d9a2d819d3248c75" have entirely different histories.
adfffdd3c3
...
4c04f9d561
|
@ -5,7 +5,6 @@ add_library(mammoth STATIC
|
|||
src/endpoint_server.cpp
|
||||
src/init.cpp
|
||||
src/memory_region.cpp
|
||||
src/mutex.cpp
|
||||
src/new.cpp
|
||||
src/process.cpp
|
||||
src/port_client.cpp
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
class Mutex {
|
||||
public:
|
||||
Mutex(const Mutex&) = delete;
|
||||
Mutex(Mutex&&);
|
||||
Mutex& operator=(Mutex&&);
|
||||
|
||||
static glcr::ErrorOr<Mutex> Create();
|
||||
|
||||
glcr::ErrorCode Lock();
|
||||
glcr::ErrorCode Release();
|
||||
|
||||
private:
|
||||
z_cap_t mutex_cap_;
|
||||
|
||||
Mutex(z_cap_t mutex_cap) : mutex_cap_(mutex_cap) {}
|
||||
};
|
|
@ -1,23 +0,0 @@
|
|||
#include "mammoth/mutex.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
Mutex::Mutex(Mutex&& other) : mutex_cap_(other.mutex_cap_) {
|
||||
other.mutex_cap_ = 0;
|
||||
}
|
||||
|
||||
Mutex& Mutex::operator=(Mutex&& other) {
|
||||
// TODO: Release existing mutex if it exists.
|
||||
mutex_cap_ = other.mutex_cap_;
|
||||
other.mutex_cap_ = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
glcr::ErrorOr<Mutex> Mutex::Create() {
|
||||
z_cap_t mutex_cap;
|
||||
RET_ERR(ZMutexCreate(&mutex_cap));
|
||||
return Mutex(mutex_cap);
|
||||
}
|
||||
|
||||
glcr::ErrorCode Mutex::Lock() { return ZMutexLock(mutex_cap_); }
|
||||
glcr::ErrorCode Mutex::Release() { return ZMutexRelease(mutex_cap_); }
|
|
@ -8,12 +8,6 @@
|
|||
#include "hw/pcie.h"
|
||||
#include "yellowstone_server.h"
|
||||
|
||||
glcr::ErrorCode SpawnProcess(z_cap_t vmmo_cap, z_cap_t yellowstone_cap) {
|
||||
uint64_t vaddr;
|
||||
RET_ERR(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
|
||||
return SpawnProcessFromElfRegion(vaddr, yellowstone_cap);
|
||||
}
|
||||
|
||||
uint64_t main(uint64_t port_cap) {
|
||||
dbgln("Yellowstone Initializing.");
|
||||
check(ParseInitPort(port_cap));
|
||||
|
@ -21,13 +15,10 @@ uint64_t main(uint64_t port_cap) {
|
|||
ASSIGN_OR_RETURN(auto server, YellowstoneServer::Create());
|
||||
Thread server_thread = server->RunServer();
|
||||
|
||||
ASSIGN_OR_RETURN(YellowstoneClient client1, server->CreateClient());
|
||||
check(SpawnProcess(gBootDenaliVmmoCap, client1.Capability()));
|
||||
|
||||
check(server->WaitDenaliRegistered());
|
||||
|
||||
ASSIGN_OR_RETURN(YellowstoneClient client2, server->CreateClient());
|
||||
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client2.Capability()));
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
|
||||
ASSIGN_OR_RETURN(YellowstoneClient client, server->CreateClient());
|
||||
check(SpawnProcessFromElfRegion(vaddr, client.Capability()));
|
||||
|
||||
check(server_thread.Join());
|
||||
dbgln("Yellowstone Finished Successfully.");
|
||||
|
|
|
@ -30,19 +30,13 @@ glcr::ErrorOr<PartitionInfo> HandleDenaliRegistration(z_cap_t endpoint_cap) {
|
|||
} // namespace
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> YellowstoneServer::Create() {
|
||||
z_cap_t endpoint_cap;
|
||||
RET_ERR(ZEndpointCreate(&endpoint_cap));
|
||||
|
||||
ASSIGN_OR_RETURN(Mutex mut, Mutex::Create());
|
||||
RET_ERR(mut.Lock());
|
||||
|
||||
return glcr::UniquePtr<YellowstoneServer>(
|
||||
new YellowstoneServer(endpoint_cap, glcr::Move(mut)));
|
||||
z_cap_t cap;
|
||||
RET_ERR(ZEndpointCreate(&cap));
|
||||
return glcr::UniquePtr<YellowstoneServer>(new YellowstoneServer(cap));
|
||||
}
|
||||
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap, Mutex&& mutex)
|
||||
: YellowstoneServerBase(endpoint_cap),
|
||||
has_denali_mutex_(glcr::Move(mutex)) {}
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
||||
: YellowstoneServerBase(endpoint_cap) {}
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&,
|
||||
AhciInfo& info) {
|
||||
|
@ -75,7 +69,13 @@ glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
|||
device_id_ = part_info_or.value().device_id;
|
||||
lba_offset_ = part_info_or.value().partition_lba;
|
||||
|
||||
check(has_denali_mutex_.Release());
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
|
||||
auto client_or = CreateClient();
|
||||
if (!client_or.ok()) {
|
||||
check(client_or.error());
|
||||
}
|
||||
check(SpawnProcessFromElfRegion(vaddr, client_or.value().Capability()));
|
||||
} else if (req.endpoint_name() == "victoriafalls") {
|
||||
victoria_falls_cap_ = req.endpoint_capability();
|
||||
} else {
|
||||
|
@ -83,8 +83,3 @@ glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
|||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::WaitDenaliRegistered() {
|
||||
RET_ERR(has_denali_mutex_.Lock());
|
||||
return has_denali_mutex_.Release();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
#include <mammoth/mutex.h>
|
||||
#include <mammoth/port_server.h>
|
||||
#include <mammoth/thread.h>
|
||||
|
||||
|
@ -19,8 +18,6 @@ class YellowstoneServer : public YellowstoneServerBase {
|
|||
glcr::ErrorCode HandleRegisterEndpoint(const RegisterEndpointRequest&,
|
||||
Empty&) override;
|
||||
|
||||
glcr::ErrorCode WaitDenaliRegistered();
|
||||
|
||||
private:
|
||||
// TODO: Store these in a data structure.
|
||||
z_cap_t denali_cap_ = 0;
|
||||
|
@ -30,7 +27,5 @@ class YellowstoneServer : public YellowstoneServerBase {
|
|||
|
||||
PciReader pci_reader_;
|
||||
|
||||
Mutex has_denali_mutex_;
|
||||
|
||||
YellowstoneServer(z_cap_t endpoint_cap, Mutex&& mutex);
|
||||
YellowstoneServer(z_cap_t endpoint_cap);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue