xref: /netbsd/usr.sbin/sysinst/arch/sparc/md.c (revision 5960e8ba)
1*5960e8baSmartin /*	$NetBSD: md.c,v 1.8 2022/12/09 17:02:14 martin Exp $	*/
226165e63Sdholland 
326165e63Sdholland /*
426165e63Sdholland  * Copyright 1997 Piermont Information Systems Inc.
526165e63Sdholland  * All rights reserved.
626165e63Sdholland  *
726165e63Sdholland  * Based on code written by Philip A. Nelson for Piermont Information
826165e63Sdholland  * Systems Inc.
926165e63Sdholland  *
1026165e63Sdholland  * Redistribution and use in source and binary forms, with or without
1126165e63Sdholland  * modification, are permitted provided that the following conditions
1226165e63Sdholland  * are met:
1326165e63Sdholland  * 1. Redistributions of source code must retain the above copyright
1426165e63Sdholland  *    notice, this list of conditions and the following disclaimer.
1526165e63Sdholland  * 2. Redistributions in binary form must reproduce the above copyright
1626165e63Sdholland  *    notice, this list of conditions and the following disclaimer in the
1726165e63Sdholland  *    documentation and/or other materials provided with the distribution.
1826165e63Sdholland  * 3. The name of Piermont Information Systems Inc. may not be used to endorse
1926165e63Sdholland  *    or promote products derived from this software without specific prior
2026165e63Sdholland  *    written permission.
2126165e63Sdholland  *
2226165e63Sdholland  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
2326165e63Sdholland  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2426165e63Sdholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2526165e63Sdholland  * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
2626165e63Sdholland  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2726165e63Sdholland  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2826165e63Sdholland  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2926165e63Sdholland  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3026165e63Sdholland  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3126165e63Sdholland  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
3226165e63Sdholland  * THE POSSIBILITY OF SUCH DAMAGE.
3326165e63Sdholland  */
3426165e63Sdholland 
3526165e63Sdholland /* changes from the i386 version made by mrg */
3626165e63Sdholland 
3726165e63Sdholland /* md.c -- sparc machine specific routines */
3826165e63Sdholland /* This file is in close sync with pmax, vax, and x68k md.c */
3926165e63Sdholland 
4026165e63Sdholland #include <sys/types.h>
4126165e63Sdholland #include <sys/ioctl.h>
4226165e63Sdholland #include <sys/param.h>
4326165e63Sdholland #include <sys/exec.h>
4426165e63Sdholland #include <stdio.h>
4526165e63Sdholland #include <curses.h>
4626165e63Sdholland #include <unistd.h>
4726165e63Sdholland #include <fcntl.h>
4826165e63Sdholland #include <util.h>
4926165e63Sdholland #include <dirent.h>
5026165e63Sdholland 
5126165e63Sdholland #include "defs.h"
5226165e63Sdholland #include "md.h"
5326165e63Sdholland #include "msg_defs.h"
5426165e63Sdholland #include "menu_defs.h"
5526165e63Sdholland 
5626165e63Sdholland void
md_init(void)5726165e63Sdholland md_init(void)
5826165e63Sdholland {
5926165e63Sdholland }
6026165e63Sdholland 
6126165e63Sdholland void
md_init_set_status(int flags)6226165e63Sdholland md_init_set_status(int flags)
6326165e63Sdholland {
6426165e63Sdholland 	(void)flags;
6526165e63Sdholland }
6626165e63Sdholland 
67dcc57e24Smartin bool
md_get_info(struct install_partition_desc * install)68dcc57e24Smartin md_get_info(struct install_partition_desc *install)
6926165e63Sdholland {
70*5960e8baSmartin 	set_default_sizemult(pm->diskdev, MEG, pm->sectorsize);
71dcc57e24Smartin 	return true;
7226165e63Sdholland }
7326165e63Sdholland 
7426165e63Sdholland /*
7526165e63Sdholland  * md back-end code for menu-driven BSD disklabel editor.
7626165e63Sdholland  */
7780bf2417Smartin int
md_make_bsd_partitions(struct install_partition_desc * install)78dcc57e24Smartin md_make_bsd_partitions(struct install_partition_desc *install)
7926165e63Sdholland {
80dcc57e24Smartin 	return(make_bsd_partitions(install));
8126165e63Sdholland }
8226165e63Sdholland 
8326165e63Sdholland /*
8426165e63Sdholland  * any additional partition validation
8526165e63Sdholland  */
86dcc57e24Smartin bool
md_check_partitions(struct install_partition_desc * install)87dcc57e24Smartin md_check_partitions(struct install_partition_desc *install)
8826165e63Sdholland {
89dcc57e24Smartin 	return true;
9026165e63Sdholland }
9126165e63Sdholland 
9226165e63Sdholland /*
9326165e63Sdholland  * hook called before writing new disklabel.
9426165e63Sdholland  */
95dcc57e24Smartin bool
md_pre_disklabel(struct install_partition_desc * install,struct disk_partitions * parts)96dcc57e24Smartin md_pre_disklabel(struct install_partition_desc *install,
97dcc57e24Smartin     struct disk_partitions *parts)
9826165e63Sdholland {
99dcc57e24Smartin 	return true;
10026165e63Sdholland }
10126165e63Sdholland 
10226165e63Sdholland /*
10326165e63Sdholland  * hook called after writing disklabel to new target disk.
10426165e63Sdholland  */
105dcc57e24Smartin bool
md_post_disklabel(struct install_partition_desc * install,struct disk_partitions * parts)106dcc57e24Smartin md_post_disklabel(struct install_partition_desc *install,
107dcc57e24Smartin     struct disk_partitions *parts)
10826165e63Sdholland {
109dcc57e24Smartin 	return true;
11026165e63Sdholland }
11126165e63Sdholland 
11226165e63Sdholland /*
11326165e63Sdholland  * hook called after upgrade() or install() has finished setting
11426165e63Sdholland  * up the target disk but immediately before the user is given the
11526165e63Sdholland  * ``disks are now set up'' message.
11626165e63Sdholland  *
11726165e63Sdholland  * On the sparc, we use this opportunity to install the boot blocks.
11826165e63Sdholland  */
11926165e63Sdholland int
md_post_newfs(struct install_partition_desc * install)120dcc57e24Smartin md_post_newfs(struct install_partition_desc *install)
12126165e63Sdholland {
12226165e63Sdholland 
12326165e63Sdholland 	/* boot blocks ... */
124f9805030Schristos 	msg_fmt_display(MSG_dobootblks, "%s", pm->diskdev);
125da5a563bSmartin 	return (run_program(RUN_DISPLAY, "/sbin/disklabel -W %s", pm->diskdev) ||
12626165e63Sdholland 	    run_program(RUN_DISPLAY, "/usr/mdec/binstall ffs %s",
12726165e63Sdholland 		targetroot_mnt));
12826165e63Sdholland }
12926165e63Sdholland 
13026165e63Sdholland int
md_post_extract(struct install_partition_desc * install,bool upgrade)131b8b586ecSmartin md_post_extract(struct install_partition_desc *install, bool upgrade)
13226165e63Sdholland {
13326165e63Sdholland 	return 0;
13426165e63Sdholland }
13526165e63Sdholland 
13626165e63Sdholland void
md_cleanup_install(struct install_partition_desc * install)137dcc57e24Smartin md_cleanup_install(struct install_partition_desc *install)
13826165e63Sdholland {
13926165e63Sdholland #ifndef DEBUG
14026165e63Sdholland 	enable_rc_conf();
14126165e63Sdholland #endif
14226165e63Sdholland }
14326165e63Sdholland 
14426165e63Sdholland int
md_pre_update(struct install_partition_desc * install)145dcc57e24Smartin md_pre_update(struct install_partition_desc *install)
14626165e63Sdholland {
14726165e63Sdholland 	return 1;
14826165e63Sdholland }
14926165e63Sdholland 
15026165e63Sdholland /* Upgrade support */
15126165e63Sdholland int
md_update(struct install_partition_desc * install)152dcc57e24Smartin md_update(struct install_partition_desc *install)
15326165e63Sdholland {
154dcc57e24Smartin 	md_post_newfs(install);
15526165e63Sdholland 	return 1;
15626165e63Sdholland }
15726165e63Sdholland 
15826165e63Sdholland int
md_pre_mount(struct install_partition_desc * install,size_t ndx)159d5a9dfe9Smartin md_pre_mount(struct install_partition_desc *install, size_t ndx)
16026165e63Sdholland {
16126165e63Sdholland 	return 0;
16226165e63Sdholland }
163dcc57e24Smartin 
164dcc57e24Smartin bool
md_parts_use_wholedisk(struct disk_partitions * parts)165dcc57e24Smartin md_parts_use_wholedisk(struct disk_partitions *parts)
166dcc57e24Smartin {
167dcc57e24Smartin 	return parts_use_wholedisk(parts, 0, NULL);
168dcc57e24Smartin }
169dcc57e24Smartin 
170dcc57e24Smartin #ifdef HAVE_GPT
171dcc57e24Smartin /*
172dcc57e24Smartin  * New GPT partitions have been written, update bootloader or remember
173dcc57e24Smartin  * data untill needed in md_post_newfs
174dcc57e24Smartin  */
175dcc57e24Smartin bool
md_gpt_post_write(struct disk_partitions * parts,part_id root_id,bool root_is_new,part_id efi_id,bool efi_is_new)176dcc57e24Smartin md_gpt_post_write(struct disk_partitions *parts, part_id root_id,
177dcc57e24Smartin     bool root_is_new, part_id efi_id, bool efi_is_new)
178dcc57e24Smartin {
179dcc57e24Smartin 
180dcc57e24Smartin 	return true;
181dcc57e24Smartin }
182dcc57e24Smartin #endif
183