// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
// Define BX_PLUGGABLE in files that can be compiled into plugins. For
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
// platforms that require a special tag on exported symbols, BX_PLUGGABLE
|
// is used to know when we are exporting symbols and when we are importing.
|
// is used to know when we are exporting symbols and when we are importing.
|
#define BX_PLUGGABLE
|
#define BX_PLUGGABLE
|
|
|
#include "iodev.h"
|
#include "iodev.h"
|
#define LOG_THIS theHdemuDevice->
|
#define LOG_THIS theHdemuDevice->
|
|
|
bx_hdemu_c *theHdemuDevice = NULL;
|
bx_hdemu_c *theHdemuDevice = NULL;
|
|
|
int libhdemu_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
|
int libhdemu_LTX_plugin_init(plugin_t *plugin, plugintype_t type, int argc, char *argv[])
|
{
|
{
|
theHdemuDevice = new bx_hdemu_c();
|
theHdemuDevice = new bx_hdemu_c();
|
bx_devices.pluginHdemuDevice = theHdemuDevice;
|
bx_devices.pluginHdemuDevice = theHdemuDevice;
|
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theHdemuDevice, "hdemu");
|
BX_REGISTER_DEVICE_DEVMODEL(plugin, type, theHdemuDevice, "hdemu");
|
return(0); // Success
|
return(0); // Success
|
}
|
}
|
|
|
void libhdemu_LTX_plugin_fini(void)
|
void libhdemu_LTX_plugin_fini(void)
|
{
|
{
|
delete theHdemuDevice;
|
delete theHdemuDevice;
|
}
|
}
|
|
|
bx_hdemu_c::bx_hdemu_c()
|
bx_hdemu_c::bx_hdemu_c()
|
{
|
{
|
put("HDEMU");
|
put("HDEMU");
|
settype(HDEMULOG);
|
settype(HDEMULOG);
|
input = NULL;
|
input = NULL;
|
}
|
}
|
|
|
bx_hdemu_c::~bx_hdemu_c()
|
bx_hdemu_c::~bx_hdemu_c()
|
{
|
{
|
if (input != NULL) fclose(input);
|
if (input != NULL) fclose(input);
|
BX_DEBUG(("Exit"));
|
BX_DEBUG(("Exit"));
|
}
|
}
|
|
|
void bx_hdemu_c::init(void)
|
void bx_hdemu_c::init(void)
|
{
|
{
|
char name[16];
|
char name[16];
|
|
|
BX_DEBUG(("Init $Id: hdemu.cc,v 1.5 2009-02-06 03:48:32 zeus Exp $"));
|
BX_DEBUG(("Init $Id: hdemu.cc,v 1.34 2008/01/26 22:24:02 sshwarts Exp $"));
|
|
|
sprintf(name, "Hd emu");
|
sprintf(name, "Hd emu");
|
/* hdemu i/o ports */
|
/* hdemu i/o ports */
|
DEV_register_ioread_handler_range(this, read_handler, 0xe000, 0xe1fe, name, 2);
|
DEV_register_ioread_handler_range(this, read_handler, 0xe000, 0xe1fe, name, 2);
|
DEV_register_iowrite_handler(this, write_handler, 0xe000, name, 2);
|
DEV_register_iowrite_handler(this, write_handler, 0xe000, name, 2);
|
|
|
/* internal state */
|
/* internal state */
|
BX_HDEMU_THIS base = 0x0;
|
BX_HDEMU_THIS base = 0x0;
|
|
|
/* input file */
|
/* input file */
|
input = fopen("hd.img", "rb");
|
input = fopen("hd.img", "rb");
|
if (!input)
|
if (!input)
|
BX_PANIC(("Could not open 'hd.img' to read hard disk contents"));
|
BX_PANIC(("Could not open 'hd.img' to read hard disk contents"));
|
}
|
}
|
|
|
void bx_hdemu_c::reset(unsigned type)
|
void bx_hdemu_c::reset(unsigned type)
|
{
|
{
|
}
|
}
|
|
|
void bx_hdemu_c::register_state(void)
|
void bx_hdemu_c::register_state(void)
|
{
|
{
|
unsigned i;
|
unsigned i;
|
char name[4], pname[20];
|
char name[4], pname[20];
|
bx_list_c *base, *port;
|
bx_list_c *base, *port;
|
|
|
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "hdemu", "Hard disk emulator", 1);
|
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "hdemu", "Hard disk emulator", 1);
|
|
|
sprintf(name, "0", i);
|
sprintf(name, "0", i);
|
port = new bx_list_c(list, name, 1);
|
port = new bx_list_c(list, name, 1);
|
new bx_shadow_num_c(port, "base", &BX_HDEMU_THIS base, BASE_HEX);
|
new bx_shadow_num_c(port, "base", &BX_HDEMU_THIS base, BASE_HEX);
|
}
|
}
|
|
|
// static IO port read callback handler
|
// static IO port read callback handler
|
// redirects to non-static class handler to avoid virtual functions
|
// redirects to non-static class handler to avoid virtual functions
|
|
|
Bit32u bx_hdemu_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
Bit32u bx_hdemu_c::read_handler(void *this_ptr, Bit32u address, unsigned io_len)
|
{
|
{
|
#if !BX_USE_PAR_SMF
|
#if !BX_USE_PAR_SMF
|
bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
|
bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
|
return class_ptr->read(address, io_len);
|
return class_ptr->read(address, io_len);
|
}
|
}
|
|
|
Bit32u bx_hdemu_c::read(Bit32u address, unsigned io_len)
|
Bit32u bx_hdemu_c::read(Bit32u address, unsigned io_len)
|
{
|
{
|
#else
|
#else
|
UNUSED(this_ptr);
|
UNUSED(this_ptr);
|
#endif // !BX_USE_PAR_SMF
|
#endif // !BX_USE_PAR_SMF
|
|
|
Bit16u retval;
|
Bit16u retval;
|
size_t result;
|
size_t result;
|
address = address & 0x01ff;
|
address = address & 0x01ff;
|
|
|
fseek (BX_HDEMU_THIS input, address+(BX_HDEMU_THIS base)*512, SEEK_SET );
|
fseek (BX_HDEMU_THIS input, address+(BX_HDEMU_THIS base)*512, SEEK_SET );
|
result = fread (&retval, 2, 1, BX_HDEMU_THIS input);
|
result = fread (&retval, 2, 1, BX_HDEMU_THIS input);
|
|
|
return(retval);
|
return(retval);
|
}
|
}
|
|
|
// static IO port write callback handler
|
// static IO port write callback handler
|
// redirects to non-static class handler to avoid virtual functions
|
// redirects to non-static class handler to avoid virtual functions
|
|
|
void bx_hdemu_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
void bx_hdemu_c::write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len)
|
{
|
{
|
#if !BX_USE_PAR_SMF
|
#if !BX_USE_PAR_SMF
|
bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
|
bx_hdemu_c *class_ptr = (bx_hdemu_c *) this_ptr;
|
|
|
class_ptr->write(address, value, io_len);
|
class_ptr->write(address, value, io_len);
|
}
|
}
|
|
|
void bx_hdemu_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
void bx_hdemu_c::write(Bit32u address, Bit32u value, unsigned io_len)
|
{
|
{
|
#else
|
#else
|
UNUSED(this_ptr);
|
UNUSED(this_ptr);
|
#endif // !BX_USE_PAR_SMF
|
#endif // !BX_USE_PAR_SMF
|
|
|
BX_HDEMU_THIS base = value;
|
BX_HDEMU_THIS base = value;
|
}
|
}
|
|
|