]>
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_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
21 * @APPLE_LICENSE_HEADER_END@
28 #include <mach_debug.h>
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>
36 #include <ppc/misc_protos.h>
37 #include <ppc/exception.h>
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.
47 extern boolean_t
copyin_multiple(const char *src
,
51 boolean_t
copyin_multiple(const char *src
,
56 vm_size_t first_count
;
57 boolean_t first_result
;
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.
63 assert(((vm_offset_t
)src
& 0xF0000000) !=
64 ((vm_offset_t
)(src
+ count
-1) & 0xF0000000));
66 /* TODO NMGS define sensible constants for segments, and apply
67 * to C and assembler (assembler is much harder)
69 midpoint
= (const char*) ((vm_offset_t
)(src
+ count
) & 0xF0000000);
70 first_count
= (midpoint
- src
);
72 first_result
= copyin(CAST_USER_ADDR_T(src
), dst
, first_count
);
74 /* If there was an error, stop now and return error */
75 if (first_result
!= 0)
78 /* otherwise finish the job and return result */
79 return copyin(CAST_USER_ADDR_T(midpoint
), dst
+ first_count
, count
-first_count
);
82 extern int copyout_multiple(const char *src
, char *dst
, vm_size_t count
);
84 int copyout_multiple(const char *src
, char *dst
, vm_size_t count
)
87 vm_size_t first_count
;
88 boolean_t first_result
;
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
95 assert(((vm_offset_t
)dst
& 0xF0000000) !=
96 ((vm_offset_t
)(dst
+ count
- 1) & 0xF0000000));
98 /* TODO NMGS define sensible constants for segments, and apply
99 * to C and assembler (assembler is much harder)
101 midpoint
= (char *) ((vm_offset_t
)(dst
+ count
) & 0xF0000000);
102 first_count
= (midpoint
- dst
);
104 first_result
= copyout(src
, CAST_USER_ADDR_T(dst
), first_count
);
106 /* If there was an error, stop now and return error */
107 if (first_result
!= 0)
110 /* otherwise finish the job and return result */
112 return copyout(src
+ first_count
, CAST_USER_ADDR_T(midpoint
), count
-first_count
);