1/* 2 * OS Abstraction Layer 3 * 4 * Copyright (C) 2013, 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. 17 * 18 * $Id: osl.h 401759 2013-05-13 16:08:08Z $ 19 */ 20 21#ifndef _osl_h_ 22#define _osl_h_ 23 24/* osl handle type forward declaration */ 25typedef struct osl_info osl_t; 26typedef struct osl_dmainfo osldma_t; 27 28#ifdef MACOSX 29#define OSL_PKTTAG_SZ 56 30#else 31#define OSL_PKTTAG_SZ 32 /* Size of PktTag */ 32#endif 33 34/* Drivers use PKTFREESETCB to register a callback function when a packet is freed by OSL */ 35typedef void (*pktfree_cb_fn_t)(void *ctx, void *pkt, unsigned int status); 36 37/* Drivers use REGOPSSET() to register register read/write funcitons */ 38typedef unsigned int (*osl_rreg_fn_t)(void *ctx, volatile void *reg, unsigned int size); 39typedef void (*osl_wreg_fn_t)(void *ctx, volatile void *reg, unsigned int val, unsigned int size); 40 41#ifdef __mips__ 42#define PREF_LOAD 0 43#define PREF_STORE 1 44#define PREF_LOAD_STREAMED 4 45#define PREF_STORE_STREAMED 5 46#define PREF_LOAD_RETAINED 6 47#define PREF_STORE_RETAINED 7 48#define PREF_WBACK_INV 25 49#define PREF_PREPARE4STORE 30 50 51 52#define MAKE_PREFETCH_FN(hint) \ 53static inline void prefetch_##hint(const void *addr) \ 54{ \ 55 __asm__ __volatile__(\ 56 " .set mips4 \n" \ 57 " pref %0, (%1) \n" \ 58 " .set mips0 \n" \ 59 : \ 60 : "i" (hint), "r" (addr)); \ 61} 62 63#define MAKE_PREFETCH_RANGE_FN(hint) \ 64static inline void prefetch_range_##hint(const void *addr, int len) \ 65{ \ 66 int size = len; \ 67 while (size > 0) { \ 68 prefetch_##hint(addr); \ 69 size -= 32; \ 70 } \ 71} 72 73MAKE_PREFETCH_FN(PREF_LOAD) 74MAKE_PREFETCH_RANGE_FN(PREF_LOAD) 75MAKE_PREFETCH_FN(PREF_STORE) 76MAKE_PREFETCH_RANGE_FN(PREF_STORE) 77MAKE_PREFETCH_FN(PREF_LOAD_STREAMED) 78MAKE_PREFETCH_RANGE_FN(PREF_LOAD_STREAMED) 79MAKE_PREFETCH_FN(PREF_STORE_STREAMED) 80MAKE_PREFETCH_RANGE_FN(PREF_STORE_STREAMED) 81MAKE_PREFETCH_FN(PREF_LOAD_RETAINED) 82MAKE_PREFETCH_RANGE_FN(PREF_LOAD_RETAINED) 83MAKE_PREFETCH_FN(PREF_STORE_RETAINED) 84MAKE_PREFETCH_RANGE_FN(PREF_STORE_RETAINED) 85#endif /* __mips__ */ 86 87#if defined(__ECOS) 88#include <ecos_osl.h> 89#elif defined(DOS) 90#include <dos_osl.h> 91#elif defined(PCBIOS) 92#include <pcbios_osl.h> 93#elif defined(linux) 94#include <linux_osl.h> 95#elif defined(NDIS) 96#include <ndis_osl.h> 97#elif defined(_CFE_) 98#include <cfe_osl.h> 99#elif defined(_HNDRTE_) 100#include <hndrte_osl.h> 101#elif defined(_MINOSL_) 102#include <min_osl.h> 103#elif defined(MACOSX) 104#include <macosx_osl.h> 105#elif defined(__NetBSD__) 106#include <bsd_osl.h> 107#elif defined(EFI) 108#include <efi_osl.h> 109#elif defined(TARGETOS_nucleus) 110#include <nucleus_osl.h> 111#elif defined(TARGETOS_symbian) 112#include <symbian_osl.h> 113#else 114#error "Unsupported OSL requested" 115#endif 116 117#ifndef PKTDBG_TRACE 118#define PKTDBG_TRACE(osh, pkt, bit) 119#endif 120 121#ifndef PKTCTFMAP 122#define PKTCTFMAP(osh, p) 123#endif /* PKTCTFMAP */ 124 125/* -------------------------------------------------------------------------- 126** Register manipulation macros. 127*/ 128 129#define SET_REG(osh, r, mask, val) W_REG((osh), (r), ((R_REG((osh), r) & ~(mask)) | (val))) 130 131#ifndef AND_REG 132#define AND_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) & (v)) 133#endif /* !AND_REG */ 134 135#ifndef OR_REG 136#define OR_REG(osh, r, v) W_REG(osh, (r), R_REG(osh, r) | (v)) 137#endif /* !OR_REG */ 138 139#if !defined(OSL_SYSUPTIME) 140#define OSL_SYSUPTIME() (0) 141#define OSL_SYSUPTIME_SUPPORT FALSE 142#else 143#define OSL_SYSUPTIME_SUPPORT TRUE 144#endif /* OSL_SYSUPTIME */ 145 146#if !(defined(linux) && defined(PKTC)) && !defined(PKTC_DONGLE) 147#define PKTCGETATTR(s) (0) 148#define PKTCSETATTR(skb, f, p, b) 149#define PKTCCLRATTR(skb) 150#define PKTCCNT(skb) (1) 151#define PKTCLEN(skb) PKTLEN(NULL, skb) 152#define PKTCGETFLAGS(skb) (0) 153#define PKTCSETFLAGS(skb, f) 154#define PKTCCLRFLAGS(skb) 155#define PKTCFLAGS(skb) (0) 156#define PKTCSETCNT(skb, c) 157#define PKTCINCRCNT(skb) 158#define PKTCADDCNT(skb, c) 159#define PKTCSETLEN(skb, l) 160#define PKTCADDLEN(skb, l) 161#define PKTCSETFLAG(skb, fb) 162#define PKTCCLRFLAG(skb, fb) 163#define PKTCLINK(skb) NULL 164#define PKTSETCLINK(skb, x) 165#define FOREACH_CHAINED_PKT(skb, nskb) \ 166 for ((nskb) = NULL; (skb) != NULL; (skb) = (nskb)) 167#define PKTCFREE PKTFREE 168#endif /* !linux || !PKTC */ 169 170#ifndef HNDCTF 171#define PKTSETCHAINED(osh, skb) 172#define PKTCLRCHAINED(osh, skb) 173#define PKTISCHAINED(skb) (FALSE) 174#endif 175 176#endif /* _osl_h_ */ 177