]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/misc.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / osfmk / ppc / misc.c
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * @OSF_COPYRIGHT@
32 */
33 #if 0 // dead code
34 #include <debug.h>
35 #include <mach_debug.h>
36
37 #include <mach/ppc/thread_status.h>
38 #include <mach/vm_types.h>
39 #include <kern/thread.h>
40 #include <kern/misc_protos.h>
41 #include <ppc/proc_reg.h>
42 #include <ppc/pmap.h>
43 #include <ppc/misc_protos.h>
44 #include <ppc/exception.h>
45
46 /*
47 * copyin/out_multiple - the assembler copyin/out functions jump to C for
48 * help when the copyin lies over a segment boundary. The C breaks
49 * down the copy into two sub-copies and re-calls the assembler with
50 * these sub-copies. Very rare occurrance. Warning: These functions are
51 * called whilst active_thread->thread_recover is still set.
52 */
53
54 extern boolean_t copyin_multiple(const char *src,
55 char *dst,
56 vm_size_t count);
57
58 boolean_t copyin_multiple(const char *src,
59 char *dst,
60 vm_size_t count)
61 {
62 const char *midpoint;
63 vm_size_t first_count;
64 boolean_t first_result;
65
66 /* Assert that we've been called because of a segment boundary,
67 * this function is more expensive than the assembler, and should
68 * only be called in this difficult case.
69 */
70 assert(((vm_offset_t)src & 0xF0000000) !=
71 ((vm_offset_t)(src + count -1) & 0xF0000000));
72
73 /* TODO NMGS define sensible constants for segments, and apply
74 * to C and assembler (assembler is much harder)
75 */
76 midpoint = (const char*) ((vm_offset_t)(src + count) & 0xF0000000);
77 first_count = (midpoint - src);
78
79 first_result = copyin(CAST_USER_ADDR_T(src), dst, first_count);
80
81 /* If there was an error, stop now and return error */
82 if (first_result != 0)
83 return first_result;
84
85 /* otherwise finish the job and return result */
86 return copyin(CAST_USER_ADDR_T(midpoint), dst + first_count, count-first_count);
87 }
88
89 extern int copyout_multiple(const char *src, char *dst, vm_size_t count);
90
91 int copyout_multiple(const char *src, char *dst, vm_size_t count)
92 {
93 char *midpoint;
94 vm_size_t first_count;
95 boolean_t first_result;
96
97 /* Assert that we've been called because of a segment boundary,
98 * this function is more expensive than the assembler, and should
99 * only be called in this difficult case. For copyout, the
100 * segment boundary is on the dst
101 */
102 assert(((vm_offset_t)dst & 0xF0000000) !=
103 ((vm_offset_t)(dst + count - 1) & 0xF0000000));
104
105 /* TODO NMGS define sensible constants for segments, and apply
106 * to C and assembler (assembler is much harder)
107 */
108 midpoint = (char *) ((vm_offset_t)(dst + count) & 0xF0000000);
109 first_count = (midpoint - dst);
110
111 first_result = copyout(src, CAST_USER_ADDR_T(dst), first_count);
112
113 /* If there was an error, stop now and return error */
114 if (first_result != 0)
115 return first_result;
116
117 /* otherwise finish the job and return result */
118
119 return copyout(src + first_count, CAST_USER_ADDR_T(midpoint), count-first_count);
120 }
121 #endif // dead code
122