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