-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1753 from meriac/master
Add initial uVisor port
- Loading branch information
Showing
60 changed files
with
3,486 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
519 Milosch Meriac | ||
420 Alessandro Angelino | ||
16 Niklas Hauser | ||
15 Jaeden Amero | ||
3 Hugo Vincent | ||
3 JaredCJR | ||
3 Jim Huang | ||
2 tonyyanxuan | ||
1 Aksel Skauge Mellbye | ||
1 Irit Arkin | ||
1 Nathan Chong | ||
1 ccli8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v0.9.14-alpha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
########################################################################### | ||
# | ||
# Copyright (c) 2013-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. | ||
# | ||
########################################################################### | ||
|
||
# Toolchain | ||
PREFIX:=arm-none-eabi- | ||
GDB:=$(PREFIX)gdb | ||
OBJDUMP:=$(PREFIX)objdump | ||
|
||
# Translate between uVisor namespace and mbed namespace | ||
TARGET_TRANSLATION:=MCU_K64F.kinetis EFM32.efm32 STM32F4.stm32 | ||
TARGET_PREFIX:=../ | ||
TARGET_SUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_SUPPORTED | ||
TARGET_UNSUPPORTED:=$(TARGET_PREFIX)targets/TARGET_UVISOR_UNSUPPORTED | ||
TARGET_INC:=$(TARGET_PREFIX)includes/uvisor/api | ||
TARGET_LIB_SRC:=$(TARGET_PREFIX)source | ||
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_DIR:=TARGET_IGNORE/uvisor | ||
UVISOR_API:=$(UVISOR_DIR)/api | ||
UVISOR_GIT_CFG=$(UVISOR_DIR)/.git/config | ||
|
||
# Derive variables from user configuration | ||
TARGET_LIST:=$(subst .,,$(suffix $(TARGET_TRANSLATION))) | ||
TARGET_LIST_DIR_SRC:=$(addprefix $(UVISOR_API)/lib/,$(TARGET_LIST)) | ||
TARGET_LIST_DIR_DST:=$(addprefix $(TARGET_SUPPORTED)/,$(TARGET_LIST)) | ||
TARGET_LIST_RELEASE:=$(addsuffix /release,$(TARGET_LIST_DIR_DST)) | ||
TARGET_LIST_DEBUG:=$(addsuffix /debug,$(TARGET_LIST_DIR_DST)) | ||
|
||
.PHONY: all deploy rsync publish uvisor uvisor-compile clean cache update | ||
|
||
all: uvisor | ||
|
||
uvisor: uvisor-compile publish | ||
|
||
rsync: | ||
# | ||
# Copying uVisor into mbed library... | ||
rm -rf $(TARGET_SUPPORTED) | ||
mkdir -p $(TARGET_SUPPORTED) | ||
rsync -a --exclude='*.txt' $(TARGET_LIST_DIR_SRC) $(TARGET_SUPPORTED) | ||
# | ||
# Copying uVisor headers to mbed includes... | ||
rm -rf $(TARGET_INC) | ||
mkdir -p $(TARGET_INC) | ||
rsync -a --delete $(UVISOR_API)/inc $(TARGET_INC) | ||
rsync -a --delete $(UVISOR_API)/rtx/inc/ $(TARGET_LIB_INC)/rtx | ||
# | ||
# Copying uVisor unsupported sources to unsupported target source... | ||
mkdir -p $(TARGET_UNSUPPORTED) | ||
cp $(UVISOR_API)/src/unsupported.c $(TARGET_UNSUPPORTED)/ | ||
# | ||
# Copying uVisor shared sources to mbed source... | ||
rm -rf $(TARGET_LIB_SRC) | ||
mkdir -p $(TARGET_LIB_SRC) | ||
cp $(UVISOR_DIR)/core/system/src/page_allocator.c $(TARGET_LIB_SRC)/page_allocator.c_inc | ||
rsync -a --delete $(UVISOR_API)/rtx/src/ $(TARGET_LIB_SRC)/rtx | ||
# | ||
# Copying licenses | ||
cp $(UVISOR_DIR)/LICENSE* $(TARGET_SUPPORTED) | ||
|
||
TARGET_M%: $(TARGET_SUPPORTED)/*/*/*_m%_*.a | ||
@printf "#\n# Copying $@ files...\n" | ||
mkdir $(foreach file,$^,$(dir $(file))$@) | ||
$(foreach file,$^,mv $(file) $(dir $(file))$@/lib$(notdir $(file));) | ||
|
||
publish: rsync TARGET_M3 TARGET_M4 | ||
# | ||
# Rename release directorires to TARGET_RELEASE filters... | ||
$(foreach dir, $(TARGET_LIST_RELEASE),mv $(dir) $(dir $(dir))TARGET_RELEASE;) | ||
# | ||
# Rename debug directorires to TARGET_DEBUG filters... | ||
$(foreach dir, $(TARGET_LIST_DEBUG),mv $(dir) $(dir $(dir))TARGET_DEBUG;) | ||
# | ||
# Rename target directorires to TARGET_* filters... | ||
$(foreach target, $(TARGET_TRANSLATION),mv $(TARGET_SUPPORTED)/$(subst .,,$(suffix $(target))) $(TARGET_SUPPORTED)/TARGET_$(basename $(target));) | ||
|
||
uvisor-compile: $(UVISOR_GIT_CFG) | ||
make -C $(UVISOR_DIR) | ||
|
||
update: $(UVISOR_GIT_CFG) | ||
# | ||
# Updating to latest uVisor library version | ||
git -C $(UVISOR_DIR) pull --rebase | ||
# | ||
# Updating checked out version tag | ||
git -C $(UVISOR_DIR) describe --tags --abbrev=40 --dirty > $(TARGET_PREFIX)VERSION.txt | ||
# | ||
# Updated list of authors, sorted by contributions | ||
git -C $(UVISOR_DIR) shortlog -s -n > $(TARGET_PREFIX)AUTHORS.txt | ||
|
||
$(UVISOR_GIT_CFG): | ||
rm -rf $(UVISOR_DIR) | ||
git clone -b $(UVISOR_GIT_BRANCH) $(UVISOR_GIT_URL) $(UVISOR_DIR) | ||
|
||
clean: $(UVISOR_GIT_CFG) | ||
make -C $(UVISOR_DIR) clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Rebuilding the uVisor mbed Library | ||
|
||
This directory contains scripts to import and rebuild the latest uVisor library to mbed Classic. | ||
uVisor does not need to be re-deployed for normal application development. | ||
|
||
For uVisor development and code contributions please visit the [uVisor repository](https://github.com/ARMmbed/uvisor). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/uvisor |
37 changes: 37 additions & 0 deletions
37
features/FEATURE_UVISOR/includes/uvisor-lib/rtx/process_malloc.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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. | ||
*/ | ||
#ifndef __RTX_PROCESS_MALLOC_H__ | ||
#define __RTX_PROCESS_MALLOC_H__ | ||
|
||
#include "secure_allocator.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Allocate memory on the process heap. */ | ||
void * malloc_p(size_t size); | ||
/* Reallocate memory on the process heap. */ | ||
void * realloc_p(void * ptr, size_t size); | ||
/* Free memory on the process heap. */ | ||
void free_p(void * ptr); | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /* __RTX_PROCESS_MALLOC_H__ */ |
43 changes: 43 additions & 0 deletions
43
features/FEATURE_UVISOR/includes/uvisor-lib/rtx/rtx_box_index.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
#ifndef __RTX_BOX_INDEX_H__ | ||
#define __RTX_BOX_INDEX_H__ | ||
|
||
#include "cmsis_os.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct | ||
{ | ||
/* The uvisor box index must be placed at the beginning */ | ||
UvisorBoxIndex index; | ||
|
||
/* Id of the mutex */ | ||
osMutexId mutex_id; | ||
/* Pointer to the data of the mutex */ | ||
osMutexDef_t mutex; | ||
/* Internal data of the mutex */ | ||
int32_t mutex_data[4]; | ||
} RtxBoxIndex; | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /* __RTX_BOX_INDEX_H__ */ |
88 changes: 88 additions & 0 deletions
88
features/FEATURE_UVISOR/includes/uvisor-lib/rtx/secure_allocator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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. | ||
*/ | ||
#ifndef __SECURE_ALLOCATOR_H__ | ||
#define __SECURE_ALLOCATOR_H__ | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** Contains the allocator data and backing page table. */ | ||
typedef void * SecureAllocator; | ||
|
||
/** Create an allocator in-place in an existing pool without using pages. | ||
* Use this to turn statically allocated memory into a heap. | ||
* Or allocate a large piece of memory and then turn that into a heap. | ||
* | ||
* @param mem Pointer to the origin of the memory pool | ||
* @param bytes Length of the memory pool in bytes | ||
* @returns the allocator or `NULL` on failure | ||
*/ | ||
SecureAllocator secure_allocator_create_with_pool( | ||
void * mem, | ||
size_t bytes); | ||
|
||
/** Create an allocator using pages from the page heap. | ||
* Use this to request secure dynamic memory for your process. | ||
* Note that this memory is not guaranteed to be consecutive, therefore you | ||
* must specify the maximum allocation size that you plan to use in this | ||
* allocator. This function will then compute the number and size of required | ||
* pages and request them from the secure page heap. | ||
* | ||
* @param total_size The minimal total size of the heap | ||
* @param maximum_malloc_size The largest size to be allocated in one chunk | ||
* @returns the allocator or `NULL` on failure (out of memory, | ||
* maximum malloc size cannot be fulfilled) | ||
*/ | ||
SecureAllocator secure_allocator_create_with_pages( | ||
size_t total_size, | ||
size_t maximum_malloc_size); | ||
|
||
/** Destroy the allocator and free the backing pages. | ||
* An attempt to destroy a memory-pool backed allocator will fail and return | ||
* with an error code. | ||
* | ||
* @retval 0 Allocator successfully destroyed. | ||
* @retval -1 Allocator is static (memory-pool), or freeing memory pages failed. | ||
*/ | ||
int secure_allocator_destroy( | ||
SecureAllocator allocator); | ||
|
||
/** Drop-in for `malloc`. */ | ||
void * secure_malloc( | ||
SecureAllocator allocator, | ||
size_t size); | ||
|
||
/** Drop-in for `realloc`. */ | ||
void * secure_realloc( | ||
SecureAllocator allocator, | ||
void * ptr, | ||
size_t size); | ||
|
||
/** Drop-in for `free`. */ | ||
void secure_free( | ||
SecureAllocator allocator, | ||
void * ptr); | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /* __SECURE_ALLOCATOR_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2013-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. | ||
*/ | ||
#ifndef __UVISOR_LIB_UVISOR_LIB_H__ | ||
#define __UVISOR_LIB_UVISOR_LIB_H__ | ||
|
||
/* This file translates mbed-specific pre-processor symbols into | ||
* uVisor-specific ones. Then the main uvisor-lib.h file is included. */ | ||
|
||
/* mbed uses UVISOR_SUPPORTED to determine whether the full uVisor binaries | ||
* should be included or not. This symbol maps to the uVisor-internal symbol | ||
* UVISOR_PRESENT. */ | ||
/* By default uVisor is not supported. */ | ||
#if !defined(FEATURE_UVISOR) || !defined(TARGET_UVISOR_SUPPORTED) || defined(TARGET_UVISOR_UNSUPPORTED) | ||
#define UVISOR_PRESENT 0 | ||
#else | ||
#define UVISOR_PRESENT 1 | ||
#endif | ||
|
||
/* Detect the target using the mbed-specific symbols and determine the MPU | ||
* architecture accordingly. */ | ||
#if defined(TARGET_KINETIS) | ||
#define ARCH_MPU_KINETIS | ||
#else | ||
#define ARCH_MPU_ARMv7M | ||
#endif | ||
|
||
/* The uVisor API main header file will use the above definitions. */ | ||
#include "uvisor/api/inc/uvisor-lib.h" | ||
#include "uvisor-lib/rtx/process_malloc.h" | ||
#include "uvisor-lib/rtx/rtx_box_index.h" | ||
#include "uvisor-lib/rtx/secure_allocator.h" | ||
|
||
#endif /* __UVISOR_LIB_UVISOR_LIB_H__ */ |
27 changes: 27 additions & 0 deletions
27
features/FEATURE_UVISOR/includes/uvisor/api/inc/benchmark.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2013-2015, 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. | ||
*/ | ||
#ifndef __UVISOR_API_BENCHMARK_H__ | ||
#define __UVISOR_API_BENCHMARK_H__ | ||
|
||
#include "api/inc/uvisor_exports.h" | ||
#include <stdint.h> | ||
|
||
UVISOR_EXTERN void uvisor_benchmark_configure(void); | ||
UVISOR_EXTERN void uvisor_benchmark_start(void); | ||
UVISOR_EXTERN uint32_t uvisor_benchmark_stop(void); | ||
|
||
#endif /* __UVISOR_API_BENCHMARK_H__ */ |
Oops, something went wrong.