]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/misc.c
xnu-792.6.56.tar.gz
[apple/xnu.git] / osfmk / ppc / misc.c
1 /*
2 * Copyright (c) 2000 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 /*
24 * @OSF_COPYRIGHT@
25 */
26 #if 0 // dead code
27 #include <debug.h>
28 #include <mach_debug.h>
29
30 #include <mach/ppc/thread_status.h>
31 #include <mach/vm_types.h>
32 #include <kern/thread.h>
33 #include <kern/misc_protos.h>
34 #include <ppc/proc_reg.h>
35 #include <ppc/pmap.h>
36 #include <ppc/misc_protos.h>
37 #include <ppc/exception.h>
38
39 /*
40 * copyin/out_multiple - the assembler copyin/out functions jump to C for
41 * help when the copyin lies over a segment boundary. The C breaks
42 * down the copy into two sub-copies and re-calls the assembler with
43 * these sub-copies. Very rare occurrance. Warning: These functions are
44 * called whilst active_thread->thread_recover is still set.
45 */
46
47 extern boolean_t copyin_multiple(const char *src,
48 char *dst,
49 vm_size_t count);
50
51 boolean_t copyin_multiple(const char *src,
52 char *dst,
53 vm_size_t count)
54 {
55 const char *midpoint;
56 vm_size_t first_count;
57 boolean_t first_result;
58
59 /* Assert that we've been called because of a segment boundary,
60 * this function is more expensive than the assembler, and should
61 * only be called in this difficult case.
62 */
63 assert(((vm_offset_t)src & 0xF0000000) !=
64 ((vm_offset_t)(src + count -1) & 0xF0000000));
65
66 /* TODO NMGS define sensible constants for segments, and apply
67 * to C and assembler (assembler is much harder)
68 */
69 midpoint = (const char*) ((vm_offset_t)(src + count) & 0xF0000000);
70 first_count = (midpoint - src);
71
72 first_result = copyin(CAST_USER_ADDR_T(src), dst, first_count);
73
74 /* If there was an error, stop now and return error */
75 if (first_result != 0)
76 return first_result;
77
78 /* otherwise finish the job and return result */
79 return copyin(CAST_USER_ADDR_T(midpoint), dst + first_count, count-first_count);
80 }
81
82 extern int copyout_multiple(const char *src, char *dst, vm_size_t count);
83
84 int copyout_multiple(const char *src, char *dst, vm_size_t count)
85 {
86 char *midpoint;
87 vm_size_t first_count;
88 boolean_t first_result;
89
90 /* Assert that we've been called because of a segment boundary,
91 * this function is more expensive than the assembler, and should
92 * only be called in this difficult case. For copyout, the
93 * segment boundary is on the dst
94 */
95 assert(((vm_offset_t)dst & 0xF0000000) !=
96 ((vm_offset_t)(dst + count - 1) & 0xF0000000));
97
98 /* TODO NMGS define sensible constants for segments, and apply
99 * to C and assembler (assembler is much harder)
100 */
101 midpoint = (char *) ((vm_offset_t)(dst + count) & 0xF0000000);
102 first_count = (midpoint - dst);
103
104 first_result = copyout(src, CAST_USER_ADDR_T(dst), first_count);
105
106 /* If there was an error, stop now and return error */
107 if (first_result != 0)
108 return first_result;
109
110 /* otherwise finish the job and return result */
111
112 return copyout(src + first_count, CAST_USER_ADDR_T(midpoint), count-first_count);
113 }
114 #endif // dead code
115