Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/vela/vela-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"crates/vela-crypto",
"crates/vela-flashpack",
"crates/vela-flasher",
"crates/vela-attestation",
"crates/vela-lifecycle",
"crates/vela-slotmgr",
Expand Down
12 changes: 6 additions & 6 deletions src/vela/vela-core/crates/vela-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct EngineHandle {

/// Get the last error message. Caller must free the returned string.
/// Returns null if no error recorded.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_last_error() -> *mut std::os::raw::c_char {
let err = LAST_ERROR.lock().ok().and_then(|g| g.clone());
match err {
Expand All @@ -36,23 +36,23 @@ pub unsafe extern "C" fn vela_last_error() -> *mut std::os::raw::c_char {
}

/// Clear the last error.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_clear_error() {
if let Ok(mut guard) = LAST_ERROR.lock() {
*guard = None;
}
}

/// Initialize the Vela Core engine. Returns engine handle or null on error.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_init() -> *mut EngineHandle {
trace!("FFI: vela_init called");
info!("Vela Core engine initialized");
Box::into_raw(Box::new(EngineHandle {}))
}

/// Shut down and release the engine handle.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_shutdown(handle: *mut EngineHandle) -> i32 {
if handle.is_null() {
trace!("FFI: vela_shutdown called with null handle");
Expand All @@ -64,7 +64,7 @@ pub unsafe extern "C" fn vela_shutdown(handle: *mut EngineHandle) -> i32 {
}

/// Open a FlashPack file. Returns handle or null on error.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_fpk_open(path: *const std::os::raw::c_char) -> *mut FpkHandle {
let path_str = match unsafe { std::ffi::CStr::from_ptr(path) }.to_str() {
Ok(s) => s,
Expand All @@ -80,7 +80,7 @@ pub unsafe extern "C" fn vela_fpk_open(path: *const std::os::raw::c_char) -> *mu
}

/// Close a FlashPack handle and release resources.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vela_fpk_close(handle: *mut FpkHandle) -> i32 {
if handle.is_null() {
return 1;
Expand Down
22 changes: 22 additions & 0 deletions src/vela/vela-core/crates/vela-flasher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "vela-flasher"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[dependencies]
tracing.workspace = true
thiserror.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio = { workspace = true, features = ["fs", "io-util", "rt"] }
sha2.workspace = true
hex.workspace = true
flate2.workspace = true
tar.workspace = true
vela-flashpack = { path = "../vela-flashpack" }
vela-crypto = { path = "../vela-crypto" }

[dev-dependencies]
tempfile.workspace = true
Loading
Loading