2001-04-10 06:20:02 +04:00
|
|
|
// Copyright (C) 2001 MandrakeSoft S.A.
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// MandrakeSoft S.A.
|
|
|
|
// 43, rue d'Aboukir
|
|
|
|
// 75002 Paris - France
|
|
|
|
// http://www.linux-mandrake.com/
|
|
|
|
// http://www.mandrakesoft.com/
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "bochs.h"
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
#include <assert.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "state_file.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <signal.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __MINGW32__
|
|
|
|
void alarm(int);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if BX_PROVIDE_DEVICE_MODELS==1
|
|
|
|
// some prototypes from iodev/
|
|
|
|
// I want to stay away from including iodev/iodev.h here
|
|
|
|
Bit32u bx_unmapped_io_read_handler(Bit32u address, unsigned io_len);
|
|
|
|
void bx_unmapped_io_write_handler(Bit32u address, Bit32u value,
|
|
|
|
unsigned io_len);
|
|
|
|
void bx_close_harddrive(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
void bx_init_bx_dbg (void);
|
2001-04-10 05:04:59 +04:00
|
|
|
void bx_emulate_hga_dumps_timer(void);
|
2001-05-23 06:37:52 +04:00
|
|
|
static char *divider = "========================================================================";
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/* typedefs */
|
|
|
|
|
|
|
|
|
|
|
|
#if ( BX_PROVIDE_DEVICE_MODELS==1 )
|
|
|
|
bx_pc_system_c bx_pc_system;
|
|
|
|
class state_file state_stuff("state_file.out", "options");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bx_debug_t bx_dbg;
|
|
|
|
|
|
|
|
bx_options_t bx_options = {
|
2001-05-23 12:16:07 +04:00
|
|
|
{ "", BX_FLOPPY_NONE, BX_EJECTED }, // floppya
|
|
|
|
{ "", BX_FLOPPY_NONE, BX_EJECTED }, // floppyb
|
|
|
|
{ 0, "", 0, 0, 0 }, // diskc
|
|
|
|
{ 0, "", 0, 0, 0 }, // diskd
|
|
|
|
{ 0, "", 0 }, // cdromd
|
|
|
|
{ NULL, 0 }, // rom
|
|
|
|
{ NULL }, // vgarom
|
|
|
|
{ BX_DEFAULT_MEM_MEGS }, // memory
|
2001-06-11 10:35:18 +04:00
|
|
|
{ 0, NULL, NULL, NULL, 0, 0, 0, 0 }, // SB16
|
2001-05-23 12:16:07 +04:00
|
|
|
"a", // boot drive
|
|
|
|
300000, // vga update interval
|
2001-04-10 05:04:59 +04:00
|
|
|
20000, // default keyboard serial path delay (usec)
|
|
|
|
50000, // default floppy command delay (usec)
|
|
|
|
500000, // default ips (instructions-per-second)
|
|
|
|
0, // default mouse_enabled
|
|
|
|
0, // default private_colormap
|
|
|
|
0, // default i440FXSupport
|
|
|
|
{NULL, 0}, // cmos path, cmos image boolean
|
|
|
|
{ 0, 0, 0, {0,0,0,0,0,0}, NULL, NULL }, // ne2k
|
2001-05-18 00:06:31 +04:00
|
|
|
1, // newHardDriveSupport
|
2001-05-23 00:01:40 +04:00
|
|
|
{ 0, NULL, NULL, NULL }, // load32bitOSImage hack stuff
|
2001-06-11 10:35:18 +04:00
|
|
|
// log options: ignore debug, report info and error, crash on panic.
|
2001-06-11 18:03:35 +04:00
|
|
|
{ "-", { ACT_IGNORE, ACT_REPORT, ACT_REPORT, ACT_ASK } },
|
2001-04-10 05:04:59 +04:00
|
|
|
};
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
static void parse_line_unformatted(char *context, char *line);
|
|
|
|
static void parse_line_formatted(char *context, int num_params, char *params[]);
|
|
|
|
static int parse_bochsrc(char *rcfile);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
// Just for the iofunctions
|
|
|
|
|
|
|
|
#define LOG_THIS this->log->
|
|
|
|
|
|
|
|
int Allocio=0;
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::flush(void) {
|
|
|
|
if(logfd && magic == MAGIC_LOGNUM) {
|
|
|
|
fflush(logfd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::init(void) {
|
|
|
|
// iofunctions methods must not be called before this magic
|
|
|
|
// number is set.
|
|
|
|
magic=MAGIC_LOGNUM;
|
|
|
|
showtick = 1;
|
2001-05-24 11:59:08 +04:00
|
|
|
n_logfn = 0;
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
init_log(stderr);
|
|
|
|
log = new logfunc_t(this);
|
|
|
|
LOG_THIS setprefix("[IO ]");
|
|
|
|
LOG_THIS settype(IOLOG);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Init(log file: '%s').",logfn));
|
2001-05-23 06:37:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::add_logfn (logfunc_t *fn)
|
|
|
|
{
|
|
|
|
assert (n_logfn < MAX_LOGFNS);
|
|
|
|
logfn_list[n_logfn++] = fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::set_log_action (int loglevel, int action)
|
|
|
|
{
|
|
|
|
for (int i=0; i<n_logfn; i++)
|
|
|
|
logfn_list[i]->setonoff(loglevel, action);
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::init_log(char *fn)
|
|
|
|
{
|
|
|
|
assert (magic==MAGIC_LOGNUM);
|
|
|
|
// use newfd/newfn so that we can log the message to the OLD log
|
|
|
|
// file descriptor.
|
|
|
|
FILE *newfd = stderr;
|
|
|
|
char *newfn = "/dev/stderr";
|
|
|
|
if( strcmp( fn, "-" ) != 0 ) {
|
|
|
|
newfd = fopen(fn, "w");
|
|
|
|
if(newfd != NULL) {
|
|
|
|
newfn = strdup(fn);
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Opened log file '%s'.", fn ));
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
} else {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_DEBUG(("Log file '%s' not there?", fn));
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
newfd = NULL;
|
|
|
|
logfn = "(none)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logfd = newfd;
|
|
|
|
logfn = newfn;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::init_log(FILE *fs)
|
|
|
|
{
|
|
|
|
assert (magic==MAGIC_LOGNUM);
|
|
|
|
logfd = fs;
|
|
|
|
|
|
|
|
if(fs == stderr) {
|
|
|
|
logfn = "/dev/stderr";
|
|
|
|
} else if(fs == stdout) {
|
|
|
|
logfn = "/dev/stdout";
|
|
|
|
} else {
|
|
|
|
logfn = "(unknown)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::init_log(int fd)
|
|
|
|
{
|
|
|
|
assert (magic==MAGIC_LOGNUM);
|
|
|
|
FILE *tmpfd;
|
|
|
|
if( (tmpfd = fdopen(fd,"w")) == NULL ) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("Couldn't open fd %d as a stream for writing", fd));
|
2001-05-25 06:07:38 +04:00
|
|
|
return;
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
init_log(tmpfd);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
// iofunctions::out( class, level, prefix, fmt, ap)
|
|
|
|
// DO NOT nest out() from ::info() and the like.
|
|
|
|
// fmt and ap retained for direct printinf from iofunctions only!
|
|
|
|
|
|
|
|
void
|
|
|
|
iofunctions::out(int f, int l, char *prefix, char *fmt, va_list ap)
|
|
|
|
{
|
|
|
|
assert (magic==MAGIC_LOGNUM);
|
|
|
|
assert (this != NULL);
|
|
|
|
assert (logfd != NULL);
|
|
|
|
|
|
|
|
if( showtick )
|
|
|
|
fprintf(logfd, "%011lld ", bx_pc_system.time_ticks());
|
|
|
|
|
|
|
|
if(prefix != NULL)
|
|
|
|
fprintf(logfd, "%s ", prefix);
|
|
|
|
|
2001-05-15 20:32:41 +04:00
|
|
|
if(l==LOGLEV_PANIC)
|
|
|
|
fprintf(logfd, ">>PANIC<< ");
|
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
vfprintf(logfd, fmt, ap);
|
2001-05-30 22:56:02 +04:00
|
|
|
fprintf(logfd, "\n");
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
fflush(logfd);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iofunctions::iofunctions(FILE *fs)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
init_log(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
iofunctions::iofunctions(char *fn)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
init_log(fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
iofunctions::iofunctions(int fd)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
init_log(fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
iofunctions::iofunctions(void)
|
|
|
|
{
|
|
|
|
this->init();
|
|
|
|
}
|
|
|
|
|
|
|
|
iofunctions::~iofunctions(void)
|
|
|
|
{
|
|
|
|
// flush before erasing magic number, or flush does nothing.
|
|
|
|
this->flush();
|
|
|
|
this->magic=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef LOG_THIS
|
|
|
|
#define LOG_THIS genlog->
|
|
|
|
|
|
|
|
logfunctions::logfunctions(void)
|
|
|
|
{
|
2001-05-23 06:37:52 +04:00
|
|
|
setprefix("[ ]");
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
settype(GENLOG);
|
|
|
|
if(io == NULL && Allocio == 0) {
|
|
|
|
Allocio = 1;
|
|
|
|
io = new iofunc_t(stderr);
|
|
|
|
}
|
|
|
|
setio(io);
|
2001-05-23 00:01:40 +04:00
|
|
|
// BUG: unfortunately this can be called before the bochsrc is read,
|
|
|
|
// which means that the bochsrc has no effect on the actions.
|
2001-06-11 10:35:18 +04:00
|
|
|
for (int i=0; i<N_LOGLEV; i++)
|
|
|
|
onoff[i] = bx_options.log.actions[i];
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
logfunctions::logfunctions(iofunc_t *iofunc)
|
|
|
|
{
|
2001-05-23 06:37:52 +04:00
|
|
|
setprefix("[ ]");
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
settype(GENLOG);
|
|
|
|
setio(iofunc);
|
2001-05-23 00:01:40 +04:00
|
|
|
// BUG: unfortunately this can be called before the bochsrc is read,
|
|
|
|
// which means that the bochsrc has no effect on the actions.
|
2001-06-11 10:35:18 +04:00
|
|
|
for (int i=0; i<N_LOGLEV; i++)
|
|
|
|
onoff[i] = bx_options.log.actions[i];
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
logfunctions::~logfunctions(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::setio(iofunc_t *i)
|
|
|
|
{
|
2001-05-23 06:37:52 +04:00
|
|
|
// add pointer to iofunction object to use
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
this->logio = i;
|
2001-05-23 06:37:52 +04:00
|
|
|
// give iofunction a pointer to me
|
|
|
|
i->add_logfn (this);
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::setprefix(char *p)
|
|
|
|
{
|
|
|
|
this->prefix=strdup(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::settype(int t)
|
|
|
|
{
|
|
|
|
type=t;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::info(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
assert (this != NULL);
|
|
|
|
assert (this->logio != NULL);
|
|
|
|
|
2001-05-24 12:46:17 +04:00
|
|
|
if(!onoff[LOGLEV_INFO]) return;
|
2001-05-16 00:00:32 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
va_start(ap, fmt);
|
|
|
|
this->logio->out(this->type,LOGLEV_INFO,this->prefix, fmt, ap);
|
2001-06-11 18:03:35 +04:00
|
|
|
if (onoff[LOGLEV_INFO] == ACT_ASK)
|
|
|
|
ask (LOGLEV_INFO, this->prefix, fmt, ap);
|
|
|
|
if (onoff[LOGLEV_INFO] == ACT_FATAL)
|
|
|
|
fatal (this->prefix, fmt, ap);
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
va_end(ap);
|
2001-05-23 00:01:40 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::error(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
assert (this != NULL);
|
|
|
|
assert (this->logio != NULL);
|
|
|
|
|
2001-05-24 12:46:17 +04:00
|
|
|
if(!onoff[LOGLEV_ERROR]) return;
|
2001-05-16 00:00:32 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
va_start(ap, fmt);
|
|
|
|
this->logio->out(this->type,LOGLEV_ERROR,this->prefix, fmt, ap);
|
2001-06-11 18:03:35 +04:00
|
|
|
if (onoff[LOGLEV_ERROR] == ACT_ASK)
|
|
|
|
ask (LOGLEV_ERROR, this->prefix, fmt, ap);
|
|
|
|
if (onoff[LOGLEV_ERROR] == ACT_FATAL)
|
|
|
|
fatal (this->prefix, fmt, ap);
|
2001-05-24 12:46:17 +04:00
|
|
|
va_end(ap);
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
2001-05-23 00:01:40 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
void
|
|
|
|
logfunctions::panic(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
assert (this != NULL);
|
|
|
|
assert (this->logio != NULL);
|
|
|
|
|
2001-05-24 12:46:17 +04:00
|
|
|
if(!onoff[LOGLEV_PANIC]) return;
|
2001-05-16 00:00:32 +04:00
|
|
|
|
2001-05-24 12:46:17 +04:00
|
|
|
va_start(ap, fmt);
|
|
|
|
this->logio->out(this->type,LOGLEV_PANIC,this->prefix, fmt, ap);
|
2001-06-11 18:03:35 +04:00
|
|
|
if (onoff[LOGLEV_PANIC] == ACT_ASK)
|
|
|
|
ask (LOGLEV_PANIC, this->prefix, fmt, ap);
|
|
|
|
if (onoff[LOGLEV_PANIC] == ACT_FATAL)
|
|
|
|
fatal (this->prefix, fmt, ap);
|
2001-05-24 12:46:17 +04:00
|
|
|
va_end(ap);
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
logfunctions::ldebug(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
assert (this != NULL);
|
|
|
|
assert (this->logio != NULL);
|
|
|
|
|
2001-05-24 12:46:17 +04:00
|
|
|
if(!onoff[LOGLEV_DEBUG]) return;
|
2001-05-16 00:00:32 +04:00
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
va_start(ap, fmt);
|
|
|
|
this->logio->out(this->type,LOGLEV_DEBUG,this->prefix, fmt, ap);
|
2001-06-11 18:03:35 +04:00
|
|
|
if (onoff[LOGLEV_DEBUG] == ACT_ASK)
|
|
|
|
ask (LOGLEV_DEBUG, this->prefix, fmt, ap);
|
|
|
|
if (onoff[LOGLEV_DEBUG] == ACT_FATAL)
|
|
|
|
fatal (this->prefix, fmt, ap);
|
2001-05-24 12:46:17 +04:00
|
|
|
va_end(ap);
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
|
2001-06-11 18:03:35 +04:00
|
|
|
void
|
|
|
|
logfunctions::ask (int level, char *prefix, char *fmt, va_list ap)
|
|
|
|
{
|
|
|
|
#if BX_USE_CONTROL_PANEL
|
|
|
|
char buf1[1024], buf2[1024];
|
|
|
|
vsprintf (buf1, fmt, ap);
|
|
|
|
sprintf (buf2, "%s %s", prefix, buf1);
|
|
|
|
// FIXME: facility set to 0 because it's unknown.
|
|
|
|
int val = SIM->LOCAL_log_msg (prefix, level, buf2);
|
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 0: // user chose continue
|
|
|
|
break;
|
|
|
|
case 1: // user said continue, and don't ask for this facility again.
|
|
|
|
setonoff (level, ACT_REPORT);
|
|
|
|
break;
|
|
|
|
case 2: // user chose die
|
|
|
|
fatal (prefix, fmt, ap);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-05-23 00:01:40 +04:00
|
|
|
void
|
2001-05-23 06:37:52 +04:00
|
|
|
logfunctions::fatal (char *prefix, char *fmt, va_list ap)
|
2001-05-23 00:01:40 +04:00
|
|
|
{
|
2001-05-23 06:37:52 +04:00
|
|
|
static int fatal_reentry = 0;
|
|
|
|
if (fatal_reentry) return;
|
|
|
|
fatal_reentry++;
|
2001-05-23 00:01:40 +04:00
|
|
|
bx_atexit();
|
2001-05-23 06:37:52 +04:00
|
|
|
fprintf (stderr, "%s\n", divider);
|
|
|
|
fprintf (stderr, "Bochs is exiting with the following message:\n");
|
|
|
|
fprintf (stderr, "%s ", prefix);
|
|
|
|
vfprintf (stderr, fmt, ap);
|
2001-05-30 22:56:02 +04:00
|
|
|
fprintf (stderr, "\n%s\n", divider);
|
2001-05-25 05:56:28 +04:00
|
|
|
#if 0 && defined(WIN32)
|
|
|
|
#error disabled because it is not working yet!
|
|
|
|
// wait for a keypress before quitting. Depending on how bochs is
|
|
|
|
// installed, the console window can disappear before the user has
|
|
|
|
// a chance to read the final message.
|
|
|
|
fprintf (stderr, "\n\nPress Enter to exit...\n");
|
|
|
|
char buf[8];
|
|
|
|
fgets (buf, 8, stdin);
|
|
|
|
#endif
|
2001-05-23 00:01:40 +04:00
|
|
|
#if !BX_DEBUGGER
|
|
|
|
exit(1);
|
|
|
|
#else
|
|
|
|
static Boolean dbg_exit_called = 0;
|
|
|
|
if (dbg_exit_called == 0) {
|
|
|
|
dbg_exit_called = 1;
|
|
|
|
bx_dbg_exit(1);
|
|
|
|
}
|
|
|
|
#endif
|
2001-05-23 06:37:52 +04:00
|
|
|
fatal_reentry--;
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
iofunc_t *io = NULL;
|
|
|
|
logfunc_t *genlog = NULL;
|
|
|
|
|
2001-05-22 22:47:30 +04:00
|
|
|
void bx_center_print (FILE *file, char *line, int maxwidth)
|
|
|
|
{
|
|
|
|
int imax;
|
|
|
|
imax = (maxwidth - strlen(line)) >> 1;
|
|
|
|
for (int i=0; i<imax; i++) fputc (' ', file);
|
|
|
|
fputs (line, file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bx_print_header ()
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s\n", divider);
|
|
|
|
char buffer[128];
|
|
|
|
sprintf (buffer, "Bochs x86 Emulator %s\n", VER_STRING);
|
|
|
|
bx_center_print (stderr, buffer, 72);
|
2001-05-23 06:45:43 +04:00
|
|
|
if (REL_STRING[0]) {
|
|
|
|
sprintf (buffer, "%s\n", REL_STRING);
|
|
|
|
bx_center_print (stderr, buffer, 72);
|
|
|
|
}
|
2001-05-22 22:47:30 +04:00
|
|
|
fprintf (stderr, "%s\n", divider);
|
|
|
|
}
|
|
|
|
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
int
|
2001-04-10 05:04:59 +04:00
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2001-06-10 00:01:12 +04:00
|
|
|
// To deal with initialization order problems inherent in C++, use the macros
|
|
|
|
// SAFE_GET_IOFUNC and SAFE_GET_GENLOG to retrieve "io" and "genlog" in all
|
|
|
|
// constructors or functions called by constructors. The macros test for
|
|
|
|
// NULL and create the object if necessary, then return it. Ensure that io
|
|
|
|
// and genlog get created, by making one reference to each macro right here.
|
|
|
|
// All other code can reference io and genlog directly.
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
SAFE_GET_IOFUNC();
|
|
|
|
SAFE_GET_GENLOG();
|
|
|
|
|
2001-05-22 22:47:30 +04:00
|
|
|
bx_print_header ();
|
2001-06-10 00:01:12 +04:00
|
|
|
bx_init_bx_dbg ();
|
|
|
|
|
|
|
|
int read_rc_already = 0;
|
|
|
|
#if BX_USE_CONTROL_PANEL
|
|
|
|
// Display the pre-simulation control panel.
|
|
|
|
init_siminterface ();
|
|
|
|
if ((bx_control_panel (BX_CPANEL_START_MAIN)) != BX_DISABLE_CONTROL_PANEL)
|
|
|
|
read_rc_already = 1;
|
|
|
|
#endif
|
|
|
|
if (!read_rc_already) {
|
|
|
|
/* parse configuration file and command line arguments */
|
|
|
|
char *bochsrc = bx_find_bochsrc ();
|
|
|
|
if (bochsrc)
|
|
|
|
bx_read_configuration (bochsrc, argc, argv);
|
|
|
|
|
|
|
|
if (bochsrc == NULL && argc == 1) {
|
|
|
|
// no bochsrc used. This is legal since they may have
|
|
|
|
// everything on the command line. However if they have no
|
|
|
|
// arguments then give them some friendly advice.
|
|
|
|
fprintf (stderr, "%s\n", divider);
|
|
|
|
fprintf (stderr, "Before running Bochs, you should cd to a directory which contains\n");
|
|
|
|
fprintf (stderr, "a .bochsrc file and a disk image. If you downloaded a binary package,\n");
|
|
|
|
fprintf (stderr, "all the necessary files are already on your disk.\n");
|
|
|
|
#if defined(WIN32)
|
|
|
|
fprintf (stderr, "\nFor Windows installations, go to the dlxlinux direectory and\n");
|
|
|
|
fprintf (stderr, "double-click on the start.bat script.\n");
|
|
|
|
#elif !defined(macintosh)
|
|
|
|
fprintf (stderr, "\nFor UNIX installations, try running \"bochs-dlx\" for a demo. This script\n");
|
|
|
|
fprintf (stderr, "is basically equivalent to typing:\n");
|
|
|
|
fprintf (stderr, " cd /usr/local/bochs/dlxlinux\n");
|
|
|
|
fprintf (stderr, " bochs\n");
|
|
|
|
#endif
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2001-05-22 22:47:30 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_DEBUGGER
|
|
|
|
// If using the debugger, it will take control and call
|
2001-06-10 00:01:12 +04:00
|
|
|
// bx_init_hardware() and cpu_loop()
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_dbg_main(argc, argv);
|
|
|
|
#else
|
2001-06-10 00:01:12 +04:00
|
|
|
|
|
|
|
bx_init_hardware();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
if (bx_options.load32bitOSImage.whichOS) {
|
|
|
|
void bx_load32bitOSimagehack(void);
|
|
|
|
bx_load32bitOSimagehack();
|
|
|
|
}
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
#if BX_USE_CONTROL_PANEL
|
|
|
|
SIM->set_init_done (1);
|
|
|
|
#endif
|
|
|
|
|
2001-06-05 19:56:19 +04:00
|
|
|
if (BX_SMP_PROCESSORS == 1) {
|
|
|
|
// only one processor, run as fast as possible by not messing with
|
|
|
|
// quantums and loops.
|
|
|
|
BX_CPU(0)->cpu_loop(1);
|
|
|
|
} else {
|
|
|
|
// SMP simulation: do 5 instructions on each processor, then switch
|
|
|
|
// to another. I'm sure that increasing quantum speeds up overall
|
|
|
|
// performance.
|
|
|
|
int processor = 0;
|
|
|
|
int quantum = 5;
|
|
|
|
while (1) {
|
|
|
|
// do some instructions in each processor
|
|
|
|
BX_CPU(processor)->cpu_loop(quantum);
|
|
|
|
processor = (processor+1) % BX_SMP_PROCESSORS;
|
|
|
|
if (processor == 0)
|
|
|
|
BX_TICKN(quantum);
|
|
|
|
}
|
2001-05-23 12:16:07 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
int
|
|
|
|
bx_read_configuration (char *rcfile, int argc, char *argv[])
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2001-06-10 00:01:12 +04:00
|
|
|
// parse rcfile first, then parse arguments in order.
|
|
|
|
BX_INFO (("reading configuration from %s", rcfile));
|
|
|
|
if (parse_bochsrc(rcfile) < 0) {
|
|
|
|
BX_ERROR (("reading from %s failed", rcfile));
|
|
|
|
return -1;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
if (argc > 1)
|
|
|
|
BX_INFO (("parsing command line arguments"));
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
int n = 2;
|
|
|
|
while (n <= argc) {
|
|
|
|
parse_line_unformatted("cmdline args", argv[n-1]);
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_init_hardware()
|
|
|
|
{
|
|
|
|
// This function used to
|
|
|
|
// all configuration has been read, now initialize everything.
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-11 10:35:18 +04:00
|
|
|
for (int level=0; level<N_LOGLEV; level++)
|
|
|
|
io->set_log_action (level, bx_options.log.actions[level]);
|
2001-05-23 06:37:52 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_pc_system.init_ips(bx_options.ips);
|
|
|
|
|
2001-06-11 10:35:18 +04:00
|
|
|
if(bx_options.log.filename[0]!='-') {
|
|
|
|
BX_INFO (("using log file %s", bx_options.log.filename));
|
|
|
|
io->init_log(bx_options.log.filename);
|
2001-05-22 23:07:53 +04:00
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-05-23 12:16:07 +04:00
|
|
|
// set up memory and CPU objects
|
2001-06-12 17:07:43 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2001-05-23 12:16:07 +04:00
|
|
|
memset(apic_index, 0, sizeof(apic_index[0]) * APIC_MAX_ID);
|
|
|
|
#endif
|
2001-06-05 21:35:08 +04:00
|
|
|
|
|
|
|
#if BX_SMP_PROCESSORS==1
|
|
|
|
BX_MEM(0)->init_memory(bx_options.memory.megs * 1024*1024);
|
|
|
|
BX_MEM(0)->load_ROM(bx_options.rom.path, bx_options.rom.address);
|
|
|
|
BX_MEM(0)->load_ROM(bx_options.vgarom.path, 0xc0000);
|
|
|
|
BX_CPU(0)->init (BX_MEM(0));
|
|
|
|
BX_CPU(0)->reset(BX_RESET_HARDWARE);
|
|
|
|
#else
|
|
|
|
// SMP initialization
|
2001-05-23 12:16:07 +04:00
|
|
|
bx_mem_array[0] = new BX_MEM_C ();
|
|
|
|
bx_mem_array[0]->init_memory(bx_options.memory.megs * 1024*1024);
|
|
|
|
bx_mem_array[0]->load_ROM(bx_options.rom.path, bx_options.rom.address);
|
|
|
|
bx_mem_array[0]->load_ROM(bx_options.vgarom.path, 0xc0000);
|
|
|
|
for (int i=0; i<BX_SMP_PROCESSORS; i++) {
|
|
|
|
BX_CPU(i) = new BX_CPU_C ();
|
|
|
|
BX_CPU(i)->init (bx_mem_array[0]);
|
|
|
|
// assign apic ID from the index of this loop
|
2001-06-12 17:07:43 +04:00
|
|
|
// if !BX_SUPPORT_APIC, this will not compile.
|
2001-05-23 12:16:07 +04:00
|
|
|
BX_CPU(i)->local_apic.set_id (i);
|
|
|
|
BX_CPU(i)->reset(BX_RESET_HARDWARE);
|
|
|
|
}
|
2001-06-05 21:35:08 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_DEBUGGER == 0
|
2001-05-23 12:16:07 +04:00
|
|
|
bx_devices.init(BX_MEM(0));
|
2001-05-09 00:18:04 +04:00
|
|
|
bx_gui.init_signal_handlers ();
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_pc_system.start_timers();
|
|
|
|
#endif
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_DEBUG(("bx_init_hardware is setting signal handlers"));
|
2001-04-10 05:04:59 +04:00
|
|
|
// if not using debugger, then we can take control of SIGINT.
|
|
|
|
// If using debugger, it needs control of this.
|
|
|
|
#if BX_DEBUGGER==0
|
|
|
|
signal(SIGINT, bx_signal_handler);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_SHOW_IPS
|
|
|
|
#ifndef __MINGW32__
|
|
|
|
signal(SIGALRM, bx_signal_handler);
|
|
|
|
#endif
|
|
|
|
alarm( 1 );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-06-10 00:01:12 +04:00
|
|
|
bx_init_bx_dbg (void)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
bx_dbg.floppy = 0;
|
|
|
|
bx_dbg.keyboard = 0;
|
|
|
|
bx_dbg.video = 0;
|
|
|
|
bx_dbg.disk = 0;
|
|
|
|
bx_dbg.pit = 0;
|
|
|
|
bx_dbg.pic = 0;
|
|
|
|
bx_dbg.bios = 0;
|
|
|
|
bx_dbg.cmos = 0;
|
|
|
|
bx_dbg.a20 = 0;
|
|
|
|
bx_dbg.interrupts = 0;
|
|
|
|
bx_dbg.exceptions = 0;
|
|
|
|
bx_dbg.unsupported = 0;
|
|
|
|
bx_dbg.temp = 0;
|
|
|
|
bx_dbg.reset = 0;
|
|
|
|
bx_dbg.mouse = 0;
|
|
|
|
bx_dbg.io = 0;
|
|
|
|
bx_dbg.debugger = 0;
|
|
|
|
bx_dbg.xms = 0;
|
|
|
|
bx_dbg.v8086 = 0;
|
|
|
|
bx_dbg.paging = 0;
|
|
|
|
bx_dbg.creg = 0;
|
|
|
|
bx_dbg.dreg = 0;
|
|
|
|
bx_dbg.dma = 0;
|
|
|
|
bx_dbg.unsupported_io = 0;
|
|
|
|
bx_dbg.record_io = 0;
|
|
|
|
bx_dbg.serial = 0;
|
|
|
|
bx_dbg.cdrom = 0;
|
2001-06-10 00:01:12 +04:00
|
|
|
#ifdef MAGIC_BREAKPOINT
|
|
|
|
bx_dbg.magic_break_enabled = 0;
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_atexit(void)
|
|
|
|
{
|
|
|
|
static Boolean been_here = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#if BX_PROVIDE_DEVICE_MODELS==1
|
|
|
|
if (been_here == 0) {
|
|
|
|
bx_pc_system.exit();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_DEBUGGER == 0
|
2001-05-23 12:16:07 +04:00
|
|
|
for (int cpu=0; cpu<BX_SMP_PROCESSORS; cpu++)
|
|
|
|
if (BX_CPU(cpu)) BX_CPU(cpu)->atexit();
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_PCI_SUPPORT
|
|
|
|
if (bx_options.i440FXSupport) {
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
bx_devices.pci->print_i440fx_state();
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (BX_PROVIDE_CPU_MEMORY==1) && (BX_EMULATE_HGA_DUMPS>0)
|
|
|
|
void
|
|
|
|
bx_emulate_hga_dumps_timer(void)
|
|
|
|
{
|
|
|
|
void bx_hga_set_video_memory(Bit8u *ptr);
|
|
|
|
|
|
|
|
bx_hga_set_video_memory(&bx_phy_memory[0xb0000]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_PROVIDE_MAIN
|
2001-06-10 00:01:12 +04:00
|
|
|
|
|
|
|
char *
|
|
|
|
bx_find_bochsrc ()
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
2001-06-12 00:39:05 +04:00
|
|
|
FILE *fd = NULL;
|
2001-06-10 00:01:12 +04:00
|
|
|
char rcfile[512];
|
2001-05-22 22:47:30 +04:00
|
|
|
Bit32u retry = 0, found = 0;
|
|
|
|
// try several possibilities for the bochsrc before giving up
|
|
|
|
while (!found) {
|
2001-06-10 00:01:12 +04:00
|
|
|
rcfile[0] = 0;
|
2001-05-22 22:47:30 +04:00
|
|
|
switch (retry++) {
|
2001-06-10 00:01:12 +04:00
|
|
|
case 0: strcpy (rcfile, ".bochsrc"); break;
|
|
|
|
case 1: strcpy (rcfile, "bochsrc"); break;
|
|
|
|
case 2: strcpy (rcfile, "bochsrc.txt"); break;
|
2001-05-22 22:47:30 +04:00
|
|
|
case 3:
|
2001-04-10 05:04:59 +04:00
|
|
|
#if (!defined(WIN32) && !defined(macintosh))
|
2001-05-22 22:47:30 +04:00
|
|
|
// only try this on unix
|
|
|
|
{
|
|
|
|
char *ptr = getenv("HOME");
|
2001-06-10 00:01:12 +04:00
|
|
|
if (ptr) sprintf (rcfile, "%s/.bochsrc", ptr);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-05-22 22:47:30 +04:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
2001-06-10 00:01:12 +04:00
|
|
|
return NULL;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-06-10 00:01:12 +04:00
|
|
|
if (rcfile[0]) {
|
|
|
|
BX_DEBUG (("looking for configuration in %s", rcfile));
|
|
|
|
fd = fopen(rcfile, "r");
|
2001-05-22 22:47:30 +04:00
|
|
|
if (fd) found = 1;
|
|
|
|
}
|
|
|
|
}
|
2001-06-10 00:01:12 +04:00
|
|
|
assert (fd != NULL && rcfile[0] != 0);
|
|
|
|
fclose (fd);
|
|
|
|
return strdup (rcfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
parse_bochsrc(char *rcfile)
|
|
|
|
{
|
|
|
|
FILE *fd = NULL;
|
|
|
|
char *ret;
|
|
|
|
char line[512];
|
|
|
|
|
|
|
|
// try several possibilities for the bochsrc before giving up
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
fd = fopen (rcfile, "r");
|
|
|
|
if (!fd) return -1;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
do {
|
|
|
|
ret = fgets(line, sizeof(line)-1, fd);
|
|
|
|
line[sizeof(line) - 1] = '\0';
|
2001-05-23 19:00:10 +04:00
|
|
|
int len = strlen(line);
|
|
|
|
if (len>0)
|
|
|
|
line[len-1] = '\0';
|
2001-04-10 05:04:59 +04:00
|
|
|
if ((ret != NULL) && strlen(line)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
parse_line_unformatted(rcfile, line);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
} while (!feof(fd));
|
2001-06-12 00:39:05 +04:00
|
|
|
return 0;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-10 00:01:12 +04:00
|
|
|
parse_line_unformatted(char *context, char *line)
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
char *ptr;
|
|
|
|
unsigned i, string_i;
|
|
|
|
char string[512];
|
|
|
|
char *params[40];
|
|
|
|
int num_params;
|
|
|
|
Boolean inquotes = 0;
|
|
|
|
|
|
|
|
if (line == NULL) return;
|
|
|
|
|
|
|
|
// if passed nothing but whitespace, just return
|
|
|
|
for (i=0; i<strlen(line); i++) {
|
|
|
|
if (!isspace(line[i])) break;
|
|
|
|
}
|
|
|
|
if (i>=strlen(line))
|
|
|
|
return;
|
|
|
|
|
|
|
|
num_params = 0;
|
|
|
|
|
|
|
|
ptr = strtok(line, ":");
|
|
|
|
while (ptr) {
|
|
|
|
string_i = 0;
|
|
|
|
for (i=0; i<strlen(ptr); i++) {
|
|
|
|
if (ptr[i] == '"')
|
|
|
|
inquotes = !inquotes;
|
|
|
|
else
|
|
|
|
if (!isspace(ptr[i]) || inquotes) {
|
|
|
|
string[string_i++] = ptr[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string[string_i] = '\0';
|
|
|
|
strcpy(ptr, string);
|
|
|
|
params[num_params++] = ptr;
|
|
|
|
ptr = strtok(NULL, ",");
|
|
|
|
}
|
2001-06-10 00:01:12 +04:00
|
|
|
parse_line_formatted(context, num_params, ¶ms[0]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-06-10 00:01:12 +04:00
|
|
|
parse_line_formatted(char *context, int num_params, char *params[])
|
2001-04-10 05:04:59 +04:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (num_params < 1) return;
|
|
|
|
|
|
|
|
if (params[0][0] == '#') return; /* comment */
|
|
|
|
else if (!strcmp(params[0], "floppya")) {
|
|
|
|
for (i=1; i<num_params; i++) {
|
2001-05-08 21:45:44 +04:00
|
|
|
if (!strncmp(params[i], "2_88=", 5)) {
|
|
|
|
strcpy(bx_options.floppya.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppya.type = BX_FLOPPY_2_88;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "1_44=", 5)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
strcpy(bx_options.floppya.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppya.type = BX_FLOPPY_1_44;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "1_2=", 4)) {
|
|
|
|
strcpy(bx_options.floppya.path, ¶ms[i][4]);
|
|
|
|
bx_options.floppya.type = BX_FLOPPY_1_2;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "720k=", 5)) {
|
|
|
|
strcpy(bx_options.floppya.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppya.type = BX_FLOPPY_720K;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "status=ejected", 14)) {
|
|
|
|
bx_options.floppya.initial_status = BX_EJECTED;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "status=inserted", 15)) {
|
|
|
|
bx_options.floppya.initial_status = BX_INSERTED;
|
|
|
|
}
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: floppya attribute '%s' not understood.", context,
|
2001-05-23 19:13:05 +04:00
|
|
|
params[i]));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "floppyb")) {
|
|
|
|
for (i=1; i<num_params; i++) {
|
2001-05-08 21:45:44 +04:00
|
|
|
if (!strncmp(params[i], "2_88=", 5)) {
|
|
|
|
strcpy(bx_options.floppyb.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppyb.type = BX_FLOPPY_2_88;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "1_44=", 5)) {
|
2001-04-10 05:04:59 +04:00
|
|
|
strcpy(bx_options.floppyb.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppyb.type = BX_FLOPPY_1_44;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "1_2=", 4)) {
|
|
|
|
strcpy(bx_options.floppyb.path, ¶ms[i][4]);
|
|
|
|
bx_options.floppyb.type = BX_FLOPPY_1_2;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "720k=", 5)) {
|
|
|
|
strcpy(bx_options.floppyb.path, ¶ms[i][5]);
|
|
|
|
bx_options.floppyb.type = BX_FLOPPY_720K;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "status=ejected", 14)) {
|
|
|
|
bx_options.floppyb.initial_status = BX_EJECTED;
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "status=inserted", 15)) {
|
|
|
|
bx_options.floppyb.initial_status = BX_INSERTED;
|
|
|
|
}
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: floppyb attribute '%s' not understood.", context,
|
2001-05-23 19:13:05 +04:00
|
|
|
params[i]));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "diskc")) {
|
|
|
|
if (num_params != 5) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: diskc directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "file=", 5) ||
|
|
|
|
strncmp(params[2], "cyl=", 4) ||
|
|
|
|
strncmp(params[3], "heads=", 6) ||
|
|
|
|
strncmp(params[4], "spt=", 4)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: diskc directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
strcpy(bx_options.diskc.path, ¶ms[1][5]);
|
|
|
|
bx_options.diskc.cylinders = atol( ¶ms[2][4] );
|
|
|
|
bx_options.diskc.heads = atol( ¶ms[3][6] );
|
|
|
|
bx_options.diskc.spt = atol( ¶ms[4][4] );
|
|
|
|
bx_options.diskc.present = 1;
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "diskd")) {
|
|
|
|
if (num_params != 5) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: diskd directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "file=", 5) ||
|
|
|
|
strncmp(params[2], "cyl=", 4) ||
|
|
|
|
strncmp(params[3], "heads=", 6) ||
|
|
|
|
strncmp(params[4], "spt=", 4)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: diskd directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
strcpy(bx_options.diskd.path, ¶ms[1][5]);
|
|
|
|
bx_options.diskd.cylinders = atol( ¶ms[2][4] );
|
|
|
|
bx_options.diskd.heads = atol( ¶ms[3][6] );
|
|
|
|
bx_options.diskd.spt = atol( ¶ms[4][4] );
|
|
|
|
bx_options.diskd.present = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "cdromd")) {
|
|
|
|
if (num_params != 3) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: cdromd directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "dev=", 4) || strncmp(params[2], "status=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: cdromd directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
strcpy(bx_options.cdromd.dev, ¶ms[1][4]);
|
|
|
|
if (!strcmp(params[2], "status=inserted"))
|
|
|
|
bx_options.cdromd.inserted = 1;
|
|
|
|
else if (!strcmp(params[2], "status=ejected"))
|
|
|
|
bx_options.cdromd.inserted = 0;
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: cdromd directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.cdromd.present = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "boot")) {
|
|
|
|
if (!strcmp(params[1], "a") ||
|
|
|
|
!strcmp(params[1], "c")) {
|
|
|
|
strcpy(bx_options.bootdrive, params[1]);
|
|
|
|
}
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: boot directive with unknown boot device '%s'. use 'a' or 'c'.", context, params[1]));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "log")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: log directive has wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-06-11 10:35:18 +04:00
|
|
|
strcpy(bx_options.log.filename, params[1]);
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp(params[0], "panic")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: panic directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "action=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: panic directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
char *action = 7 + params[1];
|
2001-05-23 06:37:52 +04:00
|
|
|
if (!strcmp(action, "fatal"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_FATAL;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "report"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_REPORT;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "ignore"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_IGNORE;
|
2001-06-11 18:03:35 +04:00
|
|
|
else if (!strcmp (action, "ask"))
|
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_ASK;
|
2001-05-23 00:01:40 +04:00
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: panic directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "error")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: error directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "action=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: error directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
char *action = 7 + params[1];
|
2001-05-23 06:37:52 +04:00
|
|
|
if (!strcmp(action, "fatal"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_ERROR] = ACT_FATAL;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "report"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_ERROR] = ACT_REPORT;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "ignore"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_ERROR] = ACT_IGNORE;
|
2001-06-11 18:03:35 +04:00
|
|
|
else if (!strcmp (action, "ask"))
|
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_ASK;
|
2001-05-23 00:01:40 +04:00
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: error directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "info")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: info directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "action=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: info directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
char *action = 7 + params[1];
|
2001-05-23 06:37:52 +04:00
|
|
|
if (!strcmp(action, "fatal"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_INFO] = ACT_FATAL;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "report"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_INFO] = ACT_REPORT;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "ignore"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_INFO] = ACT_IGNORE;
|
2001-06-11 18:03:35 +04:00
|
|
|
else if (!strcmp (action, "ask"))
|
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_ASK;
|
2001-05-23 00:01:40 +04:00
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: info directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "debug")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: debug directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "action=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: debug directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
char *action = 7 + params[1];
|
2001-05-23 06:37:52 +04:00
|
|
|
if (!strcmp(action, "fatal"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_DEBUG] = ACT_FATAL;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "report"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_DEBUG] = ACT_REPORT;
|
2001-05-23 00:01:40 +04:00
|
|
|
else if (!strcmp (action, "ignore"))
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.log.actions[LOGLEV_DEBUG] = ACT_IGNORE;
|
2001-06-11 18:03:35 +04:00
|
|
|
else if (!strcmp (action, "ask"))
|
|
|
|
bx_options.log.actions[LOGLEV_PANIC] = ACT_ASK;
|
2001-05-23 00:01:40 +04:00
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: debug directive malformed.", context));
|
2001-05-23 00:01:40 +04:00
|
|
|
}
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
else if (!strcmp(params[0], "romimage")) {
|
|
|
|
if (num_params != 3) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: romimage directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "file=", 5)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: romimage directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[2], "address=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: romimage directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.rom.path = strdup(¶ms[1][5]);
|
|
|
|
if ( (params[2][8] == '0') && (params[2][9] == 'x') )
|
|
|
|
bx_options.rom.address = strtoul(¶ms[2][8], NULL, 16);
|
|
|
|
else
|
|
|
|
bx_options.rom.address = strtoul(¶ms[2][8], NULL, 10);
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "vgaromimage")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: vgaromimage directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.vgarom.path = strdup(params[1]);
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "vga_update_interval")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: vga_update_interval directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.vga_update_interval = atol(params[1]);
|
|
|
|
if (bx_options.vga_update_interval < 50000) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: vga_update_interval not big enough!", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "keyboard_serial_delay")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: keyboard_serial_delay directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.keyboard_serial_delay = atol(params[1]);
|
|
|
|
if (bx_options.keyboard_serial_delay < 5) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: keyboard_serial_delay not big enough!", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "megs")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: megs directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.memory.megs = atol(params[1]);
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "floppy_command_delay")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: floppy_command_delay directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.floppy_command_delay = atol(params[1]);
|
|
|
|
if (bx_options.floppy_command_delay < 100) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: floppy_command_delay not big enough!", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "ips")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ips directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.ips = atol(params[1]);
|
|
|
|
if (bx_options.ips < 200000) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_INFO(("%s: WARNING: ips is AWFULLY low!", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "mouse")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: mouse directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "enabled=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: mouse directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (params[1][8] == '0')
|
|
|
|
bx_options.mouse_enabled = 0;
|
|
|
|
else if (params[1][8] == '1')
|
|
|
|
bx_options.mouse_enabled = 1;
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: mouse directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "private_colormap")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: private_colormap directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "enabled=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: private_colormap directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (params[1][8] == '0')
|
|
|
|
bx_options.private_colormap = 0;
|
|
|
|
else if (params[1][8] == '1')
|
|
|
|
bx_options.private_colormap = 1;
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: private_colormap directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "sb16")) {
|
|
|
|
for (i=1; i<num_params; i++) {
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_options.sb16.present = 1;
|
2001-04-10 05:04:59 +04:00
|
|
|
if (!strncmp(params[i], "midi=", 5)) {
|
|
|
|
bx_options.sb16.midifile = strdup(¶ms[i][5]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "midimode=", 9)) {
|
|
|
|
bx_options.sb16.midimode = atol(¶ms[i][9]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "wave=", 5)) {
|
|
|
|
bx_options.sb16.wavefile = strdup(¶ms[i][5]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "wavemode=", 9)) {
|
|
|
|
bx_options.sb16.wavemode = atol(¶ms[i][9]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "log=", 4)) {
|
|
|
|
bx_options.sb16.logfile = strdup(¶ms[i][4]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "loglevel=", 9)) {
|
|
|
|
bx_options.sb16.loglevel = atol(¶ms[i][9]);
|
|
|
|
}
|
|
|
|
else if (!strncmp(params[i], "dmatimer=", 9)) {
|
|
|
|
bx_options.sb16.dmatimer = atol(¶ms[i][9]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "i440fxsupport")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: i440FXSupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "enabled=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: i440FXSupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (params[1][8] == '0')
|
|
|
|
bx_options.i440FXSupport = 0;
|
|
|
|
else if (params[1][8] == '1')
|
|
|
|
bx_options.i440FXSupport = 1;
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: i440FXSupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "newharddrivesupport")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: newharddrivesupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "enabled=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: newharddrivesupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (params[1][8] == '0')
|
|
|
|
bx_options.newHardDriveSupport = 0;
|
|
|
|
else if (params[1][8] == '1')
|
|
|
|
bx_options.newHardDriveSupport = 1;
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: newharddrivesupport directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "cmosimage")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: cmosimage directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.cmos.path = strdup(params[1]);
|
|
|
|
bx_options.cmos.cmosImage = 1; // CMOS Image is true
|
|
|
|
}
|
|
|
|
else if (!strcmp(params[0], "time0")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: time0 directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.cmos.time0 = atoi(params[1]);
|
|
|
|
}
|
|
|
|
#ifdef MAGIC_BREAKPOINT
|
|
|
|
else if (!strcmp(params[0], "magic_break")) {
|
|
|
|
if (num_params != 2) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: magic_break directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "enabled=", 8)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: magic_break directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (params[1][8] == '0') {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("Ignoring magic break points"));
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_dbg.magic_break_enabled = 0;
|
|
|
|
}
|
|
|
|
else if (params[1][8] == '1') {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("Stopping on magic break points"));
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_dbg.magic_break_enabled = 1;
|
|
|
|
}
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: magic_break directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else if (!strcmp(params[0], "ne2k")) {
|
|
|
|
int tmp[6];
|
|
|
|
bx_options.ne2k.valid = 0;
|
|
|
|
if ((num_params < 4) || (num_params > 6)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.ne2k.ethmod = "null";
|
|
|
|
if (strncmp(params[1], "ioaddr=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[2], "irq=", 4)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[3], "mac=", 4)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.ne2k.ioaddr = strtoul(¶ms[1][7], NULL, 16);
|
|
|
|
bx_options.ne2k.irq = atol(¶ms[2][4]);
|
|
|
|
i = sscanf(¶ms[3][4], "%x:%x:%x:%x:%x:%x",
|
|
|
|
&tmp[0],&tmp[1],&tmp[2],&tmp[3],&tmp[4],&tmp[5]);
|
|
|
|
if (i != 6) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k mac address malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
for (i=0;i<6;i++)
|
|
|
|
bx_options.ne2k.macaddr[i] = tmp[i];
|
|
|
|
if (num_params > 4) {
|
|
|
|
if (strncmp(params[4], "ethmod=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.ne2k.ethmod = strdup(¶ms[4][7]);
|
|
|
|
if (num_params == 6) {
|
|
|
|
if (strncmp(params[5], "ethdev=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: ne2k directive malformed.", context));
|
2001-06-11 10:35:18 +04:00
|
|
|
return;
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.ne2k.ethdev = strdup(¶ms[5][7]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bx_options.ne2k.valid = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(params[0], "load32bitOSImage")) {
|
|
|
|
if ( (num_params!=4) && (num_params!=5) ) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage directive: wrong # args.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[1], "os=", 3)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage: directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (!strcmp(¶ms[1][3], "nullkernel")) {
|
|
|
|
bx_options.load32bitOSImage.whichOS = Load32bitOSNullKernel;
|
|
|
|
}
|
|
|
|
else if (!strcmp(¶ms[1][3], "linux")) {
|
|
|
|
bx_options.load32bitOSImage.whichOS = Load32bitOSLinux;
|
|
|
|
}
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage: unsupported OS.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[2], "path=", 5)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage: directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
if (strncmp(params[3], "iolog=", 6)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage: directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.load32bitOSImage.path = strdup(¶ms[2][5]);
|
|
|
|
bx_options.load32bitOSImage.iolog = strdup(¶ms[3][6]);
|
|
|
|
if (num_params == 5) {
|
|
|
|
if (strncmp(params[4], "initrd=", 7)) {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(("%s: load32bitOSImage: directive malformed.", context));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
|
|
|
bx_options.load32bitOSImage.initrd = strdup(¶ms[4][7]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
2001-06-10 00:01:12 +04:00
|
|
|
BX_PANIC(( "%s: directive '%s' not understood", context, params[0]));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-05-04 00:59:38 +04:00
|
|
|
|
|
|
|
if (bx_options.diskd.present && bx_options.cdromd.present)
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
BX_PANIC(("At present, using both diskd and cdromd at once is not supported."));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2001-06-11 10:35:18 +04:00
|
|
|
|
|
|
|
static char *fdtypes[] = {
|
|
|
|
"none", "1_2", "1_44", "2_88", "720k"
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_floppy_options (FILE *fp, int drive, bx_floppy_options *opt)
|
|
|
|
{
|
|
|
|
BX_ASSERT (drive==0 || drive==1);
|
|
|
|
if (opt->type == BX_FLOPPY_NONE) {
|
|
|
|
fprintf (fp, "# no floppy%c\n", (char)'a'+drive);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
BX_ASSERT (opt->type > BX_FLOPPY_NONE && opt->type <= BX_FLOPPY_LAST);
|
|
|
|
fprintf (fp, "floppy%c: %s=%s, status=%s\n",
|
|
|
|
(char)'a'+drive,
|
|
|
|
fdtypes[opt->type - BX_FLOPPY_NONE],
|
|
|
|
opt->path,
|
|
|
|
opt->initial_status==BX_EJECTED ? "ejected" : "inserted");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_disk_options (FILE *fp, int drive, bx_disk_options *opt)
|
|
|
|
{
|
|
|
|
if (!opt->present) {
|
|
|
|
fprintf (fp, "# no disk%c\n", (char)'c'+drive);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fprintf (fp, "disk%c: file=\"%s\", cyl=%d, heads=%d, spt=%d\n",
|
|
|
|
(char)'c'+drive,
|
|
|
|
opt->path,
|
|
|
|
opt->cylinders,
|
|
|
|
opt->heads,
|
|
|
|
opt->spt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_cdrom_options (FILE *fp, int drive, bx_cdrom_options *opt)
|
|
|
|
{
|
|
|
|
BX_ASSERT (drive == 0);
|
|
|
|
if (!opt->present) {
|
|
|
|
fprintf (fp, "# no cdromd\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fprintf (fp, "cdromd: dev=%s, status=%s\n",
|
|
|
|
opt->dev,
|
|
|
|
opt->inserted ? "inserted" : "ejected");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_sb16_options (FILE *fp, bx_sb16_options *opt)
|
|
|
|
{
|
|
|
|
if (!opt->present) {
|
|
|
|
fprintf (fp, "# no sb16\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fprintf (fp, "sb16: midimode=%d, midi=%s, wavemode=%d, wave=%s, loglevel=%d, log=%s, dmatimer=%d\n", opt->midimode, opt->midifile, opt->wavemode, opt->wavefile, opt->loglevel, opt->logfile, opt->dmatimer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_ne2k_options (FILE *fp, bx_ne2k_options *opt)
|
|
|
|
{
|
|
|
|
if (!opt->valid) {
|
|
|
|
fprintf (fp, "# no ne2k\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
fprintf (fp, "ne2k: ioaddr=0x%x, irq=%d, mac=%02x:%02x:%02x:%02x:%02x:%02x, ethmod=%s, ethdev=%s\n",
|
|
|
|
opt->ioaddr,
|
|
|
|
opt->irq,
|
|
|
|
opt->macaddr[0],
|
|
|
|
opt->macaddr[1],
|
|
|
|
opt->macaddr[2],
|
|
|
|
opt->macaddr[3],
|
|
|
|
opt->macaddr[4],
|
|
|
|
opt->macaddr[5],
|
|
|
|
opt->ethmod,
|
|
|
|
opt->ethdev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_loader_options (FILE *fp, bx_load32bitOSImage_t *opt)
|
|
|
|
{
|
|
|
|
if (opt->whichOS == 0) {
|
|
|
|
fprintf (fp, "# no loader\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
BX_ASSERT(opt->whichOS == Load32bitOSLinux || opt->whichOS == Load32bitOSNullKernel);
|
|
|
|
fprintf (fp, "load32bitOSImage: os=%s, path=%s, iolog=%s, initrd=%s\n",
|
|
|
|
(opt->whichOS == Load32bitOSLinux) ? "linux" : "nullkernel",
|
|
|
|
opt->path,
|
|
|
|
opt->iolog,
|
|
|
|
opt->initrd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bx_write_log_options (FILE *fp, bx_log_options *opt)
|
|
|
|
{
|
|
|
|
fprintf (fp, "log: %s\n", opt->filename);
|
|
|
|
// no syntax to describe all the possible action settings for every
|
|
|
|
// device. Instead, take a vote and record the most popular action
|
|
|
|
// for each level of event.
|
|
|
|
int action_tally[N_ACT];
|
|
|
|
int most_popular_action[N_LOGLEV];
|
2001-06-12 00:39:05 +04:00
|
|
|
int i,lev;
|
2001-06-11 10:35:18 +04:00
|
|
|
for (lev = 0; lev < N_LOGLEV; lev++) {
|
|
|
|
// clear tally
|
|
|
|
for (i=0; i<N_ACT; i++)
|
|
|
|
action_tally[i] = 0;
|
|
|
|
// count how many devices use each action
|
|
|
|
for (i=0; i<io->get_n_logfns (); i++) {
|
|
|
|
logfunc_t *fn = io->get_logfn (i);
|
|
|
|
int action = fn->getonoff(lev);
|
|
|
|
BX_ASSERT (action >= 0 && action < N_ACT);
|
|
|
|
action_tally[action]++;
|
|
|
|
}
|
|
|
|
// count the votes
|
|
|
|
int best = 0, best_votes = action_tally[0];
|
|
|
|
for (i=1; i<N_ACT; i++) {
|
|
|
|
if (action_tally[i] > best_votes) {
|
|
|
|
best = i;
|
|
|
|
best_votes = action_tally[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
most_popular_action[lev] = best;
|
|
|
|
}
|
|
|
|
fprintf (fp, "panic: action=%s\n",
|
|
|
|
io->getaction(most_popular_action[LOGLEV_PANIC]));
|
|
|
|
fprintf (fp, "error: action=%s\n",
|
|
|
|
io->getaction(most_popular_action[LOGLEV_ERROR]));
|
|
|
|
fprintf (fp, "info: action=%s\n",
|
|
|
|
io->getaction(most_popular_action[LOGLEV_INFO]));
|
|
|
|
fprintf (fp, "debug: action=%s\n",
|
|
|
|
io->getaction(most_popular_action[LOGLEV_DEBUG]));
|
2001-06-12 00:39:05 +04:00
|
|
|
return 0;
|
2001-06-11 10:35:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// return values:
|
|
|
|
// 0: written ok
|
|
|
|
// -1: failed
|
|
|
|
// -2: already exists, and overwrite was off
|
|
|
|
int
|
|
|
|
bx_write_configuration (char *rc, int overwrite)
|
|
|
|
{
|
|
|
|
BX_INFO (("write configuration to %s\n", rc));
|
|
|
|
// check if it exists. If so, only proceed if overwrite is set.
|
|
|
|
FILE *fp = fopen (rc, "r");
|
|
|
|
if (fp != NULL) {
|
|
|
|
fclose (fp);
|
|
|
|
if (!overwrite) return -2;
|
|
|
|
}
|
|
|
|
fp = fopen (rc, "w");
|
|
|
|
if (fp == NULL) return -1;
|
|
|
|
// finally it's open and we can start writing.
|
|
|
|
fprintf (fp, "# configuration file generated by Bochs\n");
|
|
|
|
// it would be nice to put this type of function as methods on
|
|
|
|
// the structs like bx_floppy_options::print or something.
|
|
|
|
bx_write_floppy_options (fp, 0, &bx_options.floppya);
|
|
|
|
bx_write_floppy_options (fp, 1, &bx_options.floppyb);
|
|
|
|
bx_write_disk_options (fp, 0, &bx_options.diskc);
|
|
|
|
bx_write_disk_options (fp, 1, &bx_options.diskd);
|
|
|
|
bx_write_cdrom_options (fp, 0, &bx_options.cdromd);
|
|
|
|
if (bx_options.rom.path)
|
2001-06-12 00:39:05 +04:00
|
|
|
fprintf (fp, "romimage: file=%s, address=0x%05x\n", bx_options.rom.path, (unsigned int)bx_options.rom.address);
|
2001-06-11 10:35:18 +04:00
|
|
|
else
|
|
|
|
fprintf (fp, "# no romimage\n");
|
|
|
|
if (bx_options.vgarom.path)
|
|
|
|
fprintf (fp, "vgaromimage: %s\n", bx_options.vgarom.path);
|
|
|
|
else
|
|
|
|
fprintf (fp, "# no vgaromimage\n");
|
|
|
|
fprintf (fp, "megs: %d\n", bx_options.memory.megs);
|
|
|
|
bx_write_sb16_options (fp, &bx_options.sb16);
|
|
|
|
fprintf (fp, "boot: %s\n", bx_options.bootdrive);
|
2001-06-12 00:39:05 +04:00
|
|
|
fprintf (fp, "vga_update_interval: %lu\n", bx_options.vga_update_interval);
|
|
|
|
fprintf (fp, "keyboard_serial_delay: %lu\n", bx_options.keyboard_serial_delay);
|
|
|
|
fprintf (fp, "floppy_command_delay: %lu\n", bx_options.floppy_command_delay);
|
|
|
|
fprintf (fp, "ips: %lu\n", bx_options.ips);
|
2001-06-11 10:35:18 +04:00
|
|
|
fprintf (fp, "mouse: enabled=%d\n", bx_options.mouse_enabled);
|
|
|
|
fprintf (fp, "private_colormap: enabled=%d\n", bx_options.private_colormap);
|
|
|
|
fprintf (fp, "i440fxsupport: enabled=%d\n", bx_options.i440FXSupport);
|
|
|
|
fprintf (fp, "time0: %u\n", bx_options.cmos.time0);
|
|
|
|
bx_write_ne2k_options (fp, &bx_options.ne2k);
|
|
|
|
fprintf (fp, "newharddrivesupport: enabled=%d\n", bx_options.newHardDriveSupport);
|
|
|
|
bx_write_loader_options (fp, &bx_options.load32bitOSImage);
|
|
|
|
bx_write_log_options (fp, &bx_options.log);
|
|
|
|
fclose (fp);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif // #if BX_PROVIDE_MAIN
|
|
|
|
|
|
|
|
void
|
|
|
|
bx_signal_handler( int signum)
|
|
|
|
{
|
2001-05-09 00:18:05 +04:00
|
|
|
#if BX_GUI_SIGHANDLER
|
|
|
|
// GUI signal handler gets first priority, if the mask says it's wanted
|
|
|
|
if ((1<<signum) & bx_gui.get_sighandler_mask ()) {
|
|
|
|
bx_gui.sighandler (signum);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#if BX_SHOW_IPS
|
|
|
|
extern unsigned long ips_count;
|
|
|
|
|
|
|
|
if (signum == SIGALRM ) {
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_INFO(("ips = %lu", ips_count));
|
2001-04-10 05:04:59 +04:00
|
|
|
ips_count = 0;
|
|
|
|
#ifndef __MINGW32__
|
|
|
|
signal(SIGALRM, bx_signal_handler);
|
|
|
|
alarm( 1 );
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-05-23 12:16:07 +04:00
|
|
|
#if BX_GUI_SIGHANDLER
|
|
|
|
if ((1<<signum) & bx_gui.get_sighandler_mask ()) {
|
|
|
|
bx_gui.sighandler (signum);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2001-05-30 22:56:02 +04:00
|
|
|
BX_PANIC(("SIGNAL %u caught", signum));
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
merge in BRANCH-io-cleanup.
To see the commit logs for this use either cvsweb or
cvs update -r BRANCH-io-cleanup and then 'cvs log' the various files.
In general this provides a generic interface for logging.
logfunctions:: is a class that is inherited by some classes, and also
. allocated as a standalone global called 'genlog'. All logging uses
. one of the ::info(), ::error(), ::ldebug(), ::panic() methods of this
. class through 'BX_INFO(), BX_ERROR(), BX_DEBUG(), BX_PANIC()' macros
. respectively.
.
. An example usage:
. BX_INFO(("Hello, World!\n"));
iofunctions:: is a class that is allocated once by default, and assigned
as the iofunction of each logfunctions instance. It is this class that
maintains the file descriptor and other output related code, at this
point using vfprintf(). At some future point, someone may choose to
write a gui 'console' for bochs to which messages would be redirected
simply by assigning a different iofunction class to the various logfunctions
objects.
More cleanup is coming, but this works for now. If you want to see alot
of debugging output, in main.cc, change onoff[LOGLEV_DEBUG]=0 to =1.
Comments, bugs, flames, to me: todd@fries.net
2001-05-15 18:49:57 +04:00
|
|
|
|