libsodium: Needed for Dnscrypto-proxy Release 1.3.0
[tomato.git] / release / src / include / bcmdefs.h
blob70e2c92d422bbbd8a670c50f7aec12601b402694
1 /*
2 * Misc system wide definitions
4 * Copyright 2007, Broadcom Corporation
5 * All Rights Reserved.
6 *
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 * $Id$
14 #ifndef _bcmdefs_h_
15 #define _bcmdefs_h_
18 * One doesn't need to include this file explicitly, gets included automatically if
19 * typedefs.h is included.
22 /* Reclaiming text and data :
23 * The following macros specify special linker sections that can be reclaimed
24 * after a system is considered 'up'.
26 #if defined(BCMRECLAIM)
27 extern bool bcmreclaimed;
28 #define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data
29 #define BCMINITFN(_fn) __attribute__ ((noinline, __section__ (".textini." #_fn))) _fn
30 #else
31 #define BCMINITDATA(_data) _data
32 #define BCMINITFN(_fn) _fn
33 #define bcmreclaimed 0
34 #endif
36 /* Reclaim uninit functions if BCMNODOWN is defined */
37 /* and if they are not already removed by -gc-sections */
38 #ifdef BCMNODOWN
39 #define BCMUNINITFN(_fn) BCMINITFN(_fn)
40 #else
41 #define BCMUNINITFN(_fn) _fn
42 #endif
44 #ifdef BCMRECLAIM
45 #define CONST
46 #else
47 #define CONST const
48 #endif /* BCMRECLAIM */
50 /* Put some library data/code into ROM to reduce RAM requirements */
51 #if defined(BCMROMOFFLOAD)
52 #define BCMROMDATA(_data) __attribute__ ((__section__ (".datarom." #_data))) _data
53 #define BCMROMFN(_fn) __attribute__ ((noinline, long_call)) _fn
54 #else
55 #define BCMROMDATA(_data) _data
56 #define BCMROMFN(_fn) _fn
57 #endif
59 /* Bus types */
60 #define SB_BUS 0 /* Silicon Backplane */
61 #define PCI_BUS 1 /* PCI target */
62 #define PCMCIA_BUS 2 /* PCMCIA target */
63 #define SDIO_BUS 3 /* SDIO target */
64 #define JTAG_BUS 4 /* JTAG */
65 #define USB_BUS 5 /* USB (does not support R/W REG) */
67 /* Allows optimization for single-bus support */
68 #ifdef BCMBUSTYPE
69 #define BUSTYPE(bus) (BCMBUSTYPE)
70 #else
71 #define BUSTYPE(bus) (bus)
72 #endif
74 /* Tell where the SPROM is hanging off */
75 #if defined(BCMSPROMBUS)
76 #define SPROMBUS (BCMSPROMBUS)
77 #elif defined(SB_PCMCIA_SROM)
78 #define SPROMBUS (PCMCIA_BUS)
79 #else
80 #define SPROMBUS (PCI_BUS)
81 #endif
83 /* Defines for DMA Address Width - Shared between OSL and HNDDMA */
84 #define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
85 #define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
86 #define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
88 #define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
89 #define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
90 #define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
91 #define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
93 /* packet headroom necessary to accomodate the largest header in the system, (i.e TXOFF).
94 * By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
95 * There is a compile time check in wlc.c which ensure that this value is at least as big
96 * as TXOFF. This value is used in dma_rxfill (hnddma.c).
98 #define BCMEXTRAHDROOM 164
100 /* Headroom required for dongle-to-host communication. Packets allocated
101 * locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
102 * leave this much room in front for low-level message headers which may
103 * be needed to get across the dongle bus to the host. (These messages
104 * don't go over the network, so room for the full WL header above would
105 * be a waste.).
107 #ifdef BCMUSBDEV
108 #define BCMDONGLEHDRSZ 0
109 #else
110 #define BCMDONGLEHDRSZ 8
111 #endif
114 /* Brett's nifty macros for doing definition and get/set of bitfields
115 * Usage example, e.g. a three-bit field (bits 4-6):
116 * #define <NAME>_M BITFIELD_MASK(3)
117 * #define <NAME>_S 4
118 * ...
119 * regval = R_REG(osh, &regs->regfoo);
120 * field = GFIELD(regval, <NAME>);
121 * regval = SFIELD(regval, <NAME>, 1);
122 * W_REG(osh, &regs->regfoo, regval);
124 #define BITFIELD_MASK(width) ((1 << width)-1)
125 #define GFIELD(val, field) ((val >> field ## _S) & field ## _M)
126 #define SFIELD(val, field, bits) ((val & (~(field ## _M << field ## _S))) | (bits << field ## _S))
128 /* define BCMSMALL to remove misc features for memory constrained enviroments */
129 #ifdef BCMSMALL
130 #undef BCMSPACE
131 #define bcmspace FALSE /* if (bcmspace) code is discarded */
132 #else
133 #define BCMSPACE
134 #define bcmspace TRUE /* if (bcmspace) code is retained */
135 #endif
137 /* Max. nvram variable table size */
138 #define MAXSZ_NVRAM_VARS 4096
140 #endif /* _bcmdefs_h_ */