Open YuweiChen1110 opened 1 year ago
Update the Descriptions:
Design Ideas: A multiway tree will be created for input bios image file to include all the info. The whole bios image will be seen as the root node of the tree. When parse the image, the FV and FFS part in it will be seen as the node (FVNode/FFSNode) which is the child of the root/FVNode. With the tree, both the structure and data of different level layout ROOT/FV/FFS... can be saved which can be used for function extensions.
Feature Introductions 1. Parse the input bios image binary file into an origin multiway tree. PS: Currently, only root FFS level replacement operation is supported, so only two different types of tree nodes are defined FV/ FFS, the multiway tree only have FV/FFS Node. 2. Parse new driver FFS file. Given a new FFS file, the file can be parsed into a multiway tree with defined FFS Node which have the FFS info got from binary file. 3. Find FFS node. Go through the whole bios image tree to find the target FFS (which will be replaced by our new driver) with specific guid (get from new driver file). 4. Replace the target FFS node with new driver FFS node in the multiway tree. 5. Encapsulate multiway tree which has the replaced FFS into the output bios image.
Code Function Descriptions 1. uefi_parser.parse_binary(): extend the parser to parse both bios image and driver ffs file: We add the multiway tree establishment process into this function, and the input file of this function is extended to both FV and FFS file. All FV/FFS tree nodes with both multiway data and position info can be collected by this function. 2. uefi_parser.find_ffs_node() This function is used to find target FFS Node in the multiway tree. 3. uefi_parser.ReplaceFfs() This function is used to replace target FFS Node with given new FFS node. 4. uefi_parser.Encapsulate_binary() This function is used to encapsulate multiway tree data into the byte buffer. 5. uefi_parser.dump_binary() This function is used to dump the multiway tree data info into a file.
Use Methods Method 1: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs" (The file name can't be changed) into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py". Then the expected output bios image file "replaced_image.bin" which has the replaced driver ffs will be generated into the root folder. Method 2: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs" (with your own file name) into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py -r $(input_bios_image) $(target_driver_ffs).ffs $(output_bios_image)". Then the expected output bios image file $(output_bios_image) will be generated into the root folder.
Known Issues
Extension directions
This Updates Driver with GUID from another binary to fulfil usecase where:
label01.bin
which is working BIOSlabel_different.bin
which can be newer or older but eventually it does not have working driver which is expected by user.
TODO:
Functions Introduction Functions:
Use method Method 1: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs" (The file name can not be changed) into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py". Then the expected output binary file "replaced_image.bin" will be generated into the root folder. Method 2: Step 1: Copy the origin "bios_image.bin" & target "driver_image.ffs"( with your own file name )into the XmlCli repo root folder. Step 2: Open windows console with XmlCli repo root folder, then run "py -3 src\xmlcli\common\bios_fw_parser.py -r $(input_binary_file) $(target_driver_ffs).ffs $(output_binary_file)". Then the expected output binary file $(output_binary_file) will be generated into the root folder.
Known Issue 3.1 Only support replace the first find driver ffs. 3.2 Only support replace the same guid driver ffs file. 3.3 The entry extension in xmlcli_registry_listener.py does not been complemented.
Extension direction 4.1 All the Known Issues can be enhanced with more details requirements descriptions. 4.2 The binary tree can be extended to save all level's FV and FFS and Section Node through binary parsing. 4.3 The existed binary Tree can be used to extend more functions like "Add a new driver / Delete a driver...".