10 typedef struct Extend Extend;
11 typedef struct Dir Dir;
40 int readsect(ulong drive, ulong lba, void *buf);
48 read(void *f, void *data, int len)
52 if(ex->len > 0 && ex->rp >= ex->ep)
53 if(readsect(ex->drive, ex->lba++, ex->rp = ex->buf))
57 if(len > (ex->ep - ex->rp))
58 len = ex->ep - ex->rp;
59 memmove(data, ex->rp, len);
73 ex->rp = ex->ep = ex->buf + Sectsz;
77 isowalk(Extend *ex, int drive, char *path)
79 char name[Maxpath], c, *end;
87 for(i=0x10; i<0x1000; i++){
88 if(readsect(drive, i, ex->buf))
93 ex->lba = *((ulong*)(ex->buf + 156 + 2));
94 ex->len = *((ulong*)(ex->buf + 156 + 10));
97 if(readn(ex, &d, Dirsz) != Dirsz)
101 if(readn(ex, name, d.namelen) != d.namelen)
103 i = d.dirlen - (Dirsz + d.namelen);
106 for(i=0; i<d.namelen; i++){
108 if(c >= 'A' && c <= 'Z'){
117 if((end = strchr(path, '/')) == 0)
118 end = path + strlen(path);
120 if(d.namelen == i && memcmp(name, path, i) == 0){
122 ex->lba = *((ulong*)d.lba);
123 ex->len = *((ulong*)d.len);
126 else if(d.flags[0] & 2){
140 char path[Maxpath], *kern;
145 /* drive passed in DL */
146 drive = ((ushort*)sp)[5] & 0xFF;
149 * load full bootblock as only the frist 2K get
150 * loaded from bios. the code is specially arranged
151 * to have all the important routines in the first
152 * 2K of the 9bootiso image. (strings have been
153 * placed in l.s to make sure they will be < 2K)
155 if(isowalk(&ex, drive, bootname)){
160 readn(&ex, origin, ex.len);
163 if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
164 print("no config\n");
168 kern = configure(f, path); f = 0;
169 if(isowalk(&ex, drive, kern)){
170 print("not found\n");
173 print(bootkern(&ex));