1
0

dat.h 1.3 KB

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