Skip to content

guid-create: All changes merged upstream #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2025
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
100 changes: 98 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion framework_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spin = { version = "0.9.8" }
no-std-compat = { version = "0.4.1", features = [ "alloc" ] }
hidapi = { version = "2.6.3", features = [ "windows-native" ], optional = true }
rusb = { version = "0.9.4", optional = true }
guid-create = { git = "https://github.com/FrameworkComputer/guid-create", branch = "no-rand", default-features = false }
guid-create = { version = "0.5.0", default-features = false }

[target.'cfg(target_os = "uefi")'.dependencies]
uefi = { version = "0.20", features = ["alloc"] }
Expand Down
8 changes: 4 additions & 4 deletions framework_lib/src/capsule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::prelude::v1::*;

use core::prelude::rust_2021::derive;
use guid_create::Guid;
use guid_create::CGuid;
#[cfg(not(feature = "uefi"))]
use std::fs::File;
#[cfg(not(feature = "uefi"))]
Expand All @@ -21,7 +21,7 @@ use std::io::prelude::*;
#[repr(C)]
pub struct EfiCapsuleHeader {
/// A GUID that defines the contents of a capsule.
pub capsule_guid: Guid,
pub capsule_guid: CGuid,

/// The size of the capsule header. This may be larger than the size of
/// the EFI_CAPSULE_HEADER since CapsuleGuid may imply
Expand Down Expand Up @@ -205,14 +205,14 @@ mod tests {
let data = fs::read(capsule_path).unwrap();
let cap = parse_capsule_header(&data).unwrap();
let expected_header = EfiCapsuleHeader {
capsule_guid: Guid::from(esrt::WINUX_GUID),
capsule_guid: CGuid::from(esrt::WINUX_GUID),
header_size: 28,
flags: 65536,
capsule_image_size: 676898,
};
assert_eq!(cap, expected_header);

assert_eq!(cap.capsule_guid, Guid::from(esrt::WINUX_GUID));
assert_eq!(cap.capsule_guid, CGuid::from(esrt::WINUX_GUID));
let ux_header = parse_ux_header(&data);
assert_eq!(
ux_header,
Expand Down
4 changes: 2 additions & 2 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use alloc::format;
use alloc::string::String;
use alloc::string::ToString;
use alloc::vec::Vec;
use guid_create::{Guid, GUID};
use guid_create::{CGuid, GUID};
use log::Level;
use num_traits::FromPrimitive;

Expand Down Expand Up @@ -1275,7 +1275,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
println!(" Size: {:>20} B", data.len());
println!(" Size: {:>20} KB", data.len() / 1024);
if let Some(header) = analyze_capsule(&data) {
if header.capsule_guid == Guid::from(esrt::WINUX_GUID) {
if header.capsule_guid == CGuid::from(esrt::WINUX_GUID) {
let ux_header = capsule::parse_ux_header(&data);
if let Some(dump_path) = &args.dump {
// TODO: Better error handling, rather than just panicking
Expand Down
14 changes: 7 additions & 7 deletions framework_lib/src/esrt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use log::{debug, error, info, trace};
use std::prelude::v1::*;

use core::prelude::v1::derive;
use guid_create::{Guid, GUID};
use guid_create::{CGuid, GUID};

#[cfg(target_os = "linux")]
use std::fs;
Expand Down Expand Up @@ -193,7 +193,7 @@ pub enum FrameworkGuidKind {
Unknown,
}

pub fn match_guid_kind(guid: &Guid) -> FrameworkGuidKind {
pub fn match_guid_kind(guid: &CGuid) -> FrameworkGuidKind {
match GUID::from(*guid) {
TGL_BIOS_GUID => FrameworkGuidKind::TglBios,
ADL_BIOS_GUID => FrameworkGuidKind::AdlBios,
Expand Down Expand Up @@ -292,7 +292,7 @@ impl UpdateStatus {
// TODO: Decode into proper Rust types
#[derive(Clone)]
pub struct EsrtResourceEntry {
pub fw_class: Guid,
pub fw_class: CGuid,
pub fw_type: u32, // ResourceType
pub fw_version: u32,
pub lowest_supported_fw_version: u32,
Expand Down Expand Up @@ -364,7 +364,7 @@ fn esrt_from_sysfs(dir: &Path) -> io::Result<Esrt> {
let last_attempt_version = fs::read_to_string(path.join("last_attempt_version"))?;
let last_attempt_status = fs::read_to_string(path.join("last_attempt_status"))?;
let esrt = EsrtResourceEntry {
fw_class: Guid::from(
fw_class: CGuid::from(
GUID::parse(fw_class.trim()).expect("Kernel provided wrong value"),
),
fw_type: fw_type
Expand Down Expand Up @@ -436,7 +436,7 @@ pub fn get_esrt() -> Option<Esrt> {
let ver_str = caps.get(2).unwrap().as_str().to_string();

let guid = GUID::parse(guid_str.trim()).expect("Kernel provided wrong value");
let guid_kind = match_guid_kind(&Guid::from(guid));
let guid_kind = match_guid_kind(&CGuid::from(guid));
let ver = u32::from_str_radix(&ver_str, 16).unwrap();
debug!("ESRT Entry {}", i);
debug!(" Name: {:?}", guid_kind);
Expand All @@ -456,7 +456,7 @@ pub fn get_esrt() -> Option<Esrt> {
// TODO: The missing fields are present in Device Manager
// So there must be a way to get at them
let esrt = EsrtResourceEntry {
fw_class: Guid::from(guid),
fw_class: CGuid::from(guid),
fw_type,
fw_version: ver,
// TODO: Not exposed by windows
Expand Down Expand Up @@ -543,7 +543,7 @@ pub fn get_esrt() -> Option<Esrt> {
for table in config_tables {
// TODO: Why aren't they the same type?
//debug!("Table: {:?}", table);
let table_guid: Guid = unsafe { std::mem::transmute(table.guid) };
let table_guid: CGuid = unsafe { std::mem::transmute(table.guid) };
let table_guid = GUID::from(table_guid);
match table_guid {
SYSTEM_RESOURCE_TABLE_GUID => unsafe {
Expand Down
Loading