31 lines
1,002 B
Shell
Executable file
31 lines
1,002 B
Shell
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
[[ $# -eq 3 ]] || {
|
|
echo "usage: build-native-physical-probe.sh <world-root> <output-directory> <probe-stage>" >&2
|
|
exit 64
|
|
}
|
|
|
|
world_root=$(readlink -f "$1")
|
|
output_root=$(readlink -m "$2")
|
|
probe_stage=$3
|
|
[[ ${probe_stage} =~ ^[1-9]$ ]]
|
|
source_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
native_root=${source_root}/native/x86_64-bios
|
|
|
|
command -v nasm >/dev/null
|
|
mkdir -p "${output_root}"
|
|
cargo run --quiet --manifest-path "${source_root}/Cargo.toml" \
|
|
-p hldp-native-compiler -- "${world_root}" "${output_root}/world.inc"
|
|
(
|
|
cd "${output_root}"
|
|
nasm -f bin -I "${output_root}/" -I "${native_root}/" \
|
|
-dSTAGE2_LBA=35 \
|
|
-dGHOS_PHYSICAL_CANDIDATE=1 \
|
|
-dGHOS_GHAL_PROBE_STAGE="${probe_stage}" \
|
|
"${native_root}/boot.asm" \
|
|
-o "guanghu-os-x86_64-bios-probe-${probe_stage}.img"
|
|
)
|
|
image=${output_root}/guanghu-os-x86_64-bios-probe-${probe_stage}.img
|
|
[[ $(stat -c %s "${image}") -eq 14848 ]]
|
|
sha256sum "${image}" >"${image}.sha256"
|