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