• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., 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 /**
16  ****************************************************************************************
17  *
18  * @file compiler.h
19  *
20  * @brief Definitions of compiler specific directives.
21  *
22  ****************************************************************************************
23  */
24 
25 #ifndef _COMPILER_H_
26 #define _COMPILER_H_
27 
28 #include "cmsis_compiler.h"
29 
30 /// define the static keyword for this compiler
31 #ifndef __STATIC
32 #define __STATIC static
33 #endif
34 
35 /// define size of an empty array (used to declare structure with an array size not defined)
36 #ifndef __ARRAY_EMPTY
37 #define __ARRAY_EMPTY
38 #endif
39 
40 /// Align instantiated lvalue or struct member on 4 bytes
41 #define __ALIGN4 __attribute__((aligned(4)))
42 
43 /// __MODULE__ comes from the RVDS compiler that supports it
44 #define __MODULE__ __BASE_FILE__
45 
46 #define __SHAREDRAM __attribute__ ((section("SHAREDRAM")))
47 #define __HOST_RXBUF __attribute__ ((section("HOST_RXBUF")))
48 #define __HOST_LPIRAM __attribute__ ((section("HOST_LPIRAM")))
49 #define XNSTR(s)            NSTR(s)
50 #define NSTR(s)             #s
51 /* Host shared memory */
52 #define __SHARED_HOST_N(m,n) __attribute__ ((section("SHAREDMEM_HOST_" XNSTR(m) "." XNSTR(n))))
53 #define SHARED_HOST_DECLARE(module, type, name) \
54     type backup_ ## name __SHARED_HOST_N(module, name)
55 #define SHARED_HOST_EXT_STATEMENT(type, name) \
56     extern type backup_ ## name
57 #define SHARED_HOST_ARRAY_DECLARE(module, type, count, name) \
58     type backup_ ## name[count] __SHARED_HOST_N(module, name)
59 #define SHARED_HOST_ARRAY_EXT_STATEMENT(type, count, name) \
60     extern type backup_ ## name[count]
61 #define SHARED_HOST_ARRAY2_DECLARE(module, type, count1, count2, name) \
62     type backup_ ## name[count1][count2] __SHARED_HOST_N(module, name)
63 #define SHARED_HOST_ARRAY2_EXT_STATEMENT(type, count1, count2, name) \
64     extern type backup_ ## name[count1][count2]
65 /* Host private memory, using groups: G0RTOS/G1WLAN/G2BTDM/G3USER */
66 #define __PRIVATE_HOST_N(m,n) __attribute__ ((section("PRIVATEMEM_HOST_" XNSTR(m) "." XNSTR(n))))
67 #define PRIVATE_HOST_DECLARE(module, type, name) \
68     type backup_ ## name __PRIVATE_HOST_N(module, name)
69 #define PRIVATE_HOST_EXT_STATEMENT(type, name) \
70     extern type backup_ ## name
71 #define PRIVATE_HOST_ARRAY_DECLARE(module, type, count, name) \
72     type backup_ ## name[count] __PRIVATE_HOST_N(module, name)
73 #define PRIVATE_HOST_ARRAY_EXT_STATEMENT(type, count, name) \
74     extern type backup_ ## name[count]
75 #define PRIVATE_HOST_ARRAY2_DECLARE(module, type, count1, count2, name) \
76     type backup_ ## name[count1][count2] __PRIVATE_HOST_N(module, name)
77 #define PRIVATE_HOST_ARRAY2_EXT_STATEMENT(type, count1, count2, name) \
78     extern type backup_ ## name[count1][count2]
79 
80 #define MCAT(a,b)                   a##b
81 
82 #define VAR_WITH_VERx(name,v)       MCAT(name ## _U0, v)
83 #define VAR_WITH_VER(name)          VAR_WITH_VERx(name, CFG_ROM_VER)
84 
85 #endif // _COMPILER_H_
86