Simplified register_state() for for small byte arrays in remaining i/o devices.

This commit is contained in:
Volker Ruppert 2015-10-06 18:20:16 +00:00
parent 9bc8651328
commit eed2bb15b8
10 changed files with 35 additions and 141 deletions

View File

@ -5,7 +5,7 @@
// Copyright (c) 2004 Makoto Suzuki (suzu)
// Volker Ruppert (vruppert)
// Robin Kay (komadori)
// Copyright (C) 2004-2014 The Bochs Project
// Copyright (C) 2004-2015 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -375,44 +375,24 @@ void bx_svga_cirrus_c::reset(unsigned type)
void bx_svga_cirrus_c::register_state(void)
{
unsigned i;
char name[6];
bx_list_c *reg;
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "svga_cirrus", "Cirrus SVGA State");
bx_vgacore_c::register_state(list);
bx_list_c *crtc = new bx_list_c(list, "crtc");
new bx_shadow_num_c(crtc, "index", &BX_CIRRUS_THIS crtc.index, BASE_HEX);
reg = new bx_list_c(crtc, "reg");
for (i=0; i<=CIRRUS_CRTC_MAX; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_CIRRUS_THIS crtc.reg[i], BASE_HEX);
}
new bx_shadow_data_c(crtc, "reg", BX_CIRRUS_THIS crtc.reg, CIRRUS_CRTC_MAX, 1);
bx_list_c *sequ = new bx_list_c(list, "sequencer");
new bx_shadow_num_c(sequ, "index", &BX_CIRRUS_THIS sequencer.index, BASE_HEX);
reg = new bx_list_c(sequ, "reg");
for (i=0; i<=CIRRUS_SEQENCER_MAX; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_CIRRUS_THIS sequencer.reg[i], BASE_HEX);
}
new bx_shadow_data_c(sequ, "reg", BX_CIRRUS_THIS sequencer.reg, CIRRUS_SEQENCER_MAX, 1);
bx_list_c *ctrl = new bx_list_c(list, "control");
new bx_shadow_num_c(ctrl, "index", &BX_CIRRUS_THIS control.index, BASE_HEX);
reg = new bx_list_c(ctrl, "reg");
for (i=0; i<=CIRRUS_CONTROL_MAX; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_CIRRUS_THIS control.reg[i], BASE_HEX);
}
new bx_shadow_data_c(ctrl, "reg", BX_CIRRUS_THIS control.reg, CIRRUS_CONTROL_MAX, 1);
new bx_shadow_num_c(ctrl, "shadow_reg0", &BX_CIRRUS_THIS control.shadow_reg0, BASE_HEX);
new bx_shadow_num_c(ctrl, "shadow_reg1", &BX_CIRRUS_THIS control.shadow_reg1, BASE_HEX);
bx_list_c *hdac = new bx_list_c(list, "hidden_dac");
new bx_shadow_num_c(hdac, "lockindex", &BX_CIRRUS_THIS hidden_dac.lockindex, BASE_HEX);
new bx_shadow_num_c(hdac, "data", &BX_CIRRUS_THIS hidden_dac.data, BASE_HEX);
reg = new bx_list_c(hdac, "palette");
for (i=0; i<48; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_CIRRUS_THIS hidden_dac.palette[i], BASE_HEX);
}
new bx_shadow_data_c(hdac, "palette", BX_CIRRUS_THIS hidden_dac.palette, 48, 1);
new bx_shadow_bool_c(list, "svga_unlock_special", &BX_CIRRUS_THIS svga_unlock_special);
new bx_shadow_num_c(list, "svga_xres", &BX_CIRRUS_THIS svga_xres);
new bx_shadow_num_c(list, "svga_yres", &BX_CIRRUS_THIS svga_yres);

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2014 The Bochs Project
// Copyright (C) 2001-2015 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -278,10 +278,6 @@ void bx_vgacore_c::init_systemtimer(bx_timer_handler_t f_timer, param_event_hand
void bx_vgacore_c::register_state(bx_list_c *parent)
{
unsigned i;
char name[6];
bx_list_c *reg;
bx_list_c *list = new bx_list_c(parent, "vgacore", "VGA Core State");
bx_list_c *misc = new bx_list_c(list, "misc_output");
new bx_shadow_bool_c(misc, "color_emulation", &BX_VGA_THIS s.misc_output.color_emulation);
@ -292,21 +288,13 @@ void bx_vgacore_c::register_state(bx_list_c *parent)
new bx_shadow_bool_c(misc, "vert_sync_pol", &BX_VGA_THIS s.misc_output.vert_sync_pol);
bx_list_c *crtc = new bx_list_c(list, "CRTC");
new bx_shadow_num_c(crtc, "address", &BX_VGA_THIS s.CRTC.address, BASE_HEX);
reg = new bx_list_c(crtc, "reg");
for (i=0; i<=0x18; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_VGA_THIS s.CRTC.reg[i], BASE_HEX);
}
new bx_shadow_data_c(crtc, "reg", BX_VGA_THIS s.CRTC.reg, 25, 1);
new bx_shadow_bool_c(crtc, "write_protect", &BX_VGA_THIS s.CRTC.write_protect);
bx_list_c *actl = new bx_list_c(list, "attribute_ctrl");
new bx_shadow_bool_c(actl, "flip_flop", &BX_VGA_THIS s.attribute_ctrl.flip_flop);
new bx_shadow_num_c(actl, "address", &BX_VGA_THIS s.attribute_ctrl.address, BASE_HEX);
new bx_shadow_bool_c(actl, "video_enabled", &BX_VGA_THIS s.attribute_ctrl.video_enabled);
reg = new bx_list_c(actl, "palette_reg");
for (i=0; i<16; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(reg, name, &BX_VGA_THIS s.attribute_ctrl.palette_reg[i], BASE_HEX);
}
new bx_shadow_data_c(actl, "palette_reg", BX_VGA_THIS s.attribute_ctrl.palette_reg, 16, 1);
new bx_shadow_num_c(actl, "overscan_color", &BX_VGA_THIS s.attribute_ctrl.overscan_color, BASE_HEX);
new bx_shadow_num_c(actl, "color_plane_enable", &BX_VGA_THIS s.attribute_ctrl.color_plane_enable, BASE_HEX);
new bx_shadow_num_c(actl, "horiz_pel_panning", &BX_VGA_THIS s.attribute_ctrl.horiz_pel_panning, BASE_HEX);

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2014 The Bochs Project
// Copyright (C) 2002-2015 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -226,10 +226,6 @@ void bx_keyb_c::reset(unsigned type)
void bx_keyb_c::register_state(void)
{
int i;
char name[4];
bx_list_c *buffer;
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "keyboard", "Keyboard State");
bx_list_c *ctrl = new bx_list_c(list, "controller");
BXRS_PARAM_BOOL(ctrl, tim, BX_KEY_THIS s.kbd_controller.tim);
@ -270,11 +266,8 @@ void bx_keyb_c::register_state(void)
BXRS_PARAM_BOOL(mouse, im_mode, BX_KEY_THIS s.mouse.im_mode);
bx_list_c *kbdbuf = new bx_list_c(list, "kbd_internal_buffer");
BXRS_DEC_PARAM_FIELD(kbdbuf, num_elements, BX_KEY_THIS s.kbd_internal_buffer.num_elements);
buffer = new bx_list_c(kbdbuf, "buffer");
for (i=0; i<BX_KBD_ELEMENTS; i++) {
sprintf(name, "%d", i);
new bx_shadow_num_c(buffer, name, &BX_KEY_THIS s.kbd_internal_buffer.buffer[i], BASE_HEX);
}
new bx_shadow_data_c(kbdbuf, "buffer", BX_KEY_THIS s.kbd_internal_buffer.buffer,
BX_KBD_ELEMENTS, 1);
BXRS_DEC_PARAM_FIELD(kbdbuf, head, BX_KEY_THIS s.kbd_internal_buffer.head);
BXRS_PARAM_BOOL(kbdbuf, expecting_typematic, BX_KEY_THIS s.kbd_internal_buffer.expecting_typematic);
BXRS_PARAM_BOOL(kbdbuf, expecting_led_write, BX_KEY_THIS s.kbd_internal_buffer.expecting_led_write);
@ -284,17 +277,11 @@ void bx_keyb_c::register_state(void)
BXRS_PARAM_BOOL(kbdbuf, scanning_enabled, BX_KEY_THIS s.kbd_internal_buffer.scanning_enabled);
bx_list_c *mousebuf = new bx_list_c(list, "mouse_internal_buffer");
BXRS_DEC_PARAM_FIELD(mousebuf, num_elements, BX_KEY_THIS s.mouse_internal_buffer.num_elements);
buffer = new bx_list_c(mousebuf, "buffer");
for (i=0; i<BX_MOUSE_BUFF_SIZE; i++) {
sprintf(name, "%d", i);
new bx_shadow_num_c(buffer, name, &BX_KEY_THIS s.mouse_internal_buffer.buffer[i], BASE_HEX);
}
new bx_shadow_data_c(mousebuf, "buffer", BX_KEY_THIS s.mouse_internal_buffer.buffer,
BX_MOUSE_BUFF_SIZE, 1);
BXRS_DEC_PARAM_FIELD(mousebuf, head, BX_KEY_THIS s.mouse_internal_buffer.head);
buffer = new bx_list_c(list, "controller_Q");
for (i=0; i<BX_KBD_CONTROLLER_QSIZE; i++) {
sprintf(name, "%d", i);
new bx_shadow_num_c(buffer, name, &BX_KEY_THIS s.controller_Q[i], BASE_HEX);
}
new bx_shadow_data_c(list, "controller_Q", BX_KEY_THIS s.controller_Q,
BX_KBD_CONTROLLER_QSIZE, 1);
BXRS_DEC_PARAM_FIELD(list, controller_Qsize, BX_KEY_THIS s.controller_Qsize);
BXRS_DEC_PARAM_FIELD(list, controller_Qsource, BX_KEY_THIS s.controller_Qsource);
}

View File

@ -563,16 +563,8 @@ void bx_e1000_c::register_state(void)
BXRS_DEC_PARAM_FIELD(list, rxbuf_min_shift, BX_E1000_THIS s.rxbuf_min_shift);
BXRS_PARAM_BOOL(list, check_rxov, BX_E1000_THIS s.check_rxov);
bx_list_c *tx = new bx_list_c(list, "tx", "");
bx_list_c *header = new bx_list_c(tx, "header", "");
for (i = 0; i < 256; i++) {
sprintf(pname, "0x%02x", i);
new bx_shadow_num_c(header, pname, &BX_E1000_THIS s.tx.header[i], BASE_HEX);
}
bx_list_c *vlh = new bx_list_c(tx, "vlan_header", "");
for (i = 0; i < 4; i++) {
sprintf(pname, "0x%02x", i);
new bx_shadow_num_c(vlh, pname, &BX_E1000_THIS s.tx.vlan_header[i], BASE_HEX);
}
new bx_shadow_data_c(tx, "header", BX_E1000_THIS s.tx.header, 256, 1);
new bx_shadow_data_c(tx, "vlan_header", BX_E1000_THIS s.tx.vlan_header, 4, 1);
new bx_shadow_data_c(list, "tx_vlan_data", BX_E1000_THIS s.tx.vlan, 0x10004);
BXRS_DEC_PARAM_FIELD(tx, size, BX_E1000_THIS s.tx.size);
BXRS_DEC_PARAM_FIELD(tx, sum_needed, BX_E1000_THIS s.tx.sum_needed);

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2014 The Bochs Project
// Copyright (C) 2001-2015 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -347,9 +347,6 @@ void bx_ne2k_c::reset(unsigned type)
void bx_ne2k_c::register_state(void)
{
unsigned i;
char name[6];
bx_list_c *list = new bx_list_c(SIM->get_bochs_root(), "ne2k", "NE2000 State");
bx_list_c *CR = new bx_list_c(list, "CR");
new bx_shadow_bool_c(CR, "stop", &BX_NE2K_THIS s.CR.stop);
@ -424,17 +421,9 @@ void bx_ne2k_c::register_state(void)
new bx_shadow_num_c(list, "tallycnt_0", &BX_NE2K_THIS s.tallycnt_0, BASE_HEX);
new bx_shadow_num_c(list, "tallycnt_1", &BX_NE2K_THIS s.tallycnt_1, BASE_HEX);
new bx_shadow_num_c(list, "tallycnt_2", &BX_NE2K_THIS s.tallycnt_2, BASE_HEX);
bx_list_c *paddr = new bx_list_c(list, "physaddr");
for (i=0; i<6; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(paddr, name, &BX_NE2K_THIS s.physaddr[i], BASE_HEX);
}
new bx_shadow_data_c(list, "physaddr", BX_NE2K_THIS s.physaddr, 6, 1);
new bx_shadow_num_c(list, "curr_page", &BX_NE2K_THIS s.curr_page, BASE_HEX);
bx_list_c *mchash = new bx_list_c(list, "mchash");
for (i=0; i<8; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(mchash, name, &BX_NE2K_THIS s.mchash[i], BASE_HEX);
}
new bx_shadow_data_c(list, "mchash", BX_NE2K_THIS s.mchash, 8, 1);
new bx_shadow_num_c(list, "rempkt_ptr", &BX_NE2K_THIS s.rempkt_ptr, BASE_HEX);
new bx_shadow_num_c(list, "localpkt_ptr", &BX_NE2K_THIS s.localpkt_ptr, BASE_HEX);
new bx_shadow_num_c(list, "address_cnt", &BX_NE2K_THIS s.address_cnt, BASE_HEX);

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2014 The Bochs Project
// Copyright (C) 2001-2015 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -577,7 +577,7 @@ bx_serial_c::init(void)
void bx_serial_c::register_state(void)
{
unsigned i, j;
unsigned i;
char name[6];
bx_list_c *port;
@ -645,16 +645,8 @@ void bx_serial_c::register_state(void)
new bx_shadow_bool_c(mstatus, "dcd", &BX_SER_THIS s[i].modem_status.dcd);
new bx_shadow_num_c(port, "scratch", &BX_SER_THIS s[i].scratch, BASE_HEX);
new bx_shadow_num_c(port, "tsrbuffer", &BX_SER_THIS s[i].tsrbuffer, BASE_HEX);
bx_list_c *rxfifo = new bx_list_c(port, "rx_fifo");
for (j=0; j<16; j++) {
sprintf(name, "0x%02x", j);
new bx_shadow_num_c(rxfifo, name, &BX_SER_THIS s[i].rx_fifo[j], BASE_HEX);
}
bx_list_c *txfifo = new bx_list_c(port, "tx_fifo");
for (j=0; j<16; j++) {
sprintf(name, "0x%02x", j);
new bx_shadow_num_c(txfifo, name, &BX_SER_THIS s[i].tx_fifo[j], BASE_HEX);
}
new bx_shadow_data_c(port, "rx_fifo", BX_SER_THIS s[i].rx_fifo, 16, 1);
new bx_shadow_data_c(port, "tx_fifo", BX_SER_THIS s[i].tx_fifo, 16, 1);
new bx_shadow_num_c(port, "divisor_lsb", &BX_SER_THIS s[i].divisor_lsb, BASE_HEX);
new bx_shadow_num_c(port, "divisor_msb", &BX_SER_THIS s[i].divisor_msb, BASE_HEX);
}
@ -666,11 +658,8 @@ void bx_serial_c::register_state(void)
new bx_shadow_bool_c(list, "mouse_update", &BX_SER_THIS mouse_update);
bx_list_c *mousebuf = new bx_list_c(list, "mouse_internal_buffer");
new bx_shadow_num_c(mousebuf, "num_elements", &BX_SER_THIS mouse_internal_buffer.num_elements);
bx_list_c *buffer = new bx_list_c(mousebuf, "buffer");
for (i=0; i<BX_MOUSE_BUFF_SIZE; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(buffer, name, &BX_SER_THIS mouse_internal_buffer.buffer[i], BASE_HEX);
}
new bx_shadow_data_c(mousebuf, "buffer", BX_SER_THIS mouse_internal_buffer.buffer,
BX_MOUSE_BUFF_SIZE, 1);
new bx_shadow_num_c(mousebuf, "head", &BX_SER_THIS mouse_internal_buffer.head);
}

View File

@ -399,11 +399,8 @@ void bx_es1370_c::register_state(void)
BXRS_HEX_PARAM_FIELD(list, status, BX_ES1370_THIS s.status);
BXRS_HEX_PARAM_FIELD(list, mempage, BX_ES1370_THIS s.mempage);
BXRS_HEX_PARAM_FIELD(list, codec_index, BX_ES1370_THIS s.codec_index);
bx_list_c *codec_regs = new bx_list_c(list, "codec_regs", "");
for (i = 0; i < BX_ES1370_CODEC_REGS; i++) {
sprintf(pname, "0x%02x", i);
new bx_shadow_num_c(codec_regs, pname, &BX_ES1370_THIS s.codec_reg[i], BASE_HEX);
}
new bx_shadow_data_c(list, "codec_regs", BX_ES1370_THIS s.codec_reg,
BX_ES1370_CODEC_REGS, 1);
BXRS_HEX_PARAM_FIELD(list, sctl, BX_ES1370_THIS s.sctl);
BXRS_HEX_PARAM_FIELD(list, legacy1B, BX_ES1370_THIS s.legacy1B);
BXRS_HEX_PARAM_FIELD(list, wave_vol, BX_ES1370_THIS s.wave_vol);

View File

@ -1525,16 +1525,8 @@ void adlib_register_state(bx_list_c *parent)
bx_list_c *adlib = new bx_list_c(parent, "adlib");
new bx_shadow_num_c(adlib, "opl_index", &opl_index, BASE_HEX);
#if defined(OPLTYPE_IS_OPL3)
bx_list_c *regs = new bx_list_c(adlib, "regs");
for (i = 0; i < 512; i++) {
sprintf(numstr, "0x%03x", i);
new bx_shadow_num_c(regs, numstr, &adlibreg[i], BASE_HEX);
}
bx_list_c *wavesel = new bx_list_c(adlib, "wave_sel");
for (i = 0; i < 44; i++) {
sprintf(numstr, "%d", i);
new bx_shadow_num_c(wavesel, numstr, &wave_sel[i]);
}
new bx_shadow_data_c(adlib, "regs", adlibreg, 512);
new bx_shadow_data_c(adlib, "wave_sel", wave_sel, 44, 1);
#endif
new bx_shadow_num_c(adlib, "vibtab_pos", &vibtab_pos);
new bx_shadow_num_c(adlib, "tremtab_pos", &tremtab_pos);

View File

@ -493,11 +493,7 @@ void bx_sb16_c::register_state(void)
new bx_shadow_num_c(dma, "volume", &DSP.dma.param.volume);
new bx_shadow_num_c(list, "fm_volume", &fm_volume);
new bx_shadow_data_c(list, "chunk", DSP.dma.chunk, BX_SOUNDLOW_WAVEPACKETSIZE);
bx_list_c *csp = new bx_list_c(list, "csp_reg");
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(csp, name, &BX_SB16_THIS csp_reg[i], BASE_HEX);
}
new bx_shadow_data_c(list, "csp_reg", BX_SB16_THIS csp_reg, 256, 1);
bx_list_c *opl = new bx_list_c(list, "opl");
new bx_shadow_num_c(opl, "timer_running", &OPL.timer_running);
for (i=0; i<2; i++) {
@ -512,11 +508,7 @@ void bx_sb16_c::register_state(void)
new bx_shadow_num_c(chip, "tflag", &OPL.tflag[i]);
}
new bx_shadow_num_c(list, "mixer_regindex", &MIXER.regindex, BASE_HEX);
bx_list_c *mixer = new bx_list_c(list, "mixer_reg");
for (i=0; i<BX_SB16_MIX_REG; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(mixer, name, &MIXER.reg[i], BASE_HEX);
}
new bx_shadow_data_c(list, "mixer_reg", MIXER.reg, BX_SB16_MIX_REG, 1);
bx_list_c *emul = new bx_list_c(list, "emul");
new bx_shadow_num_c(emul, "remaps", &EMUL.remaps);
bx_list_c *remap = new bx_list_c(emul, "remaplist");

View File

@ -7,7 +7,7 @@
//
// Copyright (c) 2005 Fabrice Bellard
// Copyright (c) 2007 OpenMoko, Inc. (andrew@openedhand.com)
// Copyright (C) 2009-2014 The Bochs Project
// Copyright (C) 2009-2015 The Bochs Project
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -444,10 +444,6 @@ usb_hid_device_c::~usb_hid_device_c(void)
void usb_hid_device_c::register_state_specific(bx_list_c *parent)
{
bx_list_c *key;
Bit8u i;
char name[6];
bx_list_c *list = new bx_list_c(parent, "s", "USB HID Device State");
new bx_shadow_num_c(list, "mouse_delayed_dx", &s.mouse_delayed_dx);
new bx_shadow_num_c(list, "mouse_delayed_dy", &s.mouse_delayed_dy);
@ -456,16 +452,8 @@ void usb_hid_device_c::register_state_specific(bx_list_c *parent)
new bx_shadow_num_c(list, "mouse_y", &s.mouse_y);
new bx_shadow_num_c(list, "mouse_z", &s.mouse_z);
new bx_shadow_num_c(list, "b_state", &s.b_state, BASE_HEX);
key = new bx_list_c(list, "saved_key");
for (i=0; i<8; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(key, name, &s.saved_key[i], BASE_HEX);
}
key = new bx_list_c(list, "key_pad_packet");
for (i=0; i<8; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(key, name, &s.key_pad_packet[i], BASE_HEX);
}
new bx_shadow_data_c(list, "saved_key", s.saved_key, 8, 1);
new bx_shadow_data_c(list, "key_pad_packet", s.key_pad_packet, 8, 1);
}
void usb_hid_device_c::handle_reset()