Spawn Processes using memory primitives rather than and elf loader.

This allows us to remove the temporary syscall for that style of process
spawn.
This commit is contained in:
Drew Galbraith 2023-06-07 00:04:53 -07:00
parent b06c76e477
commit 23895b5c6c
26 changed files with 403 additions and 94 deletions

View file

@ -12,53 +12,45 @@
#define Z_PROCESS_SPAWN 0x02
#define Z_PROCESS_START 0x03
#define Z_PROCESS_SPAWN_ELF 0x1'00000002
#define ZC_PROC_SPAWN_PROC 0x100
#define ZC_PROC_SPAWN_THREAD 0x101
#define Z_INIT_PROC_SELF 0x1
#define Z_INIT_AS_SELF 0x2
// Thread Calls.
#define Z_THREAD_CREATE 0x10
#define Z_THREAD_START 0x11
#define Z_THREAD_EXIT 0x12
// Memory Calls
#define Z_ADDRESS_SPACE_MAP 0x21
#define Z_ADDRESS_SPACE_UNMAP 0x22
#define Z_MEMORY_OBJECT_CREATE 0x30
// Debugging Calls.
#define Z_DEBUG_PRINT 0x10000000
uint64_t ZDebug(const char* message);
void ZProcessExit(uint64_t code);
// TODO: Move structs into an internal header.
struct ZProcessSpawnElfReq {
uint64_t cap_id;
uint64_t elf_base;
uint64_t elf_size;
};
[[nodiscard]] uint64_t ZProcessSpawn(uint64_t proc_cap, uint64_t* new_proc_cap,
uint64_t* new_as_cap);
// Creates a child process of the current one and
// starts its root thread from the provided ELF file.
uint64_t ZProcessSpawnElf(uint64_t cap_id, uint64_t elf_base,
uint64_t elf_size);
// UNUSED for now, I think we can get away with just starting a thread.
[[nodiscard]] uint64_t ZProcessStart(uint64_t proc_cap, uint64_t thread_cap,
uint64_t entry, uint64_t arg1,
uint64_t arg2);
struct ZThreadCreateReq {
uint64_t proc_cap;
};
[[nodiscard]] uint64_t ZThreadCreate(uint64_t proc_cap, uint64_t* thread_cap);
struct ZThreadCreateResp {
uint64_t thread_cap;
};
uint64_t ZThreadCreate(uint64_t proc_cap, uint64_t* thread_cap);
struct ZThreadStartReq {
uint64_t thread_cap;
uint64_t entry;
uint64_t arg1;
uint64_t arg2;
};
uint64_t ZThreadStart(uint64_t thread_cap, uint64_t entry, uint64_t arg1,
uint64_t arg2);
[[nodiscard]] uint64_t ZThreadStart(uint64_t thread_cap, uint64_t entry,
uint64_t arg1, uint64_t arg2);
void ZThreadExit();
[[nodiscard]] uint64_t ZAddressSpaceMap(uint64_t as_cap, uint64_t offset,
uint64_t mem_cap, uint64_t* vaddr);
[[nodiscard]] uint64_t ZMemoryObjectCreate(uint64_t size, uint64_t* mem_cap);
[[nodiscard]] uint64_t ZDebug(const char* message);

View file

@ -4,3 +4,4 @@
#define ZE_NOT_FOUND 0x1
#define ZE_INVALID 0x2
#define ZE_DENIED 0x4
#define ZE_UNIMPLEMENTED 0x8