8 #include <KernelExport.h>
12 typedef vint32 MM_ATOMIC_T
;
14 //#define MM_SWAP_LE16(x) B_SWAP_INT16(x)
15 #define MM_SWAP_LE16(x) x
17 /*#define MM_ATOMIC_SET(ptr, val) atomic_and(ptr, 0); atomic_add(ptr,val)
18 #define MM_ATOMIC_READ(ptr) atomic_add(ptr,0)
19 #define MM_ATOMIC_INC(ptr) atomic_add(ptr,1)
20 #define MM_ATOMIC_ADD(ptr, val) atomic_add(ptr,val)
21 #define MM_ATOMIC_DEC(ptr) atomic_add(ptr,-1)
22 #define MM_ATOMIC_SUB(ptr, val) atomic_add(ptr,0-val)*/
24 #define MM_ATOMIC_SET(ptr, val) *(ptr)=val
25 #define MM_ATOMIC_READ(ptr) *(ptr)
26 #define MM_ATOMIC_INC(ptr) (*(ptr))++
27 #define MM_ATOMIC_ADD(ptr, val) *(ptr)+=val
28 #define MM_ATOMIC_DEC(ptr) (*(ptr))--
29 #define MM_ATOMIC_SUB(ptr, val) *(ptr)-=val
31 /* All critical sections are protected by locking mechanisms already */
33 #define __io_virt(x) ((void *)(x))
34 #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
35 #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
36 #define __raw_readl readl
37 #define __raw_writel writel
41 #define MM_MEMWRITEL(ptr, val) __raw_writel(val, ptr)
42 #define MM_MEMREADL(ptr) __raw_readl(ptr)
45 #define mb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)": : :"memory")
48 #define mb() memory_write_barrier()
50 #warning no memory barrier function defined.
56 #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
59 #define MM_WMB() wmb()
63 extern int b44_Packet_Desc_Size
;
65 #define B44_MM_PACKET_DESC_SIZE b44_Packet_Desc_Size
72 LM_DEVICE_BLOCK lm_dev
;
74 struct pci_info pci_data
;
76 sem_id packet_release_sem
;
77 //sem_id interrupt_sem;
78 //thread_id interrupt_handler;
80 LM_RX_PACKET_Q RxPacketReadQ
;
85 area_id lockmem_list
[16];
95 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
101 struct _LM_PACKET pkt
;
107 static inline void b44_MM_MapRxDma(PLM_DEVICE_BLOCK pDevice
,
108 struct _LM_PACKET
*pPacket
,
111 physical_entry entry
;
113 get_memory_map(pPacket
->u
.Rx
.pRxBufferVirt
,pPacket
->u
.Rx
.RxBufferSize
,&entry
,1);
114 *paddr
= entry
.address
;
117 static inline void b44_MM_MapTxDma(PLM_DEVICE_BLOCK pDevice
,
118 struct _LM_PACKET
*pPacket
,
119 LM_UINT32
*paddr
, LM_UINT32
*len
, int frag
)
121 struct B_UM_PACKET
*pkt
= (struct B_UM_PACKET
*)pPacket
;
122 physical_entry entry
;
124 get_memory_map(pkt
->data
,pkt
->size
,&entry
,1);
125 *paddr
= entry
.address
;
126 *len
= pPacket
->PacketSize
;
129 #if (BITS_PER_LONG == 64)
130 #define B44_MM_GETSTATS(_Ctr) \
131 (unsigned long) (_Ctr).Low + ((unsigned long) (_Ctr).High << 32)
133 #define B44_MM_GETSTATS(_Ctr) \
134 (unsigned long) (_Ctr).Low
137 #define B44_MM_PTR(_ptr) ((unsigned long) (_ptr))
138 #define printf(fmt, args...) dprintf(fmt, ##args)
139 #define DbgPrint(fmt, arg...) dprintf(fmt, ##arg)
140 #define DbgBreakPoint()
141 #define b44_MM_Wait(time) udelay(time)
142 #define ASSERT(expr) \
144 dprintf("ASSERT failed: %s\n", #expr); \