mirror of
https://github.com/openharmony/tee_tee_os_framework.git
synced 2026-07-01 07:22:28 -04:00
!8 merge dev-rk3588 into master
add support for rk3588 Created-by: xclimatexx Commit-by: lixuan Merged-by: openharmony_ci Description: ### 一、内容说明(相关的Issue) [#5](https://gitcode.com/openharmony/tee_tee_os_framework/issues/5) ### 二、建议测试周期和提测地址 建议测试完成时间:xxxx.xx.xx 投产上线时间:xxxx.xx.xx 提测地址:CI环境/压测环境 测试账号: ### 三、变更内容 * 3.1 关联PR列表 * 3.2 数据库和部署说明 1. 常规更新 2. 重启unicorn 3. 重启sidekiq 4. 迁移任务:是否有迁移任务,没有写 "无" 5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无" * 3.4 其他技术优化内容(做了什么,变更了什么) - 重构了 xxxx 代码 - xxxx 算法优化 * 3.5 废弃通知(什么字段、方法弃用?) * 3.6 后向不兼容变更(是否有无法向后兼容的变更?) ### 四、研发自测点(自测哪些?冒烟用例全部自测?) 自测测试结论: ### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方) 检查点: | 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 | |------|------------|----------|---------------| | xxx | 否 | 需要 | 不需要 | | | | | | 接口测试: 性能测试: 并发测试: 其他: See merge request: openharmony/tee_tee_os_framework!8
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
DRIVER := libhardware_crypto_drv.so
|
||||
|
||||
include $(BUILD_CONFIG)/var.mk
|
||||
|
||||
libhardware_crypto_drv_c_files += $(wildcard src/*.c)
|
||||
|
||||
inc-flags += -I$(FRAMEWORK_PATH)/drvmgr/src
|
||||
inc-flags += -I$(DRIVERS_PATH)/include
|
||||
inc-flags += -I$(DRVLIB)/common/libdrv_frame/include
|
||||
inc-flags += -I$(DRVLIB)/libdrv_shared/include
|
||||
inc-flags += -I$(DRIVERS_PATH)/crypto_mgr/src/crypto_ioctl/
|
||||
inc-flags += -I$(TEELIB)/libcrypto_hal/include
|
||||
inc-flags += -I$(TEELIB)/libteeos/include/tee
|
||||
inc-flags += -I$(TEELIB)/libteeos/include/legacy
|
||||
inc-flags += -I$(TEELIB)/libtimer/include
|
||||
inc-flags += -I$(TEELIB)/libteemem/include
|
||||
|
||||
# Libraries
|
||||
|
||||
SVC_PARTITIAL_LINK = y
|
||||
include $(BUILD_SERVICE)/svc-common.mk
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU)
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <crypto_driver_adaptor_ops.h>
|
||||
#include <drv_io_share.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define BIT(x) (1 << (x))
|
||||
|
||||
#define TRNG_64_BIT_LEN (0 << 4)
|
||||
#define TRNG_128_BIT_LEN (1 << 4)
|
||||
#define TRNG_192_BIT_LEN (2 << 4)
|
||||
#define TRNG_256_BIT_LEN (3 << 4)
|
||||
#define TRNG_FATESY_SOC_RING (0 << 2)
|
||||
#define TRNG_SLOWER_SOC_RING_0 (1 << 2)
|
||||
#define TRNG_SLOWER_SOC_RING_1 (2 << 2)
|
||||
#define TRNG_SLOWEST_SOC_RING (3 << 2)
|
||||
#define TRNG_ENABLE BIT(1)
|
||||
#define TRNG_START BIT(0)
|
||||
#define TRNG_BASE (0xfe370000)
|
||||
#define TRNG_SIZE (0x10000)
|
||||
#define TRNG_RNG_CTL(addr) ((addr) + 0x0400)
|
||||
#define TRNG_RST_CTL(addr) ((addr) + 0x0004)
|
||||
#define TRNG_RNG_SAMPLE_CNT(addr) ((addr) + 0x0404)
|
||||
#define TRNG_RNG_DOUT(addr, x) ((addr) + 0x0410 + 4 * (x))
|
||||
|
||||
static void put32(unsigned long addr, uint32_t val)
|
||||
{
|
||||
*(volatile uint32_t *)addr = val;
|
||||
}
|
||||
|
||||
static uint32_t get32(unsigned long addr)
|
||||
{
|
||||
return *(volatile uint32_t *)addr;
|
||||
}
|
||||
|
||||
static void set32(unsigned long addr, uint32_t set_mask)
|
||||
{
|
||||
put32(addr, get32(addr) | set_mask);
|
||||
}
|
||||
|
||||
static unsigned long s_trng_vaddr;
|
||||
|
||||
int32_t init(void)
|
||||
{
|
||||
s_trng_vaddr = (unsigned long)ioremap((uintptr_t)TRNG_BASE, TRNG_SIZE, PROT_READ | PROT_WRITE);
|
||||
if ((void *)s_trng_vaddr == NULL)
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t hw_rng(void)
|
||||
{
|
||||
int reg = 0;
|
||||
uint64_t rnd;
|
||||
|
||||
set32(TRNG_RNG_SAMPLE_CNT(s_trng_vaddr), 100);
|
||||
|
||||
reg |= TRNG_64_BIT_LEN;
|
||||
reg |= TRNG_SLOWER_SOC_RING_0;
|
||||
reg |= TRNG_ENABLE;
|
||||
reg |= TRNG_START;
|
||||
|
||||
put32(TRNG_RNG_CTL(s_trng_vaddr), ((0xffff) | (reg)) << 16 | (reg));
|
||||
|
||||
set32(TRNG_RNG_CTL(s_trng_vaddr), 0b1);
|
||||
while (get32(TRNG_RNG_CTL(s_trng_vaddr)) & 1);
|
||||
|
||||
rnd = ((uint64_t)get32(TRNG_RNG_DOUT(s_trng_vaddr, 0)) << 32) | (uint64_t)get32(TRNG_RNG_DOUT(s_trng_vaddr, 1));
|
||||
|
||||
put32(TRNG_RNG_CTL(s_trng_vaddr), (0xffff) << 16);
|
||||
|
||||
return rnd;
|
||||
}
|
||||
|
||||
int32_t generate_random(void *buffer, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
int rnd;
|
||||
for (i = 0; i < size; i += sizeof(uint64_t)) {
|
||||
rnd = hw_rng();
|
||||
memcpy(buffer + i, &rnd, MIN(sizeof(uint64_t), size - i));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) const struct crypto_drv_ops_t g_crypto_drv_ops = {
|
||||
.init = init,
|
||||
.generate_random = generate_random,
|
||||
};
|
||||
@@ -98,6 +98,7 @@ hcpptest_suite("tee_test_tcf_api") {
|
||||
tee_test_root_dir + "/utils/cmd_id",
|
||||
tee_test_root_dir + "/ca/tcf_api/common",
|
||||
|
||||
"//base/tee/tee_os_framework/lib/teelib/libteeos/include/tee",
|
||||
"//test/xts/tools/lite/hctest/include",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"//foundation/systemabilitymgr/samgr_lite/interfaces/kits/samgr",
|
||||
|
||||
Reference in New Issue
Block a user