dat.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* dat.h - aoetools type definitions and macros
  2. * Copyright 2009, CORAID, Inc., and licensed under GPL v.2.
  3. */
  4. #define nil NULL
  5. #define nelem(x) (sizeof(x)/sizeof((x)[0]))
  6. typedef unsigned char uchar;
  7. typedef struct Aoehdr Aoehdr;
  8. typedef struct Ata Ata;
  9. typedef struct Conf Conf;
  10. typedef struct Ataregs Ataregs;
  11. /* use C99's stdint.h for fixed-width types
  12. *
  13. * There's no guarantee an unsigned short is 16-bits wide,
  14. * but uint16_t is always correct.
  15. */
  16. typedef uint64_t vlong;
  17. typedef uint32_t u32;
  18. typedef uint16_t u16;
  19. struct Ataregs {
  20. vlong lba;
  21. uchar cmd;
  22. uchar status;
  23. uchar err;
  24. uchar feature;
  25. uchar sectors;
  26. };
  27. struct Aoehdr {
  28. uchar dst[6];
  29. uchar src[6];
  30. u16 type;
  31. uchar flags;
  32. uchar error;
  33. u16 maj;
  34. uchar min;
  35. uchar cmd;
  36. uchar tag[4];
  37. };
  38. struct Ata {
  39. Aoehdr h;
  40. uchar aflag;
  41. uchar err;
  42. uchar sectors;
  43. uchar cmd;
  44. uchar lba[6];
  45. uchar resvd[2];
  46. uchar data[1024];
  47. };
  48. struct Conf {
  49. Aoehdr h;
  50. u16 bufcnt;
  51. u16 firmware;
  52. uchar scnt;
  53. uchar vercmd;
  54. u16 len;
  55. uchar data[1024];
  56. };
  57. enum {
  58. AOE_ETH_PROTO = 0x88a2,
  59. AoEver = 1,
  60. ATAcmd = 0, // command codes
  61. Config,
  62. Resp = 1<<3, // flags
  63. Error = 1<<2,
  64. BadCmd = 1,
  65. BadArg,
  66. DevUnavailable,
  67. ConfigErr,
  68. BadVersion,
  69. Write = 1<<0,
  70. Async = 1<<1,
  71. Device = 1<<4,
  72. Extend = 1<<6,
  73. Qread = 0,
  74. Qtest,
  75. Qprefix,
  76. Qset,
  77. Qfset,
  78. Nretries = 3,
  79. ATAid_dev = 0xec, // ATA commands
  80. ATAsmart = 0xb0,
  81. ATAabrt = 0x4, // ATA error bits
  82. SmartDataPut = 0x01,
  83. SmartDataRet = 0x10,
  84. };