1 /* 2 * Copyright (c) 2022-2023, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef __HOST_FLASH_ATU_H__ 9 #define __HOST_FLASH_ATU_H__ 10 11 #include <stdint.h> 12 #include <stddef.h> 13 #include <stdbool.h> 14 15 #include "uuid.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * \brief Gets the offsets of the FIPs in host flash. If GPT is 23 * supported these are parsed from the GPT partition 24 * list, else the hardcoded values are returned. 25 * 26 * \param[out] fip_found Which fips were found. If fip_found[x] is 0, then the 27 * value of fip_offsets[x] is undefined. 28 * \param[out] fip_offsets The FIP offsets. 29 * 30 * \return 0 on success, non-zero on failure. 31 */ 32 int host_flash_atu_get_fip_offsets(bool fip_found[2], uint64_t fip_offsets[2]); 33 34 /** 35 * \brief Set up the input ATU slots so that an 36 * image can be loaded from host flash. 37 * Parses a FIP via an intermediate ATU slot 38 * to find the image offset. 39 * 40 * \param[in] fip_offset The host flash offset of the FIP that 41 * should be parsed to find the image offset. 42 * 43 * \param[in] slot The ATU slot that should be setup as the 44 * image input slot. 45 * 46 * \param[in] logical_address The address in RSE memory to which the ATU 47 * should map the image. 48 * 49 * \param[in] image_uuid The UUID of the image that should be have 50 * its slot set up. This is used when parsing 51 * the FIP for the offset. 52 * 53 * \param[out] logical_address_offset The offset that the image has been mapped 54 * at (so the base of the image is 55 * logical_address + logical_address_offset). 56 * This is required because images may not be 57 * aligned to the ATU page size. 58 * 59 * \param[out] atu_slot_size The size of the mapped image. 60 * 61 * \return 0 on success, non-zero on failure. 62 */ 63 int host_flash_atu_setup_image_input_slots_from_fip(uint64_t fip_offset, 64 uint32_t slot, 65 uintptr_t logical_address, 66 uuid_t image_uuid, 67 uint32_t *logical_address_offset, 68 size_t *atu_slot_size); 69 70 /** 71 * \brief Setup the input and output slots for a 72 * given image. returns the offsets from the 73 * expected logical address that the image 74 * has been mapped to (to account for images 75 * not being aligned to the ATU page size). 76 * 77 * \param[in] image_uuid The UUID of the image that should be have 78 * its input and output slots set up. 79 * 80 * \param[out] offsets The offsets that the primary and secondary 81 * images for that particular UUID have been 82 * mapped at (offset from their expected 83 * logical addresses). 84 * 85 * \return 0 on success, non-zero on failure. 86 */ 87 int host_flash_atu_init_regions_for_image(uuid_t image_uuid, uint32_t offsets[2]); 88 89 /** 90 * \brief Teardown all image input and output slots. 91 * Should be called between mapping different 92 * images. 93 * 94 * \return 0 on success, non-zero on failure. 95 */ 96 int host_flash_atu_uninit_regions(void); 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif /* __HOST_FLASH_ATU_H__ */ 103