-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathimage.c
More file actions
49 lines (41 loc) · 1.24 KB
/
image.c
File metadata and controls
49 lines (41 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include "image.h"
#include "Driver_Flash.h"
#include "flash_layout.h"
#include "region_defs.h"
#include "fih.h"
#ifndef TFM_BL1_MEMORY_MAPPED_FLASH
extern ARM_DRIVER_FLASH FLASH_DEV_NAME_BL1;
#endif /* !TFM_BL1_MEMORY_MAPPED_FLASH */
uint32_t __WEAK bl1_image_get_flash_offset(uint32_t image_id)
{
switch (image_id) {
case 0:
return FLASH_AREA_0_OFFSET;
#if defined(MCUBOOT_IMAGE_NUMBER) && (MCUBOOT_IMAGE_NUMBER == 2)
case 1:
return FLASH_AREA_1_OFFSET;
#endif
default:
FIH_PANIC;
}
}
#ifndef TFM_BL1_MEMORY_MAPPED_FLASH
fih_int bl1_image_copy_to_sram(uint32_t image_id, uint8_t *out)
{
uint32_t flash_offset;
fih_int fih_rc;
flash_offset = bl1_image_get_flash_offset(image_id);
fih_rc = fih_int_encode_zero_equality(
fih_not_eq(BL2_CODE_SIZE + BL1_2_HEADER_SIZE,
(FLASH_DEV_NAME_BL1.ReadData(flash_offset,
out,
BL2_CODE_SIZE + BL1_2_HEADER_SIZE))));
FIH_RET(fih_rc);
}
#endif /* !TFM_BL1_MEMORY_MAPPED_FLASH */