tools/include/nolibc/arch-parisc.h

Source file repositories/reference/linux-study-clean/tools/include/nolibc/arch-parisc.h

File Facts

System
Linux kernel
Corpus path
tools/include/nolibc/arch-parisc.h
Extension
.h
Size
9522 bytes
Lines
186
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef _NOLIBC_ARCH_PARISC_H
#define _NOLIBC_ARCH_PARISC_H

#if defined(__LP64__)
#error 64-bit not supported
#endif

#include "compiler.h"
#include "crt.h"

/* Syscalls for parisc :
 *   - syscall number is passed in r20
 *   - arguments are in r26 to r21
 *   - the system call is performed by calling "ble 0x100(%sr2, %r0)",
 *     the instruction after that is in the delay slot and executed before
 *     the jump to 0x100 actually happens, use it to load the syscall number
 *   - syscall return comes in r28
 *   - the arguments are cast to long and assigned into the target
 *     registers which are then simply passed as registers to the asm code,
 *     so that we don't have to experience issues with register constraints.
 */

#define _NOLIBC_SYSCALL_CLOBBERLIST \
	"memory", "%r1", "%r2", "%r4", "%r20", "%r29", "%r31"

#define __nolibc_syscall0(num)                                                \
({                                                                            \
	register long _ret __asm__ ("r28");                                   \
									      \
	__asm__ volatile (                                                    \
		"ble 0x100(%%sr2, %%r0)\n\t"                                  \
		"copy %1, %%r20\n\t"                                          \
		: "=r"(_ret)                                                  \
		: "r"(num)                                                    \
		: _NOLIBC_SYSCALL_CLOBBERLIST,                                \
		  "%r21", "%r22", "%r23", "%r24", "%r25", "%r26"              \
	);                                                                    \
	_ret;                                                                 \
})

#define __nolibc_syscall1(num, arg1)                                          \
({                                                                            \
	register long _ret __asm__ ("r28");                                   \
	register long _arg1 __asm__ ("r26") = (long)(arg1);		      \
									      \
	__asm__ volatile (                                                    \
		"ble 0x100(%%sr2, %%r0)\n\t"                                  \
		"copy %2, %%r20\n\t"                                          \
		: "=r"(_ret),                                                 \
		  "+r"(_arg1)                                                 \
		: "r"(num)                                                    \
		: _NOLIBC_SYSCALL_CLOBBERLIST,                                \
		  "%r21", "%r22", "%r23", "%r24", "%r25"                      \
	);                                                                    \
	_ret;                                                                 \
})

#define __nolibc_syscall2(num, arg1, arg2)                                    \
({                                                                            \
	register long _ret __asm__ ("r28");                                   \
	register long _arg1 __asm__ ("r26") = (long)(arg1);		      \
	register long _arg2 __asm__ ("r25") = (long)(arg2);		      \
									      \
	__asm__ volatile (                                                    \
		"ble 0x100(%%sr2, %%r0)\n\t"                                  \
		"copy %3, %%r20\n\t"                                          \
		: "=r"(_ret),                                                 \
		  "+r"(_arg1), "+r"(_arg2)                                    \
		: "r"(num)                                                    \
		: _NOLIBC_SYSCALL_CLOBBERLIST,                                \
		  "%r21", "%r22", "%r23", "%r24"                              \
	);                                                                    \
	_ret;                                                                 \
})

#define __nolibc_syscall3(num, arg1, arg2, arg3)                              \
({                                                                            \
	register long _ret __asm__ ("r28");                                   \
	register long _arg1 __asm__ ("r26") = (long)(arg1);		      \
	register long _arg2 __asm__ ("r25") = (long)(arg2);		      \
	register long _arg3 __asm__ ("r24") = (long)(arg3);		      \
									      \
	__asm__ volatile (                                                    \
		"ble 0x100(%%sr2, %%r0)\n\t"                                  \
		"copy %4, %%r20\n\t"                                          \
		: "=r"(_ret),                                                 \
		  "+r"(_arg1), "+r"(_arg2), "+r"(_arg3)                       \
		: "r"(num)                                                    \
		: _NOLIBC_SYSCALL_CLOBBERLIST,                                \
		  "%r21", "%r22", "%r23"                                      \

Annotation

Implementation Notes