• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
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 #ifndef __PLAT_ADDR_MAP_H__
16 #define __PLAT_ADDR_MAP_H__
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 #if 0
23 #elif defined(CHIP_FPGA1000)
24 #define CHIP_ID_LITERAL                         fpga1000
25 #elif defined(CHIP_BEST1000)
26 #define CHIP_ID_LITERAL                         best1000
27 #elif defined(CHIP_BEST1305)
28 #define CHIP_ID_LITERAL                         best1305
29 #elif defined(CHIP_BEST1400) || defined(CHIP_BEST1402)
30 #define CHIP_ID_LITERAL                         best1400
31 #elif defined(CHIP_BEST1501)
32 #define CHIP_ID_LITERAL                         best1501
33 #elif defined(CHIP_BEST1600)
34 #define CHIP_ID_LITERAL                         best1600
35 #elif defined(CHIP_BEST2000)
36 #define CHIP_ID_LITERAL                         best2000
37 #elif defined(CHIP_BEST2001)
38 #define CHIP_ID_LITERAL                         best2001
39 #elif defined(CHIP_BEST2002)
40 #define CHIP_ID_LITERAL                         best2002
41 #elif defined(CHIP_BEST2003)
42 #define CHIP_ID_LITERAL                         best2003
43 #elif defined(CHIP_BEST2300)
44 #define CHIP_ID_LITERAL                         best2300
45 #elif defined(CHIP_BEST2300A)
46 #define CHIP_ID_LITERAL                         best2300a
47 #elif defined(CHIP_BEST2300P)
48 #define CHIP_ID_LITERAL                         best2300p
49 #elif defined(CHIP_BEST3001) || defined(CHIP_BEST3005)
50 #define CHIP_ID_LITERAL                         best3001
51 #elif defined(CHIP_BEST3003)
52 #define CHIP_ID_LITERAL                         best3003
53 #elif defined(CHIP_BEST1501SIMU)
54 #define CHIP_ID_LITERAL                         best1501simu
55 #elif defined(CHIP_BEST1600SIMU)
56 #define CHIP_ID_LITERAL                         best1600simu
57 #else
58 #error "Unknown chip ID"
59 #endif
60 
61 #define _TO_STRING_A(s)                         # s
62 #define _TO_STRING(s)                           _TO_STRING_A(s)
63 
64 #define CONCAT_NAME_A(a, b)                     a ## b
65 #define CONCAT_NAME(a, b)                       CONCAT_NAME_A(a, b)
66 #define CONCAT_SUFFIX(a, b)                     a.b
67 
68 #define CONSTRUCT_HDR_NAME_A(d, n)              d/n ## _ ## d
69 #define CONSTRUCT_HDR_NAME(d, n)                CONSTRUCT_HDR_NAME_A(d, n)
70 #define CHIP_SPECIFIC_HDR(n)                    _TO_STRING(CONSTRUCT_HDR_NAME(CHIP_ID_LITERAL, n).h)
71 
72 #include CHIP_SPECIFIC_HDR(plat_addr_map)
73 
74 #ifndef ROMX_BASE
75 #define ROMX_BASE                               ROM_BASE
76 #endif
77 
78 #ifdef CHIP_HAS_TCM
79 
80 #define RAM_TO_RAMX(d)                          (d)
81 #define RAMX_TO_RAM(d)                          (d)
82 
83 #define FLASH_TO_FLASHX(d)                      (d)
84 #define FLASHX_TO_FLASH(d)                      (d)
85 
86 #define PSRAM_TO_PSRAMX(d)                      (d)
87 #define PSRAMX_TO_PSRAM(d)                      (d)
88 
89 #else /* !CHIP_HAS_TCM */
90 
91 #define RAM_TO_RAMX(d)                          ((d) - RAM_BASE + RAMX_BASE)
92 #define RAMX_TO_RAM(d)                          ((d) - RAMX_BASE + RAM_BASE)
93 
94 #define FLASH_TO_FLASHX(d)                      ((d) - FLASH_BASE + FLASHX_BASE)
95 #define FLASHX_TO_FLASH(d)                      ((d) - FLASHX_BASE + FLASH_BASE)
96 
97 #define PSRAM_TO_PSRAMX(d)                      ((d) - PSRAM_BASE + PSRAMX_BASE)
98 #define PSRAMX_TO_PSRAM(d)                      ((d) - PSRAMX_BASE + PSRAM_BASE)
99 
100 #endif /* !CHIP_HAS_TCM */
101 
102 #define FLASH_C_TO_NC(d)                        ((d) - FLASH_BASE + FLASH_NC_BASE)
103 #define FLASH_NC_TO_C(d)                        ((d) - FLASH_NC_BASE + FLASH_BASE)
104 
105 #define PSRAM_C_TO_NC(d)                        ((d) - PSRAM_BASE + PSRAM_NC_BASE)
106 #define PSRAM_NC_TO_C(d)                        ((d) - PSRAM_NC_BASE + PSRAM_BASE)
107 
108 #define BUILD_INFO_MAGIC                        0xBE57341D
109 
110 #if (RAM_BASE & (0x400 - 1))
111 #error "RAM_BASE should be aligned on 0x400 boundary"
112 #endif
113 #if defined(RAMCP_BASE) && (RAMCP_BASE & (0x400 - 1))
114 #error "RAMCP_BASE should be aligned on 0x400 boundary"
115 #endif
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif
122