1 #ifndef _NBCOMPAT_H_
2 #define _NBCOMPAT_H_
3 
4 #include <sys/systm.h>
5 #include <sys/module.h>
6 #include <sys/cdefs.h>
7 #include <sys/queue.h>
8 #include <sys/mutex.h>
9 #include <sys/device.h>
10 
11 #define CTLFLAG_RW			CTLFLAG_READWRITE
12 
13 #define mtx				kmutex
14 #define mtx_init(mtx, desc, type, opts)	mutex_init(mtx, MUTEX_DEFAULT, IPL_NONE)
15 
16 #define mtx_lock(mtx)			mutex_enter(mtx)
17 #define mtx_unlock(mtx)			mutex_exit(mtx)
18 
19 #define	mtx_lock_spin(mtx)		mutex_spin_enter(mtx);
20 #define	mtx_unlock_spin(mtx)		mutex_spin_exit(mtx);
21 
22 void mtx_lock(struct mtx *mutex);
23 void mtx_unlock(struct mtx *mutex);
24 
25 #define mtx_destroy(mtx)		mutex_destroy(mtx)
26 
27 /* I don't think this is going to work
28 struct sysctl_ctx_entry {
29 	struct ctlname	*entry;
30 	TAILQ_ENTRY(sysctl_ctx_entry) link;
31 };
32 
33 TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
34 */
35 
36 #define ETHER_ALIGN 2
37 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
38 #ifdef PAE
39 #define BUS_SPACE_MAXADDR	0xFFFFFFFFFULL
40 #else
41 #define BUS_SPACE_MAXADDR	0xFFFFFFFF
42 #endif
43 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
44 #define I386_BUS_SPACE_MEM	x86_bus_space_mem
45 
46 #define device_get_softc	(struct ndis_softc *)
47 #define ticks			hardclock_ticks
48 #define p_siglist		p_sigctx.ps_siglist
49 
50 #ifndef __DECONST
51 #define __DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
52 #endif
53 
54 /* 4096 on x86 */
55 #ifndef PAGE_SIZE
56 #define PAGE_SIZE		4096
57 #endif
58 #define I386_BUS_SPACE_IO	x86_bus_space_io
59 
60 #define device_get_nameunit(dev)	device_xname(dev)
61 
62 /* FreeBSD Loadable Kernel Module commands that have NetBSD counterparts */
63 #define MOD_LOAD 	LKM_E_LOAD
64 #define MOD_UNLOAD	LKM_E_UNLOAD
65 
66 /* ethercom/arpcom */
67 #define ac_if ec_if
68 
69 #ifdef __NetBSD__
70 #define MAX_SYSCTL_LEN 256
71 #endif
72 
73 /* Capabilities that interfaces can advertise. */
74 /* TODO: is this the correct mapping? */
75 #define IFCAP_TXCSUM (IFCAP_CSUM_IPv4_Tx|IFCAP_CSUM_TCPv4_Tx|IFCAP_CSUM_UDPv4_Tx|IFCAP_CSUM_TCPv6_Tx|IFCAP_CSUM_UDPv6_Tx)
76 #define IFCAP_RXCSUM (IFCAP_CSUM_IPv4_Rx|IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_UDPv4_Rx|IFCAP_CSUM_TCPv6_Rx|IFCAP_CSUM_UDPv6_Rx)
77 #define CSUM_IP  M_CSUM_IPv4 /*(IFCAP_CSUM_IPv4_Rx |IFCAP_CSUM_IPv4_Tx)*/
78 #define CSUM_TCP M_CSUM_TCPv4 /*(IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_TCPv4_Tx)*/
79 #define CSUM_UDP M_CSUM_UDPv4 /*(IFCAP_CSUM_UDPv4_Rx|IFCAP_CSUM_UDPv4_Tx)*/
80 
81 typedef vaddr_t			vm_offset_t;
82 typedef vsize_t			vm_size_t;
83 typedef uint16_t		linker_file_t;
84 
85 /* Write our own versions of some FreeBSD functions */
86 struct ndis_resource;
87 #define SYS_RES_IOPORT 0
88 #define SYS_RES_MEMORY 1
89 int     bus_release_resource(device_t dev, int type, int rid,
90                              struct ndis_resource *r);
91 int	device_is_attached(device_t dev);
92 
93 /* This is the same thing as NetBSD's kthread_create1(), except
94  * the stack can be specified.
95  */
96 int
97 ndis_kthread_create(void (*func)(void *), void *arg,
98     struct proc **newpp, void *stack, size_t stacksize, const char *name);
99 
100 #endif /* _NBCOMPAT_H_ */
101