git: 9c296a210573 - main - geom: Add HiFive boot partitions

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 26 Jan 2022 15:55:07 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=9c296a2105734c6928b4e4a9d75d6a17ff9b9bab

commit 9c296a2105734c6928b4e4a9d75d6a17ff9b9bab
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-10-12 18:51:24 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-01-26 15:54:45 +0000

    geom: Add HiFive boot partitions
    
    As documented in the HiFive Unmatched Software Reference Manual.
    
    Reviewed by:    imp, mhorne
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34010
---
 lib/geom/part/gpart.8      | 12 +++++++++++-
 sys/geom/part/g_part.c     |  2 ++
 sys/geom/part/g_part.h     |  2 ++
 sys/geom/part/g_part_gpt.c |  4 ++++
 sys/sys/disk/gpt.h         |  5 +++++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8
index 15335d92221c..4dbe45b9953e 100644
--- a/lib/geom/part/gpart.8
+++ b/lib/geom/part/gpart.8
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 17, 2020
+.Dd January 26, 2022
 .Dt GPART 8
 .Os
 .Sh NAME
@@ -837,6 +837,16 @@ A partition that contains a FAT32 (LBA) filesystem.
 The scheme-specific type is
 .Qq Li "!12"
 for MBR.
+.It Cm hifive-fsbl
+A raw partition containing a HiFive first stage bootloader.
+The scheme-specific type is
+.Qq Li "!5b193300-fc78-40cd-8002-e86c45580b47"
+for GPT.
+.It Cm hifive-bbl
+A raw partition containing a HiFive second stage bootloader.
+The scheme-specific type is
+.Qq Li "!2e54b353-1271-4842-806f-e436d6af6985"
+for GPT.
 .It Cm linux-data
 A Linux partition that contains some filesystem with data.
 The scheme-specific types are
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c
index 57d45911c54d..a0981d89b042 100644
--- a/sys/geom/part/g_part.c
+++ b/sys/geom/part/g_part.c
@@ -103,6 +103,8 @@ struct g_part_alias_list {
 	{ "freebsd-ufs", G_PART_ALIAS_FREEBSD_UFS },
 	{ "freebsd-vinum", G_PART_ALIAS_FREEBSD_VINUM },
 	{ "freebsd-zfs", G_PART_ALIAS_FREEBSD_ZFS },
+	{ "hifive-fsbl", G_PART_ALIAS_HIFIVE_FSBL },
+	{ "hifive-bbl", G_PART_ALIAS_HIFIVE_BBL },
 	{ "linux-data", G_PART_ALIAS_LINUX_DATA },
 	{ "linux-lvm", G_PART_ALIAS_LINUX_LVM },
 	{ "linux-raid", G_PART_ALIAS_LINUX_RAID },
diff --git a/sys/geom/part/g_part.h b/sys/geom/part/g_part.h
index e9ac3052430c..c96cec264b87 100644
--- a/sys/geom/part/g_part.h
+++ b/sys/geom/part/g_part.h
@@ -72,6 +72,8 @@ enum g_part_alias {
 	G_PART_ALIAS_FREEBSD_UFS,	/* A UFS/UFS2 file system entry. */
 	G_PART_ALIAS_FREEBSD_VINUM,	/* A Vinum partition entry. */
 	G_PART_ALIAS_FREEBSD_ZFS,	/* A ZFS file system entry. */
+	G_PART_ALIAS_HIFIVE_FSBL,	/* HiFive First Stage Bootloader */
+	G_PART_ALIAS_HIFIVE_BBL,	/* HiFive Second Stage Bootloader */
 	G_PART_ALIAS_LINUX_DATA,	/* A Linux data partition entry. */
 	G_PART_ALIAS_LINUX_LVM,		/* A Linux LVM partition entry. */
 	G_PART_ALIAS_LINUX_RAID,	/* A Linux RAID partition entry. */
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c
index 1f6d3dff249d..0c472e5ebba6 100644
--- a/sys/geom/part/g_part_gpt.c
+++ b/sys/geom/part/g_part_gpt.c
@@ -193,6 +193,8 @@ static struct uuid gpt_uuid_freebsd_swap = GPT_ENT_TYPE_FREEBSD_SWAP;
 static struct uuid gpt_uuid_freebsd_ufs = GPT_ENT_TYPE_FREEBSD_UFS;
 static struct uuid gpt_uuid_freebsd_vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
 static struct uuid gpt_uuid_freebsd_zfs = GPT_ENT_TYPE_FREEBSD_ZFS;
+static struct uuid gpt_uuid_hifive_fsbl = GPT_ENT_TYPE_HIFIVE_FSBL;
+static struct uuid gpt_uuid_hifive_bbl = GPT_ENT_TYPE_HIFIVE_BBL;
 static struct uuid gpt_uuid_linux_data = GPT_ENT_TYPE_LINUX_DATA;
 static struct uuid gpt_uuid_linux_lvm = GPT_ENT_TYPE_LINUX_LVM;
 static struct uuid gpt_uuid_linux_raid = GPT_ENT_TYPE_LINUX_RAID;
@@ -263,6 +265,8 @@ static struct g_part_uuid_alias {
 	{ &gpt_uuid_freebsd_ufs,	G_PART_ALIAS_FREEBSD_UFS,	 0 },
 	{ &gpt_uuid_freebsd_vinum,	G_PART_ALIAS_FREEBSD_VINUM,	 0 },
 	{ &gpt_uuid_freebsd_zfs,	G_PART_ALIAS_FREEBSD_ZFS,	 0 },
+	{ &gpt_uuid_hifive_fsbl,	G_PART_ALIAS_HIFIVE_FSBL,	 0 },
+	{ &gpt_uuid_hifive_bbl,		G_PART_ALIAS_HIFIVE_BBL,	 0 },
 	{ &gpt_uuid_linux_data,		G_PART_ALIAS_LINUX_DATA,	 0x0b },
 	{ &gpt_uuid_linux_lvm,		G_PART_ALIAS_LINUX_LVM,		 0 },
 	{ &gpt_uuid_linux_raid,		G_PART_ALIAS_LINUX_RAID,	 0 },
diff --git a/sys/sys/disk/gpt.h b/sys/sys/disk/gpt.h
index 3cb8d8e071e8..e4faef2c37fb 100644
--- a/sys/sys/disk/gpt.h
+++ b/sys/sys/disk/gpt.h
@@ -249,6 +249,11 @@ CTASSERT(sizeof(struct gpt_ent) == 128);
 #define GPT_ENT_TYPE_SOLARIS_RESERVED	\
 	{0x6a945a3b,0x1dd2,0x11b2,0x99,0xa6,{0x08,0x00,0x20,0x73,0x66,0x31}}
 
+#define GPT_ENT_TYPE_HIFIVE_FSBL	\
+	{0x5b193300,0xfc78,0x40cd,0x80,0x02,{0xe8,0x6c,0x45,0x58,0x0b,0x47}}
+#define GPT_ENT_TYPE_HIFIVE_BBL		\
+	{0x2e54b353,0x1271,0x4842,0x80,0x6f,{0xe4,0x36,0xd6,0xaf,0x69,0x85}}
+
 /*
  * Boot partition used by GRUB 2.
  */