shithub: scc

Download patch

ref: 4886e44d6ea86d65f31eb6ecbfa8f82cac9c2fa0
parent: 35a949fb7820804fa191db18db2c41bda2189a3b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 14 10:47:48 EDT 2021

libc: Update arch/ppc

This code is being updated out of the tree of scc and
it is time to synchroniza both copies now.

--- a/src/libc/arch/ppc/Makefile
+++ b/src/libc/arch/ppc/Makefile
@@ -1,9 +1,9 @@
 .POSIX:
 
-DIRS =\
+PROJECTDIR = ../../../..
+DIRS = \
 	linux\
 
-PROJECTDIR =../../../..
 include $(PROJECTDIR)/scripts/rules.mk
 include ../../rules.mk
 
--- a/src/libc/arch/ppc/crt-posix.s
+++ b/src/libc/arch/ppc/crt-posix.s
@@ -1,3 +1,4 @@
+
 	.comm _environ,4,4
 
 	.text
@@ -4,8 +5,16 @@
 	.globl	_start
 _start:
 	stwu	1,-16(1)
+	la	31,16(1)
+	lwz	3,0(31)		/* argc */
+	la	4,4(31)		/* argv */
 	lis	14,_environ@h
 	ori	14,14,_environ@l
-	stw	5,0(14)
+	la	5,0(14)
+	mulli	31,3,4		/* p = argc*4 */
+	add	31,4,31		/* q = argv + p */
+	addi	31,31,4		/* r = q + 4 */
+	lwz	31,0(31)	/* r = *r */
+	stw	31,0(5)		/* envp = r */
 	bl	main
 	b	exit
--- a/src/libc/arch/ppc/linux/Makefile
+++ b/src/libc/arch/ppc/linux/Makefile
@@ -21,9 +21,9 @@
 	_write.$O\
 
 OBJS =\
+	$(GENOBJS)\
 	_cerrno.o\
 	_sys_errlist.o\
-	$(GENOBJS)\
 
 GENSRC = $(GENOBJS:.o=.s)
 
--- a/src/libc/arch/ppc/longjmp.s
+++ b/src/libc/arch/ppc/longjmp.s
@@ -4,59 +4,58 @@
 
 longjmp:
 	/* 0) move old return address into r0 */
-	lwz 0,0(3)
+	lwz	0,0(3)
 	/* 1) put it into link reg */
-	mtlr 0
+	mtlr	0
 	/* 2 ) restore stack ptr */
-	lwz 1,4(3)
+	lwz	1,4(3)
 	/* 3) restore control reg */
-	lwz 0,8(3)
-	mtcr 0
+	lwz	0,8(3)
+	mtcr	0
 	/* 4) restore r14-r31 */
-	lwz 14,12(3)
-	lwz 15,16(3)
-	lwz 16,20(3)
-	lwz 17,24(3)
-	lwz 18,28(3)
-	lwz 19,32(3)
-	lwz 20,36(3)
-	lwz 21,40(3)
-	lwz 22,44(3)
-	lwz 23,48(3)
-	lwz 24,52(3)
-	lwz 25,56(3)
-	lwz 26,60(3)
-	lwz 27,64(3)
-	lwz 28,68(3)
-	lwz 29,72(3)
-	lwz 30,76(3)
-	lwz 31,80(3)
-	lfd 14,88(3)
-	lfd 15,96(3)
-	lfd 16,104(3)
-	lfd 17,112(3)
-	lfd 18,120(3)
-	lfd 19,128(3)
-	lfd 20,136(3)
-	lfd 21,144(3)
-	lfd 22,152(3)
-	lfd 23,160(3)
-	lfd 24,168(3)
-	lfd 25,176(3)
-	lfd 26,184(3)
-	lfd 27,192(3)
-	lfd 28,200(3)
-	lfd 29,208(3)
-	lfd 30,216(3)
-	lfd 31,224(3)
+	lwz	14,12(3)
+	lwz	15,16(3)
+	lwz	16,20(3)
+	lwz	17,24(3)
+	lwz	18,28(3)
+	lwz	19,32(3)
+	lwz	20,36(3)
+	lwz	21,40(3)
+	lwz	22,44(3)
+	lwz	23,48(3)
+	lwz	24,52(3)
+	lwz	25,56(3)
+	lwz	26,60(3)
+	lwz	27,64(3)
+	lwz	28,68(3)
+	lwz	29,72(3)
+	lwz	30,76(3)
+	lwz	31,80(3)
+	lfd	14,88(3)
+	lfd	15,96(3)
+	lfd	16,104(3)
+	lfd	17,112(3)
+	lfd	18,120(3)
+	lfd	19,128(3)
+	lfd	20,136(3)
+	lfd	21,144(3)
+	lfd	22,152(3)
+	lfd	23,160(3)
+	lfd	24,168(3)
+	lfd	25,176(3)
+	lfd	26,184(3)
+	lfd	27,192(3)
+	lfd	28,200(3)
+	lfd	29,208(3)
+	lfd	30,216(3)
+	lfd	31,224(3)
 
 	/* 5) put val into return reg r3 */
-	mr 3,4
+	mr	3,4
 
 	/* 6) check if return value is 0, make it 1 in that case */
-	cmpwi cr7,4,0
-	bne cr7,1f
-	li 3, 1
+	cmpwi	cr7,4,0
+	bne	cr7,1f
+	li	3,1
 1:
 	blr
-
--- a/src/libc/arch/ppc/setjmp.s
+++ b/src/libc/arch/ppc/setjmp.s
@@ -3,54 +3,58 @@
 	.global	setjmp
 
 setjmp:
-	/* 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg) */
-	mflr 0
-	stw 0,0(3)
+	/*
+	 * 0) store IP int 0,
+	 *    then into the jmpbuf
+	 *    pointed to by r3 (first arg)
+	 */
+	mflr	0
+	stw	0,0(3)
 	/* 1) store reg1 (SP) */
-	stw 1, 4(3)
+	stw	1,4(3)
 	/* 2) store cr */
-	mfcr 0
-	stw 0,8(3)
+	mfcr	0
+	stw	0,8(3)
 	/* 3) store r14-31 */
-	stw 14,12(3)
-	stw 15,16(3)
-	stw 16,20(3)
-	stw 17,24(3)
-	stw 18,28(3)
-	stw 19,32(3)
-	stw 20,36(3)
-	stw 21,40(3)
-	stw 22,44(3)
-	stw 23,48(3)
-	stw 24,52(3)
-	stw 25,56(3)
-	stw 26,60(3)
-	stw 27,64(3)
-	stw 28,68(3)
-	stw 29,72(3)
-	stw 30,76(3)
-	stw 31,80(3)
-	stfd 14,88(3)
-	stfd 15,96(3)
-	stfd 16,104(3)
-	stfd 17,112(3)
-	stfd 18,120(3)
-	stfd 19,128(3)
-	stfd 20,136(3)
-	stfd 21,144(3)
-	stfd 22,152(3)
-	stfd 23,160(3)
-	stfd 24,168(3)
-	stfd 25,176(3)
-	stfd 26,184(3)
-	stfd 27,192(3)
-	stfd 28,200(3)
-	stfd 29,208(3)
-	stfd 30,216(3)
-	stfd 31,224(3)
+	stw	14,12(3)
+	stw	15,16(3)
+	stw	16,20(3)
+	stw	17,24(3)
+	stw	18,28(3)
+	stw	19,32(3)
+	stw	20,36(3)
+	stw	21,40(3)
+	stw	22,44(3)
+	stw	23,48(3)
+	stw	24,52(3)
+	stw	25,56(3)
+	stw	26,60(3)
+	stw	27,64(3)
+	stw	28,68(3)
+	stw	29,72(3)
+	stw	30,76(3)
+	stw	31,80(3)
+	stfd	14,88(3)
+	stfd	15,96(3)
+	stfd	16,104(3)
+	stfd	17,112(3)
+	stfd	18,120(3)
+	stfd	19,128(3)
+	stfd	20,136(3)
+	stfd	21,144(3)
+	stfd	22,152(3)
+	stfd	23,160(3)
+	stfd	24,168(3)
+	stfd	25,176(3)
+	stfd	26,184(3)
+	stfd	27,192(3)
+	stfd	28,200(3)
+	stfd	29,208(3)
+	stfd	30,216(3)
+	stfd	31,224(3)
 
 	/* 4) set return value to 0 */
-	li 3,0
+	li	3,0
 
 	/* 5) return */
 	blr