summaryrefslogtreecommitdiff
path: root/syscalls.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-17 21:41:21 +0200
committerMiguel <m.i@gmx.at>2018-08-17 21:41:21 +0200
commitc15925a24efe14f437d8a2699500241a58fdc8f9 (patch)
treec0db3a7d2a4f857324735df35e9cc1f0539c5f24 /syscalls.c
parent6fd78c2ff950310d8372ec0353553cc4a5a43e72 (diff)
cleanup and working on fifo pipes
Diffstat (limited to 'syscalls.c')
-rw-r--r--syscalls.c118
1 files changed, 24 insertions, 94 deletions
diff --git a/syscalls.c b/syscalls.c
index c4bd549..f2978cc 100644
--- a/syscalls.c
+++ b/syscalls.c
@@ -12,117 +12,49 @@ typedef struct fs_dirent_struct
char name[256];
}fs_dirent;
-//fool-os syscalls
-#define SYSCALL_READDIR 63
-#define SYSCALL_HAS_DATA 80
-#define SYSCALL_TUNE 81
-
-//syscalls required by newlib
-#define SYSCALL_EXIT 60
-#define SYSCALL_WRITE 61
-#define SYSCALL_READ 62
-#define SYSCALL_EXECVE 64
-#define SYSCALL_OPEN 65
-#define SYSCALL_CLOSE 66
-#define SYSCALL_FSTAT 67
-#define SYSCALL_ISATTY 68
-#define SYSCALL_LSEEK 69
-#define SYSCALL_SBRK 70
-#define SYSCALL_STAT 74
-#define SYSCALL_LSTAT 79
-
-// stubs only so far!
+#define SYSCALL_EXIT 60
+#define SYSCALL_WRITE 61
+#define SYSCALL_READ 62
+#define SYSCALL_READDIR 63 // fool-os-special
+#define SYSCALL_EXECVE 64
+#define SYSCALL_OPEN 65
+#define SYSCALL_CLOSE 66
+#define SYSCALL_FSTAT 67
+#define SYSCALL_ISATTY 68
+#define SYSCALL_LSEEK 69
+#define SYSCALL_SBRK 70
#define SYSCALL_GETTIMEOFDAY 71
-#define SYSCALL_FORK 72
-#define SYSCALL_KILL 73
-#define SYSCALL_LINK 73
-#define SYSCALL_TIMES 75
-#define SYSCALL_UNLINK 76
-#define SYSCALL_WAIT 77
-#define SYSCALL_GETPID 78
-
-/*
-int syscall_execve(char *name, char **argv, char **env);
-int syscall_write(int file, char *buf, int len);
-
-int syscall_readdir(const char *name,struct fs_dirent *dirs,int max);
-
-int syscall_exit(int ret, int none1, int none2);
-int syscall_open(char *name, int flags, int len);
-int syscall_read(int file, char *buf, int len);
-int syscall_close(int file,int none1,int none2);
-int syscall_fstat(int file, struct stat *st,int none);
-int syscall_isatty(int file,int none1,int none2);
-int syscall_lseek(int file,int ptr,int dir);
-int syscall_stat(char *file, struct stat *st);
-int syscall_sbrk(int incr, int none1, int none2);
-//
-int syscall_gettimeofday(struct timeval *tv, struct timezone *tz);
-int syscall_fork(void);
-int syscall_getpid(void);
-int syscall_kill(int pid, int sig);
-int syscall_link(char *old, char *ne);
-int syscall_times(struct tms *buf);
-int syscall_unlink(char *name);
-int syscall_wait(int *status);
-//
-int syscall_unhandled(int nr);
-*/
+#define SYSCALL_FORK 72
+#define SYSCALL_KILL 73
+#define SYSCALL_STAT 74
+#define SYSCALL_TIMES 75
+#define SYSCALL_UNLINK 76
+#define SYSCALL_WAIT 77
+#define SYSCALL_GETPID 78
+#define SYSCALL_LSTAT 79
+#define SYSCALL_HAS_DATA 80 // fool-os-special
+#define SYSCALL_TUNE 81 // fool-os-special
+#define SYSCALL_LINK 82
extern char **environ;
//struct _reent *_impure_ptr;
-// generic syscall interface!
-/*int volatile __attribute__ ((noinline)) syscall(int call, int p1, int p2, int p3)
-{
- int ebx; // persist over func call( a,c,d are scratch)
- int ret; // will hold return val
-
- asm("mov %%ebx, %0": "=b" (ebx));
-
-// asm("pusha");
-
- // select syscall
- asm("mov %0, %%eax"::"m"(call));
-
- // pass params
- asm("mov %0,%%edx"::"m"(p1));
- asm("mov %0,%%ecx"::"m"(p2));
- asm("mov %0,%%ebx"::"m"(p3));
-
- // interrrupt
- asm("int $0x80");
-
- // get return value
- asm("mov %%ebx, %0": "=b" (ret));
-
- // restore
- asm("mov %0,%%ebx"::"m"(ebx));
-
-// asm("popa");
-
- return ret;
-}
-*/
-
// fool os custom
-int readdir(const char *name,fs_dirent *dirs,int max)
+int readdir(const char *name,fs_dirent *dirs,int max)
{
-
return syscall(SYSCALL_READDIR,name,dirs,max);
}
int has_data_waiting()
{
-
return syscall(SYSCALL_HAS_DATA,0,0,0);
}
int fool_tune(int v1, int v2, int v3)
{
-
return syscall(SYSCALL_TUNE,v1,v2,v3);
}
+//
void _exit(int ret)
{
@@ -134,7 +66,6 @@ void _exit2(int ret,char **environ)
return syscall(SYSCALL_EXIT,ret,environ,0);
}
-//required by newlibc
int _close(int file)
{
return syscall(SYSCALL_CLOSE,file,0,0);
@@ -152,7 +83,6 @@ int _lseek(int file, int ptr, int dir)
int _read(int file, char *ptr, int len)
{
-
return syscall(SYSCALL_READ,file,ptr,len);
}