7 memset(void *p, int v, int n)
17 memmove(void *dst, void *src, int n)
38 memcmp(void *src, void *dst, int n)
43 while((n > 0) && (r = (*d++ - *s++)) == 0)
58 strchr(char *s, int c)
67 strrchr(char *s, int c)
71 while(s = strchr(s, c))
84 readn(void *f, void *data, int len)
91 if((len = read(f, p, e - p)) <= 0)
95 return p - (uchar*)data;
99 readline(void *f, char buf[64])
101 static char white[] = "\t ";
108 while(p < buf + 64-1){
113 else if(*p == 0x08 && p > buf){
117 }else if(read(f, p, 1) <= 0)
119 if(p == buf && strchr(white, *p))
125 while(p > buf && strchr(white, p[-1]))
133 configure(void *f, char *path)
135 char line[64], *p, *kern;
141 p = (char*)(CONFADDR & ~0xF0000000UL);
145 while((n = readline(f, line)) > 0){
146 if(*line == 0 || strchr("#;=", *line))
149 inblock = memcmp("[common]", line, 8);
152 if(memcmp("clear", line, 6) == 0){
156 if(memcmp("boot", line, 5) == 0)
158 if(inblock || !strrchr(line, '='))
160 print(line); print(crnl);
161 if(memcmp("bootfile=", line, 9) == 0)
162 memmove(kern = path, line+9, 1 + n-9);
163 memmove(p, line, n); p += n;
172 print("no bootfile\r\n");
175 for(n=0; n<10000; n++)
178 if(p = strrchr(kern, '!'))
190 return (p[0]<<8) | p[1];
199 return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
210 if(readn(f, &ex, sizeof(ex)) != sizeof(ex))
212 if(beswal(ex.magic) != I_MAGIC)
216 e = (uchar*)(beswal(ex.entry) & ~0xF0000000UL);
219 * the kernels load addess (entry) might overlap
220 * with some bios memory (pxe) that is needed to load
221 * it. so we read it to this address and after
222 * we finished, move it to final location.
224 t = (uchar*)0x200000;
227 if(readn(f, t, n) != n)
229 d = t + ((uchar*)PGROUND((ulong)e + n) - e);
231 if(readn(f, d, n) != n)