Commit 8f83003b authored by davidcunado-arm's avatar davidcunado-arm Committed by GitHub
Browse files

Merge pull request #1028 from vchong/bl32_optee_support_v2

hikey: Add BL32 (OP-TEE) support v2
parents 37debcc6 3b6e88a2
...@@ -14,6 +14,9 @@ Code Locations ...@@ -14,6 +14,9 @@ Code Locations
- ARM Trusted Firmware: - ARM Trusted Firmware:
`link <https://github.com/ARM-software/arm-trusted-firmware>`__ `link <https://github.com/ARM-software/arm-trusted-firmware>`__
- OP-TEE
`link <https://github.com/OP-TEE/optee_os>`__
- edk2: - edk2:
`link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__ `link <https://github.com/96boards-hikey/edk2/tree/testing/hikey960_v2.5>`__
...@@ -24,7 +27,7 @@ Code Locations ...@@ -24,7 +27,7 @@ Code Locations
`link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__ `link <https://github.com/96boards-hikey/l-loader/tree/testing/hikey960_v1.2>`__
- uefi-tools: - uefi-tools:
`link <https://github.com/96boards-hikey/uefi-tools/tree/testing/hikey960_v1>`__ `link <https://git.linaro.org/uefi/uefi-tools.git>`__
- atf-fastboot: - atf-fastboot:
`link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__ `link <https://github.com/96boards-hikey/atf-fastboot/tree/master>`__
...@@ -70,13 +73,11 @@ Build Procedure ...@@ -70,13 +73,11 @@ Build Procedure
FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]') FASTBOOT_BUILD_OPTION=$(echo ${BUILD_OPTION} | tr '[A-Z]' '[a-z]')
cd ${EDK2_DIR} cd ${EDK2_DIR}
# Build UEFI & ARM Trust Firmware # Build UEFI & ARM Trust Firmware
${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware hikey ${UEFI_TOOLS_DIR}/uefi-build.sh -b ${BUILD_OPTION} -a ../arm-trusted-firmware -s ../optee_os hikey
# Generate l-loader.bin # Generate l-loader.bin
cd ${BUILD_PATH}/l-loader cd ${BUILD_PATH}/l-loader
ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin ln -sf ${EDK2_OUTPUT_DIR}/FV/bl1.bin
ln -sf ${EDK2_OUTPUT_DIR}/FV/fip.bin
ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin ln -sf ${BUILD_PATH}/atf-fastboot/build/hikey/${FASTBOOT_BUILD_OPTION}/bl1.bin fastboot.bin
python gen_loader.py -o l-loader.bin --img_bl1=bl1.bin --img_ns_bl1u=BL33_AP_UEFI.fd
arm-linux-gnueabihf-gcc -c -o start.o start.S arm-linux-gnueabihf-gcc -c -o start.o start.S
arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader arm-linux-gnueabihf-ld -Bstatic -Tl-loader.lds -Ttext 0xf9800800 start.o -o loader
arm-linux-gnueabihf-objcopy -O binary loader temp arm-linux-gnueabihf-objcopy -O binary loader temp
...@@ -86,7 +87,7 @@ Build Procedure ...@@ -86,7 +87,7 @@ Build Procedure
.. code:: shell .. code:: shell
$PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh PTABLE=aosp-4g SECTOR_SIZE=512 bash -x generate_ptable.sh
Setup Console Setup Console
------------- -------------
...@@ -110,6 +111,13 @@ Setup Console ...@@ -110,6 +111,13 @@ Setup Console
2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner 2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
- Start ser2net
.. code:: shell
$sudo killall ser2net
$sudo ser2net -u
- Open the console. - Open the console.
.. code:: shell .. code:: shell
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
DEVICE_SIZE, \ DEVICE_SIZE, \
MT_DEVICE | MT_RW | MT_SECURE) MT_DEVICE | MT_RW | MT_SECURE)
#define MAP_TSP_MEM MAP_REGION_FLAT(TSP_SEC_MEM_BASE, \
TSP_SEC_MEM_SIZE, \
MT_MEMORY | MT_RW | MT_SECURE)
#define MAP_ROM_PARAM MAP_REGION_FLAT(XG2RAM0_BASE, \ #define MAP_ROM_PARAM MAP_REGION_FLAT(XG2RAM0_BASE, \
BL1_XG2RAM0_OFFSET, \ BL1_XG2RAM0_OFFSET, \
MT_DEVICE | MT_RO | MT_SECURE) MT_DEVICE | MT_RO | MT_SECURE)
...@@ -59,6 +63,7 @@ static const mmap_region_t hikey_mmap[] = { ...@@ -59,6 +63,7 @@ static const mmap_region_t hikey_mmap[] = {
static const mmap_region_t hikey_mmap[] = { static const mmap_region_t hikey_mmap[] = {
MAP_DDR, MAP_DDR,
MAP_DEVICE, MAP_DEVICE,
MAP_TSP_MEM,
{0} {0}
}; };
#endif #endif
...@@ -67,6 +72,15 @@ static const mmap_region_t hikey_mmap[] = { ...@@ -67,6 +72,15 @@ static const mmap_region_t hikey_mmap[] = {
static const mmap_region_t hikey_mmap[] = { static const mmap_region_t hikey_mmap[] = {
MAP_DEVICE, MAP_DEVICE,
MAP_SRAM, MAP_SRAM,
MAP_TSP_MEM,
{0}
};
#endif
#if IMAGE_BL32
static const mmap_region_t hikey_mmap[] = {
MAP_DEVICE,
MAP_DDR,
{0} {0}
}; };
#endif #endif
......
...@@ -144,6 +144,41 @@ void bl2_plat_set_bl31_ep_info(image_info_t *image, ...@@ -144,6 +144,41 @@ void bl2_plat_set_bl31_ep_info(image_info_t *image,
DISABLE_ALL_EXCEPTIONS); DISABLE_ALL_EXCEPTIONS);
} }
/*******************************************************************************
* Before calling this function BL32 is loaded in memory and its entrypoint
* is set by load_image. This is a placeholder for the platform to change
* the entrypoint of BL32 and set SPSR and security state.
* On Hikey we only set the security state of the entrypoint
******************************************************************************/
#ifdef BL32_BASE
void bl2_plat_set_bl32_ep_info(image_info_t *bl32_image_info,
entry_point_info_t *bl32_ep_info)
{
SET_SECURITY_STATE(bl32_ep_info->h.attr, SECURE);
/*
* The Secure Payload Dispatcher service is responsible for
* setting the SPSR prior to entry into the BL32 image.
*/
bl32_ep_info->spsr = 0;
}
/*******************************************************************************
* Populate the extents of memory available for loading BL32
******************************************************************************/
void bl2_plat_get_bl32_meminfo(meminfo_t *bl32_meminfo)
{
/*
* Populate the extents of memory available for loading BL32.
*/
bl32_meminfo->total_base = BL32_BASE;
bl32_meminfo->free_base = BL32_BASE;
bl32_meminfo->total_size =
(TSP_SEC_MEM_BASE + TSP_SEC_MEM_SIZE) - BL32_BASE;
bl32_meminfo->free_size =
(TSP_SEC_MEM_BASE + TSP_SEC_MEM_SIZE) - BL32_BASE;
}
#endif /* BL32_BASE */
void bl2_plat_set_bl33_ep_info(image_info_t *image, void bl2_plat_set_bl33_ep_info(image_info_t *image,
entry_point_info_t *bl33_ep_info) entry_point_info_t *bl33_ep_info)
{ {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/* Always assume DDR is 1GB size. */ /* Always assume DDR is 1GB size. */
#define DDR_BASE 0x0 #define DDR_BASE 0x0
#define DDR_SIZE 0x80000000 #define DDR_SIZE 0x40000000
#define DEVICE_BASE 0xF4000000 #define DEVICE_BASE 0xF4000000
#define DEVICE_SIZE 0x05800000 #define DEVICE_SIZE 0x05800000
...@@ -20,6 +20,25 @@ ...@@ -20,6 +20,25 @@
#define XG2RAM0_BASE 0xF9800000 #define XG2RAM0_BASE 0xF9800000
#define XG2RAM0_SIZE 0x00400000 #define XG2RAM0_SIZE 0x00400000
/* Memory location options for TSP */
#define HIKEY_SRAM_ID 0
#define HIKEY_DRAM_ID 1
/*
* DDR for OP-TEE (32MB from 0x3E00000-0x3FFFFFFF) is divided in several
* regions
* - Secure DDR (default is the top 16MB) used by OP-TEE
* - Non-secure DDR used by OP-TEE (shared memory and padding) (4MB)
* - Secure DDR (4MB aligned on 4MB) for OP-TEE's "Secure Data Path" feature
* - Non-secure DDR (8MB) reserved for OP-TEE's future use
*/
#define DDR_SEC_SIZE 0x01000000
#define DDR_SEC_BASE (DDR_BASE + DDR_SIZE - DDR_SEC_SIZE)
#define DDR_SDP_SIZE 0x00400000
#define DDR_SDP_BASE (DDR_SEC_BASE - 0x400000 /* align */ - \
DDR_SDP_SIZE)
#define SRAM_BASE 0xFFF80000 #define SRAM_BASE 0xFFF80000
#define SRAM_SIZE 0x00012000 #define SRAM_SIZE 0x00012000
......
...@@ -73,6 +73,10 @@ static const io_uuid_spec_t bl31_uuid_spec = { ...@@ -73,6 +73,10 @@ static const io_uuid_spec_t bl31_uuid_spec = {
.uuid = UUID_EL3_RUNTIME_FIRMWARE_BL31, .uuid = UUID_EL3_RUNTIME_FIRMWARE_BL31,
}; };
static const io_uuid_spec_t bl32_uuid_spec = {
.uuid = UUID_SECURE_PAYLOAD_BL32,
};
static const io_uuid_spec_t bl33_uuid_spec = { static const io_uuid_spec_t bl33_uuid_spec = {
.uuid = UUID_NON_TRUSTED_FIRMWARE_BL33, .uuid = UUID_NON_TRUSTED_FIRMWARE_BL33,
}; };
...@@ -102,6 +106,11 @@ static const struct plat_io_policy policies[] = { ...@@ -102,6 +106,11 @@ static const struct plat_io_policy policies[] = {
(uintptr_t)&bl31_uuid_spec, (uintptr_t)&bl31_uuid_spec,
check_fip check_fip
}, },
[BL32_IMAGE_ID] = {
&fip_dev_handle,
(uintptr_t)&bl32_uuid_spec,
check_fip
},
[BL33_IMAGE_ID] = { [BL33_IMAGE_ID] = {
&fip_dev_handle, &fip_dev_handle,
(uintptr_t)&bl33_uuid_spec, (uintptr_t)&bl33_uuid_spec,
......
...@@ -10,13 +10,6 @@ ...@@ -10,13 +10,6 @@
#include <arch.h> #include <arch.h>
#include "../hikey_def.h" #include "../hikey_def.h"
/*
* Platform binary types for linking
*/
#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
/* /*
* Generic platform constants * Generic platform constants
*/ */
...@@ -104,6 +97,33 @@ ...@@ -104,6 +97,33 @@
#define BL31_BASE BL2_LIMIT #define BL31_BASE BL2_LIMIT
#define BL31_LIMIT 0xF9898000 #define BL31_LIMIT 0xF9898000
/*
* BL3-2 specific defines.
*/
/*
* The TSP currently executes from TZC secured area of DRAM or SRAM.
*/
#define BL32_SRAM_BASE BL31_LIMIT
#define BL32_SRAM_LIMIT (BL31_LIMIT+0x80000) /* 512K */
#define BL32_DRAM_BASE DDR_SEC_BASE
#define BL32_DRAM_LIMIT (DDR_SEC_BASE+DDR_SEC_SIZE)
#if (HIKEY_TSP_RAM_LOCATION_ID == HIKEY_DRAM_ID)
#define TSP_SEC_MEM_BASE BL32_DRAM_BASE
#define TSP_SEC_MEM_SIZE (BL32_DRAM_LIMIT - BL32_DRAM_BASE)
#define BL32_BASE BL32_DRAM_BASE
#define BL32_LIMIT BL32_DRAM_LIMIT
#elif (HIKEY_TSP_RAM_LOCATION_ID == HIKEY_SRAM_ID)
#define TSP_SEC_MEM_BASE BL32_SRAM_BASE
#define TSP_SEC_MEM_SIZE (BL32_SRAM_LIMIT - BL32_SRAM_BASE)
#define BL32_BASE BL32_SRAM_BASE
#define BL32_LIMIT BL32_SRAM_LIMIT
#else
#error "Currently unsupported HIKEY_TSP_LOCATION_ID value"
#endif
#define NS_BL1U_BASE (BL2_BASE) #define NS_BL1U_BASE (BL2_BASE)
#define NS_BL1U_SIZE (0x00010000) #define NS_BL1U_SIZE (0x00010000)
#define NS_BL1U_LIMIT (NS_BL1U_BASE + NS_BL1U_SIZE) #define NS_BL1U_LIMIT (NS_BL1U_BASE + NS_BL1U_SIZE)
...@@ -113,10 +133,14 @@ ...@@ -113,10 +133,14 @@
*/ */
#define ADDR_SPACE_SIZE (1ull << 32) #define ADDR_SPACE_SIZE (1ull << 32)
#if IMAGE_BL1 || IMAGE_BL2 || IMAGE_BL31 #if IMAGE_BL1 || IMAGE_BL2 || IMAGE_BL32
#define MAX_XLAT_TABLES 3 #define MAX_XLAT_TABLES 3
#endif #endif
#if IMAGE_BL31
#define MAX_XLAT_TABLES 4
#endif
#define MAX_MMAP_REGIONS 16 #define MAX_MMAP_REGIONS 16
#define HIKEY_NS_IMAGE_OFFSET (DDR_BASE + 0x35000000) #define HIKEY_NS_IMAGE_OFFSET (DDR_BASE + 0x35000000)
......
...@@ -4,6 +4,17 @@ ...@@ -4,6 +4,17 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
# On Hikey, the TSP can execute from TZC secure area in DRAM (default)
# or SRAM.
HIKEY_TSP_RAM_LOCATION := dram
ifeq (${HIKEY_TSP_RAM_LOCATION}, dram)
HIKEY_TSP_RAM_LOCATION_ID = HIKEY_DRAM_ID
else ifeq (${HIKEY_TSP_RAM_LOCATION}, sram)
HIKEY_TSP_RAM_LOCATION_ID := HIKEY_SRAM_ID
else
$(error "Currently unsupported HIKEY_TSP_RAM_LOCATION value")
endif
CONSOLE_BASE := PL011_UART3_BASE CONSOLE_BASE := PL011_UART3_BASE
CRASH_CONSOLE_BASE := PL011_UART3_BASE CRASH_CONSOLE_BASE := PL011_UART3_BASE
PLAT_PARTITION_MAX_ENTRIES := 12 PLAT_PARTITION_MAX_ENTRIES := 12
...@@ -12,11 +23,11 @@ COLD_BOOT_SINGLE_CPU := 1 ...@@ -12,11 +23,11 @@ COLD_BOOT_SINGLE_CPU := 1
PROGRAMMABLE_RESET_ADDRESS := 1 PROGRAMMABLE_RESET_ADDRESS := 1
# Process flags # Process flags
$(eval $(call add_define,HIKEY_TSP_RAM_LOCATION_ID))
$(eval $(call add_define,CONSOLE_BASE)) $(eval $(call add_define,CONSOLE_BASE))
$(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_MAX_ENTRIES)) $(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES))
$(eval $(call FIP_ADD_IMG,SCP_BL2,--scp-fw))
ENABLE_PLAT_COMPAT := 0 ENABLE_PLAT_COMPAT := 0
......
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