1 /* $NetBSD: md.c,v 1.3 2015/01/02 19:43:13 abs 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. The name of Piermont Information Systems Inc. may not be used to endorse 19 * or promote products derived from this software without specific prior 20 * written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 /* md.c -- hpcsh machine specific routines */ 36 37 #include <stdio.h> 38 #include <util.h> 39 #include <sys/param.h> 40 #include <machine/cpu.h> 41 #include <sys/sysctl.h> 42 43 #include "defs.h" 44 #include "md.h" 45 #include "msg_defs.h" 46 #include "menu_defs.h" 47 #include "endian.h" 48 #include "mbr.h" 49 50 void 51 md_init(void) 52 { 53 } 54 55 void 56 md_init_set_status(int flags) 57 { 58 59 (void)flags; 60 } 61 62 int 63 md_get_info(void) 64 { 65 66 return set_bios_geom_with_mbr_guess(); 67 } 68 69 /* 70 * md back-end code for menu-driven BSD disklabel editor. 71 */ 72 int 73 md_make_bsd_partitions(void) 74 { 75 76 return make_bsd_partitions(); 77 } 78 79 /* 80 * any additional partition validation 81 */ 82 int 83 md_check_partitions(void) 84 { 85 86 return 1; 87 } 88 89 /* 90 * hook called before writing new disklabel. 91 */ 92 int 93 md_pre_disklabel(void) 94 { 95 96 msg_display(MSG_dofdisk); 97 98 /* write edited MBR onto disk. */ 99 if (write_mbr(pm->diskdev, &mbr, 1) != 0) { 100 msg_display(MSG_wmbrfail); 101 process_menu(MENU_ok, NULL); 102 return 1; 103 } 104 return 0; 105 } 106 107 /* 108 * hook called after writing disklabel to new target disk. 109 */ 110 int 111 md_post_disklabel(void) 112 { 113 return 0; 114 } 115 116 /* 117 * hook called after upgrade() or install() has finished setting 118 * up the target disk but immediately before the user is given the 119 * ``disks are now set up'' message. 120 */ 121 int 122 md_post_newfs(void) 123 { 124 125 return 0; 126 } 127 128 void 129 md_cleanup_install(void) 130 { 131 132 #ifndef DEBUG 133 enable_rc_conf(); 134 #endif 135 } 136 137 int 138 md_pre_update(void) 139 { 140 141 return 1; 142 } 143 144 /* Upgrade support */ 145 int 146 md_update(void) 147 { 148 149 md_post_newfs(); 150 return 1; 151 } 152 153 int 154 md_post_extract(void) 155 { 156 157 return 0; 158 } 159 160 int 161 md_check_mbr(mbr_info_t *mbri) 162 { 163 164 return 2; 165 } 166 167 int 168 md_mbr_use_wholedisk(mbr_info_t *mbri) 169 { 170 171 return mbr_use_wholedisk(mbri); 172 } 173 174 int 175 md_pre_mount() 176 { 177 return 0; 178 } 179