Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/i86pc/os/biosdisk.c
+++ new/usr/src/uts/i86pc/os/biosdisk.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 #include <sys/types.h>
27 27 #include <sys/param.h>
28 28 #include <sys/controlregs.h>
29 29 #include <sys/bootconf.h>
30 30 #include <sys/bootvfs.h>
31 31 #include <sys/bootregs.h>
32 32 #include <sys/bootconf.h>
33 33 #include <sys/conf.h>
34 34 #include <sys/promif.h>
35 35 #include <sys/ddi.h>
36 36 #include <sys/sunddi.h>
37 37 #include <sys/sunndi.h>
38 38 #include <sys/biosdisk.h>
39 39 #include <sys/psw.h>
40 40 #if defined(__xpv)
41 41 #include <sys/hypervisor.h>
42 42 #endif
43 43
44 44 extern int prom_debug;
45 45
46 46 /* hard code realmode memory address for now */
47 47 #define BIOS_RES_BUFFER_ADDR 0x7000
48 48
49 49 #define BIOSDEV_NUM 8
50 50 #define STARTING_DRVNUM 0x80
51 51 #define FP_OFF(fp) (((uintptr_t)(fp)) & 0xFFFF)
52 52 #define FP_SEG(fp) ((((uintptr_t)(fp)) >> 16) & 0xFFFF)
53 53
54 54 #ifdef DEBUG
55 55 int biosdebug = 0;
56 56 #define dprintf(fmt) \
57 57 if (biosdebug) \
58 58 prom_printf fmt
59 59 #else
60 60 #define dprintf(fmt)
61 61 #endif
62 62
63 63 biosdev_data_t biosdev_info[BIOSDEV_NUM]; /* from 0x80 to 0x87 */
64 64 int dobiosdev = 1;
65 65
66 66
67 67 static int bios_check_extension_present(uchar_t);
68 68 static int get_dev_params(uchar_t);
69 69 static int read_firstblock(uchar_t drivenum);
70 70 static int drive_present(uchar_t drivenum);
71 71 static void reset_disk(uchar_t drivenum);
72 72 static int is_eltorito(uchar_t drivenum);
73 73
74 74 #if !defined(__xpv)
75 75 void
76 76 startup_bios_disk()
77 77 {
78 78 uchar_t drivenum;
79 79 int got_devparams = 0;
80 80 int got_first_block = 0;
81 81 uchar_t name[20];
82 82 dev_info_t *devi;
83 83 int extensions;
84 84
85 85 if (dobiosdev == 0)
86 86 return;
87 87
88 88 for (drivenum = 0x80; drivenum < (0x80 + BIOSDEV_NUM); drivenum++) {
89 89
90 90 if (!drive_present(drivenum))
91 91 continue;
92 92
93 93 extensions = bios_check_extension_present(drivenum);
94 94
95 95 /*
96 96 * If we're booting from an Eltorito CD/DVD image, there's
97 97 * no need to get the device parameters or read the first block
98 98 * because we'll never install onto this device.
99 99 */
100 100 if (extensions && is_eltorito(drivenum))
101 101 continue;
102 102
103 103 if (extensions && get_dev_params(drivenum))
104 104 got_devparams = 1;
105 105 else
106 106 got_devparams = 0;
107 107
108 108 if ((got_first_block = read_firstblock(drivenum)) == 0) {
109 109 /* retry */
110 110 got_first_block = read_firstblock(drivenum);
111 111 }
112 112
113 113 if (got_devparams || got_first_block) {
114 114 (void) sprintf((char *)name, "biosdev-0x%x", drivenum);
115 115 devi = ddi_root_node();
116 116 (void) e_ddi_prop_update_byte_array(DDI_DEV_T_NONE,
117 117 devi, (char *)name,
↓ open down ↓ |
117 lines elided |
↑ open up ↑ |
118 118 (uchar_t *)&biosdev_info[drivenum - 0x80],
119 119 sizeof (biosdev_data_t));
120 120 }
121 121 }
122 122 }
123 123 #endif
124 124
125 125 static int
126 126 bios_check_extension_present(uchar_t drivenum)
127 127 {
128 - struct bop_regs rp = {0};
128 + struct bop_regs rp = {{0}};
129 129 extern struct bootops *bootops;
130 130
131 131 rp.eax.word.ax = 0x4100;
132 132 rp.ebx.word.bx = 0x55AA;
133 133 rp.edx.word.dx = drivenum;
134 134
135 135 /* make sure we have extension support */
136 136 BOP_DOINT(bootops, 0x13, &rp);
137 137
138 138 if (((rp.eflags & PS_C) != 0) || (rp.ebx.word.bx != 0xAA55)) {
139 139 dprintf(("bios_check_extension_present int13 fn 41 "
140 140 "failed %d bx = %x\n", rp.eflags, rp.ebx.word.bx));
141 141 return (0);
142 142 }
143 143
144 144 if ((rp.ecx.word.cx & 0x7) == 0) {
145 145 dprintf(("bios_check_extension_present get device parameters "
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
146 146 "not supported cx = %x\n", rp.ecx.word.cx));
147 147 return (0);
148 148 }
149 149
150 150 return (1);
151 151 }
152 152
153 153 static int
154 154 get_dev_params(uchar_t drivenum)
155 155 {
156 - struct bop_regs rp = {0};
156 + struct bop_regs rp = {{0}};
157 157 fn48_t *bufp;
158 158 extern struct bootops *bootops;
159 159 int i;
160 160 int index;
161 161 uchar_t *tmp;
162 162
163 163 dprintf(("In get_dev_params\n"));
164 164
165 165 bufp = (fn48_t *)BIOS_RES_BUFFER_ADDR;
166 166
167 167 /*
168 168 * We cannot use bzero here as we're initializing data
169 169 * at an address below kernel base.
170 170 */
171 171 for (i = 0; i < sizeof (*bufp); i++)
172 172 ((uchar_t *)bufp)[i] = 0;
173 173
174 174 bufp->buflen = sizeof (*bufp);
175 175 rp.eax.word.ax = 0x4800;
176 176 rp.edx.byte.dl = drivenum;
177 177
178 178 rp.esi.word.si = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);
179 179 rp.ds = FP_SEG((uint_t)(uintptr_t)bufp);
180 180
181 181 BOP_DOINT(bootops, 0x13, &rp);
182 182
183 183 if ((rp.eflags & PS_C) != 0) {
184 184 dprintf(("EDD FAILED on drive eflag = %x ah= %x\n",
185 185 rp.eflags, rp.eax.byte.ah));
186 186 return (0);
187 187 }
188 188
189 189 index = drivenum - 0x80;
190 190 biosdev_info[index].edd_valid = 1;
191 191
192 192 /*
193 193 * Some compilers turn a structure copy into a call
194 194 * to memcpy. Since we are copying data below kernel
195 195 * base intentionally, and memcpy asserts that's not
196 196 * the case, we do the copy manually here.
197 197 */
↓ open down ↓ |
31 lines elided |
↑ open up ↑ |
198 198 tmp = (uchar_t *)&biosdev_info[index].fn48_dev_params;
199 199 for (i = 0; i < sizeof (*bufp); i++)
200 200 tmp[i] = ((uchar_t *)bufp)[i];
201 201
202 202 return (1);
203 203 }
204 204
205 205 static int
206 206 drive_present(uchar_t drivenum)
207 207 {
208 - struct bop_regs rp = {0};
208 + struct bop_regs rp = {{0}};
209 209
210 210 rp.eax.byte.ah = 0x8; /* get params */
211 211 rp.edx.byte.dl = drivenum;
212 212
213 213 BOP_DOINT(bootops, 0x13, &rp);
214 214
215 215 if (((rp.eflags & PS_C) != 0) || rp.eax.byte.ah != 0) {
216 216 dprintf(("drive not present drivenum %x eflag %x ah %x\n",
217 217 drivenum, rp.eflags, rp.eax.byte.ah));
218 218 return (0);
219 219 }
220 220
221 221 dprintf(("drive-present %x\n", drivenum));
222 222 return (1);
223 223 }
224 224
225 225 static void
226 226 reset_disk(uchar_t drivenum)
227 227 {
228 - struct bop_regs rp = {0};
228 + struct bop_regs rp = {{0}};
229 229 int status;
230 230
231 231 rp.eax.byte.ah = 0x0; /* reset disk */
232 232 rp.edx.byte.dl = drivenum;
233 233
234 234 BOP_DOINT(bootops, 0x13, &rp);
235 235
236 236 status = rp.eax.byte.ah;
237 237
238 238 if (((rp.eflags & PS_C) != 0) || status != 0)
239 239 dprintf(("Bad disk reset driv %x, status %x\n", drivenum,
240 240 status));
241 241 }
242 242
243 243 /* Get first block */
244 244 static int
245 245 read_firstblock(uchar_t drivenum)
246 246 {
247 247
248 - struct bop_regs rp = {0};
248 + struct bop_regs rp = {{0}};
249 249 caddr_t bufp;
250 250 uchar_t status;
251 251 int i, index;
252 252
253 253
254 254 reset_disk(drivenum);
255 255 bufp = (caddr_t)BIOS_RES_BUFFER_ADDR;
256 256
257 257
258 258 rp.eax.byte.ah = 0x2; /* Read disk */
259 259 rp.eax.byte.al = 1; /* nsect */
260 260 rp.ecx.byte.ch = 0; /* cyl & 0xff */
261 261 rp.ecx.byte.cl = 1; /* cyl >> 2 & 0xc0 (sector number) */
262 262 rp.edx.byte.dh = 0; /* head */
263 263 rp.edx.byte.dl = drivenum; /* drivenum */
264 264
265 265 /* es:bx is buf address */
266 266 rp.ebx.word.bx = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);
267 267 rp.es = FP_SEG((uint_t)(uintptr_t)bufp);
268 268
269 269 BOP_DOINT(bootops, 0x13, &rp);
270 270
271 271 status = rp.eax.byte.ah;
272 272 if (((rp.eflags & PS_C) != 0) || status != 0) {
273 273 dprintf(("read_firstblock AH not clear %x \n", status));
274 274 return (0);
275 275 }
276 276
277 277 dprintf(("drivenum %x uid at 0x1b8 is %x\n", drivenum,
278 278 *(uint32_t *)(bufp +0x1b8)));
279 279
280 280 index = drivenum - 0x80;
281 281
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
282 282 biosdev_info[index].first_block_valid = 1;
283 283 for (i = 0; i < 512; i++)
284 284 biosdev_info[index].first_block[i] = *((uchar_t *)bufp + i);
285 285
286 286 return (1);
287 287 }
288 288
289 289 static int
290 290 is_eltorito(uchar_t drivenum)
291 291 {
292 - struct bop_regs rp = {0};
292 + struct bop_regs rp = {{0}};
293 293 fn4b_t *bufp;
294 294 extern struct bootops *bootops;
295 295 int i;
296 296
297 297 dprintf(("In is_eltorito\n"));
298 298
299 299 bufp = (fn4b_t *)BIOS_RES_BUFFER_ADDR;
300 300
301 301 /*
302 302 * We cannot use bzero here as we're initializing data
303 303 * at an address below kernel base.
304 304 */
305 305 for (i = 0; i < sizeof (*bufp); i++)
306 306 ((uchar_t *)bufp)[i] = 0;
307 307
308 308 bufp->pkt_size = sizeof (*bufp);
309 309 rp.eax.word.ax = 0x4b01;
310 310 rp.edx.byte.dl = drivenum;
311 311
312 312 rp.esi.word.si = (uint16_t)FP_OFF((uint_t)(uintptr_t)bufp);
313 313 rp.ds = FP_SEG((uint_t)(uintptr_t)bufp);
314 314
315 315 BOP_DOINT(bootops, 0x13, &rp);
316 316
317 317 if ((rp.eflags & PS_C) != 0 || bufp->drivenum != drivenum) {
318 318 dprintf(("fn 0x4b01 FAILED on drive "
319 319 "eflags=%x ah=%x drivenum=%x\n",
320 320 rp.eflags, rp.eax.byte.ah, bufp->drivenum));
321 321 return (0);
322 322 }
323 323
324 324 if (prom_debug)
325 325 prom_printf("INT13 FN4B01 mtype => %x", bufp->boot_mtype);
326 326
327 327 return (1);
328 328 }
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX