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> |
Alexander Hansen | cc37235 | 2025-01-14 14:15:39 +0100 | [diff] [blame^] | 7 | #include <functional> |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
| 10 | using namespace pldm::fw_update; |
| 11 | |
| 12 | namespace pldm_package_util |
| 13 | { |
| 14 | |
| 15 | // @param buf pointer to the pldm package |
| 16 | // @param size size of 'buf' |
| 17 | // @returns PackageParser instance |
Patrick Williams | eae5ec9 | 2025-02-01 08:21:45 -0500 | [diff] [blame] | 18 | std::shared_ptr<PackageParser> parsePLDMPackage(const uint8_t* buf, |
| 19 | size_t size); |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 20 | |
| 21 | // reads into a buffer, from file |
| 22 | // @param file the file to read from |
Alexander Hansen | cc37235 | 2025-01-14 14:15:39 +0100 | [diff] [blame^] | 23 | // @param packageData the pre-allocated buffer for the package data |
| 24 | // @param packageSize how many bytes to read from the file |
| 25 | int readImagePackage(FILE* file, uint8_t* packageData, size_t packageSize); |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 26 | |
| 27 | // @param image file descriptor to the package |
Alexander Hansen | cc37235 | 2025-01-14 14:15:39 +0100 | [diff] [blame^] | 28 | // @param sizeOut function will write the size of the package here |
| 29 | // @returns a unique pointer to the mmapped pldm package |
| 30 | std::unique_ptr<void, std::function<void(void*)>> mmapImagePackage( |
| 31 | sdbusplus::message::unix_fd image, size_t* sizeOut); |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 32 | |
| 33 | // @param packageParser PackageParser instance |
| 34 | // @param compatible 'compatible' string of device |
| 35 | // @param vendorIANA vendor iana of device |
Alexander Hansen | cc37235 | 2025-01-14 14:15:39 +0100 | [diff] [blame^] | 36 | // @param componentOffsetOut function returns offset of component image |
| 37 | // @param componentSizeOut function returns size of component image |
| 38 | // @param componentVersionOut function returns version of component image |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 39 | // @returns 0 on success |
| 40 | int extractMatchingComponentImage( |
| 41 | const std::shared_ptr<PackageParser>& packageParser, |
| 42 | const std::string& compatible, uint32_t vendorIANA, |
Alexander Hansen | cc37235 | 2025-01-14 14:15:39 +0100 | [diff] [blame^] | 43 | uint32_t* componentOffsetOut, size_t* componentSizeOut, |
| 44 | std::string& componentVersionOut); |
Alexander Hansen | 00b3cae | 2024-11-26 17:32:33 +0100 | [diff] [blame] | 45 | |
| 46 | } // namespace pldm_package_util |