dat.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. typedef struct List {
  2. void *next;
  3. } List;
  4. typedef struct Alarm Alarm;
  5. typedef struct Alarm {
  6. List;
  7. int busy;
  8. long dt;
  9. void (*f)(Alarm*);
  10. void *arg;
  11. } Alarm;
  12. typedef struct Apminfo {
  13. int haveinfo;
  14. int ax;
  15. int cx;
  16. int dx;
  17. int di;
  18. int ebx;
  19. int esi;
  20. } Apminfo;
  21. typedef struct Block Block;
  22. struct Block {
  23. Block* next;
  24. uchar* rp; /* first unconsumed byte */
  25. uchar* wp; /* first empty byte */
  26. uchar* lim; /* 1 past the end of the buffer */
  27. uchar* base; /* start of the buffer */
  28. ulong flag;
  29. };
  30. #define BLEN(s) ((s)->wp - (s)->rp)
  31. typedef struct IOQ IOQ;
  32. typedef struct IOQ {
  33. uchar buf[4096];
  34. uchar *in;
  35. uchar *out;
  36. int state;
  37. int (*getc)(IOQ*);
  38. int (*putc)(IOQ*, int);
  39. void *ptr;
  40. };
  41. enum {
  42. Eaddrlen = 6,
  43. /* next two exclude 4-byte ether CRC */
  44. ETHERMINTU = 60, /* minimum transmit size */
  45. ETHERMAXTU = 1514, /* maximum transmit size */
  46. ETHERHDRSIZE = 14, /* size of an ethernet header */
  47. MaxEther = 6,
  48. };
  49. typedef struct {
  50. uchar d[Eaddrlen];
  51. uchar s[Eaddrlen];
  52. uchar type[2];
  53. uchar data[1500];
  54. uchar crc[4];
  55. } Etherpkt;
  56. extern uchar broadcast[Eaddrlen];
  57. typedef struct Ureg Ureg;
  58. typedef struct Segdesc {
  59. ulong d0;
  60. ulong d1;
  61. } Segdesc;
  62. typedef struct Mach {
  63. ulong ticks; /* of the clock since boot time */
  64. void *alarm; /* alarms bound to this clock */
  65. } Mach;
  66. extern Mach *m;
  67. #define I_MAGIC ((((4*11)+0)*11)+7)
  68. typedef struct Exec Exec;
  69. struct Exec
  70. {
  71. uchar magic[4]; /* magic number */
  72. uchar text[4]; /* size of text segment */
  73. uchar data[4]; /* size of initialized data */
  74. uchar bss[4]; /* size of uninitialized data */
  75. uchar syms[4]; /* size of symbol table */
  76. uchar entry[4]; /* entry point */
  77. uchar spsz[4]; /* size of sp/pc offset table */
  78. uchar pcsz[4]; /* size of pc/line number table */
  79. };
  80. /*
  81. * a parsed .ini line
  82. */
  83. #define ISAOPTLEN 32
  84. #define NISAOPT 8
  85. typedef struct ISAConf {
  86. char type[NAMELEN];
  87. ulong port;
  88. ulong irq;
  89. ulong mem;
  90. ulong size;
  91. uchar ea[6];
  92. int nopt;
  93. char opt[NISAOPT][ISAOPTLEN];
  94. } ISAConf;
  95. typedef struct Pcidev Pcidev;
  96. typedef struct PCMmap PCMmap;
  97. #define BOOTLINE ((char*)CONFADDR)
  98. enum {
  99. MB = (1024*1024),
  100. };
  101. #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
  102. typedef struct Type Type;
  103. typedef struct Medium Medium;
  104. typedef struct Boot Boot;
  105. enum { /* type */
  106. Tnil = 0x00,
  107. Tfloppy = 0x01,
  108. Tsd = 0x02,
  109. Tether = 0x03,
  110. Tcd = 0x04,
  111. Tany = -1,
  112. };
  113. enum { /* name and flag */
  114. Fnone = 0x00,
  115. Nfs = 0x00,
  116. Ffs = (1<<Nfs),
  117. Nboot = 0x01,
  118. Fboot = (1<<Nboot),
  119. Nbootp = 0x02,
  120. Fbootp = (1<<Nbootp),
  121. NName = 3,
  122. Fany = Fbootp|Fboot|Ffs,
  123. Fini = 0x10,
  124. Fprobe = 0x80,
  125. };
  126. typedef struct Type {
  127. int type;
  128. int flag;
  129. int (*init)(void);
  130. void (*initdev)(int, char*);
  131. void* (*getfspart)(int, char*, int); /* actually returns Dos* */
  132. void (*addconf)(int);
  133. int (*boot)(int, char*, Boot*);
  134. void (*printdevs)(int);
  135. char** parts;
  136. char** inis;
  137. int mask;
  138. Medium* media;
  139. } Type;
  140. extern void (*etherdetach)(void);
  141. extern void (*floppydetach)(void);
  142. extern void (*sddetach)(void);
  143. typedef struct Lock { /* for ilock, iunlock */
  144. int locked;
  145. int spl;
  146. } Lock;
  147. enum { /* returned by bootpass */
  148. MORE, ENOUGH, FAIL
  149. };
  150. enum {
  151. INITKERNEL,
  152. READEXEC,
  153. READ9TEXT,
  154. READ9DATA,
  155. READGZIP,
  156. READEHDR,
  157. READPHDR,
  158. READEPAD,
  159. READEDATA,
  160. TRYBOOT,
  161. INIT9LOAD,
  162. READ9LOAD,
  163. FAILED
  164. };
  165. struct Boot {
  166. int state;
  167. Exec exec;
  168. char *bp; /* base ptr */
  169. char *wp; /* write ptr */
  170. char *ep; /* end ptr */
  171. };
  172. extern int debug;
  173. extern Apminfo apm;
  174. extern char *defaultpartition;
  175. extern int iniread;
  176. extern int pxe;