# AMD GPU retained display glue path for Redox OS # Scope: bounded Red Bear display glue path for init, connector detection, and modeset. # Imported Linux AMD DC / TTM / amdgpu core trees remain adjacent source under compile triage and # are not part of the default retained build path. Full acceleration still requires broader GPU work # plus Mesa radeonsi backend enablement. [source] # Local overlay recipe. The extracted Linux 7.0-rc7 AMDGPU tree lives next to this # recipe at ../amdgpu-source and is referenced by the custom build script below. path = "source" [build] template = "custom" dependencies = [ "redox-driver-sys", "linux-kpi", "firmware-loader", ] script = """ DYNAMIC_INIT # Paths AMD_ROOT="${COOKBOOK_SOURCE}/../../amdgpu-source/gpu/drm/amd" AMD_SRC="${AMD_ROOT}" INCLUDES="${COOKBOOK_SOURCE}/../../amdgpu-source/include" LINUX_KPI="${COOKBOOK_ROOT}/local/recipes/drivers/linux-kpi/source/src/c_headers" REDOX_GLUE="${COOKBOOK_SOURCE}" TARGET_CC="${TARGET}-gcc" # Compiler flags for the bounded retained AMD path. Legacy AMD DC config defines remain here only # for header compatibility with the adjacent imported Linux source trees. export CFLAGS="-D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_DRM_AMD_DC \ -DCONFIG_DRM_AMD_DC_DML2=1 \ -DCONFIG_DRM_AMD_DC_FP -DCONFIG_DRM_AMD_ACP \ -I${LINUX_KPI} \ -I${REDOX_GLUE} \ -I${INCLUDES} \ -I${INCLUDES}/drm \ -I${AMD_SRC}/include \ -I${AMD_SRC}/include/asic_reg \ -I${AMD_SRC}/display \ -I${AMD_SRC}/display/dc \ -I${AMD_SRC}/display/dc/dml \ -I${AMD_SRC}/display/dc/dml2_0 \ -I${AMD_SRC}/display/dc/dml2_0/dml21 \ -I${AMD_SRC}/display/dc/dcn20 \ -I${AMD_SRC}/display/dc/dcn21 \ -I${AMD_SRC}/display/dc/dcn30 \ -I${AMD_SRC}/display/dc/dcn301 \ -I${AMD_SRC}/display/dc/dcn31 \ -I${AMD_SRC}/display/dc/dcn32 \ -I${AMD_SRC}/display/dc/dcn35 \ -I${AMD_SRC}/display/dmub \ -I${AMD_SRC}/display/modules \ -I${AMD_SRC}/display/modules/freesync \ -I${AMD_SRC}/display/modules/color \ -I${AMD_SRC}/display/modules/info_packet \ -I${AMD_SRC}/display/modules/power \ -I${AMD_SRC}/pm/swsmu \ -I${AMD_SRC}/pm/swsmu/inc \ -I${AMD_SRC}/pm/powerplay \ -I${AMD_SRC}/pm/powerplay/inc \ -I${AMD_SRC}/pm/powerplay/hwmgr \ -fPIC -O2 -Wall -Wno-unused-function -Wno-unused-variable \ -Wno-address-of-packed-member -Wno-initializer-overrides" # Stage 1: Compile Redox glue code "${TARGET_CC}" -c ${CFLAGS} "${REDOX_GLUE}/amdgpu_redox_main.c" -o amdgpu_redox_main.o "${TARGET_CC}" -c ${CFLAGS} "${REDOX_GLUE}/redox_stubs.c" -o redox_stubs.o # Stage 2: Bounded first-display path # # The current Red Bear AMD display bring-up path does not call into the imported # Linux AMD Display Core tree directly. The live FFI surface comes from the # Red Bear glue layer (`amdgpu_redox_main.c` / `redox_stubs.c`), while the # broad `display/*.c` compile currently drags in optional and unsupported # subtrees such as freesync before the retained path is even proven. # # Keep Stage 2 explicit and intentionally empty until a retained imported # display-source subset is proven necessary by bounded compile triage. DISPLAY_SRCS="" success=0 failed=0 for src in $DISPLAY_SRCS; do obj=$(basename "${src%.c}.o") if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then success=$((success + 1)) else failed=$((failed + 1)) echo "ERROR: failed to compile $(basename $src)" cat "${obj}.log" exit 1 fi done echo "Stage 2: bounded AMD display path compiled ${success} imported display files, ${failed} failed" # Stage 3: Imported TTM path # # The current bounded Red Bear display path uses Rust-side GEM/GTT/ring handling in # `redox-drm`, not the imported Linux TTM stack. Keep this explicit and empty until # the bounded path proves a concrete need for imported TTM code. TTM_SRCS="" success=0 failed=0 for src in $TTM_SRCS; do obj=$(basename "${src%.c}.o") if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then success=$((success + 1)) else failed=$((failed + 1)) echo "ERROR: failed to compile $(basename $src)" cat "${obj}.log" exit 1 fi done echo "Stage 3: bounded imported TTM path compiled ${success} files, ${failed} failed" # Stage 4: Imported amdgpu core path # # The current bounded Red Bear display path uses the custom glue layer for init, # connector enumeration, and modeset, while Rust-side code owns GEM/GTT/ring state. # Keep imported amdgpu core sources out of the retained compile surface until the # bounded path proves a specific dependency on them. CORE_SRCS="" success=0 failed=0 for src_name in $CORE_SRCS; do src="${AMD_SRC}/amdgpu/${src_name}" if [ -f "$src" ]; then obj="${src_name%.c}.o" if "${TARGET_CC}" -c ${CFLAGS} "$src" -o "$obj" 2>"${obj}.log"; then success=$((success + 1)) else failed=$((failed + 1)) echo "ERROR: failed to compile $src_name" cat "${obj}.log" exit 1 fi fi done echo "Stage 4: amdgpu core compiled ${success} files, ${failed} failed" # Stage 5: Link into shared library OBJS="" for obj in $(find . -name '*.o' -size +0c); do OBJS="$OBJS $obj" done if [ -z "$OBJS" ]; then echo "ERROR: no object files compiled successfully" exit 1 fi "${TARGET_CC}" -shared -o libamdgpu_dc_redox.so $OBJS -lm -lpthread # Install mkdir -p "${COOKBOOK_STAGE}/usr/lib/redox/drivers" cp libamdgpu_dc_redox.so "${COOKBOOK_STAGE}/usr/lib/redox/drivers/" mkdir -p "${COOKBOOK_STAGE}/usr/include/amdgpu-redox" cp "${REDOX_GLUE}/redox_glue.h" "${COOKBOOK_STAGE}/usr/include/amdgpu-redox/" """