]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/db_asm.s
xnu-344.32.tar.gz
[apple/xnu.git] / osfmk / ppc / db_asm.s
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
de355530
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.
1c79356b 11 *
de355530
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
de355530
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25
26#include <debug.h>
27#include <ppc/asm.h>
28#include <ppc/proc_reg.h>
29#include <mach/ppc/vm_param.h>
30#include <assym.s>
31
de355530
A
32/* void
33 * db_phys_copy(src, dst, bytecount)
34 * vm_offset_t src;
35 * vm_offset_t dst;
36 * int bytecount
37 *
38 * This routine will copy bytecount bytes from physical address src to physical
39 * address dst.
40 */
41ENTRY(db_phys_copy, TAG_NO_FRAME_USED)
42
43 /* Switch off data translations */
44 mfmsr r6
45 rlwinm r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
46 rlwinm r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
47 rlwinm r7, r6, 0, MSR_DR_BIT+1, MSR_DR_BIT-1
48 mtmsr r7
49 isync /* Ensure data translations are off */
50
51 subi r3, r3, 4
52 subi r4, r4, 4
53
54 cmpwi r5, 3
55 ble- .L_db_phys_copy_bytes
56.L_db_phys_copy_loop:
57 lwz r0, 4(r3)
58 addi r3, r3, 4
59 subi r5, r5, 4
60 stw r0, 4(r4)
61 addi r4, r4, 4
62 cmpwi r5, 3
63 bgt+ .L_db_phys_copy_loop
64
65 /* If no leftover bytes, we're done now */
66 cmpwi r5, 0
67 beq+ .L_db_phys_copy_done
68
69.L_db_phys_copy_bytes:
70 addi r3, r3, 3
71 addi r4, r4, 3
72.L_db_phys_copy_byte_loop:
73 lbz r0, 1(r3)
74 addi r3, r3, 1
75 subi r5, r5, 1
76 stb r0, 1(r4)
77 addi r4, r4, 1
78 cmpwi r5, 0
79 bne+ .L_db_phys_copy_loop
80
81.L_db_phys_copy_done:
82 mtmsr r6 /* Restore original translations */
83 isync /* Ensure data translations are off */
84
85 blr
1c79356b
A
86
87/* void
88 * db_phys_cmp(src_a, src_b, bytecount)
89 * vm_offset_t src_a;
90 * vm_offset_t src_b;
91 * int bytecount
92 *
93 * This routine will compare bytecount bytes from physical address src_a and physical
94 * address src_b.
95 */
96
97 /* Switch off data translations */
98 mfmsr r6
de355530
A
99 rlwinm r6,r6,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
100 rlwinm r6,r6,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
101 rlwinm r7, r6, 0, MSR_DR_BIT+1, MSR_DR_BIT-1
1c79356b
A
102 mtmsr r7
103 isync /* Ensure data translations are off */
104
105 subi r3, r3, 4
106 subi r4, r4, 4
107
108 cmpwi r5, 3
109 ble- .L_db_phys_cmp_bytes
110.L_db_phys_cmp_loop:
111 lwz r0, 4(r3)
112 lwz r7, 4(r4)
113 addi r3, r3, 4
114 addi r4, r4, 4
115 subi r5, r5, 4
116 cmpw r0, r7
117 bne .L_db_phys_cmp_false
118 cmpwi r5, 3
119 bgt+ .L_db_phys_cmp_loop
120
121 /* If no leftover bytes, we're done now */
122 cmpwi r5, 0
123 beq+ .L_db_phys_cmp_true
124
125.L_db_phys_cmp_bytes:
126 addi r3, r3, 3
127 addi r4, r4, 3
128.L_db_phys_cmp_byte_loop:
129 lbz r0, 1(r3)
130 lbz r7, 1(r4)
131 addi r3, r3, 1
132 addi r4, r4, 1
133 subi r5, r5, 1
134 cmpw r0, r7
135 bne .L_db_phys_cmp_false
136 cmpwi r5, 0
137 bne+ .L_db_phys_cmp_loop
138
139.L_db_phys_cmp_true:
140 li r3, 1
141 b .L_db_phys_cmp_done
142
143.L_db_phys_cmp_false:
144 li r3, 0
145
146.L_db_phys_cmp_done:
147 mtmsr r6 /* Restore original translations */
148 isync /* Ensure data translations are off */
149
150 blr
151