m/p/gpt: add GPT package

This introduces our own GPT package. It will be used for provisioning
and Metropolis images.

Change-Id: I905cd5d540673fd4b69c01d8975f98b88e24edd4
Reviewed-on: https://review.monogon.dev/c/monogon/+/956
Tested-by: Jenkins CI
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
diff --git a/metropolis/pkg/gpt/mbr_test.go b/metropolis/pkg/gpt/mbr_test.go
new file mode 100644
index 0000000..2ed4ed1
--- /dev/null
+++ b/metropolis/pkg/gpt/mbr_test.go
@@ -0,0 +1,30 @@
+package gpt
+
+import "testing"
+
+func TestToCHS(t *testing.T) {
+	cases := []struct {
+		name        string
+		lba         int64
+		expectedCHS [3]byte
+	}{
+		{ // See UEFI Specification 2.9 Table 5-4 StartingCHS
+			name:        "One",
+			lba:         1,
+			expectedCHS: [3]byte{0x00, 0x02, 0x00},
+		},
+		{
+			name:        "TooBig",
+			lba:         (1023 * 255 * 63) + 1,
+			expectedCHS: [3]byte{0xff, 0xff, 0xff},
+		},
+	}
+	for _, c := range cases {
+		t.Run(c.name, func(t *testing.T) {
+			chs := toCHS(c.lba)
+			if chs != c.expectedCHS {
+				t.Errorf("expected %x, got %x", c.expectedCHS, chs)
+			}
+		})
+	}
+}