Skip to content

Commit 1417a63

Browse files
orenc17adbridge
authored andcommitted
Updated to f2dea5b
1 parent b078056 commit 1417a63

34 files changed

+722
-371
lines changed

components/TARGET_PSA/TARGET_TFM/COMPONENT_NSPE/interface/src/tfm_ns_lock_rtx.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
*/
77
#include <stdint.h>
88
#include <stdbool.h>
9-
#include "cmsis.h"
10-
#include "rtx_os.h"
9+
1110
#include "cmsis_os2.h"
11+
1212
#include "tfm_api.h"
1313
#include "tfm_ns_lock.h"
1414

@@ -29,14 +29,11 @@ static struct ns_lock_state ns_lock = {.init=false, .id=NULL};
2929
/**
3030
* \brief Mutex properties, NS lock
3131
*/
32-
33-
static osRtxMutex_t ns_lock_cb = { 0 };
34-
3532
static const osMutexAttr_t ns_lock_attrib = {
3633
.name = "ns_lock",
3734
.attr_bits = osMutexPrioInherit,
38-
.cb_mem = &ns_lock_cb,
39-
.cb_size = sizeof(ns_lock_cb)
35+
.cb_mem = NULL,
36+
.cb_size = 0U
4037
};
4138

4239
/**
@@ -54,19 +51,23 @@ uint32_t tfm_ns_lock_dispatch(veneer_fn fn,
5451
}
5552

5653
/* TFM request protected by NS lock */
57-
osMutexAcquire(ns_lock.id,osWaitForever);
54+
if (osMutexAcquire(ns_lock.id,osWaitForever) != osOK) {
55+
return TFM_ERROR_GENERIC;
56+
}
5857

5958
result = fn(arg0, arg1, arg2, arg3);
6059

61-
osMutexRelease(ns_lock.id);
60+
if (osMutexRelease(ns_lock.id) != osOK) {
61+
return TFM_ERROR_GENERIC;
62+
}
6263

6364
return result;
6465
}
6566

6667
/**
6768
* \brief NS world, Init NS lock
6869
*/
69-
uint32_t tfm_ns_lock_init()
70+
enum tfm_status_e tfm_ns_lock_init()
7071
{
7172
if (ns_lock.init == false) {
7273
ns_lock.id = osMutexNew(&ns_lock_attrib);
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef __BOOT_RECORD_H__
9+
#define __BOOT_RECORD_H__
10+
11+
#include <stdint.h>
12+
#include <stddef.h>
13+
#include <limits.h>
14+
#include "../ext/mcuboot/bootutil/include/bootutil/image.h"
15+
#include "../ext/mcuboot/include/flash_map/flash_map.h"
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
/*!
22+
* \enum shared_data_err_t
23+
*
24+
* \brief Return values for adding data entry to shared memory area
25+
*/
26+
enum shared_memory_err_t {
27+
SHARED_MEMORY_OK = 0,
28+
SHARED_MEMORY_OVERFLOW = 1,
29+
SHARED_MEMORY_OVERWRITE = 2,
30+
31+
/* This is used to force the maximum size */
32+
TLV_TYPE_MAX = INT_MAX
33+
};
34+
35+
/*!
36+
* \enum boot_status_err_t
37+
*
38+
* \brief Return values for saving boot status information to shared memory are
39+
*/
40+
enum boot_status_err_t {
41+
BOOT_STATUS_OK,
42+
BOOT_STATUS_ERROR,
43+
};
44+
45+
/*!
46+
* \brief Add a data item to the shared data area between bootloader and
47+
* runtime SW
48+
*
49+
* \param[in] major_type TLV major type, identify consumer
50+
* \param[in] minor_type TLV minor type, identify TLV type
51+
* \param[in] size length of added data
52+
* \param[in] data pointer to data
53+
*
54+
* \return Returns error code as specified in \ref shared_memory_err_t
55+
*/
56+
enum shared_memory_err_t
57+
boot_add_data_to_shared_area(uint8_t major_type,
58+
uint16_t minor_type,
59+
size_t size,
60+
const uint8_t *data);
61+
62+
/*!
63+
* \brief Add an image's all boot status information to the shared data area
64+
* between bootloader and runtime SW
65+
*
66+
* \param[in] sw_module Identifier of the SW component
67+
* \param[in] hdr Pointer to the image header stored in RAM
68+
* \param[in] fap Pointer to the flash area where image is stored
69+
*
70+
* \return Returns error code as specified in \ref boot_status_err_t
71+
*/
72+
enum boot_status_err_t
73+
boot_save_boot_status(uint8_t sw_module,
74+
const struct image_header *hdr,
75+
const struct flash_area *fap);
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
81+
#endif /* __BOOT_RECORD_H__ */

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/bl2/include/tfm_boot_status.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ struct shared_data_tlv_entry {
197197
uint16_t tlv_len; /* size of single TLV entry (including this header). */
198198
};
199199

200+
/**
201+
* \struct tfm_boot_data
202+
*
203+
* \brief Store the data for the runtime SW
204+
*/
205+
struct tfm_boot_data {
206+
struct shared_data_tlv_header header;
207+
uint8_t data[];
208+
};
209+
200210
#define SHARED_DATA_ENTRY_HEADER_SIZE sizeof(struct shared_data_tlv_entry)
201211
#define SHARED_DATA_ENTRY_SIZE(size) (size + SHARED_DATA_ENTRY_HEADER_SIZE)
202212

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
#-------------------------------------------------------------------------------
7+
8+
#Definitions to compile the "core" module.
9+
#This file assumes it will be included from a project specific cmakefile, and
10+
#will not create a library or executable.
11+
#Inputs:
12+
# TFM_ROOT_DIR - directory where secure FW sourec is located.
13+
#
14+
#Outputs:
15+
# Will modify include directories to make the source compile.
16+
# ALL_SRC_C: C source files to be compiled will be added to this list.
17+
# This shall be added to your add_executable or add_library command.
18+
# ALL_SRC_CXX: C++ source files to be compiled will be added to this list.
19+
# This shall be added to your add_executable or add_library command.
20+
# ALL_SRC_ASM: assembly source files to be compiled will be added to this
21+
# list. This shall be added to your add_executable or add_library
22+
# command.
23+
# Include directories will be modified by using the include_directories()
24+
# commands as needed.
25+
26+
#Get the current directory where this file is located.
27+
set(SS_CORE_DIR ${CMAKE_CURRENT_LIST_DIR})
28+
if(NOT DEFINED TFM_ROOT_DIR)
29+
message(FATAL_ERROR
30+
"Please set TFM_ROOT_DIR before including this file.")
31+
endif()
32+
33+
set (SS_CORE_C_SRC
34+
"${SS_CORE_DIR}/tfm_core.c"
35+
"${SS_CORE_DIR}/tfm_handler.c"
36+
"${SS_CORE_DIR}/tfm_secure_api.c"
37+
"${SS_CORE_DIR}/tfm_spm_services.c"
38+
"${SS_CORE_DIR}/tfm_nspm.c"
39+
"${SS_CORE_DIR}/tfm_boot_data.c"
40+
)
41+
42+
#Append all our source files to global lists.
43+
list(APPEND ALL_SRC_C ${SS_CORE_C_SRC})
44+
unset(SS_CORE_C_SRC)
45+
46+
#Setting include directories
47+
embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
48+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
49+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
50+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
51+
52+
set(BUILD_CMSIS_CORE Off)
53+
set(BUILD_RETARGET Off)
54+
set(BUILD_NATIVE_DRIVERS Off)
55+
set(BUILD_STARTUP Off)
56+
set(BUILD_TARGET_CFG Off)
57+
set(BUILD_TARGET_HARDWARE_KEYS Off)
58+
set(BUILD_TARGET_NV_COUNTERS Off)
59+
set(BUILD_CMSIS_DRIVERS Off)
60+
set(BUILD_TIME Off)
61+
set(BUILD_UART_STDOUT Off)
62+
set(BUILD_FLASH Off)
63+
set(BUILD_BOOT_SEED Off)
64+
set(BUILD_DEVICE_ID Off)
65+
if(NOT DEFINED PLATFORM_CMAKE_FILE)
66+
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
67+
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
68+
message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
69+
else()
70+
include(${PLATFORM_CMAKE_FILE})
71+
endif()
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#-------------------------------------------------------------------------------
2+
# Copyright (c) 2018, Arm Limited. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
#
6+
#-------------------------------------------------------------------------------
7+
8+
#Definitions to compile the "ipc" module.
9+
#This file assumes it will be included from a project specific cmakefile, and
10+
#will not create a library or executable.
11+
#Inputs:
12+
# TFM_ROOT_DIR - directory where secure FW sourec is located.
13+
#
14+
#Outputs:
15+
# Will modify include directories to make the source compile.
16+
# ALL_SRC_C: C source files to be compiled will be added to this list.
17+
# This shall be added to your add_executable or add_library command.
18+
# ALL_SRC_CXX: C++ source files to be compiled will be added to this list.
19+
# This shall be added to your add_executable or add_library command.
20+
# ALL_SRC_ASM: assembly source files to be compiled will be added to this
21+
# list. This shall be added to your add_executable or add_library
22+
# command.
23+
# Include directories will be modified by using the include_directories()
24+
# commands as needed.
25+
26+
#Get the current directory where this file is located.
27+
set(SS_IPC_DIR ${CMAKE_CURRENT_LIST_DIR})
28+
if(NOT DEFINED TFM_ROOT_DIR)
29+
message(FATAL_ERROR
30+
"Please set TFM_ROOT_DIR before including this file.")
31+
endif()
32+
33+
if (NOT DEFINED TFM_PSA_API)
34+
message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined. ")
35+
elseif (TFM_PSA_API)
36+
set (SS_IPC_C_SRC "${SS_IPC_DIR}/tfm_svcalls.c"
37+
"${SS_IPC_DIR}/psa_service.c"
38+
"${SS_IPC_DIR}/psa_client.c"
39+
"${SS_IPC_DIR}/tfm_arch_v8m.c"
40+
"${SS_IPC_DIR}/tfm_thread.c"
41+
"${SS_IPC_DIR}/tfm_wait.c"
42+
"${SS_IPC_DIR}/tfm_utils.c"
43+
"${SS_IPC_DIR}/tfm_message_queue.c"
44+
"${SS_IPC_DIR}/tfm_pools.c"
45+
"${SS_IPC_DIR}/tfm_spm.c"
46+
"${SS_IPC_DIR}/../tfm_core.c"
47+
"${SS_IPC_DIR}/../tfm_secure_api.c"
48+
"${SS_IPC_DIR}/../tfm_spm_services.c"
49+
"${SS_IPC_DIR}/../tfm_handler.c"
50+
"${SS_IPC_DIR}/../tfm_psa_api_client.c"
51+
"${SS_IPC_DIR}/../tfm_nspm.c"
52+
"${SS_IPC_DIR}/../tfm_boot_data.c"
53+
)
54+
endif()
55+
56+
#Append all our source files to global lists.
57+
list(APPEND ALL_SRC_C ${SS_IPC_C_SRC})
58+
unset(SS_IPC_C_SRC)
59+
60+
#Setting include directories
61+
embedded_include_directories(PATH ${TFM_ROOT_DIR} ABSOLUTE)
62+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE)
63+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE)
64+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core ABSOLUTE)
65+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core/ipc ABSOLUTE)
66+
embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/core/ipc/include ABSOLUTE)
67+
68+
if(NOT DEFINED PLATFORM_CMAKE_FILE)
69+
message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
70+
elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
71+
message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
72+
else()
73+
include(${PLATFORM_CMAKE_FILE})
74+
endif()

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/include/tfm_message_queue.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#ifndef __TFM_MESSAGE_QUEUE_H__
88
#define __TFM_MESSAGE_QUEUE_H__
99

10-
#ifndef TFM_MSG_QUEUE_MAX_MSG_NUM
1110
#define TFM_MSG_QUEUE_MAX_MSG_NUM 128
12-
#endif
1311
#define TFM_MSG_MAGIC 0x15154343
1412
/* Message struct to collect parameter from client */
1513
struct tfm_msg_body_t {

components/TARGET_PSA/TARGET_TFM/COMPONENT_SPE/secure_fw/core/ipc/include/tfm_spm.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99

1010
#include <stdbool.h>
1111
#include "tfm_list.h"
12+
#include "tfm_secure_api.h"
1213

13-
#ifndef TFM_SPM_MAX_ROT_SERV_NUM
1414
#define TFM_SPM_MAX_ROT_SERV_NUM 28
15-
#endif
1615
#define TFM_VERSION_POLICY_RELAXED 0
1716
#define TFM_VERSION_POLICY_STRICT 1
1817

19-
#ifndef TFM_CONN_HANDLE_MAX_NUM
2018
#define TFM_CONN_HANDLE_MAX_NUM 32
21-
#endif
2219

2320
/* RoT connection handle list */
2421
struct tfm_conn_handle_t {
@@ -283,12 +280,15 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
283280
* \param[in] buffer Pointer of memory reference
284281
* \param[in] len Length of memory reference in bytes
285282
* \param[in] ns_caller From non-secure caller
283+
* \param[in] access Type of access specified by the
284+
* \ref tfm_memory_access_e
286285
*
287286
* \retval IPC_SUCCESS Success
288287
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
289288
* \retval IPC_ERROR_MEMORY_CHECK Check failed
290289
*/
291-
int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller);
290+
int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller,
291+
enum tfm_memory_access_e access);
292292

293293
/* This function should be called before schedule function */
294294
void tfm_spm_init(void);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
#ifndef __TFM_SPM_SIGNAL_DEFS_H__
8+
#define __TFM_SPM_SIGNAL_DEFS_H__
9+
10+
#include "test/test_services/tfm_ipc_service/tfm_ipc_service_partition.h"
11+
#include "test/test_services/tfm_core_test/tfm_ss_core_test_signal.h"
12+
#include "test/test_services/tfm_core_test_2/tfm_ss_core_test_2_signal.h"
13+
#include "secure_fw/services/secure_storage/tfm_sst_signal.h"
14+
15+
#endif

0 commit comments

Comments
 (0)