1 /* $NetBSD: md.c,v 1.9 2022/06/26 09:14:14 martin 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 -- amiga 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 48 void 49 md_init(void) 50 { 51 } 52 53 void 54 md_init_set_status(int flags) 55 { 56 (void)flags; 57 } 58 59 bool 60 md_get_info(struct install_partition_desc *install) 61 { 62 return true; 63 } 64 65 /* 66 * md back-end code for menu-driven BSD disklabel editor. 67 */ 68 int 69 md_make_bsd_partitions(struct install_partition_desc *install) 70 { 71 return 1; 72 } 73 74 /* 75 * any additional partition validation 76 */ 77 bool 78 md_check_partitions(struct install_partition_desc *install) 79 { 80 return true; 81 } 82 83 /* 84 * hook called before writing new disklabel. 85 */ 86 bool 87 md_pre_disklabel(struct install_partition_desc *install, 88 struct disk_partitions *parts) 89 { 90 return false; 91 } 92 93 /* 94 * hook called after writing disklabel to new target disk. 95 */ 96 bool 97 md_post_disklabel(struct install_partition_desc *install, 98 struct disk_partitions *parts) 99 { 100 return true; 101 } 102 103 #ifdef DISKLABEL_NO_ONDISK_VERIFY 104 /* 105 * hook to check if disklabel returned by readdisklabel(9) via DIOCGDINFO 106 * seems the default one, on ports that have no BSD disklabel on disks. 107 */ 108 bool 109 md_disklabel_is_default(const struct disklabel *lp) 110 { 111 bool maybe_default = 112 lp->d_npartitions == RAW_PART + 1 && 113 lp->d_partitions[RAW_PART].p_size == 0x1fffffff && 114 lp->d_partitions[0].p_size == lp->d_partitions[RAW_PART].p_size && 115 lp->d_partitions[0].p_offset == 0 && 116 lp->d_partitions[0].p_fstype == FS_BSDFFS; 117 118 return maybe_default; 119 } 120 #endif 121 122 /* 123 * hook called after upgrade() or install() has finished setting 124 * up the target disk but immediately before the user is given the 125 * ``disks are now set up'' message. 126 */ 127 int 128 md_post_newfs(struct install_partition_desc *install) 129 { 130 /* boot blocks ... */ 131 msg_fmt_display(MSG_dobootblks, "%s", pm->diskdev); 132 return run_program(RUN_DISPLAY, 133 "/usr/mdec/installboot -v /usr/mdec/xxboot /dev/r%sa", pm->diskdev); 134 } 135 136 int 137 md_post_extract(struct install_partition_desc *install, bool upgrade) 138 { 139 return 0; 140 } 141 142 void 143 md_cleanup_install(struct install_partition_desc *install) 144 { 145 #ifndef DEBUG 146 enable_rc_conf(); 147 #endif 148 } 149 150 int 151 md_pre_update(struct install_partition_desc *install) 152 { 153 return 1; 154 } 155 156 /* Upgrade support */ 157 int 158 md_update(struct install_partition_desc *install) 159 { 160 md_post_newfs(install); 161 return 1; 162 } 163 164 int 165 md_pre_mount(struct install_partition_desc *install, size_t ndx) 166 { 167 return 0; 168 } 169 170 #ifdef HAVE_GPT 171 /* 172 * New GPT partitions have been written, update bootloader or remember 173 * data untill needed in md_post_newfs 174 */ 175 bool 176 md_gpt_post_write(struct disk_partitions *parts, part_id root_id, 177 bool root_is_new, part_id efi_id, bool efi_is_new) 178 { 179 180 return true; 181 } 182 #endif 183 184 bool 185 md_parts_use_wholedisk(struct disk_partitions *parts) 186 { 187 return parts_use_wholedisk(parts, 0, NULL); 188 } 189 190