1# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16LOCAL_DIR := $(GET_LOCAL_DIR)
17
18MODULE := $(LOCAL_DIR)
19
20STORAGE_RPMB_PROTOCOL ?= MMC
21
22MODULE_CONSTANTS := $(LOCAL_DIR)/storage_consts.json
23
24MANIFEST := $(LOCAL_DIR)/manifest.json
25
26MODULE_DEFINES := \
27	RPMB_PROTOCOL=RPMB_PROTOCOL_$(STORAGE_RPMB_PROTOCOL) \
28
29# WITH_HKDF_RPMB_KEY indicates that storage server derives rpmb key
30# from a random sequence stored in the rpmb partition itself,
31# and that the storage server supports auto provisioning.
32# Otherwise, keyslot will provide the rpmb key.
33# By default we obtain rpmb key from keyslot.
34WITH_HKDF_RPMB_KEY ?= false
35
36ifeq (true,$(call TOBOOL,$(WITH_HKDF_RPMB_KEY)))
37    MODULE_DEFINES += WITH_HKDF_RPMB_KEY=1
38endif
39
40STORAGE_HAS_FS_TDP ?= false
41ifeq (true,$(call TOBOOL,$(STORAGE_HAS_FS_TDP)))
42    MODULE_DEFINES += HAS_FS_TDP=1
43endif
44
45STORAGE_HAS_FS_NONSECURE_PERSIST ?= false
46ifeq (true,$(call TOBOOL,$(STORAGE_HAS_FS_NONSECURE_PERSIST)))
47    MODULE_DEFINES += HAS_FS_NSP=1
48endif
49
50SS_DATA_DEBUG_IO ?= false
51ifeq (true,$(call TOBOOL,$(SS_DATA_DEBUG_IO)))
52    MODULE_DEFINES += SS_DATA_DEBUG_IO=1
53endif
54
55STORAGE_NS_RECOVERY_CLEAR_ALLOWED ?= false
56ifeq (true,$(call TOBOOL,$(STORAGE_NS_RECOVERY_CLEAR_ALLOWED)))
57    MODULE_DEFINES += STORAGE_NS_RECOVERY_CLEAR_ALLOWED=1
58endif
59
60STORAGE_NS_ALTERNATE_SUPERBLOCK_ALLOWED ?= false
61ifeq (true,$(call TOBOOL,$(STORAGE_NS_ALTERNATE_SUPERBLOCK_ALLOWED)))
62    MODULE_DEFINES += STORAGE_NS_ALTERNATE_SUPERBLOCK_ALLOWED=1
63endif
64
65STORAGE_ENABLE_ERROR_REPORTING ?= false
66ifeq (true,$(call TOBOOL,$(STORAGE_ENABLE_ERROR_REPORTING)))
67    MODULE_DEFINES += STORAGE_ENABLE_ERROR_REPORTING=1
68endif
69
70STORAGE_TDP_RECOVERY_CHECKPOINT_RESTORE_ALLOWED ?= false
71ifeq (true,$(call TOBOOL,$(STORAGE_TDP_RECOVERY_CHECKPOINT_RESTORE_ALLOWED)))
72    MODULE_DEFINES += STORAGE_TDP_RECOVERY_CHECKPOINT_RESTORE_ALLOWED=1
73endif
74
75STORAGE_TDP_AUTO_CHECKPOINT_ENABLED ?= false
76ifeq (true,$(call TOBOOL,$(STORAGE_TDP_AUTO_CHECKPOINT_ENABLED)))
77    MODULE_DEFINES += STORAGE_TDP_AUTO_CHECKPOINT_ENABLED=1
78endif
79
80MODULE_SRCS := \
81	$(LOCAL_DIR)/block_allocator.c \
82	$(LOCAL_DIR)/block_cache.c \
83	$(LOCAL_DIR)/block_device_tipc.c \
84	$(LOCAL_DIR)/block_mac.c \
85	$(LOCAL_DIR)/block_map.c \
86	$(LOCAL_DIR)/block_set.c \
87	$(LOCAL_DIR)/block_tree.c \
88	$(LOCAL_DIR)/checkpoint.c \
89	$(LOCAL_DIR)/client.c \
90	$(LOCAL_DIR)/client_tipc.c \
91	$(LOCAL_DIR)/crypt.c \
92	$(LOCAL_DIR)/error_reporting.c \
93	$(LOCAL_DIR)/file.c \
94	$(LOCAL_DIR)/ipc.c \
95	$(LOCAL_DIR)/main.c \
96	$(LOCAL_DIR)/proxy.c \
97	$(LOCAL_DIR)/rpmb.c \
98	$(LOCAL_DIR)/super.c \
99	$(LOCAL_DIR)/tipc_ns.c \
100	$(LOCAL_DIR)/transaction.c \
101
102MODULE_LIBRARY_DEPS := \
103	trusty/user/base/interface/metrics \
104	trusty/user/base/interface/storage \
105	trusty/user/base/lib/hwkey \
106	trusty/user/base/lib/libc-trusty \
107	trusty/user/base/lib/system_state \
108	trusty/user/base/lib/tipc \
109	external/boringssl \
110
111ifeq (true,$(call TOBOOL,$(STORAGE_ENABLE_ERROR_REPORTING)))
112MODULE_LIBRARY_DEPS += \
113	trusty/user/base/interface/stats/nw \
114	trusty/user/base/interface/stats_setter \
115	trusty/user/base/interface/stats/tz \
116	trusty/user/base/lib/metrics_atoms \
117	trusty/user/base/lib/stats
118endif
119
120STORAGE_AIDL_ENABLED ?= false
121ifeq (true,$(call TOBOOL,$(STORAGE_AIDL_ENABLED)))
122MODULE_DEFINES += STORAGE_AIDL_ENABLED=1
123MODULE_SRCS += $(LOCAL_DIR)/aidl_service.cpp
124MODULE_LIBRARY_DEPS += \
125	frameworks/native/libs/binder/trusty \
126	trusty/user/base/interface/secure_storage/cpp
127endif
128
129MODULE_DEPS += \
130	trusty/user/app/storage/test/block_host_test \
131	trusty/user/app/storage/test/storage_host_test \
132
133include make/trusted_app.mk
134
135# Build host side unit tests for mock storage implementation.
136include trusty/user/app/storage/storage_mock/test_mock_storage_rules.mk
137