blob: 9803aaa15be04431994e8a8a764fd887bd42456c [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/string.h>
Stefan Richterde4394f2006-07-03 12:02:29 -04006#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/byteorder.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009typedef u32 quadlet_t;
10typedef u64 octlet_t;
11typedef u16 nodeid_t;
12
13typedef u8 byte_t;
14typedef u64 nodeaddr_t;
15typedef u16 arm_length_t;
16
17#define BUS_MASK 0xffc0
18#define BUS_SHIFT 6
19#define NODE_MASK 0x003f
20#define LOCAL_BUS 0xffc0
21#define ALL_NODES 0x003f
22
23#define NODEID_TO_BUS(nodeid) ((nodeid & BUS_MASK) >> BUS_SHIFT)
24#define NODEID_TO_NODE(nodeid) (nodeid & NODE_MASK)
25
26/* Can be used to consistently print a node/bus ID. */
27#define NODE_BUS_FMT "%d-%02d:%04d"
28#define NODE_BUS_ARGS(__host, __nodeid) \
29 __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid)
30
Stefan Richtere1d118f2006-07-03 12:02:28 -040031#define HPSB_PRINT(level, fmt, args...) \
32 printk(level "ieee1394: " fmt "\n" , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Stefan Richtere1d118f2006-07-03 12:02:28 -040034#define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
35#define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
36#define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
37#define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
38#define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
Stefan Richtere1d118f2006-07-03 12:02:28 -040041#define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
Stefan Richter99519032006-07-02 14:17:00 +020042#define HPSB_DEBUG_TLABELS
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#else
Stefan Richter611aa192006-08-02 18:44:00 +020044#define HPSB_VERBOSE(fmt, args...) do {} while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#endif
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#ifdef __BIG_ENDIAN
48
Stefan Richter2b01b802006-07-03 12:02:28 -040049static inline void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
Stefan Richtere1d118f2006-07-03 12:02:28 -040051 void *tmp = dest;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 u32 *src = (u32 *)__src;
53
Stefan Richtere1d118f2006-07-03 12:02:28 -040054 count /= 4;
55 while (count--)
56 *dest++ = swab32p(src++);
57 return tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
59
60#else
61
62static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
63{
Stefan Richtere1d118f2006-07-03 12:02:28 -040064 return memcpy(dest, src, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
67#endif /* __BIG_ENDIAN */
68
69#endif /* _IEEE1394_TYPES_H */