• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 
13 #ifndef TEE_LOADER_SET_TEEOS_CFG_H
14 #define TEE_LOADER_SET_TEEOS_CFG_H
15 
16 #include <stdint.h>
17 #include <stdbool.h>
18 
19 #define teelog(fmt, args...)
20 
21 typedef struct p_reg {
22     uint64_t start;
23     uint64_t end;
24 } p_region_t;
25 
26 #ifndef  PAGE_SIZE
27 #define PAGE_SIZE 4096
28 #endif
29 
30 #define MAX_CONFIG_LENGTH 0x1000
31 
32 #define GIC_V3_VERSION              3
33 #define GIC_V2_VERSION              2
34 #define MAX_PROTECTED_REGIONS       16
35 #define GICR_MAX_NUM    8
36 #define PLAT_ENABLE_PAN (1ull << 60)
37 #define PL011_TYPE         0x101
38 #define PL011_GENERAL_TYPE 0x102
39 #define PL011_V500_TYPE    0x103
40 #define UART_LPC_TYPE      0x201
41 #define UART_INVALID_TYPE  0xFFFF
42 #define UART_TYPE_MASK     (32U)
43 
44 #define UART_ENABLE_FLAG   ((uint64_t)(0x54524155U) << UART_TYPE_MASK)
45 #define UART_DISABLE_FLAG  ((uint64_t)(0x1234U) << UART_TYPE_MASK)
46 
47 struct gic_config_t {
48     char version;
49     union {
50         struct v2_t {
51             p_region_t dist;
52             p_region_t contr;
53         } v2;
54         struct v3_t {
55             p_region_t dist;
56             uint32_t redist_num;
57             uint32_t redist_stride;
58             p_region_t redist[GICR_MAX_NUM];
59         } v3;
60     };
61 };
62 
63 int32_t set_teeos_mem(uintptr_t teeos_base_addr, uint64_t size);
64 void set_teeos_uart(uint64_t uart_addr, uint64_t uart_type);
65 bool set_protected_regions(p_region_t *protected_regions, uint32_t regions_num);
66 void set_sharedmem_size(uint64_t shmem_size);
67 bool set_random(uint64_t random_data);
68 void set_gic(struct gic_config_t gic_config);
69 void set_spi_num(uint32_t spi_num);
70 void set_plat_features(uint64_t plat_features);
71 bool copy_extend_datas(void *extend_datas, uint64_t extend_length);
72 bool copy_teeos_cfg(void);
73 
74 uint64_t get_teeos_start(void);
75 uint64_t get_teeos_code_start(void);
76 uint64_t get_teeos_size(void);
77 uint64_t get_sharedmem_start(void);
78 uint64_t get_sharedmem_size(void);
79 
80 #endif
81