f352a0d45f
on i386 and amd64 machines. The overall process is that /boot/pmbr lives in the PMBR (similar to /boot/mbr for MBR disks) and is responsible for locating and loading /boot/gptboot. /boot/gptboot is similar to /boot/boot except that it groks GPT rather than MBR + bsdlabel. Unlike /boot/boot, /boot/gptboot lives in its own dedicated GPT partition with a new "FreeBSD boot" type. This partition does not have a fixed size in that /boot/pmbr will load the entire partition into the lower 640k. However, it is limited in that it can only be 545k. That's still a lot better than the current 7.5k limit for boot2 on MBR. gptboot mostly acts just like boot2 in that it reads /boot.config and loads up /boot/loader. Some more details: - Include uuid_equal() and uuid_is_nil() in libstand. - Add a new 'boot' command to gpt(8) which makes a GPT disk bootable using /boot/pmbr and /boot/gptboot. Note that the disk must have some free space for the boot partition. - This required exposing the backend of the 'add' function as a gpt_add_part() function to the rest of gpt(8). 'boot' uses this to create a boot partition if needed. - Don't cripple cgbase() in the UFS boot code for /boot/gptboot so that it can handle a filesystem > 1.5 TB. - /boot/gptboot has a simple loader (gptldr) that doesn't do any I/O unlike boot1 since /boot/pmbr loads all of gptboot up front. The C portion of gptboot (gptboot.c) has been repocopied from boot2.c. The primary changes are to parse the GPT to find a root filesystem and to use 64-bit disk addresses. Currently gptboot assumes that the first UFS partition on the disk is the / filesystem, but this algorithm will likely be improved in the future. - Teach the biosdisk driver in /boot/loader to understand GPT tables. GPT partitions are identified as 'disk0pX:' (e.g. disk0p2:) which is similar to the /dev names the kernel uses (e.g. /dev/ad0p2). - Add a new "freebsd-boot" alias to g_part() for the new boot UUID. MFC after: 1 month Discussed with: marcel (some things might still change, but am committing what I have so far)
124 lines
4.6 KiB
C
124 lines
4.6 KiB
C
/*-
|
|
* Copyright (c) 2002 Marcel Moolenaar
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
* $FreeBSD$
|
|
*/
|
|
|
|
#ifndef _SYS_GPT_H_
|
|
#define _SYS_GPT_H_
|
|
|
|
#include <sys/uuid.h>
|
|
|
|
struct gpt_hdr {
|
|
char hdr_sig[8];
|
|
#define GPT_HDR_SIG "EFI PART"
|
|
uint32_t hdr_revision;
|
|
#define GPT_HDR_REVISION 0x00010000
|
|
uint32_t hdr_size;
|
|
uint32_t hdr_crc_self;
|
|
uint32_t __reserved;
|
|
uint64_t hdr_lba_self;
|
|
uint64_t hdr_lba_alt;
|
|
uint64_t hdr_lba_start;
|
|
uint64_t hdr_lba_end;
|
|
struct uuid hdr_uuid;
|
|
uint64_t hdr_lba_table;
|
|
uint32_t hdr_entries;
|
|
uint32_t hdr_entsz;
|
|
uint32_t hdr_crc_table;
|
|
/*
|
|
* The header as defined in the EFI spec is not a multiple of 8 bytes
|
|
* and given that the alignment requirement is on an 8 byte boundary,
|
|
* padding will happen. We make the padding explicit so that we can
|
|
* correct the value returned by sizeof() when we put the size of the
|
|
* header in field hdr_size, or otherwise use offsetof().
|
|
*/
|
|
uint32_t padding;
|
|
};
|
|
|
|
struct gpt_ent {
|
|
struct uuid ent_type;
|
|
struct uuid ent_uuid;
|
|
uint64_t ent_lba_start;
|
|
uint64_t ent_lba_end;
|
|
uint64_t ent_attr;
|
|
#define GPT_ENT_ATTR_PLATFORM (1ULL << 0)
|
|
uint16_t ent_name[36]; /* UTF-16. */
|
|
};
|
|
|
|
#define GPT_ENT_TYPE_UNUSED \
|
|
{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
|
|
#define GPT_ENT_TYPE_EFI \
|
|
{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}
|
|
#define GPT_ENT_TYPE_MBR \
|
|
{0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
|
|
#define GPT_ENT_TYPE_FREEBSD \
|
|
{0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
#define GPT_ENT_TYPE_FREEBSD_SWAP \
|
|
{0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
#define GPT_ENT_TYPE_FREEBSD_UFS \
|
|
{0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
#define GPT_ENT_TYPE_FREEBSD_VINUM \
|
|
{0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
#define GPT_ENT_TYPE_FREEBSD_ZFS \
|
|
{0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
#define GPT_ENT_TYPE_FREEBSD_BOOT \
|
|
{0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
|
|
|
|
/*
|
|
* The following are unused but documented here to avoid reuse.
|
|
*
|
|
* GPT_ENT_TYPE_FREEBSD_UFS2 \
|
|
* {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
|
|
*/
|
|
|
|
/*
|
|
* Foreign partition types that we're likely to encounter. Note that Linux
|
|
* apparently choose to share data partitions with MS. I don't what the
|
|
* advantage might be. I can see how sharing swap partitions is advantageous
|
|
* though.
|
|
*/
|
|
#define GPT_ENT_TYPE_MS_RESERVED \
|
|
{0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}}
|
|
#define GPT_ENT_TYPE_MS_BASIC_DATA \
|
|
{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}
|
|
#define GPT_ENT_TYPE_MS_LDM_METADATA \
|
|
{0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}}
|
|
#define GPT_ENT_TYPE_MS_LDM_DATA \
|
|
{0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}}
|
|
|
|
#define GPT_ENT_TYPE_LINUX_DATA GPT_ENT_TYPE_MS_BASIC_DATA
|
|
#define GPT_ENT_TYPE_LINUX_RAID \
|
|
{0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}}
|
|
#define GPT_ENT_TYPE_LINUX_SWAP \
|
|
{0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}}
|
|
#define GPT_ENT_TYPE_LINUX_LVM \
|
|
{0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}}
|
|
|
|
#define GPT_ENT_TYPE_APPLE_HFS \
|
|
{0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
|
|
|
|
#endif /* _SYS_GPT_H_ */
|