Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/tests/fixtures/osc_unit/launch/make-l01.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / tests / fixtures / osc_unit / launch / make-l01.sh` 59 lines ยท 3253 bytes Raw Blame History 1 #!/bin/bash 2 # make-l01.sh: build the C3-3a launch test unit l01_launch_fns.unit with the spec's own generator 3 # helpers. Usage: make-l01.sh SPEC_DIR OUT_DIR 4 # SPEC_DIR a checkout of aien-protocols specs/osc-unit-artifact (needs tools/make-vectors.sh, src/min.ir) 5 # OUT_DIR receives l01_launch_fns.unit and l01.code 6 # Needs as, objcopy, nm, xxd, sha256sum, openssl (Ed25519), bash. No Python. 7 # The helper functions (u8, le16, entry, caps_none, build, resign, the throwaway TEST key "test1") are 8 # taken from SPEC_DIR/tools/make-vectors.sh unchanged: everything before its line `cp "$SRC/min.ir"`. 9 # HONEST LIMIT: the code is hand-assembled (l01.S), not compiled by oscc. The IR section is min.ir 10 # (the spec's compiled vector), so the IR does not describe this code. The IR is attested by the 11 # signer, never checked against the code (spec section 10); the container is valid and the TEST 12 # signer vouches for a mismatch. program_id therefore equals min.osc's. Test fixture only. 13 set -eu 14 export LC_ALL=C 15 mydir=$(cd "$(dirname "$0")" && pwd) 16 SPEC=${1:?SPEC_DIR} 17 OUT=${2:?OUT_DIR} 18 mkdir -p "$OUT" 19 work=$(mktemp -d) 20 trap 'rm -rf "$work"' EXIT 21 n=$(grep -n '^cp "\$SRC/min.ir"' "$SPEC/tools/make-vectors.sh" | head -1 | cut -d: -f1) 22 { echo 'here='"$SPEC/tools"; sed -n "1,$((n - 1))p" "$SPEC/tools/make-vectors.sh" | sed '/^here=/d'; } >"$work/helpers.sh" 23 OUT_UNIT=$OUT 24 set -- "$work/keys-out" "$work/keys-out" # helpers read OUT_DIR=$1, KEYS_DIR=$2 25 mkdir -p "$work/keys-out" 26 SRC=$SPEC/src 27 # shellcheck disable=SC1090 28 . "$work/helpers.sh" 29 OUT=$OUT_UNIT 30 cmp -s "$KEYS/test1.pub" "$SPEC/keys/test1.pub" || { echo "TEST key mismatch: generator is not the frozen one" >&2; exit 1; } 31 32 as -o "$work/l01.o" "$mydir/l01.S" 33 objcopy -O binary -j .text "$work/l01.o" "$work/code" 34 off() { printf '%d' 0x"$(nm "$work/l01.o" | awk -v s="$1" '$3 == s {print $1}')"; } 35 cp "$SRC/min.ir" "$work/ir" 36 { 37 entry 0 1 5 5 0 0 0 0 0 "$(off trap)" trap 38 entry 1 0 5 0 0 0 0 0 0 "$(off spin)" spin 39 entry 2 0 5 0 0 0 0 0 0 "$(off peek0)" peek0 40 entry 3 0 5 0 0 0 0 0 0 "$(off poke_rt)" poke_rt 41 entry 4 0 5 0 0 0 0 0 0 "$(off bare_brk)" bare_brk 42 entry 5 0 5 0 0 0 0 0 0 "$(off exec_stack)" exec_stack 43 entry 6 0 5 0 0 0 0 0 0 "$(off overflow)" overflow 44 entry 7 2 5 12 5 0 0 0 0 "$(off counter)" counter 45 entry 8 1 5 5 0 0 0 0 0 "$(off peek_kernel)" peek_kernel 46 entry 9 2 5 12 5 0 0 0 0 "$(off jump_ws)" jump_ws 47 entry 10 2 5 11 5 0 0 0 0 "$(off jump_in)" jump_in 48 entry 11 0 5 0 0 0 0 0 0 "$(off dirty)" dirty 49 entry 12 0 5 0 0 0 0 0 0 "$(off regs_or)" regs_or 50 entry 13 2 5 12 5 0 0 0 0 "$(off touch_past)" touch_past 51 } >"$work/ent" 52 caps_none >"$work/caps0" 53 build "$OUT/l01_launch_fns.unit" test1 1 5 1 14 "$work/ir" "$work/code" "$work/ent" "$work/caps0" 54 cp "$work/code" "$OUT/l01.code" 55 # l02: l01 with max_stack_bytes = 65552 = 65536 + 16 (offset 36; the container requires a multiple of 16, so this is the smallest legal value over the launcher's 65536 maximum), re-signed. 56 # The launcher must refuse it LIMIT_EXCEEDED (14) before any reservation. 57 patch "$OUT/l01_launch_fns.unit" 36 10 00 01 00 >"$OUT/l02_stack_over.unit" 58 resign "$OUT/l02_stack_over.unit" test1 59 echo "built $OUT/l01_launch_fns.unit $OUT/l02_stack_over.unit"