/drivers/ieee1394/ieee1394_types.h

https://bitbucket.org/evzijst/gittest · C Header · 101 lines · 72 code · 27 blank · 2 comment · 2 complexity · 6cbb5b13cd1e046d87fbb4f8fcb8295f MD5 · raw file

  1. #ifndef _IEEE1394_TYPES_H
  2. #define _IEEE1394_TYPES_H
  3. #include <linux/kernel.h>
  4. #include <linux/types.h>
  5. #include <linux/list.h>
  6. #include <linux/init.h>
  7. #include <linux/spinlock.h>
  8. #include <linux/string.h>
  9. #include <asm/semaphore.h>
  10. #include <asm/byteorder.h>
  11. /* Transaction Label handling */
  12. struct hpsb_tlabel_pool {
  13. DECLARE_BITMAP(pool, 64);
  14. spinlock_t lock;
  15. u8 next;
  16. u32 allocations;
  17. struct semaphore count;
  18. };
  19. #define HPSB_TPOOL_INIT(_tp) \
  20. do { \
  21. bitmap_zero((_tp)->pool, 64); \
  22. spin_lock_init(&(_tp)->lock); \
  23. (_tp)->next = 0; \
  24. (_tp)->allocations = 0; \
  25. sema_init(&(_tp)->count, 63); \
  26. } while (0)
  27. typedef u32 quadlet_t;
  28. typedef u64 octlet_t;
  29. typedef u16 nodeid_t;
  30. typedef u8 byte_t;
  31. typedef u64 nodeaddr_t;
  32. typedef u16 arm_length_t;
  33. #define BUS_MASK 0xffc0
  34. #define BUS_SHIFT 6
  35. #define NODE_MASK 0x003f
  36. #define LOCAL_BUS 0xffc0
  37. #define ALL_NODES 0x003f
  38. #define NODEID_TO_BUS(nodeid) ((nodeid & BUS_MASK) >> BUS_SHIFT)
  39. #define NODEID_TO_NODE(nodeid) (nodeid & NODE_MASK)
  40. /* Can be used to consistently print a node/bus ID. */
  41. #define NODE_BUS_FMT "%d-%02d:%04d"
  42. #define NODE_BUS_ARGS(__host, __nodeid) \
  43. __host->id, NODEID_TO_NODE(__nodeid), NODEID_TO_BUS(__nodeid)
  44. #define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "\n" , ## args)
  45. #define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
  46. #define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
  47. #define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
  48. #define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
  49. #define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
  50. #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
  51. #define HPSB_VERBOSE(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
  52. #else
  53. #define HPSB_VERBOSE(fmt, args...)
  54. #endif
  55. #define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "\n" , ## args)
  56. #define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
  57. #ifdef __BIG_ENDIAN
  58. static __inline__ void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
  59. {
  60. void *tmp = dest;
  61. u32 *src = (u32 *)__src;
  62. count /= 4;
  63. while (count--) {
  64. *dest++ = swab32p(src++);
  65. }
  66. return tmp;
  67. }
  68. #else
  69. static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
  70. {
  71. return memcpy(dest, src, count);
  72. }
  73. #endif /* __BIG_ENDIAN */
  74. #endif /* _IEEE1394_TYPES_H */