Close the Shanghai experiment without denying the existing Zhuyuan subject, parameterize the native layout for the JD Cloud disk, and add fail-closed one-time probe preparation, arming, and return verification.
71 lines
2.2 KiB
Shell
Executable file
71 lines
2.2 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
[[ $# -eq 1 ]] || {
|
|
echo "usage: native-layout-nasm-args.sh <world-root>" >&2
|
|
exit 64
|
|
}
|
|
|
|
manifest=$(readlink -f "$1/WORLD-MANIFEST.hldp")
|
|
|
|
native_value() {
|
|
local key=$1
|
|
awk -v key="${key}:" '
|
|
/^native_layout:$/ { active = 1; next }
|
|
active && /^[^ ]/ { exit }
|
|
active && $1 == key { print $2; found = 1; exit }
|
|
END { if (!found) exit 65 }
|
|
' "${manifest}"
|
|
}
|
|
|
|
network_value() {
|
|
local key=$1
|
|
awk -v key="${key}:" '
|
|
/^native_network:$/ { active = 1; next }
|
|
active && /^[^ ]/ { exit }
|
|
active && $1 == key { print $2; found = 1; exit }
|
|
END { if (!found) exit 65 }
|
|
' "${manifest}"
|
|
}
|
|
|
|
ipv4_dword() {
|
|
local address=$1
|
|
local a b c d
|
|
IFS=. read -r a b c d <<<"${address}"
|
|
for octet in "${a}" "${b}" "${c}" "${d}"; do
|
|
[[ ${octet} =~ ^[0-9]+$ ]]
|
|
((octet >= 0 && octet <= 255))
|
|
done
|
|
printf '0x%02x%02x%02x%02x' "${d}" "${c}" "${b}" "${a}"
|
|
}
|
|
|
|
kernel_lba=$(native_value kernel_lba_start)
|
|
proof_lba=$(native_value proof_lba)
|
|
world_store_lba=$(native_value world_store_lba)
|
|
code_channel_store_lba=$(native_value code_channel_store_lba)
|
|
code_object_lba=$(native_value code_object_lba)
|
|
branch_receipt_lba=$(native_value branch_receipt_lba)
|
|
recovery_beacon_lba=$(native_value recovery_beacon_lba_start)
|
|
gestational_index_lba=$(native_value gestational_index_lba_start)
|
|
native_ipv4=$(ipv4_dword "$(network_value native_ipv4)")
|
|
gateway_ipv4=$(ipv4_dword "$(network_value gateway_ipv4)")
|
|
|
|
for value in \
|
|
"${kernel_lba}" "${proof_lba}" "${world_store_lba}" \
|
|
"${code_channel_store_lba}" "${code_object_lba}" \
|
|
"${branch_receipt_lba}" "${recovery_beacon_lba}" \
|
|
"${gestational_index_lba}"; do
|
|
[[ ${value} =~ ^[0-9]+$ ]]
|
|
done
|
|
|
|
printf '%s\n' \
|
|
"-dSTAGE2_LBA=$((kernel_lba + 1))" \
|
|
"-dGHOS_NATIVE_PROOF_LBA=${proof_lba}" \
|
|
"-dGHOS_NATIVE_WORLD_STORE_LBA=${world_store_lba}" \
|
|
"-dGHOS_NATIVE_CODE_CHANNEL_STORE_LBA=${code_channel_store_lba}" \
|
|
"-dGHOS_NATIVE_CODE_OBJECT_LBA=${code_object_lba}" \
|
|
"-dGHOS_NATIVE_BRANCH_RECEIPT_LBA=${branch_receipt_lba}" \
|
|
"-dGHOS_NATIVE_RECOVERY_BEACON_LBA=${recovery_beacon_lba}" \
|
|
"-dGHOS_NATIVE_GESTATIONAL_INDEX_LBA=${gestational_index_lba}" \
|
|
"-dGHOS_NATIVE_IPV4_DWORD=${native_ipv4}" \
|
|
"-dGHOS_GATEWAY_IPV4_DWORD=${gateway_ipv4}"
|