diff --git a/local/recipes/gpu/amdgpu/recipe.toml b/local/recipes/gpu/amdgpu/recipe.toml index d6e37209fa..441d45b939 100644 --- a/local/recipes/gpu/amdgpu/recipe.toml +++ b/local/recipes/gpu/amdgpu/recipe.toml @@ -72,6 +72,7 @@ export CFLAGS="-std=gnu11 -D__redox__ -D__KERNEL__ -DCONFIG_DRM_AMDGPU -DCONFIG_ # 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 +"${TARGET_CC}" -c ${CFLAGS} "${REDOX_GLUE}/redox_quirk_bridge.c" -o redox_quirk_bridge.o # Stage 2: DCN hardware display files # diff --git a/local/recipes/gpu/amdgpu/source/redox_quirk_bridge.c b/local/recipes/gpu/amdgpu/source/redox_quirk_bridge.c new file mode 100644 index 0000000000..083bbe635f --- /dev/null +++ b/local/recipes/gpu/amdgpu/source/redox_quirk_bridge.c @@ -0,0 +1,38 @@ +/* R1–R10 audit Gap 15: amdgpu C ↔ redox-drm Rust quirk-flag bridge. + * + * The data flow is: + * 1. redox-drm (Rust) calls + * `redox_driver_sys::quirks::lookup_pci_quirks_full(&info)` — + * the same path pcid uses at enumeration time. The result is + * a real 64-bit flag word from the compiled-in table + TOML. + * 2. Rust pushes the word into this TU via + * `redox_pci_set_quirk_flags` (defined below). + * 3. amdgpu C reads via `pci_get_quirk_flags` / `pci_has_quirk`. + * + * The previously-shared `redox_stubs.c` was misleading: the flag + * word is real, not a fake constant. Splitting the bridge out is + * the audit's documentation fix. Rust-side caller is + * `local/recipes/gpu/redox-drm/source/src/drivers/amd/display.rs:155`. + */ + +#include "redox_glue.h" + +static u64 g_redox_quirk_flags; + +void redox_pci_set_quirk_flags(u64 quirk_flags) +{ + g_redox_quirk_flags = quirk_flags; + printk("PCI quirk flags stored: %#llx\n", (unsigned long long)quirk_flags); +} + +u64 pci_get_quirk_flags(struct pci_dev *pdev) +{ + (void)pdev; + return g_redox_quirk_flags; +} + +bool pci_has_quirk(struct pci_dev *pdev, u64 flag) +{ + (void)pdev; + return (g_redox_quirk_flags & flag) != 0; +} diff --git a/local/recipes/gpu/amdgpu/source/redox_stubs.c b/local/recipes/gpu/amdgpu/source/redox_stubs.c index 431b6c893e..080c84e3c6 100644 --- a/local/recipes/gpu/amdgpu/source/redox_stubs.c +++ b/local/recipes/gpu/amdgpu/source/redox_stubs.c @@ -221,7 +221,6 @@ void redox_dma_free_coherent(size_t size, void *vaddr, dma_addr_t dma_handle) */ static struct pci_dev g_pci_dev; static int g_pci_dev_populated; -static u64 g_pci_quirk_flags; #define REDOX_MAX_FIRMWARE_BYTES (64U * 1024U * 1024U) #define REDOX_MAX_STORED_FIRMWARES 32 @@ -323,24 +322,6 @@ void redox_pci_release_regions(struct pci_dev *pdev) (void)pdev; } -u64 pci_get_quirk_flags(struct pci_dev *pdev) -{ - (void)pdev; - return g_pci_quirk_flags; -} - -bool pci_has_quirk(struct pci_dev *pdev, u64 flag) -{ - (void)pdev; - return (g_pci_quirk_flags & flag) != 0; -} - -void redox_pci_set_quirk_flags(u64 quirk_flags) -{ - g_pci_quirk_flags = quirk_flags; - printk("PCI quirk flags stored: %#llx\n", (unsigned long long)quirk_flags); -} - void redox_firmware_store(const char *name, const u8 *data, size_t size) { int i;