Compare commits
No commits in common. "a46694d0f7b2acb8329629c9a7292db5232bc626" and "f0e8ce14a4314711c1a5d5114e007530d2cff582" have entirely different histories.
a46694d0f7
...
f0e8ce14a4
|
@ -8,9 +8,6 @@ class String {
|
|||
public:
|
||||
String(const char* cstr);
|
||||
|
||||
const char* cstr() const { return cstr_; }
|
||||
uint64_t length() const { return length_; }
|
||||
|
||||
bool operator==(const String& str);
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,8 +12,6 @@ class EndpointClient {
|
|||
template <typename Req, typename Resp>
|
||||
glcr::ErrorOr<glcr::Pair<Resp, z_cap_t>> CallEndpoint(const Req& req);
|
||||
|
||||
z_cap_t GetCap() { return cap_; }
|
||||
|
||||
private:
|
||||
EndpointClient(uint64_t cap) : cap_(cap) {}
|
||||
z_cap_t cap_;
|
||||
|
|
|
@ -1,27 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
// FIXME: Split send and receive.
|
||||
class Port {
|
||||
public:
|
||||
static glcr::ErrorOr<Port> Create();
|
||||
Port(uint64_t port_cap);
|
||||
|
||||
glcr::ErrorCode RecvCap(uint64_t* num_bytes, char* msg, uint64_t* cap);
|
||||
z_err_t PollForIntCap(uint64_t* msg, uint64_t* cap);
|
||||
|
||||
template <typename T>
|
||||
z_err_t WriteMessage(const T& obj, uint64_t cap);
|
||||
|
||||
glcr::ErrorCode WriteString(glcr::String str, uint64_t cap);
|
||||
|
||||
// FIXME: We can't create error_ors of ints
|
||||
glcr::ErrorCode Duplicate(uint64_t* new_cap);
|
||||
|
||||
private:
|
||||
uint64_t port_cap_;
|
||||
};
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mammoth/endpoint_client.h"
|
||||
|
||||
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
||||
EndpointClient client);
|
||||
glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class Thread {
|
||||
|
@ -10,8 +9,6 @@ class Thread {
|
|||
Thread() : thread_cap_(0) {}
|
||||
Thread(Entry e, const void* arg1);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode Join();
|
||||
|
||||
private:
|
||||
uint64_t thread_cap_;
|
||||
};
|
||||
|
|
|
@ -5,23 +5,8 @@
|
|||
|
||||
#include "mammoth/debug.h"
|
||||
|
||||
glcr::ErrorOr<Port> Port::Create() {
|
||||
z_cap_t port;
|
||||
RET_ERR(ZPortCreate(&port));
|
||||
return Port(port);
|
||||
}
|
||||
Port::Port(uint64_t port_cap) : port_cap_(port_cap) {}
|
||||
|
||||
glcr::ErrorCode Port::RecvCap(uint64_t *num_bytes, char *msg, uint64_t *cap) {
|
||||
uint64_t caps = 1;
|
||||
RET_ERR(ZPortRecv(port_cap_, num_bytes, reinterpret_cast<uint8_t *>(msg),
|
||||
&caps, cap));
|
||||
|
||||
if (caps != 1) {
|
||||
return glcr::FAILED_PRECONDITION;
|
||||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
|
||||
uint64_t bytes = sizeof(uint64_t);
|
||||
uint64_t caps = 1;
|
||||
|
@ -36,10 +21,3 @@ z_err_t Port::PollForIntCap(uint64_t *msg, uint64_t *cap) {
|
|||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
glcr::ErrorCode Port::WriteString(glcr::String str, uint64_t cap) {
|
||||
return ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap);
|
||||
}
|
||||
|
||||
glcr::ErrorCode Port::Duplicate(uint64_t *new_cap) {
|
||||
return ZCapDuplicate(port_cap_, new_cap);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,10 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
|
|||
|
||||
} // namespace
|
||||
|
||||
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
||||
EndpointClient client) {
|
||||
glcr::ErrorOr<EndpointClient> SpawnProcessFromElfRegion(uint64_t program) {
|
||||
ASSIGN_OR_RETURN(EndpointServer server, EndpointServer::Create());
|
||||
ASSIGN_OR_RETURN(EndpointClient client, server.CreateClient());
|
||||
|
||||
uint64_t proc_cap;
|
||||
uint64_t as_cap;
|
||||
uint64_t foreign_port_id;
|
||||
|
@ -112,7 +114,7 @@ glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
|||
#if MAM_PROC_DEBUG
|
||||
dbgln("Spawn");
|
||||
#endif
|
||||
RET_ERR(ZProcessSpawn(gSelfProcCap, port_cap_donate, &proc_cap, &as_cap,
|
||||
check(ZProcessSpawn(gSelfProcCap, port_cap_donate, &proc_cap, &as_cap,
|
||||
&foreign_port_id));
|
||||
|
||||
uint64_t entry_point = LoadElfProgram(program, as_cap);
|
||||
|
@ -121,17 +123,17 @@ glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
|||
dbgln("Thread Create");
|
||||
#endif
|
||||
uint64_t thread_cap;
|
||||
RET_ERR(ZThreadCreate(proc_cap, &thread_cap));
|
||||
check(ZThreadCreate(proc_cap, &thread_cap));
|
||||
|
||||
Port p(port_cap);
|
||||
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_SELF_PROC, proc_cap));
|
||||
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_SELF_VMAS, as_cap));
|
||||
RET_ERR(p.WriteMessage<uint64_t>(Z_INIT_ENDPOINT, client.GetCap()));
|
||||
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_ENDPOINT, server.GetCap()));
|
||||
|
||||
#if MAM_PROC_DEBUG
|
||||
dbgln("Thread start");
|
||||
#endif
|
||||
RET_ERR(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
|
||||
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
|
||||
|
||||
return glcr::OK;
|
||||
return client;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace {
|
|||
extern "C" void thread_entry(Thread::Entry entry, void* arg1) {
|
||||
entry(arg1);
|
||||
|
||||
(void)ZThreadExit();
|
||||
ZThreadExit();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -21,5 +21,3 @@ Thread::Thread(Entry e, const void* arg1) {
|
|||
reinterpret_cast<uint64_t>(e),
|
||||
reinterpret_cast<uint64_t>(arg1)));
|
||||
}
|
||||
|
||||
glcr::ErrorCode Thread::Join() { return ZThreadWait(thread_cap_); }
|
||||
|
|
|
@ -15,7 +15,6 @@ target_link_libraries(denali
|
|||
cxx
|
||||
glacier
|
||||
mammoth_lib
|
||||
yellowstonestub
|
||||
)
|
||||
|
||||
set_target_properties(denali PROPERTIES
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
#include <mammoth/debug.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/port.h>
|
||||
#include <stdint.h>
|
||||
#include <yellowstone.h>
|
||||
|
||||
#include "ahci/ahci_driver.h"
|
||||
#include "denali_server.h"
|
||||
|
@ -14,24 +12,7 @@ uint64_t main(uint64_t init_port_cap) {
|
|||
AhciDriver driver;
|
||||
RET_ERR(driver.Init());
|
||||
|
||||
EndpointClient yellowstone = EndpointClient::AdoptEndpoint(gInitEndpointCap);
|
||||
YellowstoneGetReq req{
|
||||
.type = kYellowstoneGetRegistration,
|
||||
};
|
||||
auto resp_cap_or =
|
||||
yellowstone
|
||||
.CallEndpoint<YellowstoneGetReq, YellowstoneGetRegistrationResp>(req);
|
||||
if (!resp_cap_or.ok()) {
|
||||
dbgln("Bad call");
|
||||
check(resp_cap_or.error());
|
||||
}
|
||||
auto resp_cap = resp_cap_or.value();
|
||||
Port notify(resp_cap.second());
|
||||
|
||||
ASSIGN_OR_RETURN(EndpointServer endpoint, EndpointServer::Create());
|
||||
ASSIGN_OR_RETURN(EndpointClient client, endpoint.CreateClient());
|
||||
notify.WriteMessage("denali", client.GetCap());
|
||||
|
||||
EndpointServer endpoint = EndpointServer::Adopt(gInitEndpointCap);
|
||||
DenaliServer server(endpoint, driver);
|
||||
RET_ERR(server.RunServer());
|
||||
// FIXME: Add thread join.
|
||||
|
|
|
@ -2,7 +2,6 @@ add_executable(yellowstone
|
|||
hw/gpt.cpp
|
||||
hw/pcie.cpp
|
||||
yellowstone.cpp
|
||||
yellowstone_server.cpp
|
||||
)
|
||||
target_include_directories(yellowstone
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -10,7 +9,6 @@ add_executable(yellowstone
|
|||
target_link_libraries(yellowstone
|
||||
cxx
|
||||
mammoth_lib
|
||||
glacier
|
||||
libdenali
|
||||
)
|
||||
|
||||
|
@ -18,17 +16,3 @@ set_target_properties(yellowstone PROPERTIES
|
|||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||
)
|
||||
|
||||
|
||||
add_library(yellowstonestub
|
||||
stub/yellowstone_stub.cpp
|
||||
)
|
||||
|
||||
target_include_directories(yellowstonestub
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
set_target_properties(yellowstonestub PROPERTIES
|
||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||
)
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
const uint64_t kYellowstoneGetAhci = 0x01;
|
||||
const uint64_t kYellowstoneGetRegistration = 0x02;
|
||||
|
||||
struct YellowstoneGetReq {
|
||||
uint64_t type;
|
||||
};
|
||||
|
||||
struct YellowstoneGetRegistrationResp {};
|
|
@ -1,3 +0,0 @@
|
|||
// PLACEHOLDER
|
||||
#include <stdint.h>
|
||||
uint64_t a = 0;
|
|
@ -1,3 +1,4 @@
|
|||
#include <denali/denali.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/endpoint_client.h>
|
||||
#include <mammoth/init.h>
|
||||
|
@ -6,28 +7,32 @@
|
|||
|
||||
#include "hw/gpt.h"
|
||||
#include "hw/pcie.h"
|
||||
#include "yellowstone_server.h"
|
||||
|
||||
uint64_t main(uint64_t port_cap) {
|
||||
dbgln("Yellowstone Initializing.");
|
||||
check(ParseInitPort(port_cap));
|
||||
|
||||
ASSIGN_OR_RETURN(YellowstoneServer server, YellowstoneServer::Create());
|
||||
Thread server_thread = server.RunServer();
|
||||
Thread registration_thread = server.RunRegistration();
|
||||
DumpPciEDevices();
|
||||
|
||||
uint64_t vaddr;
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
|
||||
ASSIGN_OR_RETURN(EndpointClient client, server.GetServerClient());
|
||||
check(SpawnProcessFromElfRegion(vaddr, client));
|
||||
|
||||
auto endpoint_or = SpawnProcessFromElfRegion(vaddr);
|
||||
if (!endpoint_or) {
|
||||
check(endpoint_or.error());
|
||||
}
|
||||
EndpointClient endpoint = endpoint_or.value();
|
||||
|
||||
DenaliClient client(endpoint);
|
||||
GptReader reader(client);
|
||||
|
||||
check(reader.ParsePartitionTables());
|
||||
|
||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootVictoriaFallsVmmoCap, &vaddr));
|
||||
ASSIGN_OR_RETURN(client, server.GetServerClient());
|
||||
check(SpawnProcessFromElfRegion(vaddr, client));
|
||||
|
||||
check(server_thread.Join());
|
||||
check(registration_thread.Join());
|
||||
auto error_or = SpawnProcessFromElfRegion(vaddr);
|
||||
if (!error_or) {
|
||||
check(error_or.error());
|
||||
}
|
||||
dbgln("Yellowstone Finished Successfully.");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
#include "yellowstone_server.h"
|
||||
|
||||
#include <denali/denali.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hw/gpt.h"
|
||||
#include "include/yellowstone.h"
|
||||
|
||||
// FIXME: This linkage was missing :(
|
||||
void* operator new[](uint64_t size) { return malloc(size); }
|
||||
namespace {
|
||||
|
||||
void ServerThreadBootstrap(void* yellowstone) {
|
||||
dbgln("Yellowstone server starting");
|
||||
static_cast<YellowstoneServer*>(yellowstone)->ServerThread();
|
||||
}
|
||||
|
||||
void RegistrationThreadBootstrap(void* yellowstone) {
|
||||
dbgln("Yellowstone registration starting");
|
||||
static_cast<YellowstoneServer*>(yellowstone)->RegistrationThread();
|
||||
}
|
||||
|
||||
glcr::ErrorCode HandleDenaliRegistration(z_cap_t endpoint_cap) {
|
||||
EndpointClient endpoint = EndpointClient::AdoptEndpoint(endpoint_cap);
|
||||
DenaliClient client(endpoint);
|
||||
GptReader reader(client);
|
||||
|
||||
return reader.ParsePartitionTables();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
glcr::ErrorOr<YellowstoneServer> YellowstoneServer::Create() {
|
||||
ASSIGN_OR_RETURN(EndpointServer server, EndpointServer::Create());
|
||||
ASSIGN_OR_RETURN(Port port, Port::Create());
|
||||
return YellowstoneServer(server, port);
|
||||
}
|
||||
|
||||
YellowstoneServer::YellowstoneServer(EndpointServer server, Port port)
|
||||
: server_(server), register_port_(port) {}
|
||||
|
||||
Thread YellowstoneServer::RunServer() {
|
||||
return Thread(ServerThreadBootstrap, this);
|
||||
}
|
||||
|
||||
Thread YellowstoneServer::RunRegistration() {
|
||||
return Thread(RegistrationThreadBootstrap, this);
|
||||
}
|
||||
|
||||
void YellowstoneServer::ServerThread() {
|
||||
while (true) {
|
||||
uint64_t num_bytes = kBufferSize;
|
||||
uint64_t reply_port_cap;
|
||||
// FIXME: Error handling.
|
||||
check(server_.Recieve(&num_bytes, server_buffer_, &reply_port_cap));
|
||||
YellowstoneGetReq* req =
|
||||
reinterpret_cast<YellowstoneGetReq*>(server_buffer_);
|
||||
switch (req->type) {
|
||||
case kYellowstoneGetAhci:
|
||||
dbgln("Yellowstone::GetAHCI");
|
||||
break;
|
||||
case kYellowstoneGetRegistration: {
|
||||
dbgln("Yellowstone::GetRegistration");
|
||||
uint64_t reg_cap;
|
||||
check(register_port_.Duplicate(®_cap));
|
||||
YellowstoneGetRegistrationResp resp;
|
||||
check(ZReplyPortSend(reply_port_cap, sizeof(resp), &resp, 1, ®_cap));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dbgln("Unknown request type: %x", req->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void YellowstoneServer::RegistrationThread() {
|
||||
while (true) {
|
||||
uint64_t num_bytes = kBufferSize;
|
||||
z_cap_t endpoint_cap;
|
||||
// FIXME: Better error handling here.
|
||||
check(register_port_.RecvCap(&num_bytes, registration_buffer_,
|
||||
&endpoint_cap));
|
||||
glcr::String name(registration_buffer_);
|
||||
if (name == "denali") {
|
||||
denali_cap_ = endpoint_cap;
|
||||
check(HandleDenaliRegistration(denali_cap_));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name == "victoriafalls") {
|
||||
victoria_falls_cap_ = endpoint_cap;
|
||||
continue;
|
||||
}
|
||||
|
||||
dbgln("[WARN] Got endpoint cap type:");
|
||||
dbgln(name.cstr());
|
||||
}
|
||||
}
|
||||
|
||||
glcr::ErrorOr<EndpointClient> YellowstoneServer::GetServerClient() {
|
||||
return server_.CreateClient();
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
#include <mammoth/port.h>
|
||||
#include <mammoth/thread.h>
|
||||
|
||||
class YellowstoneServer {
|
||||
public:
|
||||
static glcr::ErrorOr<YellowstoneServer> Create();
|
||||
|
||||
Thread RunServer();
|
||||
Thread RunRegistration();
|
||||
|
||||
void ServerThread();
|
||||
void RegistrationThread();
|
||||
|
||||
glcr::ErrorOr<EndpointClient> GetServerClient();
|
||||
|
||||
private:
|
||||
EndpointServer server_;
|
||||
Port register_port_;
|
||||
|
||||
static const uint64_t kBufferSize = 128;
|
||||
uint8_t server_buffer_[kBufferSize];
|
||||
char registration_buffer_[kBufferSize];
|
||||
|
||||
// TODO: Store these in a data structure.
|
||||
z_cap_t denali_cap_ = 0;
|
||||
z_cap_t victoria_falls_cap_ = 0;
|
||||
|
||||
YellowstoneServer(EndpointServer server, Port port);
|
||||
};
|
|
@ -96,7 +96,6 @@ SYS2(ThreadCreate, z_cap_t, proc_cap, z_cap_t*, thread_cap);
|
|||
SYS4(ThreadStart, z_cap_t, thread_cap, uint64_t, entry, uint64_t, arg1,
|
||||
uint64_t, arg2);
|
||||
SYS0(ThreadExit);
|
||||
SYS1(ThreadWait, z_cap_t, thread_cap);
|
||||
|
||||
SYS4(AddressSpaceMap, z_cap_t, vmas_cap, uint64_t, vmas_offset, z_cap_t,
|
||||
vmmo_cap, uint64_t*, vaddr);
|
||||
|
|
|
@ -17,7 +17,6 @@ const uint64_t kZionProcessSpawn = 0x2;
|
|||
const uint64_t kZionThreadCreate = 0x10;
|
||||
const uint64_t kZionThreadStart = 0x11;
|
||||
const uint64_t kZionThreadExit = 0x12;
|
||||
const uint64_t kZionThreadWait = 0x13;
|
||||
|
||||
// Memory Calls
|
||||
const uint64_t kZionAddressSpaceMap = 0x21;
|
||||
|
|
|
@ -69,18 +69,5 @@ void Thread::Exit() {
|
|||
#endif
|
||||
state_ = FINISHED;
|
||||
process_.CheckState();
|
||||
while (!blocked_threads_.size() == 0) {
|
||||
auto thread = blocked_threads_.PopFront();
|
||||
thread->SetState(Thread::RUNNABLE);
|
||||
gScheduler->Enqueue(thread);
|
||||
}
|
||||
gScheduler->Yield();
|
||||
}
|
||||
|
||||
void Thread::Wait() {
|
||||
// FIXME: We need synchronization code here.
|
||||
auto thread = gScheduler->CurrentThread();
|
||||
thread->SetState(Thread::BLOCKED);
|
||||
blocked_threads_.PushBack(thread);
|
||||
gScheduler->Yield();
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
void SetState(State state) { state_ = state; }
|
||||
void Exit();
|
||||
|
||||
void Wait();
|
||||
|
||||
private:
|
||||
friend class glcr::MakeRefCountedFriend<Thread>;
|
||||
Thread(Process& proc, uint64_t tid);
|
||||
|
@ -70,6 +68,4 @@ class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
|
|||
// Stack pointer to take when returning from userspace.
|
||||
// I don't think me mind clobbering the stack here.
|
||||
uint64_t rsp0_start_;
|
||||
|
||||
glcr::IntrusiveList<Thread> blocked_threads_;
|
||||
};
|
||||
|
|
|
@ -55,7 +55,6 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) {
|
|||
CASE(ThreadCreate);
|
||||
CASE(ThreadStart);
|
||||
CASE(ThreadExit);
|
||||
CASE(ThreadWait);
|
||||
// syscall/address_space.h
|
||||
CASE(AddressSpaceMap);
|
||||
// syscall/memory_object.h
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
#include "capability/capability.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
glcr::ErrorCode ThreadCreate(ZThreadCreateReq* req) {
|
||||
z_err_t ThreadCreate(ZThreadCreateReq* req) {
|
||||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
auto cap = curr_proc.GetCapability(req->proc_cap);
|
||||
RET_ERR(ValidateCapability<Process>(cap, ZC_PROC_SPAWN_THREAD));
|
||||
|
||||
auto parent_proc = cap->obj<Process>();
|
||||
auto thread = parent_proc->CreateThread();
|
||||
*req->thread_cap = curr_proc.AddNewCapability(thread, ZC_WRITE | ZC_READ);
|
||||
*req->thread_cap = curr_proc.AddNewCapability(thread, ZC_WRITE);
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode ThreadStart(ZThreadStartReq* req) {
|
||||
z_err_t ThreadStart(ZThreadStartReq* req) {
|
||||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
auto cap = curr_proc.GetCapability(req->thread_cap);
|
||||
RET_ERR(ValidateCapability<Thread>(cap, ZC_WRITE));
|
||||
|
@ -25,17 +25,8 @@ glcr::ErrorCode ThreadStart(ZThreadStartReq* req) {
|
|||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode ThreadExit(ZThreadExitReq*) {
|
||||
z_err_t ThreadExit(ZThreadExitReq*) {
|
||||
auto curr_thread = gScheduler->CurrentThread();
|
||||
curr_thread->Exit();
|
||||
panic("Returned from thread exit");
|
||||
}
|
||||
|
||||
glcr::ErrorCode ThreadWait(ZThreadWaitReq* req) {
|
||||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
auto cap = curr_proc.GetCapability(req->thread_cap);
|
||||
RET_ERR(ValidateCapability<Thread>(cap, ZC_READ));
|
||||
auto thread = cap->obj<Thread>();
|
||||
thread->Wait();
|
||||
return glcr::OK;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
|
||||
#include "include/zcall.h"
|
||||
|
||||
glcr::ErrorCode ThreadCreate(ZThreadCreateReq* req);
|
||||
glcr::ErrorCode ThreadStart(ZThreadStartReq* req);
|
||||
glcr::ErrorCode ThreadExit(ZThreadExitReq*);
|
||||
glcr::ErrorCode ThreadWait(ZThreadWaitReq* req);
|
||||
z_err_t ThreadCreate(ZThreadCreateReq* req);
|
||||
z_err_t ThreadStart(ZThreadStartReq* req);
|
||||
z_err_t ThreadExit(ZThreadExitReq*);
|
||||
|
|
Loading…
Reference in New Issue