Skip to content

Commit 331c0d5

Browse files
Alexander ZilberkantMichael Schwarcz
authored andcommitted
astyle changes
1 parent 4f3c050 commit 331c0d5

File tree

54 files changed

+484
-527
lines changed

Some content is hidden

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

54 files changed

+484
-527
lines changed

TESTS/mbed_hal/spm/main.cpp

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -36,60 +36,60 @@ extern "C" {
3636
#define EXC_RETURN_RETURN_STACK_MSK ((uint32_t)(0x00000004))
3737
#define PC_INDEX_IN_STACK_FRAME 6
3838

39-
volatile uint32_t fault_occurred;
40-
uint32_t real_hard_fault_handler;
39+
volatile uint32_t fault_occurred;
40+
uint32_t real_hard_fault_handler;
4141

42-
__attribute__ ((always_inline)) __STATIC_INLINE uint32_t __get_LR(void)
43-
{
44-
register uint32_t result;
42+
__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_LR(void)
43+
{
44+
register uint32_t result;
4545

46-
__ASM volatile ("MOV %0, LR\n" : "=r" (result));
47-
return result;
48-
}
46+
__ASM volatile("MOV %0, LR\n" : "=r"(result));
47+
return result;
48+
}
4949

5050
// This function is required as we need a symbol/address
5151
// to jump to from fault handler.
52-
void do_nothing(void)
53-
{
54-
__NOP();
55-
}
52+
void do_nothing(void)
53+
{
54+
__NOP();
55+
}
5656

5757
// Test exception handler
58-
static void hard_fault_handler_test()
59-
{
60-
fault_occurred++;
61-
// LR is set EXC_RETURN
62-
// lowest bits identify PSP vs MSP stack used for stacking
63-
uint32_t lr = __get_LR();
64-
uint32_t sp;
65-
66-
if (lr & EXC_RETURN_RETURN_STACK_MSK) {
67-
sp = __get_PSP();
68-
} else {
69-
sp = __get_MSP();
58+
static void hard_fault_handler_test()
59+
{
60+
fault_occurred++;
61+
// LR is set EXC_RETURN
62+
// lowest bits identify PSP vs MSP stack used for stacking
63+
uint32_t lr = __get_LR();
64+
uint32_t sp;
65+
66+
if (lr & EXC_RETURN_RETURN_STACK_MSK) {
67+
sp = __get_PSP();
68+
} else {
69+
sp = __get_MSP();
70+
}
71+
72+
// Overwrite return address.
73+
// Fake return to a our special function since current
74+
// instruction under test will always fail due to memory protection
75+
((uint32_t *)sp)[PC_INDEX_IN_STACK_FRAME] = (uint32_t)do_nothing;
7076
}
7177

72-
// Overwrite return address.
73-
// Fake return to a our special function since current
74-
// instruction under test will always fail due to memory protection
75-
((uint32_t *)sp)[PC_INDEX_IN_STACK_FRAME] = (uint32_t)do_nothing;
76-
}
77-
7878
// Using naked function as it will not be executed from beginning to the end.
7979
// The execution flow expected to be interrupted by exception and we will
8080
// return to other function.
8181
// compiler will not produce prolog and epilog code for naked function
8282
// and thus will preserve stack in un-corrupted state
83-
__attribute__((naked)) void call_mem(uint32_t addr)
84-
{
85-
// Only first instruction will be executed in positive flow,
86-
// since exception will be generated for invalid memory access.
87-
// Other instructions are for calling do_nothing function according to AAPCS.
88-
__ASM(
89-
"LDR r1, [r0]\n"
90-
"BX lr\n"
91-
);
92-
}
83+
__attribute__((naked)) void call_mem(uint32_t addr)
84+
{
85+
// Only first instruction will be executed in positive flow,
86+
// since exception will be generated for invalid memory access.
87+
// Other instructions are for calling do_nothing function according to AAPCS.
88+
__ASM(
89+
"LDR r1, [r0]\n"
90+
"BX lr\n"
91+
);
92+
}
9393
}
9494

9595
static void test_memory(uint32_t addr, uint32_t expected_fatal_count)
@@ -132,7 +132,7 @@ utest::v1::status_t fault_override_setup(const Case *const source, const size_t
132132
}
133133

134134
utest::v1::status_t fault_override_teardown(const Case *const source, const size_t passed, const size_t failed,
135-
const failure_t reason)
135+
const failure_t reason)
136136
{
137137
// Restore real hard fault handler
138138
NVIC_SetVector(HARDFAULT_IRQn, real_hard_fault_handler);

TESTS/psa/prot_internal_storage/COMPONENT_SPE/psa_setup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include "cmsis.h"
2626
#include "psa_test_its_reset_partition.h"
2727
#include "psa_its_partition.h"
28-
29-
28+
29+
3030
spm_partition_t g_partitions[2] = {
3131
{
3232
.partition_id = TEST_ITS_RESET_ID,
@@ -62,7 +62,7 @@ const uint32_t mem_region_count = 0;
6262
// forward declaration of partition initializers
6363
void test_its_reset_init(spm_partition_t *partition);
6464
void its_init(spm_partition_t *partition);
65-
65+
6666
uint32_t init_partitions(spm_partition_t **partitions)
6767
{
6868
if (NULL == partitions) {
@@ -71,7 +71,7 @@ uint32_t init_partitions(spm_partition_t **partitions)
7171

7272
test_its_reset_init(&(g_partitions[0]));
7373
its_init(&(g_partitions[1]));
74-
74+
7575
*partitions = g_partitions;
7676
return 2;
7777
}

TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/psa_test_its_reset_partition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ osThreadAttr_t test_its_reset_thread_attr = {
4545
.priority = osPriorityNormal,
4646
.tz_module = 0,
4747
.reserved = 0
48-
};
48+
};
4949

5050
spm_rot_service_t test_its_reset_rot_services[TEST_ITS_RESET_ROT_SRV_COUNT] = {
5151
{

TESTS/psa/prot_internal_storage/its_reset/COMPONENT_SPE/test_pits_reset_partition.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ void test_pits_entry(void *ptr)
2525
psa_get(TEST_PSA_ITS_RESET_MSK, &msg);
2626
switch (msg.type) {
2727
case PSA_IPC_CONNECT: //fallthrough
28-
case PSA_IPC_DISCONNECT:
29-
{
28+
case PSA_IPC_DISCONNECT: {
3029
break;
3130
}
32-
case PSA_IPC_CALL:
33-
{
31+
case PSA_IPC_CALL: {
3432
status = test_psa_its_reset_impl();
3533
break;
3634
}
37-
default:
38-
{
35+
default: {
3936
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
4037
break;
4138
}

TESTS/psa/spm_client/COMPONENT_NSPE/client_ipc_tests.cpp

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,29 @@ static psa_handle_t client_ipc_tests_connect(uint32_t sid, uint32_t minor_versio
5252
}
5353

5454
static void client_ipc_tests_call(
55-
psa_handle_t handle,
56-
psa_invec_t *iovec_temp,
57-
size_t tx_len,
58-
size_t rx_len,
59-
uint8_t *expected,
60-
uint8_t expected_size
61-
)
55+
psa_handle_t handle,
56+
psa_invec_t *iovec_temp,
57+
size_t tx_len,
58+
size_t rx_len,
59+
uint8_t *expected,
60+
uint8_t expected_size
61+
)
6262
{
6363
error_t status = PSA_SUCCESS;
64-
uint8_t *response_buf = (uint8_t*)malloc(CLIENT_RSP_BUF_SIZE * sizeof(uint8_t));
64+
uint8_t *response_buf = (uint8_t *)malloc(CLIENT_RSP_BUF_SIZE * sizeof(uint8_t));
6565
memset(response_buf, 0, CLIENT_RSP_BUF_SIZE);
6666
psa_outvec_t resp = {NULL, rx_len};
6767

6868
if (rx_len > 0) {
6969
resp.base = response_buf;
7070
}
7171

72-
status = psa_call( handle,
73-
(tx_len ? iovec_temp : NULL),
74-
tx_len,
75-
(rx_len ? &resp : NULL),
76-
(rx_len ? 1 : 0)
77-
);
72+
status = psa_call(handle,
73+
(tx_len ? iovec_temp : NULL),
74+
tx_len,
75+
(rx_len ? &resp : NULL),
76+
(rx_len ? 1 : 0)
77+
);
7878

7979
if (expected) {
8080
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, response_buf, expected_size);
@@ -103,9 +103,11 @@ void iovec_0_NULL()
103103
uint8_t buff1[] = {1, 2, 3, 4, 5};
104104
uint8_t expected_buff[] = {1, 2, 3, 4, 5};
105105

106-
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{NULL, 0},
107-
{meta_iovec, sizeof(meta_iovec)},
108-
{buff1, sizeof(buff1)}};
106+
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {
107+
{NULL, 0},
108+
{meta_iovec, sizeof(meta_iovec)},
109+
{buff1, sizeof(buff1)}
110+
};
109111

110112
client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, CLIENT_RSP_BUF_SIZE, expected_buff, sizeof(expected_buff));
111113

@@ -125,8 +127,9 @@ void iovec_1_NULL()
125127
uint8_t expected_buff[] = {2, 3};
126128

127129
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)},
128-
{NULL, 0},
129-
{buff1, sizeof(buff1)}};
130+
{NULL, 0},
131+
{buff1, sizeof(buff1)}
132+
};
130133

131134
client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, CLIENT_RSP_BUF_SIZE, expected_buff, sizeof(expected_buff));
132135

@@ -146,8 +149,9 @@ void iovec_2_NULL()
146149
uint8_t expected_buff[] = {2, 3};
147150

148151
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)},
149-
{buff1, sizeof(buff1)},
150-
{NULL, 0}};
152+
{buff1, sizeof(buff1)},
153+
{NULL, 0}
154+
};
151155

152156
client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, CLIENT_RSP_BUF_SIZE, expected_buff, sizeof(expected_buff));
153157

@@ -193,8 +197,8 @@ void out_len_0_outvec_not_NULL()
193197
psa_handle_t handle = client_ipc_tests_connect(PART1_ROT_SRV1, MINOR_VER);
194198

195199
psa_invec_t in_vec_temp[2] = { {dummy_buff, sizeof(dummy_buff)},
196-
{dummy_buff, sizeof(dummy_buff)}
197-
};
200+
{dummy_buff, sizeof(dummy_buff)}
201+
};
198202

199203
status = psa_call(handle, in_vec_temp, 2, outvec_temp, 0);
200204

@@ -214,8 +218,9 @@ void rx_buff_null()
214218
uint8_t buff1[] = {1, 2, 3, 4, 5}, buff2[] = {6};
215219

216220
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)},
217-
{buff1, sizeof(buff1)},
218-
{buff2, sizeof(buff2)}};
221+
{buff1, sizeof(buff1)},
222+
{buff2, sizeof(buff2)}
223+
};
219224

220225
client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, 0, NULL, 0);
221226

@@ -255,8 +260,9 @@ void multiple_call()
255260
uint8_t expected_buff[] = {1, 2};
256261

257262
psa_invec_t iovec_temp[PSA_MAX_IOVEC - 1] = {{meta_iovec, sizeof(meta_iovec)},
258-
{buff1, sizeof(buff1)},
259-
{buff2, sizeof(buff2)}};
263+
{buff1, sizeof(buff1)},
264+
{buff2, sizeof(buff2)}
265+
};
260266

261267
client_ipc_tests_call(handle, iovec_temp, PSA_MAX_IOVEC - 1, CLIENT_RSP_BUF_SIZE, expected_buff, sizeof(expected_buff));
262268

@@ -315,13 +321,14 @@ void multi_thread_diff_handles()
315321
uint8_t expected_buff_1[] = {1, 2};
316322

317323
psa_invec_t iovec_temp_1[PSA_MAX_IOVEC - 1] = {{meta_iovec_1, sizeof(meta_iovec_1)},
318-
{buff1, sizeof(buff1)},
319-
{buff2, sizeof(buff2)}};
324+
{buff1, sizeof(buff1)},
325+
{buff2, sizeof(buff2)}
326+
};
320327

321328
set_struct(&thr_attr[0], 0, iovec_temp_1, expected_buff_1, sizeof(expected_buff_1));
322329
osStatus err = T1.start(callback(call_diff_handle, (th_struct_t *)&thr_attr[0]));
323330
if (err) {
324-
TEST_FAIL_MESSAGE("creating thread failed!");
331+
TEST_FAIL_MESSAGE("creating thread failed!");
325332
}
326333

327334
uint8_t meta_iovec_2[] = { 2, //expect_size
@@ -330,12 +337,13 @@ void multi_thread_diff_handles()
330337
uint8_t expected_buff_2[] = {2, 3};
331338

332339
psa_invec_t iovec_temp_2[PSA_MAX_IOVEC - 1] = {{meta_iovec_2, sizeof(meta_iovec_2)},
333-
{buff1, sizeof(buff1)},
334-
{buff2, sizeof(buff2)}};
340+
{buff1, sizeof(buff1)},
341+
{buff2, sizeof(buff2)}
342+
};
335343
set_struct(&thr_attr[1], 0, iovec_temp_2, expected_buff_2, sizeof(expected_buff_2));
336344
err = T2.start(callback(call_diff_handle, (th_struct_t *)&thr_attr[1]));
337345
if (err) {
338-
TEST_FAIL_MESSAGE("creating thread failed!");
346+
TEST_FAIL_MESSAGE("creating thread failed!");
339347
}
340348

341349
uint8_t meta_iovec_3[] = { 2, //expect_size
@@ -344,26 +352,27 @@ void multi_thread_diff_handles()
344352
uint8_t expected_buff_3[] = {3, 4};
345353

346354
psa_invec_t iovec_temp_3[PSA_MAX_IOVEC - 1] = {{meta_iovec_3, sizeof(meta_iovec_3)},
347-
{buff1, sizeof(buff1)},
348-
{buff2, sizeof(buff2)}};
355+
{buff1, sizeof(buff1)},
356+
{buff2, sizeof(buff2)}
357+
};
349358

350359
set_struct(&thr_attr[2], 0, iovec_temp_3, expected_buff_3, sizeof(expected_buff_3));
351360
err = T3.start(callback(call_diff_handle, (th_struct_t *)&thr_attr[2]));
352361
if (err) {
353-
TEST_FAIL_MESSAGE("creating thread failed!");
362+
TEST_FAIL_MESSAGE("creating thread failed!");
354363
}
355364

356365
err = T1.join();
357366
if (err) {
358-
TEST_FAIL_MESSAGE("joining thread failed!");
367+
TEST_FAIL_MESSAGE("joining thread failed!");
359368
}
360369
err = T2.join();
361370
if (err) {
362-
TEST_FAIL_MESSAGE("joining thread failed!");
371+
TEST_FAIL_MESSAGE("joining thread failed!");
363372
}
364373
err = T3.join();
365374
if (err) {
366-
TEST_FAIL_MESSAGE("joining thread failed!");
375+
TEST_FAIL_MESSAGE("joining thread failed!");
367376
}
368377

369378
}
@@ -378,8 +387,7 @@ void exceed_num_of_max_channels()
378387
for (i = 0; i < MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS + 1; i++) {
379388
if (i != MBED_CONF_SPM_IPC_MAX_NUM_OF_CHANNELS) {
380389
handle[i] = client_ipc_tests_connect(PART1_ROT_SRV1, MINOR_VER);
381-
}
382-
else {
390+
} else {
383391
handle[i] = psa_connect(PART1_ROT_SRV1, MINOR_VER);
384392
TEST_ASSERT_EQUAL_INT32(PSA_CONNECTION_REFUSED, handle[i]);
385393
}
@@ -433,7 +441,7 @@ void psa_version_secure_access_only()
433441
}
434442

435443

436-
// Test cases
444+
// Test cases
437445
Case cases[] = {
438446
Case("Testing client iovec_0_NULL", iovec_0_NULL),
439447
Case("Testing client iovec_1_NULL", iovec_1_NULL),

TESTS/psa/spm_client/COMPONENT_SPE/psa_client_tests_part1_partition.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ osThreadAttr_t client_tests_part1_thread_attr = {
4545
.priority = osPriorityNormal,
4646
.tz_module = 0,
4747
.reserved = 0
48-
};
48+
};
4949

5050
spm_rot_service_t client_tests_part1_rot_services[CLIENT_TESTS_PART1_ROT_SRV_COUNT] = {
5151
{

0 commit comments

Comments
 (0)