10 typedef struct Extend Extend;
11 typedef struct Dir Dir;
40 int readsect(ulong drive, ulong lba, void *buf);
44 readsect4(ulong drive, ulong lba, void *buf)
49 for(i = 0; i<Sectsz/512; i++){
50 if(readsect(drive, lba++, buf))
52 buf = (uchar*)buf + 512;
56 #define readsect readsect4
65 read(void *f, void *data, int len)
69 if(ex->len > 0 && ex->rp >= ex->ep)
70 if(readsect(ex->drive, ex->lba++, ex->rp = ex->buf))
74 if(len > (ex->ep - ex->rp))
75 len = ex->ep - ex->rp;
76 memmove(data, ex->rp, len);
90 ex->rp = ex->ep = ex->buf + Sectsz;
94 isowalk(Extend *ex, int drive, char *path)
96 char name[Maxpath], c, *end;
104 for(i=0x10; i<0x1000; i++){
105 if(readsect(drive, i, ex->buf))
110 ex->lba = *((ulong*)(ex->buf + 156 + 2));
111 ex->len = *((ulong*)(ex->buf + 156 + 10));
114 if(readn(ex, &d, Dirsz) != Dirsz)
118 if(readn(ex, name, d.namelen) != d.namelen)
120 i = d.dirlen - (Dirsz + d.namelen);
123 for(i=0; i<d.namelen; i++){
125 if(c >= 'A' && c <= 'Z'){
134 if((end = strchr(path, '/')) == 0)
135 end = path + strlen(path);
137 if(d.namelen == i && memcmp(name, path, i) == 0){
139 ex->lba = *((ulong*)d.lba);
140 ex->len = *((ulong*)d.len);
143 else if(d.flags[0] & 2){
157 char path[Maxpath], *kern;
162 /* drive passed in DL */
163 drive = ((ushort*)sp)[5] & 0xFF;
167 * load full bootblock as only the frist 2K get
168 * loaded from bios. the code is specially arranged
169 * to have all the important routines in the first
170 * 2K of the 9bootiso image. (strings have been
171 * placed in l.s to make sure they will be < 2K)
173 if(isowalk(&ex, drive, bootname)){
178 readn(&ex, origin, ex.len);
182 if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
183 print("no config\n");
187 kern = configure(f, path); f = 0;
188 if(isowalk(&ex, drive, kern)){
189 print("not found\n");
192 print(bootkern(&ex));