dat.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* dat.h: include file for vblade AoE target */
  2. #include <sys/types.h>
  3. #define nil ((void *)0)
  4. /*
  5. * tunable variables
  6. */
  7. enum {
  8. VBLADE_VERSION = 25,
  9. // Firmware version
  10. FWV = 0x4000 + VBLADE_VERSION,
  11. };
  12. #undef major
  13. #undef minor
  14. #undef makedev
  15. #define major(x) ((x) >> 24 & 0xFF)
  16. #define minor(x) ((x) & 0xffffff)
  17. #define makedev(x, y) ((x) << 24 | (y))
  18. typedef unsigned char uchar;
  19. //typedef unsigned short ushort;
  20. #ifdef __FreeBSD__
  21. typedef unsigned long ulong;
  22. #else
  23. //typedef unsigned long ulong;
  24. #endif
  25. typedef long long vlong;
  26. typedef struct Aoehdr Aoehdr;
  27. typedef struct Ata Ata;
  28. typedef struct Conf Conf;
  29. typedef struct Ataregs Ataregs;
  30. typedef struct Mdir Mdir;
  31. typedef struct Aoemask Aoemask;
  32. typedef struct Aoesrr Aoesrr;
  33. struct Ataregs
  34. {
  35. vlong lba;
  36. uchar cmd;
  37. uchar status;
  38. uchar err;
  39. uchar feature;
  40. uchar sectors;
  41. };
  42. struct Aoehdr
  43. {
  44. uchar dst[6];
  45. uchar src[6];
  46. ushort type;
  47. uchar flags;
  48. uchar error;
  49. ushort maj;
  50. uchar min;
  51. uchar cmd;
  52. uchar tag[4];
  53. };
  54. struct Ata
  55. {
  56. Aoehdr h;
  57. uchar aflag;
  58. uchar err;
  59. uchar sectors;
  60. uchar cmd;
  61. uchar lba[6];
  62. uchar resvd[2];
  63. };
  64. struct Conf
  65. {
  66. Aoehdr h;
  67. ushort bufcnt;
  68. ushort firmware;
  69. uchar scnt;
  70. uchar vercmd;
  71. ushort len;
  72. uchar data[1024];
  73. };
  74. // mask directive
  75. struct Mdir {
  76. uchar res;
  77. uchar cmd;
  78. uchar mac[6];
  79. };
  80. struct Aoemask {
  81. Aoehdr h;
  82. uchar res;
  83. uchar cmd;
  84. uchar merror;
  85. uchar nmacs;
  86. // struct Mdir m[0];
  87. };
  88. struct Aoesrr {
  89. Aoehdr h;
  90. uchar rcmd;
  91. uchar nmacs;
  92. // uchar mac[6][nmacs];
  93. };
  94. enum {
  95. AoEver = 1,
  96. ATAcmd = 0, // command codes
  97. Config,
  98. Mask,
  99. Resrel,
  100. Resp = (1<<3), // flags
  101. Error = (1<<2),
  102. BadCmd = 1,
  103. BadArg,
  104. DevUnavailable,
  105. ConfigErr,
  106. BadVersion,
  107. Res,
  108. Write = (1<<0),
  109. Async = (1<<1),
  110. Device = (1<<4),
  111. Extend = (1<<6),
  112. Qread = 0,
  113. Qtest,
  114. Qprefix,
  115. Qset,
  116. Qfset,
  117. Nretries = 3,
  118. Nconfig = 1024,
  119. Bufcount = 16,
  120. /* mask commands */
  121. Mread= 0,
  122. Medit,
  123. /* mask directives */
  124. MDnop= 0,
  125. MDadd,
  126. MDdel,
  127. /* mask errors */
  128. MEunspec= 1,
  129. MEbaddir,
  130. MEfull,
  131. /* header sizes, including aoe hdr */
  132. Naoehdr= 24,
  133. Natahdr= Naoehdr + 12,
  134. Ncfghdr= Naoehdr + 8,
  135. Nmaskhdr= Naoehdr + 4,
  136. Nsrrhdr= Naoehdr + 2,
  137. Nserial= 20,
  138. };
  139. extern int shelf, slot;
  140. extern ulong aoetag;
  141. extern uchar mac[6];
  142. extern int bfd; // block file descriptor
  143. extern int sfd; // socket file descriptor
  144. extern vlong size; // size of vblade
  145. extern vlong offset;
  146. extern char *progname;
  147. extern char serial[Nserial+1];