Skip to content

Commit eae1252

Browse files
author
Nir Sonnenschein
committed
changes to test infrastructure to adapt it to green-tea
changes to test infrastructure to adapt it to green-tea Make ITS testing default Fix IAR build issues
1 parent 22e429b commit eae1252

25 files changed

+2137
-31
lines changed

features/frameworks/TARGET_PSA/pal/pal_attestation_intf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef _PAL_INITIAL_ATTESTATION_H_
1919
#define _PAL_INITIAL_ATTESTATION_H_
2020

21+
#include "psa_initial_attestation_api.h"
2122
#include "pal_attestation_eat.h"
2223

2324
enum attestation_function_code {
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/** @file
2+
* Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifndef COMPONENT_PSA_SRV_IPC
19+
20+
#include "pal_common.h"
21+
#include "pal_client_api_intf.h"
22+
23+
24+
/**
25+
* @brief - Retrieve the version of the PSA Framework API that is implemented.
26+
* This is a wrapper API for psa_framework_version API.
27+
* @param - void
28+
* @return - The PSA Framework API version.
29+
*/
30+
31+
uint32_t pal_ipc_framework_version(void)
32+
{
33+
return 0;
34+
}
35+
36+
/**
37+
* @brief - Retrieve the minor version of a Root of Trust Service by its SID.
38+
* This is a wrapper API for the psa_version API.
39+
* @param - sid The Root of Trust Service ID
40+
* @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust
41+
* Service not present on the system.
42+
*/
43+
44+
uint32_t pal_ipc_version(uint32_t sid)
45+
{
46+
return PSA_VERSION_NONE;
47+
}
48+
49+
/**
50+
* @brief - Connect to given sid.
51+
* This is a wrapper API for the psa_connect API.
52+
* @param - sid : RoT service id
53+
* @param - minor_version : minor_version of RoT service
54+
* @return - psa_handle_t : return connection handle
55+
*/
56+
57+
psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version)
58+
{
59+
return PSA_NULL_HANDLE;
60+
}
61+
62+
/**
63+
* @brief Call a connected Root of Trust Service.
64+
* This is a wrapper API for the psa_call API.
65+
* The caller must provide an array of ::psa_invec_t structures as the input payload.
66+
*
67+
* @param -handle Handle for the connection.
68+
* @param -in_vec Array of psa_invec structures.
69+
* @param -in_len Number of psa_invec structures in in_vec.
70+
* @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response.
71+
* @param -out_len Number of psa_outvec structures in out_vec.
72+
* @return -psa_status_t
73+
*/
74+
75+
psa_status_t pal_ipc_call(psa_handle_t handle,
76+
const psa_invec *in_vec,
77+
size_t in_len,
78+
psa_outvec *out_vec,
79+
size_t out_len)
80+
{
81+
return (PSA_SUCCESS - 1);
82+
}
83+
84+
/**
85+
* @brief Close a connection to a Root of Trust Service.
86+
* This is a wrapper API for the psa_close API.
87+
* Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources.
88+
*
89+
* @param handle Handle for the connection.
90+
* @return void
91+
*/
92+
93+
void pal_ipc_close(psa_handle_t handle)
94+
{
95+
return;
96+
}
97+
98+
#endif
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/** @file
2+
* Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifdef COMPONENT_PSA_SRV_IPC
19+
20+
#include "pal_common.h"
21+
#include "pal_client_api_intf.h"
22+
23+
/**
24+
* @brief - Retrieve the version of the PSA Framework API that is implemented.
25+
* This is a wrapper API for psa_framework_version API.
26+
* @param - void
27+
* @return - The PSA Framework API version.
28+
* Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented.
29+
*/
30+
31+
uint32_t pal_ipc_framework_version(void)
32+
{
33+
return (psa_framework_version());
34+
}
35+
36+
/**
37+
* @brief - Retrieve the minor version of a Root of Trust Service by its SID.
38+
* This is a wrapper API for the psa_version API.
39+
* @param - sid The Root of Trust Service ID
40+
* @return - Minor version of Root of Trust Service or PSA_VERSION_NONE if Root of Trust
41+
* Service not present on the system.
42+
* Note - Return PAL_STATUS_ERROR if PSA IPC is not implemented.
43+
*/
44+
45+
uint32_t pal_ipc_version(uint32_t sid)
46+
{
47+
return (psa_version(sid));
48+
}
49+
50+
/**
51+
* @brief - Connect to given sid.
52+
* This is a wrapper API for the psa_connect API.
53+
* @param - sid : RoT service id
54+
* @param - minor_version : minor_version of RoT service
55+
* @return - psa_handle_t : return connection handle
56+
* Note - Return PSA_NULL_HANDLE if PSA IPC is not implemented.
57+
*/
58+
59+
psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version)
60+
{
61+
return (psa_connect(sid, minor_version));
62+
}
63+
64+
/**
65+
* @brief Call a connected Root of Trust Service.
66+
* This is a wrapper API for the psa_call API.
67+
* The caller must provide an array of ::psa_invec_t structures as the input payload.
68+
*
69+
* @param -handle Handle for the connection.
70+
* @param -in_vec Array of psa_invec structures.
71+
* @param -in_len Number of psa_invec structures in in_vec.
72+
* @param -out_vec Array of psa_outvec structures for optional Root of Trust Service response.
73+
* @param -out_len Number of psa_outvec structures in out_vec.
74+
* @return -psa_status_t
75+
* Note - Return -1 if PSA IPC is not implemented.
76+
*/
77+
78+
psa_status_t pal_ipc_call(psa_handle_t handle,
79+
const psa_invec *in_vec,
80+
size_t in_len,
81+
psa_outvec *out_vec,
82+
size_t out_len)
83+
{
84+
return (psa_call(handle, in_vec, in_len, out_vec, out_len));
85+
}
86+
87+
/**
88+
* @brief Close a connection to a Root of Trust Service.
89+
* This is a wrapper API for the psa_close API.
90+
* Sends the PSA_IPC_DISCONNECT message to the Root of Trust Service so it can clean up resources.
91+
*
92+
* @param - handle Handle for the connection.
93+
* @return - void
94+
*/
95+
96+
void pal_ipc_close(psa_handle_t handle)
97+
{
98+
psa_close(handle);
99+
}
100+
101+
#endif
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/** @file
2+
* Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifndef _PAL_CLIENT_API_H_
19+
#define _PAL_CLIENT_API_H_
20+
21+
#if PSA_IPC_IMPLEMENTED
22+
/* psa/client.h: Contains the Client API elements. Accessible to all applications */
23+
#include "psa/client.h"
24+
25+
/* psa_manifest/sid.h: Macro definitions derived from manifest files that map from RoT Service
26+
* names to Service IDs (SIDs).
27+
* Partition manifest parse build tool must provide the implementation of this file.
28+
*/
29+
#include "psa_manifest/sid.h"
30+
31+
#else
32+
#include "pal_common.h"
33+
34+
#define PSA_VERSION_NONE (0)
35+
#define PSA_SUCCESS (0)
36+
#define PSA_CONNECTION_REFUSED (INT32_MIN + 1)
37+
#define PSA_CONNECTION_BUSY (INT32_MIN + 2)
38+
#define PSA_DROP_CONNECTION (INT32_MIN)
39+
#define PSA_NULL_HANDLE ((psa_handle_t)0)
40+
41+
typedef int32_t psa_status_t;
42+
typedef int32_t psa_handle_t;
43+
44+
typedef struct psa_invec {
45+
const void *base;
46+
size_t len;
47+
} psa_invec;
48+
49+
typedef struct psa_outvec {
50+
void *base;
51+
size_t len;
52+
} psa_outvec;
53+
54+
uint32_t psa_framework_version(void);
55+
uint32_t psa_version(uint32_t sid);
56+
psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version);
57+
psa_status_t psa_call(psa_handle_t handle,
58+
const psa_invec *in_vec,
59+
size_t in_len,
60+
psa_outvec *out_vec,
61+
size_t out_len);
62+
void psa_close(psa_handle_t handle);
63+
#endif /* PSA_IPC_IMPLEMENTED */
64+
65+
uint32_t pal_ipc_framework_version(void);
66+
uint32_t pal_ipc_version(uint32_t sid);
67+
psa_handle_t pal_ipc_connect(uint32_t sid, uint32_t minor_version);
68+
psa_status_t pal_ipc_call(psa_handle_t handle,
69+
const psa_invec *in_vec,
70+
size_t in_len,
71+
psa_outvec *out_vec,
72+
size_t out_len);
73+
void pal_ipc_close(psa_handle_t handle);
74+
#endif /* _PAL_CLIENT_API_H_ */
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/** @file
2+
* Copyright (c) 2018, Arm Limited or its affiliates. All rights reserved.
3+
* SPDX-License-Identifier : Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
**/
17+
18+
#ifndef _PAL_COMMON_H_
19+
#define _PAL_COMMON_H_
20+
21+
#include <string.h>
22+
#include <stdint.h>
23+
#include <stdlib.h>
24+
#include <limits.h>
25+
#include <stdarg.h>
26+
27+
#ifndef PSA_PROTECTED_STORAGE_IMPLEMENTED
28+
#define PSA_INTERNAL_TRUSTED_STORAGE_IMPLEMENTED 1 /* Use ITS by default */
29+
#define ITS_TEST 1
30+
#endif
31+
32+
#include "pal_crypto_config.h"
33+
#include "internal_trusted_storage.h"
34+
35+
/* typedef's */
36+
typedef uint8_t bool_t;
37+
typedef uint32_t addr_t;
38+
typedef uint32_t test_id_t;
39+
typedef uint32_t block_id_t;
40+
typedef char char8_t;
41+
typedef uint32_t cfg_id_t;
42+
43+
#define PAL_STATUS_UNSUPPORTED_FUNC 0xFF
44+
45+
typedef enum
46+
{
47+
PAL_STATUS_SUCCESS = 0x0,
48+
PAL_STATUS_ERROR = 0x80
49+
} pal_status_t;
50+
51+
typedef enum {
52+
NVMEM_READ = 0x1,
53+
NVMEM_WRITE = 0x2,
54+
} nvmem_fn_type_t;
55+
56+
typedef struct {
57+
nvmem_fn_type_t nvmem_fn_type;
58+
addr_t base;
59+
uint32_t offset;
60+
int size;
61+
} nvmem_param_t;
62+
63+
typedef enum {
64+
WD_INIT_SEQ = 0x1,
65+
WD_ENABLE_SEQ = 0x2,
66+
WD_DISABLE_SEQ = 0x3,
67+
WD_STATUS_SEQ = 0x4,
68+
} wd_fn_type_t;
69+
70+
typedef enum {
71+
WD_LOW_TIMEOUT = 0x1,
72+
WD_MEDIUM_TIMEOUT = 0x2,
73+
WD_HIGH_TIMEOUT = 0x3,
74+
WD_CRYPTO_TIMEOUT = 0x4,
75+
} wd_timeout_type_t;
76+
77+
typedef struct {
78+
wd_fn_type_t wd_fn_type;
79+
addr_t wd_base_addr;
80+
uint32_t wd_time_us;
81+
uint32_t wd_timer_tick_us;
82+
} wd_param_t;
83+
84+
typedef enum {
85+
UART_INIT = 0x1,
86+
UART_PRINT = 0x2,
87+
} uart_fn_type_t;
88+
89+
/*
90+
* Redefining some of the client.h elements for compilation to go through
91+
* when PSA IPC APIs are not implemented.
92+
*/
93+
#if (PSA_IPC_IMPLEMENTED == 0)
94+
95+
#ifndef PSA_VERSION_NONE
96+
#define PSA_VERSION_NONE (0)
97+
#endif
98+
99+
#ifndef PSA_SUCCESS
100+
#define PSA_SUCCESS (0)
101+
typedef int32_t psa_status_t;
102+
#endif
103+
typedef int32_t psa_handle_t;
104+
105+
#ifndef PSA_NULL_HANDLE
106+
#define PSA_NULL_HANDLE ((psa_handle_t)0)
107+
#endif
108+
109+
110+
#endif /* PSA_IPC_IMPLEMENTED */
111+
112+
#endif /* _PAL_COMMON_H_ */

0 commit comments

Comments
 (0)