interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / build-fw.sh

44 lines · 2838 bytes Raw Blame History
1#!/bin/sh
2# The firmware-hosted Allen with the native look, as one Omega unit for `target x86efi`.
3# usage: build-fw.sh OUT.EFI (OMEGA_COMPILER selects the compiler; its digest must be the pin)
4# Order matters: globals and texts precede their use; every module lists what it needs.
5set -eu
6[ "$#" = 1 ] || { echo 'usage: build-fw.sh OUT.EFI' >&2; exit 64; }
7root=$(CDPATH= cd -- "$(dirname "$0")/../../.." && pwd)
8A=$root/native/omega/allen
9compiler=${OMEGA_COMPILER:-"$root/build/allen-toolchain/seed/out/omc"}
10[ -f "$compiler" ] && [ -x "$compiler" ] || { echo 'pinned compiler missing; follow native/omega/allen/README.md' >&2; exit 69; }
11# Pin: omega-mv b8bd1d03 (local branch fix/imac-net-L974-snp on 81ab1900, tag allen-omc-pin-81ab1900; compiler change
12# pending its own review): register slots, live-slot calls, the efi 11 file word, const/bitcast, the 65536-entry site
13# tables the firmware unit needs, and efi 8 keeping a no-link adapter initialized with its scan report in efi 0.
14[ "$(sha256sum "$compiler" | cut -d' ' -f1)" = 2eeab5147deb8320cb1bc7f86a5f3de534955ff89f76be2832155348706e0164 ] || {
15 echo 'compiler digest differs from the qualified pin' >&2
16 exit 65
17}
18out=$1
19[ ! -e "$out" ] || { echo 'fresh output required' >&2; exit 73; }
20unit="$out.om"
21{
22 echo 'target x86efi'
23 for f in platform.om base.om vendor/sha256-core.om font-data.om font.om look-paint.om look-skydata.om look-sky.om \
24 look-night.om look-mind.om look-home.om surface.om github.om http.om net.om tls-crypto.om vendor/cert-sha384.om \
25 vendor/cert-p256.om tls-p384.om vendor/cert-root.om tls-cert.om tls.om session.om repository-screen.om runtime.om \
26 code.om courier.om scheduler.om memory.om intent.om reply.om context.om application.om look-chat.om look-install.om \
27 look-stat.om look-show.om efi-main.om demo.om; do cat "$A/$f"; done
28} > "$unit"
29# Names are one namespace across the unit: a duplicate fn/global/const/text/struct is refused here, not by omc's line.
30dup=$(grep -E '^(fn|global|const|text|struct) ' "$unit" | awk '{print $2}' | sort | uniq -d)
31[ -z "$dup" ] || { echo "duplicate names in the unit: $dup" >&2; exit 65; }
32if ! "$compiler" < "$unit" > "$out.tmp" 2> "$out.err"; then
33 rc=$?
34 L=$(grep -o 'line [0-9]*' "$out.err" | cut -d' ' -f2 || true)
35 echo "compile rc=$rc $(cat "$out.err")" >&2
36 [ -n "$L" ] && { sed -n "${L}p" "$unit"; awk -v L="$L" 'NR<=L && /^fn /{f=$2} END{print "in fn " f}' "$unit"; } >&2
37 rm -f "$out.tmp"
38 exit "$rc"
39fi
40[ -s "$out.tmp" ]
41# PE32+ for x64: MZ at 0 and the PE signature where e_lfanew points.
42[ "$(head -c 2 "$out.tmp")" = MZ ] || { echo 'not a PE image' >&2; rm -f "$out.tmp"; exit 65; }
43mv "$out.tmp" "$out"
44echo "ok $(sha256sum "$out" | cut -c1-16) $(wc -c < "$out") bytes, $(wc -l < "$unit") lines, $(grep -c '^fn ' "$unit") fns, compiler $(sha256sum "$compiler" | cut -c1-8)"