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