1
2 #ifndef _IEEE1394_TYPES_H
3 #define _IEEE1394_TYPES_H
4
5 #include <linux/kernel.h>
6 #include <linux/types.h>
7 #include <linux/version.h>
8 #include <linux/list.h>
9 #include <linux/init.h>
10 #include <linux/spinlock.h>
11 #include <asm/semaphore.h>
12 #include <asm/byteorder.h>
13
14
15 #ifndef BITS_TO_LONGS /* < 2.4.21-pre6 */
16 #define BITS_TO_LONGS(bits) \
17 (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
18 #define DECLARE_BITMAP(name,bits) \
19 unsigned long name[BITS_TO_LONGS(bits)]
20 #define CLEAR_BITMAP(name,bits) \
21 memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
22 #endif
23
24
25 /* Transaction Label handling */
26 struct hpsb_tlabel_pool {
27 DECLARE_BITMAP(pool, 64);
28 spinlock_t lock;
29 u8 next;
30 u32 allocations;
31 struct semaphore count;
32 };
33
34 #define HPSB_TPOOL_INIT(_tp) \
35 do { \
36 CLEAR_BITMAP((_tp)->pool, 64); \
37 spin_lock_init(&(_tp)->lock); \
38 (_tp)->next = 0; \
39 (_tp)->allocations = 0; \
40 sema_init(&(_tp)->count, 63); \
41 } while (0)
42
43
44 typedef u32 quadlet_t;
45 typedef u64 octlet_t;
46 typedef u16 nodeid_t;
47
48 typedef u8 byte_t;
49 typedef u64 nodeaddr_t;
50 typedef u16 arm_length_t;
51
52 #define BUS_MASK 0xffc0
53 #define BUS_SHIFT 6
54 #define NODE_MASK 0x003f
55 #define LOCAL_BUS 0xffc0
56 #define ALL_NODES 0x003f
57
58 #define NODEID_TO_BUS(nodeid) ((nodeid & BUS_MASK) >> BUS_SHIFT)
59 #define NODEID_TO_NODE(nodeid) (nodeid & NODE_MASK)
60
61 /* Can be used to consistently print a node/bus ID. */
62 #define NODE_BUS_FMT "%d-%02d:%04d"
63 #define NODE_BUS_ARGS(__host, __nodeid) \
64 __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid)
65
66 #define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "\n" , ## args)
67
68 #define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
69 #define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
70 #define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
71 #define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
72 #define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
73
74 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
75 #define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
76 #else
77 #define HPSB_VERBOSE(fmt, args...)
78 #endif
79
80 #define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args)
81
82 #define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
83
84
85 #ifdef __BIG_ENDIAN
86
memcpy_le32(u32 * dest,const u32 * __src,size_t count)87 static __inline__ void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
88 {
89 void *tmp = dest;
90 u32 *src = (u32 *)__src;
91
92 count /= 4;
93
94 while (count--) {
95 *dest++ = swab32p(src++);
96 }
97
98 return tmp;
99 }
100
101 #else
102
memcpy_le32(u32 * dest,const u32 * src,size_t count)103 static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
104 {
105 return memcpy(dest, src, count);
106 }
107
108 #endif /* __BIG_ENDIAN */
109
110 #endif /* _IEEE1394_TYPES_H */
111