Skip to content

Commit

Permalink
Support Genoa (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: Danny Milosavljevic <[email protected]>
Co-authored-by: Luqman Aden <[email protected]>
  • Loading branch information
3 people authored May 1, 2024
1 parent 6b1a067 commit 5a35018
Show file tree
Hide file tree
Showing 8 changed files with 2,154 additions and 84 deletions.
4 changes: 2 additions & 2 deletions src/apcb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl<'a> Apcb<'a> {
const ROME_VERSION: u16 = 0x30;
const V3_HEADER_EXT_SIZE: usize =
size_of::<V2_HEADER>() + size_of::<V3_HEADER_EXT>();
pub const MAX_SIZE: usize = 0x2400;
pub const MAX_SIZE: usize = 0x5000;

pub fn header(&self) -> Result<LayoutVerified<&[u8], V2_HEADER>> {
LayoutVerified::<&[u8], V2_HEADER>::new_unaligned_from_prefix(
Expand Down Expand Up @@ -1223,7 +1223,7 @@ impl<'a> Apcb<'a> {
"V3_HEADER_EXT::data_offset",
));
}
if value.signature_ending == *b"BCBA" {
if value.signature_ending == *b"BCPA" {
} else {
return Err(Error::FileSystem(
FileSystemError::InconsistentHeader,
Expand Down
106 changes: 105 additions & 1 deletion src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ impl<'a> schemars::JsonSchema for EntryItem<'a> {
fn json_schema(
gen: &mut schemars::gen::SchemaGenerator,
) -> schemars::schema::Schema {
use crate::fch;
use crate::memory;
use crate::psp;
use crate::tokens_entry::TokensEntryItem;
Expand Down Expand Up @@ -497,6 +498,26 @@ impl<'a> schemars::JsonSchema for EntryItem<'a> {
"LrMaxFreqElement".to_owned(),
<Vec<memory::LrMaxFreqElement>>::json_schema(gen),
);
obj.properties.insert(
"Ddr5CaPinMapElement".to_owned(),
<Vec<memory::Ddr5CaPinMapElement>>::json_schema(gen),
);
obj.properties.insert(
"MemDfeSearchElement20".to_owned(),
<Vec<memory::MemDfeSearchElement20>>::json_schema(gen),
);
obj.properties.insert(
"MemDfeSearchElement32".to_owned(),
<Vec<memory::MemDfeSearchElement32>>::json_schema(gen),
);
obj.properties.insert(
"DdrDqPinMapElement".to_owned(),
<Vec<memory::DdrDqPinMapElement>>::json_schema(gen),
);
obj.properties.insert(
"RdimmDdr5BusElement".to_owned(),
<Vec<memory::RdimmDdr5BusElement>>::json_schema(gen),
);
obj.properties.insert(
"ConsoleOutControl".to_owned(),
<memory::ConsoleOutControl>::json_schema(gen),
Expand All @@ -521,7 +542,8 @@ impl<'a> schemars::JsonSchema for EntryItem<'a> {
"SlinkConfig".to_owned(),
<crate::df::SlinkConfig>::json_schema(gen),
);

obj.properties
.insert("EspiInit".to_owned(), <fch::EspiInit>::json_schema(gen));
obj.properties
.insert("BoardIdGettingMethodGpio".to_owned(),
<(psp::BoardIdGettingMethodGpio,
Expand Down Expand Up @@ -584,6 +606,7 @@ impl<'a> Serialize for EntryItem<'a> {
S: Serializer,
{
use crate::df::SlinkConfig;
use crate::fch;
use crate::memory;
use crate::psp;
let mut state = serializer.serialize_struct("EntryItem", 2)?;
Expand Down Expand Up @@ -633,6 +656,21 @@ impl<'a> Serialize for EntryItem<'a> {
} else if let Some(s) = self.body_as_struct_array::<memory::LrMaxFreqElement>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("LrMaxFreqElement", &v)?;
} else if let Some(s) = self.body_as_struct_array::<memory::Ddr5CaPinMapElement>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("Ddr5CaPinMapElement", &v)?;
} else if let Some(s) = self.body_as_struct_array::<memory::MemDfeSearchElement20>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("MemDfeSearchElement20", &v)?;
} else if let Some(s) = self.body_as_struct_array::<memory::MemDfeSearchElement32>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("MemDfeSearchElement32", &v)?;
} else if let Some(s) = self.body_as_struct_array::<memory::DdrDqPinMapElement>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("DdrDqPinMapElement", &v)?;
} else if let Some(s) = self.body_as_struct_array::<memory::RdimmDdr5BusElement>() {
let v = s.iter().collect::<Vec<_>>();
state.serialize_field("RdimmDdr5BusElement", &v)?;
} else if let Some((s, _)) = self.body_as_struct::<memory::ConsoleOutControl>() {
state.serialize_field("ConsoleOutControl", &s)?;
} else if let Some((s, _)) = self.body_as_struct::<memory::NaplesConsoleOutControl>() {
Expand Down Expand Up @@ -661,6 +699,8 @@ impl<'a> Serialize for EntryItem<'a> {
let v = s.iter().collect::<Vec<_>>();
let t = (header, v);
state.serialize_field("BoardIdGettingMethodCustom", &t)?;
} else if let Some((header, _)) = self.body_as_struct::<fch::EspiInit>() {
state.serialize_field("EspiInit", &header)?;
} else if let Some(s) =
self.body_as_struct_sequence::<memory::platform_specific_override::ElementRef<'_>>() {
let i = s.iter().unwrap();
Expand Down Expand Up @@ -854,6 +894,12 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
LrdimmDdr4DataBusElement,
MaxFreqElement,
LrMaxFreqElement,
DdrDqPinMapElement,
Ddr5CaPinMapElement,
MemDfeSearchElement20,
MemDfeSearchElement32,
RdimmDdr5BusElement,

// Body as struct
ConsoleOutControl,
ExtVoltageControl,
Expand All @@ -864,6 +910,8 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
BoardIdGettingMethodEeprom,
BoardIdGettingMethodSmbus,
BoardIdGettingMethodCustom,
EspiInit,

// struct sequence
PlatformSpecificOverrides,
PlatformTuning,
Expand All @@ -883,6 +931,11 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
"LrdimmDdr4DataBusElement",
"MaxFreqElement",
"LrMaxFreqElement",
"DdrDqPinMapElement",
"Ddr5CaPinMapElement",
"MemDfeSearchElement20",
"MemDfeSearchElement32",
"RdimmDdr5BusElement",
// Body as struct
"ConsoleOutControl",
"ExtVoltageControl",
Expand All @@ -893,6 +946,7 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
"BoardIdGettingMethodEeprom",
"BoardIdGettingMethodSmbus",
"BoardIdGettingMethodCustom",
"EspiInit",
// struct sequence
"platform_specific_overrides",
"platform_tuning",
Expand Down Expand Up @@ -955,6 +1009,22 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
}
"MaxFreqElement" => Ok(Field::MaxFreqElement),
"LrMaxFreqElement" => Ok(Field::LrMaxFreqElement),
"DdrDqPinMapElement" => {
Ok(Field::DdrDqPinMapElement)
}
"Ddr5CaPinMapElement" => {
Ok(Field::Ddr5CaPinMapElement)
}
"MemDfeSearchElement20" => {
Ok(Field::MemDfeSearchElement20)
}
"MemDfeSearchElement32" => {
Ok(Field::MemDfeSearchElement32)
}
"RdimmDdr5BusElement" => {
Ok(Field::RdimmDdr5BusElement)
}

"ConsoleOutControl" => Ok(Field::ConsoleOutControl),
"ExtVoltageControl" => Ok(Field::ExtVoltageControl),
"ErrorOutControl116" => {
Expand All @@ -976,6 +1046,7 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
"BoardIdGettingMethodCustom" => {
Ok(Field::BoardIdGettingMethodCustom)
}
"EspiInit" => Ok(Field::EspiInit),
"platform_specific_overrides" => {
Ok(Field::PlatformSpecificOverrides)
}
Expand Down Expand Up @@ -1010,6 +1081,7 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
V: MapAccess<'de>,
{
use crate::df;
use crate::fch;
use crate::memory;
use crate::psp;
let mut header: Option<ENTRY_HEADER> = None;
Expand Down Expand Up @@ -1089,6 +1161,33 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
&mut body, &mut map,
)?;
}
Field::DdrDqPinMapElement => {
struct_vec_to_body::<memory::DdrDqPinMapElement, V>(
&mut body, &mut map,
)?;
}
Field::Ddr5CaPinMapElement => {
struct_vec_to_body::<memory::Ddr5CaPinMapElement, V>(
&mut body, &mut map,
)?;
}
Field::MemDfeSearchElement20 => {
struct_vec_to_body::<
memory::MemDfeSearchElement20,
V,
>(&mut body, &mut map)?;
}
Field::MemDfeSearchElement32 => {
struct_vec_to_body::<
memory::MemDfeSearchElement32,
V,
>(&mut body, &mut map)?;
}
Field::RdimmDdr5BusElement => {
struct_vec_to_body::<memory::RdimmDdr5BusElement, V>(
&mut body, &mut map,
)?;
}

Field::ConsoleOutControl => {
struct_to_body::<memory::ConsoleOutControl, V>(
Expand Down Expand Up @@ -1135,6 +1234,11 @@ impl<'de> Deserialize<'de> for SerdeEntryItem {
&mut body, &mut map,
)?;
}
Field::EspiInit => {
struct_to_body::<fch::EspiInit, V>(
&mut body, &mut map,
)?;
}

Field::PlatformSpecificOverrides => {
struct_sequence_to_body::<
Expand Down
Loading

0 comments on commit 5a35018

Please sign in to comment.