GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / include / osl.h
blob65bacfa5d9bd080f0707c3a840665afb8022998e
1 /*
2 * OS Abstraction Layer
4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
5 *
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.
9 *
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 $
21 #ifndef _osl_h_
22 #define _osl_h_
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);
37 #ifdef __mips__
38 #define PREF_LOAD 0
39 #define PREF_STORE 1
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) \
50 { \
51 __asm__ __volatile__(\
52 " .set mips4 \n" \
53 " pref %0, (%1) \n" \
54 " .set mips0 \n" \
55 : \
56 : "i" (hint), "r" (addr)); \
59 #define MAKE_PREFETCH_RANGE_FN(hint) \
60 static inline void prefetch_range_##hint(const void *addr, int len) \
61 { \
62 int size = len; \
63 while (size > 0) { \
64 prefetch_##hint(addr); \
65 size -= 32; \
66 } \
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)
81 #endif /* __mips__ */
83 #if defined(__ECOS)
84 #include <ecos_osl.h>
85 #elif defined(DOS)
86 #include <dos_osl.h>
87 #elif defined(PCBIOS)
88 #include <pcbios_osl.h>
89 #elif defined(linux)
90 #include <linux_osl.h>
91 #elif defined(NDIS)
92 #include <ndis_osl.h>
93 #elif defined(_CFE_)
94 #include <cfe_osl.h>
95 #elif defined(_MINOSL_)
96 #include <min_osl.h>
97 #elif defined(MACOSX)
98 #include <macosx_osl.h>
99 #elif defined(__NetBSD__)
100 #include <bsd_osl.h>
101 #elif defined(EFI)
102 #include <efi_osl.h>
103 #elif defined(TARGETOS_nucleus)
104 #include <nucleus_osl.h>
105 #elif defined(TARGETOS_symbian)
106 #include <symbian_osl.h>
107 #else
108 #error "Unsupported OSL requested"
109 #endif
111 #ifndef PKTDBG_TRACE
112 #define PKTDBG_TRACE(osh, pkt, bit)
113 #endif
115 #ifndef PKTCTFMAP
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)))
125 #ifndef AND_REG
126 #define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v))
127 #endif /* !AND_REG */
129 #ifndef OR_REG
130 #define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v))
131 #endif /* !OR_REG */
133 #if !defined(OSL_SYSUPTIME)
134 #define OSL_SYSUPTIME() (0)
135 #define OSL_SYSUPTIME_SUPPORT FALSE
136 #else
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 */
164 #ifndef HNDCTF
165 #define PKTSETCHAINED(osh, skb)
166 #define PKTCLRCHAINED(osh, skb)
167 #define PKTISCHAINED(skb) (FALSE)
168 #endif
170 #endif /* _osl_h_ */