Compare commits
2 Commits
b035795eb3
...
7ec221c36d
Author | SHA1 | Date | |
---|---|---|---|
7ec221c36d | |||
5816f54293 |
@ -1,43 +1,21 @@
|
|||||||
#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 int __luna_syscall0(long int sys_num);
|
long __luna_syscall0(long sys_num);
|
||||||
long int __luna_syscall1(long int sys_num, unsigned long int arg0);
|
long __luna_syscall1(long sys_num, unsigned long arg0);
|
||||||
long int __luna_syscall2(long int sys_num, unsigned long int arg0, unsigned long int arg1);
|
long __luna_syscall2(long sys_num, unsigned long arg0, unsigned long arg1);
|
||||||
long int __luna_syscall3(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2);
|
long __luna_syscall3(long sys_num, unsigned long arg0, unsigned long arg1, unsigned long arg2);
|
||||||
long int __luna_syscall4(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);
|
||||||
unsigned long int arg3);
|
long __luna_syscall5(long sys_num, unsigned long arg0, unsigned long arg1, unsigned long arg2, unsigned long arg3,
|
||||||
long int __luna_syscall5(long int sys_num, unsigned long int arg0, unsigned long int arg1, unsigned long int arg2,
|
unsigned long arg4);
|
||||||
unsigned long int arg3, unsigned long int arg4);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
@ -1,9 +1,24 @@
|
|||||||
#ifndef _SYS_SYSCALL_H
|
#ifndef _SYS_SYSCALL_H
|
||||||
#define _SYS_SYSCALL_H
|
#define _SYS_SYSCALL_H
|
||||||
|
|
||||||
#define __want_syscalls
|
#define SYS_exit 0
|
||||||
#include <luna/syscall.h>
|
#define SYS_yield 1
|
||||||
#undef __want_syscalls
|
#define SYS_sleep 2
|
||||||
#undef _LUNA_SYSCALL_H
|
#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
|
||||||
|
|
||||||
#endif
|
#endif
|
50
libs/libc/src/luna/syscall.asm
Normal file
50
libs/libc/src/luna/syscall.asm
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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
|
@ -1,48 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
@ -3,6 +3,7 @@
|
|||||||
#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"
|
||||||
@ -11,6 +12,7 @@ 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");
|
||||||
|
Loading…
Reference in New Issue
Block a user