diff options
| author | Michal Idziorek <m.i@gmx.at> | 2015-05-22 09:14:16 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2015-05-22 09:14:16 +0200 |
| commit | 573a28a2ea7534a1e85d2e0a3aa3d06b1218e08c (patch) | |
| tree | 4d23995749d02459951bb386be238ad491cda45f | |
| parent | bd5c0694678df3361eddaedcf9ceca6db687e010 (diff) | |
started implementing files
| -rw-r--r-- | fs/file.h | 10 | ||||
| -rw-r--r-- | fs/mount.h | 14 | ||||
| -rw-r--r-- | kernel/syscalls.h | 2 | ||||
| -rw-r--r-- | kernel/task.c | 2 | ||||
| -rw-r--r-- | userspace/sys/syscalls.c | 71 |
5 files changed, 66 insertions, 33 deletions
@@ -3,9 +3,17 @@ #include <stdint.h> -typedef struct file_struct +typedef struct { + void(* seek)(int offset, int whence); + void(* read)(char *buf, int len); + void(* wrtie)(char *buf, int len); + void(* close)(); + void(* tell)(); + int(* stat)(struct stat *buf); + + void *data; //opaque }file; diff --git a/fs/mount.h b/fs/mount.h new file mode 100644 index 0000000..d27195f --- /dev/null +++ b/fs/mount.h @@ -0,0 +1,14 @@ +#ifndef MOUNT_H +#define MOUNT_H + +typedef struct +{ + char *path; // where? + int (*getdents)(uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count); + file get + + void *data //opaque + +}mount; + +#endif diff --git a/kernel/syscalls.h b/kernel/syscalls.h index d9a338d..ff7c2e5 100644 --- a/kernel/syscalls.h +++ b/kernel/syscalls.h @@ -31,10 +31,10 @@ #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); diff --git a/kernel/task.c b/kernel/task.c index 8bb6c13..91a2c83 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -150,7 +150,6 @@ volatile uint32_t task_fork(uint32_t oldesp) volatile void task_init(pdirectory *dir) { - // this is our main task on slot 0 task_list[0].parent=0; task_list[0].active=true; @@ -159,7 +158,6 @@ volatile void task_init(pdirectory *dir) task_list[0].esp = 0; // will be set by next task_switch_next() call. current_task=0; -// while(1); switch_to_user_mode(); //syscall_execve("/bin/foolshell",argv_init,env_init); diff --git a/userspace/sys/syscalls.c b/userspace/sys/syscalls.c index fe34f47..e6a6a4d 100644 --- a/userspace/sys/syscalls.c +++ b/userspace/sys/syscalls.c @@ -2,16 +2,6 @@ char **environ; -void _exit(int ret) -{ - _exit2(ret,environ); -} - -void _exit2(int ret,char **environ) -{ - return syscall(SYSCALL_EXIT,ret,environ,0); -} - // generic syscall interface! int syscall(int call, int p1, int p2, int p3) { @@ -38,12 +28,29 @@ int syscall(int call, int p1, int p2, int p3) return ebx; } +// fool os custom +int readdir(const char *name,fs_dirent *dirs,int max) +{ + + return syscall(SYSCALL_READDIR,name,dirs,max); +} + +void _exit(int ret) +{ + _exit2(ret,environ); +} + +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); } - int isatty(int file) { return syscall(SYSCALL_ISATTY,file,0,0); @@ -60,12 +67,6 @@ int read(int file, char *ptr, int len) return syscall(SYSCALL_READ,file,ptr,len); } -int readdir(const char *name,fs_dirent *dirs,int max) -{ - - return syscall(SYSCALL_READDIR,name,dirs,max); -} - int open(const char *name, int flags, int mode) { return syscall(SYSCALL_OPEN,name,flags,mode); @@ -91,6 +92,8 @@ int gettimeofday(struct timeval *tv, void *tz) return syscall(SYSCALL_GETTIMEOFDAY,tv,tz,0); } + + int fork(void) { return syscall(SYSCALL_FORK,0,0,0); @@ -106,36 +109,46 @@ int kill(int pid, int sig) return syscall(SYSCALL_KILL,pid,sig,0); } + + + int link(char *old, char *ne) { return syscall(SYSCALL_LINK,old,ne,0); } -int stat(const char *file, struct stat *st) +int unlink(char *name) { - return syscall(SYSCALL_STAT,file,st,0); + return syscall(SYSCALL_UNLINK,name,0,0); } -int lstat(const char *file, struct stat *st) + + +int times(struct tms *buf) { - return syscall(SYSCALL_LSTAT,file,st,0); + return syscall(SYSCALL_TIMES,buf,0,0); } -int fstat(int file, struct stat *st) + +int wait(int *status) { - return syscall(SYSCALL_FSTAT,file,st,0); + return syscall(SYSCALL_WAIT,status,0,0); } -int times(struct tms *buf) + + +int stat(const char *file, struct stat *st) { - return syscall(SYSCALL_TIMES,buf,0,0); + return syscall(SYSCALL_STAT,file,st,0); } -int unlink(char *name) +int lstat(const char *file, struct stat *st) { - return syscall(SYSCALL_UNLINK,name,0,0); + return syscall(SYSCALL_LSTAT,file,st,0); } -int wait(int *status) +int fstat(int file, struct stat *st) { - return syscall(SYSCALL_WAIT,status,0,0); + return syscall(SYSCALL_FSTAT,file,st,0); } + + |
