Skip to content

Commit 62855f0

Browse files
authored
Merge pull request #1963 from meriac/dev
Re-import uVisor library v0.9.16-alpha
2 parents 1e18ea2 + 3fdb44c commit 62855f0

File tree

18 files changed

+83
-10
lines changed

18 files changed

+83
-10
lines changed

features/FEATURE_UVISOR/AUTHORS.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
523 Milosch Meriac
2-
422 Alessandro Angelino
3-
17 Niklas Hauser
4-
16 Jaeden Amero
1+
513 Milosch Meriac
2+
424 Alessandro Angelino
3+
18 Jaeden Amero
4+
18 Niklas Hauser
55
3 Hugo Vincent
66
3 JaredCJR
77
3 Jim Huang

features/FEATURE_UVISOR/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.9.14-alpha-8-g1f0a4b9b181476c65d396838d61465ea5363e23b
1+
v0.9.17-alpha

features/FEATURE_UVISOR/importer/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TARGET_LIB_INC:=$(TARGET_PREFIX)includes/uvisor-lib
3333

3434
# uVisor source directory - hidden from mbed via TARGET_IGNORE
3535
UVISOR_GIT_URL:=https://github.com/ARMmbed/uvisor
36-
UVISOR_GIT_BRANCH:=dev
36+
UVISOR_GIT_BRANCH:=unstable
3737
UVISOR_DIR:=TARGET_IGNORE/uvisor
3838
UVISOR_API:=$(UVISOR_DIR)/api
3939
UVISOR_GIT_CFG=$(UVISOR_DIR)/.git/config

features/FEATURE_UVISOR/includes/uvisor/api/inc/box_config.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
4545
sizeof(RtxBoxIndex), \
4646
0, \
4747
0, \
48+
0, \
49+
0, \
4850
NULL, \
4951
acl_list, \
5052
acl_list_count \
@@ -76,6 +78,8 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
7678
sizeof(RtxBoxIndex), \
7779
context_size, \
7880
__uvisor_box_heapsize, \
81+
__uvisor_box_main_function, \
82+
__uvisor_box_main_priority, \
7983
__uvisor_box_namespace, \
8084
acl_list, \
8185
acl_list_count \
@@ -116,6 +120,13 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
116120
#define UVISOR_BOX_NAMESPACE(box_namespace) \
117121
static const char *const __uvisor_box_namespace = box_namespace
118122

123+
/* Use this macro before UVISOR_BOX_CONFIG to define the function the main
124+
* thread of your box will use for its body. If you don't want a main thread,
125+
* too bad: you have to have one. */
126+
#define UVISOR_BOX_MAIN(function, priority) \
127+
static void (*const __uvisor_box_main_function)(void const *) = (function); \
128+
static const int32_t __uvisor_box_main_priority = (priority);
129+
119130
#define UVISOR_BOX_HEAPSIZE(heap_size) \
120131
static const uint32_t __uvisor_box_heapsize = heap_size;
121132

features/FEATURE_UVISOR/includes/uvisor/api/inc/svc_exports.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
/* SVC immediate values for hardcoded table (call from unprivileged) */
117117
#define UVISOR_SVC_ID_UNVIC_OUT UVISOR_SVC_FIXED_TABLE(0, 0)
118118
#define UVISOR_SVC_ID_REGISTER_GATEWAY UVISOR_SVC_FIXED_TABLE(3, 0)
119+
#define UVISOR_SVC_ID_BOX_MAIN_NEXT UVISOR_SVC_FIXED_TABLE(5, 0)
119120

120121
/* SVC immediate values for hardcoded table (call from privileged) */
121122
#define UVISOR_SVC_ID_UNVIC_IN UVISOR_SVC_FIXED_TABLE(0, 0)

features/FEATURE_UVISOR/includes/uvisor/api/inc/vmpu_exports.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ typedef struct {
158158
/* Contains user provided size of box heap without guards of buffers. */
159159
uint32_t heap_size;
160160

161+
void (*main_function)(void const *argument);
162+
int32_t main_priority;
163+
161164
const char * box_namespace;
162165
const UvisorBoxAclItem * const acl_list;
163166
uint32_t acl_count;

features/FEATURE_UVISOR/mbed_lib.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "uvisor-lib",
3+
"macros": ["CMSIS_NVIC_VIRTUAL", "CMSIS_VECTAB_VIRTUAL"]
4+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2016, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* 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, WITHOUT
13+
* 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+
#include "uvisor-lib/uvisor-lib.h"
18+
#include "mbed_interface.h"
19+
#include "cmsis_os.h"
20+
#include <stdint.h>
21+
#include <stdlib.h>
22+
23+
/* This function is called by uVisor in unprivileged mode to create box main
24+
* threads. */
25+
void __uvisor_lib_box_main_handler(
26+
void (*function)(void const *),
27+
int32_t priority,
28+
uint32_t stack_pointer,
29+
uint32_t stack_size)
30+
{
31+
osThreadId thread_id;
32+
osThreadDef_t thread_def;
33+
thread_def.pthread = function;
34+
thread_def.tpriority = priority;
35+
thread_def.stacksize = stack_size;
36+
thread_def.stack_pointer = malloc(stack_size); /* XXX */
37+
38+
thread_id = osThreadCreate(&thread_def, NULL);
39+
40+
if (thread_id == NULL) {
41+
mbed_die();
42+
}
43+
}

rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,6 @@ osStatus svcKernelStart (void) {
505505

506506
if (os_running) { return osOK; }
507507

508-
if (osEventObs && osEventObs->pre_start) {
509-
osEventObs->pre_start();
510-
}
511-
512508
rt_tsk_prio(0U, os_tsk.run->prio_base); // Restore priority
513509
if (os_tsk.run->task_id == 0xFFU) { // Idle Thread
514510
__set_PSP(os_tsk.run->tsk_stack + (8U*4U)); // Setup PSP
@@ -567,6 +563,15 @@ osStatus osKernelStart (void) {
567563
if (__get_IPSR() != 0U) {
568564
return osErrorISR; // Not allowed in ISR
569565
}
566+
567+
/* Call the pre-start event (from unprivileged mode) if the handler exists
568+
* and the kernel is not running. */
569+
/* FIXME osEventObs needs to be readable but not writable from unprivileged
570+
* code. */
571+
if (!osKernelRunning() && osEventObs && osEventObs->pre_start) {
572+
osEventObs->pre_start();
573+
}
574+
570575
switch (__get_CONTROL() & 0x03U) {
571576
case 0x00U: // Privileged Thread mode & MSP
572577
__set_PSP((uint32_t)(stack + 8)); // Initial PSP

rtos/rtx/TARGET_CORTEX_M/rt_OsEventObserver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,11 @@ const OsEventObserver *osEventObs;
5151

5252
void osRegisterForOsEvents(const OsEventObserver *observer)
5353
{
54+
static uint8_t has_been_called = 0;
55+
if (has_been_called) {
56+
return;
57+
}
58+
has_been_called = 1;
59+
5460
osEventObs = observer;
5561
}

0 commit comments

Comments
 (0)