00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _LINUX_K_COMPAT_H
00020 #define _LINUX_K_COMPAT_H
00021
00022 #define __LINUX__
00023 #define VERSION(v,p,s) (((v)<<16)+(p<<8)+s)
00024
00025 #define RUN_AT(x) (jiffies+(x))
00026 #define CONST const
00027 #define ALLOC_SKB(len) dev_alloc_skb(len+2)
00028 #define DEVICE(req) ((req)->rq_dev)
00029 #define GET_PACKET(dev, skb, count) \
00030 skb_reserve((skb), 2); \
00031 BLOCK_INPUT(skb_put((skb), (count)), (count)); \
00032 (skb)->protocol = eth_type_trans((skb), (dev))
00033
00034 #define BLK_DEV_HDR "linux/blk.h"
00035 #define NEW_MULTICAST
00036
00037 #define FREE_IRQ(i,d) free_irq(i, d)
00038 #define REQUEST_IRQ(i,h,f,n,d) request_irq(i,h,f,n,d)
00039 #define IRQ(a,b,c) (a,b,c)
00040 #define DEV_ID dev_id
00041
00042 #if (LINUX_VERSION_CODE < VERSION(2,0,16))
00043 #define init_waitqueue(p) (*(p) = NULL)
00044 #endif
00045
00046 #if (LINUX_VERSION_CODE < VERSION(2,1,4)) && !defined(__alpha__)
00047 #define FS_SIZE_T int
00048 #define U_FS_SIZE_T int
00049 #else
00050 #if (LINUX_VERSION_CODE < VERSION(2,1,60))
00051 #define FS_SIZE_T long
00052 #define U_FS_SIZE_T unsigned long
00053 #else
00054 #define FS_SIZE_T ssize_t
00055 #define U_FS_SIZE_T size_t
00056 #endif
00057 #endif
00058
00059 #if (LINUX_VERSION_CODE < VERSION(2,1,25))
00060 #define net_device_stats enet_statistics
00061 #endif
00062
00063 #if (LINUX_VERSION_CODE < VERSION(2,1,31))
00064 #define FS_RELEASE_T void
00065 #else
00066 #define FS_RELEASE_T int
00067 #endif
00068
00069 #if (LINUX_VERSION_CODE < VERSION(2,1,38))
00070 #define test_and_set_bit set_bit
00071 #endif
00072
00073 #if (LINUX_VERSION_CODE > VERSION(2,1,16))
00074 #define AUTOCONF_INCLUDED
00075 #define EXPORT_SYMTAB
00076 #endif
00077 #ifdef CONFIG_MODVERSIONS
00078 #define MODVERSIONS 1
00079 #include <linux/modversions.h>
00080 #endif
00081 #include <linux/module.h>
00082
00083 #if (LINUX_VERSION_CODE < VERSION(2,1,18))
00084 #define MODULE_PARM(a,b) extern int __bogus_decl
00085 #undef GET_USE_COUNT
00086 #define GET_USE_COUNT(m) mod_use_count_
00087 #endif
00088
00089 #if (LINUX_VERSION_CODE < VERSION(2,1,0))
00090 #define copy_from_user memcpy_fromfs
00091 #define copy_to_user memcpy_tofs
00092
00093 #if (!defined(__alpha__) || (LINUX_VERSION_CODE < VERSION(2,0,34)))
00094 #define ioremap(a,b) \
00095 (((a) < 0x100000) ? (void *)((u_long)(a)) : vremap(a,b))
00096 #define iounmap(v) \
00097 do { if ((u_long)(v) > 0x100000) vfree(v); } while (0)
00098 #endif
00099
00100 #include <asm/segment.h>
00101 #undef get_user
00102
00103 #ifdef __alpha__
00104 #define get_user(x, ptr) ((x) = __get_user((ptr), sizeof(*(ptr))))
00105 #undef get_fs_long
00106 #undef put_fs_long
00107 #define get_fs_long(ptr) __get_user((ptr), sizeof(int))
00108 #define put_fs_long(x, ptr) __put_user((x), (ptr), sizeof(int))
00109 #else
00110 #define get_user(x, ptr) \
00111 ((sizeof(*ptr) == 4) ? (x = get_fs_long(ptr)) : \
00112 (sizeof(*ptr) == 2) ? (x = get_fs_word(ptr)) : \
00113 (x = get_fs_byte(ptr)))
00114 #endif
00115
00116 #else
00117 #include <asm/uaccess.h>
00118 #endif
00119
00120 #if (LINUX_VERSION_CODE < VERSION(2,1,45))
00121 #define F_INODE(file) ((file)->f_inode)
00122 #else
00123 #define F_INODE(file) ((file)->f_dentry->d_inode)
00124 #endif
00125
00126 #if (LINUX_VERSION_CODE < VERSION(2,1,51))
00127 #define INVALIDATE_INODES(r) invalidate_inodes(r)
00128 #else
00129 #define INVALIDATE_INODES(r) \
00130 do { struct super_block *sb = get_super(r); \
00131 if (sb) invalidate_inodes(sb); } while (0)
00132 #endif
00133
00134 #if (LINUX_VERSION_CODE < VERSION(2,1,60))
00135 #define IRQ_MAP(irq, dev) irq2dev_map[irq] = dev
00136 #define FOPS(i,f,b,c,p) (i,f,b,c)
00137 #define FPOS (file->f_pos)
00138 #else
00139 #define IRQ_MAP(irq, dev) while (0)
00140 #define FOPS(i,f,b,c,p) (f,b,c,p)
00141 #define FPOS (*ppos)
00142 #endif
00143
00144 #if (LINUX_VERSION_CODE < VERSION(2,1,68))
00145 #define signal_pending(cur) ((cur)->signal & ~(cur)->blocked)
00146 #endif
00147
00148 #if (LINUX_VERSION_CODE < VERSION(2,1,86))
00149 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb, FREE_WRITE)
00150 #else
00151 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
00152 #endif
00153
00154 #if (LINUX_VERSION_CODE < VERSION(2,1,89))
00155 #define POLL_WAIT(f, q, w) poll_wait(q, w)
00156 #else
00157 #define POLL_WAIT(f, q, w) poll_wait(f, q, w)
00158 #endif
00159
00160 #include <asm/byteorder.h>
00161 #ifndef le16_to_cpu
00162 #define le16_to_cpu(x) (x)
00163 #define le32_to_cpu(x) (x)
00164 #define cpu_to_le16(x) (x)
00165 #define cpu_to_le32(x) (x)
00166 #endif
00167
00168 #if (LINUX_VERSION_CODE < VERSION(2,1,90))
00169 #define spin_lock(l) do { } while (0)
00170 #define spin_unlock(l) do { } while (0)
00171 #define spin_lock_irqsave(l,f) do { save_flags(f); cli(); } while (0)
00172 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
00173 #else
00174 #include <asm/spinlock.h>
00175 #endif
00176
00177 #if (LINUX_VERSION_CODE < VERSION(2,1,104))
00178 #define mdelay(x) { int i; for (i=0;i<x;i++) udelay(1000); }
00179 #endif
00180
00181 #define wacquire(w) do { } while (0)
00182 #define wrelease(w) do { } while (0)
00183 #define wsleep(w) interruptible_sleep_on(w)
00184 #define wakeup(w) wake_up_interruptible(w)
00185 #define wsleeptimeout(w,t) interruptible_sleep_on_timeout(w,t)
00186 #if (LINUX_VERSION_CODE < VERSION(2,1,127))
00187 #define interruptible_sleep_on_timeout(w,t) \
00188 ({(current->timeout=jiffies+(t));wsleep(w);current->timeout;})
00189 #define schedule_timeout(t) \
00190 do { current->timeout = jiffies+(t); schedule(); } while (0)
00191 #endif
00192
00193 #include <asm/io.h>
00194 #ifndef readw_ns
00195 #ifdef __powerpc__
00196 #define readw_ns(p) ld_be16((volatile unsigned short *)(p))
00197 #define readl_ns(p) ld_be32((volatile unsigned *)(p))
00198 #define writew_ns(v,p) st_le16((volatile unsigned short *)(p),(v))
00199 #define writel_ns(v,p) st_le32((volatile unsigned *)(p),(v))
00200 #define inw_ns(p) in_be16((unsigned short *)((p)+_IO_BASE))
00201 #define inl_ns(p) in_be32((unsigned *)((p)+_IO_BASE))
00202 #define outw_ns(v,p) out_be16((unsigned short *)((p)+_IO_BASE),(v))
00203 #define outl_ns(v,p) out_be32((unsigned *)((p)+_IO_BASE),(v))
00204 #else
00205 #define readw_ns(p) readw(p)
00206 #define readl_ns(p) readl(p)
00207 #define writew_ns(v,p) writew(v,p)
00208 #define writel_ns(v,p) writel(v,p)
00209 #define inw_ns(p) inw(p)
00210 #define inl_ns(p) inl(p)
00211 #define outw_ns(v,p) outw(v,p)
00212 #define outl_ns(v,p) outl(v,p)
00213 #endif
00214 #endif
00215 #ifndef insw_ns
00216 #define insw_ns(p,b,l) insw(p,b,l)
00217 #define insl_ns(p,b,l) insl(p,b,l)
00218 #define outsw_ns(p,b,l) outsw(p,b,l)
00219 #define outsl_ns(p,b,l) outsl(p,b,l)
00220 #endif
00221
00222 #if (LINUX_VERSION_CODE < VERSION(2,1,93))
00223 #include <linux/bios32.h>
00224 #endif
00225 #include <linux/pci.h>
00226 #ifndef PCI_FUNC
00227 #define PCI_FUNC(devfn) ((devfn)&7)
00228 #define PCI_SLOT(devfn) ((devfn)>>3)
00229 #define PCI_DEVFN(dev,fn) (((dev)<<3)|((fn)&7))
00230 #endif
00231
00232 #if (LINUX_VERSION_CODE > VERSION(2,1,117))
00233 #define NULL_FLUSH NULL,
00234 #else
00235 #define NULL_FLUSH
00236 #endif
00237
00238 #if (LINUX_VERSION_CODE < VERSION(2,1,126))
00239 #define SCSI_DISK0_MAJOR SCSI_DISK_MAJOR
00240 #endif
00241
00242 typedef unsigned long k_time_t;
00243 #define ACQUIRE_RESOURCE_LOCK do {} while (0)
00244 #define RELEASE_RESOURCE_LOCK do {} while (0)
00245
00246 #endif