2494 |
} |
} |
2495 |
|
|
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 |
|
/***********************************************************/ |
2524 |
/* main execution loop */ |
/* main execution loop */ |
2525 |
|
|
2526 |
void gui_update(void *opaque) |
void gui_update(void *opaque) |
2762 |
"'disk_image' is a raw hard image image for IDE hard disk 0\n" |
"'disk_image' is a raw hard image image for IDE hard disk 0\n" |
2763 |
"\n" |
"\n" |
2764 |
"Standard options:\n" |
"Standard options:\n" |
2765 |
|
"-M machine select emulated machine (-M ? for list)\n" |
2766 |
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n" |
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n" |
2767 |
"-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" |
"-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" |
2768 |
"-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" |
"-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" |
2780 |
#ifdef TARGET_I386 |
#ifdef TARGET_I386 |
2781 |
"-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n" |
"-win2k-hack use it when installing Windows 2000 to avoid a disk full bug\n" |
2782 |
#endif |
#endif |
|
#ifdef TARGET_PPC |
|
|
"-prep Simulate a PREP system (default is PowerMAC)\n" |
|
|
#endif |
|
2783 |
#if defined(TARGET_PPC) || defined(TARGET_SPARC) |
#if defined(TARGET_PPC) || defined(TARGET_SPARC) |
2784 |
"-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" |
"-g WxH[xDEPTH] Set the initial graphical resolution and depth\n" |
2785 |
#endif |
#endif |
2860 |
enum { |
enum { |
2861 |
QEMU_OPTION_h, |
QEMU_OPTION_h, |
2862 |
|
|
2863 |
|
QEMU_OPTION_M, |
2864 |
QEMU_OPTION_fda, |
QEMU_OPTION_fda, |
2865 |
QEMU_OPTION_fdb, |
QEMU_OPTION_fdb, |
2866 |
QEMU_OPTION_hda, |
QEMU_OPTION_hda, |
2922 |
const QEMUOption qemu_options[] = { |
const QEMUOption qemu_options[] = { |
2923 |
{ "h", 0, QEMU_OPTION_h }, |
{ "h", 0, QEMU_OPTION_h }, |
2924 |
|
|
2925 |
|
{ "M", HAS_ARG, QEMU_OPTION_M }, |
2926 |
{ "fda", HAS_ARG, QEMU_OPTION_fda }, |
{ "fda", HAS_ARG, QEMU_OPTION_fda }, |
2927 |
{ "fdb", HAS_ARG, QEMU_OPTION_fdb }, |
{ "fdb", HAS_ARG, QEMU_OPTION_fdb }, |
2928 |
{ "hda", HAS_ARG, QEMU_OPTION_hda }, |
{ "hda", HAS_ARG, QEMU_OPTION_hda }, |
3034 |
} |
} |
3035 |
} |
} |
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 |
|
|
3051 |
#define NET_IF_TUN 0 |
#define NET_IF_TUN 0 |
3052 |
#define NET_IF_USER 1 |
#define NET_IF_USER 1 |
3053 |
#define NET_IF_DUMMY 2 |
#define NET_IF_DUMMY 2 |
3057 |
#ifdef CONFIG_GDBSTUB |
#ifdef CONFIG_GDBSTUB |
3058 |
int use_gdbstub, gdbstub_port; |
int use_gdbstub, gdbstub_port; |
3059 |
#endif |
#endif |
3060 |
int i, has_cdrom; |
int i, cdrom_index; |
3061 |
int snapshot, linux_boot; |
int snapshot, linux_boot; |
3062 |
CPUState *env; |
CPUState *env; |
3063 |
const char *initrd_filename; |
const char *initrd_filename; |
3077 |
char parallel_devices[MAX_PARALLEL_PORTS][128]; |
char parallel_devices[MAX_PARALLEL_PORTS][128]; |
3078 |
int parallel_device_index; |
int parallel_device_index; |
3079 |
const char *loadvm = NULL; |
const char *loadvm = NULL; |
3080 |
|
QEMUMachine *machine; |
3081 |
|
|
3082 |
#if !defined(CONFIG_SOFTMMU) |
#if !defined(CONFIG_SOFTMMU) |
3083 |
/* we never want that malloc() uses mmap() */ |
/* we never want that malloc() uses mmap() */ |
3084 |
mallopt(M_MMAP_THRESHOLD, 4096 * 1024); |
mallopt(M_MMAP_THRESHOLD, 4096 * 1024); |
3085 |
#endif |
#endif |
3086 |
|
register_machines(); |
3087 |
|
machine = first_machine; |
3088 |
initrd_filename = NULL; |
initrd_filename = NULL; |
3089 |
for(i = 0; i < MAX_FD; i++) |
for(i = 0; i < MAX_FD; i++) |
3090 |
fd_filename[i] = NULL; |
fd_filename[i] = NULL; |
3102 |
nographic = 0; |
nographic = 0; |
3103 |
kernel_filename = NULL; |
kernel_filename = NULL; |
3104 |
kernel_cmdline = ""; |
kernel_cmdline = ""; |
3105 |
has_cdrom = 1; |
#ifdef TARGET_PPC |
3106 |
|
cdrom_index = 1; |
3107 |
|
#else |
3108 |
|
cdrom_index = 2; |
3109 |
|
#endif |
3110 |
cyls = heads = secs = 0; |
cyls = heads = secs = 0; |
3111 |
translation = BIOS_ATA_TRANSLATION_AUTO; |
translation = BIOS_ATA_TRANSLATION_AUTO; |
3112 |
pstrcpy(monitor_device, sizeof(monitor_device), "vc"); |
pstrcpy(monitor_device, sizeof(monitor_device), "vc"); |
3166 |
} |
} |
3167 |
|
|
3168 |
switch(popt->index) { |
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; |
3182 |
case QEMU_OPTION_initrd: |
case QEMU_OPTION_initrd: |
3183 |
initrd_filename = optarg; |
initrd_filename = optarg; |
3184 |
break; |
break; |
3185 |
case QEMU_OPTION_hda: |
case QEMU_OPTION_hda: |
|
hd_filename[0] = optarg; |
|
|
break; |
|
3186 |
case QEMU_OPTION_hdb: |
case QEMU_OPTION_hdb: |
3187 |
hd_filename[1] = optarg; |
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 |
|
} |
3196 |
break; |
break; |
3197 |
case QEMU_OPTION_snapshot: |
case QEMU_OPTION_snapshot: |
3198 |
snapshot = 1; |
snapshot = 1; |
3259 |
} |
} |
3260 |
} |
} |
3261 |
break; |
break; |
|
case QEMU_OPTION_hdc: |
|
|
hd_filename[2] = optarg; |
|
|
has_cdrom = 0; |
|
|
break; |
|
|
case QEMU_OPTION_hdd: |
|
|
hd_filename[3] = optarg; |
|
|
break; |
|
3262 |
case QEMU_OPTION_cdrom: |
case QEMU_OPTION_cdrom: |
3263 |
hd_filename[2] = optarg; |
if (cdrom_index >= 0) { |
3264 |
has_cdrom = 1; |
hd_filename[cdrom_index] = optarg; |
3265 |
|
} |
3266 |
break; |
break; |
3267 |
case QEMU_OPTION_boot: |
case QEMU_OPTION_boot: |
3268 |
boot_device = optarg[0]; |
boot_device = optarg[0]; |
3482 |
|
|
3483 |
linux_boot = (kernel_filename != NULL); |
linux_boot = (kernel_filename != NULL); |
3484 |
|
|
3485 |
if (!linux_boot && hd_filename[0] == '\0' && hd_filename[2] == '\0' && |
if (!linux_boot && |
3486 |
|
hd_filename[0] == '\0' && |
3487 |
|
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && |
3488 |
fd_filename[0] == '\0') |
fd_filename[0] == '\0') |
3489 |
help(); |
help(); |
3490 |
|
|
3594 |
|
|
3595 |
/* we always create the cdrom drive, even if no disk is there */ |
/* we always create the cdrom drive, even if no disk is there */ |
3596 |
bdrv_init(); |
bdrv_init(); |
3597 |
if (has_cdrom) { |
if (cdrom_index >= 0) { |
3598 |
bs_table[2] = bdrv_new("cdrom"); |
bs_table[cdrom_index] = bdrv_new("cdrom"); |
3599 |
bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); |
bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); |
3600 |
} |
} |
3601 |
|
|
3602 |
/* open the virtual block devices */ |
/* open the virtual block devices */ |
3747 |
#endif |
#endif |
3748 |
init_timers(); |
init_timers(); |
3749 |
|
|
3750 |
#if defined(TARGET_I386) |
machine->init(ram_size, vga_ram_size, boot_device, |
3751 |
pc_init(ram_size, vga_ram_size, boot_device, |
ds, fd_filename, snapshot, |
3752 |
ds, fd_filename, snapshot, |
kernel_filename, kernel_cmdline, initrd_filename); |
|
kernel_filename, kernel_cmdline, initrd_filename); |
|
|
#elif defined(TARGET_PPC) |
|
|
ppc_init(ram_size, vga_ram_size, boot_device, |
|
|
ds, fd_filename, snapshot, |
|
|
kernel_filename, kernel_cmdline, initrd_filename); |
|
|
#elif defined(TARGET_SPARC) |
|
|
sun4m_init(ram_size, vga_ram_size, boot_device, |
|
|
ds, fd_filename, snapshot, |
|
|
kernel_filename, kernel_cmdline, initrd_filename); |
|
|
#endif |
|
3753 |
|
|
3754 |
gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); |
gui_timer = qemu_new_timer(rt_clock, gui_update, NULL); |
3755 |
qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); |
qemu_mod_timer(gui_timer, qemu_get_clock(rt_clock)); |