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 src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use intel_fw::{
EMPTY,
ifd::{IFD, IfdError},
me::ME,
part::part::ClearOptions,
part::generic::ClearOptions,
};
use log::warn;

Expand Down
5 changes: 5 additions & 0 deletions src/dir.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/// Directories for ME generation 2 and 3
///
/// There are multiple kinds of partitioning schemes, and some partitions may
/// contain directories, but directories could also be referenced by other data
/// structures, such as in the case of IFWI, so they are separate here.
pub mod gen2;
pub mod gen3;
pub mod man;
12 changes: 4 additions & 8 deletions src/me.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ use crate::dir::{
gen2::Directory as Gen2Directory,
gen3::{CPD_MAGIC_BYTES, CodePartitionDirectory},
};
use crate::part::fpt::FTPR;
use crate::part::gen2::DirPartition;
use crate::part::gen3::CPDPartition;
use crate::part::part::Partition;
use crate::part::{
fpt::{FPT, MIN_FPT_SIZE},
gen2::Gen2Partition,
gen3::Gen3Partition,
part::ClearOptions,
fpt::{FPT, FTPR, MIN_FPT_SIZE},
gen2::{DirPartition, Gen2Partition},
gen3::{CPDPartition, Gen3Partition},
generic::{ClearOptions, Partition},
partitions::Partitions,
};
use crate::ver::Version;
Expand Down
7 changes: 6 additions & 1 deletion src/part.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/// Partitioning for ME generation 2 and 3
///
/// There are multiple kinds of partitioning schemes, and some partitions may
/// contain directories, but directories could also be referenced by other data
/// structures, such as in the case of IFWI, so they are separate.
pub mod fpt;
pub mod gen2;
pub mod gen3;
pub mod part;
pub mod generic;
pub mod partitions;
2 changes: 1 addition & 1 deletion src/part/fpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use zerocopy_derive::{FromBytes, Immutable, IntoBytes};

use crate::{
EMPTY,
part::part::{ClearOptions, retain},
part::generic::{ClearOptions, retain},
ver::Version,
};

Expand Down
2 changes: 1 addition & 1 deletion src/part/gen2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::dir::gen2::{ALWAYS_RETAIN, Directory, LUT_HEADER_SIZE};
use crate::dump48;
use crate::part::{
fpt::{FPT, FPTEntry, FTPR},
part::{
generic::{
ClearOptions, DataPartition, Partition, UnknownOrMalformedPartition, dir_clean, retain,
strs_to_strings,
},
Expand Down
2 changes: 1 addition & 1 deletion src/part/gen3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::dir::{
use crate::dump48;
use crate::part::{
fpt::{DIR_PARTS, FPT, FPTEntry, FS_PARTS, FTPR},
part::{
generic::{
ClearOptions, Partition, UnknownOrMalformedPartition, dir_clean, retain, strs_to_strings,
},
};
Expand Down
5 changes: 5 additions & 0 deletions src/part/part.rs → src/part/generic.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
/// Generic data structures and helpers for partitions
use serde::{Deserialize, Serialize};

use crate::{
EMPTY, Removables,
part::fpt::{FPTEntry, FTPR},
};

/// Data partitions are for now treated uniformly, but may carry semantics.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DataPartition {
pub entry: FPTEntry,
pub data: Vec<u8>,
}

/// Last resort if a partition cannot be classified
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UnknownOrMalformedPartition {
pub entry: FPTEntry,
pub data: Vec<u8>,
pub note: String,
}

/// Common trait for partitions and their relationship with the FPT
pub trait Partition {
fn entry(&self) -> &FPTEntry;
fn data(&self) -> &Vec<u8>;
Expand Down Expand Up @@ -62,6 +66,7 @@ pub fn strs_to_strings(strs: &[&str]) -> Vec<String> {
Vec::from(strs).iter().map(|s| String::from(*s)).collect()
}

/// Options for clearing partitions and directories
pub struct ClearOptions {
pub keep_modules: bool,
pub parts_force_retention: Vec<String>,
Expand Down
6 changes: 2 additions & 4 deletions src/part/partitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use zerocopy::IntoBytes;

use crate::EMPTY;
use crate::dir::gen3::CPD_MAGIC_BYTES;
use crate::part::fpt::PartitionKind;
use crate::part::part::ClearOptions;
use crate::part::{
fpt::{FPT, FPTEntry},
fpt::{FPT, FPTEntry, PartitionKind},
gen2::{self, Gen2Partition},
gen3::{self, Gen3Partition},
part::{GenUnknownPartition, Partition},
generic::{ClearOptions, GenUnknownPartition, Partition},
};
use crate::ver::Version;

Expand Down