md.c revision 1.2.2.2 1 /* $NetBSD: md.c,v 1.2.2.2 2014/08/10 07:00:27 tls Exp $ */
2
3 /*
4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved.
6 *
7 * Based on code written by Philip A. Nelson for Piermont Information
8 * Systems Inc.
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 for the NetBSD Project by
21 * Piermont Information Systems Inc.
22 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
23 * or promote products derived from this software without specific prior
24 * written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
30 * 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
36 * THE POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /* md.c -- playstation2 machine specific routines */
40
41 #include <stdio.h>
42 #include <util.h>
43 #include <sys/param.h>
44 #include <sys/sysctl.h>
45
46 #include "defs.h"
47 #include "md.h"
48 #include "msg_defs.h"
49 #include "menu_defs.h"
50
51 void
52 md_init(void)
53 {
54 }
55
56 void
57 md_init_set_status(int minimal)
58 {
59 (void)minimal;
60 }
61
62 int
63 md_get_info(void)
64 {
65 int cyl, head;
66 daddr_t sec;
67
68 read_mbr(pm->diskdev, &mbr);
69
70 msg_display(MSG_nobiosgeom, pm->dlcyl, pm->dlhead, pm->dlsec);
71
72 if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0)
73 msg_display_add(MSG_biosguess, cyl, head, sec);
74 set_bios_geom(cyl, head, sec);
75
76 edit_mbr(&mbr);
77
78 return 1;
79 }
80
81 /*
82 * md back-end code for menu-driven BSD disklabel editor.
83 */
84 int
85 md_make_bsd_partitions(void)
86 {
87 return (make_bsd_partitions());
88 }
89
90 /*
91 * any additional partition validation
92 */
93 int
94 md_check_partitions(void)
95 {
96 return 1;
97 }
98
99 /*
100 * hook called before writing new disklabel.
101 */
102 int
103 md_pre_disklabel(void)
104 {
105 msg_display(MSG_dofdisk);
106
107 /* write edited MBR onto disk. */
108 if (write_mbr(pm->diskdev, &mbr, 1) != 0) {
109 msg_display(MSG_wmbrfail);
110 process_menu(MENU_ok, NULL);
111
112 return 1;
113 }
114
115 return 0;
116 }
117
118 /*
119 * hook called after writing disklabel to new target disk.
120 */
121 int
122 md_post_disklabel(void)
123 {
124 /* Sector forwarding / badblocks ... */
125 if (*pm->doessf) {
126 msg_display(MSG_dobad144);
127 return (run_program(RUN_DISPLAY, "/usr/sbin/bad144 %s 0",
128 pm->diskdev));
129 }
130
131 return 0;
132 }
133
134 /*
135 * hook called after upgrade() or install() has finished setting
136 * up the target disk but immediately before the user is given the
137 * ``disks are now set up'' message.
138 */
139 int
140 md_post_newfs(void)
141 {
142 return 0;
143 }
144
145 int
146 md_post_extract(void)
147 {
148 return 0;
149 }
150
151 void
152 md_cleanup_install(void)
153 {
154 #ifndef DEBUG
155 enable_rc_conf();
156 #endif
157 }
158
159 int
160 md_pre_update(void)
161 {
162 return 1;
163 }
164
165 /* Upgrade support */
166 int
167 md_update(void)
168 {
169 md_post_newfs();
170 return 1;
171 }
172
173 int
174 md_check_mbr(mbr_info_t *mbri)
175 {
176 return 2;
177 }
178
179 int
180 md_mbr_use_wholedisk(mbr_info_t *mbri)
181 {
182 return mbr_use_wholedisk(mbri);
183 }
184
185 int
186 md_pre_mount()
187 {
188 return 0;
189 }
190
191