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/list.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <linux/spinlock.h> |
| 7 | #include <linux/string.h> |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame^] | 8 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <asm/byteorder.h> |
Stefan Richter | de4394f | 2006-07-03 12:02:29 -0400 | [diff] [blame^] | 11 | #include <asm/semaphore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | /* Transaction Label handling */ |
| 14 | struct 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) \ |
| 23 | do { \ |
| 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | typedef u32 quadlet_t; |
| 32 | typedef u64 octlet_t; |
| 33 | typedef u16 nodeid_t; |
| 34 | |
| 35 | typedef u8 byte_t; |
| 36 | typedef u64 nodeaddr_t; |
| 37 | typedef 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 Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 53 | #define HPSB_PRINT(level, fmt, args...) \ |
| 54 | printk(level "ieee1394: " fmt "\n" , ## args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 56 | #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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | #ifdef CONFIG_IEEE1394_VERBOSEDEBUG |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 63 | #define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #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 Richter | 2b01b80 | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 75 | 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] | 76 | { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 77 | void *tmp = dest; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | u32 *src = (u32 *)__src; |
| 79 | |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 80 | count /= 4; |
| 81 | while (count--) |
| 82 | *dest++ = swab32p(src++); |
| 83 | return tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | #else |
| 87 | |
| 88 | static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count) |
| 89 | { |
Stefan Richter | e1d118f | 2006-07-03 12:02:28 -0400 | [diff] [blame] | 90 | return memcpy(dest, src, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | #endif /* __BIG_ENDIAN */ |
| 94 | |
| 95 | #endif /* _IEEE1394_TYPES_H */ |