boot_device.c revision 1.1 1 /* $NetBSD: boot_device.c,v 1.1 2005/12/29 15:20:09 tsutsui Exp $ */
2
3 /*-
4 * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/types.h>
40 #include <machine/sbd.h>
41 #include "common.h"
42
43 /*
44 * Get boot device and unit number. IPL sets it.
45 */
46 void __nvsram_type_a(int *, int *);
47 void __nvsram_type_b(int *, int *);
48 void __nvsram_type_c(int *, int *);
49 void __nvsram_type_d(int *, int *);
50 void __nvsram_type_e(int *, int *);
51
52 void (*tab[])(int *, int *) = {
53 __nvsram_type_c, /* ER */
54 __nvsram_type_a, /* TR */
55 __nvsram_type_a, /* SR */
56 __nvsram_type_b, /* TR+2D */
57 __nvsram_type_b, /* TR+3D */
58 __nvsram_type_c, /* LR */
59 __nvsram_type_c, /* ER2 */
60 __nvsram_type_d, /* TR2 */
61 __nvsram_type_c, /* ER1V */
62 __nvsram_type_e, /* LRC */
63 __nvsram_type_c, /* SR2 */
64 __nvsram_type_d, /* ER+ */
65 __nvsram_type_c, /* TR2+ */
66 __nvsram_type_d, /* ER2A */
67 };
68
69 void
70 boot_device(int *type, int *unit, int *fd_format)
71 {
72 int i;
73
74 *fd_format = SBD_INFO->fdd == 1 ? FD_FORMAT_2HD : FD_FORMAT_2D;
75 i = SBD_INFO->machine - 0x1010;
76 if (i < sizeof tab / sizeof tab[0])
77 return tab[i](type, unit);
78
79 return __nvsram_type_e(type, unit);
80 }
81
82 void
83 __nvsram_type_a(int *type, int *unit)
84 {
85 /* TR, SR */
86 *type = NVSRAM_BOOTDEV_HARDDISK;
87 *unit = 0;
88 }
89
90 void
91 __nvsram_type_b(int *type, int *unit)
92 {
93 /* TR+2D, TR+3D */
94 *type = NVSRAM_BOOTDEV_HARDDISK;
95 *unit = *(uint8_t *)0xba021808;
96 }
97
98 void
99 __nvsram_type_c(int *type, int *unit)
100 {
101 /* ER, LR, ER2, ER1V, SR2, TR2+ */
102 *type = NVSRAM_BOOTDEV_HARDDISK;
103 *unit = *(uint8_t *)0xbb012088;
104 }
105
106 void
107 __nvsram_type_d(int *type, int *unit)
108 {
109 /* TR2, ER+, ER2A */
110 *type = *(uint8_t *)0xbb023030;
111 *unit = *(uint8_t *)0xbb023034;
112 }
113
114 void
115 __nvsram_type_e(int *type, int *unit)
116 {
117 /* LRC, TR2A, LER, LER_L, LER_H, MUS, LT, LT_L ... */
118 *type = *(uint8_t *)0xbe493030;
119 *unit = *(uint8_t *)0xbe493034;
120 }
121