Skip to content

Commit 2258bba

Browse files
committed
Added xphoton
1 parent 0607ed4 commit 2258bba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+53228
-0
lines changed

XPhoton/.clang-format

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: true
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: false
12+
AllowShortBlocksOnASingleLine: true
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: All
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: false
21+
BinPackArguments: false
22+
BinPackParameters: false
23+
BraceWrapping:
24+
AfterClass: true
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: true
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
BreakBeforeBinaryOperators: None
36+
BreakBeforeBraces: Custom
37+
BreakBeforeTernaryOperators: false
38+
BreakConstructorInitializersBeforeComma: false
39+
ColumnLimit: 0
40+
CommentPragmas: '^ IWYU pragma:'
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
42+
ConstructorInitializerIndentWidth: 4
43+
ContinuationIndentWidth: 4
44+
Cpp11BracedListStyle: true
45+
DerivePointerAlignment: false
46+
DisableFormat: false
47+
ExperimentalAutoDetectBinPacking: false
48+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
49+
IncludeCategories:
50+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
51+
Priority: 2
52+
- Regex: '^(<|"(gtest|isl|json)/)'
53+
Priority: 3
54+
- Regex: '.*'
55+
Priority: 1
56+
IndentCaseLabels: true
57+
IndentWidth: 4
58+
IndentWrappedFunctionNames: false
59+
KeepEmptyLinesAtTheStartOfBlocks: false
60+
MacroBlockBegin: ''
61+
MacroBlockEnd: ''
62+
MaxEmptyLinesToKeep: 2
63+
NamespaceIndentation: None
64+
ObjCBlockIndentWidth: 2
65+
ObjCSpaceAfterProperty: false
66+
ObjCSpaceBeforeProtocolList: true
67+
PenaltyBreakBeforeFirstCallParameter: 19
68+
PenaltyBreakComment: 300
69+
PenaltyBreakFirstLessLess: 120
70+
PenaltyBreakString: 1000
71+
PenaltyExcessCharacter: 1000000
72+
PenaltyReturnTypeOnItsOwnLine: 60
73+
PointerAlignment: Middle
74+
ReflowComments: true
75+
SortIncludes: false
76+
SpaceAfterCStyleCast: false
77+
SpaceBeforeAssignmentOperators: true
78+
SpaceBeforeParens: ControlStatements
79+
SpaceInEmptyParentheses: false
80+
SpacesBeforeTrailingComments: 4
81+
SpacesInAngles: false
82+
SpacesInContainerLiterals: false
83+
SpacesInCStyleCastParentheses: false
84+
SpacesInParentheses: false
85+
SpacesInSquareBrackets: false
86+
Standard: Cpp11
87+
TabWidth: 4
88+
UseTab: Always
89+
...
90+
91+

XPhoton/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.*
2+
!/.gitignore
3+
!/.clang-format
4+
*.elf
5+
*.o
6+
*.ta
7+
*.dmp
8+
*.map
9+
*.lds
10+
ta/dyn_list
11+

XPhoton/Android.mk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
###################### optee-add-two-numbers ######################
2+
LOCAL_PATH := $(call my-dir)
3+
4+
OPTEE_CLIENT_EXPORT = $(LOCAL_PATH)/../../optee_client/out/export
5+
6+
include $(CLEAR_VARS)
7+
LOCAL_CFLAGS += -DANDROID_BUILD
8+
LOCAL_CFLAGS += -Wall
9+
10+
LOCAL_SRC_FILES += host/main.c
11+
12+
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ta/include \
13+
$(OPTEE_CLIENT_EXPORT)/include \
14+
15+
LOCAL_SHARED_LIBRARIES := libteec
16+
LOCAL_MODULE := optee_example_add_two_numbers
17+
LOCAL_VENDOR_MODULE := true
18+
LOCAL_MODULE_TAGS := optional
19+
include $(BUILD_EXECUTABLE)
20+
21+
include $(LOCAL_PATH)/ta/Android.mk

XPhoton/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
project (xphoton C)
2+
3+
set (SRC host/main.c)
4+
5+
add_executable (${PROJECT_NAME} ${SRC})
6+
7+
target_include_directories(${PROJECT_NAME}
8+
PRIVATE ta/include
9+
PRIVATE include)
10+
11+
target_link_libraries (${PROJECT_NAME} PRIVATE teec)
12+
13+
install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

XPhoton/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export V?=0
2+
3+
# If _HOST or _TA specific compilers are not specified, then use CROSS_COMPILE
4+
HOST_CROSS_COMPILE ?= $(CROSS_COMPILE)
5+
TA_CROSS_COMPILE ?= $(CROSS_COMPILE)
6+
7+
.PHONY: all
8+
all:
9+
$(MAKE) -C host CROSS_COMPILE="$(HOST_CROSS_COMPILE)" --no-builtin-variables
10+
$(MAKE) -C ta CROSS_COMPILE="$(TA_CROSS_COMPILE)" LDFLAGS=""
11+
12+
.PHONY: clean
13+
clean:
14+
$(MAKE) -C host clean
15+
$(MAKE) -C ta clean

XPhoton/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# XPhoton
2+
3+
Clone XPhoton into a folder named XPhoton in Documents.
4+
```
5+
$ cd ~/Documents && mkdir XPhoton && cd XPhoton
6+
$ git clone git@gitlab.prognosticlab.org:friedrich12/xphoton.git XPhoton
7+
```
8+
9+
To run XPhoton on QEMU
10+
```
11+
$ cd ~/Documents && mkdir -p optee
12+
$ cd optee
13+
$ repo init -u https://github.com/OP-TEE/manifest.git -m default_stable.xml
14+
$ repo sync -j4 --no-clone-bundle
15+
```
16+
17+
and STM32MP1.
18+
```
19+
$ cd ~/Documents && mkdir -p optee2
20+
$ cd optee2
21+
$ repo init -u https://github.com/OP-TEE/manifest.git -m stm32mp1.xml.xml
22+
$ repo sync
23+
$ cd build
24+
$ make toolchains
25+
```
26+
27+
28+
Build and add XPhoton to QEMU and STM32MP1 optee builds.
29+
```
30+
$ cd ~/Documents/XPhoton/XPhoton
31+
$ ./build.sh
32+
$ ./install.sh
33+
```
34+
35+
Run on QEMU.
36+
```
37+
$ cd ~/Documents/optee/build
38+
$ make && make run
39+
```
40+
41+
Run on STM32MP1.
42+
```
43+
$ cd ~/Documents/optee2/build
44+
$ make PLATFORM=stm32mp1-157C_DK2 all
45+
$ sudo dd if=../out/bin/sdcard.img of=/dev/sdX conv=fdatasync status=progress
46+
```
47+
48+
49+
50+
## Requirements
51+
52+
OP-TEE 3.15.0
53+
54+
## TODO
55+
56+
- [x] Port the mlibc generic math library to OPTEE
57+
- [x] Load model in memory.
58+
- [x] Load image in memory.
59+
- [x] Solve memory limit problem.
60+
61+
62+
63+

XPhoton/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cd host
2+
make \
3+
CROSS_COMPILE=/home/friedy/Documents/optee/out-br/host/bin/arm-linux-gnueabihf- \
4+
TEEC_EXPORT=/home/friedy/Documents/optee/optee_client/out/export/usr \
5+
--no-builtin-variables
6+
7+
cd ../
8+
cd ta
9+
make \
10+
CROSS_COMPILE=/home/friedy/Documents/optee/out-br/host/bin/arm-linux-gnueabihf- \
11+
PLATFORM=vexpress-qemu_virt \
12+
TA_DEV_KIT_DIR=/home/friedy/Documents/optee/optee_os/out/arm/export-ta_arm32

XPhoton/host/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#%.o: %.c
2+
# $(CC) $(CFLAGS) -c $< -o $@
3+
4+
CC ?= $(CROSS_COMPILE)gcc
5+
LD ?= $(CROSS_COMPILE)ld
6+
AR ?= $(CROSS_COMPILE)ar
7+
NM ?= $(CROSS_COMPILE)nm
8+
OBJCOPY ?= $(CROSS_COMPILE)objcopy
9+
OBJDUMP ?= $(CROSS_COMPILE)objdump
10+
READELF ?= $(CROSS_COMPILE)readelf
11+
12+
OBJS = main.o incbin.o
13+
14+
CFLAGS += -Wall -I../ta/include/host -I$(TEEC_EXPORT)/include -I./include
15+
16+
#Add/link other required libraries here
17+
LDADD += -lteec -L$(TEEC_EXPORT)/lib
18+
LDADD += -lutil -L$(TEEC_EXPORT)/lib
19+
20+
BINARY = optee_example_hello_world
21+
22+
.PHONY: all
23+
all: $(BINARY)
24+
25+
$(BINARY): $(OBJS)
26+
$(CC) -o $@ $< $(LDADD)
27+
28+
.PHONY: clean
29+
clean:
30+
rm -f $(OBJS) $(BINARY)
31+
32+
%.o: %.c
33+
$(CC) $(CFLAGS) -c main.c -o main.o
34+
$(CC) -c incbin.c -o incbin.o
35+

XPhoton/host/f1.jpg

43 KB
Loading

XPhoton/host/face.realnet.sod

234 KB
Binary file not shown.

0 commit comments

Comments
 (0)