Skip to content

Re-import uVisor library v0.9.16-alpha #1963

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 5 commits into from
Jun 16, 2016
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
8 changes: 4 additions & 4 deletions features/FEATURE_UVISOR/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
523 Milosch Meriac
422 Alessandro Angelino
17 Niklas Hauser
16 Jaeden Amero
513 Milosch Meriac
424 Alessandro Angelino
18 Jaeden Amero
18 Niklas Hauser
3 Hugo Vincent
3 JaredCJR
3 Jim Huang
Expand Down
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.9.14-alpha-8-g1f0a4b9b181476c65d396838d61465ea5363e23b
v0.9.17-alpha
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/importer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TARGET_LIB_INC:=$(TARGET_PREFIX)includes/uvisor-lib

# uVisor source directory - hidden from mbed via TARGET_IGNORE
UVISOR_GIT_URL:=https://github.com/ARMmbed/uvisor
UVISOR_GIT_BRANCH:=dev
UVISOR_GIT_BRANCH:=unstable
UVISOR_DIR:=TARGET_IGNORE/uvisor
UVISOR_API:=$(UVISOR_DIR)/api
UVISOR_GIT_CFG=$(UVISOR_DIR)/.git/config
Expand Down
11 changes: 11 additions & 0 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/box_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
sizeof(RtxBoxIndex), \
0, \
0, \
0, \
0, \
NULL, \
acl_list, \
acl_list_count \
Expand Down Expand Up @@ -76,6 +78,8 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
sizeof(RtxBoxIndex), \
context_size, \
__uvisor_box_heapsize, \
__uvisor_box_main_function, \
__uvisor_box_main_priority, \
__uvisor_box_namespace, \
acl_list, \
acl_list_count \
Expand Down Expand Up @@ -116,6 +120,13 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
#define UVISOR_BOX_NAMESPACE(box_namespace) \
static const char *const __uvisor_box_namespace = box_namespace

/* Use this macro before UVISOR_BOX_CONFIG to define the function the main
* thread of your box will use for its body. If you don't want a main thread,
* too bad: you have to have one. */
#define UVISOR_BOX_MAIN(function, priority) \
static void (*const __uvisor_box_main_function)(void const *) = (function); \
static const int32_t __uvisor_box_main_priority = (priority);

#define UVISOR_BOX_HEAPSIZE(heap_size) \
static const uint32_t __uvisor_box_heapsize = heap_size;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
/* SVC immediate values for hardcoded table (call from unprivileged) */
#define UVISOR_SVC_ID_UNVIC_OUT UVISOR_SVC_FIXED_TABLE(0, 0)
#define UVISOR_SVC_ID_REGISTER_GATEWAY UVISOR_SVC_FIXED_TABLE(3, 0)
#define UVISOR_SVC_ID_BOX_MAIN_NEXT UVISOR_SVC_FIXED_TABLE(5, 0)

/* SVC immediate values for hardcoded table (call from privileged) */
#define UVISOR_SVC_ID_UNVIC_IN UVISOR_SVC_FIXED_TABLE(0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ typedef struct {
/* Contains user provided size of box heap without guards of buffers. */
uint32_t heap_size;

void (*main_function)(void const *argument);
int32_t main_priority;

const char * box_namespace;
const UvisorBoxAclItem * const acl_list;
uint32_t acl_count;
Expand Down
4 changes: 4 additions & 0 deletions features/FEATURE_UVISOR/mbed_lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "uvisor-lib",
"macros": ["CMSIS_NVIC_VIRTUAL", "CMSIS_VECTAB_VIRTUAL"]
}
43 changes: 43 additions & 0 deletions features/FEATURE_UVISOR/source/rtx/box_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "uvisor-lib/uvisor-lib.h"
#include "mbed_interface.h"
#include "cmsis_os.h"
#include <stdint.h>
#include <stdlib.h>

/* This function is called by uVisor in unprivileged mode to create box main
* threads. */
void __uvisor_lib_box_main_handler(
void (*function)(void const *),
int32_t priority,
uint32_t stack_pointer,
uint32_t stack_size)
{
osThreadId thread_id;
osThreadDef_t thread_def;
thread_def.pthread = function;
thread_def.tpriority = priority;
thread_def.stacksize = stack_size;
thread_def.stack_pointer = malloc(stack_size); /* XXX */

thread_id = osThreadCreate(&thread_def, NULL);

if (thread_id == NULL) {
mbed_die();
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 9 additions & 4 deletions rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,6 @@ osStatus svcKernelStart (void) {

if (os_running) { return osOK; }

if (osEventObs && osEventObs->pre_start) {
osEventObs->pre_start();
}

rt_tsk_prio(0U, os_tsk.run->prio_base); // Restore priority
if (os_tsk.run->task_id == 0xFFU) { // Idle Thread
__set_PSP(os_tsk.run->tsk_stack + (8U*4U)); // Setup PSP
Expand Down Expand Up @@ -567,6 +563,15 @@ osStatus osKernelStart (void) {
if (__get_IPSR() != 0U) {
return osErrorISR; // Not allowed in ISR
}

/* Call the pre-start event (from unprivileged mode) if the handler exists
* and the kernel is not running. */
/* FIXME osEventObs needs to be readable but not writable from unprivileged
* code. */
if (!osKernelRunning() && osEventObs && osEventObs->pre_start) {
osEventObs->pre_start();
}

switch (__get_CONTROL() & 0x03U) {
case 0x00U: // Privileged Thread mode & MSP
__set_PSP((uint32_t)(stack + 8)); // Initial PSP
Expand Down
6 changes: 6 additions & 0 deletions rtos/rtx/TARGET_CORTEX_M/rt_OsEventObserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@ const OsEventObserver *osEventObs;

void osRegisterForOsEvents(const OsEventObserver *observer)
{
static uint8_t has_been_called = 0;
if (has_been_called) {
return;
}
has_been_called = 1;

osEventObs = observer;
}