tools/include/nolibc/arch-powerpc.h

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

File Facts

System
Linux kernel
Corpus path
tools/include/nolibc/arch-powerpc.h
Extension
.h
Size
11569 bytes
Lines
234
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_POWERPC_H
#define _NOLIBC_ARCH_POWERPC_H

#include <linux/unistd.h>

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

/* Syscalls for PowerPC :
 *   - stack is 16-byte aligned
 *   - syscall number is passed in r0
 *   - arguments are in r3, r4, r5, r6, r7, r8, r9
 *   - the system call is performed by calling "sc"
 *   - syscall return comes in r3, and the summary overflow bit is checked
 *     to know if an error occurred, in which case errno is in r3.
 *   - 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", "cr0", "r12", "r11", "r10", "r9"

#define __nolibc_syscall0(num)                                               \
({                                                                           \
	register long _ret  __asm__ ("r3");                                  \
	register long _num  __asm__ ("r0") = (num);                          \
									     \
	__asm__ volatile (                                                   \
		"	sc\n"                                                \
		"	bns+ 1f\n"                                           \
		"	neg  %0, %0\n"                                       \
		"1:\n"                                                       \
		: "=r"(_ret), "+r"(_num)                                     \
		:                                                            \
		: _NOLIBC_SYSCALL_CLOBBERLIST, "r8", "r7", "r6", "r5", "r4"  \
	);                                                                   \
	_ret;                                                                \
})

#define __nolibc_syscall1(num, arg1)                                         \
({                                                                           \
	register long _ret  __asm__ ("r3");                                  \
	register long _num  __asm__ ("r0") = (num);                          \
	register long _arg1 __asm__ ("r3") = (long)(arg1);                   \
									     \
	__asm__ volatile (                                                   \
		"	sc\n"                                                \
		"	bns+ 1f\n"                                           \
		"	neg  %0, %0\n"                                       \
		"1:\n"                                                       \
		: "=r"(_ret), "+r"(_num)                                     \
		: "0"(_arg1)                                                 \
		: _NOLIBC_SYSCALL_CLOBBERLIST, "r8", "r7", "r6", "r5", "r4"  \
	);                                                                   \
	_ret;                                                                \
})


#define __nolibc_syscall2(num, arg1, arg2)                                   \
({                                                                           \
	register long _ret  __asm__ ("r3");                                  \
	register long _num  __asm__ ("r0") = (num);                          \
	register long _arg1 __asm__ ("r3") = (long)(arg1);                   \
	register long _arg2 __asm__ ("r4") = (long)(arg2);                   \
									     \
	__asm__ volatile (                                                   \
		"	sc\n"                                                \
		"	bns+ 1f\n"                                           \
		"	neg  %0, %0\n"                                       \
		"1:\n"                                                       \
		: "=r"(_ret), "+r"(_num), "+r"(_arg2)                        \
		: "0"(_arg1)                                                 \
		: _NOLIBC_SYSCALL_CLOBBERLIST, "r8", "r7", "r6", "r5"        \
	);                                                                   \
	_ret;                                                                \
})


#define __nolibc_syscall3(num, arg1, arg2, arg3)                             \
({                                                                           \
	register long _ret  __asm__ ("r3");                                  \
	register long _num  __asm__ ("r0") = (num);                          \
	register long _arg1 __asm__ ("r3") = (long)(arg1);                   \
	register long _arg2 __asm__ ("r4") = (long)(arg2);                   \
	register long _arg3 __asm__ ("r5") = (long)(arg3);                   \
									     \
	__asm__ volatile (                                                   \
		"	sc\n"                                                \

Annotation

Implementation Notes