aboutsummaryrefslogtreecommitdiff
path: root/arch/casiowin/libfxsys/include/asm.h
blob: 4c2bebb968238360a07c52ea11bdf3f34b71ff0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ****************************************************************************
 * libfxsys' assembly utilities.
 * Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 * ************************************************************************* */
/* Make the syscall entry */

# define ENTRY(_NAME) \
.section .text; \
.global _NAME; \
.type _NAME, @function; \
.align 2; \
_NAME:

/* Make the bare syscall, using the `sc_addr` symbol. */

# define SYSCALL_BARE(_NAME, _X) \
ENTRY(_NAME) \
	mov.l sc_addr, r2; \
	mov.l 1f, r0; \
	jmp @r2; \
	nop; \
1: .long _X

/* Define the local `sc_addr` local symbol, which is where the syscall table
 * address is. */

# define SYSCALL_ADDRESS \
sc_addr: .long 0x80010070

/* Define a syscall, defining and using the `sc_addr` local symbol. */

# define SYSCALL(_NAME, _X) \
SYSCALL_BARE(_NAME, _X); \
SYSCALL_ADDRESS