10 typedef struct Extend Extend;
11 typedef struct Dir Dir;
40 int readsect(ulong drive, ulong lba, void *buf);
43 read(void *f, void *data, int len)
47 if(ex->len > 0 && ex->rp >= ex->ep)
48 if(readsect(ex->drive, ex->lba++, ex->rp = ex->buf))
52 if(len > (ex->ep - ex->rp))
53 len = ex->ep - ex->rp;
54 memmove(data, ex->rp, len);
68 ex->rp = ex->ep = ex->buf + Sectsz;
72 isowalk(Extend *ex, int drive, char *path)
74 char name[Maxpath], c, *end;
82 for(i=0x10; i<0x1000; i++){
83 if(readsect(drive, i, ex->buf))
88 ex->lba = *((ulong*)(ex->buf + 156 + 2));
89 ex->len = *((ulong*)(ex->buf + 156 + 10));
92 if(readn(ex, &d, Dirsz) != Dirsz)
96 if(readn(ex, name, d.namelen) != d.namelen)
98 i = d.dirlen - (Dirsz + d.namelen);
101 for(i=0; i<d.namelen; i++){
103 if(c >= 'A' && c <= 'Z'){
112 if((end = strchr(path, '/')) == 0)
113 end = path + strlen(path);
115 if(d.namelen == i && memcmp(name, path, i) == 0){
117 ex->lba = *((ulong*)d.lba);
118 ex->len = *((ulong*)d.len);
121 else if(d.flags[0] & 2){
135 char path[Maxpath], *kern;
140 /* drive passed in DL */
141 drive = ((ushort*)sp)[5] & 0xFF;
144 * load full bootblock as only the frist 2K get
145 * loaded from bios. the code is specially arranged
146 * to have all the important routines in the first
147 * 2K of the 9bootiso image. (strings have been
148 * placed in l.s to make sure they will be < 2K)
150 if(isowalk(&ex, drive, bootname)){
155 readn(&ex, origin, ex.len);
158 if(isowalk(f = &ex, drive, "/cfg/plan9.ini")){
159 print("no config\r\n");
163 kern = configure(f, path); f = 0;
164 if(isowalk(&ex, drive, kern)){
165 print("not found\r\n");
168 print(bootkern(&ex));