]> git.saurik.com Git - apple/libc.git/blob - ppc/sys/SYS.h
Libc-498.tar.gz
[apple/libc.git] / ppc / sys / SYS.h
1 /*
2 * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /* Copyright (c) 1992 NeXT Computer, Inc. All rights reserved.
24 *
25 * File: SYS.h
26 *
27 * Definition of the user side of the UNIX system call interface
28 * for M98K.
29 *
30 * Errors are flagged by the location of the trap return (ie., which
31 * instruction is executed upon rfi):
32 *
33 * SC PC + 4: Error (typically branch to cerror())
34 * SC PC + 8: Success
35 *
36 * HISTORY
37 * 18-Nov-92 Ben Fathi (benf@next.com)
38 * Ported to m98k.
39 *
40 * 9-Jan-92 Peter King (king@next.com)
41 * Created.
42 */
43
44 /*
45 * Header files.
46 */
47 #include <architecture/ppc/mode_independent_asm.h>
48 #import <sys/syscall.h>
49
50 /* From rhapsody kernel mach/ppc/syscall_sw.h */
51 #define kernel_trap_args_0
52 #define kernel_trap_args_1
53 #define kernel_trap_args_2
54 #define kernel_trap_args_3
55 #define kernel_trap_args_4
56 #define kernel_trap_args_5
57 #define kernel_trap_args_6
58 #define kernel_trap_args_7
59
60 /*
61 * simple_kernel_trap -- Mach system calls with 8 or less args
62 * Args are passed in a0 - a7, system call number in r0.
63 * Do a "sc" instruction to enter kernel.
64 */
65 #define simple_kernel_trap(trap_name, trap_number) \
66 .globl _##trap_name @\
67 _##trap_name: @\
68 li r0,trap_number @\
69 sc @\
70 blr
71
72 #define kernel_trap_0(trap_name,trap_number) \
73 simple_kernel_trap(trap_name,trap_number)
74
75 #define kernel_trap_1(trap_name,trap_number) \
76 simple_kernel_trap(trap_name,trap_number)
77
78 #define kernel_trap_2(trap_name,trap_number) \
79 simple_kernel_trap(trap_name,trap_number)
80
81 #define kernel_trap_3(trap_name,trap_number) \
82 simple_kernel_trap(trap_name,trap_number)
83
84 #define kernel_trap_4(trap_name,trap_number) \
85 simple_kernel_trap(trap_name,trap_number)
86
87 #define kernel_trap_5(trap_name,trap_number) \
88 simple_kernel_trap(trap_name,trap_number)
89
90 #define kernel_trap_6(trap_name,trap_number) \
91 simple_kernel_trap(trap_name,trap_number)
92
93 #define kernel_trap_7(trap_name,trap_number) \
94 simple_kernel_trap(trap_name,trap_number)
95
96 #define kernel_trap_8(trap_name,trap_number) \
97 simple_kernel_trap(trap_name,trap_number)
98
99 #define kernel_trap_9(trap_name,trap_number) \
100 simple_kernel_trap(trap_name,trap_number)
101
102 /* End of rhapsody kernel mach/ppc/syscall_sw.h */
103
104 /*
105 * Macros.
106 */
107
108 /*
109 * This is the same as SYSCALL, but it can call an alternate error
110 * return function. It's generic to support potential future callers.
111 */
112 #define SYSCALL_ERR(name, nargs, error_ret) \
113 .globl error_ret @\
114 MI_ENTRY_POINT(_##name) @\
115 kernel_trap_args_##nargs @\
116 li r0,SYS_##name @\
117 sc @\
118 b 1f @\
119 blr @\
120 1: MI_BRANCH_EXTERNAL(error_ret)
121
122 #define SYSCALL(name, nargs) \
123 .globl cerror @\
124 MI_ENTRY_POINT(_##name) @\
125 kernel_trap_args_##nargs @\
126 li r0,SYS_##name @\
127 sc @\
128 b 1f @\
129 blr @\
130 1: MI_BRANCH_EXTERNAL(cerror)
131
132
133 #define SYSCALL_NONAME(name, nargs) \
134 .globl cerror @\
135 kernel_trap_args_##nargs @\
136 li r0,SYS_##name @\
137 sc @\
138 b 1f @\
139 b 2f @\
140 1: MI_BRANCH_EXTERNAL(cerror) @\
141 2:
142
143
144 #define PSEUDO(pseudo, name, nargs) \
145 .globl _##pseudo @\
146 .text @\
147 .align 2 @\
148 _##pseudo: @\
149 SYSCALL_NONAME(name, nargs)
150
151 #define PSEUDO_ERR(pseudo, name, nargs, error_ret) \
152 .globl _##pseudo @\
153 .globl error_ret @\
154 .text @\
155 .align 2 @\
156 _##pseudo: @\
157 kernel_trap_args_##nargs @\
158 li r0,SYS_##name @\
159 sc @\
160 b 1f @\
161 blr @\
162 1: MI_BRANCH_EXTERNAL(error_ret)
163
164
165 #undef END
166 #import <mach/ppc/syscall_sw.h>