- set device state structure to 0 with memset() for some devices

- cleaned up vga core init code after adding memset()
- floppy: removed structures that had been used for win95 direct access
This commit is contained in:
Volker Ruppert 2012-02-05 10:08:56 +00:00
parent 90e6c88c55
commit 47f2137edf
14 changed files with 21 additions and 122 deletions

View File

@ -111,6 +111,7 @@ Bit64u muldiv64(Bit64u a, Bit32u b, Bit32u c)
bx_acpi_ctrl_c::bx_acpi_ctrl_c()
{
put("ACPI");
memset(&s, 0, sizeof(s));
s.timer_index = BX_NULL_TIMER_HANDLE;
}

View File

@ -59,6 +59,8 @@ void libbiosdev_LTX_plugin_fini(void)
bx_biosdev_c::bx_biosdev_c(void)
{
memset(&s, 0, sizeof(s));
bioslog = new logfunctions();
bioslog->put("BIOS");
@ -90,11 +92,6 @@ void bx_biosdev_c::init(void)
DEV_register_iowrite_handler(this, write_handler, 0x0501, "VGABios Panic Port 1", 3);
DEV_register_iowrite_handler(this, write_handler, 0x0502, "VGABios Panic Port 2", 3);
DEV_register_iowrite_handler(this, write_handler, 0x0503, "VGABios Debug Port", 1);
s.bios_message_i = 0;
s.bios_panic_flag = 0;
s.vgabios_message_i = 0;
s.vgabios_panic_flag = 0;
}
// static IO port write callback handler

View File

@ -122,9 +122,7 @@ void libcmos_LTX_plugin_fini(void)
bx_cmos_c::bx_cmos_c(void)
{
put("CMOS");
for (unsigned i=0; i<128; i++) s.reg[i] = 0;
memset(&s, 0, sizeof(s));
s.periodic_timer_index = BX_NULL_TIMER_HANDLE;
s.one_second_timer_index = BX_NULL_TIMER_HANDLE;
s.uip_timer_index = BX_NULL_TIMER_HANDLE;

View File

@ -57,6 +57,8 @@ void libdma_LTX_plugin_fini(void)
bx_dma_c::bx_dma_c()
{
put("DMA");
memset(&s[0], 0, sizeof(s));
memset(&s[1], 0, sizeof(s));
}
bx_dma_c::~bx_dma_c()

View File

@ -128,6 +128,7 @@ void libfloppy_LTX_plugin_fini(void)
bx_floppy_ctrl_c::bx_floppy_ctrl_c()
{
put("floppy", "FDD");
memset(&s, 0, sizeof(s));
s.floppy_timer_index = BX_NULL_TIMER_HANDLE;
}

View File

@ -153,48 +153,4 @@ private:
static void runtime_config_handler(void *);
void runtime_config(void);
};
#ifdef WIN32
// used for direct floppy access in Win95
#define VWIN32_DIOC_DOS_IOCTL 1
#define VWIN32_DIOC_DOS_INT25 2
#define VWIN32_DIOC_DOS_INT26 3
typedef struct _DIOC_REGISTERS {
DWORD reg_EBX;
DWORD reg_EDX;
DWORD reg_ECX;
DWORD reg_EAX;
DWORD reg_EDI;
DWORD reg_ESI;
DWORD reg_Flags;
} DIOC_REGISTERS, *PDIOC_REGISTERS;
#pragma pack(push, 1)
typedef struct _BLOCK_DEV_PARAMS {
BYTE features;
BYTE dev_type;
WORD attribs;
WORD cylinders;
BYTE media_type;
// BPB
WORD bytes_per_sector;
BYTE sect_per_cluster;
WORD reserved_sectors;
BYTE fats;
WORD root_entries;
WORD tot_sectors;
BYTE media_id;
WORD sects_per_fat;
WORD sects_per_track;
WORD num_heads;
WORD hidden_sectors;
BYTE remainder[5];
} BLOCK_DEV_PARAMS, *PBLOCK_DEV_PARAMS;
#pragma pack(pop)
#endif /* WIN32 */
#endif

View File

@ -78,6 +78,7 @@ void libkeyboard_LTX_plugin_fini(void)
bx_keyb_c::bx_keyb_c()
{
put("keyboard", "KBD");
memset(&s, 0, sizeof(s));
pastebuf = NULL;
}

View File

@ -184,6 +184,7 @@ void libne2k_LTX_plugin_fini(void)
bx_ne2k_c::bx_ne2k_c()
{
put("NE2K");
memset(&s, 0, sizeof(bx_ne2k_t));
s.tx_timer_index = BX_NULL_TIMER_HANDLE;
ethdev = NULL;
}

View File

@ -119,10 +119,15 @@ void libpcipnic_LTX_plugin_fini(void)
bx_pcipnic_c::bx_pcipnic_c()
{
put("pcipnic", "PNIC");
memset(&s, 0, sizeof(bx_e1000_t));
ethdev = NULL;
}
bx_pcipnic_c::~bx_pcipnic_c()
{
if (ethdev != NULL) {
delete ethdev;
}
BX_DEBUG(("Exit"));
}

View File

@ -51,7 +51,7 @@ bx_parallel_c::bx_parallel_c()
{
put("parallel", "PAR");
for (int i=0; i<BX_PARPORT_MAXDEV; i++) {
s[i].output = NULL;
memset(&s[i], 0, sizeof(bx_par_t));
}
}

View File

@ -70,6 +70,7 @@ bx_serial_c::bx_serial_c(void)
{
put("serial", "SER");
for (int i=0; i<BX_SERIAL_MAXDEV; i++) {
memset(&s[i], 0, sizeof(bx_serial_t));
s[i].io_mode = BX_SER_MODE_NULL;
s[i].tty_id = -1;
s[i].tx_timer_index = BX_NULL_TIMER_HANDLE;

View File

@ -168,7 +168,7 @@ void libes1370_LTX_plugin_fini(void)
bx_es1370_c::bx_es1370_c()
{
put("es1370", "E1370");
memset(&s, 0, sizeof(bx_es1370_t));
s.dac1_timer_index = BX_NULL_TIMER_HANDLE;
s.dac2_timer_index = BX_NULL_TIMER_HANDLE;
}

View File

@ -210,6 +210,9 @@ void libsb16_LTX_plugin_fini(void)
bx_sb16_c::bx_sb16_c(void)
{
put("SB16");
memset(&mpu401, 0, sizeof(mpu401));
memset(&dsp, 0, sizeof(dsp));
memset(&opl, 0, sizeof(opl));
mpu401.timer_handle = BX_NULL_TIMER_HANDLE;
dsp.timer_handle = BX_NULL_TIMER_HANDLE;
opl.timer_handle = BX_NULL_TIMER_HANDLE;

View File

@ -79,10 +79,8 @@ static const Bit8u ccdat[16][4] = {
bx_vgacore_c::bx_vgacore_c()
{
s.vga_mem_updated = 0;
s.vga_tile_updated = NULL;
memset(&s, 0, sizeof(s));
timer_id = BX_NULL_TIMER_HANDLE;
s.memory = NULL;
}
bx_vgacore_c::~bx_vgacore_c()
@ -130,103 +128,38 @@ void bx_vgacore_c::init(void)
void bx_vgacore_c::init_standard_vga(void)
{
unsigned i;
char *extname;
// initialize VGA controllers and other internal stuff
BX_VGA_THIS s.vga_enabled = 1;
BX_VGA_THIS s.misc_output.color_emulation = 1;
BX_VGA_THIS s.misc_output.enable_ram = 1;
BX_VGA_THIS s.misc_output.clock_select = 0;
BX_VGA_THIS s.misc_output.select_high_bank = 0;
BX_VGA_THIS s.misc_output.horiz_sync_pol = 1;
BX_VGA_THIS s.misc_output.vert_sync_pol = 1;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.graphics_alpha = 0;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.display_type = 0;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.enable_line_graphics = 1;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.blink_intensity = 0;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.pixel_panning_compat = 0;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.pixel_clock_select = 0;
BX_VGA_THIS s.attribute_ctrl.mode_ctrl.internal_palette_size = 0;
BX_VGA_THIS s.line_offset=80;
BX_VGA_THIS s.line_compare=1023;
BX_VGA_THIS s.vertical_display_end=399;
for (i=0; i<=0x18; i++)
BX_VGA_THIS s.CRTC.reg[i] = 0;
BX_VGA_THIS s.CRTC.address = 0;
BX_VGA_THIS s.CRTC.write_protect = 0;
BX_VGA_THIS s.attribute_ctrl.flip_flop = 0;
BX_VGA_THIS s.attribute_ctrl.address = 0;
BX_VGA_THIS s.attribute_ctrl.video_enabled = 1;
for (i=0; i<16; i++)
BX_VGA_THIS s.attribute_ctrl.palette_reg[i] = 0;
BX_VGA_THIS s.attribute_ctrl.overscan_color = 0;
BX_VGA_THIS s.attribute_ctrl.color_plane_enable = 0x0f;
BX_VGA_THIS s.attribute_ctrl.horiz_pel_panning = 0;
BX_VGA_THIS s.attribute_ctrl.color_select = 0;
for (i=0; i<256; i++) {
BX_VGA_THIS s.pel.data[i].red = 0;
BX_VGA_THIS s.pel.data[i].green = 0;
BX_VGA_THIS s.pel.data[i].blue = 0;
}
BX_VGA_THIS s.pel.write_data_register = 0;
BX_VGA_THIS s.pel.write_data_cycle = 0;
BX_VGA_THIS s.pel.read_data_register = 0;
BX_VGA_THIS s.pel.read_data_cycle = 0;
BX_VGA_THIS s.pel.dac_state = 0x01;
BX_VGA_THIS s.pel.mask = 0xff;
BX_VGA_THIS s.graphics_ctrl.index = 0;
BX_VGA_THIS s.graphics_ctrl.set_reset = 0;
BX_VGA_THIS s.graphics_ctrl.enable_set_reset = 0;
BX_VGA_THIS s.graphics_ctrl.color_compare = 0;
BX_VGA_THIS s.graphics_ctrl.data_rotate = 0;
BX_VGA_THIS s.graphics_ctrl.raster_op = 0;
BX_VGA_THIS s.graphics_ctrl.read_map_select = 0;
BX_VGA_THIS s.graphics_ctrl.write_mode = 0;
BX_VGA_THIS s.graphics_ctrl.read_mode = 0;
BX_VGA_THIS s.graphics_ctrl.odd_even = 0;
BX_VGA_THIS s.graphics_ctrl.chain_odd_even = 0;
BX_VGA_THIS s.graphics_ctrl.shift_reg = 0;
BX_VGA_THIS s.graphics_ctrl.graphics_alpha = 0;
BX_VGA_THIS s.graphics_ctrl.memory_mapping = 2; // monochrome text mode
BX_VGA_THIS s.graphics_ctrl.color_dont_care = 0;
BX_VGA_THIS s.graphics_ctrl.bitmask = 0;
for (i=0; i<4; i++) {
BX_VGA_THIS s.graphics_ctrl.latch[i] = 0;
}
BX_VGA_THIS s.sequencer.index = 0;
BX_VGA_THIS s.sequencer.map_mask = 0;
BX_VGA_THIS s.sequencer.reset1 = 1;
BX_VGA_THIS s.sequencer.reset2 = 1;
BX_VGA_THIS s.sequencer.reg1 = 0;
BX_VGA_THIS s.sequencer.char_map_select = 0;
BX_VGA_THIS s.sequencer.extended_mem = 1; // display mem greater than 64K
BX_VGA_THIS s.sequencer.odd_even = 1; // use sequential addressing mode
BX_VGA_THIS s.sequencer.chain_four = 0; // use map mask & read map select
BX_VGA_THIS s.charmap_address = 0;
BX_VGA_THIS s.x_dotclockdiv2 = 0;
BX_VGA_THIS s.y_doublescan = 0;
BX_VGA_THIS s.plane_shift = 16;
BX_VGA_THIS s.plane_offset = 0;
BX_VGA_THIS s.dac_shift = 2;
BX_VGA_THIS s.last_xres = 0;
BX_VGA_THIS s.last_yres = 0;
BX_VGA_THIS s.last_bpp = 8;
BX_VGA_THIS s.last_msl = 0;
BX_VGA_THIS s.max_xres = 800;
BX_VGA_THIS s.max_yres = 600;
BX_VGA_THIS s.vga_mem_updated = 0;
// initialize memory, handlers and timer (depending on extension)
extname = SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr();
if ((strlen(extname) == 0) || (!strcmp(extname, "none"))) {