Compare commits

..

No commits in common. "7ec221c36dd37130bc91442762c27b8d152f1cef" and "b035795eb3f5f42be2b2ee88b73ee9204732132d" have entirely different histories.

5 changed files with 82 additions and 79 deletions

View File

@ -1,21 +1,43 @@
#ifndef _LUNA_SYSCALL_H #ifndef _LUNA_SYSCALL_H
#define _LUNA_SYSCALL_H #define _LUNA_SYSCALL_H
#define SYS_exit 0
#define SYS_yield 1
#define SYS_sleep 2
#define SYS_write 3
#define SYS_paint 4
#define SYS_getprocid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8
#define SYS_read 9
#define SYS_close 10
#define SYS_seek 11
#define SYS_exec 12
#define SYS_fcntl 13
#define SYS_mprotect 14
#define SYS_clock 15
#define SYS_mkdir 16
#define SYS_fork 17
#define SYS_waitpid 18
#ifndef __want_syscalls
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
long __luna_syscall0(long sys_num); long int __luna_syscall0(long int sys_num);
long __luna_syscall1(long sys_num, unsigned long arg0); long int __luna_syscall1(long int sys_num, unsigned long int arg0);
long __luna_syscall2(long sys_num, unsigned long arg0, unsigned long arg1); long int __luna_syscall2(long int sys_num, unsigned long int arg0, unsigned long int arg1);
long __luna_syscall3(long sys_num, unsigned long arg0, unsigned long arg1, unsigned long arg2); long int __luna_syscall3(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2);
long __luna_syscall4(long sys_num, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3); long int __luna_syscall4(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
long __luna_syscall5(long sys_num, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long int arg3);
unsigned long arg4); long int __luna_syscall5(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3, unsigned long int arg4);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif
#endif #endif

View File

@ -1,24 +1,9 @@
#ifndef _SYS_SYSCALL_H #ifndef _SYS_SYSCALL_H
#define _SYS_SYSCALL_H #define _SYS_SYSCALL_H
#define SYS_exit 0 #define __want_syscalls
#define SYS_yield 1 #include <luna/syscall.h>
#define SYS_sleep 2 #undef __want_syscalls
#define SYS_write 3 #undef _LUNA_SYSCALL_H
#define SYS_paint 4
#define SYS_getprocid 5
#define SYS_mmap 6
#define SYS_munmap 7
#define SYS_open 8
#define SYS_read 9
#define SYS_close 10
#define SYS_seek 11
#define SYS_exec 12
#define SYS_fcntl 13
#define SYS_mprotect 14
#define SYS_clock 15
#define SYS_mkdir 16
#define SYS_fork 17
#define SYS_waitpid 18
#endif #endif

View File

@ -1,50 +0,0 @@
global __luna_syscall0
__luna_syscall0:
mov rax, rdi
int 0x42
ret
global __luna_syscall1
__luna_syscall1:
mov rax, rdi
mov rdi, rsi
int 0x42
ret
global __luna_syscall2
__luna_syscall2:
mov rax, rdi
mov rdi, rsi
mov rsi, rdx
int 0x42
ret
global __luna_syscall3
__luna_syscall3:
mov rax, rdi
mov rdi, rsi
mov rsi, rdx
mov rdx, rcx
int 0x42
ret
global __luna_syscall4
__luna_syscall4:
mov rax, rdi
mov rdi, rsi
mov rsi, rdx
mov rdx, rcx
mov r10, r8
int 0x42
ret
global __luna_syscall5
__luna_syscall5:
mov rax, rdi
mov rdi, rsi
mov rsi, rdx
mov rdx, rcx
mov r10, r8
mov r8, r9
int 0x42
ret

View File

@ -0,0 +1,48 @@
#include <luna/syscall.h>
long int __luna_syscall0(long int sys_num)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num));
return result;
}
long int __luna_syscall1(long int sys_num, unsigned long int arg0)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0));
return result;
}
long int __luna_syscall2(long int sys_num, unsigned long int arg0, unsigned long int arg1)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1));
return result;
}
long int __luna_syscall3(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2)
{
long int result;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2));
return result;
}
long int __luna_syscall4(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3)
{
long int result;
register unsigned long int value0 asm("r10") = arg3;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2), "r"(value0));
return result;
}
long int __luna_syscall5(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
unsigned long int arg3, unsigned long int arg4)
{
long int result;
register unsigned long int value0 asm("r10") = arg3;
register unsigned long int value1 asm("r8") = arg4;
asm volatile("int $0x42" : "=a"(result) : "a"(sys_num), "D"(arg0), "S"(arg1), "d"(arg2), "r"(value0), "r"(value1));
return result;
}

View File

@ -3,7 +3,6 @@
#include <luna.h> #include <luna.h>
#include <luna/syscall.h> #include <luna/syscall.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/syscall.h>
#include <unistd.h> #include <unistd.h>
extern "C" extern "C"
@ -12,7 +11,6 @@ extern "C"
{ {
return (int)syscall(SYS_exec, program); return (int)syscall(SYS_exec, program);
} }
int execve(const char*, char* const[], char* const[]) int execve(const char*, char* const[], char* const[])
{ {
NOT_IMPLEMENTED("execve"); NOT_IMPLEMENTED("execve");