[zion] Move to default permissions being supplied by KernelObjects

This commit is contained in:
Drew Galbraith 2023-08-01 18:22:41 -07:00
parent 48c6e5b3a4
commit 1364fbed9f
16 changed files with 91 additions and 54 deletions

View file

@ -4,6 +4,7 @@
#include <glacier/memory/ref_ptr.h>
#include <stdint.h>
#include "include/ztypes.h"
#include "memory/user_stack_manager.h"
#include "object/memory_object.h"
@ -36,6 +37,8 @@ class AddressSpace : public KernelObject {
public:
uint64_t TypeTag() override { return KernelObject::ADDRESS_SPACE; }
static uint64_t DefaultPermissions() { return kZionPerm_Write; }
enum MemoryType {
UNSPECIFIED,
UNMAPPED,

View file

@ -21,6 +21,10 @@ struct KernelObjectTag<Channel> {
class Channel : public IpcObject {
public:
uint64_t TypeTag() override { return KernelObject::CHANNEL; }
static uint64_t DefaultPermissions() {
return kZionPerm_Read | kZionPerm_Write;
}
static glcr::Pair<glcr::RefPtr<Channel>, glcr::RefPtr<Channel>>
CreateChannelPair();

View file

@ -20,6 +20,10 @@ struct KernelObjectTag<Endpoint> {
class Endpoint : public IpcObject {
public:
uint64_t TypeTag() override { return KernelObject::ENDPOINT; }
static uint64_t DefaultPermissions() {
return kZionPerm_Read | kZionPerm_Write;
}
static glcr::RefPtr<Endpoint> Create();
glcr::ErrorCode Read(uint64_t* num_bytes, void* data,

View file

@ -4,6 +4,7 @@
#include <glacier/memory/ref_ptr.h>
#include <glacier/status/error_or.h>
#include "include/ztypes.h"
#include "object/kernel_object.h"
class MemoryObject;
@ -21,6 +22,10 @@ struct KernelObjectTag<MemoryObject> {
class MemoryObject : public KernelObject {
public:
uint64_t TypeTag() override { return KernelObject::MEMORY_OBJECT; }
static uint64_t DefaultPermissions() {
return kZionPerm_Write | kZionPerm_Read;
}
MemoryObject(uint64_t size);
uint64_t size() { return size_; }

View file

@ -21,6 +21,9 @@ struct KernelObjectTag<Port> {
class Port : public IpcObject {
public:
uint64_t TypeTag() override { return KernelObject::PORT; }
static uint64_t DefaultPermissions() {
return kZionPerm_Write | kZionPerm_Read;
}
Port() = default;

View file

@ -22,6 +22,11 @@ struct KernelObjectTag<Process> {
class Process : public KernelObject {
public:
uint64_t TypeTag() override { return KernelObject::PROCESS; }
static uint64_t DefaultPermissions() {
return kZionPerm_Write | kZionPerm_Read | kZionPerm_SpawnThread |
kZionPerm_SpawnProcess;
}
enum State {
UNSPECIFIED,
SETUP,
@ -44,6 +49,10 @@ class Process : public KernelObject {
uint64_t AddNewCapability(const glcr::RefPtr<T>& obj, uint64_t permissions) {
return caps_.AddNewCapability(obj, permissions);
}
template <typename T>
uint64_t AddNewCapability(const glcr::RefPtr<T>& obj) {
return caps_.AddNewCapability(obj);
}
uint64_t AddExistingCapability(const glcr::RefPtr<Capability>& cap);
// Checks the state of all child threads and transitions to

View file

@ -4,6 +4,7 @@
#include <glacier/memory/ref_ptr.h>
#include <stdint.h>
#include "include/ztypes.h"
#include "object/kernel_object.h"
// Forward decl due to cyclic dependency.
@ -18,6 +19,10 @@ struct KernelObjectTag<Thread> {
class Thread : public KernelObject, public glcr::IntrusiveListNode<Thread> {
public:
uint64_t TypeTag() override { return KernelObject::THREAD; }
static uint64_t DefaultPermissions() {
return kZionPerm_Read | kZionPerm_Write;
}
enum State {
UNSPECIFIED,
CREATED,