a few new syscalls, init process
This commit is contained in:
1 parent
320a24e1a5
commit
cdf7ed4cea
12 files changed
+830
-480
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// init.c - first user-mode process
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Syscall stubs
|
||||
// ---------------------------------------------------------------------------
|
||||
extern uint32_t SysCreateProcess(const char* path, uint32_t* handleOut,
|
||||
const char* cmdline);
|
||||
extern uint32_t SysCloseHandle(uint32_t handle);
|
||||
extern void SysDebugPrint(const char* str);
|
||||
extern uint32_t SysWaitForProcess(uint32_t handle);
|
||||
extern void SysExitProcess(int code);
|
||||
extern void SysYield(void);
|
||||
|
||||
#define STATUS_SUCCESS 0u
|
||||
|
||||
void _start()
|
||||
{
|
||||
uint32_t h = 0;
|
||||
uint32_t s = 0;
|
||||
|
||||
SysDebugPrint("[init] starting shell\n");
|
||||
s = SysCreateProcess("shell.exe", &h, NULL);
|
||||
if (s != STATUS_SUCCESS) {
|
||||
SysDebugPrint("[init] FATAL: failed to start shell.exe\n");
|
||||
SysExitProcess(1);
|
||||
}
|
||||
|
||||
SysDebugPrint("[init] waiting for shell\n");
|
||||
s = SysWaitForProcess(h);
|
||||
if (s != STATUS_SUCCESS)
|
||||
SysDebugPrint("[init] WARNING: SysWaitForProcess returned error\n");
|
||||
SysCloseHandle(h);
|
||||
|
||||
SysDebugPrint("[init] done\n");
|
||||
|
||||
SysExitProcess(0);
|
||||
}
|
||||
Reference in new issue
Block a user