Skip to content

Commit 73ea7ca

Browse files
author
Michael Schwarcz
committed
[trusted-firmware-m]: Updated to 45e5276
1 parent f5af459 commit 73ea7ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+8502
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright (c) 2017-2018, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
#include <stdint.h>
8+
#include <stdbool.h>
9+
10+
#include "cmsis.h"
11+
#include "cmsis_os2.h"
12+
13+
#include "tfm_api.h"
14+
#include "tfm_ns_lock.h"
15+
16+
/**
17+
* \brief struct ns_lock_state type
18+
*/
19+
struct ns_lock_state
20+
{
21+
bool init;
22+
osMutexId_t id;
23+
};
24+
25+
/**
26+
* \brief ns_lock status
27+
*/
28+
static struct ns_lock_state ns_lock = {.init=false, .id=NULL};
29+
30+
/**
31+
* \brief Mutex properties, NS lock
32+
*/
33+
static const osMutexAttr_t ns_lock_attrib = {
34+
.name = "ns_lock",
35+
.attr_bits = osMutexPrioInherit
36+
};
37+
38+
/**
39+
* \brief NS world, NS lock based dispatcher
40+
*/
41+
uint32_t tfm_ns_lock_dispatch(veneer_fn fn,
42+
uint32_t arg0, uint32_t arg1,
43+
uint32_t arg2, uint32_t arg3)
44+
{
45+
uint32_t result;
46+
47+
/* Check the NS lock has been initialized */
48+
if (ns_lock.init == false) {
49+
return TFM_ERROR_GENERIC;
50+
}
51+
52+
/* TFM request protected by NS lock */
53+
osMutexAcquire(ns_lock.id,osWaitForever);
54+
55+
result = fn(arg0, arg1, arg2, arg3);
56+
57+
osMutexRelease(ns_lock.id);
58+
59+
return result;
60+
}
61+
62+
/**
63+
* \brief NS world, Init NS lock
64+
*/
65+
uint32_t tfm_ns_lock_init()
66+
{
67+
if (ns_lock.init == false) {
68+
ns_lock.id = osMutexNew(&ns_lock_attrib);
69+
ns_lock.init = true;
70+
return TFM_SUCCESS;
71+
}
72+
else {
73+
return TFM_ERROR_GENERIC;
74+
}
75+
}
76+
77+
bool tfm_ns_lock_get_init_state()
78+
{
79+
return ns_lock.init;
80+
}
81+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#include "interface/include/psa_client.h"
9+
#include "tfm_ns_lock.h"
10+
#include "tfm_api.h"
11+
12+
/**** API functions ****/
13+
14+
uint32_t psa_framework_version(void)
15+
{
16+
return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_framework_version_veneer,
17+
0,
18+
0,
19+
0,
20+
0);
21+
}
22+
23+
uint32_t psa_version(uint32_t sid)
24+
{
25+
return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_version_veneer,
26+
sid,
27+
0,
28+
0,
29+
0);
30+
}
31+
32+
psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version)
33+
{
34+
return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_connect_veneer,
35+
sid,
36+
minor_version,
37+
0,
38+
0);
39+
}
40+
41+
psa_status_t psa_call(psa_handle_t handle,
42+
const psa_invec *in_vec,
43+
size_t in_len,
44+
psa_outvec *out_vec,
45+
size_t out_len)
46+
{
47+
/* FixMe: sanity check can be added to offload some NS thread checks from
48+
* TFM secure API
49+
*/
50+
51+
/* Due to v8M restrictions, TF-M NS API needs to add another layer of
52+
* serialization in order for NS to pass arguments to S
53+
*/
54+
psa_invec in_vecs, out_vecs;
55+
56+
in_vecs.base = in_vec;
57+
in_vecs.len = in_len;
58+
out_vecs.base = out_vec;
59+
out_vecs.len = out_len;
60+
return tfm_ns_lock_dispatch((veneer_fn)tfm_psa_call_veneer,
61+
(uint32_t)handle,
62+
(uint32_t)&in_vecs,
63+
(uint32_t)&out_vecs,
64+
0);
65+
}
66+
67+
void psa_close(psa_handle_t handle)
68+
{
69+
tfm_ns_lock_dispatch((veneer_fn)tfm_psa_close_veneer,
70+
(uint32_t)handle,
71+
0,
72+
0,
73+
0);
74+
}
75+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2018, 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+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
/*!
20+
* \enum shared_data_err_t
21+
*
22+
* \brief Return values for adding data entry to shared memory area
23+
*/
24+
enum shared_memory_err_t {
25+
SHARED_MEMORY_OK = 0,
26+
SHARED_MEMORY_OVERFLOW = 1,
27+
SHARED_MEMORY_OVERWRITE = 2,
28+
29+
/* This is used to force the maximum size */
30+
TLV_TYPE_MAX = INT_MAX
31+
};
32+
33+
/*!
34+
* \brief Add a data item to the shared data area between bootloader and
35+
* runtime SW
36+
*
37+
* \param[in] major_type TLV major type, identify consumer
38+
* \param[in] minor_type TLV minor type, identify TLV type
39+
* \param[in] size length of added data
40+
* \param[in] data pointer to data
41+
*
42+
* \return Returns error code as specified in \ref shared_memory_err_t
43+
*/
44+
enum shared_memory_err_t
45+
boot_add_data_to_shared_area(uint8_t major_type,
46+
uint8_t minor_type,
47+
size_t size,
48+
const uint8_t *data);
49+
50+
#ifdef __cplusplus
51+
}
52+
#endif
53+
54+
#endif /* __BOOT_RECORD_H__ */
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*
6+
*/
7+
8+
#ifndef __TFM_BOOT_STATUS_H__
9+
#define __TFM_BOOT_STATUS_H__
10+
11+
#include <stdint.h>
12+
#include <stddef.h>
13+
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
/* Major numbers to identify the consumer of shared data in runtime SW */
20+
#define TLV_MAJOR_CORE 0x0
21+
#define TLV_MAJOR_IAS 0x1
22+
23+
/* PSA Root of Trust */
24+
#define TLV_MINOR_IAS_PRoT_SHA256 0x00
25+
#define TLV_MINOR_IAS_PRoT_SW_VERSION 0x01
26+
#define TLV_MINOR_IAS_PRoT_EPOCH 0x02
27+
28+
/* Application Root of Trust */
29+
#define TLV_MINOR_IAS_ARoT_SHA256 0x03
30+
#define TLV_MINOR_IAS_ARoT_SW_VERSION 0x04
31+
#define TLV_MINOR_IAS_ARoT_EPOCH 0x05
32+
33+
/* Non-secure processing environment: single non-secure image */
34+
#define TLV_MINOR_IAS_NSPE_SHA256 0x06
35+
#define TLV_MINOR_IAS_NSPE_SW_VERSION 0x07
36+
#define TLV_MINOR_IAS_NSPE_EPOCH 0x08
37+
38+
/* ARoT + PRoT: single secure image */
39+
#define TLV_MINOR_IAS_S_SHA256 0x09
40+
#define TLV_MINOR_IAS_S_SW_VERSION 0x0a
41+
#define TLV_MINOR_IAS_S_EPOCH 0x0b
42+
43+
/* S + NS: combined secure and non-secure image */
44+
#define TLV_MINOR_IAS_S_NS_SHA256 0x0c
45+
#define TLV_MINOR_IAS_S_NS_SW_VERSION 0x0d
46+
#define TLV_MINOR_IAS_S_NS_EPOCH 0x0e
47+
48+
#define SHARED_DATA_TLV_INFO_MAGIC 0x2016
49+
50+
/**
51+
* Shared data TLV header. All fields in little endian.
52+
*
53+
* ---------------------------
54+
* | tlv_magic | tlv_tot_len |
55+
* ---------------------------
56+
*/
57+
struct shared_data_tlv_header {
58+
uint16_t tlv_magic;
59+
uint16_t tlv_tot_len; /* size of whole TLV area (including this header) */
60+
};
61+
62+
#define SHARED_DATA_HEADER_SIZE sizeof(struct shared_data_tlv_header)
63+
64+
/**
65+
* Shared data TLV entry header format. All fields in little endian.
66+
*
67+
* ---------------------------------------------
68+
* | tlv_major_type | tlv_minor_type | tlv_len |
69+
* ---------------------------------------------
70+
* | Raw data |
71+
* ---------------------------------------------
72+
*/
73+
struct shared_data_tlv_entry {
74+
uint8_t tlv_major_type;
75+
uint8_t tlv_minor_type;
76+
uint16_t tlv_len; /* size of single TLV entry (including this header). */
77+
};
78+
79+
#define SHARED_DATA_ENTRY_HEADER_SIZE sizeof(struct shared_data_tlv_entry)
80+
#define SHARED_DATA_ENTRY_SIZE(size) (size + SHARED_DATA_ENTRY_HEADER_SIZE)
81+
82+
#ifdef __cplusplus
83+
}
84+
#endif
85+
86+
#endif /* __TFM_BOOT_STATUS_H__ */
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2013-2016 ARM Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* $Date: 2. Jan 2014
19+
* $Revision: V2.00
20+
*
21+
* Project: Common Driver definitions
22+
*/
23+
24+
/* History:
25+
* Version 2.00
26+
* Changed prefix ARM_DRV -> ARM_DRIVER
27+
* Added General return codes definitions
28+
* Version 1.10
29+
* Namespace prefix ARM_ added
30+
* Version 1.00
31+
* Initial release
32+
*/
33+
34+
#ifndef __DRIVER_COMMON_H
35+
#define __DRIVER_COMMON_H
36+
37+
#include <stddef.h>
38+
#include <stdint.h>
39+
#include <stdbool.h>
40+
41+
#define ARM_DRIVER_VERSION_MAJOR_MINOR(major,minor) (((major) << 8) | (minor))
42+
43+
/**
44+
\brief Driver Version
45+
*/
46+
typedef struct _ARM_DRIVER_VERSION {
47+
uint16_t api; ///< API version
48+
uint16_t drv; ///< Driver version
49+
} ARM_DRIVER_VERSION;
50+
51+
/* General return codes */
52+
#define ARM_DRIVER_OK 0 ///< Operation succeeded
53+
#define ARM_DRIVER_ERROR -1 ///< Unspecified error
54+
#define ARM_DRIVER_ERROR_BUSY -2 ///< Driver is busy
55+
#define ARM_DRIVER_ERROR_TIMEOUT -3 ///< Timeout occurred
56+
#define ARM_DRIVER_ERROR_UNSUPPORTED -4 ///< Operation not supported
57+
#define ARM_DRIVER_ERROR_PARAMETER -5 ///< Parameter error
58+
#define ARM_DRIVER_ERROR_SPECIFIC -6 ///< Start of driver specific errors
59+
60+
/**
61+
\brief General power states
62+
*/
63+
typedef enum _ARM_POWER_STATE {
64+
ARM_POWER_OFF, ///< Power off: no operation possible
65+
ARM_POWER_LOW, ///< Low Power mode: retain state, detect and signal wake-up events
66+
ARM_POWER_FULL ///< Power on: full operation at maximum performance
67+
} ARM_POWER_STATE;
68+
69+
#endif /* __DRIVER_COMMON_H */

0 commit comments

Comments
 (0)