dat.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. #pragma incomplete Ureg
  59. typedef struct Segdesc {
  60. ulong d0;
  61. ulong d1;
  62. } Segdesc;
  63. typedef struct Mach {
  64. ulong ticks; /* of the clock since boot time */
  65. void *alarm; /* alarms bound to this clock */
  66. } Mach;
  67. extern Mach *m;
  68. #define I_MAGIC ((((4*11)+0)*11)+7)
  69. typedef struct Exec Exec;
  70. struct Exec
  71. {
  72. uchar magic[4]; /* magic number */
  73. uchar text[4]; /* size of text segment */
  74. uchar data[4]; /* size of initialized data */
  75. uchar bss[4]; /* size of uninitialized data */
  76. uchar syms[4]; /* size of symbol table */
  77. uchar entry[4]; /* entry point */
  78. uchar spsz[4]; /* size of sp/pc offset table */
  79. uchar pcsz[4]; /* size of pc/line number table */
  80. };
  81. /*
  82. * a parsed .ini line
  83. */
  84. #define ISAOPTLEN 32
  85. #define NISAOPT 8
  86. typedef struct ISAConf {
  87. char type[NAMELEN];
  88. ulong port;
  89. ulong irq;
  90. ulong mem;
  91. ulong size;
  92. uchar ea[6];
  93. int nopt;
  94. char opt[NISAOPT][ISAOPTLEN];
  95. } ISAConf;
  96. typedef struct Pcidev Pcidev;
  97. typedef struct PCMmap PCMmap;
  98. typedef struct PCMslot PCMslot;
  99. #define BOOTLINE ((char*)CONFADDR)
  100. enum {
  101. MB = (1024*1024),
  102. };
  103. #define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
  104. typedef struct Type Type;
  105. typedef struct Medium Medium;
  106. typedef struct Boot Boot;
  107. enum { /* type */
  108. Tnil = 0x00,
  109. Tfloppy = 0x01,
  110. Tsd = 0x02,
  111. Tether = 0x03,
  112. Tcd = 0x04,
  113. Tbios = 0x05,
  114. Tany = -1,
  115. };
  116. enum { /* name and flag */
  117. Fnone = 0x00,
  118. Nfs = 0x00,
  119. Ffs = (1<<Nfs),
  120. Nboot = 0x01,
  121. Fboot = (1<<Nboot),
  122. Nbootp = 0x02,
  123. Fbootp = (1<<Nbootp),
  124. NName = 3,
  125. Fany = Fbootp|Fboot|Ffs,
  126. Fini = 0x10,
  127. Fprobe = 0x80,
  128. };
  129. typedef struct Type {
  130. int type;
  131. int flag;
  132. int (*init)(void);
  133. void (*initdev)(int, char*);
  134. void* (*getfspart)(int, char*, int); /* actually returns Dos* */
  135. void (*addconf)(int);
  136. int (*boot)(int, char*, Boot*);
  137. void (*printdevs)(int);
  138. char** parts;
  139. char** inis;
  140. int mask;
  141. Medium* media;
  142. } Type;
  143. extern void (*etherdetach)(void);
  144. extern void (*floppydetach)(void);
  145. extern void (*sddetach)(void);
  146. typedef struct Lock { /* for ilock, iunlock */
  147. int locked;
  148. int spl;
  149. } Lock;
  150. enum { /* returned by bootpass */
  151. MORE, ENOUGH, FAIL
  152. };
  153. enum {
  154. INITKERNEL,
  155. READEXEC,
  156. READ9TEXT,
  157. READ9DATA,
  158. READGZIP,
  159. READEHDR,
  160. READPHDR,
  161. READEPAD,
  162. READEDATA,
  163. TRYBOOT,
  164. INIT9LOAD,
  165. READ9LOAD,
  166. FAILED
  167. };
  168. struct Boot {
  169. int state;
  170. Exec exec;
  171. char *bp; /* base ptr */
  172. char *wp; /* write ptr */
  173. char *ep; /* end ptr */
  174. };
  175. extern int debug;
  176. extern Apminfo apm;
  177. extern char *defaultpartition;
  178. extern int iniread;
  179. extern int pxe;