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/def.bzl b/osbase/build/mkimage/def.bzl
index 3f9327b..33323d7 100644
--- a/osbase/build/mkimage/def.bzl
+++ b/osbase/build/mkimage/def.bzl
@@ -1,22 +1,30 @@
def _node_image_impl(ctx):
img_file = ctx.actions.declare_file(ctx.label.name + ".img")
+
+ arguments = ctx.actions.args()
+ arguments.add_all([
+ "-efi",
+ ctx.file.kernel.path,
+ "-system",
+ ctx.file.system.path,
+ "-abloader",
+ ctx.file.abloader.path,
+ "-out",
+ img_file.path,
+ ])
+
+ if len(ctx.files.bios_bootcode) != 0:
+ arguments.add_all(["-bios_bootcode", ctx.file.bios_bootcode.path])
+
ctx.actions.run(
mnemonic = "MkImage",
executable = ctx.executable._mkimage,
- arguments = [
- "-efi",
- ctx.file.kernel.path,
- "-system",
- ctx.file.system.path,
- "-abloader",
- ctx.file.abloader.path,
- "-out",
- img_file.path,
- ],
+ arguments = [arguments],
inputs = [
ctx.file.kernel,
ctx.file.system,
ctx.file.abloader,
+ ctx.file.bios_bootcode,
],
outputs = [img_file],
)
@@ -45,6 +53,14 @@
mandatory = True,
allow_single_file = True,
),
+ "bios_bootcode": attr.label(
+ doc = """
+ Optional label 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.
+ """,
+ mandatory = False,
+ allow_single_file = True,
+ ),
"_mkimage": attr.label(
doc = "The mkimage executable.",
default = "//osbase/build/mkimage",