Files
geramyloveless d6486e4dc8 Phase 1B chunk 6: IP discovery parser + correct team/bundle IDs
Two related changes that unblock the entitlement application + every
post-discovery bringup stage.

(1) IP discovery binary parser ported from upstream
    drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c. Reads the packed
    binary format documented in include/discovery.h:

      binary_header  (sig 0x28211407, 6 × table_info entries)
        └─ table[0] → ip_discovery_header  (sig 'IPDS')
              └─ die_info[N] → die_header
                    └─ ip_v4 [num_ips]
                         { hw_id, instance, num_base_address,
                           major, minor, revision, base_address[] }

    For each ip_v4 with hw_id in {MP0, MP1, GC, MMHUB→GMC, HDP,
    OSSSYS, SDMA0, SDMA1, NBIF→NBIO} we copy base_address[0] into
    DeviceContext.ip via IPBaseTable.set(). PSP/SMU/GMC/etc. queries
    isResolved() before using the base — now those checks pass once
    discovery has been loaded.

    Files:
      dext/amdgpu/amdgpu_discovery.h    structs + DiscoveryParseResult
      dext/amdgpu/amdgpu_discovery.cpp  parser (~230 lines)

    Selector 13 = LoadDiscoveryBinary: client uploads binary via
    DMABuffer (page-aligned per the 16 KB rule), calls
    LoadDiscoveryBin(size). Returns (ok, num_ips_total).

    scripts/macamdgpu_ping.swift gains --load-discovery PATH that
    drives this end-to-end.

    Reference binary committed at docs/reference/gfx1151_discovery.bin
    — pulled live from the Strix Halo box at 10.10.13.8 via
    /sys/kernel/debug/dri/0000:bd:00.0/amdgpu_discovery. Useful for
    parser regression checks. The R9700 has its own discovery binary
    accessible the same way (via the qemu-vfio-apple Linux VM passing
    the card through); pulling that lives on the worklist.

(2) Team ID + bundle identifiers updated to the user's real values:

      DEVELOPMENT_TEAM     YBQ9BU6Q6F  (override with XCODE_TEAM_ID env)
      Host app bundle      com.geramyloveless.MacAMDGPUHost
      Dext bundle          com.geramyloveless.MacAMDGPUHost.MacAMDGPU

    These match the user's Apple Developer team and the prefix already
    used by their qemu-vfio-apple host app, so first build will
    round-trip the bundle IDs to the Apple Developer portal cleanly.

    project.yml + Host/MacAMDGPUHostApp.swift + scripts/build.sh all
    point at the same identifiers.

(3) Dext is now correctly **embedded** in the host app at
    Contents/Library/SystemExtensions/MacAMDGPU.dext (xcodegen
    'embed: true' with no explicit destination now picks the right
    path based on target type = driver-extension).

Build still clean: ** BUILD SUCCEEDED ** for both MacAMDGPU.dext
(126 KB) and MacAMDGPUHost.app on this M5 with Xcode 26.4.1 +
DriverKit SDK 25.4.
2026-05-13 15:25:32 -07:00

95 lines
2.6 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# scripts/build.sh — generate + build the MacAMDGPU Xcode project.
#
# Usage:
# scripts/build.sh # generate (if needed) + build
# scripts/build.sh --gen # generate the .xcodeproj only, no build
# scripts/build.sh --open # generate + open in Xcode (no build)
# scripts/build.sh --clean # remove generated artifacts
# scripts/build.sh --release # build a Release configuration
#
# Required env:
# XCODE_TEAM_ID — your 10-char Apple Developer team prefix.
# `security find-identity -p codesigning` lists yours.
#
set -euo pipefail
cd "$(dirname "$0")/.."
PROJECT_ROOT="$(pwd)"
PROJECT_NAME="MacAMDGPU"
PROJECT_FILE="$PROJECT_ROOT/$PROJECT_NAME.xcodeproj"
config=Debug
do_gen=1
do_build=1
do_open=0
for arg in "$@"; do
case "$arg" in
--gen) do_build=0 ;;
--open) do_open=1; do_build=0 ;;
--clean) rm -rf "$PROJECT_FILE" build/; exit 0 ;;
--release) config=Release ;;
-h|--help)
sed -n '1,20p' "$0"; exit 0 ;;
*) echo "unknown arg: $arg" >&2; exit 2 ;;
esac
done
ensure_xcodegen() {
if command -v xcodegen >/dev/null 2>&1; then
return 0
fi
echo "==> xcodegen not found"
if command -v brew >/dev/null 2>&1; then
echo "==> installing via Homebrew: brew install xcodegen"
brew install xcodegen
else
cat <<EOF
xcodegen is required to generate the .xcodeproj from project.yml.
Install it via Homebrew (\`brew install xcodegen\`) or build from
source: https://github.com/yonaskolb/XcodeGen
If you'd rather wire up the project by hand in Xcode, see
dext/README.md.
EOF
exit 1
fi
}
if [[ $do_gen -eq 1 ]]; then
ensure_xcodegen
# project.yml defaults to YBQ9BU6Q6F (Geramy's team) if env unset.
# Override on the command line for builds against a different team.
echo "==> using DEVELOPMENT_TEAM=${XCODE_TEAM_ID:-YBQ9BU6Q6F}"
echo "==> generating $PROJECT_FILE from project.yml"
xcodegen generate --spec project.yml --project "$PROJECT_ROOT" --quiet
fi
if [[ $do_open -eq 1 ]]; then
echo "==> opening Xcode"
open "$PROJECT_FILE"
exit 0
fi
if [[ $do_build -eq 1 ]]; then
echo "==> xcodebuild ($config)"
xcodebuild \
-project "$PROJECT_FILE" \
-scheme "$PROJECT_NAME"Host \
-configuration "$config" \
-destination 'platform=macOS' \
build | tee build.log
echo ""
echo "==> built — locate the app:"
echo " xcodebuild -showBuildSettings -scheme MacAMDGPUHost \\"
echo " | awk '/ BUILT_PRODUCTS_DIR / {print \$3}'"
echo ""
echo "Next step: drag MacAMDGPUHost.app into /Applications and"
echo "launch it once to activate the dext. See dext/README.md."
fi