1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// This file is part of fpgad, an application to manage FPGA subsystem together with device-tree and kernel modules.
//
// Copyright 2026 Canonical Ltd.
//
// SPDX-License-Identifier: GPL-3.0-only
//
// fpgad is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation.
//
// fpgad is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
//! Xilinx DFX Manager FPGA device implementation.
//!
//! This module provides the [`XilinxDfxMgrFPGA`] struct, which implements the [`Fpga`] trait
//! for Xilinx FPGA devices using the dfx-mgr backend. It provides a hybrid approach that:
//! - Uses standard sysfs for reading flags
//! - Uses dfx-mgr-client for bitstream loading and package management
//! - Supports dfx-mgr's slot-based management
//!
//! # Key Differences from XilinxSys Platform
//!
//! - **State Query**: Returns dfx-mgr package listing instead of simple sysfs state
//! - **Bitstream Loading**: Uses `dfx-mgr-client -b` instead of direct firmware loading due to snap confinement
//! limitations (temporary?)
//! - **Firmware Removal**: Supports slot-based removal via `dfx-mgr-client -unload`
//!
//! # Examples
//!
//! ```rust,no_run
//! # use daemon::platforms::platform::platform_for_known_platform;
//! # fn example() -> Result<(), daemon::error::FpgadError> {
//! let platform = platform_for_known_platform("xlnx,zynqmp-pcap-fpga")?;
//! let fpga = platform.fpga("fpga0")?;
//! let state = fpga.state()?; // Returns dfx-mgr package listing
//! # Ok(())
//! # }
//! ```
use crateFpgadError;
use crateFpga;
use cratexilinx_dfx_mgr;
use Path;
/// Xilinx DFX Manager FPGA device implementation.
///
/// This struct represents a Xilinx FPGA device and provides methods to interact
/// with it through the dfx-mgr backend. It stores only the device handle and
/// uses dfx-mgr-client for most operations.
///
/// # Fields
///
/// * `device_handle` - The device identifier (e.g., "fpga0") used to locate the device in sysfs.
/// Only used for sysfs backed functions e.g. flags
///
/// # Implementation Notes
///
/// While this implementation uses the dfx-mgr backend, it still reads flags directly
/// from sysfs for consistency with the standard FPGA subsystem interface.