Skip to content

Commit 4788dea

Browse files
authored
Merge pull request #50 from Patater/feature_cmsis5
Update for feature_cmsis5
2 parents ce20c5e + 5493f55 commit 4788dea

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

source/fun_bag.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ static int prn_verify(const void * mem, uint16_t seed, size_t len)
5858
{
5959
size_t i;
6060
uint16_t state = seed;
61-
uint8_t * m = (uint8_t *) mem;
61+
const uint8_t * m = (const uint8_t *) mem;
6262
bool matches = true;
6363

6464
/* Check all of the bytes, even if we find a match sooner. This tests that
6565
* we can read all of the memory (and that it hasn't been securely taken
66-
* over by another box. */
66+
* over by another box). */
6767
for (i = 0; i < len; ++i) {
6868
if (m[i] != (state & 0xFF)) {
6969
matches = false;

source/led1.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led1_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led1, acl, 512, box_context);
2424

25-
/* FIXME: The guard is needed for backwards-compatibility reasons. Remove it
26-
* when mbed OS is updated. */
27-
#ifdef __uvisor_ctx
2825
#define uvisor_ctx ((box_context *) __uvisor_ctx)
29-
#endif
3026

3127
static void led1_main(const void *)
3228
{

source/led2.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
2323
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);
2424

25-
/* FIXME: The guard is needed for backwards-compatibility reasons. Remove it
26-
* when mbed OS is updated. */
27-
#ifdef __uvisor_ctx
2825
#define uvisor_ctx ((box_context *) __uvisor_ctx)
29-
#endif
3026

3127
static void led2_main(const void *)
3228
{

source/led3.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
2222
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
2323
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);
2424

25-
/* FIXME: The guard is needed for backwards-compatibility reasons. Remove it
26-
* when mbed OS is updated. */
27-
#ifdef __uvisor_ctx
2825
#define uvisor_ctx ((box_context *) __uvisor_ctx)
29-
#endif
3026

3127
static void run_3(void)
3228
{
@@ -40,6 +36,16 @@ static void run_3(void)
4036
}
4137
}
4238

39+
#if (osCMSIS >= 0x20000U)
40+
/* A thin wrapper around run_3 that accepts and ignores a context. This avoid a
41+
* cast, as mbed's Thread and RTX's osThreadContextNew operate on differently
42+
* typed thread functions. */
43+
static void run_3_context(void *)
44+
{
45+
run_3();
46+
}
47+
#endif
48+
4349
static void led3_main(const void *)
4450
{
4551
osStatus status;
@@ -64,6 +70,22 @@ static void led3_main(const void *)
6470
const uint32_t kB = 1024;
6571
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
6672
/* Prepare the thread definition structure. */
73+
/* FIXME: Remove the dependency on the CMSIS OS version after mbed OS has
74+
* completed its migration to CMSIS 5 RTX 2. We only need to keep both
75+
* around so that the example will work both before and after the
76+
* migration. */
77+
#if (osCMSIS >= 0x20000U)
78+
osThreadAttr_t thread_attr = {0};
79+
os_thread_t thread_def = {0};
80+
thread_def.stack_size = 512;
81+
/* Allocate the stack inside the page allocator! */
82+
thread_attr.stack_mem = (uint32_t *) secure_malloc(alloc, 512);
83+
thread_def.priority = osPriorityNormal;
84+
thread_attr.cb_size = sizeof(thread_def);
85+
thread_attr.cb_mem = &thread_def;
86+
/* Create a thread with the page allocator as heap. */
87+
osThreadContextNew(run_3_context, NULL, &thread_attr, alloc);
88+
#else
6789
osThreadDef_t thread_def;
6890
thread_def.stacksize = 512;
6991
/* Allocate the stack inside the page allocator! */
@@ -72,6 +94,7 @@ static void led3_main(const void *)
7294
thread_def.pthread = (void (*)(const void *)) &run_3;
7395
/* Create a thread with the page allocator as heap. */
7496
osThreadContextCreate(&thread_def, NULL, alloc);
97+
#endif
7598

7699
while (1) {
77100
static const size_t size = 20;

source/main-hw.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@
4545
{SPI0, sizeof(*SPI0), UVISOR_TACLDEF_PERIPH}, \
4646
}
4747

48+
#elif defined (TARGET_EFM32GG_STK3700)
49+
50+
#define MAIN_LED LED1
51+
#define SECURE_LED LED2
52+
#define LED_ON true
53+
#define LED_OFF false
54+
#define SECURE_SWITCH SW2
55+
#define SECURE_SWITCH_PULL PullUp
56+
57+
#define MAIN_ACL(acl_list_name) \
58+
static const UvisorBoxAclItem acl_list_name[] = { \
59+
{CMU, sizeof(*CMU), UVISOR_TACLDEF_PERIPH}, \
60+
{MSC, sizeof(*MSC), UVISOR_TACLDEF_PERIPH}, \
61+
{GPIO, sizeof(*GPIO), UVISOR_TACLDEF_PERIPH}, \
62+
{TIMER0, sizeof(*TIMER0), UVISOR_TACLDEF_PERIPH}, \
63+
{UART0, sizeof(*UART0), UVISOR_TACLDEF_PERIPH}, \
64+
{(void *) 0x0FE08000, 0x1000, UVISOR_TACLDEF_PERIPH}, \
65+
{(void *) 0x42000000, 0x2000000, UVISOR_TACLDEF_PERIPH}, \
66+
}
67+
4868
#else /* Target-specific settings */
4969

5070
#error "Unsupported target. Checkout the README.md file for the list of supported targets for this app."

test/filters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"blacklist" : [ {
3-
"platforms" : ["EFM32GG_STK3700", "DISCO_F429ZI"]
3+
"platforms" : ["DISCO_F429ZI"]
44
}
55
]
66
}

0 commit comments

Comments
 (0)