Annotation of src/sys/compat/ndis/nbcompat.h, Revision 1.3
1.1 rittera 1: #ifndef _NBCOMPAT_H_
2: #define _NBCOMPAT_H_
3:
4: #include <sys/systm.h>
5: #include <sys/lkm.h>
6: #include <sys/cdefs.h>
7: #include <sys/queue.h>
1.3 ! rittera 8: #include <sys/device.h>
1.1 rittera 9:
10: #define CTLFLAG_RW CTLFLAG_READWRITE
11:
12: #define mtx lock
13: #define mtx_init(mtx, desc, type, opts) lockinit(mtx, PWAIT, desc, 0, 0/*LK_CANRECURSE*/)
14: /*
15: #define mtx_lock(mtx) ndis_mtx_ipl = splnet() lockmgr(mtx, LK_EXCLUSIVE? LK_SHARED, NULL)
16: #define mtx_unlock(mtx) splx(ndis_mtx_ipl) lockmgr(mtx, LK_RELEASE, NULL)
17: */
18:
19: void mtx_lock(struct mtx *mutex);
20: void mtx_unlock(struct mtx *mutex);
21:
22: #define mtx_destroy(mtx)
23:
24: /* I don't think this is going to work
25: struct sysctl_ctx_entry {
26: struct ctlname *entry;
27: TAILQ_ENTRY(sysctl_ctx_entry) link;
28: };
29:
30: TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
31: */
32:
33: #define ETHER_ALIGN 2
34: #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
35: #ifdef PAE
36: #define BUS_SPACE_MAXADDR 0xFFFFFFFFFULL
37: #else
38: #define BUS_SPACE_MAXADDR 0xFFFFFFFF
39: #endif
40: #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
41: #define I386_BUS_SPACE_MEM 1
42:
43: #define device_get_softc (struct ndis_softc *)
44: #define ticks hardclock_ticks
45: #define p_siglist p_sigctx.ps_siglist
46:
47: #ifndef __DECONST
48: #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
49: #endif
50:
51: /* 4096 on x86 */
52: #ifndef PAGE_SIZE
53: #define PAGE_SIZE 4096
54: #endif
55: #define I386_BUS_SPACE_IO 0
56:
57: #define device_get_nameunit(dev) (dev)->dv_xname
58:
59: int tvtohz(struct timeval *tv);
60:
61: /* FreeBSD Loadable Kernel Module commands that have NetBSD counterparts */
62: #define MOD_LOAD LKM_E_LOAD
63: #define MOD_UNLOAD LKM_E_UNLOAD
64:
65: /* ethercom/arpcom */
66: #define ac_if ec_if
67:
68: #ifdef __NetBSD__
69: #define MAX_SYSCTL_LEN 256
70: #endif
71:
72: /* Capabilities that interfaces can advertise. */
73: /* TODO: is this the correct mapping? */
74: #define IFCAP_TXCSUM (IFCAP_CSUM_IPv4_Tx|IFCAP_CSUM_TCPv4_Tx|IFCAP_CSUM_UDPv4_Tx|IFCAP_CSUM_TCPv6_Tx|IFCAP_CSUM_UDPv6_Tx)
75: #define IFCAP_RXCSUM (IFCAP_CSUM_IPv4_Rx|IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_UDPv4_Rx|IFCAP_CSUM_TCPv6_Rx|IFCAP_CSUM_UDPv6_Rx)
76: #define CSUM_IP M_CSUM_IPv4 /*(IFCAP_CSUM_IPv4_Rx |IFCAP_CSUM_IPv4_Tx)*/
77: #define CSUM_TCP M_CSUM_TCPv4 /*(IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_TCPv4_Tx)*/
78: #define CSUM_UDP M_CSUM_UDPv4 /*(IFCAP_CSUM_UDPv4_Rx|IFCAP_CSUM_UDPv4_Tx)*/
79:
80: typedef vaddr_t vm_offset_t;
81: typedef vsize_t vm_size_t;
82: typedef uint16_t linker_file_t;
83: typedef struct lkm_table * module_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: void device_printf(device_t, const char *fmt, ...);
93:
94: /* This is the same thing as NetBSD's kthread_create1(), except
95: * the stack can be specified.
96: */
97: int
98: ndis_kthread_create(void (*func)(void *), void *arg,
99: struct proc **newpp, void *stack, size_t stacksize, const char *fmt, ...);
100:
101: /*
102: * NetBSD miss some atomic function so we add this function here. Note it
103: * is x86 function ( taken from FreeBSD atomic.h)
104: */
105:
106: static
107: __inline void atomic_add_long(volatile u_long *p, u_long v) {
108: __asm __volatile("lock ; addl %1,%0" : "+m" (*p) : "ir" (v));
109: }
110:
111: static
112: __inline void atomic_subtract_long(volatile u_long *p, u_long v){
113: __asm __volatile("lock ; subl %1,%0" : "+m" (*p) : "ir" (v));
114: }
115:
116: static
117: __inline void atomic_store_rel_int( volatile u_int *p, u_int v){
118: __asm __volatile("xchgl %1,%0" : "+m" (*p), "+r" (v) : : "memory");
119: }
120:
121: static __inline int
122: atomic_cmpset_int(volatile u_int *dst, u_int expe, u_int src)
123: {
124: int res = expe;
125:
126: __asm __volatile(
127: " pushfl ; "
128: " cli ; "
129: " cmpl %0,%2 ; "
130: " jne 1f ; "
131: " movl %1,%2 ; "
132: "1: "
133: " sete %%al; "
134: " movzbl %%al,%0 ; "
135: " popfl ; "
136: "# atomic_cmpset_int"
137: : "+a" (res) /* 0 (result) */
138: : "r" (src), /* 1 */
139: "m" (*(dst)) /* 2 */
140: : "memory");
141:
142: return (res);
143: }
144:
145: #define atomic_cmpset_acq_int atomic_cmpset_int
146:
147: #endif /* _NBCOMPAT_H_ */
CVSweb <webmaster@jp.NetBSD.org>