Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ members = ["cli", "fpgad_macros"]

[dependencies]
fpgad_macros = { path = "fpgad_macros" }
ctor = "0.4.2"
log = "0.4.27"
env_logger = "0.11.8"
tokio = { version = "1.46.1", features = ["full"] }
Expand Down
20 changes: 12 additions & 8 deletions fpgad_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ pub fn platform(args: TokenStream, input: TokenStream) -> TokenStream {
}
}
let compat_string = compat_string.expect("compat_string must be provided");
let register_fn_name = syn::Ident::new(
&format!("{struct_name}_register_platform"),
struct_name.span(),
);

// Generate code to register the platform
let expanded = quote! {
#input_struct

impl #struct_name {
#[doc(hidden)]
pub fn register_platform() {
crate::platforms::platform::register_platform(
#compat_string,
|| Box::new(Self::new())
);
}
#[doc(hidden)]
#[allow(non_snake_case)]
#[ctor::ctor]
fn #register_fn_name() {
crate::platforms::platform::register_platform(
#compat_string,
|| Box::new(#struct_name::new())
);
}
};
TokenStream::from(expanded)
Expand Down
12 changes: 1 addition & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,11 @@ mod platforms;
mod softeners;
mod system_io;

use crate::{
comm::dbus::{control_interface::ControlInterface, status_interface::StatusInterface},
platforms::universal::UniversalPlatform,
softeners::xilinx_dfx_mgr::XilinxDfxMgrPlatform,
};

fn register_platforms() {
XilinxDfxMgrPlatform::register_platform();
UniversalPlatform::register_platform();
}
use crate::comm::dbus::{control_interface::ControlInterface, status_interface::StatusInterface};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
register_platforms();

// Upon load, the daemon will search each fpga device and determine what platform it is
// based on its name in /sys/class/fpga_manager/{device}/name
Expand Down
1 change: 1 addition & 0 deletions src/softeners/xilinx_dfx_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ impl XilinxDfxMgrPlatform {
}
}
}

impl Platform for XilinxDfxMgrPlatform {
fn fpga(
&self,
Expand Down
Loading