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