blob: ed6fdd811a09456d658b6b320837324154f99131 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001
2#ifndef _IEEE1394_TYPES_H
3#define _IEEE1394_TYPES_H
4
5#include <linux/kernel.h>
6#include <linux/types.h>
7#include <linux/list.h>
8#include <linux/init.h>
9#include <linux/spinlock.h>
10#include <linux/string.h>
11
12#include <asm/semaphore.h>
13#include <asm/byteorder.h>
14
15
16/* Transaction Label handling */
17struct hpsb_tlabel_pool {
18 DECLARE_BITMAP(pool, 64);
19 spinlock_t lock;
20 u8 next;
21 u32 allocations;
22 struct semaphore count;
23};
24
25#define HPSB_TPOOL_INIT(_tp) \
26do { \
27 bitmap_zero((_tp)->pool, 64); \
28 spin_lock_init(&(_tp)->lock); \
29 (_tp)->next = 0; \
30 (_tp)->allocations = 0; \
31 sema_init(&(_tp)->count, 63); \
32} while (0)
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034typedef u32 quadlet_t;
35typedef u64 octlet_t;
36typedef u16 nodeid_t;
37
38typedef u8 byte_t;
39typedef u64 nodeaddr_t;
40typedef u16 arm_length_t;
41
42#define BUS_MASK 0xffc0
43#define BUS_SHIFT 6
44#define NODE_MASK 0x003f
45#define LOCAL_BUS 0xffc0
46#define ALL_NODES 0x003f
47
48#define NODEID_TO_BUS(nodeid) ((nodeid & BUS_MASK) >> BUS_SHIFT)
49#define NODEID_TO_NODE(nodeid) (nodeid & NODE_MASK)
50
51/* Can be used to consistently print a node/bus ID. */
52#define NODE_BUS_FMT "%d-%02d:%04d"
53#define NODE_BUS_ARGS(__host, __nodeid) \
54 __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid)
55
Stefan Richtere1d118f2006-07-03 12:02:28 -040056#define HPSB_PRINT(level, fmt, args...) \
57 printk(level "ieee1394: " fmt "\n" , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Stefan Richtere1d118f2006-07-03 12:02:28 -040059#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
60#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
61#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
62#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
63#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
Stefan Richtere1d118f2006-07-03 12:02:28 -040066#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#else
68#define HPSB_VERBOSE(fmt, args...)
69#endif
70
71#define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args)
72
73#define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
74
75
76#ifdef __BIG_ENDIAN
77
Stefan Richter2b01b802006-07-03 12:02:28 -040078static inline void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
Stefan Richtere1d118f2006-07-03 12:02:28 -040080 void *tmp = dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 u32 *src = (u32 *)__src;
82
Stefan Richtere1d118f2006-07-03 12:02:28 -040083 count /= 4;
84 while (count--)
85 *dest++ = swab32p(src++);
86 return tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89#else
90
91static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
92{
Stefan Richtere1d118f2006-07-03 12:02:28 -040093 return memcpy(dest, src, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
96#endif /* __BIG_ENDIAN */
97
98#endif /* _IEEE1394_TYPES_H */