1 /* $NetBSD: dk.c,v 1.9 2009/05/07 15:21:39 skrll Exp $ */
3 /* $OpenBSD: dk.c,v 1.5 1999/04/20 20:01:01 mickey Exp $ */
6 * Copyright 1996 1995 by Open Software Foundation, Inc.
9 * Permission to use, copy, modify, and distribute this software and
10 * its documentation for any purpose and without fee is hereby granted,
11 * provided that the above copyright notice appears in all copies and
12 * that both the copyright notice and this permission notice appear in
13 * supporting documentation.
15 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17 * FOR A PARTICULAR PURPOSE.
19 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
22 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
23 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include <sys/param.h>
30 #include <sys/disklabel.h>
31 #include <sys/reboot.h>
32 #include <machine/pdc.h>
33 #include <machine/iomod.h>
37 const char *dk_disklabel(struct hppa_dev
*, struct disklabel
*);
39 iodcio_t dkiodc
; /* boot IODC entry point */
42 dk_disklabel(struct hppa_dev
*dp
, struct disklabel
*label
)
47 if (iodcstrategy(dp
, F_READ
, LABELSECTOR
, DEV_BSIZE
, buf
, &ret
) ||
49 return "can't read disklabel";
51 return (getdisklabel(buf
, label
));
55 dkopen(struct open_file
*f
, ...)
58 struct hppa_dev
*dp
= f
->f_devdata
;
64 printf("dkopen(%p)\n", f
);
67 if (!(dp
->pz_dev
= pdc_findev(-1, PCL_RANDOM
)))
74 printf ("disklabel\n");
76 if ((st
= dk_disklabel(dp
, &dkl
)) != NULL
) {
79 printf ("dkopen: %s\n", st
);
82 * Ignore disklabel errors for this two reasons:
83 * 1. It is possible to dd(1) a LIF image containing the bootloader
84 * and a kernel with attached RAM disk to disk and boot it. That way
85 * the netboot installation LIF image is also usable as disk boot
87 * 2. Some old 700 machines report a wrong device class in
88 * PAGE0->mem_boot.pz_class when net booting. (PCL_RANDOM instead
89 * PCL_NET_MASK|PCL_SEQU) So the bootloader thinks it is booting
90 * from disk when it is actually net booting. The net boot LIF image
91 * contains no disklabel so the test for the disklabel will fail.
92 * If the device open fails if there is no disklabel we are not able
93 * to netboot those machines.
94 * Therefore the error is ignored. The bootloader will fall back to
95 * LIF later when there is no disklabel / FFS partition.
96 * At the moment it doesn't matter that the wrong device type ("dk"
97 * instead "lf") is used, as all I/O is abstracted by the firmware.
98 * To get the correct device type it would be necessary to add a
99 * quirk table to the switch() in dev_hppa.c:devboot().
102 i
= B_PARTITION(dp
->bootdev
);
105 printf("bootdev 0x%x, partition %u\n", dp
->bootdev
, i
);
107 if (i
>= dkl
.d_npartitions
|| !dkl
.d_partitions
[i
].p_size
) {
110 dp
->part_off
= dkl
.d_partitions
[i
].p_offset
* dkl
.d_secsize
;
114 printf ("dkopen() ret\n");
120 dkclose(struct open_file
*f
)
122 dealloc(f
->f_devdata
, sizeof(struct hppa_dev
));