Create new seed from `cd4c665`

c42dbf4a6ed99795b13c9737713d96d010ed92f0c6812c46db89782ca451a732
Check in a seed in the self-contained image format, and add `seed/test`,
run by `make test`, which checks that the seed is such an image.
Alexis Sellier committed ago 1 parent cd4c6650
Makefile +5 -2
21 21
22 22
# Verify the emulator binary exists.
23 23
EMU_PATH := $(shell command -v $(EMU) 2>/dev/null)
24 24
25 25
default: emulator $(RAD_BIN)
26 -
test: emulator std-test bin-test
26 +
test: emulator seed-test std-test bin-test
27 +
28 +
seed-test:
29 +
	@seed/test
27 30
28 31
# Emulator command check
29 32
30 33
emulator:
31 34
ifeq ($(EMU_PATH),)
117 120
clean: clean-std-test clean-bin-test clean-rad
118 121
119 122
t: test
120 123
c: clean
121 124
122 -
.PHONY: test clean default std-test bin-test seed \
125 +
.PHONY: test clean default seed-test std-test bin-test seed \
123 126
	clean-std-test clean-bin-test clean-rad emulator
124 127
.SUFFIXES:
125 128
.DELETE_ON_ERROR:
126 129
.SILENT:
seed/README +2 -3
37 37
                  affected by.
38 38
39 39
40 40
FILES
41 41
42 -
  seed/radiance.rv64           Seed binary (RISC-V machine code).
43 -
  seed/radiance.rv64.ro.data   Read-only data section.
44 -
  seed/radiance.rv64.rw.data   Read-write data section.
42 +
  seed/radiance.rv64           Self-contained RV64 image containing the seed's
43 +
                               text, read-only data, and read-write data.
45 44
  seed/radiance.rv64.git       SHA-256 of the git commit whose *source*
46 45
                               was compiled to produce this seed.
47 46
  seed/update                  Tool that finds the fixed point and
48 47
                               updates the seed.
49 48
seed/radiance.rv64 +0 -0

Binary file changed.

seed/radiance.rv64.git +1 -1
1 -
5e540047274d636e694a0ae1fc1667f324e146dac97bd90c7942e65e01f54325
1 +
cd4c66504e92946940d8e1315dcf2347997d7eb3cc80dd7540e6d094f2549223
seed/radiance.rv64.ro.data deleted +0 -0

Binary file changed.

seed/radiance.rv64.rw.data deleted +0 -0

Binary file changed.

seed/test added +24 -0
1 +
#!/bin/sh
2 +
# Verify that the checked-in seed and its workflow use self-contained images.
3 +
set -eu
4 +
5 +
fail() {
6 +
  printf 'seed test: %s\n' "$*" >&2
7 +
  exit 1
8 +
}
9 +
10 +
magic="$(od -An -tx4 -N4 seed/radiance.rv64 | tr -d ' ')"
11 +
[ "$magic" = "30444152" ] || fail "seed is not a self-contained RV64 image"
12 +
13 +
version="$(od -An -tu4 -j4 -N4 seed/radiance.rv64 | tr -d ' ')"
14 +
[ "$version" = "1" ] || fail "unsupported seed image version: $version"
15 +
16 +
size="$(wc -c < seed/radiance.rv64 | tr -d ' ')"
17 +
code="$(od -An -tu4 -j8 -N4 seed/radiance.rv64 | tr -d ' ')"
18 +
ro="$(od -An -tu4 -j12 -N4 seed/radiance.rv64 | tr -d ' ')"
19 +
rw="$(od -An -tu4 -j16 -N4 seed/radiance.rv64 | tr -d ' ')"
20 +
21 +
[ "$size" -eq $((20 + code + ro + rw)) ] ||
22 +
  fail "seed image size $size does not match header sections"
23 +
24 +
printf 'seed test: ok\n'
seed/update +2 -6
74 74
# ---------------------------------------------------------------------------
75 75
# Compare two stage binaries. Returns 0 if identical, 1 if they differ.
76 76
# ---------------------------------------------------------------------------
77 77
78 78
compareStages() {
79 -
  if cmp -s "$1" "$2" \
80 -
  && cmp -s "$1.ro.data" "$2.ro.data" \
81 -
  && cmp -s "$1.rw.data" "$2.rw.data"; then
79 +
  if cmp -s "$1" "$2"; then
82 80
    printf " IDENTICAL\n  sha256: %s\n" "$(sha256sum "$2" | cut -d' ' -f1)"
83 81
    return 0
84 82
  else
85 83
    printf " DIFFERENT\n"
86 84
    return 1
90 88
# ---------------------------------------------------------------------------
91 89
# Copy the fixed-point binary to the seed.
92 90
# ---------------------------------------------------------------------------
93 91
94 92
updateSeed() {
95 -
  [ "$1"         != seed/radiance.rv64 ]         && cp "$1"         seed/radiance.rv64
96 -
  [ "$1.ro.data" != seed/radiance.rv64.ro.data ] && cp "$1.ro.data" seed/radiance.rv64.ro.data
97 -
  [ "$1.rw.data" != seed/radiance.rv64.rw.data ] && cp "$1.rw.data" seed/radiance.rv64.rw.data
93 +
  [ "$1" != seed/radiance.rv64 ] && cp "$1" seed/radiance.rv64
98 94
99 95
  git rev-parse HEAD > seed/radiance.rv64.git
100 96
101 97
  printf "\n"
102 98
  printf "Fixed point reached at %s\n" "$2"