1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 8 #ifndef __TST_PHYS_MEM_H__ 9 #define __TST_PHYS_MEM_H__ 10 11 #include <stdint.h> 12 13 #ifdef DX_PLAT_ZYNQ7000 14 #define USER_WORKSPACE_MEM_BASE_ADDR 0x30000000 15 #define DX_REE_BASE_CC 0x80000000 16 #elif defined DX_PLAT_JUNO 17 #define USER_WORKSPACE_MEM_BASE_ADDR 0x8B0000000 18 #define DX_REE_BASE_CC 0x60010000 19 #endif 20 21 #define USER_WORKSPACE_MEM_SIZE 0x10000000 22 #define BOOT_FREE_MEM_LEN 0x50000 23 24 // workspace mapping supports 1 process and up to 16 threads: 25 // process RND CTX - 16KB 26 // for each thread: 27 // RND CTX - 16KB 28 // stack - 16KB 29 // user Data - (((256MB-16KB)/16)-32KB) 30 #define REG_MAP_AREA_LEN 0x20000 31 #define TEST_MAX_PROCESSES 1 32 #define TEST_MAX_THREADS 16 33 #define PROCESS_RND_CTX_OFFSET 0 34 #define PROCESS_RND_WORKBUFF_OFFSET (10*1024) 35 #define PROCESS_RND_WORKBUFF_SIZE (6*1024) // rnd working buff needs 2KB, we take 6KB within total size of context 36 #define PROCESS_RND_CTX_SIZE (16*1024) // rnd ctx needs 7KB, we take 16KB 37 38 #define TOTAL_USR_THREAD_MAPPING_SIZE ((USER_WORKSPACE_MEM_SIZE-PROCESS_RND_CTX_SIZE)/TEST_MAX_THREADS) // each thread gets workspace size [(256MB-16KB)/16] = [16MB-1KB] 39 #define THREADS_START_OFFSET (PROCESS_RND_CTX_OFFSET+PROCESS_RND_CTX_SIZE) 40 #define THREAD_RND_CTX_OFFSET 0 41 #define THREAD_RND_CTX_SIZE PROCESS_RND_CTX_SIZE 42 #define THREAD_STACK_OFFSET (THREAD_RND_CTX_OFFSET+THREAD_RND_CTX_SIZE) 43 #define THREAD_STACK_SIZE (128*1024) // stack has 128KB for 64bit CPU 44 #define USER_DATA_OFFSET (THREAD_STACK_OFFSET+THREAD_STACK_SIZE) 45 #define USER_DATA_SIZE (TOTAL_USR_THREAD_MAPPING_SIZE-THREAD_RND_CTX_SIZE-THREAD_STACK_SIZE) // {[16MB-1KB]-32KB} = 16MB-33KB 46 // devide by 6 for: dataIn, dataOut, expectedData, ccm-aData, hmac-keySize, other-key, iv, tag... 47 #define USER_DATA_INPUT_MAX_SIZE (USER_DATA_SIZE/6) // {16MB-33KB}/6 = 48 49 typedef enum memMapTypes_t { 50 MEM_MAP_REGS = 1, 51 MEM_MAP_ENV = 2, 52 MEM_MAP_USR_DATA = 4, 53 MEM_MAP_USR_STACK = 8, 54 MEM_MAP_RND_CTX = 0x10 55 56 }MemMapTypes_t; 57 58 59 typedef struct { 60 unsigned long threadHwRndCtxBaseAddr; 61 unsigned long threadHwRndWorkBuffBaseAddr; 62 unsigned long threadHwUserStackBaseAddr; 63 unsigned long threadHwUserBaseAddr; 64 }ThreadMappingArea_t; 65 66 typedef struct { 67 unsigned long processHwRegBaseAddr; 68 unsigned long processHwEnvBaseAddr; 69 unsigned long processHwRndCtxBaseAddr; 70 unsigned long processHwRndWorkBuffBaseAddr; 71 uint32_t userSpaceSize; 72 uint32_t numOfThreads; 73 ThreadMappingArea_t threadMapAddr[TEST_MAX_THREADS]; 74 }ProcessMappingArea_t; 75 76 77 /******************************/ 78 /* function declaration */ 79 /*****************************/ 80 81 unsigned int TestMapCCRegs(void); 82 void TestUnmapCCRegs(void); 83 84 unsigned int TestMapRee(void); 85 void TestMunMapRee(void); 86 87 unsigned int TestMapProcessAddrs(uint32_t numOfThreads, ProcessMappingArea_t *processMap); 88 void TestMunMapProcessAddrs(ProcessMappingArea_t *processMap); 89 90 extern unsigned long g_testHwEnvBaseAddr; 91 extern unsigned long g_testHwRegBaseAddr; 92 extern unsigned long g_testHwReeRegBaseAddr; 93 extern unsigned long g_testHwRndCtxBaseAddr; 94 extern unsigned long g_testHwRndWorkBuffBaseAddr; 95 extern unsigned long g_testHwUserStackBaseAddr; 96 extern unsigned long g_testHwUserBaseAddr; 97 98 #endif //__TST_PHYS_MEM_H__ 99