[Mirmince-commits] {mirmince} branch master updated. 5a3da144cc64f70dce82d769e7585a3915f1f7a3
tg at freewrt.org
tg at freewrt.org
Sun Jan 13 06:24:02 UTC 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main git repository for FreeWRT project mirmince".
The branch, master has been updated
via 5a3da144cc64f70dce82d769e7585a3915f1f7a3 (commit)
via 75f19cca3e4e800e9b1a2d21878fafd7f1d37a6f (commit)
via 7a5a85f92505cd71ccf6f63d54d68c0edeea381f (commit)
via 6abd41a03259aa1909202e9ef5493719b275f51b (commit)
via 916962552a334ca725e7ee988adba90a6daed3c0 (commit)
via 32d00b9e3acd47e8fe2065c2e52a796e5fe599de (commit)
via f0c3e91da695a723c05d5b9bbcf7adb2f6302da9 (commit)
via e214911acb0729a2a9c3ea58a54cf5b13358dcbe (commit)
via d99795e972e4fcb2fc5c931e708f9ecdd6d72385 (commit)
via 32e931683303db569354d60f31ba3b88c7f9c5d8 (commit)
via b18d0487f8a30e2d7d77b47a010635f28963f962 (commit)
via 617fdc0723fd7bdbe0eac8ada4f537f34f807dae (commit)
via 944762a3831416f7e04c5c595f07c03bb6e002eb (commit)
via ea0a799b9cde0c28c59f345bfc5a8605ace60009 (commit)
via 51ea5caefb314799b6ed1818431b0d36c320bcb9 (commit)
via 209d032832b64fcd833d485704f897c14a086506 (commit)
from 925ed2e6a6a2ee89e51ab358d93d8aeb424aa9b3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5a3da144cc64f70dce82d769e7585a3915f1f7a3
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 06:23:58 2013 +0000
new target: the MirBSD/i386 “linuxulator” compat_linux(8), and…
… by extension, of course, the Linux kernel as well ☺
commit 75f19cca3e4e800e9b1a2d21878fafd7f1d37a6f
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 05:45:52 2013 +0000
drop unused SYSCALL_PREP
commit 7a5a85f92505cd71ccf6f63d54d68c0edeea381f
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 05:45:01 2013 +0000
move -fhonour-copts -Wbounded scan
commit 6abd41a03259aa1909202e9ef5493719b275f51b
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 05:40:50 2013 +0000
add new types (integers, mode_t) and <stdarg.h> with va_list
commit 916962552a334ca725e7ee988adba90a6daed3c0
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 04:54:38 2013 +0000
fix reverse logic error
commit 32d00b9e3acd47e8fe2065c2e52a796e5fe599de
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 04:52:58 2013 +0000
*every* header (except mirmince/types.h) needs an inclusion guard
commit f0c3e91da695a723c05d5b9bbcf7adb2f6302da9
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 04:45:51 2013 +0000
more os-dep
commit e214911acb0729a2a9c3ea58a54cf5b13358dcbe
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 03:45:23 2013 +0000
add mirmince_{u,s}reg types: a register width
(always “long” for all of our platforms, except x32 where it needs
to be 64 bit wide and thus using “long long”)
commit d99795e972e4fcb2fc5c931e708f9ecdd6d72385
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 03:32:46 2013 +0000
variablise osmd part of mincebeg.o
commit 32e931683303db569354d60f31ba3b88c7f9c5d8
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 03:20:07 2013 +0000
fix
commit b18d0487f8a30e2d7d77b47a010635f28963f962
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 03:18:40 2013 +0000
better place for syscall ABI docs
commit 617fdc0723fd7bdbe0eac8ada4f537f34f807dae
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 03:08:40 2013 +0000
be paranoid, other OSes are worse…
commit 944762a3831416f7e04c5c595f07c03bb6e002eb
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 02:45:51 2013 +0000
osmd includes, EXTRN macro, and size optimisation for syscalls
commit ea0a799b9cde0c28c59f345bfc5a8605ace60009
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 02:24:55 2013 +0000
move existing osdep+machdep code
commit 51ea5caefb314799b6ed1818431b0d36c320bcb9
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 02:22:49 2013 +0000
add support for osdep MD subsections
commit 209d032832b64fcd833d485704f897c14a086506
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sun Jan 13 01:46:18 2013 +0000
add .size to all functions from asm (and data, there aren’t any atm)
-----------------------------------------------------------------------
Summary of changes:
Makefile | 14 +++---
cvsyscls | 40 ++++++++++++++---
do-install | 14 +++---
include/fcntl.h | 30 +------------
include/mirmince/asm.h | 4 ++
include/mirmince/c.h | 20 +++++++++
include/mirmince/types.h | 27 +++++++++++
include/stdarg.h | 12 +++++
md/i386/README | 14 ------
md/i386/asm.h | 22 ++-------
md/i386/c.h | 5 +++
osdep/linux/Makefile.inc | 9 ++++
osdep/linux/asm.h | 25 +++++++++++
osdep/linux/c.h | 13 ++++++
osdep/linux/fcntl.h | 6 +++
osdep/linux/i386/Makefile.inc | 8 ++++
osdep/linux/i386/README | 11 +++++
osdep/linux/i386/asm.h | 20 +++++++++
osdep/linux/i386/c.h | 6 +++
osdep/linux/i386/fcntl.h | 32 +++++++++++++
.../mincebeg_os.S => linux/i386/mincebeg_md.S} | 27 ++++++-----
osdep/{mirbsd/cerror.S => linux/i386/syscalls.S} | 47 ++++++++++++++------
mi/exit.c => osdep/linux/open.c | 24 +++++++---
osdep/{mirbsd => linux}/syscalls | 6 ++-
osdep/mirbsd/Makefile.inc | 6 +--
osdep/mirbsd/asm.h | 22 +++++++++
osdep/mirbsd/c.h | 7 +++
{include => osdep/mirbsd}/fcntl.h | 24 ++--------
osdep/mirbsd/i386/Makefile.inc | 3 ++
osdep/mirbsd/i386/README | 13 ++++++
osdep/mirbsd/i386/asm.h | 18 ++++++++
osdep/mirbsd/i386/c.h | 4 ++
{md => osdep/mirbsd}/i386/mincebeg_md.S | 28 +++++-------
osdep/mirbsd/{cerror.S => i386/syscalls.S} | 22 ++++-----
34 files changed, 414 insertions(+), 169 deletions(-)
create mode 100644 include/stdarg.h
delete mode 100644 md/i386/README
create mode 100644 osdep/linux/Makefile.inc
create mode 100644 osdep/linux/asm.h
create mode 100644 osdep/linux/c.h
create mode 100644 osdep/linux/fcntl.h
create mode 100644 osdep/linux/i386/Makefile.inc
create mode 100644 osdep/linux/i386/README
create mode 100644 osdep/linux/i386/asm.h
create mode 100644 osdep/linux/i386/c.h
create mode 100644 osdep/linux/i386/fcntl.h
copy osdep/{mirbsd/mincebeg_os.S => linux/i386/mincebeg_md.S} (73%)
copy osdep/{mirbsd/cerror.S => linux/i386/syscalls.S} (64%)
copy mi/exit.c => osdep/linux/open.c (72%)
copy osdep/{mirbsd => linux}/syscalls (59%)
copy {include => osdep/mirbsd}/fcntl.h (60%)
create mode 100644 osdep/mirbsd/i386/Makefile.inc
create mode 100644 osdep/mirbsd/i386/README
create mode 100644 osdep/mirbsd/i386/asm.h
create mode 100644 osdep/mirbsd/i386/c.h
rename {md => osdep/mirbsd}/i386/mincebeg_md.S (77%)
rename osdep/mirbsd/{cerror.S => i386/syscalls.S} (84%)
diff --git a/Makefile b/Makefile
index f68ce2e..3e30b15 100644
--- a/Makefile
+++ b/Makefile
@@ -23,9 +23,9 @@ CC?= mgcc
LD?= ld
STRIP?= strip
OBJCOPY?= objcopy
-DST= /opt/mirmince
-TG_ARCH= i386
-TG_OS= mirbsd
+DST?= /opt/mirmince
+TG_ARCH?= i386
+TG_OS?= mirbsd
# not settings
SHELL= /bin/mksh
@@ -60,6 +60,7 @@ AFLAGS:=
LDFLAGS:=
LDADD:=
+.PATH: ${LIBCDIR}/osdep/${TG_OS}/${TG_ARCH}
.PATH: ${LIBCDIR}/osdep/${TG_OS}
.PATH: ${LIBCDIR}/md/${TG_ARCH}
.PATH: ${LIBCDIR}/mi
@@ -67,6 +68,7 @@ LDADD:=
.include "${LIBCDIR}/mi/Makefile.inc"
.include "${LIBCDIR}/md/${TG_ARCH}/Makefile.inc"
.include "${LIBCDIR}/osdep/${TG_OS}/Makefile.inc"
+.include "${LIBCDIR}/osdep/${TG_OS}/${TG_ARCH}/Makefile.inc"
.if !make(obj) && !make(prereq) && !make(depend) && !make(clean)
.include "${LIBCDIR}/obj/Makefile.gen"
@@ -95,8 +97,11 @@ LINK.c:= ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}
all: ${GENHDRS}
all: mincebeg.o
+MINCEBEG_OSDEP?=
+MINCEBEG_OSMD?=
+
# un-nice: despite localising, _mince_csu_run is not discarded
-mincebeg.o: mincebeg_os.o mincebeg_md.o mincebeg_mi.o
+mincebeg.o: ${MINCEBEG_OSDEP} ${MINCEBEG_OSMD} mincebeg_mi.o
${LD} -X -r -o $@.o $>
${OBJCOPY} -G _mince_csu_init -x $@.o $@
@rm -f $@.o
@@ -121,7 +126,6 @@ SOBJS+= sys_${_n}.o
sys_${_n}.S:
x='#include <mirmince/asm.h>'; \
x+=$$'\n#include <mirmince/syscall.h>'; \
- x+=$$'\nSYSCALL_PREP'; \
x+=$$'\nSYSCALL${_a}(${_n}, ${_k})'; \
print -r -- "$$x" >$@
diff --git a/cvsyscls b/cvsyscls
index f767ad0..a11f413 100644
--- a/cvsyscls
+++ b/cvsyscls
@@ -19,22 +19,47 @@
whattodo=$1
syscalls=$2
+if [[ -z $syscalls || ! -s $syscalls ]]; then
+ print -u2 "E: syscalls file '$syscalls' illegible"
+ exit 2
+fi
+
+exec >$whattodo
+
case $whattodo {
(Makefile.gen)
function doit {
mv=SYSCALLS_$arch
[[ $arch = '*' ]] && mv=SYSCALLS
- print -r "${mv}+= $name $kname $args"
+ if (( num < 256 )); then
+ size=B
+ else
+ size=D
+ fi
+ print -r "${mv}+= $name $kname $args$size"
+ }
+ function dopost {
+ :
}
;;
(syscall.h)
+ print "#ifndef MIRMINCE_SYSCALL_H"
+ print "#define MIRMINCE_SYSCALL_H"
+ print
function doit {
[[ $arch = '*' ]] || print "#ifdef __mirmincE_arch_$arch"
print "#define SYS_$kname $num"
[[ $arch = '*' ]] || print "#endif"
}
+ function dopost {
+ print
+ print "#endif"
+ }
;;
(syscallc.h)
+ print "#ifndef MIRMINCE_SYSCALLC_H"
+ print "#define MIRMINCE_SYSCALLC_H"
+ print
function doit {
[[ $arch = '*' ]] || print "#ifdef __mirmincE_arch_$arch"
print "#define mirmincE_cc_$kname mirmince_cc_$cconv"
@@ -42,6 +67,10 @@ case $whattodo {
"#define mirmincE_cc_$name mirmince_cc_$kcconv /* $kname */"
[[ $arch = '*' ]] || print "#endif"
}
+ function dopost {
+ print
+ print "#endif"
+ }
;;
(*)
print -u2 "E: Syntax error"
@@ -49,11 +78,6 @@ case $whattodo {
;;
}
-if [[ -z $syscalls || ! -s $syscalls ]]; then
- print -u2 "E: syscalls file '$syscalls' illegible"
- exit 2
-fi
-
set -A numseen
while read arch num args name kname cconv kcconv rest; do
[[ -z $arch || $arch = '#' ]] && continue
@@ -101,4 +125,6 @@ while read arch num args name kname cconv kcconv rest; do
print -ru2 "E: syscall $num calling convention '$kcconv' invalid"
fi
doit
-done <"$syscalls" >$whattodo
+done <"$syscalls"
+
+dopost
diff --git a/do-install b/do-install
index 1765e71..6e47f1f 100644
--- a/do-install
+++ b/do-install
@@ -39,6 +39,11 @@ arch=$3
os=$4
cflags=$5
+#XXX in lieu of a configure script
+for tryflags in -Wbounded -fhonour-copts; do
+ $cc $tryflags -E - <<<'' >/dev/null 2>&1 && cflags+=" $tryflags"
+done
+
set -A defenv
for x in GNUTARGET LDEMULATION; do
eval y=\$$x
@@ -48,7 +53,7 @@ done
cd "$(dirname "$0")"
rm -rf "$dst"/{bin,include,lib,libdata}
-mkdir -p "$dst"/{bin,include/mirmince/{md,osdep},lib,libdata}
+mkdir -p "$dst"/{bin,include/mirmince/{md,osdep,osmd},lib,libdata}
cp LICENCE "$dst"/libdata/
while IFS= read -r line; do
print -r -- "${line//@@DST@@/"${dst at Q}"}"
@@ -72,10 +77,9 @@ while IFS= read -r line; do
done <gcc-wrap >"$dst"/bin/cc
chmod +x "$dst"/bin/cc
find include -name \*.h -print0 | pax -rw -0 "$dst"/
-(cd md/"$arch" && find . -name \*.h -print0 | \
- pax -rw -0 "$dst"/include/mirmince/md/)
-(cd osdep/"$os" && find . -name \*.h -print0 | \
- pax -rw -0 "$dst"/include/mirmince/osdep/)
+(cd md/"$arch" && pax -rw *.h "$dst"/include/mirmince/md/)
+(cd osdep/"$os" && pax -rw *.h "$dst"/include/mirmince/osdep/)
+(cd osdep/"$os/$arch" && pax -rw *.h "$dst"/include/mirmince/osmd/)
cp obj/syscall.h obj/syscallc.h "$dst"/include/mirmince/
(( full )) || exit 0
for f in obj/mince{beg,end}.o obj/*.a; do
diff --git a/include/fcntl.h b/include/fcntl.h
index f2324d8..4b20520 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -10,35 +10,7 @@
#define MIRMINCE_NT_PID_T
#include <mirmince/types.h>
-#if defined(__mirmincE_os_mirbsd)
-/*#define O_EXEC*/
-#define O_RDONLY 0x0000
-#define O_RDWR 0x0002
-/*#define O_SEARCH*/
-#define O_WRONLY 0x0001
-#ifndef _ALL_SOURCE
-#define O_ACCMODE 0x0003
-#endif
-#define O_APPEND 0x0008
-/*#define O_CLOEXEC*/
-#define O_CREAT 0x0200
-/*#define O_DIRECTORY*/
-#define O_DSYNC O_SYNC
-#define O_EXCL 0x0800
-#define O_NOCTTY 0x8000
-#define O_NOFOLLOW 0x0100
-#define O_NONBLOCK 0x0004
-#define O_RSYNC O_SYNC
-#define O_SYNC 0x0080
-#define O_TRUNC 0x0400
-/*#define O_TTY_INIT*/
-#ifndef _ALL_SOURCE
-#define O_SHLOCK 0x0010
-#define O_EXLOCK 0x0020
-#define O_ASYNC 0x0040
-#define O_FSYNC O_SYNC
-#endif
-#endif /* OS:MirBSD */
+#include <mirmince/osdep/fcntl.h>
__BEGIN_DECLS
int open(const char *path, int oflag, ...)
diff --git a/include/mirmince/asm.h b/include/mirmince/asm.h
index ee5cdf9..7cae754 100644
--- a/include/mirmince/asm.h
+++ b/include/mirmince/asm.h
@@ -3,6 +3,7 @@
#include <mirmince/md/asm.h>
#include <mirmince/osdep/asm.h>
+#include <mirmince/osmd/asm.h>
#ifndef MIRMINCE_ASM_USCORES
#ifdef __ELF__
@@ -49,5 +50,8 @@
#define ENTRY(x) _TEXT; _ALIGN_TEXT; ASENTRY(_C_LABEL(x))
#define TENTRY(x) ASENTRY(_C_LABEL(x))
#define DENTRY(x) .globl _C_LABEL(x); _OTYPE(_C_LABEL(x)); _C_LABEL(x):
+#define ENDSYM(x) .size x, . - x
+#define END(x) ENDSYM(_C_LABEL(x))
+#define EXTRN(x) .globl _C_LABEL(x)
#endif
diff --git a/include/mirmince/c.h b/include/mirmince/c.h
index 6eb14f0..77b3342 100644
--- a/include/mirmince/c.h
+++ b/include/mirmince/c.h
@@ -3,6 +3,7 @@
#include <mirmince/md/c.h>
#include <mirmince/osdep/c.h>
+#include <mirmince/osmd/c.h>
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
@@ -40,4 +41,23 @@
#define NULL ((void *)0)
+/* CPU register wide types */
+#ifdef __mirmincE_arch_x32
+typedef unsigned long long mirmince_ureg;
+typedef signed long long mirmince_sreg;
+#else
+typedef unsigned long mirmince_ureg;
+typedef signed long mirmince_sreg;
+#endif
+
+/* specific bit wide types */
+typedef unsigned char mirmince_u8;
+typedef unsigned short mirmince_u16;
+typedef unsigned int mirmince_u32;
+typedef unsigned long long mirmince_u64;
+typedef signed char mirmince_s8;
+typedef signed short mirmince_s16;
+typedef signed int mirmince_s32;
+typedef signed long long mirmince_s64;
+
#endif
diff --git a/include/mirmince/types.h b/include/mirmince/types.h
index 306c6fb..397296f 100644
--- a/include/mirmince/types.h
+++ b/include/mirmince/types.h
@@ -1,3 +1,20 @@
+/*
+ * this file does NOT have multiple-inclusion protection,
+ * this is by design, as it needs to be multiply included
+ * it instead has multiple definition protection for each
+ * thing it defines
+ */
+
+/* depends on c.h */
+#ifdef MIRMINCE_NT_MODE_T
+#ifndef MIRMINCE_DT_MODE_T
+typedef MIRMINCE_UT_MODE_T mode_t;
+#define MIRMINCE_DT_MODE_T
+#endif
+#undef MIRMINCE_NT_MODE_T
+#endif
+
+/* uses a compiler builtin */
#ifdef MIRMINCE_NT_SIZE_T
#ifndef MIRMINCE_DT_SIZE_T
#ifdef __SIZE_TYPE__
@@ -8,6 +25,7 @@ typedef __SIZE_TYPE__ size_t;
#undef MIRMINCE_NT_SIZE_T
#endif
+/* uses a compiler builtin */
#ifdef MIRMINCE_NT_SSIZE_T
#ifndef MIRMINCE_DT_SSIZE_T
#ifdef __SIZE_TYPE__
@@ -19,3 +37,12 @@ typedef signed __SIZE_TYPE__ ssize_t;
#endif
#undef MIRMINCE_NT_SSIZE_T
#endif
+
+/* uses a compiler builtin */
+#ifdef MIRMINCE_NT_VA_LIST
+#ifndef MIRMINCE_DT_VA_LIST
+typedef __builtin_va_list va_list;
+#define MIRMINCE_DT_VA_LIST
+#endif
+#undef MIRMINCE_NT_VA_LIST
+#endif
diff --git a/include/stdarg.h b/include/stdarg.h
new file mode 100644
index 0000000..5012320
--- /dev/null
+++ b/include/stdarg.h
@@ -0,0 +1,12 @@
+#ifndef STDARG_H
+#define STDARG_H
+
+#define MIRMINCE_NT_VA_LIST
+#include <mirmince/types.h>
+
+#define va_start __builtin_va_start
+#define va_copy __builtin_va_copy
+#define va_arg __builtin_va_arg
+#define va_end __builtin_va_end
+
+#endif
diff --git a/md/i386/README b/md/i386/README
deleted file mode 100644
index a0717f9..0000000
--- a/md/i386/README
+++ /dev/null
@@ -1,14 +0,0 @@
-syscall ABI
-===========
-
-MirBSD/i386
------------
-
-Arguments are pushed on the stack (cdecl),
-then another argument (call), then int 80h
-is run.
-
-Normal: CF clear (NC), EDX:EAX = return value
-Error: CF set (CY), EAX = errno
-
-All registers other than EAX, EDX, EFLAGS are preserved.
diff --git a/md/i386/asm.h b/md/i386/asm.h
index aa39352..1e8990b 100644
--- a/md/i386/asm.h
+++ b/md/i386/asm.h
@@ -1,3 +1,6 @@
+#ifndef MIRMINCE_MD_I386_ASM_H
+#define MIRMINCE_MD_I386_ASM_H
+
#ifdef _ASM_SOURCE
.intel_syntax noprefix
#endif
@@ -6,23 +9,4 @@
#define _ALIGN_TEXT .p2align 2,0x90
#endif
-#if defined(__mirmincE_os_mirbsd)
-#define SYSCALL_PREP \
- .globl _C_LABEL(_mince_cerror)
-#define SYSCALL(cname,kname) \
- ENTRY(cname) \
- mov eax,SYS_ ## kname; \
- int 0x80; \
- jc _mince_cerror; \
- ret
-#define SYSCALLV SYSCALL
-#define SYSCALL0 SYSCALL
-#define SYSCALL1 SYSCALL
-#define SYSCALL2 SYSCALL
-#define SYSCALL3 SYSCALL
-#define SYSCALL4 SYSCALL
-#define SYSCALL5 SYSCALL
-#define SYSCALL6 SYSCALL
-#else
-#error define a syscall convention for the OS
#endif
diff --git a/md/i386/c.h b/md/i386/c.h
index 6e818ff..de24c06 100644
--- a/md/i386/c.h
+++ b/md/i386/c.h
@@ -1,3 +1,8 @@
+#ifndef MIRMINCE_MD_I386_C_H
+#define MIRMINCE_MD_I386_C_H
+
#ifdef __mirmincE_use_regparm__
#define mirmince_cc_userspc mirmince_cc_regparm(__mirmincE_use_regparm__)
#endif
+
+#endif
diff --git a/osdep/linux/Makefile.inc b/osdep/linux/Makefile.inc
new file mode 100644
index 0000000..892b037
--- /dev/null
+++ b/osdep/linux/Makefile.inc
@@ -0,0 +1,9 @@
+#XXX not thought about this much
+
+TG_CFLAGS+= -Os -fweb -frename-registers
+TG_CFLAGS+= -fno-align-functions -fno-align-labels \
+ -falign-loops=4 -falign-jumps=4
+TG_CFLAGS+= -Wformat -Wstrict-aliasing -Wmissing-declarations
+TG_CFLAGS+= -fwrapv
+
+SRCS+= open.c
diff --git a/osdep/linux/asm.h b/osdep/linux/asm.h
new file mode 100644
index 0000000..a68ae81
--- /dev/null
+++ b/osdep/linux/asm.h
@@ -0,0 +1,25 @@
+#ifndef MIRMINCE_OSDEP_LINUX_ASM_H
+#define MIRMINCE_OSDEP_LINUX_ASM_H
+
+#ifndef __ELF__
+#error we always use ELF on Linux
+#endif
+
+#define SYSCALLVB SYSCALLB
+#define SYSCALL0B SYSCALLB
+#define SYSCALL1B SYSCALLB
+#define SYSCALL2B SYSCALLB
+#define SYSCALL3B SYSCALLB
+#define SYSCALL4B SYSCALLB
+#define SYSCALL5B SYSCALLB
+#define SYSCALL6B SYSCALLB
+#define SYSCALLVD SYSCALLD
+#define SYSCALL0D SYSCALLD
+#define SYSCALL1D SYSCALLD
+#define SYSCALL2D SYSCALLD
+#define SYSCALL3D SYSCALLD
+#define SYSCALL4D SYSCALLD
+#define SYSCALL5D SYSCALLD
+#define SYSCALL6D SYSCALLD
+
+#endif
diff --git a/osdep/linux/c.h b/osdep/linux/c.h
new file mode 100644
index 0000000..3b62fba
--- /dev/null
+++ b/osdep/linux/c.h
@@ -0,0 +1,13 @@
+#ifndef MIRMINCE_OSDEP_LINUX_C_H
+#define MIRMINCE_OSDEP_LINUX_C_H
+
+#ifndef __ELF__
+#error we always use ELF on Linux
+#endif
+
+#ifdef __mirmincE_arch_i386
+/* reset -mrtd but keep regparm */
+#define mirmince_cc_syscall mirmince_cc_cdecl mirmince_cc_regparm(3)
+#endif
+
+#endif
diff --git a/osdep/linux/fcntl.h b/osdep/linux/fcntl.h
new file mode 100644
index 0000000..51c8731
--- /dev/null
+++ b/osdep/linux/fcntl.h
@@ -0,0 +1,6 @@
+#ifndef MIRMINCE_OSDEP_LINUX_FCNTL_H
+#define MIRMINCE_OSDEP_LINUX_FCNTL_H
+
+#include <mirmince/osmd/fcntl.h>
+
+#endif
diff --git a/osdep/linux/i386/Makefile.inc b/osdep/linux/i386/Makefile.inc
new file mode 100644
index 0000000..c0c527d
--- /dev/null
+++ b/osdep/linux/i386/Makefile.inc
@@ -0,0 +1,8 @@
+#XXX not thought about this much
+
+TG_CFLAGS+= -march=i486 -mpush-args -mpreferred-stack-boundary=2 \
+ -momit-leaf-frame-pointer
+
+MINCEBEG_OSMD= mincebeg_md.o
+
+SRCS+= syscalls.S
diff --git a/osdep/linux/i386/README b/osdep/linux/i386/README
new file mode 100644
index 0000000..40b9b32
--- /dev/null
+++ b/osdep/linux/i386/README
@@ -0,0 +1,11 @@
+┌────────────────────────┐
+│ Linux/i386 syscall ABI │
+└────────────────────────┘
+
+Arguments are passed in registers. It is not known whether
+the registers are preserved. The register order is:
+ EBX ECX EDX ESI EDI EBP
+The syscall number itself is passed in EAX.
+
+Return values are always “int” in EAX; values >= -4095 are
+neg’d errno values, anything else is the return value.
diff --git a/osdep/linux/i386/asm.h b/osdep/linux/i386/asm.h
new file mode 100644
index 0000000..ab926c5
--- /dev/null
+++ b/osdep/linux/i386/asm.h
@@ -0,0 +1,20 @@
+#ifndef MIRMINCE_OSDEP_LINUX_I386_ASM_H
+#define MIRMINCE_OSDEP_LINUX_I386_ASM_H
+
+#define SYSCALLB(cname,kname) \
+ .globl _mince_syscall; \
+ ENTRY(cname) \
+ push ebx; \
+ mov bl,SYS_ ## kname; \
+ jmp _mince_syscall; \
+ END(cname)
+
+#define SYSCALLD(cname,kname) \
+ .globl _mince_syscallEx; \
+ ENTRY(cname) \
+ push ebx; \
+ mov ebx,SYS_ ## kname; \
+ jmp _mince_syscallEx; \
+ END(cname)
+
+#endif
diff --git a/osdep/linux/i386/c.h b/osdep/linux/i386/c.h
new file mode 100644
index 0000000..4778940
--- /dev/null
+++ b/osdep/linux/i386/c.h
@@ -0,0 +1,6 @@
+#ifndef MIRMINCE_OSDEP_LINUX_I386_C_H
+#define MIRMINCE_OSDEP_LINUX_I386_C_H
+
+#define MIRMINCE_UT_MODE_T mirmince_u16
+
+#endif
diff --git a/osdep/linux/i386/fcntl.h b/osdep/linux/i386/fcntl.h
new file mode 100644
index 0000000..363a630
--- /dev/null
+++ b/osdep/linux/i386/fcntl.h
@@ -0,0 +1,32 @@
+#ifndef MIRMINCE_OSDEP_LINUX_I386_FCNTL_H
+#define MIRMINCE_OSDEP_LINUX_I386_FCNTL_H
+
+/*#define O_EXEC*/
+#define O_RDONLY 0x00000
+#define O_RDWR 0x00002
+/*#define O_SEARCH*/
+#define O_WRONLY 0x00001
+#ifdef _ALL_SOURCE
+#define O_ACCMODE 0x00003
+#endif
+#define O_APPEND 0x00400
+/*#define O_CLOEXEC*/
+#define O_CREAT 0x00040
+#define O_DIRECTORY 0x10000
+/*#define O_DSYNC*/
+#define O_EXCL 0x00080
+#define O_NOCTTY 0x00100
+#define O_NOFOLLOW 0x20000
+#define O_NONBLOCK 0x00800
+/*#define O_RSYNC*/
+#define O_SYNC 0x01000
+#define O_TRUNC 0x00200
+/*#define O_TTY_INIT*/
+#ifdef _ALL_SOURCE
+#define O_DIRECT 0x04000
+#define O_LARGEFILE 0x08000
+#define O_NOATIME 0x40000
+#define O_NDELAY O_NONBLOCK
+#endif
+
+#endif
diff --git a/osdep/mirbsd/mincebeg_os.S b/osdep/linux/i386/mincebeg_md.S
similarity index 73%
copy from osdep/mirbsd/mincebeg_os.S
copy to osdep/linux/i386/mincebeg_md.S
index 0c3d09c..71ce8e6 100644
--- a/osdep/mirbsd/mincebeg_os.S
+++ b/osdep/linux/i386/mincebeg_md.S
@@ -1,5 +1,5 @@
/*-
- * Copyright © 2003, 2004, 2005, 2013
+ * Copyright © 2004, 2005, 2007, 2013
* Thorsten Glaser <tg at mirbsd.org>
*
* Provided that these terms and disclaimer and all copyright notices
@@ -20,16 +20,15 @@
#include <mirmince/asm.h>
-#ifndef __ELF__
-#error huh?
-#endif
-
- .section .note.miros.ident,"a", at progbits
- .p2align 2
- .long 2f-1f /* name size */
- .long 4f-3f /* desc size */
- .long 1 /* type (OS version note) */
-1: .asciz "MirOS BSD" /* name */
-2: .p2align 2
-3: .long 0 /* desc */
-4: .p2align 2
+_TEXT
+_ALIGN_TEXT
+ASENTRY(_mince_csu_init)
+ cld /* required by the ABI */
+ pop eax /* argc */
+ mov edx,esp /* argv */
+ lea ecx,[edx+4*eax+4] /* envp = argv[argc + 1] */
+ push ecx /* envp */
+ push edx /* argv */
+ push eax /* argc */
+ call _C_LABEL(_mince_csu_run)
+ENDSYM(_mince_csu_init)
diff --git a/osdep/mirbsd/cerror.S b/osdep/linux/i386/syscalls.S
similarity index 64%
copy from osdep/mirbsd/cerror.S
copy to osdep/linux/i386/syscalls.S
index 1e3c925..dc7ad13 100644
--- a/osdep/mirbsd/cerror.S
+++ b/osdep/linux/i386/syscalls.S
@@ -20,18 +20,39 @@
#include <mirmince/asm.h>
- _TEXT
+EXTRN(errno)
- .globl _C_LABEL(errno)
-
- _ALIGN_TEXT
-ASENTRY(_mince_cerror)
-
-#if defined(__mirmincE_arch_i386)
- mov [_C_LABEL(errno)],eax
- mov edx,0xFFFFFFFF
- mov eax,edx
+_TEXT
+_ALIGN_TEXT
+ASENTRY(_mince_syscall)
+ movzx ebx,bl
+ASENTRY(_mince_syscallEx)
+ /*
+ * regparm(3) is EAX EDX ECX
+ * we need EAX + EBX ECX EDX ESI EDI EBP
+ * the SYSCALL* macro already pushed EBX
+ * which now contains the syscall number
+ */
+ push ebp
+ mov ebp,esp
+ push esi
+ push edi
+ xchg eax,ebx
+ xchg ecx,edx
+ mov esi,[ebp+16]
+ mov edi,[ebp+20]
+ mov ebp,[ebp+24]
+ int 0x80
+ cmp eax,(-4095)
+ jae 2f
+1: pop edi
+ pop esi
+ pop ebp
+ pop ebx
ret
-#else
-#error define cerror for this architecture
-#endif
+2: neg eax
+ mov [_C_LABEL(errno)],eax
+ mov eax,0xFFFFFFFF
+ /* no edx: no 64-bit retvals in Linux/i386 */
+ jmp 1b
+ENDSYM(_mince_syscall)
diff --git a/mi/exit.c b/osdep/linux/open.c
similarity index 72%
copy from mi/exit.c
copy to osdep/linux/open.c
index 99b7bc0..2f66f01 100644
--- a/mi/exit.c
+++ b/osdep/linux/open.c
@@ -18,14 +18,24 @@
* of said person’s immediate fault when using the work as intended.
*/
-#include <stdlib.h>
+#include <fcntl.h>
+#include <stdarg.h>
-extern int _exit__(int status)
- mirmince_dead
- mirmincE_cc__exit__;
+extern int _open__(const char *path, int oflag, mirmince_ureg mode)
+ mirmincE_cc__open__;
-void
-exit(int status)
+mirmincE_cc_open int
+open(const char *path, int oflag, ...)
{
- _exit__(status);
+ mode_t mode;
+
+ if (oflag & O_CREAT) {
+ va_list ap;
+
+ va_start(ap, oflag);
+ mode = va_arg(ap, int);
+ va_end(ap);
+ }
+
+ return _open__(path, oflag | O_LARGEFILE, mode);
}
diff --git a/osdep/mirbsd/syscalls b/osdep/linux/syscalls
similarity index 59%
copy from osdep/mirbsd/syscalls
copy to osdep/linux/syscalls
index 37ce142..3c3903e 100644
--- a/osdep/mirbsd/syscalls
+++ b/osdep/linux/syscalls
@@ -1,7 +1,9 @@
+#
+# currently checked arches: i386
+#
# arch num args name kname cconv kcconv
-* 0 V syscall
* 1 1 _exit__ exit
* 3 3 read
* 4 3 write
-* 5 V open
+i386 5 3 _open__ open cdecl
* 6 1 close
diff --git a/osdep/mirbsd/Makefile.inc b/osdep/mirbsd/Makefile.inc
index 57afa49..f07cc69 100644
--- a/osdep/mirbsd/Makefile.inc
+++ b/osdep/mirbsd/Makefile.inc
@@ -15,9 +15,5 @@ TG_CFLAGS+= -mcpu=v8 -mtune=hypersparc
TG_CFLAGS+= -Wformat -Wstrict-aliasing -Wmissing-declarations
TG_CFLAGS+= -fwrapv
-#XXX in lieu of a configure script
-.if defined(OStype) && ${OStype} == "MirBSD"
-TG_CFLAGS+= -Wbounded -fhonour-copts
-.endif
-SRCS+= cerror.S
+MINCEBEG_OSDEP= mincebeg_os.o
diff --git a/osdep/mirbsd/asm.h b/osdep/mirbsd/asm.h
index 154adc7..8f4c451 100644
--- a/osdep/mirbsd/asm.h
+++ b/osdep/mirbsd/asm.h
@@ -1,3 +1,25 @@
+#ifndef MIRMINCE_OSDEP_MIRBSD_ASM_H
+#define MIRMINCE_OSDEP_MIRBSD_ASM_H
+
#ifndef __ELF__
#error we always use ELF on MirBSD
#endif
+
+#define SYSCALLVB SYSCALLB
+#define SYSCALL0B SYSCALLB
+#define SYSCALL1B SYSCALLB
+#define SYSCALL2B SYSCALLB
+#define SYSCALL3B SYSCALLB
+#define SYSCALL4B SYSCALLB
+#define SYSCALL5B SYSCALLB
+#define SYSCALL6B SYSCALLB
+#define SYSCALLVD SYSCALLD
+#define SYSCALL0D SYSCALLD
+#define SYSCALL1D SYSCALLD
+#define SYSCALL2D SYSCALLD
+#define SYSCALL3D SYSCALLD
+#define SYSCALL4D SYSCALLD
+#define SYSCALL5D SYSCALLD
+#define SYSCALL6D SYSCALLD
+
+#endif
diff --git a/osdep/mirbsd/c.h b/osdep/mirbsd/c.h
index 154adc7..c616670 100644
--- a/osdep/mirbsd/c.h
+++ b/osdep/mirbsd/c.h
@@ -1,3 +1,10 @@
+#ifndef MIRMINCE_OSDEP_MIRBSD_C_H
+#define MIRMINCE_OSDEP_MIRBSD_C_H
+
#ifndef __ELF__
#error we always use ELF on MirBSD
#endif
+
+#define MIRMINCE_UT_MODE_T mirmince_u32
+
+#endif
diff --git a/include/fcntl.h b/osdep/mirbsd/fcntl.h
similarity index 60%
copy from include/fcntl.h
copy to osdep/mirbsd/fcntl.h
index f2324d8..67176fb 100644
--- a/include/fcntl.h
+++ b/osdep/mirbsd/fcntl.h
@@ -1,22 +1,12 @@
-#ifndef FCNTL_H
-#define FCNTL_H
+#ifndef MIRMINCE_OSDEP_MIRBSD_FCNTL_H
+#define MIRMINCE_OSDEP_MIRBSD_FCNTL_H
-#ifndef MIRMINCE_C_H
-#include <mirmince/c.h>
-#endif
-
-#define MIRMINCE_NT_MODE_T
-#define MIRMINCE_NT_OFF_T
-#define MIRMINCE_NT_PID_T
-#include <mirmince/types.h>
-
-#if defined(__mirmincE_os_mirbsd)
/*#define O_EXEC*/
#define O_RDONLY 0x0000
#define O_RDWR 0x0002
/*#define O_SEARCH*/
#define O_WRONLY 0x0001
-#ifndef _ALL_SOURCE
+#ifdef _ALL_SOURCE
#define O_ACCMODE 0x0003
#endif
#define O_APPEND 0x0008
@@ -32,17 +22,11 @@
#define O_SYNC 0x0080
#define O_TRUNC 0x0400
/*#define O_TTY_INIT*/
-#ifndef _ALL_SOURCE
+#ifdef _ALL_SOURCE
#define O_SHLOCK 0x0010
#define O_EXLOCK 0x0020
#define O_ASYNC 0x0040
#define O_FSYNC O_SYNC
#endif
-#endif /* OS:MirBSD */
-
-__BEGIN_DECLS
-int open(const char *path, int oflag, ...)
- mirmincE_cc_open;
-__END_DECLS
#endif
diff --git a/osdep/mirbsd/i386/Makefile.inc b/osdep/mirbsd/i386/Makefile.inc
new file mode 100644
index 0000000..65f2dee
--- /dev/null
+++ b/osdep/mirbsd/i386/Makefile.inc
@@ -0,0 +1,3 @@
+MINCEBEG_OSMD= mincebeg_md.o
+
+SRCS+= syscalls.S
diff --git a/osdep/mirbsd/i386/README b/osdep/mirbsd/i386/README
new file mode 100644
index 0000000..ff559f6
--- /dev/null
+++ b/osdep/mirbsd/i386/README
@@ -0,0 +1,13 @@
+┌─────────────────────────┐
+│ MirBSD/i386 syscall ABI │
+└─────────────────────────┘
+
+Arguments are pushed on the stack (cdecl),
+then another argument (call), then EAX is
+loaded with the syscall number and int 80h
+is run.
+
+Normal: CF clear (NC), EDX:EAX = return value
+Error: CF set (CY), EAX = errno
+
+All registers other than EAX, EDX, EFLAGS are preserved.
diff --git a/osdep/mirbsd/i386/asm.h b/osdep/mirbsd/i386/asm.h
new file mode 100644
index 0000000..2266c8e
--- /dev/null
+++ b/osdep/mirbsd/i386/asm.h
@@ -0,0 +1,18 @@
+#ifndef MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
+#define MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
+
+#define SYSCALLB(cname,kname) \
+ .globl _mince_syscall; \
+ ENTRY(cname) \
+ mov al,SYS_ ## kname; \
+ jmp _mince_syscall; \
+ END(cname)
+
+#define SYSCALLD(cname,kname) \
+ .globl _mince_syscallEx; \
+ ENTRY(cname) \
+ mov eax,SYS_ ## kname; \
+ jmp _mince_syscallEx; \
+ END(cname)
+
+#endif
diff --git a/osdep/mirbsd/i386/c.h b/osdep/mirbsd/i386/c.h
new file mode 100644
index 0000000..784aa88
--- /dev/null
+++ b/osdep/mirbsd/i386/c.h
@@ -0,0 +1,4 @@
+#ifndef MIRMINCE_OSDEP_MIRBSD_I386_C_H
+#define MIRMINCE_OSDEP_MIRBSD_I386_C_H
+
+#endif
diff --git a/md/i386/mincebeg_md.S b/osdep/mirbsd/i386/mincebeg_md.S
similarity index 77%
rename from md/i386/mincebeg_md.S
rename to osdep/mirbsd/i386/mincebeg_md.S
index c97972e..a5252c5 100644
--- a/md/i386/mincebeg_md.S
+++ b/osdep/mirbsd/i386/mincebeg_md.S
@@ -20,26 +20,18 @@
#include <mirmince/asm.h>
- _TEXT
- _ALIGN_TEXT
+_TEXT
+_ALIGN_TEXT
ASENTRY(_mince_csu_init)
-
-#ifdef extra_paranoid
- /* required by the ABI */
- cld
-#endif
-
-#if defined(__mirmincE_os_mirbsd)
- push ebx /* ps_strings (unused) */
- push ecx /* obj (unused) */
- push edx /* cleanup (unused) */
+ cld /* required by the ABI */
+ push ebx /* ps_strings (unused) */
+ push ecx /* obj (unused) */
+ push edx /* cleanup (unused) */
mov eax,[esp+12]
lea ecx,[esp+4*eax+20]
lea edx,[esp+16]
- push ecx /* envp */
- push edx /* argv */
- push eax /* argc */
-#else
-#error need OS specific CSU
-#endif
+ push ecx /* envp */
+ push edx /* argv */
+ push eax /* argc */
call _C_LABEL(_mince_csu_run)
+ENDSYM(_mince_csu_init)
diff --git a/osdep/mirbsd/cerror.S b/osdep/mirbsd/i386/syscalls.S
similarity index 84%
rename from osdep/mirbsd/cerror.S
rename to osdep/mirbsd/i386/syscalls.S
index 1e3c925..4f22263 100644
--- a/osdep/mirbsd/cerror.S
+++ b/osdep/mirbsd/i386/syscalls.S
@@ -20,18 +20,18 @@
#include <mirmince/asm.h>
- _TEXT
+EXTRN(errno)
- .globl _C_LABEL(errno)
-
- _ALIGN_TEXT
-ASENTRY(_mince_cerror)
-
-#if defined(__mirmincE_arch_i386)
- mov [_C_LABEL(errno)],eax
+_TEXT
+_ALIGN_TEXT
+ASENTRY(_mince_syscall)
+ movzx eax,al
+ASENTRY(_mince_syscallEx)
+ int 0x80
+ jc 1f
+ ret
+1: mov [_C_LABEL(errno)],eax
mov edx,0xFFFFFFFF
mov eax,edx
ret
-#else
-#error define cerror for this architecture
-#endif
+ENDSYM(_mince_syscall)
hooks/post-receive
--
Main git repository for FreeWRT project mirmince
(FreeWRT project mirmince repository mirmince)
More information about the Mirmince-commits
mailing list