mirror of
https://github.com/xomboverlord/buildtools.git
synced 2026-01-12 19:03:15 +01:00
merge with gcc 4.5.0 support and binutils per-version patches from xomb branch
This commit is contained in:
4
README
4
README
@@ -18,6 +18,10 @@ FEATURES:
|
||||
|
||||
1. Will compile a complete C and C++ toolchain.
|
||||
|
||||
PREREQUISITES:
|
||||
|
||||
The gcc tools require m4, autoconf, automake and texinfo (or another source of makeinfo) to successfully compile.
|
||||
|
||||
BUGS:
|
||||
|
||||
1. Does not compile fortran target.
|
||||
|
||||
57
binutils.2.19.patch
Normal file
57
binutils.2.19.patch
Normal file
@@ -0,0 +1,57 @@
|
||||
--- ../../binutils-2.20/config.sub 2009-08-17 00:10:29.000000000 -0400
|
||||
+++ config.sub 2010-04-03 18:01:47.000000000 -0400
|
||||
@@ -1275,6 +1275,7 @@ case $os in
|
||||
| -kopensolaris* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* \
|
||||
+ | -{{OSNAME}}* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
--- ../../binutils-2.20/ld/configure.tgt 2009-08-06 13:38:03.000000000 -0400
|
||||
+++ ld/configure.tgt 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -201,6 +201,8 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386
|
||||
targ64_extra_emuls="elf_x86_64 elf_l1om"
|
||||
targ64_extra_libpath=elf_x86_64
|
||||
tdir_i386linux=${targ_alias}aout ;;
|
||||
+x86_64-*-{{OSNAME}}*) targ_emul={{OSNAME}}_x86_64 ;;
|
||||
+
|
||||
x86_64-*-linux-*) targ_emul=elf_x86_64
|
||||
targ_extra_emuls="elf_i386 i386linux elf_l1om"
|
||||
targ_extra_libpath=elf_i386
|
||||
--- ../../binutils-2.20/ld/Makefile.in 2009-09-07 08:10:24.000000000 -0400
|
||||
+++ ld/Makefile.in 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -2451,6 +2451,9 @@ eelf64ltsmip.c: $(srcdir)/emulparams/elf
|
||||
eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)"
|
||||
+e{{OSNAME}}_x86_64.c: $(srcdir)/emulparams/{{OSNAME}}_x86_64.sh \
|
||||
+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
+ ${GENSCRIPTS} {{OSNAME}}_x86_64 "$(tdir_{{OSNAME}}_x86_64)"
|
||||
eelf_x86_64.c: $(srcdir)/emulparams/elf_x86_64.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_x86_64 "$(tdir_elf_x86_64)"
|
||||
--- ../../binutils-2.20/bfd/config.bfd 2009-08-06 13:38:00.000000000 -0400
|
||||
+++ bfd/config.bfd 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -615,6 +615,11 @@ case "${targ}" in
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-{{OSNAME}}*)
|
||||
+ targ_defvec=bfd_elf64_x86_64_vec
|
||||
+ targ_selvecs=bfd_elf32_i386_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
x86_64-*-elf*)
|
||||
targ_defvec=bfd_elf64_x86_64_vec
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec i386coff_vec"
|
||||
|
||||
--- ../../../binutils-2.20/gas/configure.tgt 2009-09-09 04:13:28.000000000 -0400
|
||||
+++ gas/configure.tgt 2010-04-03 19:13:26.000000000 -0400
|
||||
@@ -236,5 +236,6 @@ case ${generic_target} in
|
||||
i386-*-chaos) fmt=elf ;;
|
||||
i386-*-rdos*) fmt=elf ;;
|
||||
+ i386-*-{{OSNAME}}*) fmt=elf ;;
|
||||
|
||||
i860-*-*) fmt=elf endian=little ;;
|
||||
|
||||
58
binutils.2.20.patch
Normal file
58
binutils.2.20.patch
Normal file
@@ -0,0 +1,58 @@
|
||||
--- ../../binutils-2.20/config.sub 2009-08-17 00:10:29.000000000 -0400
|
||||
+++ config.sub 2010-04-03 18:01:47.000000000 -0400
|
||||
@@ -1275,6 +1275,7 @@ case $os in
|
||||
| -kopensolaris* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* | -aros* \
|
||||
+ | -{{OSNAME}}* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
--- ../../binutils-2.20/ld/configure.tgt 2009-08-06 13:38:03.000000000 -0400
|
||||
+++ ld/configure.tgt 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -201,6 +201,8 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386
|
||||
targ64_extra_emuls="elf_x86_64 elf_l1om"
|
||||
targ64_extra_libpath=elf_x86_64
|
||||
tdir_i386linux=${targ_alias}aout ;;
|
||||
+x86_64-*-{{OSNAME}}*) targ_emul={{OSNAME}}_x86_64 ;;
|
||||
+
|
||||
x86_64-*-linux-*) targ_emul=elf_x86_64
|
||||
targ_extra_emuls="elf_i386 i386linux elf_l1om"
|
||||
targ_extra_libpath=elf_i386
|
||||
--- ../../binutils-2.20/ld/Makefile.in 2009-09-07 08:10:24.000000000 -0400
|
||||
+++ ld/Makefile.in 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -2451,6 +2451,9 @@ eelf64ltsmip.c: $(srcdir)/emulparams/elf
|
||||
eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)"
|
||||
+e{{OSNAME}}_x86_64.c: $(srcdir)/emulparams/{{OSNAME}}_x86_64.sh \
|
||||
+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
+ ${GENSCRIPTS} {{OSNAME}}_x86_64 "$(tdir_{{OSNAME}}_x86_64)"
|
||||
eelf_x86_64.c: $(srcdir)/emulparams/elf_x86_64.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_x86_64 "$(tdir_elf_x86_64)"
|
||||
--- ../../binutils-2.20/bfd/config.bfd 2009-08-06 13:38:00.000000000 -0400
|
||||
+++ bfd/config.bfd 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -615,6 +615,11 @@ case "${targ}" in
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-{{OSNAME}}*)
|
||||
+ targ_defvec=bfd_elf64_x86_64_vec
|
||||
+ targ_selvecs=bfd_elf32_i386_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
x86_64-*-elf*)
|
||||
targ_defvec=bfd_elf64_x86_64_vec
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec i386coff_vec"
|
||||
|
||||
--- ../../../binutils-2.20/gas/configure.tgt 2009-09-09 04:13:28.000000000 -0400
|
||||
+++ gas/configure.tgt 2010-04-03 19:13:26.000000000 -0400
|
||||
@@ -236,6 +236,7 @@ case ${generic_target} in
|
||||
i386-*-chaos) fmt=elf ;;
|
||||
i386-*-rdos*) fmt=elf ;;
|
||||
i386-*-darwin*) fmt=macho ;;
|
||||
+ i386-*-{{OSNAME}}*) fmt=elf ;;
|
||||
|
||||
i860-*-*) fmt=elf endian=little ;;
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
--- ../../binutils-2.20/config.sub 2009-08-17 00:10:29.000000000 -0400
|
||||
+++ config.sub 2010-04-03 18:01:47.000000000 -0400
|
||||
@@ -1275,6 +1275,7 @@ case $os in
|
||||
| -kopensolaris* \
|
||||
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
|
||||
| -aos* | -aros* \
|
||||
+ | -{{OSNAME}}* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
|
||||
--- ../../binutils-2.20/ld/configure.tgt 2009-08-06 13:38:03.000000000 -0400
|
||||
+++ ld/configure.tgt 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -201,6 +201,8 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386
|
||||
targ64_extra_emuls="elf_x86_64 elf_l1om"
|
||||
targ64_extra_libpath=elf_x86_64
|
||||
tdir_i386linux=${targ_alias}aout ;;
|
||||
+x86_64-*-{{OSNAME}}*) targ_emul={{OSNAME}}_x86_64 ;;
|
||||
+
|
||||
x86_64-*-linux-*) targ_emul=elf_x86_64
|
||||
targ_extra_emuls="elf_i386 i386linux elf_l1om"
|
||||
targ_extra_libpath=elf_i386
|
||||
--- ../../binutils-2.20/ld/Makefile.in 2009-09-07 08:10:24.000000000 -0400
|
||||
+++ ld/Makefile.in 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -2451,6 +2451,9 @@ eelf64ltsmip.c: $(srcdir)/emulparams/elf
|
||||
eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)"
|
||||
+e{{OSNAME}}_x86_64.c: $(srcdir)/emulparams/{{OSNAME}}_x86_64.sh \
|
||||
+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
+ ${GENSCRIPTS} {{OSNAME}}_x86_64 "$(tdir_{{OSNAME}}_x86_64)"
|
||||
eelf_x86_64.c: $(srcdir)/emulparams/elf_x86_64.sh \
|
||||
$(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
|
||||
${GENSCRIPTS} elf_x86_64 "$(tdir_elf_x86_64)"
|
||||
--- ../../binutils-2.20/bfd/config.bfd 2009-08-06 13:38:00.000000000 -0400
|
||||
+++ bfd/config.bfd 2010-04-03 18:01:16.000000000 -0400
|
||||
@@ -615,6 +615,11 @@ case "${targ}" in
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec"
|
||||
want64=true
|
||||
;;
|
||||
+ x86_64-*-{{OSNAME}}*)
|
||||
+ targ_defvec=bfd_elf64_x86_64_vec
|
||||
+ targ_selvecs=bfd_elf32_i386_vec
|
||||
+ want64=true
|
||||
+ ;;
|
||||
x86_64-*-elf*)
|
||||
targ_defvec=bfd_elf64_x86_64_vec
|
||||
targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec i386coff_vec"
|
||||
|
||||
--- ../../../binutils-2.20/gas/configure.tgt 2009-09-09 04:13:28.000000000 -0400
|
||||
+++ gas/configure.tgt 2010-04-03 19:13:26.000000000 -0400
|
||||
@@ -236,6 +236,7 @@ case ${generic_target} in
|
||||
i386-*-chaos) fmt=elf ;;
|
||||
i386-*-rdos*) fmt=elf ;;
|
||||
i386-*-darwin*) fmt=macho ;;
|
||||
+ i386-*-{{OSNAME}}*) fmt=elf ;;
|
||||
|
||||
i860-*-*) fmt=elf endian=little ;;
|
||||
|
||||
1
binutils.patch
Symbolic link
1
binutils.patch
Symbolic link
@@ -0,0 +1 @@
|
||||
binutils.2.20.patch
|
||||
37
build.sh
37
build.sh
@@ -1,10 +1,11 @@
|
||||
OSNAME=myos
|
||||
OSNAME=linux
|
||||
|
||||
BINUTILS_VER=2.20
|
||||
GCC_VER=4.4.3
|
||||
GCC_VER=4.5.0
|
||||
GMP_VER=5.0.1
|
||||
MPFR_VER=2.4.2
|
||||
NEWLIB_VER=1.18.0
|
||||
MPC_VER=0.8.1
|
||||
|
||||
export TARGET=x86_64-pc-${OSNAME}
|
||||
export PREFIX=`pwd`/local
|
||||
@@ -44,6 +45,10 @@ echo "FETCH MPFR"
|
||||
wget $WFLAGS http://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR_VER}.tar.gz
|
||||
tar -xf mpfr-${MPFR_VER}.tar.gz
|
||||
|
||||
echo "FETCH MPC"
|
||||
wget $WFLAGS http://www.multiprecision.org/mpc/download/mpc-${MPC_VER}.tar.gz
|
||||
tar -xf mpc-${MPC_VER}.tar.gz
|
||||
|
||||
echo "FETCH NEWLIB"
|
||||
wget $WFLAGS ftp://sources.redhat.com/pub/newlib/newlib-${NEWLIB_VER}.tar.gz
|
||||
tar -xf newlib-${NEWLIB_VER}.tar.gz
|
||||
@@ -62,6 +67,7 @@ echo "PATCH NEWLIB"
|
||||
patch -p0 -d newlib-${NEWLIB_VER} < ../newlib.patch || exit
|
||||
mkdir -p newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}
|
||||
cp -r ../newlib-files/* newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/.
|
||||
cp ../newlib-files/vanilla-syscalls.c newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/syscalls.c
|
||||
|
||||
echo "MAKE OBJECT DIRECTORIES"
|
||||
mkdir -p binutils-obj
|
||||
@@ -69,12 +75,13 @@ mkdir -p gcc-obj
|
||||
mkdir -p newlib-obj
|
||||
mkdir -p gmp-obj
|
||||
mkdir -p mpfr-obj
|
||||
mkdir -p mpc-obj
|
||||
|
||||
# Compile all packages
|
||||
|
||||
echo "COMPILE BINUTILS"
|
||||
cd binutils-obj
|
||||
../binutils-${BINUTILS_VER}/configure --target=$TARGET --prefix=$PREFIX || exit
|
||||
../binutils-${BINUTILS_VER}/configure --target=$TARGET --prefix=$PREFIX --disable-werror || exit
|
||||
make || exit
|
||||
make install || exit
|
||||
cd ..
|
||||
@@ -95,6 +102,15 @@ make check || exit
|
||||
make install || exit
|
||||
cd ..
|
||||
|
||||
echo "COMPILE MPC"
|
||||
cd mpc-obj
|
||||
../mpc-${MPC_VER}/configure --target=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-shared || exit
|
||||
make || exit
|
||||
make check || exit
|
||||
make install || exit
|
||||
cd ..
|
||||
|
||||
|
||||
echo "AUTOCONF GCC"
|
||||
cd gcc-${GCC_VER}/libstdc++-v3
|
||||
#autoconf || exit
|
||||
@@ -102,13 +118,13 @@ cd ../..
|
||||
|
||||
echo "COMPILE GCC"
|
||||
cd gcc-obj
|
||||
#../gcc-${GCC_VER}/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++ --disable-libssp --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-nls --with-newlib || exit
|
||||
../gcc-${GCC_VER}/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++,fortran --disable-libssp --with-gmp=$PREFIX --with-mpfr=$PREFIX --disable-nls --with-newlib || exit
|
||||
../gcc-${GCC_VER}/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++,fortran --disable-libssp --with-gmp=$PREFIX --with-mpfr=$PREFIX --with-mpc=$PREFIX --disable-nls --with-newlib || exit
|
||||
|
||||
make all-gcc || exit
|
||||
make install-gcc || exit
|
||||
cd ..
|
||||
|
||||
echo "AUTOCONF NEWLIB-XOMB"
|
||||
echo "AUTOCONF NEWLIB"
|
||||
cd newlib-${NEWLIB_VER}/newlib/libc/sys
|
||||
autoconf || exit
|
||||
cd ${OSNAME}
|
||||
@@ -133,3 +149,12 @@ make install-target-libstdc++-v3 || exit
|
||||
make || exit
|
||||
make install || exit
|
||||
cd ..
|
||||
|
||||
echo "PASS-2 COMPILE NEWLIB"
|
||||
cp ../newlib-files/syscalls.c newlib-${NEWLIB_VER}/newlib/libc/sys/${OSNAME}/syscalls.c
|
||||
|
||||
cd newlib-obj
|
||||
#../newlib-${NEWLIB_VER}/configure --target=$TARGET --prefix=$PREFIX --with-gmp=$PREFIX --with-mpfr=$PREFIX || exit
|
||||
make || exit
|
||||
make install || exit
|
||||
cd ..
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
extern int main(int argc, char **argv, char **environ);
|
||||
extern int main(); //int argc, char **argv, char **environ);
|
||||
|
||||
extern char __bss_start, _end; // BSS should be the last think before _end
|
||||
|
||||
|
||||
@@ -69,11 +69,23 @@ wait(int *status) {
|
||||
* returns 0 if not. Since we're hooked up to a
|
||||
* serial port, we'll say yes and return a 1.
|
||||
*/
|
||||
|
||||
|
||||
int gibOpen(const char* name, unsigned int nameLen, char readOnly);
|
||||
int gibRead(int fd, void* buf, unsigned int len);
|
||||
int gibWrite(int fd, void* buf, unsigned int len);
|
||||
unsigned long long initHeap();
|
||||
|
||||
|
||||
int
|
||||
isatty(fd)
|
||||
int fd;
|
||||
{
|
||||
return (1);
|
||||
if(fd < 3){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +128,12 @@ stat(const char* file, struct stat *st) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
link(char *old, char *new) {
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
unlink(char *name) {
|
||||
errno = ENOENT;
|
||||
@@ -123,21 +141,9 @@ unlink(char *name) {
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
write(int file, char *ptr, int len) {
|
||||
//XXX: write to stdout
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// --- Memory ---
|
||||
|
||||
/* _end is set in the linker command file */
|
||||
extern caddr_t _end;
|
||||
|
||||
#define PAGE_SIZE 4096ULL
|
||||
#define PAGE_MASK 0xFFFFFFFFFFFFF000ULL
|
||||
#define HEAP_ADDR (((unsigned long long)&_end + PAGE_SIZE) & PAGE_MASK)
|
||||
|
||||
/*
|
||||
* sbrk -- changes heap size size. Get nbytes more
|
||||
@@ -146,20 +152,25 @@ extern caddr_t _end;
|
||||
*/
|
||||
caddr_t
|
||||
sbrk(int nbytes){
|
||||
static caddr_t heap_ptr = NULL;
|
||||
static unsigned long long heap_ptr = 0;
|
||||
caddr_t base;
|
||||
|
||||
// TODO: REPLACE allocPage with a call to a page allocator
|
||||
int temp;
|
||||
|
||||
if(heap_ptr == NULL){
|
||||
heap_ptr = (caddr_t)HEAP_ADDR;
|
||||
if(heap_ptr == 0){
|
||||
heap_ptr = initHeap();
|
||||
}
|
||||
|
||||
base = heap_ptr;
|
||||
base = (caddr_t)heap_ptr;
|
||||
|
||||
if(((unsigned long long)heap_ptr & ~PAGE_MASK) != 0ULL){
|
||||
temp = (PAGE_SIZE - ((unsigned long long)heap_ptr & ~PAGE_MASK));
|
||||
if(nbytes < 0){
|
||||
heap_ptr -= nbytes;
|
||||
return base;
|
||||
}
|
||||
|
||||
if( (heap_ptr & ~PAGE_MASK) != 0ULL){
|
||||
temp = (PAGE_SIZE - (heap_ptr & ~PAGE_MASK));
|
||||
|
||||
if( nbytes < temp ){
|
||||
heap_ptr += nbytes;
|
||||
@@ -192,6 +203,9 @@ sbrk(int nbytes){
|
||||
|
||||
|
||||
// --- Other ---
|
||||
int gettimeofday(struct timeval *p, void *z){
|
||||
return -1;
|
||||
}
|
||||
|
||||
//int times(struct tms *buf) {
|
||||
//int gettimeofday(struct timeval *p, struct timezone *z){
|
||||
|
||||
210
newlib-files/vanilla-syscalls.c
Normal file
210
newlib-files/vanilla-syscalls.c
Normal file
@@ -0,0 +1,210 @@
|
||||
#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 <_ansi.h>
|
||||
#include <errno.h>
|
||||
|
||||
// --- Process Control ---
|
||||
|
||||
int
|
||||
_exit(int val){
|
||||
exit(val);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
execve(char *name, char **argv, char **env) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* getpid -- only one process, so just return 1.
|
||||
*/
|
||||
#define __MYPID 1
|
||||
int
|
||||
getpid()
|
||||
{
|
||||
return __MYPID;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fork(void) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* kill -- go out via exit...
|
||||
*/
|
||||
int
|
||||
kill(pid, sig)
|
||||
int pid;
|
||||
int sig;
|
||||
{
|
||||
if(pid == __MYPID)
|
||||
_exit(sig);
|
||||
|
||||
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
wait(int *status) {
|
||||
errno = ECHILD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// --- 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(fd)
|
||||
int fd;
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
close(int file) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
link(char *old, char *new) {
|
||||
errno = EMLINK;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
lseek(int file, int ptr, int dir) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
open(const char *name, int flags, ...) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
read(int file, char *ptr, int len) {
|
||||
// XXX: keyboard support
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
fstat(int file, struct stat *st) {
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
stat(const char *file, struct stat *st){
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
unlink(char *name) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
write(int file, char *ptr, int len) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// --- Memory ---
|
||||
|
||||
/* _end is set in the linker command file */
|
||||
extern caddr_t _end;
|
||||
|
||||
#define PAGE_SIZE 4096ULL
|
||||
#define PAGE_MASK 0xFFFFFFFFFFFFF000ULL
|
||||
#define HEAP_ADDR (((unsigned long long)&_end + PAGE_SIZE) & PAGE_MASK)
|
||||
|
||||
/*
|
||||
* sbrk -- changes heap size size. Get nbytes more
|
||||
* RAM. We just increment a pointer in what's
|
||||
* left of memory on the board.
|
||||
*/
|
||||
caddr_t
|
||||
sbrk(int nbytes){
|
||||
static caddr_t heap_ptr = NULL;
|
||||
caddr_t base;
|
||||
|
||||
int temp;
|
||||
|
||||
if(heap_ptr == NULL){
|
||||
heap_ptr = (caddr_t)HEAP_ADDR;
|
||||
}
|
||||
|
||||
base = heap_ptr;
|
||||
|
||||
if(((unsigned long long)heap_ptr & ~PAGE_MASK) != 0ULL){
|
||||
temp = (PAGE_SIZE - ((unsigned long long)heap_ptr & ~PAGE_MASK));
|
||||
|
||||
if( nbytes < temp ){
|
||||
heap_ptr += nbytes;
|
||||
nbytes = 0;
|
||||
}else{
|
||||
heap_ptr += temp;
|
||||
nbytes -= temp;
|
||||
}
|
||||
}
|
||||
|
||||
while(nbytes > PAGE_SIZE){
|
||||
//allocPage(heap_ptr);
|
||||
|
||||
nbytes -= (int) PAGE_SIZE;
|
||||
heap_ptr = heap_ptr + PAGE_SIZE;
|
||||
}
|
||||
|
||||
if( nbytes > 0){
|
||||
//allocPage(heap_ptr);
|
||||
|
||||
heap_ptr += nbytes;
|
||||
}
|
||||
|
||||
|
||||
return base;
|
||||
/*
|
||||
static caddr_t heap_ptr = NULL;
|
||||
caddr_t base;
|
||||
|
||||
if (heap_ptr == NULL) {
|
||||
heap_ptr = (caddr_t)&_end;
|
||||
}
|
||||
|
||||
if ((RAMSIZE - heap_ptr) >= 0) {
|
||||
base = heap_ptr;
|
||||
heap_ptr += nbytes;
|
||||
return (base);
|
||||
} else {
|
||||
errno = ENOMEM;
|
||||
return ((caddr_t)-1);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
// --- Other ---
|
||||
int gettimeofday(struct timeval *p, void *z){
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user