Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/bcmdefs.h
Views: 3959
/*1* Misc system wide definitions2*3* $Copyright Open Broadcom Corporation$4*5* $Id: bcmdefs.h 401759 2013-05-13 16:08:08Z sudhirbs $6*/78#ifndef _bcmdefs_h_9#define _bcmdefs_h_1011/*12* One doesn't need to include this file explicitly, gets included automatically if13* typedefs.h is included.14*/1516/* Use BCM_REFERENCE to suppress warnings about intentionally-unused function17* arguments or local variables.18*/19#define BCM_REFERENCE(data) ((void)(data))2021#ifdef EFI22#define STATIC_ASSERT(expr) ASSERT((expr))23#else24/* Compile-time assert can be used in place of ASSERT if the expression evaluates25* to a constant at compile time.26*/27#define STATIC_ASSERT(expr) { \28/* Make sure the expression is constant. */ \29typedef enum { _STATIC_ASSERT_NOT_CONSTANT = (expr) } _static_assert_e; \30/* Make sure the expression is true. */ \31typedef char STATIC_ASSERT_FAIL[(expr) ? 1 : -1]; \32}33#endif3435/* Reclaiming text and data :36* The following macros specify special linker sections that can be reclaimed37* after a system is considered 'up'.38* BCMATTACHFN is also used for detach functions (it's not worth having a BCMDETACHFN,39* as in most cases, the attach function calls the detach function to clean up on error).40*/41#ifdef DONGLEBUILD4243extern bool bcmreclaimed;44extern bool attach_part_reclaimed;4546#define BCMATTACHDATA(_data) __attribute__ ((__section__ (".dataini2." #_data))) _data47#define BCMATTACHFN(_fn) __attribute__ ((__section__ (".textini2." #_fn), noinline)) _fn4849#ifndef PREATTACH_NORECLAIM50#define BCMPREATTACHDATA(_data) __attribute__ ((__section__ (".dataini3." #_data))) _data51#define BCMPREATTACHFN(_fn) __attribute__ ((__section__ (".textini3." #_fn), noinline)) _fn52#else53#define BCMPREATTACHDATA(_data) __attribute__ ((__section__ (".dataini2." #_data))) _data54#define BCMPREATTACHFN(_fn) __attribute__ ((__section__ (".textini2." #_fn), noinline)) _fn55#endif5657#if defined(BCMRECLAIM)58#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini1." #_data))) _data59#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini1." #_fn), noinline)) _fn60#define CONST61#else62#define BCMINITDATA(_data) _data63#define BCMINITFN(_fn) _fn64#define CONST const65#endif6667/* Non-manufacture or internal attach function/dat */68#if !(defined(WLTEST) || defined(BCMINTERNAL))69#define BCMNMIATTACHFN(_fn) BCMATTACHFN(_fn)70#define BCMNMIATTACHDATA(_data) BCMATTACHDATA(_data)71#else72#define BCMNMIATTACHFN(_fn) _fn73#define BCMNMIATTACHDATA(_data) _data74#endif /* WLTEST || BCMINTERNAL */7576#ifdef BCMNODOWN77#define BCMUNINITFN(_fn) BCMINITFN(_fn)78#else79#define BCMUNINITFN(_fn) _fn80#endif8182#define BCMFASTPATH83#else /* DONGLEBUILD */8485#define bcmreclaimed 086#define BCMATTACHDATA(_data) _data87#define BCMATTACHFN(_fn) _fn88#define BCMPREATTACHDATA(_data) _data89#define BCMPREATTACHFN(_fn) _fn90#define BCMINITDATA(_data) _data91#define BCMINITFN(_fn) _fn92#define BCMUNINITFN(_fn) _fn93#define BCMNMIATTACHFN(_fn) _fn94#define BCMNMIATTACHDATA(_data) _data95#define CONST const96#if defined(BCM47XX) && defined(__ARM_ARCH_7A__)97#define BCM47XX_CA998#else99#undef BCM47XX_CA9100#endif101#ifndef BCMFASTPATH102#if defined(mips) || defined(BCM47XX_CA9)103#define BCMFASTPATH __attribute__ ((__section__ (".text.fastpath")))104#define BCMFASTPATH_HOST __attribute__ ((__section__ (".text.fastpath_host")))105#else106#define BCMFASTPATH107#define BCMFASTPATH_HOST108#endif109#endif /* BCMFASTPATH */110111#endif /* DONGLEBUILD */112113#if defined(BCMROMOFFLOAD) || defined(BCMROMBUILD)114typedef struct {115uint16 esiz;116uint16 cnt;117void *addr;118} bcmromdat_patch_t;119#endif120121/* Put some library data/code into ROM to reduce RAM requirements */122#if defined(BCMROMOFFLOAD)123#define BCMROMBASE ((uint32) 0x1e000000)124#define BCMROMEND (BCMROMBASE + (uint32) 0x100000)125126/* These are legacy macros - make them nop's. */127#define BCMROMDATA(_data) _data128#define BCMROMFN(_fn) _fn129130#define STATIC static131132#define BCMROMDAT_NAME(_data) _data133#define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)134#define BCMROMDAT_SIZEOF(data) sizeof(data)135#define BCMROMDAT_APATCH(data) \136bcmromdat_patch_t BCMROMDATA(data##__bcmpatch) = \137{ sizeof(data[0]), sizeof(data)/sizeof(data[0]), ((void*)data) };138#define BCMROMDAT_SPATCH(data) \139bcmromdat_patch_t BCMROMDATA(data##__bcmpatch) = \140{ sizeof(data), 1, ((void*)&data) };141#define BCMROMFN_NAME(_fn) _fn142#elif defined(BCMROMBUILD) && !defined(BCMROMSYMGEN_BUILD) && !defined(BCMJMPTBL_TCAM)143#include <bcmjmptbl.h>144#define STATIC static145#else /* !BCMROMBUILD */146#define BCMROMDATA(_data) _data147#define BCMROMDAT_NAME(_data) _data148#define BCMROMFN(_fn) _fn149#define BCMROMFN_NAME(_fn) _fn150#define STATIC static151#define BCMROMDAT_ARYSIZ(data) ARRAYSIZE(data)152#define BCMROMDAT_SIZEOF(data) sizeof(data)153#define BCMROMDAT_APATCH(data)154#define BCMROMDAT_SPATCH(data)155#endif /* !BCMROMBUILD */156157/* Bus types */158#define SI_BUS 0 /* SOC Interconnect */159#define PCI_BUS 1 /* PCI target */160#define PCMCIA_BUS 2 /* PCMCIA target */161#define SDIO_BUS 3 /* SDIO target */162#define JTAG_BUS 4 /* JTAG */163#define USB_BUS 5 /* USB (does not support R/W REG) */164#define SPI_BUS 6 /* gSPI target */165#define RPC_BUS 7 /* RPC target */166167/* Allows size optimization for single-bus image */168#ifdef BCMBUSTYPE169#define BUSTYPE(bus) (BCMBUSTYPE)170#else171#define BUSTYPE(bus) (bus)172#endif173174/* Allows size optimization for single-backplane image */175#ifdef BCMCHIPTYPE176#define CHIPTYPE(bus) (BCMCHIPTYPE)177#else178#define CHIPTYPE(bus) (bus)179#endif180181182/* Allows size optimization for SPROM support */183#if defined(BCMSPROMBUS)184#define SPROMBUS (BCMSPROMBUS)185#elif defined(SI_PCMCIA_SROM)186#define SPROMBUS (PCMCIA_BUS)187#else188#define SPROMBUS (PCI_BUS)189#endif190191/* Allows size optimization for single-chip image */192/* XXX These macros are NOT meant to encourage writing chip-specific code.193* Use them only when it is appropriate for example in PMU PLL/CHIP/SWREG194* controls and in chip-specific workarounds.195*/196#ifdef BCMCHIPID197#define CHIPID(chip) (BCMCHIPID)198#else199#define CHIPID(chip) (chip)200#endif201202#ifdef BCMCHIPREV203#define CHIPREV(rev) (BCMCHIPREV)204#else205#define CHIPREV(rev) (rev)206#endif207208/* Defines for DMA Address Width - Shared between OSL and HNDDMA */209#define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */210#define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */211#define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */212213#define DMADDRWIDTH_30 30 /* 30-bit addressing capability */214#define DMADDRWIDTH_32 32 /* 32-bit addressing capability */215#define DMADDRWIDTH_63 63 /* 64-bit addressing capability */216#define DMADDRWIDTH_64 64 /* 64-bit addressing capability */217218#ifdef BCMDMA64OSL219typedef struct {220uint32 loaddr;221uint32 hiaddr;222} dma64addr_t;223224typedef dma64addr_t dmaaddr_t;225#define PHYSADDRHI(_pa) ((_pa).hiaddr)226#define PHYSADDRHISET(_pa, _val) \227do { \228(_pa).hiaddr = (_val); \229} while (0)230#define PHYSADDRLO(_pa) ((_pa).loaddr)231#define PHYSADDRLOSET(_pa, _val) \232do { \233(_pa).loaddr = (_val); \234} while (0)235236#else237typedef unsigned long dmaaddr_t;238#define PHYSADDRHI(_pa) (0)239#define PHYSADDRHISET(_pa, _val)240#define PHYSADDRLO(_pa) ((_pa))241#define PHYSADDRLOSET(_pa, _val) \242do { \243(_pa) = (_val); \244} while (0)245#endif /* BCMDMA64OSL */246247/* One physical DMA segment */248typedef struct {249dmaaddr_t addr;250uint32 length;251} hnddma_seg_t;252253#if defined(MACOSX)254/* In MacOS, the OS API may return large number of segments. Setting this number lower255* will result in failure of dma map256*/257#define MAX_DMA_SEGS 8258#elif defined(__NetBSD__)259/* In NetBSD we also want more segments because the lower level mbuf mapping api might260* allocate a large number of segments261*/262#define MAX_DMA_SEGS 32263#elif defined(linux)264#define MAX_DMA_SEGS 8265#else266#define MAX_DMA_SEGS 4267#endif268269270typedef struct {271void *oshdmah; /* Opaque handle for OSL to store its information */272uint origsize; /* Size of the virtual packet */273uint nsegs;274hnddma_seg_t segs[MAX_DMA_SEGS];275} hnddma_seg_map_t;276277278/* packet headroom necessary to accommodate the largest header in the system, (i.e TXOFF).279* By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.280* There is a compile time check in wlc.c which ensure that this value is at least as big281* as TXOFF. This value is used in dma_rxfill (hnddma.c).282*/283284#if defined(BCM_RPC_NOCOPY) || defined(BCM_RCP_TXNOCOPY)285/* add 40 bytes to allow for extra RPC header and info */286#define BCMEXTRAHDROOM 260287#else /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */288#ifdef CTFMAP289#define BCMEXTRAHDROOM 208290#else /* CTFMAP */291#define BCMEXTRAHDROOM 204292#endif /* CTFMAP */293#endif /* BCM_RPC_NOCOPY || BCM_RPC_TXNOCOPY */294295/* Packet alignment for most efficient SDIO (can change based on platform) */296#ifndef SDALIGN297#define SDALIGN 32298#endif299300/* Headroom required for dongle-to-host communication. Packets allocated301* locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should302* leave this much room in front for low-level message headers which may303* be needed to get across the dongle bus to the host. (These messages304* don't go over the network, so room for the full WL header above would305* be a waste.).306*/307/*308* XXX: set the numbers to be MAX of all the devices, to avoid problems with ROM builds309* USB BCMDONGLEHDRSZ and BCMDONGLEPADSZ is 0310* SDIO BCMDONGLEHDRSZ 12 and BCMDONGLEPADSZ 16311*/312#define BCMDONGLEHDRSZ 12313#define BCMDONGLEPADSZ 16314315#define BCMDONGLEOVERHEAD (BCMDONGLEHDRSZ + BCMDONGLEPADSZ)316317#ifdef BCMDBG318319#ifndef BCMDBG_ERR320#define BCMDBG_ERR321#endif /* BCMDBG_ERR */322323#ifndef BCMDBG_ASSERT324#define BCMDBG_ASSERT325#endif /* BCMDBG_ASSERT */326327#endif /* BCMDBG */328329#if defined(BCMDBG_ASSERT) || defined(BCMASSERT_LOG)330#define BCMASSERT_SUPPORT331#endif /* BCMDBG_ASSERT || BCMASSERT_LOG */332333/* Macros for doing definition and get/set of bitfields334* Usage example, e.g. a three-bit field (bits 4-6):335* #define <NAME>_M BITFIELD_MASK(3)336* #define <NAME>_S 4337* ...338* regval = R_REG(osh, ®s->regfoo);339* field = GFIELD(regval, <NAME>);340* regval = SFIELD(regval, <NAME>, 1);341* W_REG(osh, ®s->regfoo, regval);342*/343#define BITFIELD_MASK(width) \344(((unsigned)1 << (width)) - 1)345#define GFIELD(val, field) \346(((val) >> field ## _S) & field ## _M)347#define SFIELD(val, field, bits) \348(((val) & (~(field ## _M << field ## _S))) | \349((unsigned)(bits) << field ## _S))350351/* define BCMSMALL to remove misc features for memory-constrained environments */352#ifdef BCMSMALL353#undef BCMSPACE354#define bcmspace FALSE /* if (bcmspace) code is discarded */355#else356#define BCMSPACE357#define bcmspace TRUE /* if (bcmspace) code is retained */358#endif359360/* Max. nvram variable table size */361#ifndef MAXSZ_NVRAM_VARS362#define MAXSZ_NVRAM_VARS 4096 /* XXX should be reduced */363#endif364365366#ifdef EFI367#define __attribute__(x) /* CSTYLED */368#endif369370#endif /* _bcmdefs_h_ */371372373