[mirmince commits] {mirmince} branch master updated. 4de7ad02a319341ec238ff10d49cc5878a278ea7

tg at freewrt.org tg at freewrt.org
Mon Jul 15 21:22:55 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  4de7ad02a319341ec238ff10d49cc5878a278ea7 (commit)
       via  239c9ac1b110c6c8a5362a11297e32f2aca24a7e (commit)
       via  6850ce1f3fc4d20ee785964c6b36f17a6fcb866b (commit)
       via  29ac6e6db42cde6664f22910ca2c59ae13eb7a26 (commit)
      from  b21c1be6c86925d6e46d3a27f81ebc29394090da (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 4de7ad02a319341ec238ff10d49cc5878a278ea7
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Mon Jul 15 21:01:12 2013 +0000

    MidnightBSD/amd64 port

commit 239c9ac1b110c6c8a5362a11297e32f2aca24a7e
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Mon Jul 15 19:07:44 2013 +0000

    drop _ALIGN_DATA as it’s currently unused

commit 6850ce1f3fc4d20ee785964c6b36f17a6fcb866b
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Mon Jul 15 14:46:29 2013 -0400

    MidnightBSD pax(1) has no -0 so let’s just not use white-space in filenames

commit 29ac6e6db42cde6664f22910ca2c59ae13eb7a26
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Mon Jul 15 18:35:52 2013 +0000

    add basic support for MidnightBSD/i386
    
    (also FreeBSD/i386, Debian GNU/kFreeBSD/i386)
    mostly copied from MirBSD/i386
    
    also mention that the cross overrides have to be exported,
    not passed as make arguments

-----------------------------------------------------------------------

Summary of changes:
 Makefile                                           |    2 ++
 README                                             |    5 ++-
 do-install                                         |    8 ++---
 include/fcntl.h                                    |    4 +++
 include/mirmince/asm.h                             |    4 ---
 md/amd64/asm.h                                     |   12 +++++++
 md/i386/asm.h                                      |    5 ---
 osdep/linux/i386/fcntl.h                           |    1 -
 osdep/{mirbsd => midnightbsd}/Makefile.inc         |   10 +++---
 .../i386 => midnightbsd/amd64}/Makefile.inc        |    0
 osdep/midnightbsd/amd64/README                     |   35 ++++++++++++++++++++
 osdep/{mirbsd/i386 => midnightbsd/amd64}/asm.h     |    4 +--
 .../i386 => midnightbsd/amd64}/mincebeg_md.S       |   20 +++++------
 .../{mirbsd/i386 => midnightbsd/amd64}/syscalls.S  |    8 +++--
 osdep/{mirbsd => midnightbsd}/asm.h                |    6 ++--
 osdep/midnightbsd/fcntl.h                          |   32 ++++++++++++++++++
 osdep/{mirbsd => midnightbsd}/i386/Makefile.inc    |    0
 osdep/{mirbsd => midnightbsd}/i386/README          |    8 +++--
 osdep/{mirbsd => midnightbsd}/i386/asm.h           |    4 +--
 osdep/{mirbsd => midnightbsd}/i386/mincebeg_md.S   |    0
 osdep/{mirbsd => midnightbsd}/i386/syscalls.S      |    0
 osdep/{mirbsd => midnightbsd}/syscalls             |    1 -
 22 files changed, 124 insertions(+), 45 deletions(-)
 create mode 100644 md/amd64/Makefile.inc
 create mode 100644 md/amd64/asm.h
 copy osdep/{mirbsd => midnightbsd}/Makefile.inc (59%)
 copy osdep/{mirbsd/i386 => midnightbsd/amd64}/Makefile.inc (100%)
 create mode 100644 osdep/midnightbsd/amd64/README
 copy osdep/{mirbsd/i386 => midnightbsd/amd64}/asm.h (76%)
 copy osdep/{mirbsd/i386 => midnightbsd/amd64}/mincebeg_md.S (77%)
 copy osdep/{mirbsd/i386 => midnightbsd/amd64}/syscalls.S (95%)
 copy osdep/{mirbsd => midnightbsd}/asm.h (78%)
 create mode 100644 osdep/midnightbsd/fcntl.h
 copy osdep/{mirbsd => midnightbsd}/i386/Makefile.inc (100%)
 copy osdep/{mirbsd => midnightbsd}/i386/README (73%)
 copy osdep/{mirbsd => midnightbsd}/i386/asm.h (76%)
 copy osdep/{mirbsd => midnightbsd}/i386/mincebeg_md.S (100%)
 copy osdep/{mirbsd => midnightbsd}/i386/syscalls.S (100%)
 copy osdep/{mirbsd => midnightbsd}/syscalls (88%)

diff --git a/Makefile b/Makefile
index 7d96dc1..1fbdf57 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,8 @@ CC:=		${OBJADIR}/cc
 _CONF:=		${LIBCDIR}/obj/.conf-${TG_ARCH:Q}-${TG_OS:Q}-${OBJADIR:S!/!_!g:Q}
 TGS_ALL:=	mirbsd/i386
 TGS_ALL+=	linux/i386
+TGS_ALL+=	midnightbsd/amd64
+TGS_ALL+=	midnightbsd/i386
 TGS_OS:=	${TGS_ALL:H}
 TGS_CPU:=	${TGS_ALL:T}
 
diff --git a/README b/README
index b1107e9..8e0a666 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ You’ll need MirMake: a BSD make that automatically descends
 into ./obj/ and reads .depend if possible and supports several
 variable expansion manipulation operators like :M :Q :S etc.
 
-On Debian/amd64 install pmake and expose CC='cc -m32' and
+On Debian/amd64 install pmake and export CC='cc -m32' and
 LDEMULATION=elf_i386 to pmake depend and pmake install calls.
 You can set TG_VARIANT to DEB_HOST_MULTIARCH and even append
 things to further distinguish, like '-regparm-rtd' for ABI
@@ -21,6 +21,9 @@ IR bytecode version. (The scripts-as-they-are-right-now are
 GCC specific, but that’s only by happenstance, not by design.)
 Some appropriate value may have been set by default.
 
+Equivalent FreeBSD magic: export TG_OS=midnightbsd TG_ARCH=amd64
+export TG_ARCH=i386 CC='gcc -m32' LDEMULATION=elf_i386_fbsd
+
 To use:
 
 $DST/bin/cc [-D_ALL_SOURCE] foo.c
diff --git a/do-install b/do-install
index d0069ab..b8bfa9e 100644
--- a/do-install
+++ b/do-install
@@ -42,10 +42,10 @@ mksh gcc-mk "$cc" "$dst" "$arch" "$os" "$cflags" \
     "$dst"/libdata$vsub "$dst"/libexec$vsub "$dst"/lib$vsub
 linkfile "$DESTDIR$dst"/libexec$vsub/cc "$DESTDIR$dst"/bin/${vpfx}cc
 linkfile "$DESTDIR$dst"/libexec$vsub/cc "$DESTDIR$dst"/bin/cc
-find include -name \*.h -print0 | pax -rw -0 "$DESTDIR$dst"/
-find md osdep -name \*.h -print0 | pax -rw -0 "$DESTDIR$dst"/include/mirmince/
-(cd obj; find osdep -name \*.h -print0 | \
-    pax -rw -0 "$DESTDIR$dst"/include/mirmince/)
+find include -name \*.h | pax -rw "$DESTDIR$dst"/
+find md osdep -name \*.h | pax -rw "$DESTDIR$dst"/include/mirmince/
+(cd obj; find osdep -name \*.h | \
+    pax -rw "$DESTDIR$dst"/include/mirmince/)
 for f in obj/mince{beg,end}.o obj/*.a; do
 	[[ -s $f ]] || continue
 	cp "$f" "$DESTDIR$dst"/lib$vsub/
diff --git a/include/fcntl.h b/include/fcntl.h
index 1d827bd..3710230 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -12,6 +12,10 @@
 
 #include mirmince_hdr_osdep(fcntl.h)
 
+#ifdef _ALL_SOURCE
+#define O_NDELAY		O_NONBLOCK
+#endif
+
 __BEGIN_DECLS
 int open(const char *path, int oflag, ...)
 	mirmincE_cc_open;
diff --git a/include/mirmince/asm.h b/include/mirmince/asm.h
index 6c4b6b1..0d8bf8e 100644
--- a/include/mirmince/asm.h
+++ b/include/mirmince/asm.h
@@ -40,10 +40,6 @@
 #define _COMMENT		.section .comment
 #endif
 
-#ifndef _ALIGN_DATA
-#define _ALIGN_DATA(x)		/* nothing */
-#endif
-
 #ifndef _ALIGN_TEXT
 #define _ALIGN_TEXT		/* nothing */
 #endif
diff --git a/md/amd64/Makefile.inc b/md/amd64/Makefile.inc
new file mode 100644
index 0000000..e69de29
diff --git a/md/amd64/asm.h b/md/amd64/asm.h
new file mode 100644
index 0000000..d5f02d1
--- /dev/null
+++ b/md/amd64/asm.h
@@ -0,0 +1,12 @@
+#ifndef MIRMINCE_MD_AMD64_ASM_H
+#define MIRMINCE_MD_AMD64_ASM_H
+
+#ifdef __ASSEMBLER__
+	.intel_syntax noprefix
+#endif
+
+#ifndef SMALL
+#define _ALIGN_TEXT		.p2align 3,0x90
+#endif
+
+#endif
diff --git a/md/i386/asm.h b/md/i386/asm.h
index 08c81ae..2cd2863 100644
--- a/md/i386/asm.h
+++ b/md/i386/asm.h
@@ -9,11 +9,6 @@
 #define _ALIGN_TEXT		.p2align 2,0x90
 #endif
 
-#ifdef notdef
-/* we do not need this, really, on x86 */
-#define _ALIGN_DATA(x)		.balign x,0
-#endif
-
 #ifdef __mirmincE_use_regparm__
 #define mirmince_cc_userspc	mirmince_cc_regparm(__mirmincE_use_regparm__)
 #endif
diff --git a/osdep/linux/i386/fcntl.h b/osdep/linux/i386/fcntl.h
index 363a630..ae7a736 100644
--- a/osdep/linux/i386/fcntl.h
+++ b/osdep/linux/i386/fcntl.h
@@ -26,7 +26,6 @@
 #define O_DIRECT		0x04000
 #define O_LARGEFILE		0x08000
 #define O_NOATIME		0x40000
-#define O_NDELAY		O_NONBLOCK
 #endif
 
 #endif
diff --git a/osdep/mirbsd/Makefile.inc b/osdep/midnightbsd/Makefile.inc
similarity index 59%
copy from osdep/mirbsd/Makefile.inc
copy to osdep/midnightbsd/Makefile.inc
index e7b99b1..50cf255 100644
--- a/osdep/mirbsd/Makefile.inc
+++ b/osdep/midnightbsd/Makefile.inc
@@ -5,15 +5,13 @@ TG_CFLAGS+=	-fno-align-functions -fno-align-labels \
 		-falign-loops=4 -falign-jumps=4
 
 .if ${TG_ARCH} == "i386"
-TG_CFLAGS+=	-march=i486 -mpush-args -mpreferred-stack-boundary=2
-.elif ${TG_ARCH} == "sparc"
-TG_CFLAGS+=	-mcpu=v8 -mtune=hypersparc
+TG_CFLAGS+=	-march=i486 -mpreferred-stack-boundary=2
+.elif ${TG_ARCH} == "amd64"
+TG_CFLAGS+=	-falign-loops=8
 .else
-.error Unknown MirBSD architecture "${TG_ARCH}"
+.error Unknown MidnightBSD architecture "${TG_ARCH}"
 .endif
 
 TG_CFLAGS+=	-Wformat -Wstrict-aliasing -Wmissing-declarations
 TG_CFLAGS+=	-fwrapv
 TG_CFLAGS+=	-fomit-frame-pointer
-
-MINCEBEG_OSDEP=	mincebeg_os.o
diff --git a/osdep/mirbsd/i386/Makefile.inc b/osdep/midnightbsd/amd64/Makefile.inc
similarity index 100%
copy from osdep/mirbsd/i386/Makefile.inc
copy to osdep/midnightbsd/amd64/Makefile.inc
diff --git a/osdep/midnightbsd/amd64/README b/osdep/midnightbsd/amd64/README
new file mode 100644
index 0000000..c3a577b
--- /dev/null
+++ b/osdep/midnightbsd/amd64/README
@@ -0,0 +1,35 @@
+┌───────────────────────────────┐
+│ MidnightBSD/amd64 syscall ABI │
+└───────────────────────────────┘
+
+User functions on amd64 have arguments first fill up the
+registers rdi, rsi, rdx, rcx, r8, r9 then then push them
+on the stack; return value is rax. (FPU notwithstanding.)
+
+Kernel calls use the SYSCALL instruction and trash rcx
+and r11, so they use r10 instead of rcx. The syscall number
+is passed in rax. Return values are:
+
+Normal:	CF clear (NC), rdx:rax = return value
+Error:	CF set (CY), eax = errno
+
+Register usage table:
+• rax	ret_lo	syscall#no.	return value (lo)
+• rcx	arg#4	<trashed by SYSCALL instruction (rip)>
+• rdx	#3/hi	sarg#3		return value (hi)
+• rbx	presvd	-		= preserved
+• rsp	presvd	<stack pointer>
+• rbp	presvd	-		= preserved
+• rsi	arg#2	sarg#2		= sarg#2
+• rdi	arg#1	sarg#1		= sarg#1
+• r8	arg#5	sarg#5		trashed
+• r9	arg#6	sarg#6		trashed
+• r10	tmp	sarg#4		trashed
+• r11	tmp	<trashed by SYSCALL instruction (rflags)>
+• r12	presvd	-		= preserved
+• r13	presvd	-		= preserved
+• r14	presvd	-		= preserved
+• r15	presvd	-		= preserved
+
+The flags are not preserved. The kernel does not seem
+to require stack alignment even if other libcs say so.
diff --git a/osdep/mirbsd/i386/asm.h b/osdep/midnightbsd/amd64/asm.h
similarity index 76%
copy from osdep/mirbsd/i386/asm.h
copy to osdep/midnightbsd/amd64/asm.h
index 2266c8e..534bc9d 100644
--- a/osdep/mirbsd/i386/asm.h
+++ b/osdep/midnightbsd/amd64/asm.h
@@ -1,5 +1,5 @@
-#ifndef MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
-#define MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
+#ifndef MIRMINCE_OSDEP_MIDNIGHTBSD_AMD64_ASM_H
+#define MIRMINCE_OSDEP_MIDNIGHTBSD_AMD64_ASM_H
 
 #define SYSCALLB(cname,kname)			\
 		.globl	_mince_syscall;		\
diff --git a/osdep/mirbsd/i386/mincebeg_md.S b/osdep/midnightbsd/amd64/mincebeg_md.S
similarity index 77%
copy from osdep/mirbsd/i386/mincebeg_md.S
copy to osdep/midnightbsd/amd64/mincebeg_md.S
index a5252c5..f93ab60 100644
--- a/osdep/mirbsd/i386/mincebeg_md.S
+++ b/osdep/midnightbsd/amd64/mincebeg_md.S
@@ -1,5 +1,5 @@
 /*-
- * Copyright © 2004, 2005, 2007, 2013
+ * Copyright © 2013
  *	Thorsten Glaser <tg at mirbsd.org>
  *
  * Provided that these terms and disclaimer and all copyright notices
@@ -24,14 +24,14 @@ _TEXT
 _ALIGN_TEXT
 ASENTRY(_mince_csu_init)
 	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 */
+	xor	ebp,ebp			/* clear the frame pointer */
+	/* should be rsp according to the ELF psABI, but FreeBSD uses rdi */
+	mov	rcx,rdi
+	/* load arguments */
+	mov	rdi,[rcx]		/* argc */
+	lea	rsi,8[rcx]		/* argv */
+	lea	rdx,[rcx+8*rdi+16]	/* envp */
+	/* align the stack */
+	and	rsp,0xFFFFFFFFFFFFFFF0
 	call	_C_LABEL(_mince_csu_run)
 ENDSYM(_mince_csu_init)
diff --git a/osdep/mirbsd/i386/syscalls.S b/osdep/midnightbsd/amd64/syscalls.S
similarity index 95%
copy from osdep/mirbsd/i386/syscalls.S
copy to osdep/midnightbsd/amd64/syscalls.S
index 4f22263..dc88cf0 100644
--- a/osdep/mirbsd/i386/syscalls.S
+++ b/osdep/midnightbsd/amd64/syscalls.S
@@ -27,11 +27,13 @@ _ALIGN_TEXT
 ASENTRY(_mince_syscall)
 	movzx	eax,al
 ASENTRY(_mince_syscallEx)
-	int	0x80
+	mov	r10,rcx
+	syscall
 	jc	1f
 	ret
 1:	mov	[_C_LABEL(errno)],eax
-	mov	edx,0xFFFFFFFF
-	mov	eax,edx
+	xor	edx,edx
+	dec	rdx
+	mov	rax,rdx
 	ret
 ENDSYM(_mince_syscall)
diff --git a/osdep/mirbsd/asm.h b/osdep/midnightbsd/asm.h
similarity index 78%
copy from osdep/mirbsd/asm.h
copy to osdep/midnightbsd/asm.h
index 9ec8681..766e994 100644
--- a/osdep/mirbsd/asm.h
+++ b/osdep/midnightbsd/asm.h
@@ -1,5 +1,5 @@
-#ifndef MIRMINCE_OSDEP_MIRBSD_ASM_H
-#define MIRMINCE_OSDEP_MIRBSD_ASM_H
+#ifndef MIRMINCE_OSDEP_MIDNIGHTBSD_ASM_H
+#define MIRMINCE_OSDEP_MIDNIGHTBSD_ASM_H
 
 #define SYSCALLVB		SYSCALLB
 #define SYSCALL0B		SYSCALLB
@@ -18,6 +18,6 @@
 #define SYSCALL5D		SYSCALLD
 #define SYSCALL6D		SYSCALLD
 
-#define MIRMINCE_UT_MODE_T	mirmince_u32
+#define MIRMINCE_UT_MODE_T	mirmince_u16
 
 #endif
diff --git a/osdep/midnightbsd/fcntl.h b/osdep/midnightbsd/fcntl.h
new file mode 100644
index 0000000..7d05f27
--- /dev/null
+++ b/osdep/midnightbsd/fcntl.h
@@ -0,0 +1,32 @@
+#ifndef MIRMINCE_OSDEP_MIDNIGHTBSD_FCNTL_H
+#define MIRMINCE_OSDEP_MIDNIGHTBSD_FCNTL_H
+
+#define O_EXEC			0x00040000
+#define O_RDONLY		0x00000000
+#define O_RDWR			0x00000002
+/*#define O_SEARCH*/
+#define O_WRONLY		0x00000001
+#ifdef _ALL_SOURCE
+#define O_ACCMODE		0x00000003
+#endif
+#define O_APPEND		0x00000008
+#define O_CLOEXEC		0x00100000
+#define O_CREAT			0x00000200
+#define O_DIRECTORY		0x00020000
+#define O_DSYNC			O_SYNC
+#define O_NOCTTY		0x00008000
+#define O_NOFOLLOW		0x00000100
+#define O_NONBLOCK		0x00000004
+#define O_RSYNC			O_SYNC
+#define O_SYNC			0x00000080
+#define O_TRUNC			0x00000400
+#define O_TTY_INIT		0x00080000
+#ifdef _ALL_SOURCE
+#define O_SHLOCK		0x00000010
+#define O_EXLOCK		0x00000020
+#define O_ASYNC			0x00000040
+#define O_FSYNC			0x00000080
+#define O_DIRECT		0x00010000
+#endif
+
+#endif
diff --git a/osdep/mirbsd/i386/Makefile.inc b/osdep/midnightbsd/i386/Makefile.inc
similarity index 100%
copy from osdep/mirbsd/i386/Makefile.inc
copy to osdep/midnightbsd/i386/Makefile.inc
diff --git a/osdep/mirbsd/i386/README b/osdep/midnightbsd/i386/README
similarity index 73%
copy from osdep/mirbsd/i386/README
copy to osdep/midnightbsd/i386/README
index ff559f6..aeaa7ae 100644
--- a/osdep/mirbsd/i386/README
+++ b/osdep/midnightbsd/i386/README
@@ -1,6 +1,8 @@
-┌─────────────────────────┐
-│ MirBSD/i386 syscall ABI │
-└─────────────────────────┘
+┌──────────────────────────────┐
+│ MidnightBSD/i386 syscall ABI │
+└──────────────────────────────┘
+
+XXX copied from MirBSD/i386; needs recheck
 
 Arguments are pushed on the stack (cdecl),
 then another argument (call), then EAX is
diff --git a/osdep/mirbsd/i386/asm.h b/osdep/midnightbsd/i386/asm.h
similarity index 76%
copy from osdep/mirbsd/i386/asm.h
copy to osdep/midnightbsd/i386/asm.h
index 2266c8e..af48550 100644
--- a/osdep/mirbsd/i386/asm.h
+++ b/osdep/midnightbsd/i386/asm.h
@@ -1,5 +1,5 @@
-#ifndef MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
-#define MIRMINCE_OSDEP_MIRBSD_I386_ASM_H
+#ifndef MIRMINCE_OSDEP_MIDNIGHTBSD_I386_ASM_H
+#define MIRMINCE_OSDEP_MIDNIGHTBSD_I386_ASM_H
 
 #define SYSCALLB(cname,kname)			\
 		.globl	_mince_syscall;		\
diff --git a/osdep/mirbsd/i386/mincebeg_md.S b/osdep/midnightbsd/i386/mincebeg_md.S
similarity index 100%
copy from osdep/mirbsd/i386/mincebeg_md.S
copy to osdep/midnightbsd/i386/mincebeg_md.S
diff --git a/osdep/mirbsd/i386/syscalls.S b/osdep/midnightbsd/i386/syscalls.S
similarity index 100%
copy from osdep/mirbsd/i386/syscalls.S
copy to osdep/midnightbsd/i386/syscalls.S
diff --git a/osdep/mirbsd/syscalls b/osdep/midnightbsd/syscalls
similarity index 88%
copy from osdep/mirbsd/syscalls
copy to osdep/midnightbsd/syscalls
index 37ce142..1a43913 100644
--- a/osdep/mirbsd/syscalls
+++ b/osdep/midnightbsd/syscalls
@@ -1,5 +1,4 @@
 # arch	num	args	name		kname		cconv	kcconv
-*	0	V	syscall
 *	1	1	_exit__		exit
 *	3	3	read
 *	4	3	write


hooks/post-receive
-- 
Main git repository for FreeWRT project mirmince
(FreeWRT project mirmince repository mirmince)


More information about the mirmince-commits mailing list