metropolis/node/core/bios_bootcode: Add legacy bootcode
This change provides a legacy bootcode that shows the user that they
are using an invalid configuration, e.g. not use UEFI. This can be
tested with "qemu-system-i386 -hda bazel-bin/metropolis/node/image.img".
Closes monogon-dev/monogon#142
Change-Id: I3337a70125010aec110ad75647346310cac76d37
Reviewed-on: https://review.monogon.dev/c/monogon/+/3748
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/osbase/build/mkimage/main.go b/osbase/build/mkimage/main.go
index 37691a9..5e2b082 100644
--- a/osbase/build/mkimage/main.go
+++ b/osbase/build/mkimage/main.go
@@ -40,17 +40,19 @@
func main() {
// Fill in the image parameters based on flags.
var (
- efiPayload string
- systemImage string
- abLoaderPayload string
- nodeParams string
- outputPath string
- diskUUID string
- cfg osimage.Params
+ efiPayload string
+ systemImage string
+ abLoaderPayload string
+ biosBootCodePayload string
+ nodeParams string
+ outputPath string
+ diskUUID string
+ cfg osimage.Params
)
flag.StringVar(&efiPayload, "efi", "", "Path to the UEFI payload used")
flag.StringVar(&systemImage, "system", "", "Path to the system partition image used")
flag.StringVar(&abLoaderPayload, "abloader", "", "Path to the abloader payload used")
+ flag.StringVar(&biosBootCodePayload, "bios_bootcode", "", "Optional path to the BIOS bootcode which gets placed at the start of the first block of the image. Limited to 440 bytes, padding is not required. It is only used by legacy BIOS boot.")
flag.StringVar(&nodeParams, "node_parameters", "", "Path to Node Parameters to be written to the ESP (default: don't write Node Parameters)")
flag.StringVar(&outputPath, "out", "", "Path to the resulting disk image or block device")
flag.Int64Var(&cfg.PartitionSize.Data, "data_partition_size", 2048, "Override the data partition size (default 2048 MiB). Used only when generating image files.")
@@ -95,6 +97,14 @@
cfg.NodeParameters = np
}
+ if biosBootCodePayload != "" {
+ bp, err := os.ReadFile(biosBootCodePayload)
+ if err != nil {
+ log.Fatalf("while opening BIOS bootcode at %q: %v", biosBootCodePayload, err)
+ }
+ cfg.BIOSBootCode = bp
+ }
+
// TODO(#254): Build and use dynamically-grown block devices
cfg.Output, err = blockdev.CreateFile(outputPath, 512, 10*1024*1024)
if err != nil {