diff --git a/bochs/.bochsrc b/bochs/.bochsrc index 6b7ce8874..790d9344e 100644 --- a/bochs/.bochsrc +++ b/bochs/.bochsrc @@ -108,6 +108,11 @@ megs: 32 #optromimage3: file=optionalrom.bin, address=0xd2000 #optromimage4: file=optionalrom.bin, address=0xd3000 +#optramimage1: file=/path/file1.img, address=0x0010000 +#optramimage2: file=/path/file2.img, address=0x0020000 +#optramimage3: file=/path/file3.img, address=0x0030000 +#optramimage4: file=/path/file4.img, address=0x0040000 + #======================================================================= # VGAROMIMAGE # You now need to load a VGA ROM BIOS into C0000. diff --git a/bochs/bochs.h b/bochs/bochs.h index e553d80a1..1a31a6675 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: bochs.h,v 1.160 2005-10-13 16:22:21 sshwarts Exp $ +// $Id: bochs.h,v 1.161 2005-10-28 00:12:26 kevinlawton Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -630,6 +630,7 @@ typedef struct BOCHSAPI { 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_OPTROM_IMAGES]; // Optional ram images bx_mem_options memory; bx_parport_options par[BX_N_PARALLEL_PORTS]; // parallel ports bx_sb16_options sb16; diff --git a/bochs/config.cc b/bochs/config.cc index 8eb02819c..d24f6d831 100755 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: config.cc,v 1.50 2005-10-22 08:07:53 vruppert Exp $ +// $Id: config.cc,v 1.51 2005-10-28 00:12:26 kevinlawton Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -880,6 +880,36 @@ void bx_init_options () #endif } + for (i=0; i<4; i++) { + sprintf (name, "memory.optram.%d.path", i+1); + sprintf (descr, "Pathname of optional ROM image #%d to load", i+1); + bx_options.optram[i].Opath = new bx_param_filename_c ((bx_id)(BXP_OPTRAM1_PATH+i), + strdup(name), + strdup(descr), + "", BX_PATHNAME_LEN); + sprintf (label, "Name of optional ROM image #%d", i+1); + strcat(label, " : %s"); + bx_options.optram[i].Opath->set_format (strdup(label)); + sprintf (name, "memory.optram.%d.address", i+1); + sprintf (descr, "The address at which the optional ROM image #%d should be loaded", i+1); + bx_options.optram[i].Oaddress = new bx_param_num_c ((bx_id)(BXP_OPTRAM1_ADDRESS+i), + strdup(name), + strdup(descr), + 0, BX_MAX_BIT32U, + 0); + bx_options.optram[i].Oaddress->set_base (16); +#if BX_WITH_WX + sprintf (label, "Optional ROM 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"); +#else + sprintf (label, "Optional ROM #%d address:", i+1); + strcat(label, " 0x%05x"); + bx_options.optram[i].Oaddress->set_format (strdup(label)); +#endif + } + bx_param_c *memory_init_list[] = { bx_options.memory.Osize, bx_options.rom.Opath, @@ -893,6 +923,14 @@ void bx_init_options () 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, NULL }; menu = new bx_list_c (BXP_MENU_MEMORY, "Bochs Memory Options", "memmenu", memory_init_list); @@ -1734,6 +1772,14 @@ void bx_reset_options () bx_options.optrom[2].Oaddress->reset(); bx_options.optrom[3].Opath->reset(); bx_options.optrom[3].Oaddress->reset(); + bx_options.optram[0].Opath->reset(); + bx_options.optram[0].Oaddress->reset(); + bx_options.optram[1].Opath->reset(); + bx_options.optram[1].Oaddress->reset(); + bx_options.optram[2].Opath->reset(); + bx_options.optram[2].Oaddress->reset(); + bx_options.optram[3].Opath->reset(); + bx_options.optram[3].Oaddress->reset(); // standard ports for (i=0; i 4)) { + PARSE_ERR(("%s: ramimage%d: not supported", context, num)); + } + if (num_params != 3) { + PARSE_ERR(("%s: ramimage%d directive: wrong # args.", context, num)); + } + for (i=1; igetptr(), (unsigned int)bx_options.optrom[i].Oaddress->get ()); } + for (i=0; i<4; i++) { + if (strlen (bx_options.optram[i].Opath->getptr ()) > 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 ()); + } // parallel ports for (i=0; igetptr (),"") !=0 ) BX_MEM(0)->load_ROM(bx_options.optrom[3].Opath->getptr (), bx_options.optrom[3].Oaddress->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); + BX_CPU(0)->init (BX_MEM(0)); BX_CPU(0)->set_cpu_id(0); #if BX_SUPPORT_APIC @@ -895,6 +905,16 @@ int bx_init_hardware() if (strcmp(bx_options.optrom[3].Opath->getptr (),"") !=0 ) bx_mem_array[0]->load_ROM(bx_options.optrom[3].Opath->getptr (), bx_options.optrom[3].Oaddress->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); + for (int i=0; iinit (bx_mem_array[0]); diff --git a/bochs/memory/memory.h b/bochs/memory/memory.h index 2796fb507..748ef466a 100644 --- a/bochs/memory/memory.h +++ b/bochs/memory/memory.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: memory.h,v 1.25 2005-10-12 17:11:44 vruppert Exp $ +// $Id: memory.h,v 1.26 2005-10-28 00:12:27 kevinlawton Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -87,6 +87,7 @@ public: BX_MEM_SMF void writePhysicalPage(BX_CPU_C *cpu, Bit32u addr, unsigned len, void *data) BX_CPP_AttrRegparmN(3); BX_MEM_SMF void load_ROM(const char *path, Bit32u romaddress, Bit8u type); + BX_MEM_SMF void load_RAM(const char *path, Bit32u romaddress, Bit8u type); BX_MEM_SMF Bit32u get_memory_in_k(void); BX_MEM_SMF bx_bool dbg_fetch_mem(Bit32u addr, unsigned len, Bit8u *buf); BX_MEM_SMF bx_bool dbg_set_mem(Bit32u addr, unsigned len, Bit8u *buf); diff --git a/bochs/memory/misc_mem.cc b/bochs/memory/misc_mem.cc index ef8876929..6d5b6ed03 100644 --- a/bochs/memory/misc_mem.cc +++ b/bochs/memory/misc_mem.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: misc_mem.cc,v 1.64 2005-10-25 19:12:54 vruppert Exp $ +// $Id: misc_mem.cc,v 1.65 2005-10-28 00:12:27 kevinlawton Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2002 MandrakeSoft S.A. @@ -95,7 +95,7 @@ void BX_MEM_C::init_memory(int memsize) { int idx; - BX_DEBUG(("Init $Id: misc_mem.cc,v 1.64 2005-10-25 19:12:54 vruppert Exp $")); + BX_DEBUG(("Init $Id: misc_mem.cc,v 1.65 2005-10-28 00:12:27 kevinlawton Exp $")); // you can pass 0 if memory has been allocated already through // the constructor, or the desired size of memory if it hasn't // BX_INFO(("%.2fMB", (float)(BX_MEM_THIS megabytes) )); @@ -261,6 +261,50 @@ void BX_MEM_C::load_ROM(const char *path, Bit32u romaddress, Bit8u type) (unsigned) stat_buf.st_size, path)); } + +void BX_MEM_C::load_RAM(const char *path, Bit32u ramaddress, Bit8u type) +{ + struct stat stat_buf; + int fd, ret, i, start_idx, end_idx; + unsigned long size, max_size, offset; + + if (*path == '\0') { + BX_PANIC(( "RAM: Optional RAM image undefined")); + return; + } + // read in RAM BIOS image file + fd = open(path, O_RDONLY +#ifdef O_BINARY + | O_BINARY +#endif + ); + if (fd < 0) { + BX_PANIC(( "RAM: couldn't open RAM image file '%s'.", path)); + return; + } + ret = fstat(fd, &stat_buf); + if (ret) { + BX_PANIC(( "RAM: couldn't stat RAM image file '%s'.", path)); + return; + } + + size = (unsigned long)stat_buf.st_size; + + offset = ramaddress; + while (size > 0) { + ret = read(fd, (bx_ptr_t) &BX_MEM_THIS vector[offset], size); + if (ret <= 0) { + BX_PANIC(( "RAM: read failed on BIOS image: '%s'",path)); + } + size -= ret; + offset += ret; + } + close(fd); + BX_INFO(("ram at 0x%05x/%u ('%s')", + (unsigned) ramaddress, + (unsigned) stat_buf.st_size, + path)); +} #endif // #if BX_PROVIDE_CPU_MEMORY