ieee1394_types.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _IEEE1394_TYPES_H
  2. #define _IEEE1394_TYPES_H
  3. #include <linux/kernel.h>
  4. #include <linux/types.h>
  5. #include <linux/version.h>
  6. #include <linux/list.h>
  7. #include <linux/init.h>
  8. #include <asm/byteorder.h>
  9. /* The great kdev_t changeover in 2.5.x */
  10. #include <linux/kdev_t.h>
  11. #ifndef minor
  12. #define minor(dev) MINOR(dev)
  13. #endif
  14. #ifndef __devexit_p
  15. #define __devexit_p(x) x
  16. #endif
  17. /* This showed up around this time */
  18. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,12)
  19. # ifndef MODULE_LICENSE
  20. # define MODULE_LICENSE(x)
  21. # endif
  22. # ifndef min
  23. # define min(x,y) ({ 
  24. const typeof(x) _x = (x);       
  25. const typeof(y) _y = (y);       
  26. (void) (&_x == &_y);            
  27. _x < _y ? _x : _y; })
  28. # endif
  29. #endif /* Linux version < 2.4.12 */
  30. #include <linux/spinlock.h>
  31. #ifndef list_for_each_safe
  32. #define list_for_each_safe(pos, n, head) 
  33. for (pos = (head)->next, n = pos->next; pos != (head); 
  34. pos = n, n = pos->next)
  35. #endif
  36. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,5)
  37. #define pte_offset_kernel pte_offset
  38. #endif
  39. #ifndef MIN
  40. #define MIN(a,b) ((a) < (b) ? (a) : (b))
  41. #endif
  42. #ifndef MAX
  43. #define MAX(a,b) ((a) > (b) ? (a) : (b))
  44. #endif
  45. typedef u32 quadlet_t;
  46. typedef u64 octlet_t;
  47. typedef u16 nodeid_t;
  48. #define BUS_MASK  0xffc0
  49. #define NODE_MASK 0x003f
  50. #define LOCAL_BUS 0xffc0
  51. #define ALL_NODES 0x003f
  52. /* Can be used to consistently print a node/bus ID. */
  53. #define NODE_BUS_FMT    "%02d:%04d"
  54. #define NODE_BUS_ARGS(nodeid) 
  55. (nodeid & NODE_MASK), ((nodeid & BUS_MASK) >> 6)
  56. #define HPSB_PRINT(level, fmt, args...) printk(level "ieee1394: " fmt "n" , ## args)
  57. #define HPSB_DEBUG(fmt, args...) HPSB_PRINT(KERN_DEBUG, fmt , ## args)
  58. #define HPSB_INFO(fmt, args...) HPSB_PRINT(KERN_INFO, fmt , ## args)
  59. #define HPSB_NOTICE(fmt, args...) HPSB_PRINT(KERN_NOTICE, fmt , ## args)
  60. #define HPSB_WARN(fmt, args...) HPSB_PRINT(KERN_WARNING, fmt , ## args)
  61. #define HPSB_ERR(fmt, args...) HPSB_PRINT(KERN_ERR, fmt , ## args)
  62. #define HPSB_PANIC(fmt, args...) panic("ieee1394: " fmt "n" , ## args)
  63. #define HPSB_TRACE() HPSB_PRINT(KERN_INFO, "TRACE - %s, %s(), line %d", __FILE__, __FUNCTION__, __LINE__)
  64. #ifdef __BIG_ENDIAN
  65. static __inline__ void *memcpy_le32(u32 *dest, const u32 *__src, size_t count)
  66. {
  67.         void *tmp = dest;
  68. u32 *src = (u32 *)__src;
  69.         count /= 4;
  70.         while (count--) {
  71.                 *dest++ = swab32p(src++);
  72.         }
  73.         return tmp;
  74. }
  75. #else
  76. static __inline__ void *memcpy_le32(u32 *dest, const u32 *src, size_t count)
  77. {
  78.         return memcpy(dest, src, count);
  79. }
  80. #endif /* __BIG_ENDIAN */
  81. #endif /* _IEEE1394_TYPES_H */