Organize system calls
* syscalls should all return j6_status_t now * syscalls are grouped by category in name as well as in files
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "j6/types.h"
|
||||
#include "j6/errors.h"
|
||||
|
||||
extern "C" {
|
||||
int32_t getpid();
|
||||
int32_t fork();
|
||||
void sleep(uint64_t til);
|
||||
void debug();
|
||||
void message(const char *msg);
|
||||
j6_status_t getpid(uint64_t *);
|
||||
j6_status_t fork(uint64_t *);
|
||||
j6_status_t sleep(uint64_t til);
|
||||
j6_status_t debug();
|
||||
j6_status_t message(const char *msg);
|
||||
|
||||
int main(int, const char **);
|
||||
}
|
||||
@@ -15,10 +18,21 @@ extern "C" {
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
int32_t pid = getpid();
|
||||
int32_t child = fork();
|
||||
uint64_t pid = 0;
|
||||
uint64_t child = 0;
|
||||
|
||||
j6_status_t result = fork(&child);
|
||||
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);
|
||||
return 0;
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,9 @@ getpid:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 0x02 ; getpid syscall
|
||||
syscall ; pid is now already in rax, so just return
|
||||
; address of out var should already be in rdi
|
||||
mov rax, 0x13 ; getpid syscall
|
||||
syscall ; result is now already in rax, so just return
|
||||
|
||||
pop rbp
|
||||
ret
|
||||
@@ -33,7 +34,7 @@ sleep:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 0x21 ; sleep syscall
|
||||
mov rax, 0x16 ; sleep syscall
|
||||
syscall
|
||||
|
||||
pop rbp
|
||||
@@ -44,8 +45,9 @@ fork:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
mov rax, 0x03
|
||||
syscall ; pid left in rax
|
||||
; address of out var should already be in rdi
|
||||
mov rax, 0x12
|
||||
syscall ; result left in rax
|
||||
|
||||
pop rbp
|
||||
ret
|
||||
@@ -57,7 +59,7 @@ message:
|
||||
mov rbp, rsp
|
||||
|
||||
; message should already be in rdi
|
||||
mov rax, 0x10
|
||||
mov rax, 0x14
|
||||
syscall
|
||||
|
||||
pop rbp
|
||||
|
||||
Reference in New Issue
Block a user