int main(int argc, char *argv[]) { int i; int debugflag = 0, keep_video = 0; const char *kernel_name = NULL; const char *ramdisk_name = NULL; char commandline[CL_SIZE] = ""; ProgramName = argv[0]; while (--argc) { argv++; if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) Usage(); else if (!strcmp(argv[0], "-k") || !strcmp(argv[0], "--kernel")) if (--argc && !kernel_name) { kernel_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-r") || !strcmp(argv[0], "--ramdisk")) if (--argc && !ramdisk_name) { ramdisk_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-d") || !strcmp(argv[0], "--debug")) debugflag = 1; else if (!strcmp(argv[0], "-m") || !strcmp(argv[0], "--memfile")) if (--argc && !memfile_name) { memfile_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--keep-video")) keep_video = 1; else if (!strcmp(argv[0], "-t") || !strcmp(argv[0], "--model")) if (--argc && !model) { model = atoi(argv[1]); argv++; } else Usage(); else break; } if (!kernel_name) kernel_name = "vmlinux"; SysBase = *(struct ExecBase **)4; /* open Expansion Library */ ExpansionBase = (struct ExpansionBase *)OpenLibrary("expansion.library", 36); if (!ExpansionBase) { fputs("Unable to open expansion.library V36 or greater! Aborting...\n", stderr); exit(EXIT_FAILURE); } /* open Graphics Library */ GfxBase = (struct GfxBase *)OpenLibrary ("graphics.library", 0); if (!GfxBase) { fputs("Unable to open graphics.library! Aborting...\n", stderr); exit(EXIT_FAILURE); } /* * Join command line options */ i = 0; while (argc--) { if ((i+strlen(*argv)+1) < CL_SIZE) { i += strlen(*argv) + 1; if (commandline[0]) strcat(commandline, " "); strcat(commandline, *argv++); } } args.kernelname = kernel_name; args.ramdiskname = ramdisk_name; args.commandline = commandline; args.debugflag = debugflag; args.keep_video = keep_video; args.reset_boards = 1; args.puts = Puts; args.getchar = GetChar; args.putchar = PutChar; args.printf = Printf; args.open = Open; args.seek = Seek; args.read = Read; args.close = Close; args.filesize = FileSize; args.sleep = Sleep; args.modify_bootinfo = ModifyBootinfo; /* Do The Right Stuff */ linuxboot(&args); CloseLibrary((struct Library *)GfxBase); CloseLibrary((struct Library *)ExpansionBase); /* if we ever get here, something went wrong */ exit(EXIT_FAILURE); }
int main(int argc, char *argv[]) { int i; int processor = 0, debugflag = 0, keep_video = 0; int apus_boot = 0, checksum = 0; u_int baud = 0; const char *kernel_name = NULL; const char *ramdisk_name = NULL; char commandline[CL_SIZE] = ""; ProgramName = argv[0]; while (--argc) { argv++; if (!strcmp(argv[0], "-h") || !strcmp(argv[0], "--help")) Usage(); else if (!strcmp(argv[0], "-k") || !strcmp(argv[0], "--kernel")) if (--argc && !kernel_name) { kernel_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-r") || !strcmp(argv[0], "--ramdisk")) if (--argc && !ramdisk_name) { ramdisk_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-d") || !strcmp(argv[0], "--debug")) debugflag = 1; else if (!strcmp(argv[0], "-b") || !strcmp(argv[0], "--baud")) if (--argc && !baud) { baud = atoi(argv[1]); argv++; } else Usage(); else if (!strcmp(argv[0], "-m") || !strcmp(argv[0], "--memfile")) if (--argc && !memfile_name) { memfile_name = argv[1]; argv++; } else Usage(); else if (!strcmp(argv[0], "-v") || !strcmp(argv[0], "--keep-video")) keep_video = 1; else if (!strcmp(argv[0], "-t") || !strcmp(argv[0], "--model")) if (--argc && !model) { model = atoi(argv[1]); argv++; } else Usage(); else if (!strcmp(argv[0], "-p") || !strcmp(argv[0], "--processor")) if (--argc && !processor) { processor = atoi(argv[1]); argv++; } else Usage(); else if (!strcmp(argv[0], "--apus")) apus_boot = 1; else if (!strcmp(argv[0], "--checksum")) checksum = 1; else break; } if (!kernel_name) kernel_name = "vmlinux"; SysBase = *(struct ExecBase **)4; if (apus_boot) { if (!(PPCLibBasePTR = (struct PPCLibBase *) OpenLibrary("ppc.library", 45))){ fprintf(stderr, "Cannot open ppc.library version45+\n"); return (FALSE); } } /* * Join command line options */ i = 0; while (argc--) { if ((i+strlen(*argv)+1) < CL_SIZE) { i += strlen(*argv) + 1; if (commandline[0]) strcat(commandline, " "); strcat(commandline, *argv++); } } memset(&args.bi, 0, sizeof(args.bi)); if (processor) { int cpu = processor/100%10; int fpu = processor/10%10; int mmu = processor%10; if (cpu) args.bi.cputype = 1<<(cpu-1); if (fpu) args.bi.fputype = 1<<(fpu-1); if (mmu) args.bi.mmutype = 1<<(mmu-1); } /* * If we have a memory file, read the memory information from it */ if (memfile_name) { FILE *fp; int i; if ((fp = fopen(memfile_name, "r")) == NULL) { perror("open memory file"); fprintf(stderr, "Cannot open memory file %s\n", memfile_name); return(FALSE); } if (fscanf(fp, "%lu", &args.bi.chip_size) != 1) { fprintf(stderr, "memory file does not contain chip memory size\n"); fclose(fp); return(FALSE); } for (i = 0; i < NUM_MEMINFO; i++) if (fscanf(fp, "%lx %lu", &args.bi.memory[i].addr, &args.bi.memory[i].size) != 2) break; fclose(fp); args.bi.num_memory = i; } strncpy(args.bi.command_line, commandline, CL_SIZE); args.bi.command_line[CL_SIZE-1] = '\0'; if (model != AMI_UNKNOWN) args.bi.model = model; args.apus_boot = apus_boot; args.checksum = checksum; args.kernelname = kernel_name; args.ramdiskname = ramdisk_name; args.debugflag = debugflag; args.keep_video = keep_video; args.reset_boards = 1; args.baud = baud; args.puts = Puts; args.getchar = GetChar; args.putchar = PutChar; args.printf = Printf; args.open = Open; args.seek = Seek; args.read = Read; args.close = Close; args.filesize = FileSize; args.sleep = Sleep; /* Do The Right Stuff */ linuxboot(&args); /* if we ever get here, something went wrong */ exit(EXIT_FAILURE); }