From 6e8ea08166b53507f38ed7f435728b7470a061ab Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Fri, 21 Nov 2014 15:21:07 +0100 Subject: trying to port binutils --- userspace/Makefile | 3 ++- userspace/crt0.S | 4 ++-- userspace/smalltest.c | 4 ++++ userspace/sys.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ userspace/syscalls.c | 46 +++++++++++++++++++++++++++++++++++++++--- 5 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 userspace/smalltest.c create mode 100644 userspace/sys.c (limited to 'userspace') diff --git a/userspace/Makefile b/userspace/Makefile index 7ae91ee..ad2ae1e 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -9,7 +9,7 @@ CFLAGS+=--no-builtin-free LDFLAGS=-L/home/miguel/temp/fool-os-stuff/newlib-build-clean-new/i686-elf/newlib ext2.img: shell simple brainfuck add - dd if=/dev/zero of=ext2.img bs=512 count=500 + dd if=/dev/zero of=ext2.img bs=512 count=3500 sudo mkfs.ext2 -O none ext2.img -F mkdir mnt sudo mount ext2.img mnt @@ -21,6 +21,7 @@ ext2.img: shell simple brainfuck add cp simple mnt cp brainfuck mnt cp add mnt + cp ~/temp/fool-os-stuff/binutils-fool-build/binutils/ar.bin mnt sync sudo umount mnt rm mnt -rf diff --git a/userspace/crt0.S b/userspace/crt0.S index e3bfa3b..48eadd9 100644 --- a/userspace/crt0.S +++ b/userspace/crt0.S @@ -8,8 +8,8 @@ _start: push $0 call sbrk -push $[_BSS_END_] -call sbrk +#push $[_BSS_END_] +#call sbrk call main diff --git a/userspace/smalltest.c b/userspace/smalltest.c new file mode 100644 index 0000000..905869d --- /dev/null +++ b/userspace/smalltest.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/userspace/sys.c b/userspace/sys.c new file mode 100644 index 0000000..7dcfaee --- /dev/null +++ b/userspace/sys.c @@ -0,0 +1,55 @@ +#include +#include +#include + + +// building binutils required this stubs! +long sysconf(int name) +{ + return 0; +} + + +mode_t umask(mode_t mask) +{ + return mask; +} + +int chmod(const char * path, mode_t mode) +{ + return 0; +} + +int fcntl(int fd, int cmd, ...) +{ + return -1; +} + +int lstat(const char *path, struct stat *buf) +{ + return -1; +} + +char *getwd(char *buf) +{ + return buf; +} +int access(const char *pathname, int mode) +{ + return 0; +} + +int utime(const char *filename, const int *x) +{ + return 0; +} + +int rmdir (const char *pathname) +{ + return -1; +} + +int chown(const char *path, uid_t owner, gid_t group) +{ + return 0; +} diff --git a/userspace/syscalls.c b/userspace/syscalls.c index 8c8bfc9..51436fb 100644 --- a/userspace/syscalls.c +++ b/userspace/syscalls.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "../kernel/syscalls.h" /* @@ -93,4 +90,47 @@ uint32_t sbrk(int incr) return syscall(SYSCALL_SBRK,incr,0,0); } +int gettimeofday(struct timeval *tv, void *tz) +{ + return syscall(SYSCALL_GETTIMEOFDAY,tv,tz,0); +} +int fork(void) +{ + return syscall(SYSCALL_FORK,0,0,0); +} + +int getpid(void) +{ + return syscall(SYSCALL_GETPID,0,0,0); +} + +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) +{ + return syscall(SYSCALL_STAT,file,st,0); +} + +int times(struct tms *buf) +{ + return syscall(SYSCALL_TIMES,buf,0,0); +} + +int unlink(char *name) +{ + return syscall(SYSCALL_UNLINK,name,0,0); +} + +int wait(int *status) +{ + return syscall(SYSCALL_WAIT,status,0,0); +} -- cgit v1.2.3