Resync with broadcom drivers 5.100.138.20 and utilities.
[tomato.git] / release / src-rt / include / osl.h
blobdfed1b154579c024284b4fab0672c8b2a79fccea
1 /*
2 * OS Abstraction Layer
4 * Copyright (C) 2010, 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,v 13.45.2.2 2010-08-31 00:29:57 Exp $
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, void *reg, unsigned int size);
35 typedef void (*osl_wreg_fn_t)(void *ctx, 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
47 #define MAKE_PREFETCH_FN(hint) \
48 static inline void prefetch_##hint(const void *addr) \
49 { \
50 __asm__ __volatile__(\
51 " .set mips4 \n" \
52 " pref %0, (%1) \n" \
53 " .set mips0 \n" \
54 : \
55 : "i" (hint), "r" (addr)); \
58 #define MAKE_PREFETCH_RANGE_FN(hint) \
59 static inline void prefetch_range_##hint(const void *addr, int len) \
60 { \
61 int size = len; \
62 while (size > 0) { \
63 prefetch_##hint(addr); \
64 size -= 32; \
65 } \
68 MAKE_PREFETCH_FN(PREF_LOAD)
69 MAKE_PREFETCH_RANGE_FN(PREF_LOAD)
70 MAKE_PREFETCH_FN(PREF_STORE)
71 MAKE_PREFETCH_RANGE_FN(PREF_STORE)
72 MAKE_PREFETCH_FN(PREF_LOAD_STREAMED)
73 MAKE_PREFETCH_RANGE_FN(PREF_LOAD_STREAMED)
74 MAKE_PREFETCH_FN(PREF_STORE_STREAMED)
75 MAKE_PREFETCH_RANGE_FN(PREF_STORE_STREAMED)
76 MAKE_PREFETCH_FN(PREF_LOAD_RETAINED)
77 MAKE_PREFETCH_RANGE_FN(PREF_LOAD_RETAINED)
78 MAKE_PREFETCH_FN(PREF_STORE_RETAINED)
79 MAKE_PREFETCH_RANGE_FN(PREF_STORE_RETAINED)
80 #endif /* __mips__ */
82 #if defined(__ECOS)
83 #include <ecos_osl.h>
84 #elif defined(DOS)
85 #include <dos_osl.h>
86 #elif defined(PCBIOS)
87 #include <pcbios_osl.h>
88 #elif defined(linux)
89 #ifdef USER_MODE
90 #include <usermode_osl.h>
91 #else
92 #include <linux_osl.h>
93 #endif
94 #elif defined(NDIS)
95 #include <ndis_osl.h>
96 #elif defined(_CFE_)
97 #include <cfe_osl.h>
98 #elif defined(_MINOSL_)
99 #include <min_osl.h>
100 #elif defined(MACOSX)
101 #include <macosx_osl.h>
102 #elif defined(__NetBSD__)
103 #include <bsd_osl.h>
104 #elif defined(EFI)
105 #include <efi_osl.h>
106 #elif defined(TARGETOS_nucleus)
107 #include <nucleus_osl.h>
108 #else
109 #error "Unsupported OSL requested"
110 #endif
112 #ifndef PKTDBG_TRACE
113 #define PKTDBG_TRACE(osh, pkt, bit)
114 #endif
116 /* --------------------------------------------------------------------------
117 ** Register manipulation macros.
120 #define SET_REG(osh, r, mask, val) W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val)))
122 #ifndef AND_REG
123 #define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v))
124 #endif /* !AND_REG */
126 #ifndef OR_REG
127 #define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v))
128 #endif /* !OR_REG */
130 #if !defined(OSL_SYSUPTIME)
131 #define OSL_SYSUPTIME() (0)
132 #define OSL_SYSUPTIME_SUPPORT FALSE
133 #else
134 #define OSL_SYSUPTIME_SUPPORT TRUE
135 #endif /* OSL_SYSUPTIME */
137 #endif /* _osl_h_ */