⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osapi_linux.h

📁 Linux下SDIO设备的驱动程序
💻 H
字号:
/* * Copyright 2003-2006 Atheros Communications, Inc. * *  Wireless Network driver for Atheros AR6001 * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License version 2 as *  published by the Free Software Foundation; * *  Software distributed under the License is distributed on an "AS *  IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or *  implied. See the License for the specific language governing *  rights and limitations under the License. * * * This file contains the definitions of the basic atheros data types. * It is used to map the data types in atheros files to a platform specific * type. * */#ifndef _OSAPI_LINUX_H_#define _OSAPI_LINUX_H_#include <linux/version.h>#include <linux/types.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/skbuff.h>#include <linux/netdevice.h>#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)#include <linux/jiffies.h>#endif#include <linux/timer.h>#include <linux/delay.h>#include <linux/wait.h>#ifdef KERNEL_2_4#include <asm/arch/irq.h>#include <asm/irq.h>#endif/* * Endianes macros */#define A_BE2CPU8(x)       ntohb(x)#define A_BE2CPU16(x)      ntohs(x)#define A_BE2CPU32(x)      ntohl(x)#define A_LE2CPU8(x)       (x)#define A_LE2CPU16(x)      (x)#define A_LE2CPU32(x)      (x)#define A_CPU2BE8(x)       htonb(x)#define A_CPU2BE16(x)      htons(x)#define A_CPU2BE32(x)      htonl(x)#define A_MEMCPY(dst, src, len)         memcpy((A_UINT8 *)(dst), (src), (len))#define A_MEMZERO(addr, len)            memset(addr, 0, len)#define A_MEMCMP(addr1, addr2, len)     memcmp((addr1), (addr2), (len))#define A_MALLOC(size)                  kmalloc((size), GFP_KERNEL)#define A_MALLOC_NOWAIT(size)           kmalloc((size), GFP_ATOMIC)#define A_FREE(addr)                    kfree(addr)#define A_PRINTF(args...)               printk(args)/* Mutual Exclusion */typedef spinlock_t                      A_MUTEX_T;#define A_MUTEX_INIT(mutex)             spin_lock_init(mutex)#define A_MUTEX_LOCK(mutex)             spin_lock_bh(mutex)#define A_MUTEX_UNLOCK(mutex)           spin_unlock_bh(mutex)/* * Timer Functions */#define A_MDELAY(msecs)                 mdelay(msecs)typedef struct timer_list               A_TIMER;#define A_INIT_TIMER(pTimer, pFunction, pArg) do {              \    init_timer(pTimer);                                         \    (pTimer)->function = (pFunction);                           \    (pTimer)->data	 = (unsigned long)(pArg);                   \} while (0)/* * Start a Timer that elapses after 'periodMSec' milli-seconds * Support is provided for a one-shot timer. The 'repeatFlag' is * ignored. */#define A_TIMEOUT_MS(pTimer, periodMSec, repeatFlag) do {                   \    if (repeatFlag) {                                                       \        printk("\n" __FILE__ ":%d: Timer Repeat requested\n",__LINE__);     \        panic("Timer Repeat");                                              \    }                                                                       \    mod_timer((pTimer), jiffies + HZ * (periodMSec) / 1000);                \} while (0)/* * Cancel the Timer. */#define A_UNTIMEOUT(pTimer) do {                                \    del_timer((pTimer));                                        \} while (0)#define A_DELETE_TIMER(pTimer) do {                             \} while (0)/* * Wait Queue related functions */typedef wait_queue_head_t               A_WAITQUEUE_HEAD;#define A_INIT_WAITQUEUE_HEAD(head)     init_waitqueue_head(head)#ifdef mvlcee31_2_4_20_omap2420_gsm_gprs#ifndef wait_event_interruptible_timeout#define __wait_event_interruptible_timeout(wq, condition, ret)          \do {                                                                    \        wait_queue_t __wait;                                            \        init_waitqueue_entry(&__wait, current);                         \                                                                        \        add_wait_queue(&wq, &__wait);                                   \        for (;;) {                                                      \                set_current_state(TASK_INTERRUPTIBLE);                  \                if (condition)                                          \                        break;                                          \                if (!signal_pending(current)) {                         \                        ret = schedule_timeout(ret);                    \                        if (!ret)                                       \                                break;                                  \                        continue;                                       \                }                                                       \                ret = -ERESTARTSYS;                                     \                break;                                                  \        }                                                               \        current->state = TASK_RUNNING;                                  \        remove_wait_queue(&wq, &__wait);                                \} while (0)#define wait_event_interruptible_timeout(wq, condition, timeout)        \({                                                                      \        long __ret = timeout;                                           \        if (!(condition))                                               \                __wait_event_interruptible_timeout(wq, condition, __ret); \        __ret;                                                          \})#endif /* wait_event_interruptible_timeout */#define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \    wait_event_interruptible_timeout(head, condition, timeout); \} while (0)#else#define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \    wait_event_interruptible_timeout(head, condition, timeout); \} while (0)#endif /* mvlcee31_2_4_20-omap2420_gsm_gprs */#define A_WAKE_UP(head)                 wake_up(head)#ifdef DEBUG#define A_ASSERT(expr)  \    if (!(expr)) {   \        printk( "\n" __FILE__ ":%d: Assertion " #expr " failed!\n",__LINE__); \        panic(#expr); \    }#else#define A_ASSERT(expr)#endif /* DEBUG */#endif /* _OSAPI_LINUX_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -