Commit 69ef7b7f authored by Paul Beesley's avatar Paul Beesley Committed by TrustedFirmware Code Review
Browse files

Merge changes I0283fc2e,Ib476d024,Iada05f7c into integration

* changes:
  hikey: fix to load FIP by partition table.
  hikey960: fix to load FIP by partition table
  drivers: partition: support different block size
parents 80a624d1 deb330cb
...@@ -546,6 +546,13 @@ optionally be defined: ...@@ -546,6 +546,13 @@ optionally be defined:
PLAT_PARTITION_MAX_ENTRIES := 12 PLAT_PARTITION_MAX_ENTRIES := 12
$(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES)) $(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES))
- **PLAT_PARTITION_BLOCK_SIZE**
The size of partition block. It could be either 512 bytes or 4096 bytes.
The default value is 512.
`For example, define the build flag in platform.mk`_:
PLAT_PARTITION_BLOCK_SIZE := 4096
$(eval $(call add_define,PLAT_PARTITION_BLOCK_SIZE))
The following constant is optional. It should be defined to override the default The following constant is optional. It should be defined to override the default
behaviour of the ``assert()`` function (for example, to save memory). behaviour of the ``assert()`` function (for example, to save memory).
......
...@@ -52,9 +52,10 @@ int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry) ...@@ -52,9 +52,10 @@ int parse_gpt_entry(gpt_entry_t *gpt_entry, partition_entry_t *entry)
if (result != 0) { if (result != 0) {
return result; return result;
} }
entry->start = (uint64_t)gpt_entry->first_lba * PARTITION_BLOCK_SIZE; entry->start = (uint64_t)gpt_entry->first_lba *
PLAT_PARTITION_BLOCK_SIZE;
entry->length = (uint64_t)(gpt_entry->last_lba - entry->length = (uint64_t)(gpt_entry->last_lba -
gpt_entry->first_lba + 1) * gpt_entry->first_lba + 1) *
PARTITION_BLOCK_SIZE; PLAT_PARTITION_BLOCK_SIZE;
return 0; return 0;
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <drivers/partition/mbr.h> #include <drivers/partition/mbr.h>
#include <plat/common/platform.h> #include <plat/common/platform.h>
static uint8_t mbr_sector[PARTITION_BLOCK_SIZE]; static uint8_t mbr_sector[PLAT_PARTITION_BLOCK_SIZE];
static partition_entry_list_t list; static partition_entry_list_t list;
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
...@@ -57,15 +57,15 @@ static int load_mbr_header(uintptr_t image_handle, mbr_entry_t *mbr_entry) ...@@ -57,15 +57,15 @@ static int load_mbr_header(uintptr_t image_handle, mbr_entry_t *mbr_entry)
return result; return result;
} }
result = io_read(image_handle, (uintptr_t)&mbr_sector, result = io_read(image_handle, (uintptr_t)&mbr_sector,
PARTITION_BLOCK_SIZE, &bytes_read); PLAT_PARTITION_BLOCK_SIZE, &bytes_read);
if (result != 0) { if (result != 0) {
WARN("Failed to read data (%i)\n", result); WARN("Failed to read data (%i)\n", result);
return result; return result;
} }
/* Check MBR boot signature. */ /* Check MBR boot signature. */
if ((mbr_sector[PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) || if ((mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) ||
(mbr_sector[PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) { (mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) {
return -ENOENT; return -ENOENT;
} }
offset = (uintptr_t)&mbr_sector + MBR_PRIMARY_ENTRY_OFFSET; offset = (uintptr_t)&mbr_sector + MBR_PRIMARY_ENTRY_OFFSET;
...@@ -120,15 +120,15 @@ static int load_mbr_entry(uintptr_t image_handle, mbr_entry_t *mbr_entry, ...@@ -120,15 +120,15 @@ static int load_mbr_entry(uintptr_t image_handle, mbr_entry_t *mbr_entry,
return result; return result;
} }
result = io_read(image_handle, (uintptr_t)&mbr_sector, result = io_read(image_handle, (uintptr_t)&mbr_sector,
PARTITION_BLOCK_SIZE, &bytes_read); PLAT_PARTITION_BLOCK_SIZE, &bytes_read);
if (result != 0) { if (result != 0) {
WARN("Failed to read data (%i)\n", result); WARN("Failed to read data (%i)\n", result);
return result; return result;
} }
/* Check MBR boot signature. */ /* Check MBR boot signature. */
if ((mbr_sector[PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) || if ((mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 2] != MBR_SIGNATURE_FIRST) ||
(mbr_sector[PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) { (mbr_sector[LEGACY_PARTITION_BLOCK_SIZE - 1] != MBR_SIGNATURE_SECOND)) {
return -ENOENT; return -ENOENT;
} }
offset = (uintptr_t)&mbr_sector + offset = (uintptr_t)&mbr_sector +
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include <drivers/partition/partition.h> #include <drivers/partition/partition.h>
#define PARTITION_TYPE_GPT 0xee #define PARTITION_TYPE_GPT 0xee
#define GPT_HEADER_OFFSET PARTITION_BLOCK_SIZE #define GPT_HEADER_OFFSET PLAT_PARTITION_BLOCK_SIZE
#define GPT_ENTRY_OFFSET (GPT_HEADER_OFFSET + \ #define GPT_ENTRY_OFFSET (GPT_HEADER_OFFSET + \
PARTITION_BLOCK_SIZE) PLAT_PARTITION_BLOCK_SIZE)
#define GUID_LEN 16 #define GUID_LEN 16
#define GPT_SIGNATURE "EFI PART" #define GPT_SIGNATURE "EFI PART"
......
...@@ -17,7 +17,15 @@ ...@@ -17,7 +17,15 @@
CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries); CASSERT(PLAT_PARTITION_MAX_ENTRIES <= 128, assert_plat_partition_max_entries);
#define PARTITION_BLOCK_SIZE 512 #if !PLAT_PARTITION_BLOCK_SIZE
# define PLAT_PARTITION_BLOCK_SIZE 512
#endif /* PLAT_PARTITION_BLOCK_SIZE */
CASSERT((PLAT_PARTITION_BLOCK_SIZE == 512) ||
(PLAT_PARTITION_BLOCK_SIZE == 4096),
assert_plat_partition_block_size);
#define LEGACY_PARTITION_BLOCK_SIZE 512
#define EFI_NAMELEN 36 #define EFI_NAMELEN 36
......
...@@ -114,6 +114,11 @@ uint32_t hikey_get_spsr_for_bl33_entry(void) ...@@ -114,6 +114,11 @@ uint32_t hikey_get_spsr_for_bl33_entry(void)
} }
#endif /* __aarch64__ */ #endif /* __aarch64__ */
int bl2_plat_handle_pre_image_load(unsigned int image_id)
{
return hikey_set_fip_addr(image_id, "fastboot");
}
int hikey_bl2_handle_post_image_load(unsigned int image_id) int hikey_bl2_handle_post_image_load(unsigned int image_id)
{ {
int err = 0; int err = 0;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <drivers/io/io_memmap.h> #include <drivers/io/io_memmap.h>
#include <drivers/io/io_storage.h> #include <drivers/io/io_storage.h>
#include <drivers/mmc.h> #include <drivers/mmc.h>
#include <drivers/partition/partition.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/semihosting.h> #include <lib/semihosting.h>
#include <tools_share/firmware_image_package.h> #include <tools_share/firmware_image_package.h>
...@@ -43,9 +44,12 @@ static uintptr_t fip_dev_handle; ...@@ -43,9 +44,12 @@ static uintptr_t fip_dev_handle;
static int check_emmc(const uintptr_t spec); static int check_emmc(const uintptr_t spec);
static int check_fip(const uintptr_t spec); static int check_fip(const uintptr_t spec);
static const io_block_spec_t emmc_fip_spec = { static io_block_spec_t emmc_fip_spec;
.offset = HIKEY_FIP_BASE,
.length = HIKEY_FIP_MAX_SIZE, static const io_block_spec_t emmc_gpt_spec = {
.offset = 0,
.length = PLAT_PARTITION_BLOCK_SIZE *
(PLAT_PARTITION_MAX_ENTRIES / 4 + 2),
}; };
static const io_block_dev_spec_t emmc_dev_spec = { static const io_block_dev_spec_t emmc_dev_spec = {
...@@ -213,6 +217,11 @@ static const struct plat_io_policy policies[] = { ...@@ -213,6 +217,11 @@ static const struct plat_io_policy policies[] = {
check_fip check_fip
}, },
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
[GPT_IMAGE_ID] = {
&emmc_dev_handle,
(uintptr_t)&emmc_gpt_spec,
check_emmc
},
}; };
static int check_emmc(const uintptr_t spec) static int check_emmc(const uintptr_t spec)
...@@ -267,6 +276,23 @@ void hikey_io_setup(void) ...@@ -267,6 +276,23 @@ void hikey_io_setup(void)
(void)result; (void)result;
} }
int hikey_set_fip_addr(unsigned int image_id, const char *name)
{
const partition_entry_t *entry;
if (emmc_fip_spec.length == 0) {
partition_init(GPT_IMAGE_ID);
entry = get_partition_entry(name);
if (entry == NULL) {
ERROR("Could NOT find the %s partition!\n", name);
return -ENOENT;
}
emmc_fip_spec.offset = entry->start;
emmc_fip_spec.length = entry->length;
}
return 0;
}
/* Return an IO device handle and specification which can be used to access /* Return an IO device handle and specification which can be used to access
* an image. Use this to enforce platform load policy * an image. Use this to enforce platform load policy
*/ */
......
...@@ -72,4 +72,6 @@ int hikey_write_serialno(struct random_serial_num *serialno); ...@@ -72,4 +72,6 @@ int hikey_write_serialno(struct random_serial_num *serialno);
void init_acpu_dvfs(void); void init_acpu_dvfs(void);
int hikey_set_fip_addr(unsigned int image_id, const char *name);
#endif /* HIKEY_PRIVATE_H */ #endif /* HIKEY_PRIVATE_H */
...@@ -84,8 +84,6 @@ ...@@ -84,8 +84,6 @@
#define HIKEY_BL1_MMC_DATA_SIZE 0x0000B000 #define HIKEY_BL1_MMC_DATA_SIZE 0x0000B000
#define EMMC_BASE 0 #define EMMC_BASE 0
#define HIKEY_FIP_BASE (EMMC_BASE + (4 << 20))
#define HIKEY_FIP_MAX_SIZE (8 << 20)
#define HIKEY_EMMC_RPMB_BASE (EMMC_BASE + 0) #define HIKEY_EMMC_RPMB_BASE (EMMC_BASE + 0)
#define HIKEY_EMMC_RPMB_MAX_SIZE (128 << 10) #define HIKEY_EMMC_RPMB_MAX_SIZE (128 << 10)
#define HIKEY_EMMC_USERDATA_BASE (EMMC_BASE + 0) #define HIKEY_EMMC_USERDATA_BASE (EMMC_BASE + 0)
......
...@@ -76,6 +76,8 @@ BL2_SOURCES += common/desc_image_load.c \ ...@@ -76,6 +76,8 @@ BL2_SOURCES += common/desc_image_load.c \
drivers/io/io_fip.c \ drivers/io/io_fip.c \
drivers/io/io_storage.c \ drivers/io/io_storage.c \
drivers/mmc/mmc.c \ drivers/mmc/mmc.c \
drivers/partition/gpt.c \
drivers/partition/partition.c \
drivers/synopsys/emmc/dw_mmc.c \ drivers/synopsys/emmc/dw_mmc.c \
lib/cpus/aarch64/cortex_a53.S \ lib/cpus/aarch64/cortex_a53.S \
plat/hisilicon/hikey/aarch64/hikey_helpers.S \ plat/hisilicon/hikey/aarch64/hikey_helpers.S \
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <drivers/delay_timer.h> #include <drivers/delay_timer.h>
#include <drivers/dw_ufs.h> #include <drivers/dw_ufs.h>
#include <drivers/generic_delay_timer.h> #include <drivers/generic_delay_timer.h>
#include <drivers/partition/partition.h>
#include <drivers/ufs.h> #include <drivers/ufs.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#ifdef SPD_opteed #ifdef SPD_opteed
...@@ -263,6 +264,11 @@ int hikey960_bl2_handle_post_image_load(unsigned int image_id) ...@@ -263,6 +264,11 @@ int hikey960_bl2_handle_post_image_load(unsigned int image_id)
* This function can be used by the platforms to update/use image * This function can be used by the platforms to update/use image
* information for given `image_id`. * information for given `image_id`.
******************************************************************************/ ******************************************************************************/
int bl2_plat_handle_pre_image_load(unsigned int image_id)
{
return hikey960_set_fip_addr(image_id, "fip");
}
int bl2_plat_handle_post_image_load(unsigned int image_id) int bl2_plat_handle_post_image_load(unsigned int image_id)
{ {
return hikey960_bl2_handle_post_image_load(image_id); return hikey960_bl2_handle_post_image_load(image_id);
......
...@@ -44,9 +44,6 @@ ...@@ -44,9 +44,6 @@
#define PL011_UART_CLK_IN_HZ 19200000 #define PL011_UART_CLK_IN_HZ 19200000
#define UFS_BASE 0 #define UFS_BASE 0
/* FIP partition */
#define HIKEY960_FIP_BASE (UFS_BASE + 0x1400000)
#define HIKEY960_FIP_MAX_SIZE (12 << 20)
#define HIKEY960_UFS_DESC_BASE 0x20000000 #define HIKEY960_UFS_DESC_BASE 0x20000000
#define HIKEY960_UFS_DESC_SIZE 0x00200000 /* 2MB */ #define HIKEY960_UFS_DESC_SIZE 0x00200000 /* 2MB */
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <drivers/io/io_fip.h> #include <drivers/io/io_fip.h>
#include <drivers/io/io_memmap.h> #include <drivers/io/io_memmap.h>
#include <drivers/io/io_storage.h> #include <drivers/io/io_storage.h>
#include <drivers/partition/partition.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/semihosting.h> #include <lib/semihosting.h>
#include <tools_share/firmware_image_package.h> #include <tools_share/firmware_image_package.h>
...@@ -36,9 +37,12 @@ static int check_fip(const uintptr_t spec); ...@@ -36,9 +37,12 @@ static int check_fip(const uintptr_t spec);
size_t ufs_read_lun3_blks(int lba, uintptr_t buf, size_t size); size_t ufs_read_lun3_blks(int lba, uintptr_t buf, size_t size);
size_t ufs_write_lun3_blks(int lba, const uintptr_t buf, size_t size); size_t ufs_write_lun3_blks(int lba, const uintptr_t buf, size_t size);
static const io_block_spec_t ufs_fip_spec = { static io_block_spec_t ufs_fip_spec;
.offset = HIKEY960_FIP_BASE,
.length = HIKEY960_FIP_MAX_SIZE, static const io_block_spec_t ufs_gpt_spec = {
.offset = 0,
.length = PLAT_PARTITION_BLOCK_SIZE *
(PLAT_PARTITION_MAX_ENTRIES / 4 + 2),
}; };
static const io_block_dev_spec_t ufs_dev_spec = { static const io_block_dev_spec_t ufs_dev_spec = {
...@@ -199,6 +203,11 @@ static const struct plat_io_policy policies[] = { ...@@ -199,6 +203,11 @@ static const struct plat_io_policy policies[] = {
check_fip check_fip
}, },
#endif /* TRUSTED_BOARD_BOOT */ #endif /* TRUSTED_BOARD_BOOT */
[GPT_IMAGE_ID] = {
&ufs_dev_handle,
(uintptr_t)&ufs_gpt_spec,
check_ufs
},
}; };
static int check_ufs(const uintptr_t spec) static int check_ufs(const uintptr_t spec)
...@@ -253,6 +262,23 @@ void hikey960_io_setup(void) ...@@ -253,6 +262,23 @@ void hikey960_io_setup(void)
(void)result; (void)result;
} }
int hikey960_set_fip_addr(unsigned int image_id, const char *name)
{
const partition_entry_t *entry;
if (ufs_fip_spec.length == 0) {
partition_init(GPT_IMAGE_ID);
entry = get_partition_entry(name);
if (entry == NULL) {
ERROR("Could NOT find the %s partition!\n", name);
return -ENOENT;
}
ufs_fip_spec.offset = entry->start;
ufs_fip_spec.length = entry->length;
}
return 0;
}
/* Return an IO device handle and specification which can be used to access /* Return an IO device handle and specification which can be used to access
* an image. Use this to enforce platform load policy * an image. Use this to enforce platform load policy
*/ */
......
...@@ -26,6 +26,7 @@ void hikey960_init_mmu_el3(unsigned long total_base, ...@@ -26,6 +26,7 @@ void hikey960_init_mmu_el3(unsigned long total_base,
unsigned long coh_limit); unsigned long coh_limit);
void hikey960_io_setup(void); void hikey960_io_setup(void);
int hikey960_read_boardid(unsigned int *id); int hikey960_read_boardid(unsigned int *id);
int hikey960_set_fip_addr(unsigned int image_id, const char *name);
void hikey960_clk_init(void); void hikey960_clk_init(void);
void hikey960_pmu_init(void); void hikey960_pmu_init(void);
void hikey960_regulator_enable(void); void hikey960_regulator_enable(void);
......
...@@ -22,11 +22,13 @@ COLD_BOOT_SINGLE_CPU := 1 ...@@ -22,11 +22,13 @@ COLD_BOOT_SINGLE_CPU := 1
PLAT_PL061_MAX_GPIOS := 176 PLAT_PL061_MAX_GPIOS := 176
PROGRAMMABLE_RESET_ADDRESS := 1 PROGRAMMABLE_RESET_ADDRESS := 1
ENABLE_SVE_FOR_NS := 0 ENABLE_SVE_FOR_NS := 0
PLAT_PARTITION_BLOCK_SIZE := 4096
# Process flags # Process flags
$(eval $(call add_define,HIKEY960_TSP_RAM_LOCATION_ID)) $(eval $(call add_define,HIKEY960_TSP_RAM_LOCATION_ID))
$(eval $(call add_define,CRASH_CONSOLE_BASE)) $(eval $(call add_define,CRASH_CONSOLE_BASE))
$(eval $(call add_define,PLAT_PL061_MAX_GPIOS)) $(eval $(call add_define,PLAT_PL061_MAX_GPIOS))
$(eval $(call add_define,PLAT_PARTITION_BLOCK_SIZE))
# Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images
# in the FIP if the platform requires. # in the FIP if the platform requires.
...@@ -75,6 +77,8 @@ BL2_SOURCES += common/desc_image_load.c \ ...@@ -75,6 +77,8 @@ BL2_SOURCES += common/desc_image_load.c \
drivers/io/io_block.c \ drivers/io/io_block.c \
drivers/io/io_fip.c \ drivers/io/io_fip.c \
drivers/io/io_storage.c \ drivers/io/io_storage.c \
drivers/partition/gpt.c \
drivers/partition/partition.c \
drivers/synopsys/ufs/dw_ufs.c \ drivers/synopsys/ufs/dw_ufs.c \
drivers/ufs/ufs.c \ drivers/ufs/ufs.c \
lib/cpus/aarch64/cortex_a53.S \ lib/cpus/aarch64/cortex_a53.S \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment