Files
RedBear-OS/local/recipes/gpu/amdgpu/source/redox_quirk_bridge.c
T
vasilito 98982cc2fa amdgpu: extract pci_*_quirk_flags into redox_quirk_bridge.c (Gap 15)
R1-R10 audit Gap 15: the pci_*_quirk_flags and
redox_pci_set_quirk_flags symbols lived inside redox_stubs.c
alongside kmalloc, printk, and other generic glue functions.
The 'stub' file name was misleading — the flag word that
pci_get_quirk_flags() returned was real, computed by
redox-drm (Rust) via redox_driver_sys::quirks::lookup_pci_quirks_full()
and pushed across the FFI boundary.

This change:

- Adds source/redox_quirk_bridge.c containing the three
  symbols plus a static g_redox_quirk_flags global. The
  header documents the Rust-to-C data flow and references
  the audit + the Rust-side caller at display.rs:155.
- Removes the three functions and the g_pci_quirk_flags
  static from source/redox_stubs.c. redox_stubs.c now only
  contains generic glue (kmalloc, printk, msleep, udelay,
  firmware_store, etc.) and the file name matches its
  contents.
- Updates recipe.toml Stage 1 to compile the new
  translation unit alongside redox_stubs.c. Both files
  are linked into libamdgpu_dc_redox.so.

The Rust-side caller in
local/recipes/gpu/redox-drm/source/src/drivers/amd/display.rs
is unchanged: the FFI symbol name 'redox_pci_set_quirk_flags'
is the same, so the linker picks up the new definition
without any code change on the Rust side.

No caller code in amdgpu_redox_main.c changes either —
pci_get_quirk_flags and pci_has_quirk are still declared
in redox_glue.h with the same signatures, and the new TU
provides the single definition that the linker resolves.

The end result is identical behavior (the flag word flows
the same way) with cleaner file naming and accurate
documentation. The audit's stub-finding is now a non-issue
for these symbols: there is no longer a stub; the bridge
file is named for what it does.
2026-06-07 20:44:08 +03:00

39 lines
1.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* R1R10 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;
}