dat.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. typedef struct PCMslot PCMslot;
  98. #define BOOTLINE ((char*)CONFADDR)
  99. enum {
  100. MB = (1024*1024),
  101. };
  102. #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
  103. typedef struct Type Type;
  104. typedef struct Medium Medium;
  105. typedef struct Boot Boot;
  106. enum { /* type */
  107. Tnil = 0x00,
  108. Tfloppy = 0x01,
  109. Tsd = 0x02,
  110. Tether = 0x03,
  111. Tcd = 0x04,
  112. Tany = -1,
  113. };
  114. enum { /* name and flag */
  115. Fnone = 0x00,
  116. Nfs = 0x00,
  117. Ffs = (1<<Nfs),
  118. Nboot = 0x01,
  119. Fboot = (1<<Nboot),
  120. Nbootp = 0x02,
  121. Fbootp = (1<<Nbootp),
  122. NName = 3,
  123. Fany = Fbootp|Fboot|Ffs,
  124. Fini = 0x10,
  125. Fprobe = 0x80,
  126. };
  127. typedef struct Type {
  128. int type;
  129. int flag;
  130. int (*init)(void);
  131. void (*initdev)(int, char*);
  132. void* (*getfspart)(int, char*, int); /* actually returns Dos* */
  133. void (*addconf)(int);
  134. int (*boot)(int, char*, Boot*);
  135. void (*printdevs)(int);
  136. char** parts;
  137. char** inis;
  138. int mask;
  139. Medium* media;
  140. } Type;
  141. extern void (*etherdetach)(void);
  142. extern void (*floppydetach)(void);
  143. extern void (*sddetach)(void);
  144. typedef struct Lock { /* for ilock, iunlock */
  145. int locked;
  146. int spl;
  147. } Lock;
  148. enum { /* returned by bootpass */
  149. MORE, ENOUGH, FAIL
  150. };
  151. enum {
  152. INITKERNEL,
  153. READEXEC,
  154. READ9TEXT,
  155. READ9DATA,
  156. READGZIP,
  157. READEHDR,
  158. READPHDR,
  159. READEPAD,
  160. READEDATA,
  161. TRYBOOT,
  162. INIT9LOAD,
  163. READ9LOAD,
  164. FAILED
  165. };
  166. struct Boot {
  167. int state;
  168. Exec exec;
  169. char *bp; /* base ptr */
  170. char *wp; /* write ptr */
  171. char *ep; /* end ptr */
  172. };
  173. extern int debug;
  174. extern Apminfo apm;
  175. extern char *defaultpartition;
  176. extern int iniread;
  177. extern int pxe;