Skip to content

Commit 0e8fa8a

Browse files
authored
Merge pull request #47 from Patater/feature_cmsis5
Update for feature_cmsis5
2 parents 860ac0c + 0aa2743 commit 0e8fa8a

File tree

9 files changed

+49
-31
lines changed

9 files changed

+49
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Supported devices:
88
|--------|-----------|-----------|
99
| `K64F` | `GCC_ARM` | 9600 |
1010

11-
Latest release: [mbed-os-5.3.x](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/latest). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).
11+
Latest release: [mbed-os-5.4.x](https://github.com/ARMmbed/mbed-os-example-uvisor/releases/latest). Tested with [mbed-cli v1.0.0](https://github.com/ARMmbed/mbed-cli/releases/tag/1.0.0).
1212

1313
## Quickstart
1414

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#42be5c01a7f91292d5e27124ad9584236025f6ab
1+
https://github.com/ARMmbed/mbed-os/#799983c5d17ed649cc8385f3fb11e486864b9eac

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: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct box_context {
1212
static const UvisorBoxAclItem acl[] = {
1313
};
1414

15-
static void led1_main(const void *);
15+
static void led1_main(void *);
1616

1717
/* Box configuration
1818
* We do not need large stacks in either the main nor the interrupt thread, as
@@ -22,13 +22,9 @@ 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

31-
static void led1_main(const void *)
27+
static void led1_main(void *)
3228
{
3329
DigitalOut led1(LED1);
3430
led1 = LED_OFF;

source/led2.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct box_context {
1212
static const UvisorBoxAclItem acl[] = {
1313
};
1414

15-
static void led2_main(const void *);
15+
static void led2_main(void *);
1616

1717
/* Box configuration
1818
* We do not need large stacks in either the main nor the interrupt thread, as
@@ -22,13 +22,9 @@ 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

31-
static void led2_main(const void *)
27+
static void led2_main(void *)
3228
{
3329
DigitalOut led2(LED2);
3430
led2 = LED_OFF;

source/led3.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct box_context {
1212
static const UvisorBoxAclItem acl[] = {
1313
};
1414

15-
static void led3_main(const void *);
15+
static void led3_main(void *);
1616

1717
/* Box configuration
1818
* We need at least 1kB in the main thread as we use printf in it. The interrupt
@@ -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,9 +36,17 @@ static void run_3(void)
4036
}
4137
}
4238

43-
static void led3_main(const void *)
39+
/* A thin wrapper around run_3 that accepts and ignores a context. This avoid a
40+
* cast, as mbed's Thread and RTX's osThreadContextNew operate on differently
41+
* typed thread functions. */
42+
static void run_3_context(void *)
4443
{
45-
osStatus status;
44+
run_3();
45+
}
46+
47+
static void led3_main(void *)
48+
{
49+
osStatus_t status;
4650
DigitalOut led3(LED3);
4751
led3 = LED_OFF;
4852

@@ -64,14 +68,16 @@ static void led3_main(const void *)
6468
const uint32_t kB = 1024;
6569
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
6670
/* Prepare the thread definition structure. */
67-
osThreadDef_t thread_def;
68-
thread_def.stacksize = 512;
71+
osThreadAttr_t thread_attr = {0};
72+
os_thread_t thread_def = {0};
73+
thread_def.stack_size = 512;
6974
/* Allocate the stack inside the page allocator! */
70-
thread_def.stack_pointer = (uint32_t *) secure_malloc(alloc, DEFAULT_STACK_SIZE);
71-
thread_def.tpriority = osPriorityNormal;
72-
thread_def.pthread = (void (*)(const void *)) &run_3;
75+
thread_attr.stack_mem = (uint32_t *) secure_malloc(alloc, 512);
76+
thread_def.priority = osPriorityNormal;
77+
thread_attr.cb_size = sizeof(thread_def);
78+
thread_attr.cb_mem = &thread_def;
7379
/* Create a thread with the page allocator as heap. */
74-
osThreadContextCreate(&thread_def, NULL, alloc);
80+
osThreadContextNew(run_3_context, NULL, &thread_attr, alloc);
7581

7682
while (1) {
7783
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."

source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void main_alloc(void)
4343
int main(void)
4444
{
4545
Thread thread(osPriorityNormal, 512, NULL);
46-
osStatus status = thread.start(main_alloc);
46+
osStatus_t status = thread.start(main_alloc);
4747
if (status != osOK) {
4848
printf("Could not start main thread.\r\n");
4949
uvisor_error(USER_NOT_ALLOWED);

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)