blob: 3865d4b5b1887630e03d75de5bce4a10c3bac8ff [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __FWU_NVM_H__
8#define __FWU_NVM_H__
9
10#include <nvm.h>
11#include <platform_def.h>
12
13#define FIP_IMAGE_UPDATE_DONE_FLAG (0xDEADBEEF)
14/*
15 * This is the temporary ddr address for loading backup fip.bin
16 * image from NVM which is used for replacing original fip.bin
17 * This address is chosen such that the NS_BL2U can be expanded
18 * in future and also considering the large size of fip.bin.
19 */
20#define FIP_IMAGE_TMP_DDR_ADDRESS (DRAM_BASE + 0x100000)
21#define FWU_TFTF_TESTCASE_BUFFER_OFFSET \
22 (TFTF_NVM_OFFSET + TFTF_STATE_OFFSET(testcase_buffer))
23
24/*
25 * This offset is used to corrupt data in fip.bin
26 * The offset is from the base where fip.bin is
27 * located in NVM. This particular value is chosen
28 * to make sure the corruption is done beyond fip header.
29 */
Manish V Badarkhe24a4a7c2020-06-05 08:41:42 +010030#define FIP_CORRUPT_OFFSET (0x400)
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020031
32/*
33 * This is the base address for backup fip.bin image in NVM
34 * which is used for replacing original fip.bin
35 * This address is chosen such that it can stay with all
36 * the other images in the NVM.
37 */
38#define FIP_BKP_ADDRESS (FLASH_BASE + 0x1000000)
39
40/* Writes the buffer to the flash at offset with length equal to
41 * size
42 * Returns: STATUS_FAIL, STATUS_SUCCESS, STATUS_OUT_OF_RESOURCES
43 */
44STATUS fwu_nvm_write(unsigned long long offset, const void *buffer, size_t size);
45
46/* Reads the flash into buffer at offset with length equal to
47 * size
48 * Returns: STATUS_FAIL, STATUS_SUCCESS, STATUS_OUT_OF_RESOURCES
49 */
50STATUS fwu_nvm_read(unsigned long long offset, void *buffer, size_t size);
51
52/*
53 * This function is used to replace the original fip.bin
54 * by the backup fip.bin passed through fip_addr argument.
55 */
56STATUS fwu_update_fip(unsigned long fip_addr);
57
58#endif /* __FWU_NVM_H__ */