1
- use amd_apcb:: { Apcb , ApcbIoOptions } ;
1
+ use amd_apcb:: { Apcb , ApcbIoOptions , Context } ;
2
2
3
3
use amd_efs:: {
4
4
AddressMode , BhdDirectory , BhdDirectoryEntry , BhdDirectoryEntryType ,
@@ -772,6 +772,7 @@ fn dump_bhd_directory<'a, T: FlashRead + FlashWrite>(
772
772
bhd_directory : & BhdDirectory ,
773
773
apcb_buffer_option : & mut Option < & ' a mut [ u8 ] > ,
774
774
blob_dump_dirname : & Option < PathBuf > ,
775
+ context : Context ,
775
776
) -> SerdeBhdDirectoryVariant < ' a > {
776
777
if let Some ( blob_dump_dirname) = & blob_dump_dirname {
777
778
let mut path = PathBuf :: new ( ) ;
@@ -808,7 +809,7 @@ fn dump_bhd_directory<'a, T: FlashRead + FlashWrite>(
808
809
std:: borrow:: Cow :: Borrowed (
809
810
apcb_buffer,
810
811
) ,
811
- & ApcbIoOptions :: default ( ) ,
812
+ & ApcbIoOptions :: default ( ) . with_context ( context ) . build ( ) ,
812
813
)
813
814
. unwrap ( ) ;
814
815
apcb. validate ( None ) . unwrap ( ) ; // TODO: abl0 version ?
@@ -836,7 +837,7 @@ fn dump_bhd_directory<'a, T: FlashRead + FlashWrite>(
836
837
t. push ( "bhd-second-level" ) ;
837
838
t
838
839
} ) ;
839
- let variant = dump_bhd_directory ( storage, & sub_bhd_directory, apcb_buffer_option, & subdir) ; //SerdeBhdDirectoryVariant
840
+ let variant = dump_bhd_directory ( storage, & sub_bhd_directory, apcb_buffer_option, & subdir, context ) ; //SerdeBhdDirectoryVariant
840
841
Some ( SerdeBhdEntry {
841
842
source : SerdeBhdSource :: SecondLevelDirectory ( match variant {
842
843
SerdeBhdDirectoryVariant :: BhdDirectory ( d) => d,
@@ -922,6 +923,13 @@ fn dump(
922
923
Some ( efs. psp_directory ( ) . unwrap ( ) . beginning ( ) ) ;
923
924
let bhd_main_directory_flash_location =
924
925
Some ( efs. bhd_directory ( None ) . unwrap ( ) . beginning ( ) ) ;
926
+
927
+ let psp = dump_psp_directory (
928
+ & storage,
929
+ & efs. psp_directory ( ) . unwrap ( ) ,
930
+ & blob_dump_dirname,
931
+ ) ;
932
+
925
933
let config = SerdeConfig {
926
934
processor_generation : * gen,
927
935
spi_mode_bulldozer : efs. spi_mode_bulldozer ( ) . unwrap ( ) ,
@@ -932,17 +940,30 @@ fn dump(
932
940
psp_main_directory_flash_location,
933
941
bhd_main_directory_flash_location,
934
942
// TODO: psp_directory or psp_combo_directory
935
- psp : dump_psp_directory (
936
- & storage,
937
- & efs. psp_directory ( ) . unwrap ( ) ,
938
- & blob_dump_dirname,
939
- ) ,
943
+ psp,
940
944
// TODO: bhd_directory or bhd_combo_directory
941
945
bhd : dump_bhd_directory (
942
946
& storage,
943
947
& efs. bhd_directory ( None ) . unwrap ( ) ,
944
948
& mut apcb_buffer_option,
945
949
& blob_dump_dirname,
950
+ match * gen {
951
+ ProcessorGeneration :: Naples => {
952
+ Context :: builder ( ) . with_generation ( 1 ) . build ( ) // FIXME abl0 version (from "psp" variable)
953
+ } // FIXME
954
+ ProcessorGeneration :: Rome => {
955
+ Context :: builder ( ) . with_generation ( 2 ) . build ( )
956
+ }
957
+ ProcessorGeneration :: Milan => {
958
+ Context :: builder ( ) . with_generation ( 3 ) . build ( )
959
+ }
960
+ ProcessorGeneration :: Genoa => {
961
+ Context :: builder ( ) . with_generation ( 4 ) . build ( )
962
+ }
963
+ ProcessorGeneration :: Turin => {
964
+ Context :: builder ( ) . with_generation ( 5 ) . build ( )
965
+ }
966
+ } ,
946
967
) ,
947
968
} ;
948
969
if let Some ( blob_dump_dirname) = & blob_dump_dirname {
@@ -1183,6 +1204,8 @@ fn prepare_bhd_directory_contents<'a>(
1183
1204
// Note: We need to do this
1184
1205
// manually because validation
1185
1206
// needs ABL_VERSION.
1207
+ // FIXME make sure to compare apcb.context() with our processor generation here.
1208
+ // Since the context is actually serialized to the JSON5 it could be messed with by the user and then deserialized again.
1186
1209
apcb. validate ( None )
1187
1210
. map_err ( apcb_to_io_error)
1188
1211
. unwrap ( ) ;
@@ -1227,7 +1250,7 @@ fn generate(
1227
1250
blobdirs : Vec < PathBuf > ,
1228
1251
verbose : bool ,
1229
1252
) -> std:: io:: Result < ( ) > {
1230
- let filename = & output_filename;
1253
+ let filename = output_filename;
1231
1254
let flash_to_io_error = |e : amd_efs:: flash:: Error | {
1232
1255
std:: io:: Error :: new (
1233
1256
std:: io:: ErrorKind :: Other ,
0 commit comments