diff --git a/bochs/bochs.h b/bochs/bochs.h index 9db6b1123..5c0220fbd 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: bochs.h,v 1.172 2006-02-16 21:44:16 vruppert Exp $ +// $Id: bochs.h,v 1.173 2006-02-17 22:27:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -471,15 +471,6 @@ typedef struct { bx_param_num_c *Oirq; } bx_ata_options; -typedef struct { - bx_param_string_c *Opath; - bx_param_num_c *Oaddress; -} bx_rom_options; - -typedef struct { - bx_param_string_c *Opath; -} bx_vgarom_options; - typedef struct { bx_param_num_c *Onprocessors; bx_param_num_c *Oncores; @@ -488,10 +479,6 @@ typedef struct { bx_param_bool_c *Oreset_on_triple_fault; } bx_cpu_options; -typedef struct { - bx_param_num_c *Osize; -} bx_mem_options; - typedef struct { bx_param_bool_c *Oenabled; bx_param_string_c *Ooutfile; @@ -584,12 +571,7 @@ typedef struct BOCHSAPI { bx_usb_options usb[BX_N_USB_HUBS]; bx_pcislot_options pcislot[BX_N_PCI_SLOTS]; bx_pnic_options pnic; - bx_rom_options rom; - bx_vgarom_options vgarom; - bx_rom_options optrom[BX_N_OPTROM_IMAGES]; // Optional rom images - bx_rom_options optram[BX_N_OPTRAM_IMAGES]; // Optional ram images bx_cpu_options cpu; - bx_mem_options memory; bx_parport_options par[BX_N_PARALLEL_PORTS]; // parallel ports bx_sb16_options sb16; bx_param_enum_c *Obootdrive[3]; diff --git a/bochs/config.cc b/bochs/config.cc index ca29c327b..d736a444e 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.74 2006-02-16 21:44:16 vruppert Exp $ +// $Id: config.cc,v 1.75 2006-02-17 22:27:38 vruppert Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -813,108 +813,111 @@ void bx_init_options () bx_list_c *optram = new bx_list_c (memory, "optram", ""); // memory options (ram & rom) - bx_options.memory.Osize = new bx_param_num_c (ram, + bx_param_num_c *ramsize = new bx_param_num_c(ram, "size", "Amount of RAM in megabytes", 1, 2048, BX_DEFAULT_MEM_MEGS); - bx_options.memory.Osize->set_format ("Memory size in megabytes: %d"); - bx_options.memory.Osize->set_ask_format ("Enter memory size (MB): [%d] "); + ramsize->set_format("Memory size in megabytes: %d"); + ramsize->set_ask_format("Enter memory size (MB): [%d] "); #if BX_WITH_WX - bx_options.memory.Osize->set_label ("Memory size (megabytes)"); - bx_options.memory.Osize->set_options (bx_param_num_c::USE_SPIN_CONTROL); + ramsize->set_label("Memory size (megabytes)"); + ramsize->set_options(bx_param_num_c::USE_SPIN_CONTROL); #endif - bx_options.rom.Opath = new bx_param_filename_c (rom, + bx_param_filename_c *rompath = new bx_param_filename_c(rom, "path", "Pathname of ROM image to load", "", BX_PATHNAME_LEN); - bx_options.rom.Opath->set_format ("Name of ROM BIOS image: %s"); + rompath->set_format ("Name of ROM BIOS image: %s"); sprintf(name, "%s/BIOS-bochs-latest", get_builtin_variable("BXSHARE")); - bx_options.rom.Opath->set_initial_val (name); - bx_options.rom.Oaddress = new bx_param_num_c (rom, + rompath->set_initial_val(name); + bx_param_num_c *romaddr = new bx_param_num_c(rom, "addr", "The address at which the ROM image should be loaded", 0, BX_MAX_BIT32U, 0); - bx_options.rom.Oaddress->set_base (16); + romaddr->set_base(16); #if BX_WITH_WX - bx_options.rom.Opath->set_label ("ROM BIOS image"); - bx_options.rom.Oaddress->set_label ("ROM BIOS address"); - bx_options.rom.Oaddress->set_format ("0x%05x"); + rompath->set_label("ROM BIOS image"); + romaddr->set_label("ROM BIOS address"); + romaddr->set_format("0x%05x"); #else - bx_options.rom.Oaddress->set_format ("ROM BIOS address: 0x%05x"); + romaddr->set_format("ROM BIOS address: 0x%05x"); #endif - bx_options.vgarom.Opath = new bx_param_filename_c (vgarom, + bx_param_filename_c *vgarompath = new bx_param_filename_c(vgarom, "path", "Pathname of VGA ROM image to load", "", BX_PATHNAME_LEN); - bx_options.vgarom.Opath->set_format ("Name of VGA BIOS image: %s"); + vgarompath->set_format("Name of VGA BIOS image: %s"); #if BX_WITH_WX - bx_options.vgarom.Opath->set_label ("VGA BIOS image"); + vgarompath->set_label("VGA BIOS image"); #endif sprintf(name, "%s/VGABIOS-lgpl-latest", get_builtin_variable("BXSHARE")); - bx_options.vgarom.Opath->set_initial_val (name); + vgarompath->set_initial_val(name); + + bx_param_filename_c *optpath; + bx_param_num_c *optaddr; for (i=0; iset_format (strdup(label)); + optpath->set_format(strdup(label)); sprintf (descr, "The address at which the optional ROM image #%d should be loaded", i+1); - bx_options.optrom[i].Oaddress = new bx_param_num_c (optnum1, + optaddr = new bx_param_num_c(optnum1, "addr", strdup(descr), 0, BX_MAX_BIT32U, 0); - bx_options.optrom[i].Oaddress->set_base (16); + optaddr->set_base(16); #if BX_WITH_WX sprintf (label, "Optional ROM image #%d", i+1); - bx_options.optrom[i].Opath->set_label (strdup(label)); - bx_options.optrom[i].Oaddress->set_label ("Address"); - bx_options.optrom[i].Oaddress->set_format ("0x%05x"); + optpath->set_label(strdup(label)); + optaddr->set_label("Address"); + optaddr->set_format("0x%05x"); #else sprintf (label, "Optional ROM #%d address:", i+1); strcat(label, " 0x%05x"); - bx_options.optrom[i].Oaddress->set_format (strdup(label)); + optaddr->set_format(strdup(label)); #endif } for (i=0; iset_format (strdup(label)); + optpath->set_format(strdup(label)); sprintf (name, "memory.optram.%d.address", i+1); sprintf (descr, "The address at which the optional RAM image #%d should be loaded", i+1); - bx_options.optram[i].Oaddress = new bx_param_num_c (optnum2, + optaddr = new bx_param_num_c(optnum2, "addr", strdup(descr), 0, BX_MAX_BIT32U, 0); - bx_options.optram[i].Oaddress->set_base (16); + optaddr->set_base(16); #if BX_WITH_WX sprintf (label, "Optional RAM image #%d", i+1); - bx_options.optram[i].Opath->set_label (strdup(label)); - bx_options.optram[i].Oaddress->set_label ("Address"); - bx_options.optram[i].Oaddress->set_format ("0x%05x"); + optpath->set_label(strdup(label)); + optaddr->set_label("Address"); + optaddr->set_format("0x%05x"); #else - sprintf (label, "Optional RAM #%d address:", i+1); + sprintf(label, "Optional RAM #%d address:", i+1); strcat(label, " 0x%05x"); - bx_options.optram[i].Oaddress->set_format (strdup(label)); + optaddr->set_format(strdup(label)); #endif } memory->get_options()->set(bx_list_c::USE_TAB_WINDOW); @@ -924,30 +927,30 @@ void bx_init_options () optram->set_label("Optional RAM Images"); bx_param_c *memory_init_list[] = { - bx_options.memory.Osize, - bx_options.rom.Opath, - bx_options.rom.Oaddress, - bx_options.vgarom.Opath, - bx_options.optrom[0].Opath, - bx_options.optrom[0].Oaddress, - bx_options.optrom[1].Opath, - bx_options.optrom[1].Oaddress, - bx_options.optrom[2].Opath, - bx_options.optrom[2].Oaddress, - bx_options.optrom[3].Opath, - bx_options.optrom[3].Oaddress, - bx_options.optram[0].Opath, - bx_options.optram[0].Oaddress, - bx_options.optram[1].Opath, - bx_options.optram[1].Oaddress, - bx_options.optram[2].Opath, - bx_options.optram[2].Oaddress, - bx_options.optram[3].Opath, - bx_options.optram[3].Oaddress, + SIM->get_param(BXPN_MEM_SIZE), + SIM->get_param(BXPN_ROM_PATH), + SIM->get_param(BXPN_ROM_ADDRESS), + SIM->get_param(BXPN_VGA_ROM_PATH), + SIM->get_param(BXPN_OPTROM1_PATH), + SIM->get_param(BXPN_OPTROM1_ADDRESS), + SIM->get_param(BXPN_OPTROM2_PATH), + SIM->get_param(BXPN_OPTROM2_ADDRESS), + SIM->get_param(BXPN_OPTROM3_PATH), + SIM->get_param(BXPN_OPTROM3_ADDRESS), + SIM->get_param(BXPN_OPTROM4_PATH), + SIM->get_param(BXPN_OPTROM4_ADDRESS), + SIM->get_param(BXPN_OPTRAM1_PATH), + SIM->get_param(BXPN_OPTRAM1_ADDRESS), + SIM->get_param(BXPN_OPTRAM2_PATH), + SIM->get_param(BXPN_OPTRAM2_ADDRESS), + SIM->get_param(BXPN_OPTRAM3_PATH), + SIM->get_param(BXPN_OPTRAM3_ADDRESS), + SIM->get_param(BXPN_OPTRAM4_PATH), + SIM->get_param(BXPN_OPTRAM4_ADDRESS), NULL }; - menu = new bx_list_c (BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list); - menu->get_options ()->set (menu->SHOW_PARENT); + menu = new bx_list_c(BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list); + menu->get_options()->set(menu->SHOW_PARENT); // serial and parallel port options @@ -2694,74 +2697,80 @@ static Bit32s parse_line_formatted(char *context, int num_params, char *params[] if (num_params != 2) { PARSE_ERR(("%s: megs directive: wrong # args.", context)); } - SIM->get_param_num("memory.standard.ram.size")->set(atol(params[1])); + SIM->get_param_num(BXPN_MEM_SIZE)->set(atol(params[1])); } else if (!strcmp(params[0], "romimage")) { if ((num_params < 2) || (num_params > 3)) { PARSE_ERR(("%s: romimage directive: wrong # args.", context)); } if (!strncmp(params[1], "file=", 5)) { - SIM->get_param_string("memory.standard.rom.path")->set(¶ms[1][5]); + SIM->get_param_string(BXPN_ROM_PATH)->set(¶ms[1][5]); } else { PARSE_ERR(("%s: romimage directive malformed.", context)); } if (num_params == 3) { if (!strncmp(params[2], "address=", 8)) { if ((params[2][8] == '0') && (params[2][9] == 'x')) - SIM->get_param_num("memory.standard.rom.addr")->set(strtoul (¶ms[2][8], NULL, 16)); + SIM->get_param_num(BXPN_ROM_ADDRESS)->set(strtoul (¶ms[2][8], NULL, 16)); else - SIM->get_param_num("memory.standard.rom.addr")->set(strtoul (¶ms[2][8], NULL, 10)); + SIM->get_param_num(BXPN_ROM_ADDRESS)->set(strtoul (¶ms[2][8], NULL, 10)); } else { PARSE_ERR(("%s: romimage directive malformed.", context)); } } else { - SIM->get_param_num("memory.standard.rom.addr")->set (0); + SIM->get_param_num(BXPN_ROM_ADDRESS)->set (0); } } else if (!strcmp(params[0], "vgaromimage")) { if (num_params != 2) { PARSE_ERR(("%s: vgaromimage directive: wrong # args.", context)); } if (!strncmp(params[1], "file=", 5)) { - SIM->get_param_string("memory.standard.vgarom.path")->set(¶ms[1][5]); + SIM->get_param_string(BXPN_VGA_ROM_PATH)->set(¶ms[1][5]); } else { BX_INFO(("WARNING: syntax has changed, please use 'vgaromimage: file=...' now")); - SIM->get_param_string("memory.standard.vgarom.path")->set (params[1]); + SIM->get_param_string(BXPN_VGA_ROM_PATH)->set (params[1]); } } else if (!strncmp(params[0], "optromimage", 11)) { int num = atoi(¶ms[0][11]); + char tmppath[80], tmpaddr[80]; if ((num < 1) || (num > BX_N_OPTROM_IMAGES)) { PARSE_ERR(("%s: optromimage%d: not supported", context, num)); } if (num_params != 3) { PARSE_ERR(("%s: optromimage%d directive: wrong # args.", context, num)); } + sprintf(tmppath, "memory.optrom.%d.path", num); + sprintf(tmpaddr, "memory.optrom.%d.addr", num); for (i=1; i BX_N_OPTRAM_IMAGES)) { PARSE_ERR(("%s: ramimage%d: not supported", context, num)); } if (num_params != 3) { PARSE_ERR(("%s: ramimage%d directive: wrong # args.", context, num)); } + sprintf(tmppath, "memory.optram.%d.path", num); + sprintf(tmpaddr, "memory.optram.%d.addr", num); for (i=1; igetptr ()); else fprintf (fp, "\n"); - fprintf (fp, "megs: %d\n", bx_options.memory.Osize->get ()); - if (strlen (bx_options.rom.Opath->getptr ()) > 0) - fprintf (fp, "romimage: file=\"%s\", address=0x%05x\n", bx_options.rom.Opath->getptr(), (unsigned int)bx_options.rom.Oaddress->get ()); + fprintf (fp, "megs: %d\n", SIM->get_param_num(BXPN_MEM_SIZE)->get()); + strptr = SIM->get_param_string(BXPN_ROM_PATH)->getptr(); + if (strlen(strptr) > 0) + fprintf (fp, "romimage: file=\"%s\", address=0x%05x\n", strptr, (unsigned int)SIM->get_param_num(BXPN_ROM_ADDRESS)->get()); else fprintf (fp, "# no romimage\n"); - if (strlen (bx_options.vgarom.Opath->getptr ()) > 0) - fprintf (fp, "vgaromimage: file=\"%s\"\n", bx_options.vgarom.Opath->getptr ()); + strptr = SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(); + if (strlen(strptr) > 0) + fprintf (fp, "vgaromimage: file=\"%s\"\n", strptr); else fprintf (fp, "# no vgaromimage\n"); fprintf (fp, "boot: %s", bx_options.Obootdrive[0]->get_choice(bx_options.Obootdrive[0]->get() - 1)); @@ -3663,14 +3675,20 @@ int bx_write_configuration (char *rc, int overwrite) bx_write_atadevice_options (fp, channel, 1, &bx_options.atadevice[channel][1]); } for (i=0; igetptr ()) > 0) - fprintf (fp, "optromimage%d: file=\"%s\", address=0x%05x\n", i+1, bx_options.optrom[i].Opath->getptr(), - (unsigned int)bx_options.optrom[i].Oaddress->get ()); + sprintf(tmppath, "memory.optrom.%d.path", i+1); + sprintf(tmpaddr, "memory.optrom.%d.addr", i+1); + strptr = SIM->get_param_string(tmppath)->getptr(); + if (strlen(strptr) > 0) + fprintf(fp, "optromimage%d: file=\"%s\", address=0x%05x\n", i+1, strptr, + (unsigned int)SIM->get_param_num(tmpaddr)->get()); } for (i=0; igetptr ()) > 0) - fprintf (fp, "optramimage%d: file=\"%s\", address=0x%05x\n", i+1, bx_options.optram[i].Opath->getptr(), - (unsigned int)bx_options.optram[i].Oaddress->get ()); + sprintf(tmppath, "memory.optram.%d.path", i+1); + sprintf(tmpaddr, "memory.optram.%d.addr", i+1); + strptr = SIM->get_param_string(tmppath)->getptr(); + if (strlen(strptr) > 0) + fprintf(fp, "optramimage%d: file=\"%s\", address=0x%05x\n", i+1, strptr, + (unsigned int)SIM->get_param_num(tmpaddr)->get()); } // parallel ports for (i=0; igetptr(),"") == 0) { + if (strcmp(SIM->get_param_string(BXPN_ROM_PATH)->getptr(),"") == 0) { BX_ERROR(("No romimage to load. Is your bochsrc file loaded/valid ?")); } // set up memory and CPU objects - bx_param_num_c *bxp_memsize = SIM->get_param_num("memory.standard.ram.size"); + bx_param_num_c *bxp_memsize = SIM->get_param_num(BXPN_MEM_SIZE); Bit32u memSize = bxp_memsize->get() * 1024*1024; #if BX_SUPPORT_ICACHE @@ -906,28 +906,29 @@ int bx_init_hardware() BX_MEM(0)->init_memory(memSize); // First load the BIOS and VGABIOS - BX_MEM(0)->load_ROM(bx_options.rom.Opath->getptr(), bx_options.rom.Oaddress->get(), 0); - BX_MEM(0)->load_ROM(bx_options.vgarom.Opath->getptr(), 0xc0000, 1); + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_ROM_PATH)->getptr(), + SIM->get_param_num(BXPN_ROM_ADDRESS)->get(), 0); + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1); // Then load the optional ROM images - if (strcmp(bx_options.optrom[0].Opath->getptr(), "") !=0) - BX_MEM(0)->load_ROM(bx_options.optrom[0].Opath->getptr(), bx_options.optrom[0].Oaddress->get(), 2); - if (strcmp(bx_options.optrom[1].Opath->getptr(), "") !=0 ) - BX_MEM(0)->load_ROM(bx_options.optrom[1].Opath->getptr(), bx_options.optrom[1].Oaddress->get(), 2); - if (strcmp(bx_options.optrom[2].Opath->getptr(), "") !=0) - BX_MEM(0)->load_ROM(bx_options.optrom[2].Opath->getptr(), bx_options.optrom[2].Oaddress->get(), 2); - if (strcmp(bx_options.optrom[3].Opath->getptr(), "") !=0) - BX_MEM(0)->load_ROM(bx_options.optrom[3].Opath->getptr(), bx_options.optrom[3].Oaddress->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTROM1_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_OPTROM1_PATH)->getptr(), SIM->get_param_num(BXPN_OPTROM1_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTROM2_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_OPTROM2_PATH)->getptr(), SIM->get_param_num(BXPN_OPTROM2_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTROM3_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_OPTROM3_PATH)->getptr(), SIM->get_param_num(BXPN_OPTROM3_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTROM4_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_OPTROM4_PATH)->getptr(), SIM->get_param_num(BXPN_OPTROM4_ADDRESS)->get(), 2); // Then load the optional RAM images - if (strcmp(bx_options.optram[0].Opath->getptr(), "") !=0) - BX_MEM(0)->load_RAM(bx_options.optram[0].Opath->getptr(), bx_options.optram[0].Oaddress->get(), 2); - if (strcmp(bx_options.optram[1].Opath->getptr(), "") !=0) - BX_MEM(0)->load_RAM(bx_options.optram[1].Opath->getptr(), bx_options.optram[1].Oaddress->get(), 2); - if (strcmp(bx_options.optram[2].Opath->getptr(), "") !=0) - BX_MEM(0)->load_RAM(bx_options.optram[2].Opath->getptr(), bx_options.optram[2].Oaddress->get(), 2); - if (strcmp(bx_options.optram[3].Opath->getptr(), "") !=0) - BX_MEM(0)->load_RAM(bx_options.optram[3].Opath->getptr(), bx_options.optram[3].Oaddress->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTRAM1_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_RAM(SIM->get_param_string(BXPN_OPTRAM1_PATH)->getptr(), SIM->get_param_num(BXPN_OPTRAM1_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTRAM2_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_RAM(SIM->get_param_string(BXPN_OPTRAM2_PATH)->getptr(), SIM->get_param_num(BXPN_OPTRAM2_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTRAM3_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_RAM(SIM->get_param_string(BXPN_OPTRAM3_PATH)->getptr(), SIM->get_param_num(BXPN_OPTRAM3_ADDRESS)->get(), 2); + if (strcmp(SIM->get_param_string(BXPN_OPTRAM4_PATH)->getptr(), "") !=0) + BX_MEM(0)->load_RAM(SIM->get_param_string(BXPN_OPTRAM4_PATH)->getptr(), SIM->get_param_num(BXPN_OPTRAM4_ADDRESS)->get(), 2); #if BX_SUPPORT_SMP == 0 BX_CPU(0)->initialize(BX_MEM(0));