int main() { int chosen; /* * Get the boot arguments from Openfirmware */ if ((chosen = OF_finddevice("/chosen")) == -1 || OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { printf("Invalid Openfirmware environment\n"); exit(); } prom2boot(bootdev); get_alt_bootdev(bootdev, sizeof(bootdev), bootline, sizeof(bootline)); if (bootline[0] != '\0') kernelfile = bootline; OF_claim((void *)0x00100000, CLAIM_LIMIT, 0); /* XXX */ boot(0); return 0; }
void main(void) { extern char bootprog_name[], bootprog_rev[]; int chosen; char bootline[512]; /* Should check size? */ char *cp, *startbuf, *endbuf; u_long marks[MARK_MAX], size; u_int32_t entry; void *ssym, *esym; printf("\n"); printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev); /* * Get the boot arguments from Openfirmware */ if ((chosen = OF_finddevice("/chosen")) == -1 || OF_getprop(chosen, "bootpath", bootdev, sizeof bootdev) < 0 || OF_getprop(chosen, "bootargs", bootline, sizeof bootline) < 0) { printf("Invalid Openfirmware environment\n"); OF_exit(); } prom2boot(bootdev); parseargs(bootline, &boothowto); DPRINTF("bootline=%s\n", bootline); /* * Per the ARM OpenFirmware bindings, the firmware must * allocate and map at least 6MB of physical memory starting * at VA 0xf0000000. We have been loaded at 0xf0000000, * and the memory after us has been unmapped and freed. * We expect to load the kernel at 0xf0100000, so we will * allocate 5MB of virtual memory starting there, and * unmap/free what we don't use. */ startbuf = OF_claim((void *) 0xf0100000, (5 * 1024 * 1024), 0); if (startbuf != (void *) 0xf0100000) { printf("Unable to claim buffer for kernel\n"); OF_exit(); } endbuf = startbuf + (5 * 1024 * 1024); for (;;) { int i; if (boothowto & RB_ASKNAME) { printf("Boot: "); gets(bootline); parseargs(bootline, &boothowto); } if (bootline[0]) { kernels[0] = bootline; kernels[1] = NULL; } for (i = 0; kernels[i]; i++) { DPRINTF("Trying %s\n", kernels[i]); marks[MARK_START] = 0xf0100000; if (loadfile(kernels[i], marks, LOAD_KERNEL) >= 0) goto loaded; } boothowto |= RB_ASKNAME; } loaded: /* * Okay, kernel is loaded, free the extra memory at the end. * Round to the ARM OpenFirmare page size (4k). */ cp = (char *) ((marks[MARK_END] + 0xfff) & ~0xfff); size = (u_long) (endbuf - cp); if (size) OF_release(cp, size); #ifdef __notyet__ OF_setprop(chosen, "bootpath", opened_name, strlen(opened_name) + 1); cp = bootline; #else strcpy(bootline, opened_name); cp = bootline + strlen(bootline); *cp++ = ' '; #endif *cp = '-'; if (boothowto & RB_ASKNAME) *++cp = 'a'; if (boothowto & RB_SINGLE) *++cp = 's'; if (boothowto & RB_KDB) *++cp = 'd'; if (*cp == '-') #ifdef __notyet__ *cp = 0; #else *--cp = 0; #endif else