Prepare script should be done.

This commit is contained in:
Kevin Lange 2012-05-16 22:21:37 -04:00
parent 37bd5caf53
commit af8e7d9e00
12 changed files with 3501 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
AM_CCASFLAGS = $(INCLUDES)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = syscalls.c
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS)
all: crt0.o
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host

View File

@ -0,0 +1,412 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(srcdir)/../../../../mkinstalldirs
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/../../../../mkinstalldirs
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = cru
lib_a_AR = $(AR) $(ARFLAGS)
lib_a_LIBADD =
am_lib_a_OBJECTS = lib_a-syscalls.$(OBJEXT)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp =
am__depfiles_maybe =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(lib_a_SOURCES)
ETAGS = etags
CTAGS = ctags
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCAS = @CCAS@
CCASFLAGS = @CCASFLAGS@
CCDEPMODE = @CCDEPMODE@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
READELF = @READELF@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
aext = @aext@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
libm_machine_dir = @libm_machine_dir@
localedir = @localedir@
localstatedir = @localstatedir@
lpfx = @lpfx@
machine_dir = @machine_dir@
mandir = @mandir@
mkdir_p = @mkdir_p@
newlib_basedir = @newlib_basedir@
oext = @oext@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sys_dir = @sys_dir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
AM_CCASFLAGS = $(INCLUDES)
noinst_LIBRARIES = lib.a
lib_a_SOURCES = syscalls.c
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
lib_a_CFLAGS = $(AM_CFLAGS)
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
all: all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --cygnus'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --cygnus \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --cygnus Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
-rm -f lib.a
$(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
$(RANLIB) lib.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(COMPILE) -c $<
.c.obj:
$(COMPILE) -c `$(CYGPATH_W) '$<'`
lib_a-syscalls.o: syscalls.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-syscalls.o `test -f 'syscalls.c' || echo '$(srcdir)/'`syscalls.c
lib_a-syscalls.obj: syscalls.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-syscalls.obj `if test -f 'syscalls.c'; then $(CYGPATH_W) 'syscalls.c'; else $(CYGPATH_W) '$(srcdir)/syscalls.c'; fi`
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
check-am:
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-generic clean-noinstLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-tags dvi dvi-am \
html html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am
all: crt0.o
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,7 @@
AC_PREREQ(2.59)
AC_INIT([newlib], [NEWLIB_VERSION])
AC_CONFIG_SRCDIR([crt0.s])
AC_CONFIG_AUX_DIR(../../../..)
NEWLIB_CONFIGURE(../../..)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@ -0,0 +1,19 @@
; ToAruOS User CRT0
BITS 32
global _start
_start: ; Global entry point
pop eax ; Our stack is slightly off
extern main ;
call main ; call C main function
mov ebx, eax ; return value from main
mov eax, 0x0 ; sys_exit
int 0x7F ; syscall
_wait: ; wait until we've been deschuled
hlt
jmp _wait
; vim:syntax=nasm
; vim:noexpandtab
; vim:tabstop=4
; vim:shiftwidth=4

View File

@ -0,0 +1,21 @@
; ToAruOS User CRT0
BITS 32
global _start
_start: ; Global entry point
pop eax ; Our stack is slightly off
extern __do_global_ctors
call __do_global_ctors
extern main ;
call main ; call C main function
mov ebx, eax ; return value from main
mov eax, 0x0 ; sys_exit
int 0x7F ; syscall
_wait: ; wait until we've been deschuled
hlt
jmp _wait
; vim:syntax=nasm
; vim:noexpandtab
; vim:tabstop=4
; vim:shiftwidth=4

Binary file not shown.

View File

@ -0,0 +1,58 @@
/* libc/sys/toaru/sys/dirent.h - Directory entry as returned by readdir */
/* Written 2000 by Werner Almesberger */
/* Hacked, and broken by Kevin Lange */
#ifndef _SYS_DIRENT_H
#define _SYS_DIRENT_H
#include <sys/types.h>
#include <bits/dirent.h>
#define _LIBC 1
#define NOT_IN_libc 1
#include <sys/lock.h>
#undef _LIBC
#define HAVE_NO_D_NAMLEN /* no struct dirent->d_namlen */
#define MAXNAMLEN 255 /* sizeof(struct dirent.d_name)-1 */
typedef struct {
int dd_fd; /* directory file */
int dd_loc; /* position in buffer */
int dd_seek;
char *dd_buf; /* buffer */
int dd_len; /* buffer length */
int dd_size; /* amount of data in buffer */
_LOCK_RECURSIVE_T dd_lock;
} DIR;
#define __dirfd(dir) (dir)->dd_fd
/* --- redundant --- */
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
void rewinddir(DIR *);
int closedir(DIR *);
/* internal prototype */
void _seekdir(DIR *dir, long offset);
DIR *_opendir(const char *);
#ifndef _POSIX_SOURCE
long telldir (DIR *);
void seekdir (DIR *, off_t loc);
int scandir (const char *__dir,
struct dirent ***__namelist,
int (*select) (const struct dirent *),
int (*compar) (const struct dirent **, const struct dirent **));
int alphasort (const struct dirent **__a, const struct dirent **__b);
#endif /* _POSIX_SOURCE */
#endif

View File

@ -0,0 +1,361 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab
*
* Copyright 2012 Kevin Lange
*
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/times.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <stdio.h>
#include <utime.h>
#include <_ansi.h>
#include <errno.h>
#define DECL_SYSCALL0(fn) int syscall_##fn()
#define DECL_SYSCALL1(fn,p1) int syscall_##fn(p1)
#define DECL_SYSCALL2(fn,p1,p2) int syscall_##fn(p1,p2)
#define DECL_SYSCALL3(fn,p1,p2,p3) int syscall_##fn(p1,p2,p3)
#define DECL_SYSCALL4(fn,p1,p2,p3,p4) int syscall_##fn(p1,p2,p3,p4)
#define DECL_SYSCALL5(fn,p1,p2,p3,p4,p5) int syscall_##fn(p1,p2,p3,p4,p5)
#define DEFN_SYSCALL0(fn, num) \
int syscall_##fn() { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num)); \
return a; \
}
#define DEFN_SYSCALL1(fn, num, P1) \
int syscall_##fn(P1 p1) { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1)); \
return a; \
}
#define DEFN_SYSCALL2(fn, num, P1, P2) \
int syscall_##fn(P1 p1, P2 p2) { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2)); \
return a; \
}
#define DEFN_SYSCALL3(fn, num, P1, P2, P3) \
int syscall_##fn(P1 p1, P2 p2, P3 p3) { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3)); \
return a; \
}
#define DEFN_SYSCALL4(fn, num, P1, P2, P3, P4) \
int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4) { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3), "S" ((int)p4)); \
return a; \
}
#define DEFN_SYSCALL5(fn, num, P1, P2, P3, P4, P5) \
int syscall_##fn(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { \
int a; __asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (num), "b" ((int)p1), "c" ((int)p2), "d" ((int)p3), "S" ((int)p4), "D" ((int)p5)); \
return a; \
}
/* Core */
DECL_SYSCALL1(exit, int);
DECL_SYSCALL1(print, const char *);
/* Files */
DECL_SYSCALL1(close, int);
DECL_SYSCALL3(open, const char *, int, int);
DECL_SYSCALL3(read, int, char *, int);
DECL_SYSCALL3(write, int, char *, int);
DECL_SYSCALL2(fstat, int, void *);
DECL_SYSCALL1(isatty, int);
DECL_SYSCALL2(link, char *, char *);
DECL_SYSCALL1(unlink, char *);
DECL_SYSCALL3(lseek, int, int, int);
DECL_SYSCALL2(stat, const char *, void *);
/* Process Control */
DECL_SYSCALL0(getpid);
DECL_SYSCALL3(execve, char *, char **, char **);
DECL_SYSCALL0(fork);
DECL_SYSCALL2(kill, int, int);
DECL_SYSCALL1(wait, int *);
/* Memory management */
DECL_SYSCALL1(sbrk, int);
DECL_SYSCALL2(gettimeofday, void *, void *);
DECL_SYSCALL2(getcwd, char *, size_t);
DECL_SYSCALL1(chdir, char *);
DECL_SYSCALL2(mkdir, char *, unsigned int);
DECL_SYSCALL0(getuid);
DEFN_SYSCALL1(exit, 0, int)
DEFN_SYSCALL1(print, 1, const char *)
DEFN_SYSCALL3(open, 2, const char *, int, int)
DEFN_SYSCALL3(read, 3, int, char *, int)
DEFN_SYSCALL3(write, 4, int, char *, int)
DEFN_SYSCALL1(close, 5, int)
DEFN_SYSCALL2(gettimeofday, 6, void *, void *)
DEFN_SYSCALL3(execve, 7, char *, char **, char **)
DEFN_SYSCALL0(fork, 8)
DEFN_SYSCALL0(getpid, 9)
DEFN_SYSCALL1(sbrk, 10, int)
DEFN_SYSCALL3(lseek, 14, int, int, int);
DEFN_SYSCALL2(fstat, 15, int, void *);
DEFN_SYSCALL1(wait, 17, int *);
DEFN_SYSCALL0(mkpipe, 21);
DEFN_SYSCALL2(dup2, 22, int, int);
DEFN_SYSCALL0(getuid, 23);
DEFN_SYSCALL2(getcwd, 29, char *, size_t);
DEFN_SYSCALL1(chdir, 28, char *);
DEFN_SYSCALL2(mkdir, 34, char *, unsigned int);
// --- Process Control ---
int _exit(int val){
return syscall_exit(val);
}
int execve(char *name, char **argv, char **env) {
return syscall_execve(name,argv,env);
}
/*
* getpid -- only one process, so just return 1.
*/
int getpid() {
return syscall_getpid();
}
/* Fork. Duh. */
int fork(void) {
return syscall_fork();
}
/*
* kill -- go out via exit...
*/
int kill(int pid, int sig) {
if(pid == getpid())
_exit(sig);
errno = EINVAL;
return -1;
}
int wait(int *status) {
fprintf(stderr, "[debug] pid %d: wait(**)\n", getpid());
errno = ECHILD;
return -1;
}
int waitpid(int pid, int *status, int options) {
/* XXX: status, options? */
return syscall_wait((int *)pid);
}
// --- I/O ---
/*
* isatty -- returns 1 if connected to a terminal device,
* returns 0 if not. Since we're hooked up to a
* serial port, we'll say yes and return a 1.
*/
int isatty(int fd) {
fprintf(stderr, "[debug] pid %d: isatty(%d);\n", getpid(), fd);
return (fd < 3);
}
int close(int file) {
return syscall_close(file);
}
int link(char *old, char *new) {
fprintf(stderr, "[debug] pid %d: link(%s, %s);\n", getpid(), old, new);
errno = EMLINK;
return -1;
}
int lseek(int file, int ptr, int dir) {
return syscall_lseek(file,ptr,dir);
}
int open(const char *name, int flags, ...) {
return syscall_open(name,flags, 0);
}
int read(int file, char *ptr, int len) {
return syscall_read(file,ptr,len);
}
int creat(const char *path, mode_t mode) {
return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);
}
int fstat(int file, struct stat *st) {
syscall_fstat(file, st);
return 0;
}
int stat(const char *file, struct stat *st){
int i = open(file, 0);
int ret = fstat(i, st);
close(i);
return ret;
}
int unlink(char *name) {
fprintf(stderr, "[debug] pid %d unlink(%s);\n", getpid(), name);
errno = ENOENT;
return -1;
}
int write(int file, char *ptr, int len) {
return syscall_write(file,ptr,len);
}
// --- Memory ---
/* _end is set in the linker command file */
extern caddr_t _end;
#if 0
#define PAGE_SIZE 4096UL
#define PAGE_MASK 0xFFFFF000UL
#define HEAP_ADDR (((unsigned long long)&_end + PAGE_SIZE) & PAGE_MASK)
#endif
/*
* sbrk: request a larger heap
* [the kernel will give this to us]
*/
caddr_t sbrk(int nbytes){
return (caddr_t)syscall_sbrk(nbytes);
}
// --- Other ---
int gettimeofday(struct timeval *p, void *z){
return syscall_gettimeofday(p,z);
}
int pipe(int fildes[2]) {
int fd = syscall_mkpipe();
fildes[0] = fd;
fildes[1] = fd;
return 0;
}
int fcntl(int fd, int cmd, ...) {
if (cmd == F_GETFD || cmd == F_SETFD) {
return 0;
}
fprintf(stderr, "[user/debug] Unsupported operation [fcntl]\n");
/* Not supported */
return -1;
}
mode_t umask(mode_t mask) {
fprintf(stderr, "[user/debug] Unsupported operation [umask]\n");
/* Not supported */
return 0;
}
char *getwd(char *buf) {
return syscall_getcwd(buf, 256);
}
int chmod(const char *path, mode_t mode) {
fprintf(stderr, "[user/debug] Unsupported operation [chmod]\n");
/* Not supported */
return -1;
}
int access(const char *pathname, int mode) {
fprintf(stderr, "[user/debug] Unsupported operation [access]\n");
/* Not supported */
return -1;
}
int lstat(const char *path, struct stat *buf) {
return stat(path, buf);
}
long pathconf(char *path, int name) {
fprintf(stderr, "[user/debug] Unsupported operation [pathconf]\n");
/* Not supported */
return -1;
}
int utime(const char *filename, const struct utimbuf *times) {
fprintf(stderr, "[user/debug] Unsupported operation [utime]\n");
return -1;
}
int chown(const char *path, uid_t owner, gid_t group) {
fprintf(stderr, "[user/debug] Unsupported operation [chown]\n");
return -1;
}
int rmdir(const char *pathname) {
fprintf(stderr, "[user/debug] Unsupported operation [rmdir]\n");
return -1;
}
int mkdir(const char *pathname, mode_t mode) {
return syscall_mkdir(pathname, mode);
}
int chdir(const char *path) {
return syscall_chdir(path);
}
char *ttyname(int fd) {
errno = ENOTTY;
return NULL;
}
unsigned int sleep(unsigned int seconds) {
/* lol go fuck yourself */
return 0;
}
char _username[256];
char *getlogin(void) {
#define LINE_LEN 4096
FILE * passwd = fopen("/etc/passwd", "r");
char line[LINE_LEN];
int uid = syscall_getuid();
while (fgets(line, LINE_LEN, passwd) != NULL) {
line[strlen(line)-1] = '\0';
char *p, *tokens[10], *last;
int i = 0;
for ((p = strtok_r(line, ":", &last)); p;
(p = strtok_r(NULL, ":", &last)), i++) {
if (i < 511) tokens[i] = p;
}
tokens[i] = NULL;
if (atoi(tokens[2]) == uid) {
memcpy(_username, tokens[0], strlen(tokens[0])+1);
break;
}
}
fclose(passwd);
return &_username;
}

View File

@ -29,9 +29,13 @@ function patc () {
$END "patch" "$1"
}
function deleteUnused_gcc_4_6_0 () {
function deleteUnusedGCC () {
# These directories are not used and are primarily for support of unecessarily libraries like Java and the testsuite.
rm -r gcc-4.6.0/boehm-gc gcc-4.6.0/gcc/ada gcc-4.6.0/gcc/go gcc-4.6.0/gcc/java gcc-4.6.0/gcc/objc gcc-4.6.0/gcc/objcp gcc-4.6.0/gcc/testsuite gcc-4.6.0/gnattools gcc-4.6.0/libada gcc-4.6.0/libffi gcc-4.6.0/libgo gcc-4.6.0/libjava gcc-4.6.0/libobjc
rm -r $1/boehm-gc $1/gcc/ada $1/gcc/go $1/gcc/java $1/gcc/objc $1/gcc/objcp $1/gcc/testsuite $1/gnattools $1/libada $1/libffi $1/libgo $1/libjava $1/libobjc
}
function installNewlibStuff () {
cp -r ../patches/newlib/toaru $1/newlib/libc/sys/toaru
}
pushd "$DIR" > /dev/null
@ -46,6 +50,7 @@ pushd "$DIR" > /dev/null
grab "mpfr" "http://www.mpfr.org/mpfr-3.0.1/mpfr-3.0.1.tar.gz"
grab "gmp" "ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.gz"
grab "binutils" "http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.gz"
grab "newlib" "ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz"
$INFO "wget" "Pulled source packages."
$INFO "tar" "Decompressing..."
deco "gcc" "gcc-4.6.0.tar.gz"
@ -53,6 +58,7 @@ pushd "$DIR" > /dev/null
deco "mpfr" "mpfr-3.0.1.tar.gz"
deco "gmp" "gmp-5.0.1.tar.gz"
deco "binutils" "binutils-2.22.tar.gz"
deco "newlib" "newlib-1.19.0.tar.gz"
$INFO "tar" "Decompressed source packages."
$INFO "patch" "Patching..."
patc "gcc" "gcc-4.6.0"
@ -60,7 +66,11 @@ pushd "$DIR" > /dev/null
patc "mpfr" "mpfr-3.0.1"
patc "gmp" "gmp-5.0.1"
patc "binutils" "binutils-2.22"
patc "newlib" "newlib-1.19.0"
$INFO "patch" "Patched third-party software."
$INFO "--" "Running additional bits..."
deleteUnusedGCC "gcc-4.6.0"
installNewlibStuff "newlib-1.19.0"
popd > /dev/null
popd > /dev/null