1 /*	$OpenBSD: efi_softraid.c,v 1.4 2022/11/07 15:56:09 kn Exp $	*/
2 /*
3  * Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
4  * Copyright (c) 2022 Klemens Nanni <kn@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #include <dev/biovar.h>
20 
21 #include <stdio.h>
22 #include <unistd.h>
23 
24 #include "installboot.h"
25 
26 void
sr_install_bootblk(int devfd,int vol,int disk)27 sr_install_bootblk(int devfd, int vol, int disk)
28 {
29 	struct bioc_disk bd;
30 	char *realdev;
31 	int diskfd;
32 	char part;
33 
34 	diskfd = sr_open_chunk(devfd, vol, disk, &bd, &realdev, &part);
35 	if (diskfd == -1)
36 		return;
37 
38 	if (verbose)
39 		fprintf(stderr, "%s%c: %s boot blocks on %s\n", bd.bd_vendor,
40 		    part, (nowrite ? "would install" : "installing"), realdev);
41 
42 	/* Write boot blocks to device. */
43 	md_installboot(diskfd, realdev);
44 
45 	close(diskfd);
46 }
47 
48 void
sr_install_bootldr(int devfd,char * dev)49 sr_install_bootldr(int devfd, char *dev)
50 {
51 	/*
52 	 * EFI platforms have a single stage bootstrap.
53 	 * sr_install_bootblk() installs it on each softraid chunk.
54 	 * The softraid volume does not require any bootstrap code.
55 	 */
56 }
57