Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "package_parser.hpp" |
| 4 | #include "sdbusplus/message/native_types.hpp" |
| 5 | |
| 6 | #include <cstdint> |
| 7 | #include <memory> |
| 8 | |
| 9 | using namespace pldm::fw_update; |
| 10 | |
| 11 | namespace pldm_package_util |
| 12 | { |
| 13 | |
| 14 | // @param buf pointer to the pldm package |
| 15 | // @param size size of 'buf' |
| 16 | // @returns PackageParser instance |
| 17 | std::shared_ptr<PackageParser> |
| 18 | parsePLDMPackage(const uint8_t* buf, size_t size); |
| 19 | |
| 20 | // reads into a buffer, from file |
| 21 | // @param file the file to read from |
| 22 | // @param package_data the pre-allocated buffer for the package data |
| 23 | // @param package_size how many bytes to read from the file |
| 24 | int readImagePackage(FILE* file, uint8_t* package_data, size_t package_size); |
| 25 | |
| 26 | // @param image file descriptor to the package |
| 27 | // @param size_out function will write the size of the package here |
| 28 | // @returns a pointer to the mmapped pldm package |
| 29 | void* mmapImagePackage(sdbusplus::message::unix_fd image, size_t* size_out); |
| 30 | |
| 31 | // @param packageParser PackageParser instance |
| 32 | // @param compatible 'compatible' string of device |
| 33 | // @param vendorIANA vendor iana of device |
| 34 | // @param component_offset_out function returns offset of component image |
| 35 | // @param component_size_out function returns size of component image |
| 36 | // @returns 0 on success |
| 37 | int extractMatchingComponentImage( |
| 38 | const std::shared_ptr<PackageParser>& packageParser, |
| 39 | const std::string& compatible, uint32_t vendorIANA, |
| 40 | uint32_t* component_offset_out, size_t* size_out); |
| 41 | |
| 42 | } // namespace pldm_package_util |