forked from linaro-swg/optee_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
53,228 additions
and
0 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,91 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: LLVM | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: true | ||
AlignEscapedNewlinesLeft: true | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: false | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeBraces: Custom | ||
BreakBeforeTernaryOperators: false | ||
BreakConstructorInitializersBeforeComma: false | ||
ColumnLimit: 0 | ||
CommentPragmas: '^ IWYU pragma:' | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
- Regex: '^(<|"(gtest|isl|json)/)' | ||
Priority: 3 | ||
- Regex: '.*' | ||
Priority: 1 | ||
IndentCaseLabels: true | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 2 | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Middle | ||
ReflowComments: true | ||
SortIncludes: false | ||
SpaceAfterCStyleCast: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 4 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
TabWidth: 4 | ||
UseTab: Always | ||
... | ||
|
||
|
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,11 @@ | ||
.* | ||
!/.gitignore | ||
!/.clang-format | ||
*.elf | ||
*.o | ||
*.ta | ||
*.dmp | ||
*.map | ||
*.lds | ||
ta/dyn_list | ||
|
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,21 @@ | ||
###################### optee-add-two-numbers ###################### | ||
LOCAL_PATH := $(call my-dir) | ||
|
||
OPTEE_CLIENT_EXPORT = $(LOCAL_PATH)/../../optee_client/out/export | ||
|
||
include $(CLEAR_VARS) | ||
LOCAL_CFLAGS += -DANDROID_BUILD | ||
LOCAL_CFLAGS += -Wall | ||
|
||
LOCAL_SRC_FILES += host/main.c | ||
|
||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/include \ | ||
$(OPTEE_CLIENT_EXPORT)/include \ | ||
|
||
LOCAL_SHARED_LIBRARIES := libteec | ||
LOCAL_MODULE := optee_example_add_two_numbers | ||
LOCAL_VENDOR_MODULE := true | ||
LOCAL_MODULE_TAGS := optional | ||
include $(BUILD_EXECUTABLE) | ||
|
||
include $(LOCAL_PATH)/ta/Android.mk |
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,13 @@ | ||
project (xphoton C) | ||
|
||
set (SRC host/main.c) | ||
|
||
add_executable (${PROJECT_NAME} ${SRC}) | ||
|
||
target_include_directories(${PROJECT_NAME} | ||
PRIVATE ta/include | ||
PRIVATE include) | ||
|
||
target_link_libraries (${PROJECT_NAME} PRIVATE teec) | ||
|
||
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) |
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,15 @@ | ||
export V?=0 | ||
|
||
# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE | ||
HOST_CROSS_COMPILE ?= $(CROSS_COMPILE) | ||
TA_CROSS_COMPILE ?= $(CROSS_COMPILE) | ||
|
||
.PHONY: all | ||
all: | ||
$(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables | ||
$(MAKE) -C ta CROSS_COMPILE="$(TA_CROSS_COMPILE)" LDFLAGS="" | ||
|
||
.PHONY: clean | ||
clean: | ||
$(MAKE) -C host clean | ||
$(MAKE) -C ta 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,63 @@ | ||
# XPhoton | ||
|
||
Clone XPhoton into a folder named XPhoton in Documents. | ||
``` | ||
$ cd ~/Documents && mkdir XPhoton && cd XPhoton | ||
$ git clone [email protected]:friedrich12/xphoton.git XPhoton | ||
``` | ||
|
||
To run XPhoton on QEMU | ||
``` | ||
$ cd ~/Documents && mkdir -p optee | ||
$ cd optee | ||
$ repo init -u https://github.com/OP-TEE/manifest.git -m default_stable.xml | ||
$ repo sync -j4 --no-clone-bundle | ||
``` | ||
|
||
and STM32MP1. | ||
``` | ||
$ cd ~/Documents && mkdir -p optee2 | ||
$ cd optee2 | ||
$ repo init -u https://github.com/OP-TEE/manifest.git -m stm32mp1.xml.xml | ||
$ repo sync | ||
$ cd build | ||
$ make toolchains | ||
``` | ||
|
||
|
||
Build and add XPhoton to QEMU and STM32MP1 optee builds. | ||
``` | ||
$ cd ~/Documents/XPhoton/XPhoton | ||
$ ./build.sh | ||
$ ./install.sh | ||
``` | ||
|
||
Run on QEMU. | ||
``` | ||
$ cd ~/Documents/optee/build | ||
$ make && make run | ||
``` | ||
|
||
Run on STM32MP1. | ||
``` | ||
$ cd ~/Documents/optee2/build | ||
$ make PLATFORM=stm32mp1-157C_DK2 all | ||
$ sudo dd if=../out/bin/sdcard.img of=/dev/sdX conv=fdatasync status=progress | ||
``` | ||
|
||
|
||
|
||
## Requirements | ||
|
||
OP-TEE 3.15.0 | ||
|
||
## TODO | ||
|
||
- [x] Port the mlibc generic math library to OPTEE | ||
- [x] Load model in memory. | ||
- [x] Load image in memory. | ||
- [x] Solve memory limit problem. | ||
|
||
|
||
|
||
|
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 @@ | ||
cd host | ||
make \ | ||
CROSS_COMPILE=/home/friedy/Documents/optee/out-br/host/bin/arm-linux-gnueabihf- \ | ||
TEEC_EXPORT=/home/friedy/Documents/optee/optee_client/out/export/usr \ | ||
--no-builtin-variables | ||
|
||
cd ../ | ||
cd ta | ||
make \ | ||
CROSS_COMPILE=/home/friedy/Documents/optee/out-br/host/bin/arm-linux-gnueabihf- \ | ||
PLATFORM=vexpress-qemu_virt \ | ||
TA_DEV_KIT_DIR=/home/friedy/Documents/optee/optee_os/out/arm/export-ta_arm32 |
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,35 @@ | ||
#%.o: %.c | ||
# $(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
CC ?= $(CROSS_COMPILE)gcc | ||
LD ?= $(CROSS_COMPILE)ld | ||
AR ?= $(CROSS_COMPILE)ar | ||
NM ?= $(CROSS_COMPILE)nm | ||
OBJCOPY ?= $(CROSS_COMPILE)objcopy | ||
OBJDUMP ?= $(CROSS_COMPILE)objdump | ||
READELF ?= $(CROSS_COMPILE)readelf | ||
|
||
OBJS = main.o incbin.o | ||
|
||
CFLAGS += -Wall -I../ta/include/host -I$(TEEC_EXPORT)/include -I./include | ||
|
||
#Add/link other required libraries here | ||
LDADD += -lteec -L$(TEEC_EXPORT)/lib | ||
LDADD += -lutil -L$(TEEC_EXPORT)/lib | ||
|
||
BINARY = optee_example_hello_world | ||
|
||
.PHONY: all | ||
all: $(BINARY) | ||
|
||
$(BINARY): $(OBJS) | ||
$(CC) -o $@ $< $(LDADD) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(OBJS) $(BINARY) | ||
|
||
%.o: %.c | ||
$(CC) $(CFLAGS) -c main.c -o main.o | ||
$(CC) -c incbin.c -o incbin.o | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.