changeset 345:c607d67cd6b8 r1.1-RC2

- doc: added syscall info to appendix, fixed broken literature link - cleanup, added missing forward declarations, ...
author Tassilo Philipp
date Tue, 07 Jan 2020 21:52:57 +0100
parents d60728b1f4a1
children d3d6dbe3c2bc
files doc/manual/callconvs/callconv_ppc32.tex doc/manual/callconvs/callconv_ppc64.tex doc/manual/callconvs/callconv_x64.tex doc/manual/callconvs/callconv_x86.tex doc/manual/manual_literature.tex dyncall/dyncall_call_ppc32.S dyncall/dyncall_call_ppc32.h dyncall/dyncall_call_ppc64.S dyncall/dyncall_call_ppc64.h
diffstat 9 files changed, 78 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/doc/manual/callconvs/callconv_ppc32.tex	Tue Jan 07 11:34:31 2020 +0100
+++ b/doc/manual/callconvs/callconv_ppc32.tex	Tue Jan 07 21:52:57 2020 +0100
@@ -36,7 +36,10 @@
 
 \paragraph{\product{dyncall} support}
 
-\product{Dyncall} and \product{dyncallback} are supported for PowerPC (32bit) Big Endian (MSB), for Darwin's and System V's calling convention.
+\product{Dyncall} and \product{dyncallback} are supported for PowerPC (32bit)
+Big Endian (MSB), for Darwin's and System V's calling convention.\\
+\product{Dyncall} can also be used to issue syscalls by using the syscall
+number as target parameter and selecting the correct mode.
 
 
 \subsubsection{Mac OS X/Darwin}
@@ -245,3 +248,19 @@
 \caption{Stack layout on System V ABI for PowerPC 32-bit calling convention}
 \end{figure}
 
+
+\newpage
+
+\subsubsection{System V syscalls}
+
+\paragraph{Parameter passing}
+
+\begin{itemize}
+\item syscall is issued via the {\em sc} instruction
+\item kernel destroys registers r13
+\item syscall number is set in r0
+\item params are passed in registers r3 through r10
+\item no stack in use, meaning syscalls are in theory limited to eight arguments
+\item register r3 holds the return value, overflow flag in conditional register cr0 signals errors in syscall
+\end{itemize}
+
--- a/doc/manual/callconvs/callconv_ppc64.tex	Tue Jan 07 11:34:31 2020 +0100
+++ b/doc/manual/callconvs/callconv_ppc64.tex	Tue Jan 07 21:52:57 2020 +0100
@@ -33,7 +33,11 @@
 
 \paragraph{\product{dyncall} support}
 
-\product{Dyncall} supports PowerPC (64bit) Big Endian and Little Endian ELF ABIs on System V systems (Linux, etc.), including syscalls. Mac OS X is not supported.
+\product{Dyncall} and \product{dyncallback} are supported for PowerPC (64bit)
+Big Endian and Little Endian ELF ABIs on System V systems. Mac OS X is not
+supported.\\
+\product{Dyncall} can also be used to issue syscalls by using the syscall
+number as target parameter and selecting the correct mode.
 
 
 \subsubsection{PPC64 ELF ABI}
@@ -152,3 +156,19 @@
 \caption{Stack layout on ppc64 ELF ABI}
 \end{figure}
 
+
+\newpage
+
+\subsubsection{System V syscalls}
+
+\paragraph{Parameter passing}
+
+\begin{itemize}
+\item syscall is issued via the {\em sc} instruction
+\item kernel destroys registers r13
+\item syscall number is set in r0
+\item params are passed in registers r3 through r10
+\item no stack in use, meaning syscalls are in theory limited to eight arguments
+\item register r3 holds the return value, overflow flag in conditional register cr0 signals errors in syscall
+\end{itemize}
+
--- a/doc/manual/callconvs/callconv_x64.tex	Tue Jan 07 11:34:31 2020 +0100
+++ b/doc/manual/callconvs/callconv_x64.tex	Tue Jan 07 21:52:57 2020 +0100
@@ -251,8 +251,8 @@
 \item syscall is issued via the {\em syscall} instruction
 \item kernel destroys registers rcx and r11
 \item syscall number is set in rax
-\item up to 6 params are passed in the following registers in this order: rdi, rsi, rdx, rcx, r8, r9
-\item no stack in use, meaning syscalls are limited to six arguments
+\item params are passed in the following registers in this order: rdi, rsi, rdx, rcx, r8, r9
+\item no stack in use, meaning syscalls are in theory limited to six arguments
 \item register rax holds the return value (values in between -4095 and -1 indicate errors)
 \end{itemize}
 
--- a/doc/manual/callconvs/callconv_x86.tex	Tue Jan 07 11:34:31 2020 +0100
+++ b/doc/manual/callconvs/callconv_x86.tex	Tue Jan 07 21:52:57 2020 +0100
@@ -808,21 +808,27 @@
 \end{figure}
 
 
-%@@@ \newpage
-%@@@ 
-%@@@ \subsubsection{Linux syscalls}
-%@@@ 
-%@@@ \paragraph{Parameter passing}
-%@@@ 
-%@@@ \begin{itemize}
-%@@@ \item ...
-%@@@ \end{itemize}
-%@@@ 
-%@@@ \subsubsection{*BSD syscalls}
-%@@@ 
-%@@@ \paragraph{Parameter passing}
-%@@@ 
-%@@@ \begin{itemize}
-%@@@ \item ...
-%@@@ \end{itemize}
+\newpage
+
+\subsubsection{Linux syscalls}
+
+\paragraph{Parameter passing}
 
+\begin{itemize}
+\item syscall is issued by triggering {\em interrupt 80h}
+\item syscall number is set in eax
+\item params are passed in the following registers in this order: ebx, ecx, edx, esi, edi, ebp
+\item for more than six arguments, ebx points to the list of further arguments (not used in practice, as Linux syscalls use a maximum of 5 arguments)
+\item register eax holds the return value
+\end{itemize}
+
+\subsubsection{*BSD syscalls}
+
+\paragraph{Parameter passing}
+
+\begin{itemize}
+\item syscall is issued by triggering {\em interrupt 80h}
+\item syscall number is set in eax
+\item params are passed on the stack as with the cdecl calling convention
+\end{itemize}
+
--- a/doc/manual/manual_literature.tex	Tue Jan 07 11:34:31 2020 +0100
+++ b/doc/manual/manual_literature.tex	Tue Jan 07 21:52:57 2020 +0100
@@ -160,7 +160,7 @@
 
 \bibitem{ppceabi}
 	PowerPC Embedded Application Binary Interface 32-bit Implementation\\
-	\url{http://ftp.twaren.net/Unix/Sourceware/binutils/ppc-eabi-1995-01.pdf}
+	\url{http://ftp.twaren.net/Unix/sourceware.org/binutils/ppc-docs/ppc-eabi-1995-01.pdf}
 
 \bibitem{ppceabiibm}
 	Developing PowerPC Embedded Application Binary Interface (EABI)\\
--- a/dyncall/dyncall_call_ppc32.S	Tue Jan 07 11:34:31 2020 +0100
+++ b/dyncall/dyncall_call_ppc32.S	Tue Jan 07 21:52:57 2020 +0100
@@ -268,6 +268,7 @@
 
 	.align 2
 
+/* @@@ Bus Error on Darwin */
 GLOBAL_C(dcCall_ppc32_syscall)
 ENTRY_C(dcCall_ppc32_syscall)
 	mflr r0			/* r0 = return address */
@@ -282,10 +283,11 @@
 	lwz  r5 , 8(r11)
 	lwz  r6 ,12(r11)
 	lwz  r7 ,16(r11)
+	/* @@@ missing r8,r9,10 on some platforms? */
 	sc
 
 	lwz  r1, 0(r1)		/* restore stack */
 	lwz  r0, 4(r1)		/* r0 = return address */
 	mtlr r0			/* setup link register */
 	blr
-	
+
--- a/dyncall/dyncall_call_ppc32.h	Tue Jan 07 11:34:31 2020 +0100
+++ b/dyncall/dyncall_call_ppc32.h	Tue Jan 07 21:52:57 2020 +0100
@@ -47,12 +47,13 @@
 */
 
 /* Darwin ABI */
-
 void     dcCall_ppc32_darwin (DCpointer target, struct DCRegData_ppc32_* ppc32data, DCsize stksize, DCpointer stkdata);
 
-/* System V (Linux) ABI */
+/* System V ABI */
+void     dcCall_ppc32_sysv (DCpointer target, struct DCRegData_ppc32_* ppc32data, DCsize stksize, DCpointer stkdata);
 
-void     dcCall_ppc32_sysv (DCpointer target, struct DCRegData_ppc32_* ppc32data, DCsize stksize, DCpointer stkdata);
+/* syscall @@@ Bus Error on Darwin */
+void     dcCall_ppc32_syscall (DCpointer target, struct DCRegData_ppc32_* ppc32data, DCsize stksize, DCpointer stkdata);
 
 #ifdef __cplusplus
 }
--- a/dyncall/dyncall_call_ppc64.S	Tue Jan 07 11:34:31 2020 +0100
+++ b/dyncall/dyncall_call_ppc64.S	Tue Jan 07 21:52:57 2020 +0100
@@ -197,7 +197,7 @@
 	ld  r5 ,16(r11)
 	ld  r6 ,24(r11)
 	ld  r7 ,32(r11)
-	
+	/* @@@ missing r8,r9,10 on some platforms? */
 	sc                    /* system call */
 
 	/* epilog */
--- a/dyncall/dyncall_call_ppc64.h	Tue Jan 07 11:34:31 2020 +0100
+++ b/dyncall/dyncall_call_ppc64.h	Tue Jan 07 21:52:57 2020 +0100
@@ -47,6 +47,9 @@
 
 void     dcCall_ppc64(DCpointer target, struct DCRegData_ppc64_* ppc64data, DCsize stksize, DCpointer stkdata);
 
+/* syscall */
+void     dcCall_ppc64_syscall(DCpointer target, struct DCRegData_ppc64_* ppc64data, DCsize stksize, DCpointer stkdata);
+
 #ifdef __cplusplus
 }
 #endif