]>
Commit | Line | Data |
---|---|---|
916eb79e A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights | |
7 | * Reserved. This file contains Original Code and/or Modifications of | |
8 | * Original Code as defined in and that are subject to the Apple Public | |
9 | * Source License Version 1.0 (the 'License'). You may not use this file | |
10 | * except in compliance with the License. Please obtain a copy of the | |
11 | * License at http://www.apple.com/publicsource and read it before using | |
12 | * this file. | |
13 | * | |
14 | * The Original Code and all software distributed under the License are | |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
19 | * License for the specific language governing rights and limitations | |
20 | * under the License." | |
21 | * | |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | /*- | |
25 | * Copyright (c) 1986, 1991, 1993 | |
26 | * The Regents of the University of California. All rights reserved. | |
27 | * | |
28 | * Redistribution and use in source and binary forms, with or without | |
29 | * modification, are permitted provided that the following conditions | |
30 | * are met: | |
31 | * 1. Redistributions of source code must retain the above copyright | |
32 | * notice, this list of conditions and the following disclaimer. | |
33 | * 2. Redistributions in binary form must reproduce the above copyright | |
34 | * notice, this list of conditions and the following disclaimer in the | |
35 | * documentation and/or other materials provided with the distribution. | |
36 | * 3. All advertising materials mentioning features or use of this software | |
37 | * must display the following acknowledgement: | |
38 | * This product includes software developed by the University of | |
39 | * California, Berkeley and its contributors. | |
40 | * 4. Neither the name of the University nor the names of its contributors | |
41 | * may be used to endorse or promote products derived from this software | |
42 | * without specific prior written permission. | |
43 | * | |
44 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
45 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
46 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
47 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
48 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
49 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
50 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
51 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
52 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
53 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
54 | * SUCH DAMAGE. | |
55 | */ | |
56 | ||
57 | #if !defined(hp300) && !defined(tahoe) && !defined(vax) && \ | |
58 | !defined(luna68k) && !defined(mips) | |
59 | char *defdrives[] = { 0 }; | |
60 | int | |
61 | read_names() | |
62 | { | |
63 | return 0; | |
64 | } | |
65 | #endif | |
66 | ||
67 | #if defined(hp300) || defined(luna68k) | |
68 | #if defined(hp300) | |
69 | #include <hp/dev/device.h> | |
70 | #else | |
71 | #include <luna68k/dev/device.h> | |
72 | #endif | |
73 | ||
74 | char *defdrives[] = { "sd0", "sd1", "sd2", "rd0", "rd1", "rd2", 0 }; | |
75 | ||
76 | int | |
77 | read_names() | |
78 | { | |
79 | register char *p; | |
80 | register u_long hp; | |
81 | static char buf[BUFSIZ]; | |
82 | struct hp_device hdev; | |
83 | struct driver hdrv; | |
84 | char name[10]; | |
85 | ||
86 | hp = namelist[X_HPDINIT].n_value; | |
87 | if (hp == 0) { | |
88 | (void)fprintf(stderr, | |
89 | "disk init info not in namelist\n"); | |
90 | return (0); | |
91 | } | |
92 | p = buf; | |
93 | for (;; hp += sizeof hdev) { | |
94 | (void)kvm_read(kd, hp, &hdev, sizeof hdev); | |
95 | if (hdev.hp_driver == 0) | |
96 | break; | |
97 | if (hdev.hp_dk < 0 || hdev.hp_alive == 0 || | |
98 | hdev.hp_cdriver == 0) | |
99 | continue; | |
100 | (void)kvm_read(kd, (u_long)hdev.hp_driver, &hdrv, sizeof hdrv); | |
101 | (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name); | |
102 | dr_name[hdev.hp_dk] = p; | |
103 | p += sprintf(p, "%s%d", name, hdev.hp_unit) + 1; | |
104 | } | |
105 | return (1); | |
106 | } | |
107 | #endif /* hp300 || luna68k */ | |
108 | ||
109 | #ifdef tahoe | |
110 | #include <tahoe/vba/vbavar.h> | |
111 | ||
112 | char *defdrives[] = { "dk0", "dk1", "dk2", 0 }; | |
113 | ||
114 | int | |
115 | read_names() | |
116 | { | |
117 | register char *p; | |
118 | struct vba_device udev, *up; | |
119 | struct vba_driver udrv; | |
120 | char name[10]; | |
121 | static char buf[BUFSIZ]; | |
122 | ||
123 | up = (struct vba_device *)namelist[X_VBDINIT].n_value; | |
124 | if (up == 0) { | |
125 | (void) fprintf(stderr, | |
126 | "disk init info not in namelist\n"); | |
127 | return (0); | |
128 | } | |
129 | p = buf; | |
130 | for (;; up += sizeof udev) { | |
131 | (void)kvm_read(kd, up, &udev, sizeof udev); | |
132 | if (udev.ui_driver == 0) | |
133 | break; | |
134 | if (udev.ui_dk < 0 || udev.ui_alive == 0) | |
135 | continue; | |
136 | (void)kvm_read(kd, udev.ui_driver, &udrv, sizeof udrv); | |
137 | (void)kvm_read(kd, udrv.ud_dname, name, sizeof name); | |
138 | dr_name[udev.ui_dk] = p; | |
139 | p += sprintf(p, "%s%d", name, udev.ui_unit); | |
140 | } | |
141 | return (1); | |
142 | } | |
143 | #endif /* tahoe */ | |
144 | ||
145 | #ifdef vax | |
146 | #include <vax/uba/ubavar.h> | |
147 | #include <vax/mba/mbavar.h> | |
148 | ||
149 | char *defdrives[] = { "hp0", "hp1", "hp2", 0 }; | |
150 | ||
151 | int | |
152 | read_names() | |
153 | { | |
154 | register char *p; | |
155 | unsigned long mp, up; | |
156 | struct mba_device mdev; | |
157 | struct mba_driver mdrv; | |
158 | struct uba_device udev; | |
159 | struct uba_driver udrv; | |
160 | char name[10]; | |
161 | static char buf[BUFSIZ]; | |
162 | ||
163 | mp = namelist[X_MBDINIT].n_value; | |
164 | up = namelist[X_UBDINIT].n_value; | |
165 | if (mp == 0 && up == 0) { | |
166 | (void)fprintf(stderr, | |
167 | "disk init info not in namelist\n"); | |
168 | return (0); | |
169 | } | |
170 | p = buf; | |
171 | if (mp) | |
172 | for (;; mp += sizeof mdev) { | |
173 | (void)kvm_read(kd, mp, &mdev, sizeof mdev); | |
174 | if (mdev.mi_driver == 0) | |
175 | break; | |
176 | if (mdev.mi_dk < 0 || mdev.mi_alive == 0) | |
177 | continue; | |
178 | (void)kvm_read(kd, mdev.mi_driver, &mdrv, sizeof mdrv); | |
179 | (void)kvm_rea(kd, mdrv.md_dname, name, sizeof name); | |
180 | dr_name[mdev.mi_dk] = p; | |
181 | p += sprintf(p, "%s%d", name, mdev.mi_unit); | |
182 | } | |
183 | if (up) | |
184 | for (;; up += sizeof udev) { | |
185 | (void)kvm_read(kd, up, &udev, sizeof udev); | |
186 | if (udev.ui_driver == 0) | |
187 | break; | |
188 | if (udev.ui_dk < 0 || udev.ui_alive == 0) | |
189 | continue; | |
190 | (void)kvm_read(kd, udev.ui_driver, &udrv, sizeof udrv); | |
191 | (void)kvm_read(kd, udrv.ud_dname, name, sizeof name); | |
192 | dr_name[udev.ui_dk] = p; | |
193 | p += sprintf(p, "%s%d", name, udev.ui_unit); | |
194 | } | |
195 | return (1); | |
196 | } | |
197 | #endif /* vax */ | |
198 | ||
199 | #ifdef sun | |
200 | #include <sundev/mbvar.h> | |
201 | ||
202 | int | |
203 | read_names() | |
204 | { | |
205 | static int once = 0; | |
206 | struct mb_device mdev; | |
207 | struct mb_driver mdrv; | |
208 | short two_char; | |
209 | char *cp = (char *) &two_char; | |
210 | register struct mb_device *mp; | |
211 | ||
212 | mp = (struct mb_device *)namelist[X_MBDINIT].n_value; | |
213 | if (mp == 0) { | |
214 | (void)fprintf(stderr, | |
215 | "disk init info not in namelist\n"); | |
216 | return (0); | |
217 | } | |
218 | for (;; ++mp) { | |
219 | (void)kvm_read(kd, mp++, &mdev, sizeof(mdev)); | |
220 | if (mdev.md_driver == 0) | |
221 | break; | |
222 | if (mdev.md_dk < 0 || mdev.md_alive == 0) | |
223 | continue; | |
224 | (void)kvm_read(kd, mdev.md_driver, &mdrv, sizeof(mdrv)); | |
225 | (void)kvm_read(kd, mdrv.mdr_dname, &two_char, sizeof(two_char)); | |
226 | (void)sprintf(dr_name[mdev.md_dk], | |
227 | "%c%c%d", cp[0], cp[1], mdev.md_unit); | |
228 | } | |
229 | return(1); | |
230 | } | |
231 | #endif /* sun */ | |
232 | ||
233 | #if defined(mips) | |
234 | #include <pmax/dev/device.h> | |
235 | ||
236 | char *defdrives[] = { "rz0", "rz1", "rz2", "rz3", "rz4", "rz5", "rz6", 0 }; | |
237 | ||
238 | int | |
239 | read_names() | |
240 | { | |
241 | register char *p; | |
242 | register u_long sp; | |
243 | static char buf[BUFSIZ]; | |
244 | struct scsi_device sdev; | |
245 | struct driver hdrv; | |
246 | char name[10]; | |
247 | ||
248 | sp = namelist[X_SCSI_DINIT].n_value; | |
249 | if (sp == 0) { | |
250 | (void)fprintf(stderr, "disk init info not in namelist\n"); | |
251 | return (0); | |
252 | } | |
253 | p = buf; | |
254 | for (;; sp += sizeof sdev) { | |
255 | (void)kvm_read(kd, sp, &sdev, sizeof sdev); | |
256 | if (sdev.sd_driver == 0) | |
257 | break; | |
258 | if (sdev.sd_dk < 0 || sdev.sd_alive == 0 || | |
259 | sdev.sd_cdriver == 0) | |
260 | continue; | |
261 | (void)kvm_read(kd, (u_long)sdev.sd_driver, &hdrv, sizeof hdrv); | |
262 | (void)kvm_read(kd, (u_long)hdrv.d_name, name, sizeof name); | |
263 | dr_name[sdev.sd_dk] = p; | |
264 | p += sprintf(p, "%s%d", name, sdev.sd_unit) + 1; | |
265 | } | |
266 | return (1); | |
267 | } | |
268 | #endif /* mips */ |