[kernel] Remove getpid and fork system calls

The getpid and fork system calls were stubbed out previously, this
commit removes them and adds process_koid as a getpid replacement.
This commit is contained in:
2020-07-19 17:15:36 -07:00
parent c3abe035c8
commit 4cf222a5bb
4 changed files with 19 additions and 61 deletions

View File

@@ -5,8 +5,7 @@
#include "j6/errors.h"
extern "C" {
j6_status_t getpid(uint64_t *);
j6_status_t fork(uint64_t *);
j6_status_t get_process_koid(j6_koid_t *koid);
j6_status_t sleep(uint64_t til);
j6_status_t debug();
j6_status_t message(const char *msg);
@@ -20,17 +19,14 @@ main(int argc, const char **argv)
{
uint64_t pid = 0;
uint64_t child = 0;
j6_koid_t process = 0;
j6_status_t result = fork(&child);
j6_status_t result = get_process_koid(&process);
if (result != j6_status_ok)
return result;
message("hello from nulldrv!");
result = getpid(&pid);
if (result != j6_status_ok)
return result;
for (int i = 1; i < 5; ++i)
sleep(i*10);

View File

@@ -6,13 +6,13 @@ extern main
extern exit
section .text
global getpid
getpid:
global get_process_koid
get_process_koid:
push rbp
mov rbp, rsp
; address of out var should already be in rdi
mov rax, 0x13 ; getpid syscall
mov rax, 0x10 ; getpid syscall
syscall ; result is now already in rax, so just return
pop rbp
@@ -34,32 +34,19 @@ sleep:
push rbp
mov rbp, rsp
mov rax, 0x16 ; sleep syscall
mov rax, 0x14 ; sleep syscall
syscall
pop rbp
ret
global fork
fork:
push rbp
mov rbp, rsp
; address of out var should already be in rdi
mov rax, 0x12
syscall ; result left in rax
pop rbp
ret
global message
message:
push rbp
mov rbp, rsp
; message should already be in rdi
mov rax, 0x14
mov rax, 0x12
syscall
pop rbp