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
2 changes: 1 addition & 1 deletion app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "intel_crashlog_app"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion efi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "intel_crashlog_efi"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT"

[[bin]]
Expand Down
2 changes: 1 addition & 1 deletion efi/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use alloc::fmt;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use uefi::CString16;
use uefi::fs::PathBuf;
use uefi::prelude::*;
use uefi::println;
use uefi::proto::shell_params::ShellParameters;
use uefi::CString16;

pub enum ArgsError {
InvalidArgument(String),
Expand Down
2 changes: 1 addition & 1 deletion efi/src/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
use alloc::format;
use intel_crashlog::CrashLog;
use log::{error, warn};
use uefi::CString16;
use uefi::fs::{FileSystem, Path, PathBuf};
use uefi::prelude::*;
use uefi::CString16;

fn generate_filename(crashlog: &CrashLog) -> Result<PathBuf, uefi::Error> {
CString16::try_from(format!("{}.crashlog", crashlog.metadata).as_str())
Expand Down
6 changes: 3 additions & 3 deletions efi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ fn run_command(args: &Args) -> Result<(), uefi::Error> {

if let Some(ref command) = args.command {
match command {
Command::Extract { ref output_path } => extract::extract(output_path.as_deref()),
Command::Info { ref input_paths } => {
Command::Extract { output_path } => extract::extract(output_path.as_deref()),
Command::Info { input_paths } => {
for input_path in input_paths {
if let Err(err) = decode::info(input_path) {
println!("Cannot decode sample: {err}");
}
}
Ok(())
}
Command::Decode { ref input_path } => decode::decode(input_path),
Command::Decode { input_path } => decode::decode(input_path),
}
} else {
args.show_help();
Expand Down
2 changes: 1 addition & 1 deletion efi/src/pager/update.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: MIT

use super::input::Command;
use super::Pager;
use super::input::Command;

impl Pager {
fn search(&mut self, indexes: impl IntoIterator<Item = usize>) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "intel_crashlog"
version = "0.1.0"
edition = "2021"
edition = "2024"
license = "MIT"

[lib]
Expand Down
4 changes: 2 additions & 2 deletions lib/src/bert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ pub mod berr;
mod tests;

use acpi::{
sdt::{SdtHeader, Signature},
AcpiTable,
sdt::{SdtHeader, Signature},
};
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
Expand Down Expand Up @@ -66,7 +66,7 @@ impl Bert {
/// If the [Berr] is not valid, None is returned.
#[cfg(all(target_os = "uefi", feature = "extraction"))]
pub unsafe fn berr_from_phys_mem(&self) -> Option<Berr> {
Berr::from_slice(self.raw_berr_from_phys_mem())
Berr::from_slice(unsafe { self.raw_berr_from_phys_mem() })
}

pub(super) fn to_bytes(&self) -> Vec<u8> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bert/berr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// SPDX-License-Identifier: MIT

use super::Bert;
use crate::CrashLog;
use crate::cper::fer::{FirmwareErrorRecord, FirmwareErrorRecordHeader, RECORD_ID_CRASHLOG};
use crate::cper::{CperSection, FW_ERROR_RECORD_GUID};
use crate::CrashLog;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/collateral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ mod path;
mod pvss;
mod target_info;

use crate::Error;
use crate::header::Header;
use crate::utils::Map;
use crate::Error;
#[cfg(not(feature = "std"))]
use alloc::{string::ToString, vec::Vec};

Expand Down
2 changes: 1 addition & 1 deletion lib/src/collateral/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: MIT

use super::{CollateralManager, CollateralTree, ItemPath, PVSS};
use crate::utils::Map;
use crate::Error;
use crate::utils::Map;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/collateral/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: MIT

use super::{CollateralManager, CollateralTree, ItemPath};
use crate::utils::Map;
use crate::Error;
use crate::utils::Map;
#[cfg(not(feature = "std"))]
use alloc::string::String;
use serde::Deserialize;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/crashlog.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: MIT

use crate::Error;
use crate::bert::{Berr, Bert};
#[cfg(feature = "collateral_manager")]
use crate::collateral::{CollateralManager, CollateralTree};
Expand All @@ -10,7 +11,6 @@ use crate::extract;
use crate::metadata::Metadata;
use crate::node::Node;
use crate::region::Region;
use crate::Error;
#[cfg(not(feature = "std"))]
use alloc::{collections::VecDeque, vec, vec::Vec};
#[cfg(target_os = "uefi")]
Expand Down
16 changes: 9 additions & 7 deletions lib/src/extract/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ impl AcpiHandler for IdentityMapped {
physical_address: usize,
size: usize,
) -> PhysicalMapping<Self, T> {
PhysicalMapping::new(
physical_address,
NonNull::new(physical_address as *mut _).unwrap(),
size,
size,
Self,
)
unsafe {
PhysicalMapping::new(
physical_address,
NonNull::new(physical_address as *mut _).unwrap(),
size,
size,
Self,
)
}
}

fn unmap_physical_region<T>(_region: &PhysicalMapping<Self, T>) {}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/extract/event_log.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: MIT

use crate::metadata;
use crate::CrashLog;
use std::alloc::{alloc, dealloc, Layout};
use crate::metadata;
use std::alloc::{Layout, alloc, dealloc};
use std::ffi::c_void;
use std::ops::{Deref, Drop};
use std::path::Path;
use std::slice;
use windows::core::*;
use windows::Win32::Foundation::*;
use windows::Win32::System::EventLog::EVT_VARIANT;
use windows::Win32::System::EventLog::*;
use windows::Win32::System::Time::FileTimeToSystemTime;
use windows::core::*;

pub struct EvtHandle(EVT_HANDLE);

Expand Down
42 changes: 21 additions & 21 deletions lib/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ use core::slice;
use core::{ffi::c_void, ptr::NonNull};
#[cfg(not(feature = "std"))]
use core::{
ffi::{c_char, c_uchar, CStr},
ffi::{CStr, c_char, c_uchar},
ptr,
};
#[cfg(feature = "std")]
use std::{
collections::VecDeque,
ffi::{c_char, c_uchar, CStr, CString},
ffi::{CStr, CString, c_char, c_uchar},
ptr,
};
#[cfg(all(target_os = "uefi", feature = "extraction"))]
Expand Down Expand Up @@ -85,7 +85,7 @@ pub struct CrashLogNodeChildren<'a> {
/// # Errors
///
/// Returns a NULL pointer if the context cannot be initialized.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_init() -> *mut CrashLogContext {
#[cfg(not(feature = "embedded_collateral_tree"))]
{
Expand Down Expand Up @@ -120,7 +120,7 @@ pub extern "C" fn crashlog_init() -> *mut CrashLogContext {
/// # Errors
///
/// Returns a `NULL` pointer if the binary blob does not encode any valid Crash Log records.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_read_from_buffer(
context: *mut CrashLogContext,
data: *const u8,
Expand All @@ -137,7 +137,7 @@ pub unsafe extern "C" fn crashlog_read_from_buffer(
///
/// Returns a `NULL` pointer if the Crash Log records cannot be found.
#[cfg(all(target_os = "uefi", feature = "extraction"))]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_read_from_system_table(
context: *mut CrashLogContext,
system_table: *mut c_void,
Expand All @@ -153,7 +153,7 @@ pub extern "C" fn crashlog_read_from_system_table(
///
/// Returns a `NULL` pointer if the Crash Log records cannot be found.
#[cfg(any(all(target_os = "windows", feature = "extraction"), doc))]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_read_from_windows_event_logs(
context: *mut CrashLogContext,
) -> *mut CrashLogs {
Expand All @@ -172,7 +172,7 @@ pub extern "C" fn crashlog_read_from_windows_event_logs(
///
/// Returns a `NULL` pointer if the Crash Log records cannot be found.
#[cfg(any(all(target_os = "linux", feature = "extraction"), doc))]
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_read_from_linux_sysfs(context: *mut CrashLogContext) -> *mut CrashLog {
CrashLog::from_linux_sysfs()
.map(alloc)
Expand All @@ -196,7 +196,7 @@ pub extern "C" fn crashlog_read_from_linux_sysfs(context: *mut CrashLogContext)
///
/// Returns a `NULL` pointer if one of the arguments is `NULL` or if no more Crash Logs is
/// available in the iterator.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_next(
context: *mut CrashLogContext,
crashlogs: *mut CrashLogs,
Expand Down Expand Up @@ -232,7 +232,7 @@ pub unsafe extern "C" fn crashlog_next(
/// # Errors
///
/// Returns a `NULL` pointer if one of the arguments is `NULL`.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_decode(
context: *mut CrashLogContext,
crashlog: *const CrashLog,
Expand Down Expand Up @@ -265,7 +265,7 @@ pub unsafe extern "C" fn crashlog_decode(
///
/// The `crashlog` pointer must be valid and obtained using one of the `crashlog_read_*()`
/// functions.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_export_to_binary(
context: *mut CrashLogContext,
crashlog: *const CrashLog,
Expand Down Expand Up @@ -296,7 +296,7 @@ pub unsafe extern "C" fn crashlog_export_to_binary(
///
/// Returns a `NULL` pointer if one of the arguments is `NULL` or if an error happens during the
/// generation of the JSON.
#[no_mangle]
#[unsafe(no_mangle)]
#[cfg(feature = "serialize")]
pub unsafe extern "C" fn crashlog_export_to_json(
context: *mut CrashLogContext,
Expand Down Expand Up @@ -336,7 +336,7 @@ pub unsafe extern "C" fn crashlog_export_to_json(
///
/// The `buffer` pointer must point to a valid writable memory region of `buffer_size` bytes.
/// The data written to this buffer is not nul-terminated.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_read_export(
context: *mut CrashLogContext,
export: *mut CrashLogExport,
Expand Down Expand Up @@ -379,7 +379,7 @@ pub unsafe extern "C" fn crashlog_read_export(
/// [`crashlog_get_next_node_child`], or the [`crashlog_get_node_by_path`] functions.
///
/// The `buffer` pointer must point to a writable memory region of `buffer_size` bytes.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_get_node_name(
context: *mut CrashLogContext,
node: *const Node,
Expand Down Expand Up @@ -419,7 +419,7 @@ pub unsafe extern "C" fn crashlog_get_node_name(
/// [`crashlog_get_next_node_child`], or the [`crashlog_get_node_by_path`] functions.
///
/// The `value` pointer must point to a writable memory region of 8 bytes.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_get_node_value(
context: *mut CrashLogContext,
node: *const Node,
Expand Down Expand Up @@ -455,7 +455,7 @@ pub unsafe extern "C" fn crashlog_get_node_value(
/// # Errors
///
/// Returns a `NULL` pointer if one of the arguments is `NULL`.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_get_node_children<'a>(
context: *mut CrashLogContext,
node: *const Node,
Expand Down Expand Up @@ -488,7 +488,7 @@ pub unsafe extern "C" fn crashlog_get_node_children<'a>(
///
/// Returns a `NULL` pointer if one of the arguments is `NULL` or if no more node is available in
/// the iterator.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_get_next_node_child(
context: *mut CrashLogContext,
children: *mut CrashLogNodeChildren,
Expand Down Expand Up @@ -522,7 +522,7 @@ pub unsafe extern "C" fn crashlog_get_next_node_child(
/// # Errors
///
/// Returns a `NULL` pointer if one of the arguments is `NULL` or if the node does not exist.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn crashlog_get_node_by_path(
context: *mut CrashLogContext,
node: *const Node,
Expand Down Expand Up @@ -554,27 +554,27 @@ fn free<T>(ptr: *mut T) {
}

/// Releases the memory allocated for the Crash Log.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_release(crashlog: *mut CrashLog) {
free(crashlog)
}

/// Releases the memory allocated for the Crash Log register tree.
///
/// The root node of the tree is expected to be passed to this function.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_release_nodes(node: *mut Node) {
free(node)
}

/// Releases the memory allocated for the Crash Log export.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_release_export(node: *mut CrashLogExport) {
free(node)
}

/// Releases the memory allocated for the Crash Log global context.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn crashlog_deinit(ctx: *mut CrashLogContext) {
free(ctx)
}
4 changes: 2 additions & 2 deletions lib/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//! A tree-like data structure containing the decoded Crash Log registers.

#[cfg(feature = "std")]
use std::collections::{btree_map, BTreeMap};
use std::collections::{BTreeMap, btree_map};

#[cfg(not(feature = "std"))]
use alloc::{
collections::{btree_map, BTreeMap},
collections::{BTreeMap, btree_map},
format,
string::String,
};
Expand Down
Loading