Compare commits
2 Commits
c2dfe17363
...
1f7a15eed4
Author | SHA1 | Date |
---|---|---|
|
1f7a15eed4 | |
|
0ec2fa3e76 |
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
namespace glcr {
|
||||||
|
|
||||||
template <typename T, typename U>
|
template <typename T, typename U>
|
||||||
class Pair {
|
class Pair {
|
||||||
public:
|
public:
|
||||||
|
@ -11,3 +13,5 @@ class Pair {
|
||||||
T first_;
|
T first_;
|
||||||
U second_;
|
U second_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace glcr
|
|
@ -10,6 +10,8 @@ class ErrorOr {
|
||||||
ErrorOr() = delete;
|
ErrorOr() = delete;
|
||||||
ErrorOr(const ErrorOr&) = delete;
|
ErrorOr(const ErrorOr&) = delete;
|
||||||
ErrorOr(ErrorOr&&) = delete;
|
ErrorOr(ErrorOr&&) = delete;
|
||||||
|
// FIXME: Do we have to call ~T manually here.
|
||||||
|
~ErrorOr() {}
|
||||||
|
|
||||||
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
|
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
|
||||||
ErrorOr(const T& obj) : obj_(obj), ok_(true) {}
|
ErrorOr(const T& obj) : obj_(obj), ok_(true) {}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glacier/status/error_or.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "mammoth/channel.h"
|
#include "mammoth/channel.h"
|
||||||
|
|
||||||
uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local);
|
glcr::ErrorOr<Channel> SpawnProcessFromElfRegion(uint64_t program);
|
||||||
|
|
|
@ -95,8 +95,8 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
|
glcr::ErrorOr<Channel> SpawnProcessFromElfRegion(uint64_t program) {
|
||||||
Channel foreign;
|
Channel local, foreign;
|
||||||
check(CreateChannels(local, foreign));
|
check(CreateChannels(local, foreign));
|
||||||
|
|
||||||
uint64_t proc_cap;
|
uint64_t proc_cap;
|
||||||
|
@ -134,5 +134,5 @@ uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
|
||||||
#endif
|
#endif
|
||||||
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
|
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
|
||||||
|
|
||||||
return glcr::OK;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,11 @@ uint64_t main(uint64_t port_cap) {
|
||||||
uint64_t vaddr;
|
uint64_t vaddr;
|
||||||
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
|
check(ZAddressSpaceMap(gSelfVmasCap, 0, gBootDenaliVmmoCap, &vaddr));
|
||||||
|
|
||||||
Channel local;
|
auto local_or = SpawnProcessFromElfRegion(vaddr);
|
||||||
check(SpawnProcessFromElfRegion(vaddr, local));
|
if (!local_or) {
|
||||||
|
check(local_or.error());
|
||||||
|
}
|
||||||
|
Channel local = local_or.value();
|
||||||
|
|
||||||
DenaliClient client(local);
|
DenaliClient client(local);
|
||||||
GptReader reader(client);
|
GptReader reader(client);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "include/ztypes.h"
|
#include "include/ztypes.h"
|
||||||
#include "scheduler/scheduler.h"
|
#include "scheduler/scheduler.h"
|
||||||
|
|
||||||
Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>>
|
glcr::Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>>
|
||||||
Channel::CreateChannelPair() {
|
Channel::CreateChannelPair() {
|
||||||
auto c1 = glcr::MakeRefCounted<Channel>();
|
auto c1 = glcr::MakeRefCounted<Channel>();
|
||||||
auto c2 = glcr::MakeRefCounted<Channel>();
|
auto c2 = glcr::MakeRefCounted<Channel>();
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glacier/container/intrusive_list.h>
|
#include <glacier/container/intrusive_list.h>
|
||||||
|
#include <glacier/container/pair.h>
|
||||||
#include <glacier/memory/ref_ptr.h>
|
#include <glacier/memory/ref_ptr.h>
|
||||||
|
|
||||||
#include "capability/capability.h"
|
#include "capability/capability.h"
|
||||||
#include "include/ztypes.h"
|
#include "include/ztypes.h"
|
||||||
#include "lib/message_queue.h"
|
#include "lib/message_queue.h"
|
||||||
#include "lib/mutex.h"
|
#include "lib/mutex.h"
|
||||||
#include "lib/pair.h"
|
|
||||||
#include "object/kernel_object.h"
|
#include "object/kernel_object.h"
|
||||||
#include "usr/zcall_internal.h"
|
#include "usr/zcall_internal.h"
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ struct KernelObjectTag<Channel> {
|
||||||
class Channel : public KernelObject {
|
class Channel : public KernelObject {
|
||||||
public:
|
public:
|
||||||
uint64_t TypeTag() override { return KernelObject::CHANNEL; }
|
uint64_t TypeTag() override { return KernelObject::CHANNEL; }
|
||||||
static Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>> CreateChannelPair();
|
static glcr::Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>>
|
||||||
|
CreateChannelPair();
|
||||||
|
|
||||||
glcr::RefPtr<Channel> peer() { return peer_; }
|
glcr::RefPtr<Channel> peer() { return peer_; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue