metropolis/node: move misplaced packages out of core
abloader, bios_bootcode and minit don't run as part of the core process,
so it doesn't make sense to have them in //metropolis/node/core.
This changes moves these three to //metropolis/node.
Change-Id: I908efb311a138f07a9f1de8e3c23437ff00131ee
Reviewed-on: https://review.monogon.dev/c/monogon/+/4196
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/bios_bootcode/genlogo/BUILD.bazel b/metropolis/node/bios_bootcode/genlogo/BUILD.bazel
new file mode 100644
index 0000000..c8769a4
--- /dev/null
+++ b/metropolis/node/bios_bootcode/genlogo/BUILD.bazel
@@ -0,0 +1,14 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+
+go_library(
+ name = "genlogo_lib",
+ srcs = ["main.go"],
+ importpath = "source.monogon.dev/metropolis/node/bios_bootcode/genlogo",
+ visibility = ["//visibility:private"],
+)
+
+go_binary(
+ name = "genlogo",
+ embed = [":genlogo_lib"],
+ visibility = ["//visibility:public"],
+)
diff --git a/metropolis/node/bios_bootcode/genlogo/def.bzl b/metropolis/node/bios_bootcode/genlogo/def.bzl
new file mode 100644
index 0000000..5db80ee
--- /dev/null
+++ b/metropolis/node/bios_bootcode/genlogo/def.bzl
@@ -0,0 +1,32 @@
+def _build_logo_impl(ctx):
+ arguments = ctx.actions.args()
+
+ arguments.add_all(["--input"] + ctx.files.logo)
+ output = ctx.actions.declare_file("logo.asm")
+ arguments.add_all(["--output", output])
+
+ ctx.actions.run(
+ outputs = [output],
+ inputs = ctx.files.logo,
+ arguments = [arguments],
+ executable = ctx.executable._genlogo,
+ )
+
+ return DefaultInfo(
+ files = depset([output]),
+ )
+
+gen_logo = rule(
+ implementation = _build_logo_impl,
+ attrs = {
+ "logo": attr.label(
+ allow_single_file = True,
+ ),
+ "_genlogo": attr.label(
+ default = Label(":genlogo"),
+ allow_single_file = True,
+ executable = True,
+ cfg = "exec",
+ ),
+ },
+)
diff --git a/metropolis/node/bios_bootcode/genlogo/main.go b/metropolis/node/bios_bootcode/genlogo/main.go
new file mode 100644
index 0000000..f810357
--- /dev/null
+++ b/metropolis/node/bios_bootcode/genlogo/main.go
@@ -0,0 +1,88 @@
+// Copyright The Monogon Project Authors.
+// SPDX-License-Identifier: Apache-2.0
+
+package main
+
+import (
+ "flag"
+ "fmt"
+ "image/color"
+ "image/png"
+ "log"
+ "os"
+)
+
+func main() {
+ input := flag.String("input", "", "")
+ output := flag.String("output", "", "")
+ flag.Parse()
+
+ if *input == "" || *output == "" {
+ log.Fatal("missing input or output flag")
+ }
+
+ inputFile, err := os.Open(*input)
+ if err != nil {
+ log.Fatal("Error opening image file:", err)
+ return
+ }
+ defer inputFile.Close()
+
+ img, err := png.Decode(inputFile)
+ if err != nil {
+ log.Fatal("Error decoding image:", err)
+ }
+
+ if img.Bounds().Dx() != 80 || img.Bounds().Dy() != 20 {
+ log.Fatal("Image dimensions must be 80x20")
+ }
+
+ var linear []uint8
+ for y := 0; y < img.Bounds().Dy(); y++ {
+ for x := 0; x < img.Bounds().Dx(); x++ {
+ gray := color.GrayModel.Convert(img.At(x, y)).(color.Gray).Y
+ linear = append(linear, gray)
+ }
+ }
+
+ // Perform RLE compression
+ var rle []uint8
+ for len(linear) > 0 {
+ val := linear[0]
+ l := uint8(1)
+ for i := 1; i < len(linear); i++ {
+ if linear[i] != val {
+ break
+ }
+ l++
+ }
+
+ L := l
+ for l > 0 {
+ block := l
+ if block > 127 {
+ block = 127
+ }
+ rle = append(rle, (val<<7)|block)
+ l -= block
+ }
+ linear = linear[L:]
+ }
+
+ rle = append(rle, 0)
+
+ outputFile, err := os.Create(*output)
+ if err != nil {
+ log.Fatalf("failed creating output file: %v", err)
+ }
+ defer outputFile.Close()
+
+ outputFile.WriteString("logo: db ")
+ for i, r := range rle {
+ if i > 0 {
+ outputFile.WriteString(", ")
+ }
+ fmt.Fprintf(outputFile, "0x%02x", r)
+ }
+ outputFile.WriteString("\n")
+}