How amd/xdna-driver works
Main components (each represented as a clearly labeled block)
• Kernel Module (Driver)
– Located primarily in “src/driver/amdxdna”
– Sub-components: PCI handling (amdxdna_pci_drv.c/h, etc.), DRM integration (amdxdna_drm.c/h), mailbox messaging, debugfs, error handling, and other low-level driver functionalities.
• User-space SHIM Library
– Found in “src/shim” (and its subdirectories including alternative implementations in “kmq”, “umq”, “virtio”)
– Provides an abstraction layer between user applications (via the XRT plugin) and the lower-level driver.
• XRT Plugin & Base Package
– Built by the “build” scripts (e.g., build/build.sh) and deployed as a DEB package containing the .so files (installed into /opt/xilinx/xrt/lib)
– Interfaces with the driver through the SHIM library.
• Firmware Binaries
– Provided in the “tools/bins” directories and installed into /usr/lib/firmware/amdnpu
– Loaded by the driver to run on AMD XDNA devices.
• Build & Packaging Infrastructure
– CMake configuration folders (CMake, src/CMakeLists.txt, etc.), DKMS-specific configurations (e.g., dkms.conf.in within “src/driver/CMake/config”) and scripts in “tools/”
– Provides the automated build, compile, and packaging cycle.
• Testing & Example Programs
– Located in “example”, “test”, and “tools” directories
– Validate proper integration and communication between the kernel driver, firmware, and user-space libraries.
Out the relationships and interactions
• From the SHIM library, indicate the interactions with the kernel driver (amdxdna.ko) – for instance, via IOCTL calls, sysfs interfaces, or DRM APIs.
• That the driver integrates with the hardware/firmware layer (firmware binaries loaded from /usr/lib/firmware/amdnpu).
• Build system as an external process that compiles, packages, and deploys both the user-space library and the kernel module.
• Optionally, add testing as a separate component that validates each of these interactions.
Architectural patterns/design principles
• Modularity: Separate modules for the kernel driver and user-space libraries.
• Clear separation of concerns: Distinct components for hardware-interfacing (kernel module), abstraction (SHIM), and user application integration (XRT plugin).
• Use of DKMS and CMake indicates that the project is designed for portability and dynamic module updating.
• Interaction layering: The stack moves from user applications → XRT plugin & SHIM library → Kernel driver → Firmware & hardware.
Incorporate relevant technologies
• Linux Kernel module framework (with DKMS support)
• CMake for configurable builds across multiple components (driver, shim, tests)
• Integration with XRT (Xilinx Runtime) – both in terms of plugin libraries and possibly shared user-space drivers.
• Standard Linux subsystems (PCI, DRM, sysfs, debugfs)
• Shell/Bash scripts that aid in building dependencies and testing.