4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 * $Id: osl.h 377094 2013-01-04 03:11:57Z $
24 /* osl handle type forward declaration */
25 typedef struct osl_info osl_t
;
26 typedef struct osl_dmainfo osldma_t
;
28 #define OSL_PKTTAG_SZ 32 /* Size of PktTag */
30 /* Drivers use PKTFREESETCB to register a callback function when a packet is freed by OSL */
31 typedef void (*pktfree_cb_fn_t
)(void *ctx
, void *pkt
, unsigned int status
);
33 /* Drivers use REGOPSSET() to register register read/write funcitons */
34 typedef unsigned int (*osl_rreg_fn_t
)(void *ctx
, volatile void *reg
, unsigned int size
);
35 typedef void (*osl_wreg_fn_t
)(void *ctx
, volatile void *reg
, unsigned int val
, unsigned int size
);
40 #define PREF_LOAD_STREAMED 4
41 #define PREF_STORE_STREAMED 5
42 #define PREF_LOAD_RETAINED 6
43 #define PREF_STORE_RETAINED 7
44 #define PREF_WBACK_INV 25
45 #define PREF_PREPARE4STORE 30
48 #define MAKE_PREFETCH_FN(hint) \
49 static inline void prefetch_##hint(const void *addr) \
51 __asm__ __volatile__(\
56 : "i" (hint), "r" (addr)); \
59 #define MAKE_PREFETCH_RANGE_FN(hint) \
60 static inline void prefetch_range_##hint(const void *addr, int len) \
64 prefetch_##hint(addr); \
69 MAKE_PREFETCH_FN(PREF_LOAD
)
70 MAKE_PREFETCH_RANGE_FN(PREF_LOAD
)
71 MAKE_PREFETCH_FN(PREF_STORE
)
72 MAKE_PREFETCH_RANGE_FN(PREF_STORE
)
73 MAKE_PREFETCH_FN(PREF_LOAD_STREAMED
)
74 MAKE_PREFETCH_RANGE_FN(PREF_LOAD_STREAMED
)
75 MAKE_PREFETCH_FN(PREF_STORE_STREAMED
)
76 MAKE_PREFETCH_RANGE_FN(PREF_STORE_STREAMED
)
77 MAKE_PREFETCH_FN(PREF_LOAD_RETAINED
)
78 MAKE_PREFETCH_RANGE_FN(PREF_LOAD_RETAINED
)
79 MAKE_PREFETCH_FN(PREF_STORE_RETAINED
)
80 MAKE_PREFETCH_RANGE_FN(PREF_STORE_RETAINED
)
88 #include <pcbios_osl.h>
90 #include <linux_osl.h>
95 #elif defined(_MINOSL_)
98 #include <macosx_osl.h>
99 #elif defined(__NetBSD__)
103 #elif defined(TARGETOS_nucleus)
104 #include <nucleus_osl.h>
105 #elif defined(TARGETOS_symbian)
106 #include <symbian_osl.h>
108 #error "Unsupported OSL requested"
112 #define PKTDBG_TRACE(osh, pkt, bit)
116 #define PKTCTFMAP(osh, p)
117 #endif /* PKTCTFMAP */
119 /* --------------------------------------------------------------------------
120 ** Register manipulation macros.
123 #define SET_REG(osh, r, mask, val) W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val)))
126 #define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v))
127 #endif /* !AND_REG */
130 #define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v))
133 #if !defined(OSL_SYSUPTIME)
134 #define OSL_SYSUPTIME() (0)
135 #define OSL_SYSUPTIME_SUPPORT FALSE
137 #define OSL_SYSUPTIME_SUPPORT TRUE
138 #endif /* OSL_SYSUPTIME */
140 #if !(defined(linux) && defined(PKTC)) && !defined(PKTC_DONGLE)
141 #define PKTCGETATTR(s) (0)
142 #define PKTCSETATTR(skb, f, p, b)
143 #define PKTCCLRATTR(skb)
144 #define PKTCCNT(skb) (1)
145 #define PKTCLEN(skb) PKTLEN(NULL, skb)
146 #define PKTCGETFLAGS(skb) (0)
147 #define PKTCSETFLAGS(skb, f)
148 #define PKTCCLRFLAGS(skb)
149 #define PKTCFLAGS(skb) (0)
150 #define PKTCSETCNT(skb, c)
151 #define PKTCINCRCNT(skb)
152 #define PKTCADDCNT(skb, c)
153 #define PKTCSETLEN(skb, l)
154 #define PKTCADDLEN(skb, l)
155 #define PKTCSETFLAG(skb, fb)
156 #define PKTCCLRFLAG(skb, fb)
157 #define PKTCLINK(skb) NULL
158 #define PKTSETCLINK(skb, x)
159 #define FOREACH_CHAINED_PKT(skb, nskb) \
160 for ((nskb) = NULL; (skb) != NULL; (skb) = (nskb))
161 #define PKTCFREE PKTFREE
162 #endif /* !linux || !PKTC */
165 #define PKTSETCHAINED(osh, skb)
166 #define PKTCLRCHAINED(osh, skb)
167 #define PKTISCHAINED(skb) (FALSE)