]>
git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/systemcalls.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1997 Apple Computer, Inc.
25 * PowerPC Family: System Call handlers.
28 * 27-July-97 A. Ramesh
29 * Adopted for Common Core.
32 #include <mach/mach_types.h>
33 #include <mach/error.h>
35 #include <kern/syscall_sw.h>
38 #include <machdep/ppc/frame.h>
39 #include <machdep/ppc/thread.h>
40 #include <machdep/ppc/asm.h>
41 #include <machdep/ppc/proc_reg.h>
42 #include <machdep/ppc/trap.h>
43 #include <machdep/ppc/exception.h>
46 #define ERESTART -1 /* restart syscall */
47 #define EJUSTRETURN -2 /* don't modify regs, just return */
50 struct unix_syscallargs
{
53 int arg1
, arg2
,arg3
,arg4
,arg5
,arg6
,arg7
,arg8
,arg9
;
55 extern struct sysent
{ /* system call table */
56 int16_t sy_narg
; /* number of args */
57 int16_t sy_parallel
;/* can execute in parallel */
58 int32_t (*sy_call
)(); /* implementing function */
62 ** Function: unix_syscall
64 ** Inputs: pcb - pointer to Process Control Block
65 ** arg1 - arguments to mach system calls
87 struct ppc_saved_state
*regs
;
94 struct unix_syscallargs sarg
;
96 if (!USERMODE(pcb
->ss
.srr1
))
97 panic("unix_syscall");
100 thread
= current_thread();
104 ** Get index into sysent table
110 ** Set up call pointer
112 callp
= (code
>= nsysent
) ? &sysent
[63] : &sysent
[code
];
114 sarg
. flavor
= (callp
== sysent
): 1: 0;
124 set_bsduthreadargs(thread
,pcb
,&sarg
);
127 if (callp
->sy_narg
> 8)
128 panic("unix_syscall: max arg count exceeded");
132 /* r4 is volatile, if we set it to regs->r4 here the child
133 * will have parents r4 after execve */
136 error
= 0; /* Start with a good value */
139 ** the PPC runtime calls cerror after every unix system call, so
140 ** assume no error and adjust the "pc" to skip this call.
141 ** It will be set back to the cerror call if an error is detected.
144 vt
= get_bsduthreadarg(thread
);
145 p
= ((struct proc
*)get_bsdtask_info(current_task()));
146 error
= (*(callp
->sy_call
))(p
, (caddr_t
)vt
, rval
);
148 if (error
== ERESTART
) {
151 else if (error
!= EJUSTRETURN
) {
155 /* set the "pc" to execute cerror routine */
157 } else { /* (not error) */
162 /* else (error == EJUSTRETURN) { nothing } */
164 thread_exception_return();