- initial "log action by device" implementation added (TODO: check for

invalid module names, save log actions to bochsrc)
- added new member 'name' to the logfunctions class for the case the prefix
  is too short. Added to some devices with longer names.
This commit is contained in:
Volker Ruppert 2011-12-29 19:51:54 +00:00
parent 32f53b5151
commit b130bf671b
20 changed files with 72 additions and 26 deletions

View File

@ -241,6 +241,7 @@ void print_tree(bx_param_c *node, int level = 0);
typedef class BOCHSAPI logfunctions
{
char *name;
char *prefix;
// values of onoff: 0=ignore, 1=report, 2=ask, 3=fatal
#define ACT_IGNORE 0
@ -264,13 +265,15 @@ public:
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
void ask (int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
void setonoff(int loglev, int value) {
assert (loglev >= 0 && loglev < N_LOGLEV);
onoff[loglev] = value;
}
char *getprefix () { return prefix; }
char *get_name() { return name; }
char *getprefix() { return prefix; }
int getonoff(int level) {
assert (level>=0 && level<N_LOGLEV);
return onoff[level];

View File

@ -280,10 +280,10 @@ void bx_init_options()
// subtree for setting up log actions by device in bochsrc
bx_list_c *logfn = new bx_list_c(menu, "logfn", "Logfunctions", 4);
new bx_list_c(logfn, "panic", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "error", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "info", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "debug", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "info", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "error", "", BX_MAX_LOGFN_MODULES);
new bx_list_c(logfn, "panic", "", BX_MAX_LOGFN_MODULES);
// optional plugin control (empty list)
menu = new bx_list_c(menu, "plugin_ctrl", "Optional Plugin Control", 16);

View File

@ -89,6 +89,7 @@ public:
virtual bx_param_enum_c *get_param_enum(const char *pname, bx_param_c *base=NULL);
virtual Bit32u gen_param_id() { return param_id++; }
virtual int get_n_log_modules();
virtual char *get_logfn_name(int mod);
virtual char *get_prefix(int mod);
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
@ -341,6 +342,12 @@ int bx_real_sim_c::get_n_log_modules()
return io->get_n_logfns();
}
char *bx_real_sim_c::get_logfn_name(int mod)
{
logfunc_t *logfn = io->get_logfn(mod);
return logfn->get_name();
}
char *bx_real_sim_c::get_prefix(int mod)
{
logfunc_t *logfn = io->get_logfn(mod);

View File

@ -600,6 +600,7 @@ public:
virtual bx_param_enum_c *get_param_enum(const char *pname, bx_param_c *base=NULL) {return NULL;}
virtual unsigned gen_param_id() {return 0;}
virtual int get_n_log_modules() {return -1;}
virtual char *get_logfn_name(int mod) {return 0;}
virtual char *get_prefix(int mod) {return 0;}
virtual int get_log_action(int mod, int level) {return -1;}
virtual void set_log_action(int mod, int level, int action) {}

View File

@ -167,7 +167,7 @@ void libes1370_LTX_plugin_fini(void)
bx_es1370_c::bx_es1370_c()
{
put("E1370");
put("es1370", "E1370");
s.dac1_timer_index = BX_NULL_TIMER_HANDLE;
s.dac2_timer_index = BX_NULL_TIMER_HANDLE;

View File

@ -127,7 +127,7 @@ void libfloppy_LTX_plugin_fini(void)
bx_floppy_ctrl_c::bx_floppy_ctrl_c()
{
put("FDD");
put("floppy", "FDD");
s.floppy_timer_index = BX_NULL_TIMER_HANDLE;
}

View File

@ -125,7 +125,7 @@ bx_hard_drive_c::bx_hard_drive_c()
# error code must be fixed to use DLL_HD_SUPPORT and 4 ata channels
#endif
put("HD");
put("harddrv", "HD");
for (Bit8u channel=0; channel<BX_MAX_ATA_CHANNEL; channel++) {
for (Bit8u device=0; device<2; device ++) {
channels[channel].drives[device].hdimage = NULL;

View File

@ -113,7 +113,7 @@ void bx_io_redirect_entry_t::register_state(bx_param_c *parent)
bx_ioapic_c::bx_ioapic_c(): base_addr(BX_IOAPIC_BASE_ADDR)
{
set_id(BX_IOAPIC_DEFAULT_ID);
put("IOAP");
put("ioapic", "IOAP");
}
void bx_ioapic_c::init(void)

View File

@ -60,7 +60,7 @@ struct bx_iodebug_s_type {
bx_iodebug_c::bx_iodebug_c()
{
put("IODBG");
put("iodebug", "IODBG");
}
void bx_iodebug_c::init(void)

View File

@ -77,7 +77,7 @@ void libkeyboard_LTX_plugin_fini(void)
bx_keyb_c::bx_keyb_c()
{
put("KBD");
put("keyboard", "KBD");
pastebuf = NULL;
}

View File

@ -49,7 +49,7 @@ void libparallel_LTX_plugin_fini(void)
bx_parallel_c::bx_parallel_c()
{
put("PAR");
put("parallel", "PAR");
for (int i=0; i<BX_PARPORT_MAXDEV; i++) {
s[i].output = NULL;
}

View File

@ -57,7 +57,7 @@ void libpci2isa_LTX_plugin_fini(void)
bx_piix3_c::bx_piix3_c()
{
put("P2I");
put("pci2isa", "P2I");
}
bx_piix3_c::~bx_piix3_c()

View File

@ -58,7 +58,7 @@ void libpcidev_LTX_plugin_fini(void)
bx_pcidev_c::bx_pcidev_c()
{
put("PCI2H");
put("pcidev", "PCI2H");
}
bx_pcidev_c::~bx_pcidev_c()

View File

@ -53,7 +53,7 @@ void libpcipnic_LTX_plugin_fini(void)
bx_pcipnic_c::bx_pcipnic_c()
{
put("PNIC");
put("pcipnic", "PNIC");
}
bx_pcipnic_c::~bx_pcipnic_c()

View File

@ -58,7 +58,7 @@ void libpcivga_LTX_plugin_fini(void)
bx_pcivga_c::bx_pcivga_c()
{
put("PCIVGA");
put("pcivga", "PCIVG");
}
bx_pcivga_c::~bx_pcivga_c()

View File

@ -68,7 +68,7 @@ void libserial_LTX_plugin_fini(void)
bx_serial_c::bx_serial_c(void)
{
put("SER");
put("serial", "SER");
for (int i=0; i<BX_SERIAL_MAXDEV; i++) {
s[i].io_mode = BX_SER_MODE_NULL;
s[i].tty_id = -1;

View File

@ -253,7 +253,7 @@ bx_svga_cirrus_c::~bx_svga_cirrus_c()
void bx_svga_cirrus_c::init_vga_extension(void)
{
if (!strcmp(SIM->get_param_string(BXPN_VGA_EXTENSION)->getptr(), "cirrus")) {
BX_CIRRUS_THIS put("CLVGA");
BX_CIRRUS_THIS put("cirrus", "CLVGA");
// initialize SVGA stuffs.
BX_CIRRUS_THIS bx_vga_c::init_iohandlers(svga_read_handler, svga_write_handler);
BX_CIRRUS_THIS bx_vga_c::init_systemtimer(svga_timer_handler, svga_param_handler);

View File

@ -45,7 +45,7 @@ void libunmapped_LTX_plugin_fini(void)
bx_unmapped_c::bx_unmapped_c(void)
{
put("UNMP");
put("unmapped", "UNMP");
}
bx_unmapped_c::~bx_unmapped_c(void)

View File

@ -280,8 +280,9 @@ int logfunctions::default_onoff[N_LOGLEV] =
logfunctions::logfunctions(void)
{
name = NULL;
prefix = NULL;
put(" ");
put("?", " ");
if (io == NULL && Allocio == 0) {
Allocio = 1;
io = new iofunc_t(stderr);
@ -295,8 +296,9 @@ logfunctions::logfunctions(void)
logfunctions::logfunctions(iofunc_t *iofunc)
{
name = NULL;
prefix = NULL;
put(" ");
put("?", " ");
setio(iofunc);
// BUG: unfortunately this can be called before the bochsrc is read,
// which means that the bochsrc has no effect on the actions.
@ -307,6 +309,7 @@ logfunctions::logfunctions(iofunc_t *iofunc)
logfunctions::~logfunctions()
{
logio->remove_logfn(this);
if (name) free(name);
if (prefix) free(prefix);
}
@ -319,6 +322,12 @@ void logfunctions::setio(iofunc_t *i)
}
void logfunctions::put(const char *p)
{
const char *n = p;
put(n, p);
}
void logfunctions::put(const char *n, const char *p)
{
char *tmpbuf=strdup("[ ]"); // if we ever have more than 32 chars,
// we need to rethink this
@ -326,8 +335,13 @@ void logfunctions::put(const char *p)
if (tmpbuf == NULL)
return; // allocation not successful
if (prefix != NULL)
{
if (name != NULL) {
free(name); // free previously allocated memory
name = NULL;
}
name = strdup(n);
if (prefix != NULL) {
free(prefix); // free previously allocated memory
prefix = NULL;
}

View File

@ -1008,6 +1008,29 @@ void bx_sr_after_restore_state(void)
DEV_after_restore_state();
}
void bx_set_log_action_by_device()
{
int m, l;
char *module;
bx_list_c *levels, *table;
bx_param_num_c *action;
for (m = 0; m < SIM->get_n_log_modules(); m++) {
module = SIM->get_logfn_name(m);
if (strcmp(module, "?")) {
for (l = 0; l < SIM->get_max_log_level(); l++) {
levels = (bx_list_c*) SIM->get_param("general.logfn");
table = (bx_list_c*) levels->get(l);
action = (bx_param_num_c*) table->get_by_name(module);
if (action != NULL) {
SIM->set_log_action(m, l, action->get());
}
}
}
}
// TODO: check for invalid module names
}
void bx_init_hardware()
{
// all configuration has been read, now initialize everything.
@ -1215,9 +1238,7 @@ void bx_init_hardware()
SIM->get_param_bool(BXPN_RESTORE_FLAG)->set(0);
}
} else {
//
// TODO: add set log actions by device code here
//
bx_set_log_action_by_device();
}
// will enable A20 line and reset CPU and devices