Commit cc1daa40f188ec3ea6c37db546887488a419e900
1 parent
2d618793
added -M machine option - permit to put CDROM on hdb on PPC to handle the case w…
…here a single IDE controller is present git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1444 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
88 additions
and
35 deletions
vl.c
... | ... | @@ -2494,6 +2494,33 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) |
2494 | 2494 | } |
2495 | 2495 | |
2496 | 2496 | /***********************************************************/ |
2497 | +/* machine registration */ | |
2498 | + | |
2499 | +QEMUMachine *first_machine = NULL; | |
2500 | + | |
2501 | +int qemu_register_machine(QEMUMachine *m) | |
2502 | +{ | |
2503 | + QEMUMachine **pm; | |
2504 | + pm = &first_machine; | |
2505 | + while (*pm != NULL) | |
2506 | + pm = &(*pm)->next; | |
2507 | + m->next = NULL; | |
2508 | + *pm = m; | |
2509 | + return 0; | |
2510 | +} | |
2511 | + | |
2512 | +QEMUMachine *find_machine(const char *name) | |
2513 | +{ | |
2514 | + QEMUMachine *m; | |
2515 | + | |
2516 | + for(m = first_machine; m != NULL; m = m->next) { | |
2517 | + if (!strcmp(m->name, name)) | |
2518 | + return m; | |
2519 | + } | |
2520 | + return NULL; | |
2521 | +} | |
2522 | + | |
2523 | +/***********************************************************/ | |
2497 | 2524 | /* main execution loop */ |
2498 | 2525 | |
2499 | 2526 | void gui_update(void *opaque) |
... | ... | @@ -2735,6 +2762,7 @@ void help(void) |
2735 | 2762 | "'disk_image' is a raw hard image image for IDE hard disk 0\n" |
2736 | 2763 | "\n" |
2737 | 2764 | "Standard options:\n" |
2765 | + "-M machine select emulated machine (-M ? for list)\n" | |
2738 | 2766 | "-fda/-fdb file use 'file' as floppy disk 0/1 image\n" |
2739 | 2767 | "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" |
2740 | 2768 | "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" |
... | ... | @@ -2752,9 +2780,6 @@ void help(void) |
2752 | 2780 | #ifdef TARGET_I386 |
2753 | 2781 | "-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n" |
2754 | 2782 | #endif |
2755 | -#ifdef TARGET_PPC | |
2756 | - "-prep Simulate a PREP system (default is PowerMAC)\n" | |
2757 | -#endif | |
2758 | 2783 | #if defined(TARGET_PPC) || defined(TARGET_SPARC) |
2759 | 2784 | "-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" |
2760 | 2785 | #endif |
... | ... | @@ -2835,6 +2860,7 @@ void help(void) |
2835 | 2860 | enum { |
2836 | 2861 | QEMU_OPTION_h, |
2837 | 2862 | |
2863 | + QEMU_OPTION_M, | |
2838 | 2864 | QEMU_OPTION_fda, |
2839 | 2865 | QEMU_OPTION_fdb, |
2840 | 2866 | QEMU_OPTION_hda, |
... | ... | @@ -2896,6 +2922,7 @@ typedef struct QEMUOption { |
2896 | 2922 | const QEMUOption qemu_options[] = { |
2897 | 2923 | { "h", 0, QEMU_OPTION_h }, |
2898 | 2924 | |
2925 | + { "M", HAS_ARG, QEMU_OPTION_M }, | |
2899 | 2926 | { "fda", HAS_ARG, QEMU_OPTION_fda }, |
2900 | 2927 | { "fdb", HAS_ARG, QEMU_OPTION_fdb }, |
2901 | 2928 | { "hda", HAS_ARG, QEMU_OPTION_hda }, |
... | ... | @@ -3007,6 +3034,20 @@ static void read_passwords(void) |
3007 | 3034 | } |
3008 | 3035 | } |
3009 | 3036 | |
3037 | +/* XXX: currently we cannot use simultaneously different CPUs */ | |
3038 | +void register_machines(void) | |
3039 | +{ | |
3040 | +#if defined(TARGET_I386) | |
3041 | + qemu_register_machine(&pc_machine); | |
3042 | +#elif defined(TARGET_PPC) | |
3043 | + qemu_register_machine(&heathrow_machine); | |
3044 | + qemu_register_machine(&core99_machine); | |
3045 | + qemu_register_machine(&prep_machine); | |
3046 | +#elif defined(TARGET_SPARC) | |
3047 | + qemu_register_machine(&sun4m_machine); | |
3048 | +#endif | |
3049 | +} | |
3050 | + | |
3010 | 3051 | #define NET_IF_TUN 0 |
3011 | 3052 | #define NET_IF_USER 1 |
3012 | 3053 | #define NET_IF_DUMMY 2 |
... | ... | @@ -3016,7 +3057,7 @@ int main(int argc, char **argv) |
3016 | 3057 | #ifdef CONFIG_GDBSTUB |
3017 | 3058 | int use_gdbstub, gdbstub_port; |
3018 | 3059 | #endif |
3019 | - int i, has_cdrom; | |
3060 | + int i, cdrom_index; | |
3020 | 3061 | int snapshot, linux_boot; |
3021 | 3062 | CPUState *env; |
3022 | 3063 | const char *initrd_filename; |
... | ... | @@ -3036,11 +3077,14 @@ int main(int argc, char **argv) |
3036 | 3077 | char parallel_devices[MAX_PARALLEL_PORTS][128]; |
3037 | 3078 | int parallel_device_index; |
3038 | 3079 | const char *loadvm = NULL; |
3039 | - | |
3080 | + QEMUMachine *machine; | |
3081 | + | |
3040 | 3082 | #if !defined(CONFIG_SOFTMMU) |
3041 | 3083 | /* we never want that malloc() uses mmap() */ |
3042 | 3084 | mallopt(M_MMAP_THRESHOLD, 4096 * 1024); |
3043 | 3085 | #endif |
3086 | + register_machines(); | |
3087 | + machine = first_machine; | |
3044 | 3088 | initrd_filename = NULL; |
3045 | 3089 | for(i = 0; i < MAX_FD; i++) |
3046 | 3090 | fd_filename[i] = NULL; |
... | ... | @@ -3058,7 +3102,11 @@ int main(int argc, char **argv) |
3058 | 3102 | nographic = 0; |
3059 | 3103 | kernel_filename = NULL; |
3060 | 3104 | kernel_cmdline = ""; |
3061 | - has_cdrom = 1; | |
3105 | +#ifdef TARGET_PPC | |
3106 | + cdrom_index = 1; | |
3107 | +#else | |
3108 | + cdrom_index = 2; | |
3109 | +#endif | |
3062 | 3110 | cyls = heads = secs = 0; |
3063 | 3111 | translation = BIOS_ATA_TRANSLATION_AUTO; |
3064 | 3112 | pstrcpy(monitor_device, sizeof(monitor_device), "vc"); |
... | ... | @@ -3118,14 +3166,33 @@ int main(int argc, char **argv) |
3118 | 3166 | } |
3119 | 3167 | |
3120 | 3168 | switch(popt->index) { |
3169 | + case QEMU_OPTION_M: | |
3170 | + machine = find_machine(optarg); | |
3171 | + if (!machine) { | |
3172 | + QEMUMachine *m; | |
3173 | + printf("Supported machines are:\n"); | |
3174 | + for(m = first_machine; m != NULL; m = m->next) { | |
3175 | + printf("%-10s %s%s\n", | |
3176 | + m->name, m->desc, | |
3177 | + m == first_machine ? " (default)" : ""); | |
3178 | + } | |
3179 | + exit(1); | |
3180 | + } | |
3181 | + break; | |
3121 | 3182 | case QEMU_OPTION_initrd: |
3122 | 3183 | initrd_filename = optarg; |
3123 | 3184 | break; |
3124 | 3185 | case QEMU_OPTION_hda: |
3125 | - hd_filename[0] = optarg; | |
3126 | - break; | |
3127 | 3186 | case QEMU_OPTION_hdb: |
3128 | - hd_filename[1] = optarg; | |
3187 | + case QEMU_OPTION_hdc: | |
3188 | + case QEMU_OPTION_hdd: | |
3189 | + { | |
3190 | + int hd_index; | |
3191 | + hd_index = popt->index - QEMU_OPTION_hda; | |
3192 | + hd_filename[hd_index] = optarg; | |
3193 | + if (hd_index == cdrom_index) | |
3194 | + cdrom_index = -1; | |
3195 | + } | |
3129 | 3196 | break; |
3130 | 3197 | case QEMU_OPTION_snapshot: |
3131 | 3198 | snapshot = 1; |
... | ... | @@ -3192,16 +3259,10 @@ int main(int argc, char **argv) |
3192 | 3259 | } |
3193 | 3260 | } |
3194 | 3261 | break; |
3195 | - case QEMU_OPTION_hdc: | |
3196 | - hd_filename[2] = optarg; | |
3197 | - has_cdrom = 0; | |
3198 | - break; | |
3199 | - case QEMU_OPTION_hdd: | |
3200 | - hd_filename[3] = optarg; | |
3201 | - break; | |
3202 | 3262 | case QEMU_OPTION_cdrom: |
3203 | - hd_filename[2] = optarg; | |
3204 | - has_cdrom = 1; | |
3263 | + if (cdrom_index >= 0) { | |
3264 | + hd_filename[cdrom_index] = optarg; | |
3265 | + } | |
3205 | 3266 | break; |
3206 | 3267 | case QEMU_OPTION_boot: |
3207 | 3268 | boot_device = optarg[0]; |
... | ... | @@ -3421,7 +3482,9 @@ int main(int argc, char **argv) |
3421 | 3482 | |
3422 | 3483 | linux_boot = (kernel_filename != NULL); |
3423 | 3484 | |
3424 | - if (!linux_boot && hd_filename[0] == '\0' && hd_filename[2] == '\0' && | |
3485 | + if (!linux_boot && | |
3486 | + hd_filename[0] == '\0' && | |
3487 | + (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && | |
3425 | 3488 | fd_filename[0] == '\0') |
3426 | 3489 | help(); |
3427 | 3490 | |
... | ... | @@ -3531,9 +3594,9 @@ int main(int argc, char **argv) |
3531 | 3594 | |
3532 | 3595 | /* we always create the cdrom drive, even if no disk is there */ |
3533 | 3596 | bdrv_init(); |
3534 | - if (has_cdrom) { | |
3535 | - bs_table[2] = bdrv_new("cdrom"); | |
3536 | - bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); | |
3597 | + if (cdrom_index >= 0) { | |
3598 | + bs_table[cdrom_index] = bdrv_new("cdrom"); | |
3599 | + bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); | |
3537 | 3600 | } |
3538 | 3601 | |
3539 | 3602 | /* open the virtual block devices */ |
... | ... | @@ -3684,19 +3747,9 @@ int main(int argc, char **argv) |
3684 | 3747 | #endif |
3685 | 3748 | init_timers(); |
3686 | 3749 | |
3687 | -#if defined(TARGET_I386) | |
3688 | - pc_init(ram_size, vga_ram_size, boot_device, | |
3689 | - ds, fd_filename, snapshot, | |
3690 | - kernel_filename, kernel_cmdline, initrd_filename); | |
3691 | -#elif defined(TARGET_PPC) | |
3692 | - ppc_init(ram_size, vga_ram_size, boot_device, | |
3693 | - ds, fd_filename, snapshot, | |
3694 | - kernel_filename, kernel_cmdline, initrd_filename); | |
3695 | -#elif defined(TARGET_SPARC) | |
3696 | - sun4m_init(ram_size, vga_ram_size, boot_device, | |
3697 | - ds, fd_filename, snapshot, | |
3698 | - kernel_filename, kernel_cmdline, initrd_filename); | |
3699 | -#endif | |
3750 | + machine->init(ram_size, vga_ram_size, boot_device, | |
3751 | + ds, fd_filename, snapshot, | |
3752 | + kernel_filename, kernel_cmdline, initrd_filename); | |
3700 | 3753 | |
3701 | 3754 | gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); |
3702 | 3755 | qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); | ... | ... |