summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-11-21 15:21:07 +0100
committerMichal Idziorek <m.i@gmx.at>2014-11-21 15:21:07 +0100
commit6e8ea08166b53507f38ed7f435728b7470a061ab (patch)
treed0669f3a70963056dbd7ffc59ab04e5cd172c52e /userspace
parent1f460d7d4fcbf29e21b3da77eab247f528f02f19 (diff)
trying to port binutils
Diffstat (limited to 'userspace')
-rw-r--r--userspace/Makefile3
-rw-r--r--userspace/crt0.S4
-rw-r--r--userspace/smalltest.c4
-rw-r--r--userspace/sys.c55
-rw-r--r--userspace/syscalls.c46
5 files changed, 106 insertions, 6 deletions
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 <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+
+// 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 <sys/stat.h>
-#include <string.h>
-#include <stdint.h>
#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);
+}