]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/misc.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
35 #include <mach_debug.h>
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>
43 #include <ppc/misc_protos.h>
44 #include <ppc/exception.h>
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.
54 extern boolean_t
copyin_multiple(const char *src
,
58 boolean_t
copyin_multiple(const char *src
,
63 vm_size_t first_count
;
64 boolean_t first_result
;
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.
70 assert(((vm_offset_t
)src
& 0xF0000000) !=
71 ((vm_offset_t
)(src
+ count
-1) & 0xF0000000));
73 /* TODO NMGS define sensible constants for segments, and apply
74 * to C and assembler (assembler is much harder)
76 midpoint
= (const char*) ((vm_offset_t
)(src
+ count
) & 0xF0000000);
77 first_count
= (midpoint
- src
);
79 first_result
= copyin(CAST_USER_ADDR_T(src
), dst
, first_count
);
81 /* If there was an error, stop now and return error */
82 if (first_result
!= 0)
85 /* otherwise finish the job and return result */
86 return copyin(CAST_USER_ADDR_T(midpoint
), dst
+ first_count
, count
-first_count
);
89 extern int copyout_multiple(const char *src
, char *dst
, vm_size_t count
);
91 int copyout_multiple(const char *src
, char *dst
, vm_size_t count
)
94 vm_size_t first_count
;
95 boolean_t first_result
;
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
102 assert(((vm_offset_t
)dst
& 0xF0000000) !=
103 ((vm_offset_t
)(dst
+ count
- 1) & 0xF0000000));
105 /* TODO NMGS define sensible constants for segments, and apply
106 * to C and assembler (assembler is much harder)
108 midpoint
= (char *) ((vm_offset_t
)(dst
+ count
) & 0xF0000000);
109 first_count
= (midpoint
- dst
);
111 first_result
= copyout(src
, CAST_USER_ADDR_T(dst
), first_count
);
113 /* If there was an error, stop now and return error */
114 if (first_result
!= 0)
117 /* otherwise finish the job and return result */
119 return copyout(src
+ first_count
, CAST_USER_ADDR_T(midpoint
), count
-first_count
);