Skip to content

Update for feature_cmsis5 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Supported devices:
|--------|-----------|-----------|
| `K64F` | `GCC_ARM` | 9600 |

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).
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).

## Quickstart

Expand Down
2 changes: 1 addition & 1 deletion mbed-os.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ARMmbed/mbed-os/#42be5c01a7f91292d5e27124ad9584236025f6ab
https://github.com/ARMmbed/mbed-os/#799983c5d17ed649cc8385f3fb11e486864b9eac
4 changes: 2 additions & 2 deletions source/fun_bag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ static int prn_verify(const void * mem, uint16_t seed, size_t len)
{
size_t i;
uint16_t state = seed;
uint8_t * m = (uint8_t *) mem;
const uint8_t * m = (const uint8_t *) mem;
bool matches = true;

/* Check all of the bytes, even if we find a match sooner. This tests that
* we can read all of the memory (and that it hasn't been securely taken
* over by another box. */
* over by another box). */
for (i = 0; i < len; ++i) {
if (m[i] != (state & 0xFF)) {
matches = false;
Expand Down
8 changes: 2 additions & 6 deletions source/led1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct box_context {
static const UvisorBoxAclItem acl[] = {
};

static void led1_main(const void *);
static void led1_main(void *);

/* Box configuration
* We do not need large stacks in either the main nor the interrupt thread, as
Expand All @@ -22,13 +22,9 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_MAIN(led1_main, osPriorityNormal, 512);
UVISOR_BOX_CONFIG(box_led1, acl, 512, box_context);

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

static void led1_main(const void *)
static void led1_main(void *)
{
DigitalOut led1(LED1);
led1 = LED_OFF;
Expand Down
8 changes: 2 additions & 6 deletions source/led2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct box_context {
static const UvisorBoxAclItem acl[] = {
};

static void led2_main(const void *);
static void led2_main(void *);

/* Box configuration
* We do not need large stacks in either the main nor the interrupt thread, as
Expand All @@ -22,13 +22,9 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_MAIN(led2_main, osPriorityNormal, 512);
UVISOR_BOX_CONFIG(box_led2, acl, 512, box_context);

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

static void led2_main(const void *)
static void led2_main(void *)
{
DigitalOut led2(LED2);
led2 = LED_OFF;
Expand Down
32 changes: 19 additions & 13 deletions source/led3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct box_context {
static const UvisorBoxAclItem acl[] = {
};

static void led3_main(const void *);
static void led3_main(void *);

/* Box configuration
* We need at least 1kB in the main thread as we use printf in it. The interrupt
Expand All @@ -22,11 +22,7 @@ UVISOR_BOX_HEAPSIZE(3 * 1024);
UVISOR_BOX_MAIN(led3_main, osPriorityNormal, 1024);
UVISOR_BOX_CONFIG(box_led3, acl, 512, box_context);

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

static void run_3(void)
{
Expand All @@ -40,9 +36,17 @@ static void run_3(void)
}
}

static void led3_main(const void *)
/* A thin wrapper around run_3 that accepts and ignores a context. This avoid a
* cast, as mbed's Thread and RTX's osThreadContextNew operate on differently
* typed thread functions. */
static void run_3_context(void *)
{
osStatus status;
run_3();
}

static void led3_main(void *)
{
osStatus_t status;
DigitalOut led3(LED3);
led3 = LED_OFF;

Expand All @@ -64,14 +68,16 @@ static void led3_main(const void *)
const uint32_t kB = 1024;
SecureAllocator alloc = secure_allocator_create_with_pages(4 * kB, 1 * kB);
/* Prepare the thread definition structure. */
osThreadDef_t thread_def;
thread_def.stacksize = 512;
osThreadAttr_t thread_attr = {0};
os_thread_t thread_def = {0};
thread_def.stack_size = 512;
/* Allocate the stack inside the page allocator! */
thread_def.stack_pointer = (uint32_t *) secure_malloc(alloc, DEFAULT_STACK_SIZE);
thread_def.tpriority = osPriorityNormal;
thread_def.pthread = (void (*)(const void *)) &run_3;
thread_attr.stack_mem = (uint32_t *) secure_malloc(alloc, 512);
thread_def.priority = osPriorityNormal;
thread_attr.cb_size = sizeof(thread_def);
thread_attr.cb_mem = &thread_def;
/* Create a thread with the page allocator as heap. */
osThreadContextCreate(&thread_def, NULL, alloc);
osThreadContextNew(run_3_context, NULL, &thread_attr, alloc);

while (1) {
static const size_t size = 20;
Expand Down
20 changes: 20 additions & 0 deletions source/main-hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
{SPI0, sizeof(*SPI0), UVISOR_TACLDEF_PERIPH}, \
}

#elif defined (TARGET_EFM32GG_STK3700)

#define MAIN_LED LED1
#define SECURE_LED LED2
#define LED_ON true
#define LED_OFF false
#define SECURE_SWITCH SW2
#define SECURE_SWITCH_PULL PullUp

#define MAIN_ACL(acl_list_name) \
static const UvisorBoxAclItem acl_list_name[] = { \
{CMU, sizeof(*CMU), UVISOR_TACLDEF_PERIPH}, \
{MSC, sizeof(*MSC), UVISOR_TACLDEF_PERIPH}, \
{GPIO, sizeof(*GPIO), UVISOR_TACLDEF_PERIPH}, \
{TIMER0, sizeof(*TIMER0), UVISOR_TACLDEF_PERIPH}, \
{UART0, sizeof(*UART0), UVISOR_TACLDEF_PERIPH}, \
{(void *) 0x0FE08000, 0x1000, UVISOR_TACLDEF_PERIPH}, \
{(void *) 0x42000000, 0x2000000, UVISOR_TACLDEF_PERIPH}, \
}

#else /* Target-specific settings */

#error "Unsupported target. Checkout the README.md file for the list of supported targets for this app."
Expand Down
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void main_alloc(void)
int main(void)
{
Thread thread(osPriorityNormal, 512, NULL);
osStatus status = thread.start(main_alloc);
osStatus_t status = thread.start(main_alloc);
if (status != osOK) {
printf("Could not start main thread.\r\n");
uvisor_error(USER_NOT_ALLOWED);
Expand Down
2 changes: 1 addition & 1 deletion test/filters.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"blacklist" : [ {
"platforms" : ["EFM32GG_STK3700", "DISCO_F429ZI"]
"platforms" : ["DISCO_F429ZI"]
}
]
}