summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/ppc
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/dietlibc/ppc')
-rw-r--r--mdk-stage1/dietlibc/ppc/__testandset.S9
-rw-r--r--mdk-stage1/dietlibc/ppc/mmap.c11
-rw-r--r--mdk-stage1/dietlibc/ppc/start.S32
-rw-r--r--mdk-stage1/dietlibc/ppc/unified.S37
4 files changed, 55 insertions, 34 deletions
diff --git a/mdk-stage1/dietlibc/ppc/__testandset.S b/mdk-stage1/dietlibc/ppc/__testandset.S
index a6063fbb2..146982337 100644
--- a/mdk-stage1/dietlibc/ppc/__testandset.S
+++ b/mdk-stage1/dietlibc/ppc/__testandset.S
@@ -2,10 +2,11 @@
.type __testandset,@function
.align 2
__testandset:
- lwarx 5,0,3
- add 0,4,5
- stwcx 0,0,3
- bne __testandset
+1: lwarx 5,0,3
+ li 0,1
+ stwcx. 0,0,3
+ bne- 1b
+ mr 3,5
blr
.size __testandset,.-__testandset
diff --git a/mdk-stage1/dietlibc/ppc/mmap.c b/mdk-stage1/dietlibc/ppc/mmap.c
index 25d2926b2..d03e87089 100644
--- a/mdk-stage1/dietlibc/ppc/mmap.c
+++ b/mdk-stage1/dietlibc/ppc/mmap.c
@@ -1,5 +1,7 @@
-#include <linux/types.h>
-#include <linux/unistd.h>
+#include "dietfeatures.h"
+#include <sys/types.h>
+#include <errno.h>
+#include "syscalls.h"
int mmap(void*start,size_t length,int prot,int flags,int fd,off_t offset) {
unsigned long __sc_ret, __sc_err;
@@ -29,9 +31,10 @@ int mmap(void*start,size_t length,int prot,int flags,int fd,off_t offset) {
"r" (__sc_6),
"r" (__sc_7),
"r" (__sc_8)
- : __syscall_clobbers);
+ : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
__sc_ret = __sc_3;
__sc_err = __sc_0;
}
- __syscall_return (int);
+ return (__sc_err & 0x10000000 ? errno = __sc_ret, __sc_ret = -1 : 0),
+ (int) __sc_ret;
}
diff --git a/mdk-stage1/dietlibc/ppc/start.S b/mdk-stage1/dietlibc/ppc/start.S
index c7afeecd2..7b2aed7fb 100644
--- a/mdk-stage1/dietlibc/ppc/start.S
+++ b/mdk-stage1/dietlibc/ppc/start.S
@@ -1,21 +1,17 @@
-#include "start.h"
-
-#ifdef __powerpc__
-
.text
.global _start
.type _start,@function
_start:
/* Save the stack pointer, in case we're statically linked under Linux. */
- mr 9,1
+ mr 9,1
/* Set up an initial stack frame, and clear the LR. */
- clrrwi 1,1,4
- li 0,0
- stwu 1,-16(1)
- mtlr 0
- stw 0,0(1)
+ clrrwi 1,1,4
+ li 0,0
+ stwu 1,-16(1)
+ mtlr 0
+ stw 0,0(1)
- /* r9 enthält den initialen Stackpointer.
+ /* r9 contains the initial stack pointer
argc = (r9)
argv = (r9+4)
envp = argv+(argc+1)*4 */
@@ -27,18 +23,20 @@ _start:
slwi 5,5,2 /* (argc+1)*4 */
add 5,5,4 /* argv+(argc+1)*4 */
- lis 6,environ@ha
- stw 5,environ@l(6)
+ lis 14,environ@ha
+ stw 5,environ@l(14)
+#ifdef WANT_DYNAMIC
+ mr 6,7
+ bl _dyn_start
+#else
bl main
+#endif
b exit
.size _start,.-_start
/* Define a symbol for the first piece of initialized data. */
- .section ".data"
+ .section ".data"
__data_start:
-
-#endif
-
diff --git a/mdk-stage1/dietlibc/ppc/unified.S b/mdk-stage1/dietlibc/ppc/unified.S
index d2b419f0b..eb136a96b 100644
--- a/mdk-stage1/dietlibc/ppc/unified.S
+++ b/mdk-stage1/dietlibc/ppc/unified.S
@@ -1,21 +1,40 @@
#include <dietfeatures.h>
+#include "syscalls.h"
.text
+.type exit,@function
+.weak exit
+exit:
+.type _exit,@function
+.global _exit
+_exit:
+ li 0,__NR_exit
.global __unified_syscall
__unified_syscall:
sc
- mfcr 0
- andis. 9,0,4096
- mr 0,3
- beq .L1
-#ifdef WANT_THREAD_SAVE
- bl __set_errno
+ bnslr+
+
+.global error_unified_syscall
+error_unified_syscall:
+#ifdef WANT_THREAD_SAFE
+ stwu 1,-16(1)
+ mflr 0
+ stw 0,20(1)
+ stw 3,12(1)
+ bl __errno_location
+ lwz 0,12(1)
+ stw 0,0(3)
+ lwz 0,20(1)
+ mtlr 0
+ addi 1,1,16
#else
lis 9,errno@ha
stw 3,errno@l(9)
#endif
- li 0,-1
-.L1:
- mr 3,0
+ li 3,-1
+
+/* here we go and "reuse" the return for weak-void functions */
+#include "dietuglyweaks.h"
+
blr