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

📄 ntoskernel.h

📁 ndis在linux下的无线网卡驱动源码
💻 H
📖 第 1 页 / 共 3 页
字号:
/* *  Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *  GNU General Public License for more details. * */#ifndef _NTOSKERNEL_H_#define _NTOSKERNEL_H_#include <linux/types.h>#include <linux/timer.h>#include <linux/time.h>#include <linux/module.h>#include <linux/kmod.h>#include <linux/netdevice.h>#include <linux/wireless.h>#include <linux/pci.h>#include <linux/wait.h>#include <linux/pm.h>#include <linux/delay.h>#include <linux/mm.h>#include <linux/random.h>#include <linux/ctype.h>#include <linux/list.h>#include <linux/sched.h>#include <linux/usb.h>#include <linux/spinlock.h>#include <asm/mman.h>#include <linux/version.h>#include <linux/etherdevice.h>#include <net/iw_handler.h>#include <linux/netdevice.h>#include <linux/ethtool.h>#include <linux/if_arp.h>#include <linux/rtnetlink.h>#include <linux/highmem.h>#include "winnt_types.h"#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)#include <linux/kthread.h>#endif/* Interrupt backwards compatibility stuff */#include <linux/interrupt.h>#ifndef IRQ_HANDLED#define IRQ_HANDLED#define IRQ_NONE#define irqreturn_t void#endif/* Workqueue / task queue backwards compatibility stuff */#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)#include <linux/workqueue.h>/* pci functions in 2.6 kernels have problems allocating dma buffers, * but seem to work fine with dma functions */#include <asm/dma-mapping.h>#define PCI_DMA_ALLOC_COHERENT(pci_dev,size,dma_handle)			\	dma_alloc_coherent(&pci_dev->dev,size,dma_handle,		\			   GFP_KERNEL | __GFP_REPEAT)#define PCI_DMA_FREE_COHERENT(pci_dev,size,cpu_addr,dma_handle)		\	dma_free_coherent(&pci_dev->dev,size,cpu_addr,dma_handle)#define PCI_DMA_MAP_SINGLE(pci_dev,addr,size,direction)		\	dma_map_single(&pci_dev->dev,addr,size,direction)#define PCI_DMA_UNMAP_SINGLE(pci_dev,dma_handle,size,direction)		\	dma_unmap_single(&pci_dev->dev,dma_handle,size,direction)#define MAP_SG(pci_dev, sglist, nents, direction)		\	dma_map_sg(&pci_dev->dev, sglist, nents, direction)#define UNMAP_SG(pci_dev, sglist, nents, direction)		\	dma_unmap_sg(&pci_dev->dev, sglist, nents, direction)#else // linux version <= 2.5.41#define PCI_DMA_ALLOC_COHERENT(dev,size,dma_handle)	\	pci_alloc_consistent(dev,size,dma_handle)#define PCI_DMA_FREE_COHERENT(dev,size,cpu_addr,dma_handle)	\	pci_free_consistent(dev,size,cpu_addr,dma_handle)#define PCI_DMA_MAP_SINGLE(dev,addr,size,direction)	\	pci_map_single(dev,addr,size,direction)#define PCI_DMA_UNMAP_SINGLE(dev,dma_handle,size,direction)	\	pci_unmap_single(dev,dma_handle,size,direction)#define MAP_SG(dev, sglist, nents, direction)		\	pci_map_sg(dev, sglist, nents, direction)#define UNMAP_SG(dev, sglist, nents, direction)		\	pci_unmap_sg(dev, sglist, nents, direction)#include <linux/smp_lock.h>/* RedHat kernels define irqs_disabled this way */#ifndef irqs_disabled#define irqs_disabled()                \({                                     \	unsigned long flags;	       \       __save_flags(flags);            \       !(flags & (1<<9));              \})#endif#ifndef in_atomic#ifdef CONFIG_PREEMPT#define in_atomic()					\	((preempt_get_count() & ~PREEMPT_ACTIVE) != 0)#else#define in_atomic() (in_interrupt())#endif // CONFIG_PREEMPT#endif // in_atomic#endif // LINUX_VERSION_CODE/* Wait in wait_state (e.g., TASK_INTERRUPTIBLE) for condition to * become true; timeout is either jiffies (> 0) to wait or 0 to wait * forever. * When timeout == 0, return value is *    > 0 if condition becomes true, or *    < 0 if signal is pending on the thread. * When timeout > 0, return value is *    > 0 if condition becomes true before timeout, *    < 0 if signal is pending on the thread before timeout, or *    0 if timedout (condition may have become true at the same time) */#define wrap_wait_event(condition, timeout, wait_state)		\({								\	long ret = timeout ? timeout : 1;			\	while (!(condition)) {					\		if (signal_pending(current)) {			\			ret = -ERESTARTSYS;			\			break;					\		}						\		set_current_state(wait_state);			\		if (timeout) {					\			ret = schedule_timeout(ret);		\			if (!ret)				\				break;				\		} else						\			schedule();				\	}							\	current->state = TASK_RUNNING;				\	ret;							\})#ifdef USE_OWN_WQtypedef struct {	spinlock_t lock;	struct task_struct *task;	struct completion *completion;	char name[16];	int pid;	/* whether any work_structs pending? <0 implies quit */	int pending;	/* list of work_structs pending */	struct list_head work_list;} workqueue_struct_t;typedef struct {	struct list_head list;	void (*func)(void *data);	void *data;	/* whether/on which workqueue scheduled */	workqueue_struct_t *workq;} work_struct_t;#define initialize_work(work, pfunc, pdata)			\	do {							\		(work)->func = (pfunc);				\		(work)->data = (pdata);				\		(work)->workq = NULL;				\	} while (0)#undef create_singlethread_workqueue#define create_singlethread_workqueue wrap_create_wq#undef destroy_workqueue#define destroy_workqueue wrap_destroy_wq#undef queue_work#define queue_work wrap_queue_work#undef flush_workqueue#define flush_workqueue wrap_flush_wqworkqueue_struct_t *wrap_create_wq(const char *name);void wrap_destroy_wq(workqueue_struct_t *workq);void wrap_queue_work(workqueue_struct_t *workq, work_struct_t *work) wfastcall;void wrap_cancel_work(work_struct_t *work);void wrap_flush_wq(workqueue_struct_t *workq);typedef void *worker_param_t;#define worker_param_data(param, type, member) param#else // USE_OWN_WQtypedef struct workqueue_struct workqueue_struct_t;typedef struct work_struct work_struct_t;#ifdef INIT_WORK_NAR#define initialize_work(work, func, data) INIT_WORK(work, func)typedef struct work_struct *worker_param_t;#define worker_param_data(param, type, member)	\	container_of(param, type, member)#else#define initialize_work(work, func, data) INIT_WORK(work, func, data)typedef void *worker_param_t;#define worker_param_data(param, type, member) param#endif // INIT_WORK_NAR#endif // USE_OWN_WQ#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)#define WRAP_MODULE_PARM_INT(name, perm) module_param(name, int, perm)#define WRAP_MODULE_PARM_STRING(name, perm) module_param(name, charp, perm)#else#define WRAP_MODULE_PARM_INT(name, perm) MODULE_PARM(name, "i")#define WRAP_MODULE_PARM_STRING(name, perm) MODULE_PARM(name, "s")#endif#ifndef LOCK_PREFIX#ifdef LOCK#define LOCK_PREFIX LOCK#else#ifdef CONFIG_SMP#define LOCK_PREFIX "lock ; "#else#define LOCK_PREFIX ""#endif#endif#endif#ifndef NETDEV_TX_OK#define NETDEV_TX_OK 0#endif#ifndef NETDEV_TX_BUSY#define NETDEV_TX_BUSY 1#endif#ifndef CHECKSUM_HW#define CHECKSUM_HW CHECKSUM_PARTIAL#endif/* this ugly hack is to handle RH kernels; I don't know any better, * but this has to be fixed soon */#ifndef rt_task#define rt_task(p) ((p)->prio < MAX_RT_PRIO)#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)#ifndef preempt_enable#define preempt_enable()  do { } while (0)#endif#ifndef preempt_disable#define preempt_disable() do { } while (0)#endif#ifndef preempt_enable_no_resched#define preempt_enable_no_resched() preempt_enable()#endif#ifndef container_of#define container_of(ptr, type, member)					\({									\	const typeof( ((type *)0)->member ) *__mptr = (ptr);		\	(type *)( (char *)__mptr - offsetof(type,member) );		\})#endif#ifndef virt_addr_valid#define virt_addr_valid(addr) VALID_PAGE(virt_to_page(addr))#endif#ifndef SET_NETDEV_DEV#define SET_NETDEV_DEV(net,pdev) do { } while (0)#endif#define usb_set_intfdata(intf, data) do { } while (0)#endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)#ifndef offset_in_page#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,23)#define HAVE_ETHTOOL 1#endif#ifndef PMSG_SUSPEND#ifdef PM_SUSPEND/* this is not correct - the value of PM_SUSPEND is different from * PMSG_SUSPEND, but ndiswrapper doesn't care about the value when * suspending */#define PMSG_SUSPEND PM_SUSPEND#define PSMG_ON PM_ON#elsetypedef u32 pm_message_t;#define PMSG_SUSPEND 2#define PMSG_ON 0#endif#endif#ifndef PCI_D0#define PCI_D0 0#define PCI_D3hot 3#endif#ifndef PM_EVENT_SUSPEND#define PM_EVENT_SUSPEND 2#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)#define pci_choose_state(dev, state) (state)#endif#if !defined(HAVE_NETDEV_PRIV)#define netdev_priv(dev)  ((dev)->priv)#endif#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)#define ISR_PT_REGS_PARAM_DECL#define ISR_PT_REGS_ARG#else#define ISR_PT_REGS_PARAM_DECL , struct pt_regs *regs#define ISR_PT_REGS_ARG , NULL#endif#ifndef flush_icache_range#define flush_icache_range(start, end) do { } while (0)#endif#ifndef CHECKSUM_PARTIAL#define CHECKSUM_PARTIAL CHECKSUM_HW#endif#ifndef IRQF_SHARED#define IRQF_SHARED SA_SHIRQ#endif#define memcpy_skb(skb, from, length)			\	memcpy(skb_put(skb, length), from, length)#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)#define thread_priority(thread) (thread)->nice#define set_thread_priority(thread, prio) (thread)->nice = (prio)#else#define thread_priority(thread) task_nice(thread)#define set_thread_priority(thread, prio) set_user_nice(thread, prio)

⌨️ 快捷键说明

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