]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/ppc/stubs.c
xnu-517.12.7.tar.gz
[apple/xnu.git] / bsd / dev / ppc / stubs.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * Copyright (c) 1997 by Apple Computer, Inc., all rights reserved
24 * Copyright (c) 1993 NeXT Computer, Inc.
25 *
26 */
27
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/buf.h>
31 #include <sys/ioctl.h>
32 #include <sys/tty.h>
33 #include <sys/conf.h>
34 #include <sys/proc.h>
35 #include <sys/user.h>
36 #include <kern/thread.h>
37 #include <kern/thread_act.h>
38 #include <kern/task.h>
39 #include <vm/vm_map.h>
40
41
42 /*
43 * copy a null terminated string from one point to another in
44 * the kernel address space.
45 * - no access checks are performed.
46 * - if the end of string isn't found before
47 * maxlen bytes are copied, return ENAMETOOLONG,
48 * indicating an incomplete copy.
49 * - otherwise, return 0, indicating success.
50 * the number of bytes copied is always returned in lencopied.
51 */
52 /* from ppc/fault_copy.c -Titan1T4 VERSION */
53 int
54 copystr(vfrom, vto, maxlen, lencopied)
55 register void * vfrom, *vto;
56 size_t maxlen, *lencopied;
57 {
58 register unsigned l;
59 int error;
60 caddr_t from, to;
61
62 from = vfrom;
63 to = vto;
64 for (l = 0; l < maxlen; l++)
65 if ((*to++ = *from++) == '\0') {
66 if (lencopied)
67 *lencopied = l + 1;
68 return 0;
69 }
70 if (lencopied)
71 *lencopied = maxlen;
72 return ENAMETOOLONG;
73 }
74
75 int copywithin(src, dst, count)
76 void * src, *dst;
77 size_t count;
78 {
79 bcopy(src,dst,count);
80 return 0;
81 }
82
83 struct unix_syscallargs {
84 int flavor;
85 int r3;
86 int arg1, arg2,arg3,arg4,arg5,arg6,arg7;
87 };
88
89 set_bsduthreadargs(thread_t th, void * pcb, struct unix_syscallargs * sarg)
90 {
91 struct uthread * ut;
92
93 ut = get_bsdthread_info(th);
94 ut->uu_ar0 = (int *)pcb;
95
96 if (sarg->flavor)
97 {
98 ut->uu_arg[0] = sarg->arg1;
99 ut->uu_arg[1] = sarg->arg2;
100 ut->uu_arg[2] = sarg->arg3;
101 ut->uu_arg[3] = sarg->arg4;
102 ut->uu_arg[4] = sarg->arg5;
103 ut->uu_arg[5] = sarg->arg6;
104 ut->uu_arg[7] = sarg->arg7;
105 }
106 else
107 {
108 ut->uu_arg[0] = sarg->r3;
109 ut->uu_arg[1] = sarg->arg1;
110 ut->uu_arg[2] = sarg->arg2;
111 ut->uu_arg[3] = sarg->arg3;
112 ut->uu_arg[4] = sarg->arg4;
113 ut->uu_arg[5] = sarg->arg5;
114 ut->uu_arg[6] = sarg->arg6;
115 ut->uu_arg[7] = sarg->arg7;
116 }
117
118 return(1);
119 }
120
121 void *
122 get_bsduthreadarg(thread_t th)
123 {
124 struct uthread *ut;
125 ut = get_bsdthread_info(th);
126 return((void *)(ut->uu_arg));
127 }
128
129 int *
130 get_bsduthreadrval(thread_act_t th)
131 {
132 struct uthread *ut;
133 ut = get_bsdthread_info(th);
134 return(&ut->uu_rval[0]);
135 }
136