fixed code duplication and comments

This commit is contained in:
Stanislav Shwartsman 2007-02-03 17:56:35 +00:00
parent 4fecfdebbf
commit 2f9e1bee68
12 changed files with 52 additions and 73 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: exception.cc,v 1.88 2007-01-13 10:43:31 sshwarts Exp $
// $Id: exception.cc,v 1.89 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -67,9 +67,6 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
bx_descriptor_t gate_descriptor, cs_descriptor;
bx_selector_t cs_selector;
Bit16u gate_dest_selector;
Bit64u gate_dest_offset;
// interrupt vector must be within IDT table limits,
// else #GP(vector number*16 + 2 + EXT)
idtindex = vector*16;
@ -82,7 +79,7 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
}
// descriptor AR byte must indicate interrupt gate, trap gate,
// or task gate, else #GP(vector*8 + 2 + EXT)
// or task gate, else #GP(vector*16 + 2 + EXT)
idtindex += BX_CPU_THIS_PTR idtr.base;
access_linear(idtindex, 4, 0, BX_READ, &dword1);
@ -106,21 +103,21 @@ void BX_CPU_C::long_mode_int(Bit8u vector, bx_bool is_INT, bx_bool is_error_code
}
// if software interrupt, then gate descripor DPL must be >= CPL,
// else #GP(vector * 8 + 2 + EXT)
// else #GP(vector * 16 + 2 + EXT)
if (is_INT && (gate_descriptor.dpl < CPL))
{
BX_ERROR(("interrupt(long mode): is_INT && (dpl < CPL)"));
exception(BX_GP_EXCEPTION, vector*16 + 2, 0);
}
// Gate must be present, else #NP(vector * 8 + 2 + EXT)
// Gate must be present, else #NP(vector * 16 + 2 + EXT)
if (! IS_PRESENT(gate_descriptor)) {
BX_ERROR(("interrupt(long mode): p == 0"));
exception(BX_NP_EXCEPTION, vector*16 + 2, 0);
}
gate_dest_selector = gate_descriptor.u.gate386.dest_selector;
gate_dest_offset = ((Bit64u)dword3 << 32) +
Bit16u gate_dest_selector = gate_descriptor.u.gate386.dest_selector;
Bit64u gate_dest_offset = ((Bit64u)dword3 << 32) +
gate_descriptor.u.gate386.dest_offset;
unsigned ist = gate_descriptor.u.gate386.dword_count & 0x7;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vm8086.cc,v 1.27 2006-06-12 16:58:27 sshwarts Exp $
// $Id: vm8086.cc,v 1.28 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -87,7 +87,7 @@ void BX_CPU_C::stack_return_to_v86(Bit32u new_eip, Bit32u raw_cs_selector,
exception(BX_SS_EXCEPTION, 0, 0);
}
esp_laddr = BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].cache.u.segment.base + temp_ESP;
esp_laddr = BX_CPU_THIS_PTR get_segment_base(BX_SEG_REG_SS) + temp_ESP;
// load SS:ESP from stack
access_linear(esp_laddr + 12, 4, 0, BX_READ, &new_esp);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: acpi.cc,v 1.5 2006-10-07 08:59:15 vruppert Exp $
// $Id: acpi.cc,v 1.6 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2006 Volker Ruppert
@ -177,19 +177,12 @@ void bx_acpi_ctrl_c::reset(unsigned type)
#if BX_SUPPORT_SAVE_RESTORE
void bx_acpi_ctrl_c::register_state(void)
{
unsigned i;
char name[6];
bx_list_c *list = new bx_list_c(SIM->get_sr_root(), "acpi", "ACPI Controller State");
bx_list_c *list = new bx_list_c(SIM->get_sr_root(), "acpi", "ACPI Controller State", 5);
BXRS_HEX_PARAM_FIELD(list, pmsts, BX_ACPI_THIS s.pmsts);
BXRS_HEX_PARAM_FIELD(list, pmen, BX_ACPI_THIS s.pmen);
BXRS_HEX_PARAM_FIELD(list, pmcntrl, BX_ACPI_THIS s.pmcntrl);
BXRS_HEX_PARAM_FIELD(list, tmr_overflow_time, BX_ACPI_THIS s.tmr_overflow_time);
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_ACPI_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_ACPI_THIS s.pci_conf);
}
void bx_acpi_ctrl_c::after_restore_state(void)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: devices.cc,v 1.115 2006-10-02 10:14:07 vruppert Exp $
// $Id: devices.cc,v 1.116 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -122,7 +122,7 @@ void bx_devices_c::init(BX_MEM_C *newmem)
unsigned i;
const char def_name[] = "Default";
BX_DEBUG(("Init $Id: devices.cc,v 1.115 2006-10-02 10:14:07 vruppert Exp $"));
BX_DEBUG(("Init $Id: devices.cc,v 1.116 2007-02-03 17:56:35 sshwarts Exp $"));
mem = newmem;
/* set no-default handlers, will be overwritten by the real default handler */
@ -1030,3 +1030,17 @@ bx_bool bx_devices_c::is_parallel_enabled()
}
return false;
}
#if BX_SUPPORT_SAVE_RESTORE
void bx_pci_device_stub_c::register_pci_state(bx_list_c *list, Bit8u *pci_conf)
{
unsigned i;
char name[6];
bx_list_c *pci = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci, name, &pci_conf[i], BASE_HEX);
}
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: iodev.h,v 1.85 2006-10-02 10:14:07 vruppert Exp $
// $Id: iodev.h,v 1.86 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -58,7 +58,6 @@ class bx_g2h_c;
#endif
typedef Bit32u (*bx_read_handler_t)(void *, Bit32u, unsigned);
typedef void (*bx_write_handler_t)(void *, Bit32u, Bit32u, unsigned);
@ -95,6 +94,8 @@ class BOCHSAPI bx_devmodel_c : public logfunctions {
// declare stubs for PCI devices
//////////////////////////////////////////////////////////////////////
class bx_list_c;
// the best should be deriving of bx_pci_device_stub_c from bx_devmodel_c
// but it make serious problems for cirrus_svga device
class BOCHSAPI bx_pci_device_stub_c {
@ -106,6 +107,10 @@ public:
}
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len) {}
#if BX_SUPPORT_SAVE_RESTORE
void register_pci_state(bx_list_c *list, Bit8u *pci_conf);
#endif
};
//////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: ne2k.cc,v 1.90 2006-09-20 20:52:23 vruppert Exp $
// $Id: ne2k.cc,v 1.91 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -226,11 +226,7 @@ void bx_ne2k_c::register_state(void)
new bx_shadow_bool_c(list, "tx_timer_active", &BX_NE2K_THIS s.tx_timer_active);
#if BX_SUPPORT_PCI
if (BX_NE2K_THIS s.pci_enabled) {
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_NE2K_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_NE2K_THIS s.pci_conf);
}
#endif
}
@ -1408,7 +1404,7 @@ void bx_ne2k_c::init(void)
char devname[16];
bx_list_c *base;
BX_DEBUG(("Init $Id: ne2k.cc,v 1.90 2006-09-20 20:52:23 vruppert Exp $"));
BX_DEBUG(("Init $Id: ne2k.cc,v 1.91 2007-02-03 17:56:35 sshwarts Exp $"));
// Read in values from config interface
base = (bx_list_c*) SIM->get_param(BXPN_NE2K);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pci2isa.cc,v 1.39 2006-10-01 19:51:49 vruppert Exp $
// $Id: pci2isa.cc,v 1.40 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -155,11 +155,9 @@ void bx_piix3_c::register_state(void)
char name[6];
bx_list_c *list = new bx_list_c(SIM->get_sr_root(), "pci2isa", "PCI-to-ISA Bridge State", 8);
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_P2I_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_P2I_THIS s.pci_conf);
BXRS_HEX_PARAM_FIELD(list, elcr1, BX_P2I_THIS s.elcr1);
BXRS_HEX_PARAM_FIELD(list, elcr2, BX_P2I_THIS s.elcr2);
BXRS_HEX_PARAM_FIELD(list, apmc, BX_P2I_THIS s.apmc);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pci_ide.cc,v 1.27 2006-09-10 17:18:44 vruppert Exp $
// $Id: pci_ide.cc,v 1.28 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -139,20 +139,15 @@ void bx_pci_ide_c::reset(unsigned type)
void bx_pci_ide_c::register_state(void)
{
char name[6];
unsigned i;
bx_list_c *list = new bx_list_c(SIM->get_sr_root(), "pci_ide", "PCI IDE Controller State");
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_PIDE_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_PIDE_THIS s.pci_conf);
new bx_shadow_data_c(list, "buffer0", BX_PIDE_THIS s.bmdma[0].buffer, 0x20000);
new bx_shadow_data_c(list, "buffer1", BX_PIDE_THIS s.bmdma[1].buffer, 0x20000);
for (i=0; i<2; i++) {
for (unsigned i=0; i<2; i++) {
sprintf(name, "%d", i);
bx_list_c *ctrl = new bx_list_c(list, name, 7);
BXRS_PARAM_BOOL(ctrl, cmd_ssbm, BX_PIDE_THIS s.bmdma[i].cmd_ssbm);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pcipnic.cc,v 1.22 2006-09-10 17:18:44 vruppert Exp $
// $Id: pcipnic.cc,v 1.23 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2003 Fen Systems Ltd.
@ -171,11 +171,7 @@ void bx_pcipnic_c::register_state(void)
}
new bx_shadow_data_c(list, "rData", BX_PNIC_THIS s.rData, PNIC_DATA_SIZE);
new bx_shadow_data_c(list, "recvRing", (Bit8u*)BX_PNIC_THIS s.recvRing, PNIC_RECV_RINGS*PNIC_DATA_SIZE);
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_PNIC_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_PNIC_THIS s.pci_conf);
}
void bx_pcipnic_c::after_restore_state(void)

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pciusb.cc,v 1.44 2006-09-24 10:10:21 vruppert Exp $
// $Id: pciusb.cc,v 1.45 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2004 MandrakeSoft S.A.
@ -296,11 +296,7 @@ void bx_pciusb_c::register_state(void)
new bx_shadow_bool_c(port, "connect_changed", &BX_USB_THIS hub[i].usb_port[j].connect_changed);
new bx_shadow_bool_c(port, "status", &BX_USB_THIS hub[i].usb_port[j].status);
}
bx_list_c *pci_conf = new bx_list_c(hub, "pci_conf", 256);
for (n=0; n<256; n++) {
sprintf(name, "0x%02x", n);
new bx_shadow_num_c(pci_conf, name, &BX_USB_THIS hub[i].pci_conf[n], BASE_HEX);
}
register_pci_state(hub, BX_USB_THIS hub[i].pci_conf);
}
new bx_shadow_bool_c(list, "busy", &BX_USB_THIS busy);
new bx_shadow_num_c(list, "global_reset", &BX_USB_THIS global_reset);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: pcivga.cc,v 1.13 2006-09-10 17:18:44 vruppert Exp $
// $Id: pcivga.cc,v 1.14 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002,2003 Mike Nordell
@ -114,15 +114,8 @@ void bx_pcivga_c::reset(unsigned type)
#if BX_SUPPORT_SAVE_RESTORE
void bx_pcivga_c::register_state(void)
{
unsigned i;
char name[6];
bx_list_c *list = new bx_list_c(SIM->get_sr_root(), "pcivga", "PCI VGA Adapter State");
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_PCIVGA_THIS s.pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_PCIVGA_THIS s.pci_conf);
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: svga_cirrus.cc,v 1.36 2006-10-08 15:21:26 vruppert Exp $
// $Id: svga_cirrus.cc,v 1.37 2007-02-03 17:56:35 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Makoto Suzuki (suzu)
@ -420,11 +420,7 @@ void bx_svga_cirrus_c::register_state(void)
new bx_shadow_num_c(cursor, "size", &BX_CIRRUS_THIS hw_cursor.size, BASE_HEX);
#if BX_SUPPORT_PCI && BX_SUPPORT_CLGD54XX_PCI
if (BX_CIRRUS_THIS pci_enabled) {
bx_list_c *pci_conf = new bx_list_c(list, "pci_conf", 256);
for (i=0; i<256; i++) {
sprintf(name, "0x%02x", i);
new bx_shadow_num_c(pci_conf, name, &BX_CIRRUS_THIS pci_conf[i], BASE_HEX);
}
register_pci_state(list, BX_CIRRUS_THIS pci_conf);
}
#endif
}