]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000-2004 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/ioctl.h> | |
31 | #include <sys/tty.h> | |
32 | #include <sys/conf.h> | |
33 | #include <sys/proc.h> | |
34 | #include <sys/user.h> | |
35 | #include <kern/thread.h> | |
36 | #include <kern/task.h> | |
37 | #include <vm/vm_map.h> | |
38 | ||
39 | ||
40 | /* | |
41 | * copy a null terminated string from one point to another in | |
42 | * the kernel address space. | |
43 | * - no access checks are performed. | |
44 | * - if the end of string isn't found before | |
45 | * maxlen bytes are copied, return ENAMETOOLONG, | |
46 | * indicating an incomplete copy. | |
47 | * - otherwise, return 0, indicating success. | |
48 | * the number of bytes copied is always returned in lencopied. | |
49 | */ | |
50 | /* from ppc/fault_copy.c -Titan1T4 VERSION */ | |
51 | int | |
52 | copystr(const void *vfrom, void *vto, size_t maxlen, size_t *lencopied) | |
53 | { | |
54 | register unsigned l; | |
55 | caddr_t from, to; | |
56 | ||
57 | from = vfrom; | |
58 | to = vto; | |
59 | for (l = 0; l < maxlen; l++) | |
60 | if ((*to++ = *from++) == '\0') { | |
61 | if (lencopied) | |
62 | *lencopied = l + 1; | |
63 | return 0; | |
64 | } | |
65 | if (lencopied) | |
66 | *lencopied = maxlen; | |
67 | return ENAMETOOLONG; | |
68 | } | |
69 | ||
70 | int copywithin(src, dst, count) | |
71 | void * src, *dst; | |
72 | size_t count; | |
73 | { | |
74 | bcopy(src,dst,count); | |
75 | return 0; | |
76 | } | |
77 | ||
78 | void * | |
79 | get_bsduthreadarg(thread_t th) | |
80 | { | |
81 | struct uthread *ut; | |
82 | ut = get_bsdthread_info(th); | |
83 | return((void *)(ut->uu_arg)); | |
84 | } | |
85 | ||
86 | int * | |
87 | get_bsduthreadrval(thread_t th) | |
88 | { | |
89 | struct uthread *ut; | |
90 | ut = get_bsdthread_info(th); | |
91 | return(&ut->uu_rval[0]); | |
92 | } | |
93 |