From b130bf671be9e8219bd913375daa6d8020c7c2d1 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 29 Dec 2011 19:51:54 +0000 Subject: [PATCH] - 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. --- bochs/bochs.h | 7 +++++-- bochs/config.cc | 6 +++--- bochs/gui/siminterface.cc | 7 +++++++ bochs/gui/siminterface.h | 1 + bochs/iodev/es1370.cc | 2 +- bochs/iodev/floppy.cc | 2 +- bochs/iodev/harddrv.cc | 2 +- bochs/iodev/ioapic.cc | 2 +- bochs/iodev/iodebug.cc | 2 +- bochs/iodev/keyboard.cc | 2 +- bochs/iodev/parallel.cc | 2 +- bochs/iodev/pci2isa.cc | 2 +- bochs/iodev/pcidev.cc | 2 +- bochs/iodev/pcipnic.cc | 2 +- bochs/iodev/pcivga.cc | 2 +- bochs/iodev/serial.cc | 2 +- bochs/iodev/svga_cirrus.cc | 2 +- bochs/iodev/unmapped.cc | 2 +- bochs/logio.cc | 22 ++++++++++++++++++---- bochs/main.cc | 27 ++++++++++++++++++++++++--- 20 files changed, 72 insertions(+), 26 deletions(-) diff --git a/bochs/bochs.h b/bochs/bochs.h index e65c3bd9c..61f4e5afa 100644 --- a/bochs/bochs.h +++ b/bochs/bochs.h @@ -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 && levelget_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); diff --git a/bochs/gui/siminterface.h b/bochs/gui/siminterface.h index ccd437ed1..b5de0ee9b 100644 --- a/bochs/gui/siminterface.h +++ b/bochs/gui/siminterface.h @@ -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) {} diff --git a/bochs/iodev/es1370.cc b/bochs/iodev/es1370.cc index b0b88aa4d..6e0e30b2f 100644 --- a/bochs/iodev/es1370.cc +++ b/bochs/iodev/es1370.cc @@ -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; diff --git a/bochs/iodev/floppy.cc b/bochs/iodev/floppy.cc index 68dc13503..9456b7a1b 100644 --- a/bochs/iodev/floppy.cc +++ b/bochs/iodev/floppy.cc @@ -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; } diff --git a/bochs/iodev/harddrv.cc b/bochs/iodev/harddrv.cc index 5f3846dc2..cc7944222 100644 --- a/bochs/iodev/harddrv.cc +++ b/bochs/iodev/harddrv.cc @@ -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; channelget_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); diff --git a/bochs/iodev/unmapped.cc b/bochs/iodev/unmapped.cc index 1d5d194f2..4fd8007fb 100644 --- a/bochs/iodev/unmapped.cc +++ b/bochs/iodev/unmapped.cc @@ -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) diff --git a/bochs/logio.cc b/bochs/logio.cc index 88377be15..9f9d66d3f 100644 --- a/bochs/logio.cc +++ b/bochs/logio.cc @@ -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; } diff --git a/bochs/main.cc b/bochs/main.cc index 9f4a403dd..ddc86abae 100644 --- a/bochs/main.cc +++ b/bochs/main.cc @@ -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