1*7b08a307SMitchell Horne /* 2*7b08a307SMitchell Horne * Copyright (C) 2016 Cavium Inc. 3*7b08a307SMitchell Horne * All rights reserved. 4*7b08a307SMitchell Horne * 5*7b08a307SMitchell Horne * Developed by Semihalf. 6*7b08a307SMitchell Horne * Based on work by Nathan Whitehorn. 7*7b08a307SMitchell Horne * 8*7b08a307SMitchell Horne * Redistribution and use in source and binary forms, with or without 9*7b08a307SMitchell Horne * modification, are permitted provided that the following conditions 10*7b08a307SMitchell Horne * are met: 11*7b08a307SMitchell Horne * 1. Redistributions of source code must retain the above copyright 12*7b08a307SMitchell Horne * notice, this list of conditions and the following disclaimer. 13*7b08a307SMitchell Horne * 2. Redistributions in binary form must reproduce the above copyright 14*7b08a307SMitchell Horne * notice, this list of conditions and the following disclaimer in the 15*7b08a307SMitchell Horne * documentation and/or other materials provided with the distribution. 16*7b08a307SMitchell Horne * 17*7b08a307SMitchell Horne * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18*7b08a307SMitchell Horne * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*7b08a307SMitchell Horne * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*7b08a307SMitchell Horne * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21*7b08a307SMitchell Horne * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*7b08a307SMitchell Horne * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*7b08a307SMitchell Horne * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*7b08a307SMitchell Horne * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*7b08a307SMitchell Horne * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*7b08a307SMitchell Horne * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*7b08a307SMitchell Horne * SUCH DAMAGE. 28*7b08a307SMitchell Horne * 29*7b08a307SMitchell Horne * $FreeBSD$ 30*7b08a307SMitchell Horne */ 31*7b08a307SMitchell Horne 32*7b08a307SMitchell Horne #include <sys/types.h> 33*7b08a307SMitchell Horne #include <string.h> 34*7b08a307SMitchell Horne 35*7b08a307SMitchell Horne #include "partedit.h" 36*7b08a307SMitchell Horne 37*7b08a307SMitchell Horne /* 38*7b08a307SMitchell Horne * partedit implementation for platforms on which the installer only offers 39*7b08a307SMitchell Horne * UEFI-based boot. Currently, this includes arm64 and RISC-V. 40*7b08a307SMitchell Horne */ 41*7b08a307SMitchell Horne 42*7b08a307SMitchell Horne /* EFI partition size in bytes */ 43*7b08a307SMitchell Horne #define EFI_BOOTPART_SIZE (260 * 1024 * 1024) 44*7b08a307SMitchell Horne 45*7b08a307SMitchell Horne const char * 46*7b08a307SMitchell Horne default_scheme(void) 47*7b08a307SMitchell Horne { 48*7b08a307SMitchell Horne 49*7b08a307SMitchell Horne return ("GPT"); 50*7b08a307SMitchell Horne } 51*7b08a307SMitchell Horne 52*7b08a307SMitchell Horne int 53*7b08a307SMitchell Horne is_scheme_bootable(const char *part_type) 54*7b08a307SMitchell Horne { 55*7b08a307SMitchell Horne 56*7b08a307SMitchell Horne if (strcmp(part_type, "GPT") == 0) 57*7b08a307SMitchell Horne return (1); 58*7b08a307SMitchell Horne 59*7b08a307SMitchell Horne return (0); 60*7b08a307SMitchell Horne } 61*7b08a307SMitchell Horne 62*7b08a307SMitchell Horne int 63*7b08a307SMitchell Horne is_fs_bootable(const char *part_type, const char *fs) 64*7b08a307SMitchell Horne { 65*7b08a307SMitchell Horne 66*7b08a307SMitchell Horne if (strcmp(fs, "freebsd-ufs") == 0) 67*7b08a307SMitchell Horne return (1); 68*7b08a307SMitchell Horne 69*7b08a307SMitchell Horne return (0); 70*7b08a307SMitchell Horne } 71*7b08a307SMitchell Horne 72*7b08a307SMitchell Horne size_t 73*7b08a307SMitchell Horne bootpart_size(const char *scheme) 74*7b08a307SMitchell Horne { 75*7b08a307SMitchell Horne 76*7b08a307SMitchell Horne /* We only support GPT with EFI */ 77*7b08a307SMitchell Horne if (strcmp(scheme, "GPT") != 0) 78*7b08a307SMitchell Horne return (0); 79*7b08a307SMitchell Horne 80*7b08a307SMitchell Horne return (EFI_BOOTPART_SIZE); 81*7b08a307SMitchell Horne } 82*7b08a307SMitchell Horne 83*7b08a307SMitchell Horne const char * 84*7b08a307SMitchell Horne bootpart_type(const char *scheme, const char **mountpoint) 85*7b08a307SMitchell Horne { 86*7b08a307SMitchell Horne 87*7b08a307SMitchell Horne /* Only EFI is supported as boot partition */ 88*7b08a307SMitchell Horne return ("efi"); 89*7b08a307SMitchell Horne } 90*7b08a307SMitchell Horne 91*7b08a307SMitchell Horne const char * 92*7b08a307SMitchell Horne bootcode_path(const char *part_type) 93*7b08a307SMitchell Horne { 94*7b08a307SMitchell Horne 95*7b08a307SMitchell Horne return (NULL); 96*7b08a307SMitchell Horne } 97*7b08a307SMitchell Horne 98*7b08a307SMitchell Horne const char * 99*7b08a307SMitchell Horne partcode_path(const char *part_type, const char *fs_type) 100*7b08a307SMitchell Horne { 101*7b08a307SMitchell Horne 102*7b08a307SMitchell Horne /* No boot partition data. */ 103*7b08a307SMitchell Horne return (NULL); 104*7b08a307SMitchell Horne } 105*7b08a307SMitchell Horne 106