Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _IEEE1394_TYPES_H |
| 2 | #define _IEEE1394_TYPES_H |
| 3 | |
| 4 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/string.h> |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame] | 6 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <asm/byteorder.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | typedef u32 quadlet_t; |
| 10 | typedef u64 octlet_t; |
| 11 | typedef u16 nodeid_t; |
| 12 | |
| 13 | typedef u8 byte_t; |
| 14 | typedef u64 nodeaddr_t; |
| 15 | typedef 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 Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 31 | #define HPSB_PRINT(level, fmt, args...) \ |
| 32 | printk(level "ieee1394: " fmt "\n" , ## args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 34 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | #ifdef CONFIG_IEEE1394_VERBOSEDEBUG |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 41 | #define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) |
Stefan Richter | 9951903 | 2006-07-02 14:17:00 +0200 | [diff] [blame] | 42 | #define HPSB_DEBUG_TLABELS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #else |
Stefan Richter | 611aa19 | 2006-08-02 18:44:00 +0200 | [diff] [blame] | 44 | #define HPSB_VERBOSE(fmt, args...) do {} while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #endif |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #ifdef __BIG_ENDIAN |
| 48 | |
Stefan Richter | 2b01b80 | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 49 | static inline void *memcpy_le32(u32 *dest, const u32 *__src, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 51 | void *tmp = dest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | u32 *src = (u32 *)__src; |
| 53 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 54 | count /= 4; |
| 55 | while (count--) |
| 56 | *dest++ = swab32p(src++); |
| 57 | return tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | #else |
| 61 | |
| 62 | static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count) |
| 63 | { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 64 | return memcpy(dest, src, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | #endif /* __BIG_ENDIAN */ |
| 68 | |
| 69 | #endif /* _IEEE1394_TYPES_H */ |