mirror of https://github.com/bochs-emu/Bochs
- better error handling in function load_ROM():
* cause a BX_PANIC if the path of the system BIOS or VGA BIOS is empty * open() and fstat() now cause a BX_ERROR if the rom image is optional
This commit is contained in:
parent
d5234085df
commit
6b184eb3b5
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: dbg_main.cc,v 1.98 2002-12-17 03:36:53 yakovlev Exp $
|
||||
// $Id: dbg_main.cc,v 1.99 2003-04-02 17:03:29 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
|
@ -397,8 +397,8 @@ process_sim2:
|
|||
BX_CPU(1) = new BX_CPU_C (BX_MEM(1));
|
||||
BX_CPU(1)->reset(BX_RESET_HARDWARE);
|
||||
BX_MEM(1)->init_memory(bx_options.memory.Osize->get () * 1024*1024);
|
||||
BX_MEM(1)->load_ROM(bx_options.rom.path->getptr (), bx_options.rom.address->get ());
|
||||
BX_MEM(1)->load_ROM(bx_options.vgarom.path->getptr (), 0xc0000);
|
||||
BX_MEM(1)->load_ROM(bx_options.rom.path->getptr (), bx_options.rom.address->get (), 1);
|
||||
BX_MEM(1)->load_ROM(bx_options.vgarom.path->getptr (), 0xc0000, 2);
|
||||
#endif
|
||||
|
||||
// (mch) Moved from main.cc
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: debug.h,v 1.16 2002-10-25 11:44:35 bdenney Exp $
|
||||
// $Id: debug.h,v 1.17 2003-04-02 17:03:32 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
|
@ -383,7 +383,7 @@ typedef struct {
|
|||
void (*take_dma)(void);
|
||||
void (*reset_cpu)(unsigned source);
|
||||
void (*init_mem)(int size_in_bytes);
|
||||
void (*load_ROM)(const char *path, Bit32u romaddress);
|
||||
void (*load_ROM)(const char *path, Bit32u romaddress, Bit8u type);
|
||||
|
||||
// for asynchronous environment handling
|
||||
void (*set_A20)(unsigned val);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: sim2.cc,v 1.4 2002-10-25 11:44:35 bdenney Exp $
|
||||
// $Id: sim2.cc,v 1.5 2003-04-02 17:03:32 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
|
@ -51,7 +51,7 @@ void sim2_take_irq(void);
|
|||
void sim2_take_dma(void);
|
||||
void sim2_reset_cpu(void);
|
||||
void sim2_init_mem(int size_in_bytes);
|
||||
void sim2_load_ROM(const char *path, Bit32u romaddress);
|
||||
void sim2_load_ROM(const char *path, Bit32u romaddress, Bit8u type);
|
||||
|
||||
void sim2_set_A20(unsigned val);
|
||||
void sim2_set_NMI(unsigned val);
|
||||
|
@ -187,7 +187,7 @@ sim2_init_mem(int size_in_bytes)
|
|||
{
|
||||
}
|
||||
void
|
||||
sim2_load_ROM(const char *path, Bit32u romaddress)
|
||||
sim2_load_ROM(const char *path, Bit32u romaddress, Bit8u type)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: main.cc,v 1.223 2003-02-13 15:51:12 sshwarts Exp $
|
||||
// $Id: main.cc,v 1.224 2003-04-02 17:03:26 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
|
@ -2183,17 +2183,17 @@ bx_init_hardware()
|
|||
|
||||
// First 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 ());
|
||||
BX_MEM(0)->load_ROM(bx_options.optrom[0].Opath->getptr (), bx_options.optrom[0].Oaddress->get (), 0);
|
||||
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 ());
|
||||
BX_MEM(0)->load_ROM(bx_options.optrom[1].Opath->getptr (), bx_options.optrom[1].Oaddress->get (), 0);
|
||||
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 ());
|
||||
BX_MEM(0)->load_ROM(bx_options.optrom[2].Opath->getptr (), bx_options.optrom[2].Oaddress->get (), 0);
|
||||
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 ());
|
||||
BX_MEM(0)->load_ROM(bx_options.optrom[3].Opath->getptr (), bx_options.optrom[3].Oaddress->get (), 0);
|
||||
|
||||
// Then Load the BIOS and VGABIOS
|
||||
BX_MEM(0)->load_ROM(bx_options.rom.Opath->getptr (), bx_options.rom.Oaddress->get ());
|
||||
BX_MEM(0)->load_ROM(bx_options.vgarom.Opath->getptr (), 0xc0000);
|
||||
BX_MEM(0)->load_ROM(bx_options.rom.Opath->getptr (), bx_options.rom.Oaddress->get (), 1);
|
||||
BX_MEM(0)->load_ROM(bx_options.vgarom.Opath->getptr (), 0xc0000, 2);
|
||||
|
||||
BX_CPU(0)->init (BX_MEM(0));
|
||||
BX_CPU(0)->set_cpu_id(0);
|
||||
|
@ -2209,18 +2209,18 @@ bx_init_hardware()
|
|||
|
||||
// First load the optional ROM images
|
||||
if (bx_options.optrom[0].Opath->getptr () > 0)
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[0].Opath->getptr (), bx_options.optrom[0].Oaddress->get ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[0].Opath->getptr (), bx_options.optrom[0].Oaddress->get (), 0);
|
||||
if (bx_options.optrom[1].Opath->getptr () > 0)
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[1].Opath->getptr (), bx_options.optrom[1].Oaddress->get ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[1].Opath->getptr (), bx_options.optrom[1].Oaddress->get (), 0);
|
||||
if (bx_options.optrom[2].Opath->getptr () > 0)
|
||||
BX_MEM(0)->load_ROM(bx_options.optrom[2].Opath->getptr (), bx_options.optrom[2].Oaddress->get ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[2].Opath->getptr (), bx_options.optrom[2].Oaddress->get ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[2].Opath->getptr (), bx_options.optrom[2].Oaddress->get (), 0);
|
||||
if (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 ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.optrom[3].Opath->getptr (), bx_options.optrom[3].Oaddress->get (), 0);
|
||||
|
||||
// Then Load the BIOS and VGABIOS
|
||||
bx_mem_array[0]->load_ROM(bx_options.rom.Opath->getptr (), bx_options.rom.Oaddress->get ());
|
||||
bx_mem_array[0]->load_ROM(bx_options.vgarom.Opath->getptr (), 0xc0000);
|
||||
bx_mem_array[0]->load_ROM(bx_options.rom.Opath->getptr (), bx_options.rom.Oaddress->get (), 1);
|
||||
bx_mem_array[0]->load_ROM(bx_options.vgarom.Opath->getptr (), 0xc0000, 2);
|
||||
|
||||
for (int i=0; i<BX_SMP_PROCESSORS; i++) {
|
||||
BX_CPU(i) = new BX_CPU_C;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: memory.h,v 1.14 2003-03-02 23:59:12 cbothamy Exp $
|
||||
// $Id: memory.h,v 1.15 2003-04-02 17:03:33 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001 MandrakeSoft S.A.
|
||||
|
@ -66,7 +66,7 @@ public:
|
|||
unsigned len, void *data) BX_CPP_AttrRegparmN(3);
|
||||
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);
|
||||
BX_MEM_SMF void load_ROM(const char *path, Bit32u romaddress, Bit8u type);
|
||||
BX_MEM_SMF Bit32u get_memory_in_k(void);
|
||||
#if BX_PCI_SUPPORT
|
||||
BX_MEM_SMF Bit8u* pci_fetch_ptr(Bit32u addr) BX_CPP_AttrRegparmN(1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id: misc_mem.cc,v 1.36 2003-03-02 23:59:12 cbothamy Exp $
|
||||
// $Id: misc_mem.cc,v 1.37 2003-04-02 17:03:34 vruppert Exp $
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2002 MandrakeSoft S.A.
|
||||
|
@ -120,7 +120,7 @@ BX_MEM_C::~BX_MEM_C(void)
|
|||
void
|
||||
BX_MEM_C::init_memory(int memsize)
|
||||
{
|
||||
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.36 2003-03-02 23:59:12 cbothamy Exp $"));
|
||||
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.37 2003-04-02 17:03:34 vruppert 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) ));
|
||||
|
@ -146,14 +146,21 @@ BX_MEM_C::init_memory(int memsize)
|
|||
|
||||
#if BX_PROVIDE_CPU_MEMORY
|
||||
void
|
||||
BX_MEM_C::load_ROM(const char *path, Bit32u romaddress)
|
||||
BX_MEM_C::load_ROM(const char *path, Bit32u romaddress, Bit8u type)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
int fd, ret;
|
||||
unsigned long size, offset;
|
||||
|
||||
if (*path == '\0')
|
||||
if (*path == '\0') {
|
||||
if (type == 1) {
|
||||
BX_PANIC(( "ROM: System BIOS image undefined."));
|
||||
}
|
||||
else {
|
||||
BX_PANIC(( "ROM: VGA BIOS image undefined."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
// read in ROM BIOS image file
|
||||
fd = open(path, O_RDONLY
|
||||
#ifdef O_BINARY
|
||||
|
@ -161,12 +168,22 @@ BX_MEM_C::load_ROM(const char *path, Bit32u romaddress)
|
|||
#endif
|
||||
);
|
||||
if (fd < 0) {
|
||||
BX_PANIC(( "ROM: couldn't open ROM image file '%s'.", path));
|
||||
if (type > 0) {
|
||||
BX_PANIC(( "ROM: couldn't open ROM image file '%s'.", path));
|
||||
}
|
||||
else {
|
||||
BX_ERROR(( "ROM: couldn't open ROM image file '%s'.", path));
|
||||
}
|
||||
return;
|
||||
}
|
||||
ret = fstat(fd, &stat_buf);
|
||||
if (ret) {
|
||||
BX_PANIC(( "ROM: couldn't stat ROM image file '%s'.", path));
|
||||
if (type > 0) {
|
||||
BX_PANIC(( "ROM: couldn't stat ROM image file '%s'.", path));
|
||||
}
|
||||
else {
|
||||
BX_ERROR(( "ROM: couldn't stat ROM image file '%s'.", path));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue