]>
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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 #include <mach_debug.h>
31 #include <mach/ppc/thread_status.h>
32 #include <mach/vm_types.h>
33 #include <kern/thread.h>
34 #include <kern/misc_protos.h>
35 #include <ppc/proc_reg.h>
37 #include <ppc/misc_protos.h>
38 #include <ppc/exception.h>
41 * copyin/out_multiple - the assembler copyin/out functions jump to C for
42 * help when the copyin lies over a segment boundary. The C breaks
43 * down the copy into two sub-copies and re-calls the assembler with
44 * these sub-copies. Very rare occurrance. Warning: These functions are
45 * called whilst active_thread->thread_recover is still set.
48 extern boolean_t
copyin_multiple(const char *src
,
52 boolean_t
copyin_multiple(const char *src
,
57 vm_size_t first_count
;
58 boolean_t first_result
;
60 /* Assert that we've been called because of a segment boundary,
61 * this function is more expensive than the assembler, and should
62 * only be called in this difficult case.
64 assert(((vm_offset_t
)src
& 0xF0000000) !=
65 ((vm_offset_t
)(src
+ count
-1) & 0xF0000000));
67 /* TODO NMGS define sensible constants for segments, and apply
68 * to C and assembler (assembler is much harder)
70 midpoint
= (const char*) ((vm_offset_t
)(src
+ count
) & 0xF0000000);
71 first_count
= (midpoint
- src
);
73 first_result
= copyin(src
, dst
, first_count
);
75 /* If there was an error, stop now and return error */
76 if (first_result
!= 0)
79 /* otherwise finish the job and return result */
80 return copyin(midpoint
, dst
+ first_count
, count
-first_count
);
83 extern int copyout_multiple(const char *src
, char *dst
, vm_size_t count
);
85 int copyout_multiple(const char *src
, char *dst
, vm_size_t count
)
88 vm_size_t first_count
;
89 boolean_t first_result
;
91 /* Assert that we've been called because of a segment boundary,
92 * this function is more expensive than the assembler, and should
93 * only be called in this difficult case. For copyout, the
94 * segment boundary is on the dst
96 assert(((vm_offset_t
)dst
& 0xF0000000) !=
97 ((vm_offset_t
)(dst
+ count
- 1) & 0xF0000000));
99 /* TODO NMGS define sensible constants for segments, and apply
100 * to C and assembler (assembler is much harder)
102 midpoint
= (char *) ((vm_offset_t
)(dst
+ count
) & 0xF0000000);
103 first_count
= (midpoint
- dst
);
105 first_result
= copyout(src
, dst
, first_count
);
107 /* If there was an error, stop now and return error */
108 if (first_result
!= 0)
111 /* otherwise finish the job and return result */
113 return copyout(src
+ first_count
, midpoint
, count
-first_count
);