Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: vdev_simdisk.s | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | .ident "@(#)vdev_simdisk.s 1.4 07/05/03 SMI" | |
50 | ||
51 | #ifdef CONFIG_DISK | |
52 | ||
53 | #include <sys/asm_linkage.h> | |
54 | #include <hypervisor.h> | |
55 | #include <asi.h> | |
56 | #include <mmu.h> | |
57 | ||
58 | #include <guest.h> | |
59 | #include <offsets.h> | |
60 | #include <util.h> | |
61 | #include <vdev_simdisk.h> | |
62 | ||
63 | ||
64 | /* | |
65 | * fake-disk read | |
66 | * | |
67 | * arg0 disk offset (%o0) | |
68 | * arg1 target real address (%o1) | |
69 | * arg2 size (%o2) | |
70 | * -- | |
71 | * ret0 status (%o0) | |
72 | * ret1 size (%o1) | |
73 | */ | |
74 | ENTRY_NP(hcall_disk_read) | |
75 | #ifndef SIMULATION | |
76 | ba herr_inval | |
77 | nop | |
78 | #endif | |
79 | GUEST_STRUCT(%g1) | |
80 | RA2PA_RANGE_CONV_UNK_SIZE(%g1, %o1, %o2, herr_noraddr, %g3, %g2) | |
81 | ! %g2 paddr | |
82 | ||
83 | set GUEST_DISK, %g3 | |
84 | add %g1, %g3, %g1 | |
85 | ! %g1 = diskp | |
86 | ||
87 | ldx [%g1 + DISK_SIZE], %g3 | |
88 | brnz,pt %g3, 1f | |
89 | cmp %o0, %g3 ! XXX this doesn't matter, just %o0+%o2 | |
90 | ||
91 | ldx [%g1 + DISK_PA], %g4 ! base of disk | |
92 | cmp %g4, -1 | |
93 | be,pn %xcc, herr_inval | |
94 | nop | |
95 | ||
96 | ld [%g4 + DISK_S2NBLK_OFFSET], %g5 ! read nblks from s2 | |
97 | sllx %g5, DISK_BLKSIZE_SHIFT, %g5 ! multiply by blocksize | |
98 | stx %g5, [%g1 + DISK_SIZE] ! store disk size | |
99 | mov %g5, %g3 | |
100 | ||
101 | cmp %o0, %g3 | |
102 | 1: bgeu,pn %xcc, herr_inval | |
103 | add %o0, %o2, %g4 | |
104 | cmp %g4, %g3 | |
105 | bgu,pn %xcc, herr_inval | |
106 | ldx [%g1 + DISK_PA], %g3 ! base of disk | |
107 | ||
108 | /* bcopy(%g3 + %o0, %g2, %o2) */ | |
109 | add %g3, %o0, %g1 | |
110 | ! %g2 already set up | |
111 | mov %o2, %g3 | |
112 | ba bcopy | |
113 | rd %pc, %g7 | |
114 | ||
115 | mov %o2, %o1 | |
116 | HCALL_RET(EOK) | |
117 | SET_SIZE(hcall_disk_read) | |
118 | ||
119 | /* | |
120 | * fake-disk write | |
121 | * | |
122 | * arg0 disk offset (%o0) | |
123 | * arg1 source real address (%o1) | |
124 | * arg2 size (%o2) | |
125 | * -- | |
126 | * ret0 status (%o0) | |
127 | * ret1 size (%o1) | |
128 | */ | |
129 | ENTRY_NP(hcall_disk_write) | |
130 | #ifndef SIMULATION | |
131 | ba herr_inval | |
132 | nop | |
133 | #endif | |
134 | GUEST_STRUCT(%g1) | |
135 | RA2PA_RANGE_CONV_UNK_SIZE(%g1, %o1, %o2, herr_noraddr, %g2, %g3) | |
136 | ! %g3 paddr | |
137 | ||
138 | set GUEST_DISK, %g2 | |
139 | add %g1, %g2, %g1 | |
140 | ! %g1 = diskp | |
141 | ||
142 | ldx [%g1 + DISK_SIZE], %g2 | |
143 | brnz,pt %g2, 1f | |
144 | cmp %o0, %g2 | |
145 | ||
146 | ldx [%g1 + DISK_PA], %g4 ! base of disk | |
147 | cmp %g4, -1 | |
148 | be,pn %xcc, herr_inval | |
149 | nop | |
150 | ||
151 | ld [%g4 + DISK_S2NBLK_OFFSET], %g5 ! read nblks from s2 | |
152 | sllx %g5, DISK_BLKSIZE_SHIFT, %g5 ! multiply by blocksize | |
153 | stx %g5, [%g1 + DISK_SIZE] ! store disk size | |
154 | mov %g5, %g2 | |
155 | ||
156 | cmp %o0, %g2 | |
157 | 1: bgeu,pn %xcc, herr_inval | |
158 | add %o0, %o2, %g4 | |
159 | cmp %g4, %g2 | |
160 | bgu,pn %xcc, herr_inval | |
161 | ldx [%g1 + DISK_PA], %g2 ! base of disk | |
162 | ||
163 | /* bcopy(%g3, %g2 + %o0, %o2) */ | |
164 | mov %g3, %g1 | |
165 | add %g2, %o0, %g2 | |
166 | mov %o2, %g3 | |
167 | ba bcopy | |
168 | rd %pc, %g7 | |
169 | ||
170 | mov %o2, %o1 | |
171 | HCALL_RET(EOK) | |
172 | SET_SIZE(hcall_disk_write) | |
173 | ||
174 | #endif /* CONFIG_DISK */ |