commit cbaa33552ffc4d811511544c8803303a1e4630d9
parent 99cc38df2baf6201cabaed55e39bb9d1815d1c41
Author: zerous Naveen Narayanan <zerous@simple-cc.org>
Date: Mon, 20 Apr 2020 21:33:54 +0200
libc: Implement the following syscalls for ppc32
Exit
read
write
open
close
waitpid
creat
link
unlink
getpid
Diffstat:
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/src/libc/arch/ppc32/linux/Makefile b/src/libc/arch/ppc32/linux/Makefile
@@ -3,12 +3,23 @@ PROJECTDIR =../../../../..
include $(PROJECTDIR)/scripts/rules.mk
include ../../../rules.mk
-GENOBJS =
+GENOBJS =\
+ _Exit.$O\
+ _read.$O\
+ _write.$O\
+ _open.$O\
+ _close.$O\
+ _waitpid.$O\
+ _create.$O\
+ _link.$O\
+ _unlink.$O\
+ _getpid.$O\
GENSRC = $(GENOBJS:.$O=.s)
OBJS = \
$(GENOBJS)\
+ _cerrno.$O\
# Rules
diff --git a/src/libc/arch/ppc32/linux/_cerrno.s b/src/libc/arch/ppc32/linux/_cerrno.s
@@ -0,0 +1,12 @@
+ .file "_cerrno.s"
+ .globl _cerrno
+_cerrno:
+ cmpwi 0,0
+ bne err
+ blr
+err:
+ lis 0,errno@h
+ ori 0,0,errno@l
+ stw 3,0(0)
+ addi 3,3,-1
+ blr
diff --git a/src/libc/arch/ppc32/linux/gensys.sh b/src/libc/arch/ppc32/linux/gensys.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+awk '! /^#/ && $2 == "'$1'" {
+ syscall=$2
+ fname=$2".s"
+
+ printf ("\t.file\t" \
+ "\"%s\"\n" \
+ "\t.globl\t%s\n" \
+ "%s:\n",
+ fname, syscall, syscall)
+
+ printf ("\tli\t0,%d\n" \
+ "\tsc\n" \
+ "\tmfcr\t0\n" \
+ "\tb\t_cerrno\n", $1)
+} ' syscall.lst >$1.s
diff --git a/src/libc/arch/ppc32/linux/syscall.lst b/src/libc/arch/ppc32/linux/syscall.lst
@@ -0,0 +1,11 @@
+#number name
+1 _Exit
+3 _read
+4 _write
+5 _open
+6 _close
+7 _waitpid
+8 _creat
+9 _link
+10 _unlink
+20 _getpid