blob: e510be1cf89fa50dfd225758b4405b014dc17bf6 [file] [log] [blame]
Alexander Hansen00b3cae2024-11-26 17:32:33 +01001#pragma once
2
3#include "package_parser.hpp"
4#include "sdbusplus/message/native_types.hpp"
5
6#include <cstdint>
7#include <memory>
8
9using namespace pldm::fw_update;
10
11namespace pldm_package_util
12{
13
14// @param buf pointer to the pldm package
15// @param size size of 'buf'
16// @returns PackageParser instance
Patrick Williamseae5ec92025-02-01 08:21:45 -050017std::shared_ptr<PackageParser> parsePLDMPackage(const uint8_t* buf,
18 size_t size);
Alexander Hansen00b3cae2024-11-26 17:32:33 +010019
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
24int 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
29void* 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
37int 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