From d04645198d648a17ccb83e70aa5e6d60a06121aa Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 18 Dec 2009 16:22:58 +0100 Subject: [nonworking commit] Started porting newlib --- Source/Applications/Demos/Makefile | 2 +- Source/Applications/PaperWork/Makefile | 2 +- Source/Applications/Shell/Makefile | 2 +- Source/Library/App.ld | 33 ++++++++++++++++++++++ Source/Library/Link.ld | 33 ---------------------- Source/UnixUserland/App.ld | 33 ++++++++++++++++++++++ Source/UnixUserland/Makefile | 50 ++++++++++++++++++++++++++++++++++ Source/UnixUserland/_exit.c | 2 ++ Source/UnixUserland/_start.c | 7 +++++ Source/UnixUserland/close.c | 3 ++ Source/UnixUserland/environ.c | 2 ++ Source/UnixUserland/execve.c | 8 ++++++ Source/UnixUserland/fork.c | 8 ++++++ Source/UnixUserland/fstat.c | 6 ++++ Source/UnixUserland/getpid.c | 3 ++ Source/UnixUserland/isatty.c | 3 ++ Source/UnixUserland/kill.c | 8 ++++++ Source/UnixUserland/link.c | 8 ++++++ Source/UnixUserland/lseek.c | 3 ++ Source/UnixUserland/open.c | 3 ++ Source/UnixUserland/read.c | 3 ++ Source/UnixUserland/sbrk.c | 16 +++++++++++ Source/UnixUserland/stat.c | 2 ++ Source/UnixUserland/times.c | 1 + Source/UnixUserland/unlink.c | 8 ++++++ Source/UnixUserland/wait.c | 8 ++++++ Source/UnixUserland/write.c | 10 +++++++ 27 files changed, 231 insertions(+), 36 deletions(-) create mode 100644 Source/Library/App.ld delete mode 100644 Source/Library/Link.ld create mode 100644 Source/UnixUserland/App.ld create mode 100644 Source/UnixUserland/Makefile create mode 100644 Source/UnixUserland/_exit.c create mode 100644 Source/UnixUserland/_start.c create mode 100644 Source/UnixUserland/close.c create mode 100644 Source/UnixUserland/environ.c create mode 100644 Source/UnixUserland/execve.c create mode 100644 Source/UnixUserland/fork.c create mode 100644 Source/UnixUserland/fstat.c create mode 100644 Source/UnixUserland/getpid.c create mode 100644 Source/UnixUserland/isatty.c create mode 100644 Source/UnixUserland/kill.c create mode 100644 Source/UnixUserland/link.c create mode 100644 Source/UnixUserland/lseek.c create mode 100644 Source/UnixUserland/open.c create mode 100644 Source/UnixUserland/read.c create mode 100644 Source/UnixUserland/sbrk.c create mode 100644 Source/UnixUserland/stat.c create mode 100644 Source/UnixUserland/times.c create mode 100644 Source/UnixUserland/unlink.c create mode 100644 Source/UnixUserland/wait.c create mode 100644 Source/UnixUserland/write.c (limited to 'Source') diff --git a/Source/Applications/Demos/Makefile b/Source/Applications/Demos/Makefile index e66acce..82489ba 100644 --- a/Source/Applications/Demos/Makefile +++ b/Source/Applications/Demos/Makefile @@ -7,7 +7,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/Link.ld -L ../../Library +LDFLAGS = -T ../../Library/App.ld -L ../../Library Applications = asmdemo cxxdemo GOL diff --git a/Source/Applications/PaperWork/Makefile b/Source/Applications/PaperWork/Makefile index fe8d564..c39fc83 100644 --- a/Source/Applications/PaperWork/Makefile +++ b/Source/Applications/PaperWork/Makefile @@ -4,7 +4,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/Link.ld -L ../../Library +LDFLAGS = -T ../../Library/App.ld -L ../../Library Objects = main.o OutFile = PaperWork diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile index bf81af6..a5587d8 100644 --- a/Source/Applications/Shell/Makefile +++ b/Source/Applications/Shell/Makefile @@ -4,7 +4,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/Link.ld -L ../../Library +LDFLAGS = -T ../../Library/App.ld -L ../../Library Objects = main.o \ Shell.ns.o \ diff --git a/Source/Library/App.ld b/Source/Library/App.ld new file mode 100644 index 0000000..68591fd --- /dev/null +++ b/Source/Library/App.ld @@ -0,0 +1,33 @@ +ENTRY (start) +INPUT (Melon.o) + +SECTIONS{ + . = 0x10000000; + + .text : { + *(.text) + } + + .rodata ALIGN (0x1000) :{ + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } + + end = .; _end = .; __end = .; +} diff --git a/Source/Library/Link.ld b/Source/Library/Link.ld deleted file mode 100644 index 68591fd..0000000 --- a/Source/Library/Link.ld +++ /dev/null @@ -1,33 +0,0 @@ -ENTRY (start) -INPUT (Melon.o) - -SECTIONS{ - . = 0x10000000; - - .text : { - *(.text) - } - - .rodata ALIGN (0x1000) :{ - *(.rodata) - } - - .data ALIGN (0x1000) : { - start_ctors = .; - *(.ctor*) - end_ctors = .; - start_dtors = .; - *(.dtor*) - end_dtors = .; - *(.data) - } - - .bss : { - sbss = .; - *(COMMON) - *(.bss) - ebss = .; - } - - end = .; _end = .; __end = .; -} diff --git a/Source/UnixUserland/App.ld b/Source/UnixUserland/App.ld new file mode 100644 index 0000000..03ac84f --- /dev/null +++ b/Source/UnixUserland/App.ld @@ -0,0 +1,33 @@ +ENTRY (_start) +INPUT (MelonUnix.o) + +SECTIONS{ + . = 0x10000000; + + .text : { + *(.text) + } + + .rodata ALIGN (0x1000) :{ + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } + + end = .; _end = .; __end = .; +} diff --git a/Source/UnixUserland/Makefile b/Source/UnixUserland/Makefile new file mode 100644 index 0000000..44fa29f --- /dev/null +++ b/Source/UnixUserland/Makefile @@ -0,0 +1,50 @@ +.PHONY: clean, mrproper + +CC = gcc +CCFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -Werror -I../../Ports/newlib-1.15.0/newlib/libc/include + +LD = ld +LDFLAGS = -r + +OutFile = MelonUnix.o +Objects = _exit.o \ + _start.o \ + close.o \ + environ.o \ + execve.o \ + fork.o \ + fstat.o \ + getpid.o \ + isatty.o \ + kill.o \ + link.o \ + lseek.o \ + open.o \ + read.o \ + sbrk.o \ + stat.o \ + times.o \ + unlink.o \ + wait.o \ + write.o + +all: $(OutFile) + echo "* Done with $(OutFile)." + +rebuild: mrproper all + +$(OutFile): $(Objects) + echo "* Linking executable : $(OutFile)..." + $(LD) $(LDFLAGS) -o $(OutFile) $^ + +%.o: %.c + echo "* Compiling $<..." + $(CC) -c $< -o $@ $(CFLAGS) + +clean: + echo "* Removing object files..." + rm -rf $(Objects) + +mrproper: clean + echo "* Removing executable: $(OutFile)" + rm -rf $(OutFile) diff --git a/Source/UnixUserland/_exit.c b/Source/UnixUserland/_exit.c new file mode 100644 index 0000000..8753f0c --- /dev/null +++ b/Source/UnixUserland/_exit.c @@ -0,0 +1,2 @@ +void _exit(int errcode) { +} diff --git a/Source/UnixUserland/_start.c b/Source/UnixUserland/_start.c new file mode 100644 index 0000000..00dc77e --- /dev/null +++ b/Source/UnixUserland/_start.c @@ -0,0 +1,7 @@ +int main(); + +void _start() { + main(); + asm volatile("int $66;"); + while(1); +} diff --git a/Source/UnixUserland/close.c b/Source/UnixUserland/close.c new file mode 100644 index 0000000..d1e0a16 --- /dev/null +++ b/Source/UnixUserland/close.c @@ -0,0 +1,3 @@ +int close(int file) { + return -1; +} diff --git a/Source/UnixUserland/environ.c b/Source/UnixUserland/environ.c new file mode 100644 index 0000000..7a59da1 --- /dev/null +++ b/Source/UnixUserland/environ.c @@ -0,0 +1,2 @@ +char *_env[1] = { 0 }; +char **environ = _env; diff --git a/Source/UnixUserland/execve.c b/Source/UnixUserland/execve.c new file mode 100644 index 0000000..b066745 --- /dev/null +++ b/Source/UnixUserland/execve.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int execve(char *name, char **argv, char **env) { + errno = ENOMEM; + return -1; +} diff --git a/Source/UnixUserland/fork.c b/Source/UnixUserland/fork.c new file mode 100644 index 0000000..012bc17 --- /dev/null +++ b/Source/UnixUserland/fork.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int fork() { + errno = EAGAIN; + return -1; +} diff --git a/Source/UnixUserland/fstat.c b/Source/UnixUserland/fstat.c new file mode 100644 index 0000000..78d32f2 --- /dev/null +++ b/Source/UnixUserland/fstat.c @@ -0,0 +1,6 @@ +#include + +int fstat(int file, struct stat *st) { + st->st_mode = S_IFCHR; + return 0; +} diff --git a/Source/UnixUserland/getpid.c b/Source/UnixUserland/getpid.c new file mode 100644 index 0000000..c5e6884 --- /dev/null +++ b/Source/UnixUserland/getpid.c @@ -0,0 +1,3 @@ +int getpid() { + return 1; +} diff --git a/Source/UnixUserland/isatty.c b/Source/UnixUserland/isatty.c new file mode 100644 index 0000000..8a0d1e7 --- /dev/null +++ b/Source/UnixUserland/isatty.c @@ -0,0 +1,3 @@ +int isatty(int file) { + return 1; +} diff --git a/Source/UnixUserland/kill.c b/Source/UnixUserland/kill.c new file mode 100644 index 0000000..c1f438b --- /dev/null +++ b/Source/UnixUserland/kill.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int kill(int pid, int sig) { + errno = EINVAL; + return -1; +} diff --git a/Source/UnixUserland/link.c b/Source/UnixUserland/link.c new file mode 100644 index 0000000..17c08dd --- /dev/null +++ b/Source/UnixUserland/link.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int link(char *old, char *new) { + errno = EMLINK; + return -1; +} diff --git a/Source/UnixUserland/lseek.c b/Source/UnixUserland/lseek.c new file mode 100644 index 0000000..d3d24d8 --- /dev/null +++ b/Source/UnixUserland/lseek.c @@ -0,0 +1,3 @@ +int lseek(int file, int ptr, int dir) { + return 0; +} diff --git a/Source/UnixUserland/open.c b/Source/UnixUserland/open.c new file mode 100644 index 0000000..eb9bed7 --- /dev/null +++ b/Source/UnixUserland/open.c @@ -0,0 +1,3 @@ +int open(const char* name, int flags, int mode) { + return -1; +} diff --git a/Source/UnixUserland/read.c b/Source/UnixUserland/read.c new file mode 100644 index 0000000..303c413 --- /dev/null +++ b/Source/UnixUserland/read.c @@ -0,0 +1,3 @@ +int read(int file, char *ptr, int len) { + return 0; +} diff --git a/Source/UnixUserland/sbrk.c b/Source/UnixUserland/sbrk.c new file mode 100644 index 0000000..26df466 --- /dev/null +++ b/Source/UnixUserland/sbrk.c @@ -0,0 +1,16 @@ +#include + +caddr_t sbrk(int incr) { + extern char end; + static char *heap_end; + char *prev_heap_end; + + if (heap_end == 0) { + heap_end = &end; + } + prev_heap_end = heap_end; + + heap_end += incr; + return (caddr_t) prev_heap_end; + +} diff --git a/Source/UnixUserland/stat.c b/Source/UnixUserland/stat.c new file mode 100644 index 0000000..1dada06 --- /dev/null +++ b/Source/UnixUserland/stat.c @@ -0,0 +1,2 @@ +#include + diff --git a/Source/UnixUserland/times.c b/Source/UnixUserland/times.c new file mode 100644 index 0000000..39ebf29 --- /dev/null +++ b/Source/UnixUserland/times.c @@ -0,0 +1 @@ +#include diff --git a/Source/UnixUserland/unlink.c b/Source/UnixUserland/unlink.c new file mode 100644 index 0000000..112ca54 --- /dev/null +++ b/Source/UnixUserland/unlink.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int unlink(char *name) { + errno = ENOENT; + return -1; +} diff --git a/Source/UnixUserland/wait.c b/Source/UnixUserland/wait.c new file mode 100644 index 0000000..5073c77 --- /dev/null +++ b/Source/UnixUserland/wait.c @@ -0,0 +1,8 @@ +#include +#undef errno +extern int errno; + +int wait(int *status) { + errno = ECHILD; + return -1; +} diff --git a/Source/UnixUserland/write.c b/Source/UnixUserland/write.c new file mode 100644 index 0000000..3cd436b --- /dev/null +++ b/Source/UnixUserland/write.c @@ -0,0 +1,10 @@ +int write(int file, char *ptr, int len) { + int i; + for (i = 0; i < len; i++) { + int t = ptr[i]; + asm volatile("mov $0xFFFFFF01, %%eax; \ + mov %0, %%ebx; \ + int $64;" : : "r"(t)); + } + return len; +} -- cgit v1.2.3 From 260347c06637f15ea93c6ad99bce4420a28bae6b Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 18 Dec 2009 16:26:56 +0100 Subject: Revert "Nothing, really" This reverts commit 5f87c447bdcb82beacbfb930942fe9995dcdb60f. --- Source/Library/Userland/Start.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp index f1d1771..0c25491 100644 --- a/Source/Library/Userland/Start.cpp +++ b/Source/Library/Userland/Start.cpp @@ -13,14 +13,13 @@ VirtualTerminal invt(0), outvt(0); int main(const Vector& args); extern "C" void start() { - heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index - //Call static constructors u32int i = 0; for(u32int * call = &start_ctors; call < &end_ctors; call++) { ((void (*)(void))*call)(); } + heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index invt = VirtualTerminal::getIn(); outvt = VirtualTerminal::getOut(); if (!invt.valid()) threadFinishedSyscall(1); if (!outvt.valid()) threadFinishedSyscall(2); -- cgit v1.2.3 From 437e65ecbdedd07105254b1b5e6a41d191a794a3 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 18 Dec 2009 16:27:29 +0100 Subject: Revert "[nonworking commit] Started porting newlib" This reverts commit d04645198d648a17ccb83e70aa5e6d60a06121aa. --- Source/Applications/Demos/Makefile | 2 +- Source/Applications/PaperWork/Makefile | 2 +- Source/Applications/Shell/Makefile | 2 +- Source/Library/App.ld | 33 ---------------------- Source/Library/Link.ld | 33 ++++++++++++++++++++++ Source/UnixUserland/App.ld | 33 ---------------------- Source/UnixUserland/Makefile | 50 ---------------------------------- Source/UnixUserland/_exit.c | 2 -- Source/UnixUserland/_start.c | 7 ----- Source/UnixUserland/close.c | 3 -- Source/UnixUserland/environ.c | 2 -- Source/UnixUserland/execve.c | 8 ------ Source/UnixUserland/fork.c | 8 ------ Source/UnixUserland/fstat.c | 6 ---- Source/UnixUserland/getpid.c | 3 -- Source/UnixUserland/isatty.c | 3 -- Source/UnixUserland/kill.c | 8 ------ Source/UnixUserland/link.c | 8 ------ Source/UnixUserland/lseek.c | 3 -- Source/UnixUserland/open.c | 3 -- Source/UnixUserland/read.c | 3 -- Source/UnixUserland/sbrk.c | 16 ----------- Source/UnixUserland/stat.c | 2 -- Source/UnixUserland/times.c | 1 - Source/UnixUserland/unlink.c | 8 ------ Source/UnixUserland/wait.c | 8 ------ Source/UnixUserland/write.c | 10 ------- 27 files changed, 36 insertions(+), 231 deletions(-) delete mode 100644 Source/Library/App.ld create mode 100644 Source/Library/Link.ld delete mode 100644 Source/UnixUserland/App.ld delete mode 100644 Source/UnixUserland/Makefile delete mode 100644 Source/UnixUserland/_exit.c delete mode 100644 Source/UnixUserland/_start.c delete mode 100644 Source/UnixUserland/close.c delete mode 100644 Source/UnixUserland/environ.c delete mode 100644 Source/UnixUserland/execve.c delete mode 100644 Source/UnixUserland/fork.c delete mode 100644 Source/UnixUserland/fstat.c delete mode 100644 Source/UnixUserland/getpid.c delete mode 100644 Source/UnixUserland/isatty.c delete mode 100644 Source/UnixUserland/kill.c delete mode 100644 Source/UnixUserland/link.c delete mode 100644 Source/UnixUserland/lseek.c delete mode 100644 Source/UnixUserland/open.c delete mode 100644 Source/UnixUserland/read.c delete mode 100644 Source/UnixUserland/sbrk.c delete mode 100644 Source/UnixUserland/stat.c delete mode 100644 Source/UnixUserland/times.c delete mode 100644 Source/UnixUserland/unlink.c delete mode 100644 Source/UnixUserland/wait.c delete mode 100644 Source/UnixUserland/write.c (limited to 'Source') diff --git a/Source/Applications/Demos/Makefile b/Source/Applications/Demos/Makefile index 82489ba..e66acce 100644 --- a/Source/Applications/Demos/Makefile +++ b/Source/Applications/Demos/Makefile @@ -7,7 +7,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/App.ld -L ../../Library +LDFLAGS = -T ../../Library/Link.ld -L ../../Library Applications = asmdemo cxxdemo GOL diff --git a/Source/Applications/PaperWork/Makefile b/Source/Applications/PaperWork/Makefile index c39fc83..fe8d564 100644 --- a/Source/Applications/PaperWork/Makefile +++ b/Source/Applications/PaperWork/Makefile @@ -4,7 +4,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/App.ld -L ../../Library +LDFLAGS = -T ../../Library/Link.ld -L ../../Library Objects = main.o OutFile = PaperWork diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile index a5587d8..bf81af6 100644 --- a/Source/Applications/Shell/Makefile +++ b/Source/Applications/Shell/Makefile @@ -4,7 +4,7 @@ CXX = g++ CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND LD = ld -LDFLAGS = -T ../../Library/App.ld -L ../../Library +LDFLAGS = -T ../../Library/Link.ld -L ../../Library Objects = main.o \ Shell.ns.o \ diff --git a/Source/Library/App.ld b/Source/Library/App.ld deleted file mode 100644 index 68591fd..0000000 --- a/Source/Library/App.ld +++ /dev/null @@ -1,33 +0,0 @@ -ENTRY (start) -INPUT (Melon.o) - -SECTIONS{ - . = 0x10000000; - - .text : { - *(.text) - } - - .rodata ALIGN (0x1000) :{ - *(.rodata) - } - - .data ALIGN (0x1000) : { - start_ctors = .; - *(.ctor*) - end_ctors = .; - start_dtors = .; - *(.dtor*) - end_dtors = .; - *(.data) - } - - .bss : { - sbss = .; - *(COMMON) - *(.bss) - ebss = .; - } - - end = .; _end = .; __end = .; -} diff --git a/Source/Library/Link.ld b/Source/Library/Link.ld new file mode 100644 index 0000000..68591fd --- /dev/null +++ b/Source/Library/Link.ld @@ -0,0 +1,33 @@ +ENTRY (start) +INPUT (Melon.o) + +SECTIONS{ + . = 0x10000000; + + .text : { + *(.text) + } + + .rodata ALIGN (0x1000) :{ + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } + + end = .; _end = .; __end = .; +} diff --git a/Source/UnixUserland/App.ld b/Source/UnixUserland/App.ld deleted file mode 100644 index 03ac84f..0000000 --- a/Source/UnixUserland/App.ld +++ /dev/null @@ -1,33 +0,0 @@ -ENTRY (_start) -INPUT (MelonUnix.o) - -SECTIONS{ - . = 0x10000000; - - .text : { - *(.text) - } - - .rodata ALIGN (0x1000) :{ - *(.rodata) - } - - .data ALIGN (0x1000) : { - start_ctors = .; - *(.ctor*) - end_ctors = .; - start_dtors = .; - *(.dtor*) - end_dtors = .; - *(.data) - } - - .bss : { - sbss = .; - *(COMMON) - *(.bss) - ebss = .; - } - - end = .; _end = .; __end = .; -} diff --git a/Source/UnixUserland/Makefile b/Source/UnixUserland/Makefile deleted file mode 100644 index 44fa29f..0000000 --- a/Source/UnixUserland/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -.PHONY: clean, mrproper - -CC = gcc -CCFLAGS = -nostdlib -nostartfiles -nodefaultlibs -fno-builtin -fno-stack-protector -Wall -Wextra -Werror -I../../Ports/newlib-1.15.0/newlib/libc/include - -LD = ld -LDFLAGS = -r - -OutFile = MelonUnix.o -Objects = _exit.o \ - _start.o \ - close.o \ - environ.o \ - execve.o \ - fork.o \ - fstat.o \ - getpid.o \ - isatty.o \ - kill.o \ - link.o \ - lseek.o \ - open.o \ - read.o \ - sbrk.o \ - stat.o \ - times.o \ - unlink.o \ - wait.o \ - write.o - -all: $(OutFile) - echo "* Done with $(OutFile)." - -rebuild: mrproper all - -$(OutFile): $(Objects) - echo "* Linking executable : $(OutFile)..." - $(LD) $(LDFLAGS) -o $(OutFile) $^ - -%.o: %.c - echo "* Compiling $<..." - $(CC) -c $< -o $@ $(CFLAGS) - -clean: - echo "* Removing object files..." - rm -rf $(Objects) - -mrproper: clean - echo "* Removing executable: $(OutFile)" - rm -rf $(OutFile) diff --git a/Source/UnixUserland/_exit.c b/Source/UnixUserland/_exit.c deleted file mode 100644 index 8753f0c..0000000 --- a/Source/UnixUserland/_exit.c +++ /dev/null @@ -1,2 +0,0 @@ -void _exit(int errcode) { -} diff --git a/Source/UnixUserland/_start.c b/Source/UnixUserland/_start.c deleted file mode 100644 index 00dc77e..0000000 --- a/Source/UnixUserland/_start.c +++ /dev/null @@ -1,7 +0,0 @@ -int main(); - -void _start() { - main(); - asm volatile("int $66;"); - while(1); -} diff --git a/Source/UnixUserland/close.c b/Source/UnixUserland/close.c deleted file mode 100644 index d1e0a16..0000000 --- a/Source/UnixUserland/close.c +++ /dev/null @@ -1,3 +0,0 @@ -int close(int file) { - return -1; -} diff --git a/Source/UnixUserland/environ.c b/Source/UnixUserland/environ.c deleted file mode 100644 index 7a59da1..0000000 --- a/Source/UnixUserland/environ.c +++ /dev/null @@ -1,2 +0,0 @@ -char *_env[1] = { 0 }; -char **environ = _env; diff --git a/Source/UnixUserland/execve.c b/Source/UnixUserland/execve.c deleted file mode 100644 index b066745..0000000 --- a/Source/UnixUserland/execve.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int execve(char *name, char **argv, char **env) { - errno = ENOMEM; - return -1; -} diff --git a/Source/UnixUserland/fork.c b/Source/UnixUserland/fork.c deleted file mode 100644 index 012bc17..0000000 --- a/Source/UnixUserland/fork.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int fork() { - errno = EAGAIN; - return -1; -} diff --git a/Source/UnixUserland/fstat.c b/Source/UnixUserland/fstat.c deleted file mode 100644 index 78d32f2..0000000 --- a/Source/UnixUserland/fstat.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int fstat(int file, struct stat *st) { - st->st_mode = S_IFCHR; - return 0; -} diff --git a/Source/UnixUserland/getpid.c b/Source/UnixUserland/getpid.c deleted file mode 100644 index c5e6884..0000000 --- a/Source/UnixUserland/getpid.c +++ /dev/null @@ -1,3 +0,0 @@ -int getpid() { - return 1; -} diff --git a/Source/UnixUserland/isatty.c b/Source/UnixUserland/isatty.c deleted file mode 100644 index 8a0d1e7..0000000 --- a/Source/UnixUserland/isatty.c +++ /dev/null @@ -1,3 +0,0 @@ -int isatty(int file) { - return 1; -} diff --git a/Source/UnixUserland/kill.c b/Source/UnixUserland/kill.c deleted file mode 100644 index c1f438b..0000000 --- a/Source/UnixUserland/kill.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int kill(int pid, int sig) { - errno = EINVAL; - return -1; -} diff --git a/Source/UnixUserland/link.c b/Source/UnixUserland/link.c deleted file mode 100644 index 17c08dd..0000000 --- a/Source/UnixUserland/link.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int link(char *old, char *new) { - errno = EMLINK; - return -1; -} diff --git a/Source/UnixUserland/lseek.c b/Source/UnixUserland/lseek.c deleted file mode 100644 index d3d24d8..0000000 --- a/Source/UnixUserland/lseek.c +++ /dev/null @@ -1,3 +0,0 @@ -int lseek(int file, int ptr, int dir) { - return 0; -} diff --git a/Source/UnixUserland/open.c b/Source/UnixUserland/open.c deleted file mode 100644 index eb9bed7..0000000 --- a/Source/UnixUserland/open.c +++ /dev/null @@ -1,3 +0,0 @@ -int open(const char* name, int flags, int mode) { - return -1; -} diff --git a/Source/UnixUserland/read.c b/Source/UnixUserland/read.c deleted file mode 100644 index 303c413..0000000 --- a/Source/UnixUserland/read.c +++ /dev/null @@ -1,3 +0,0 @@ -int read(int file, char *ptr, int len) { - return 0; -} diff --git a/Source/UnixUserland/sbrk.c b/Source/UnixUserland/sbrk.c deleted file mode 100644 index 26df466..0000000 --- a/Source/UnixUserland/sbrk.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -caddr_t sbrk(int incr) { - extern char end; - static char *heap_end; - char *prev_heap_end; - - if (heap_end == 0) { - heap_end = &end; - } - prev_heap_end = heap_end; - - heap_end += incr; - return (caddr_t) prev_heap_end; - -} diff --git a/Source/UnixUserland/stat.c b/Source/UnixUserland/stat.c deleted file mode 100644 index 1dada06..0000000 --- a/Source/UnixUserland/stat.c +++ /dev/null @@ -1,2 +0,0 @@ -#include - diff --git a/Source/UnixUserland/times.c b/Source/UnixUserland/times.c deleted file mode 100644 index 39ebf29..0000000 --- a/Source/UnixUserland/times.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/Source/UnixUserland/unlink.c b/Source/UnixUserland/unlink.c deleted file mode 100644 index 112ca54..0000000 --- a/Source/UnixUserland/unlink.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int unlink(char *name) { - errno = ENOENT; - return -1; -} diff --git a/Source/UnixUserland/wait.c b/Source/UnixUserland/wait.c deleted file mode 100644 index 5073c77..0000000 --- a/Source/UnixUserland/wait.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#undef errno -extern int errno; - -int wait(int *status) { - errno = ECHILD; - return -1; -} diff --git a/Source/UnixUserland/write.c b/Source/UnixUserland/write.c deleted file mode 100644 index 3cd436b..0000000 --- a/Source/UnixUserland/write.c +++ /dev/null @@ -1,10 +0,0 @@ -int write(int file, char *ptr, int len) { - int i; - for (i = 0; i < len; i++) { - int t = ptr[i]; - asm volatile("mov $0xFFFFFF01, %%eax; \ - mov %0, %%ebx; \ - int $64;" : : "r"(t)); - } - return len; -} -- cgit v1.2.3 From b2e3fc19bdad4c4d5c650e9ca759883db54b2e41 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Fri, 18 Dec 2009 16:27:47 +0100 Subject: Revert "Revert "Nothing, really"" This reverts commit 260347c06637f15ea93c6ad99bce4420a28bae6b. --- Source/Library/Userland/Start.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp index 0c25491..f1d1771 100644 --- a/Source/Library/Userland/Start.cpp +++ b/Source/Library/Userland/Start.cpp @@ -13,13 +13,14 @@ VirtualTerminal invt(0), outvt(0); int main(const Vector& args); extern "C" void start() { + heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index + //Call static constructors u32int i = 0; for(u32int * call = &start_ctors; call < &end_ctors; call++) { ((void (*)(void))*call)(); } - heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index invt = VirtualTerminal::getIn(); outvt = VirtualTerminal::getOut(); if (!invt.valid()) threadFinishedSyscall(1); if (!outvt.valid()) threadFinishedSyscall(2); -- cgit v1.2.3 From 07f030f2a2147598236c5fd361a7caaba7d00b23 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sat, 19 Dec 2009 14:57:50 +0100 Subject: Minor changes --- Source/Kernel/Devices/Display/VESADisplay.class.cpp | 3 ++- Source/Kernel/FileSystems/FAT/FATFS.class.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'Source') diff --git a/Source/Kernel/Devices/Display/VESADisplay.class.cpp b/Source/Kernel/Devices/Display/VESADisplay.class.cpp index d4aee07..7c4adca 100644 --- a/Source/Kernel/Devices/Display/VESADisplay.class.cpp +++ b/Source/Kernel/Devices/Display/VESADisplay.class.cpp @@ -208,7 +208,7 @@ void VESADisplay::putPix(u16int x, u16int y, u32int c) { u32int VESADisplay::getPix(u16int x, u16int y) { if (x >= m_currMode.Xres or y >= m_currMode.Yres) return 0; - u32int ret; + u32int ret = 0; union { u8int* c; u16int* w; @@ -258,6 +258,7 @@ void VESADisplay::drawChar(u16int line, u16int col, WChar c, u8int color) { p[2] = (bgcolor); p += 3; } + p -= (9 * 3); } p += m_currMode.pitch; } diff --git a/Source/Kernel/FileSystems/FAT/FATFS.class.cpp b/Source/Kernel/FileSystems/FAT/FATFS.class.cpp index 4c20b3f..f1d01c5 100644 --- a/Source/Kernel/FileSystems/FAT/FATFS.class.cpp +++ b/Source/Kernel/FileSystems/FAT/FATFS.class.cpp @@ -70,7 +70,7 @@ u32int FATFS::nextCluster(u32int cluster) { u32int fat_sector = m_bs.reserved_sector_count + (fat_offset / m_part->blockSize()); u32int ent_offset = fat_offset % m_part->blockSize(); m_fatCache.readBlocks(fat_sector, 1, fat_table); - u16int tblval = *(u16int*)&fat_table[ent_offset]; + u16int tblval = *((u16int*)(fat_table + ent_offset)); if (cluster & 1) val = tblval >> 4; else val = tblval & 0x0FFF; if (val >= 0xFF7) val = 0; @@ -79,7 +79,7 @@ u32int FATFS::nextCluster(u32int cluster) { u32int fat_sector = m_bs.reserved_sector_count + (fat_offset / m_part->blockSize()); u32int ent_offset = fat_offset % m_part->blockSize(); m_fatCache.readBlocks(fat_sector, 1, fat_table); - u16int tblval = *(u16int*)&fat_table[ent_offset]; + u16int tblval = *(u16int*)(fat_table + ent_offset); val = tblval; if (tblval >= 0xFFF7) val = 0; } else if (m_fatType == 32) { @@ -87,8 +87,10 @@ u32int FATFS::nextCluster(u32int cluster) { u32int fat_sector = m_bs.reserved_sector_count + (fat_offset / m_part->blockSize()); u32int ent_offset = fat_offset % m_part->blockSize(); m_fatCache.readBlocks(fat_sector, 1, fat_table); - val = *(u32int*)&fat_table[ent_offset] & 0x0FFFFFFF; + val = *(u32int*)(fat_table + ent_offset) & 0x0FFFFFFF; if (val >= 0x0FFFFFF7) val = 0; + } else { + val = 0; } return val; } -- cgit v1.2.3