- }
- file.fs->close(&file);
- memset(&file, 0, sizeof(file));
- }
- if (initrd_base)
- prom_printf("ramdisk loaded at %p, size: %lu Kbytes\n",
- initrd_base, initrd_size >> 10);
- else {
- prom_printf("ramdisk load failed !\n");
- prom_pause();
- }
- }
-
- DEBUG_F("setting kernel args to: %s\n", params.args);
- prom_setargs(params.args);
- DEBUG_F("flushing icache...");
- flush_icache_range ((long)loadinfo.base, (long)loadinfo.base+loadinfo.memsize);
- DEBUG_F(" done\n");
-
- /*
- * Fill mew boot infos
- *
- * The birec is low on memory, probably inside the malloc pool, so
- * we don't write it earlier. At this point, we should not use anything
- * coming from the malloc pool
- */
- birec = (struct bi_record *)_ALIGN(loadinfo.filesize+(1<<20)-1,(1<<20));
-
- /* We make sure it's mapped. We map only 64k for now, it's plenty enough
- * we don't claim since this precise memory range may already be claimed
- * by the malloc pool
- */
- prom_map (birec, birec, 0x10000);
- DEBUG_F("birec at %p\n", birec);
- DEBUG_SLEEP;
-
- birec->tag = BI_FIRST;
- birec->size = sizeof(struct bi_record);
- birec = (struct bi_record *)((unsigned long)birec + birec->size);
-
- birec->tag = BI_BOOTLOADER_ID;
- sprintf( (char *)birec->data, "yaboot");
- birec->size = sizeof(struct bi_record) + strlen("yaboot") + 1;
- birec = (struct bi_record *)((unsigned long)birec + birec->size);
-
- birec->tag = BI_MACHTYPE;
- birec->data[0] = _machine;
- birec->size = sizeof(struct bi_record) + sizeof(unsigned long);
- birec = (struct bi_record *)((unsigned long)birec + birec->size);
-
- if (sysmap_base) {
- birec->tag = BI_SYSMAP;
- birec->data[0] = (unsigned long)sysmap_base;
- birec->data[1] = sysmap_size;
- birec->size = sizeof(struct bi_record) + sizeof(unsigned long)*2;
- birec = (struct bi_record *)((unsigned long)birec + birec->size);
- }
- birec->tag = BI_LAST;
- birec->size = sizeof(struct bi_record);
- birec = (struct bi_record *)((unsigned long)birec + birec->size);
-
- /* compute the kernel's entry point. */
- kernel_entry = loadinfo.base + loadinfo.entry - loadinfo.load_loc;
-
- DEBUG_F("Kernel entry point = %p\n", kernel_entry);
- DEBUG_F("kernel: arg1 = %p,\n"
- " arg2 = 0x%08lx,\n"
- " prom = %p,\n"
- " arg4 = %d,\n"
- " arg5 = %d\n\n",
- initrd_base + loadinfo.load_loc, initrd_size, prom, 0, 0);
-
- DEBUG_F("Entering kernel...\n");
-
- /* call the kernel with our stack. */
- kernel_entry(initrd_base + loadinfo.load_loc, initrd_size, prom, 0, 0);
- continue;
-next:
- ; /* do nothing */
- }
+ strcpy(loc,boot.file);
+ strcat(loc,params.sysmap.file);
+ free(params.sysmap.file);
+ params.sysmap.file=loc;
+ }
+
+ result = open_file(¶ms.sysmap, &file);
+ if (result != FILE_ERR_OK) {
+ prom_printf("%s:%d,", params.sysmap.dev, params.sysmap.part);
+ prom_perror(result, params.sysmap.file);
+ }
+ else {
+ sysmap_base = prom_claim(loadinfo.base+loadinfo.memsize, 0x100000, 0);
+ if (sysmap_base == (void *)-1) {
+ prom_printf("Claim failed for sysmap memory\n");
+ prom_pause();
+ sysmap_base = 0;
+ } else {
+ sysmap_size = file.fs->read(&file, 0xfffff, sysmap_base);
+ if (sysmap_size == 0)
+ sysmap_base = 0;
+ else
+ ((char *)sysmap_base)[sysmap_size++] = 0;
+ }
+ file.fs->close(&file);
+ memset(&file, 0, sizeof(file));
+ }
+ if (sysmap_base) {
+ prom_printf("System.map loaded at %p, size: %lu Kbytes\n",
+ sysmap_base, sysmap_size >> 10);
+ loadinfo.memsize += _ALIGN(0x100000, 0x1000);
+ } else {
+ prom_printf("System.map load failed !\n");
+ prom_pause();
+ }
+ }
+
+ /* If ramdisk, load it (only if booting a vmlinux). For now, we
+ * can't tell the size it will be so we claim an arbitrary amount
+ * of 4Mb.
+ */
+ if (flat_vmlinux && params.rd.file) {
+ if(strlen(boot.file) && !strcmp(boot.file,"\\\\") && params.rd.file[0] != '/'
+ && params.kernel.file[0] != '\\')
+ {
+ if (loc) free(loc);
+ loc=(char*)malloc(strlen(params.rd.file)+3);
+ if (!loc) {
+ prom_printf ("Malloc error\n");
+ goto next;
+ }
+ strcpy(loc,boot.file);
+ strcat(loc,params.rd.file);
+ free(params.rd.file);
+ params.rd.file=loc;
+ }
+ prom_printf("Loading ramdisk...\n");
+ result = open_file(¶ms.rd, &file);
+ if (result != FILE_ERR_OK) {
+ prom_printf("%s:%d,", params.rd.dev, params.rd.part);
+ prom_perror(result, params.rd.file);
+ }
+ else {
+#define INITRD_CHUNKSIZE 0x100000
+ initrd_base = prom_claim(loadinfo.base+loadinfo.memsize, INITRD_CHUNKSIZE, 0);
+ if (initrd_base == (void *)-1) {
+ prom_printf("Claim failed for initrd memory\n");
+ initrd_base = 0;
+ } else {
+ initrd_size = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_base);
+ if (initrd_size == 0)
+ initrd_base = 0;
+ initrd_read = initrd_size;
+ initrd_more = initrd_base;
+ while (initrd_read == INITRD_CHUNKSIZE ) { /* need to read more? */
+ initrd_want = (void *)((unsigned long)initrd_more+INITRD_CHUNKSIZE);
+ initrd_more = prom_claim(initrd_want, INITRD_CHUNKSIZE, 0);
+ if (initrd_more != initrd_want) {
+ prom_printf("Claim failed for initrd memory at %p rc=%p\n",initrd_want,initrd_more);
+ prom_pause();
+ break;
+ }
+ initrd_read = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_more);
+ DEBUG_F(" block at %p rc=%lu\n",initrd_more,initrd_read);
+ initrd_size += initrd_read;
+ }
+ }
+ file.fs->close(&file);
+ memset(&file, 0, sizeof(file));
+ }
+ if (initrd_base)
+ prom_printf("ramdisk loaded at %p, size: %lu Kbytes\n",
+ initrd_base, initrd_size >> 10);
+ else {
+ prom_printf("ramdisk load failed !\n");
+ prom_pause();
+ }
+ }
+
+ DEBUG_F("setting kernel args to: %s\n", params.args);
+ prom_setargs(params.args);
+ DEBUG_F("flushing icache...");
+ flush_icache_range ((long)loadinfo.base, (long)loadinfo.base+loadinfo.memsize);
+ DEBUG_F(" done\n");
+
+ if (flat_vmlinux) {
+ /*
+ * Fill new boot infos (only if booting a vmlinux).
+ *
+ * The birec is low on memory, probably inside the malloc pool,
+ * so we don't write it earlier. At this point, we should not
+ * use anything coming from the malloc pool.
+ */
+ birec = (struct bi_record *)_ALIGN(loadinfo.filesize+(1<<20)-1,(1<<20));
+
+ /* We make sure it's mapped. We map only 64k for now, it's
+ * plenty enough we don't claim since this precise memory
+ * range may already be claimed by the malloc pool.
+ */
+ prom_map (birec, birec, 0x10000);
+ DEBUG_F("birec at %p\n", birec);
+ DEBUG_SLEEP;
+
+ birec->tag = BI_FIRST;
+ birec->size = sizeof(struct bi_record);
+ birec = (struct bi_record *)((ulong)birec + birec->size);
+
+ birec->tag = BI_BOOTLOADER_ID;
+ sprintf( (char *)birec->data, "yaboot");
+ birec->size = sizeof(struct bi_record) + strlen("yaboot") + 1;
+ birec = (struct bi_record *)((ulong)birec + birec->size);
+
+ birec->tag = BI_MACHTYPE;
+ birec->data[0] = _machine;
+ birec->size = sizeof(struct bi_record) + sizeof(ulong);
+ birec = (struct bi_record *)((ulong)birec + birec->size);
+
+ if (sysmap_base) {
+ birec->tag = BI_SYSMAP;
+ birec->data[0] = (ulong)sysmap_base;
+ birec->data[1] = sysmap_size;
+ birec->size = sizeof(struct bi_record) + sizeof(ulong)*2;
+ birec = (struct bi_record *)((ulong)birec + birec->size);
+ }
+ birec->tag = BI_LAST;
+ birec->size = sizeof(struct bi_record);
+ birec = (struct bi_record *)((ulong)birec + birec->size);
+ }
+
+ /* compute the kernel's entry point. */
+ kernel_entry = loadinfo.base + loadinfo.entry - loadinfo.load_loc;
+
+ DEBUG_F("Kernel entry point = %p\n", kernel_entry);
+ DEBUG_F("kernel: arg1 = %p,\n"
+ " arg2 = 0x%08lx,\n"
+ " prom = %p,\n"
+ " arg4 = %d,\n"
+ " arg5 = %d\n\n",
+ initrd_base + loadinfo.load_loc, initrd_size, prom, 0, 0);
+
+ DEBUG_F("Entering kernel...\n");
+
+ /* call the kernel with our stack. */
+ kernel_entry(initrd_base + loadinfo.load_loc, initrd_size, prom, 0, 0);
+ continue;
+ next:
+ ; /* do nothing */
+ }