blob: 6c246913b16fae08eaf98025c35fa5126cf3d428 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _IEEE1394_TYPES_H
2#define _IEEE1394_TYPES_H
3
4#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <linux/spinlock.h>
7#include <linux/string.h>
Stefan Richterde4394f2006-07-03 12:02:29 -04008#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <asm/byteorder.h>
Stefan Richterde4394f2006-07-03 12:02:29 -040011#include <asm/semaphore.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13/* Transaction Label handling */
14struct hpsb_tlabel_pool {
15 DECLARE_BITMAP(pool, 64);
16 spinlock_t lock;
17 u8 next;
18 u32 allocations;
19 struct semaphore count;
20};
21
22#define HPSB_TPOOL_INIT(_tp) \
23do { \
24 bitmap_zero((_tp)->pool, 64); \
25 spin_lock_init(&(_tp)->lock); \
26 (_tp)->next = 0; \
27 (_tp)->allocations = 0; \
28 sema_init(&(_tp)->count, 63); \
29} while (0)
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031typedef u32 quadlet_t;
32typedef u64 octlet_t;
33typedef u16 nodeid_t;
34
35typedef u8 byte_t;
36typedef u64 nodeaddr_t;
37typedef u16 arm_length_t;
38
39#define BUS_MASK 0xffc0
40#define BUS_SHIFT 6
41#define NODE_MASK 0x003f
42#define LOCAL_BUS 0xffc0
43#define ALL_NODES 0x003f
44
45#define NODEID_TO_BUS(nodeid) ((nodeid & BUS_MASK) >> BUS_SHIFT)
46#define NODEID_TO_NODE(nodeid) (nodeid & NODE_MASK)
47
48/* Can be used to consistently print a node/bus ID. */
49#define NODE_BUS_FMT "%d-%02d:%04d"
50#define NODE_BUS_ARGS(__host, __nodeid) \
51 __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid)
52
Stefan Richtere1d118f2006-07-03 12:02:28 -040053#define HPSB_PRINT(level, fmt, args...) \
54 printk(level "ieee1394: " fmt "\n" , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Stefan Richtere1d118f2006-07-03 12:02:28 -040056#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
57#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
58#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
59#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
60#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
Stefan Richtere1d118f2006-07-03 12:02:28 -040063#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#else
65#define HPSB_VERBOSE(fmt, args...)
66#endif
67
68#define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args)
69
70#define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
71
72
73#ifdef __BIG_ENDIAN
74
Stefan Richter2b01b802006-07-03 12:02:28 -040075static inline void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Stefan Richtere1d118f2006-07-03 12:02:28 -040077 void *tmp = dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 u32 *src = (u32 *)__src;
79
Stefan Richtere1d118f2006-07-03 12:02:28 -040080 count /= 4;
81 while (count--)
82 *dest++ = swab32p(src++);
83 return tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
85
86#else
87
88static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
89{
Stefan Richtere1d118f2006-07-03 12:02:28 -040090 return memcpy(dest, src, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091}
92
93#endif /* __BIG_ENDIAN */
94
95#endif /* _IEEE1394_TYPES_H */