CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/bcmdefs.h
Views: 3959
1
/*
2
* Misc system wide definitions
3
*
4
* $Copyright Open Broadcom Corporation$
5
*
6
* $Id: bcmdefs.h 401759 2013-05-13 16:08:08Z sudhirbs $
7
*/
8
9
#ifndef _bcmdefs_h_
10
#define _bcmdefs_h_
11
12
/*
13
* One doesn't need to include this file explicitly, gets included automatically if
14
* typedefs.h is included.
15
*/
16
17
/* Use BCM_REFERENCE to suppress warnings about intentionally-unused function
18
* arguments or local variables.
19
*/
20
#define BCM_REFERENCE(data) ((void)(data))
21
22
#ifdef EFI
23
#define STATIC_ASSERT(expr) ASSERT((expr))
24
#else
25
/* Compile-time assert can be used in place of ASSERT if the expression evaluates
26
* to a constant at compile time.
27
*/
28
#define STATIC_ASSERT(expr) { \
29
/* Make sure the expression is constant. */ \
30
typedef enum { _STATIC_ASSERT_NOT_CONSTANT = (expr) } _static_assert_e; \
31
/* Make sure the expression is true. */ \
32
typedef char STATIC_ASSERT_FAIL[(expr) ? 1 : -1]; \
33
}
34
#endif
35
36
/* Reclaiming text and data :
37
* The following macros specify special linker sections that can be reclaimed
38
* after a system is considered 'up'.
39
* BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,
40
* as in most cases, the attach function calls the detach function to clean up on error).
41
*/
42
#ifdef DONGLEBUILD
43
44
extern bool bcmreclaimed;
45
extern bool attach_part_reclaimed;
46
47
#define BCMATTACHDATA(_data) __attribute__ ((__section__ (".dataini2." #_data))) _data
48
#define BCMATTACHFN(_fn) __attribute__ ((__section__ (".textini2." #_fn), noinline)) _fn
49
50
#ifndef PREATTACH_NORECLAIM
51
#define BCMPREATTACHDATA(_data) __attribute__ ((__section__ (".dataini3." #_data))) _data
52
#define BCMPREATTACHFN(_fn) __attribute__ ((__section__ (".textini3." #_fn), noinline)) _fn
53
#else
54
#define BCMPREATTACHDATA(_data) __attribute__ ((__section__ (".dataini2." #_data))) _data
55
#define BCMPREATTACHFN(_fn) __attribute__ ((__section__ (".textini2." #_fn), noinline)) _fn
56
#endif
57
58
#if defined(BCMRECLAIM)
59
#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini1." #_data))) _data
60
#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini1." #_fn), noinline)) _fn
61
#define CONST
62
#else
63
#define BCMINITDATA(_data) _data
64
#define BCMINITFN(_fn) _fn
65
#define CONST const
66
#endif
67
68
/* Non-manufacture or internal attach function/dat */
69
#if !(defined(WLTEST) || defined(BCMINTERNAL))
70
#define BCMNMIATTACHFN(_fn) BCMATTACHFN(_fn)
71
#define BCMNMIATTACHDATA(_data) BCMATTACHDATA(_data)
72
#else
73
#define BCMNMIATTACHFN(_fn) _fn
74
#define BCMNMIATTACHDATA(_data) _data
75
#endif /* WLTEST || BCMINTERNAL */
76
77
#ifdef BCMNODOWN
78
#define BCMUNINITFN(_fn) BCMINITFN(_fn)
79
#else
80
#define BCMUNINITFN(_fn) _fn
81
#endif
82
83
#define BCMFASTPATH
84
#else /* DONGLEBUILD */
85
86
#define bcmreclaimed 0
87
#define BCMATTACHDATA(_data) _data
88
#define BCMATTACHFN(_fn) _fn
89
#define BCMPREATTACHDATA(_data) _data
90
#define BCMPREATTACHFN(_fn) _fn
91
#define BCMINITDATA(_data) _data
92
#define BCMINITFN(_fn) _fn
93
#define BCMUNINITFN(_fn) _fn
94
#define BCMNMIATTACHFN(_fn) _fn
95
#define BCMNMIATTACHDATA(_data) _data
96
#define CONST const
97
#if defined(BCM47XX) && defined(__ARM_ARCH_7A__)
98
#define BCM47XX_CA9
99
#else
100
#undef BCM47XX_CA9
101
#endif
102
#ifndef BCMFASTPATH
103
#if defined(mips) || defined(BCM47XX_CA9)
104
#define BCMFASTPATH __attribute__ ((__section__ (".text.fastpath")))
105
#define BCMFASTPATH_HOST __attribute__ ((__section__ (".text.fastpath_host")))
106
#else
107
#define BCMFASTPATH
108
#define BCMFASTPATH_HOST
109
#endif
110
#endif /* BCMFASTPATH */
111
112
#endif /* DONGLEBUILD */
113
114
#if defined(BCMROMOFFLOAD) || defined(BCMROMBUILD)
115
typedef struct {
116
uint16 esiz;
117
uint16 cnt;
118
void *addr;
119
} bcmromdat_patch_t;
120
#endif
121
122
/* Put some library data/code into ROM to reduce RAM requirements */
123
#if defined(BCMROMOFFLOAD)
124
#define BCMROMBASE ((uint32) 0x1e000000)
125
#define BCMROMEND (BCMROMBASE + (uint32) 0x100000)
126
127
/* These are legacy macros - make them nop's. */
128
#define BCMROMDATA(_data) _data
129
#define BCMROMFN(_fn) _fn
130
131
#define STATIC static
132
133
#define BCMROMDAT_NAME(_data) _data
134
#define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)
135
#define BCMROMDAT_SIZEOF(data) sizeof(data)
136
#define BCMROMDAT_APATCH(data) \
137
bcmromdat_patch_t BCMROMDATA(data##__bcmpatch) = \
138
{ sizeof(data[0]), sizeof(data)/sizeof(data[0]), ((void*)data) };
139
#define BCMROMDAT_SPATCH(data) \
140
bcmromdat_patch_t BCMROMDATA(data##__bcmpatch) = \
141
{ sizeof(data), 1, ((void*)&data) };
142
#define BCMROMFN_NAME(_fn) _fn
143
#elif defined(BCMROMBUILD) && !defined(BCMROMSYMGEN_BUILD) && !defined(BCMJMPTBL_TCAM)
144
#include <bcmjmptbl.h>
145
#define STATIC static
146
#else /* !BCMROMBUILD */
147
#define BCMROMDATA(_data) _data
148
#define BCMROMDAT_NAME(_data) _data
149
#define BCMROMFN(_fn) _fn
150
#define BCMROMFN_NAME(_fn) _fn
151
#define STATIC static
152
#define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)
153
#define BCMROMDAT_SIZEOF(data) sizeof(data)
154
#define BCMROMDAT_APATCH(data)
155
#define BCMROMDAT_SPATCH(data)
156
#endif /* !BCMROMBUILD */
157
158
/* Bus types */
159
#define SI_BUS 0 /* SOC Interconnect */
160
#define PCI_BUS 1 /* PCI target */
161
#define PCMCIA_BUS 2 /* PCMCIA target */
162
#define SDIO_BUS 3 /* SDIO target */
163
#define JTAG_BUS 4 /* JTAG */
164
#define USB_BUS 5 /* USB (does not support R/W REG) */
165
#define SPI_BUS 6 /* gSPI target */
166
#define RPC_BUS 7 /* RPC target */
167
168
/* Allows size optimization for single-bus image */
169
#ifdef BCMBUSTYPE
170
#define BUSTYPE(bus) (BCMBUSTYPE)
171
#else
172
#define BUSTYPE(bus) (bus)
173
#endif
174
175
/* Allows size optimization for single-backplane image */
176
#ifdef BCMCHIPTYPE
177
#define CHIPTYPE(bus) (BCMCHIPTYPE)
178
#else
179
#define CHIPTYPE(bus) (bus)
180
#endif
181
182
183
/* Allows size optimization for SPROM support */
184
#if defined(BCMSPROMBUS)
185
#define SPROMBUS (BCMSPROMBUS)
186
#elif defined(SI_PCMCIA_SROM)
187
#define SPROMBUS (PCMCIA_BUS)
188
#else
189
#define SPROMBUS (PCI_BUS)
190
#endif
191
192
/* Allows size optimization for single-chip image */
193
/* XXX These macros are NOT meant to encourage writing chip-specific code.
194
* Use them only when it is appropriate for example in PMU PLL/CHIP/SWREG
195
* controls and in chip-specific workarounds.
196
*/
197
#ifdef BCMCHIPID
198
#define CHIPID(chip) (BCMCHIPID)
199
#else
200
#define CHIPID(chip) (chip)
201
#endif
202
203
#ifdef BCMCHIPREV
204
#define CHIPREV(rev) (BCMCHIPREV)
205
#else
206
#define CHIPREV(rev) (rev)
207
#endif
208
209
/* Defines for DMA Address Width - Shared between OSL and HNDDMA */
210
#define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
211
#define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
212
#define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
213
214
#define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
215
#define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
216
#define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
217
#define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
218
219
#ifdef BCMDMA64OSL
220
typedef struct {
221
uint32 loaddr;
222
uint32 hiaddr;
223
} dma64addr_t;
224
225
typedef dma64addr_t dmaaddr_t;
226
#define PHYSADDRHI(_pa) ((_pa).hiaddr)
227
#define PHYSADDRHISET(_pa, _val) \
228
do { \
229
(_pa).hiaddr = (_val); \
230
} while (0)
231
#define PHYSADDRLO(_pa) ((_pa).loaddr)
232
#define PHYSADDRLOSET(_pa, _val) \
233
do { \
234
(_pa).loaddr = (_val); \
235
} while (0)
236
237
#else
238
typedef unsigned long dmaaddr_t;
239
#define PHYSADDRHI(_pa) (0)
240
#define PHYSADDRHISET(_pa, _val)
241
#define PHYSADDRLO(_pa) ((_pa))
242
#define PHYSADDRLOSET(_pa, _val) \
243
do { \
244
(_pa) = (_val); \
245
} while (0)
246
#endif /* BCMDMA64OSL */
247
248
/* One physical DMA segment */
249
typedef struct {
250
dmaaddr_t addr;
251
uint32 length;
252
} hnddma_seg_t;
253
254
#if defined(MACOSX)
255
/* In MacOS, the OS API may return large number of segments. Setting this number lower
256
* will result in failure of dma map
257
*/
258
#define MAX_DMA_SEGS 8
259
#elif defined(__NetBSD__)
260
/* In NetBSD we also want more segments because the lower level mbuf mapping api might
261
* allocate a large number of segments
262
*/
263
#define MAX_DMA_SEGS 32
264
#elif defined(linux)
265
#define MAX_DMA_SEGS 8
266
#else
267
#define MAX_DMA_SEGS 4
268
#endif
269
270
271
typedef struct {
272
void *oshdmah; /* Opaque handle for OSL to store its information */
273
uint origsize; /* Size of the virtual packet */
274
uint nsegs;
275
hnddma_seg_t segs[MAX_DMA_SEGS];
276
} hnddma_seg_map_t;
277
278
279
/* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).
280
* By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
281
* There is a compile time check in wlc.c which ensure that this value is at least as big
282
* as TXOFF. This value is used in dma_rxfill (hnddma.c).
283
*/
284
285
#if defined(BCM_RPC_NOCOPY) || defined(BCM_RCP_TXNOCOPY)
286
/* add 40 bytes to allow for extra RPC header and info */
287
#define BCMEXTRAHDROOM 260
288
#else /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */
289
#ifdef CTFMAP
290
#define BCMEXTRAHDROOM 208
291
#else /* CTFMAP */
292
#define BCMEXTRAHDROOM 204
293
#endif /* CTFMAP */
294
#endif /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */
295
296
/* Packet alignment for most efficient SDIO (can change based on platform) */
297
#ifndef SDALIGN
298
#define SDALIGN 32
299
#endif
300
301
/* Headroom required for dongle-to-host communication. Packets allocated
302
* locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
303
* leave this much room in front for low-level message headers which may
304
* be needed to get across the dongle bus to the host. (These messages
305
* don't go over the network, so room for the full WL header above would
306
* be a waste.).
307
*/
308
/*
309
* XXX: set the numbers to be MAX of all the devices, to avoid problems with ROM builds
310
* USB BCMDONGLEHDRSZ and BCMDONGLEPADSZ is 0
311
* SDIO BCMDONGLEHDRSZ 12 and BCMDONGLEPADSZ 16
312
*/
313
#define BCMDONGLEHDRSZ 12
314
#define BCMDONGLEPADSZ 16
315
316
#define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)
317
318
#ifdef BCMDBG
319
320
#ifndef BCMDBG_ERR
321
#define BCMDBG_ERR
322
#endif /* BCMDBG_ERR */
323
324
#ifndef BCMDBG_ASSERT
325
#define BCMDBG_ASSERT
326
#endif /* BCMDBG_ASSERT */
327
328
#endif /* BCMDBG */
329
330
#if defined(BCMDBG_ASSERT) || defined(BCMASSERT_LOG)
331
#define BCMASSERT_SUPPORT
332
#endif /* BCMDBG_ASSERT || BCMASSERT_LOG */
333
334
/* Macros for doing definition and get/set of bitfields
335
* Usage example, e.g. a three-bit field (bits 4-6):
336
* #define <NAME>_M BITFIELD_MASK(3)
337
* #define <NAME>_S 4
338
* ...
339
* regval = R_REG(osh, &regs->regfoo);
340
* field = GFIELD(regval, <NAME>);
341
* regval = SFIELD(regval, <NAME>, 1);
342
* W_REG(osh, &regs->regfoo, regval);
343
*/
344
#define BITFIELD_MASK(width) \
345
(((unsigned)1 << (width)) - 1)
346
#define GFIELD(val, field) \
347
(((val) >> field ## _S) & field ## _M)
348
#define SFIELD(val, field, bits) \
349
(((val) & (~(field ## _M << field ## _S))) | \
350
((unsigned)(bits) << field ## _S))
351
352
/* define BCMSMALL to remove misc features for memory-constrained environments */
353
#ifdef BCMSMALL
354
#undef BCMSPACE
355
#define bcmspace FALSE /* if (bcmspace) code is discarded */
356
#else
357
#define BCMSPACE
358
#define bcmspace TRUE /* if (bcmspace) code is retained */
359
#endif
360
361
/* Max. nvram variable table size */
362
#ifndef MAXSZ_NVRAM_VARS
363
#define MAXSZ_NVRAM_VARS 4096 /* XXX should be reduced */
364
#endif
365
366
367
#ifdef EFI
368
#define __attribute__(x) /* CSTYLED */
369
#endif
370
371
#endif /* _bcmdefs_h_ */
372
373