2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2007-12-26 21:39:15 +03:00
|
|
|
// $Id: bochs.h,v 1.219 2007-12-26 18:39:15 sshwarts Exp $
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2002-06-16 19:02:28 +04:00
|
|
|
// Copyright (C) 2002 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
|
|
|
|
|
2001-04-10 05:58:07 +04:00
|
|
|
//
|
|
|
|
// bochs.h is the master header file for all C++ code. It includes all
|
|
|
|
// the system header files needed by bochs, and also includes all the bochs
|
|
|
|
// C++ header files. Because bochs.h and the files that it includes has
|
|
|
|
// structure and class definitions, it cannot be called from C code.
|
|
|
|
//
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#ifndef BX_BOCHS_H
|
|
|
|
# define BX_BOCHS_H 1
|
|
|
|
|
2001-09-27 03:33:14 +04:00
|
|
|
#include "config.h" /* generated by configure script from config.h.in */
|
|
|
|
|
2004-11-22 16:14:54 +03:00
|
|
|
#ifndef __QNXNTO__
|
2001-04-10 05:04:59 +04:00
|
|
|
extern "C" {
|
2004-11-22 16:14:54 +03:00
|
|
|
#endif
|
2002-10-04 01:07:04 +04:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
// In a win32 compile (including cygwin), windows.h is required for several
|
|
|
|
// files in gui and iodev. It is important to include it here in a header
|
|
|
|
// file so that WIN32-specific data types can be used in fields of classes.
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2006-10-31 22:26:34 +03:00
|
|
|
#if defined(__sun__)
|
|
|
|
#undef EAX
|
|
|
|
#undef ECX
|
|
|
|
#undef EDX
|
|
|
|
#undef EBX
|
|
|
|
#undef ESP
|
|
|
|
#undef EBP
|
|
|
|
#undef ESI
|
|
|
|
#undef EDI
|
|
|
|
#undef EIP
|
|
|
|
#undef CS
|
|
|
|
#undef DS
|
|
|
|
#undef ES
|
|
|
|
#undef SS
|
|
|
|
#undef FS
|
|
|
|
#undef GS
|
|
|
|
#endif
|
2001-06-08 00:31:20 +04:00
|
|
|
#include <assert.h>
|
2003-05-03 20:37:18 +04:00
|
|
|
#include <errno.h>
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifndef WIN32
|
|
|
|
# include <unistd.h>
|
|
|
|
#else
|
|
|
|
# include <io.h>
|
|
|
|
#endif
|
|
|
|
#include <time.h>
|
2001-09-26 04:11:23 +04:00
|
|
|
#if BX_WITH_MACOS
|
2001-04-10 05:04:59 +04:00
|
|
|
# include <types.h>
|
|
|
|
# include <stat.h>
|
2002-12-12 18:29:45 +03:00
|
|
|
# include <cstdio>
|
|
|
|
# include <unistd.h>
|
2001-09-26 04:11:23 +04:00
|
|
|
#elif BX_WITH_CARBON
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <sys/param.h> /* for MAXPATHLEN */
|
2007-12-20 21:32:14 +03:00
|
|
|
# include <sys/time.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
# include <utime.h>
|
|
|
|
#else
|
|
|
|
# ifndef WIN32
|
|
|
|
# include <sys/time.h>
|
|
|
|
# endif
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
2003-08-04 20:03:09 +04:00
|
|
|
#include <limits.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifdef macintosh
|
|
|
|
# define SuperDrive "[fd:]"
|
|
|
|
#endif
|
2004-11-22 16:14:54 +03:00
|
|
|
|
|
|
|
#ifndef __QNXNTO__
|
2001-04-10 05:04:59 +04:00
|
|
|
}
|
2004-11-22 16:14:54 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-04-10 05:53:28 +04:00
|
|
|
#include "osdep.h" /* platform dependent includes and defines */
|
2006-09-26 23:16:10 +04:00
|
|
|
#include "bx_debug/debug.h"
|
2001-05-22 22:49:11 +04:00
|
|
|
#include "bxversion.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-06-08 11:20:07 +04:00
|
|
|
#include "gui/siminterface.h"
|
|
|
|
|
2005-07-31 19:35:01 +04:00
|
|
|
// BX_SHARE_PATH should be defined by the makefile. If not, give it
|
|
|
|
// a value of NULL to avoid compile problems.
|
|
|
|
#ifndef BX_SHARE_PATH
|
|
|
|
#define BX_SHARE_PATH NULL
|
|
|
|
#endif
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// prototypes
|
2006-03-12 01:40:32 +03:00
|
|
|
int bx_begin_simulation(int argc, char *argv[]);
|
|
|
|
void bx_stop_simulation();
|
|
|
|
char *bx_find_bochsrc(void);
|
|
|
|
int bx_parse_cmdline(int arg, int argc, char *argv[]);
|
2006-03-13 21:55:53 +03:00
|
|
|
int bx_read_configuration(const char *rcfile);
|
|
|
|
int bx_write_configuration(const char *rcfile, int overwrite);
|
2006-03-12 01:40:32 +03:00
|
|
|
void bx_reset_options(void);
|
2006-01-28 19:16:03 +03:00
|
|
|
Bit32u crc32(const Bit8u *buf, int len);
|
2006-02-17 00:44:17 +03:00
|
|
|
// for param-tree testing only
|
|
|
|
void print_tree(bx_param_c *node, int level = 0);
|
2002-10-25 01:07:56 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// some macros to interface the CPU and memory to external environment
|
|
|
|
// so that these functions can be redirected to the debugger when
|
|
|
|
// needed.
|
|
|
|
//
|
|
|
|
|
2007-09-28 23:52:08 +04:00
|
|
|
#define BXRS_PARAM_SPECIAL(parent, name, maxvalue, save_handler, restore_handler) \
|
|
|
|
{ \
|
2006-05-28 21:07:57 +04:00
|
|
|
bx_param_num_c *param = new bx_param_num_c(parent, #name, "", "", 0, maxvalue, 0); \
|
|
|
|
param->set_base(BASE_HEX); \
|
|
|
|
param->set_sr_handlers(this, save_handler, restore_handler); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BXRS_PARAM_SPECIAL64(parent, name, save_handler, restore_handler) \
|
|
|
|
BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT64U, save_handler, restore_handler)
|
|
|
|
#define BXRS_PARAM_SPECIAL32(parent, name, save_handler, restore_handler) \
|
|
|
|
BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT32U, save_handler, restore_handler)
|
|
|
|
#define BXRS_PARAM_SPECIAL16(parent, name, save_handler, restore_handler) \
|
|
|
|
BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT16U, save_handler, restore_handler)
|
|
|
|
#define BXRS_PARAM_SPECIAL8(parent, name, save_handler, restore_handler) \
|
|
|
|
BXRS_PARAM_SPECIAL(parent, name, BX_MAX_BIT8U, save_handler, restore_handler)
|
|
|
|
|
|
|
|
#define BXRS_HEX_PARAM_SIMPLE(parent, name) \
|
|
|
|
new bx_shadow_num_c(parent, #name, &(name), BASE_HEX)
|
|
|
|
#define BXRS_HEX_PARAM_FIELD(parent, name, field) \
|
|
|
|
new bx_shadow_num_c(parent, #name, &(field), BASE_HEX)
|
|
|
|
|
|
|
|
#define BXRS_DEC_PARAM_SIMPLE(parent, name) \
|
|
|
|
new bx_shadow_num_c(parent, #name, &(name), BASE_DEC)
|
|
|
|
#define BXRS_DEC_PARAM_FIELD(parent, name, field) \
|
|
|
|
new bx_shadow_num_c(parent, #name, &(field), BASE_DEC)
|
|
|
|
|
|
|
|
#define BXRS_PARAM_BOOL(parent, name, field) \
|
|
|
|
new bx_shadow_bool_c(parent, #name, (bx_bool*)(&(field)))
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// =-=-=-=-=-=-=- Normal optimized use -=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
// some pc_systems functions just redirect to the IO devices so optimize
|
|
|
|
// by eliminating call here
|
|
|
|
//
|
|
|
|
// #define BX_INP(addr, len) bx_pc_system.inp(addr, len)
|
|
|
|
// #define BX_OUTP(addr, val, len) bx_pc_system.outp(addr, val, len)
|
|
|
|
#define BX_INP(addr, len) bx_devices.inp(addr, len)
|
|
|
|
#define BX_OUTP(addr, val, len) bx_devices.outp(addr, val, len)
|
|
|
|
#define BX_TICK1() bx_pc_system.tick1()
|
2001-05-23 12:16:07 +04:00
|
|
|
#define BX_TICKN(n) bx_pc_system.tickn(n)
|
2001-04-10 05:04:59 +04:00
|
|
|
#define BX_INTR bx_pc_system.INTR
|
|
|
|
#define BX_SET_INTR(b) bx_pc_system.set_INTR(b)
|
|
|
|
#define BX_CPU_C bx_cpu_c
|
|
|
|
#define BX_MEM_C bx_mem_c
|
2002-06-16 19:02:28 +04:00
|
|
|
#define BX_HRQ (bx_pc_system.HRQ)
|
|
|
|
|
2006-01-18 21:35:38 +03:00
|
|
|
#if BX_SUPPORT_SMP
|
2001-06-05 21:35:08 +04:00
|
|
|
#define BX_CPU(x) (bx_cpu_array[x])
|
2006-01-18 21:35:38 +03:00
|
|
|
#else
|
|
|
|
#define BX_CPU(x) (&bx_cpu)
|
2006-01-15 22:35:39 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BX_MEM(x) (&bx_mem)
|
2001-06-05 21:35:08 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#define BX_SET_ENABLE_A20(enabled) bx_pc_system.set_enable_a20(enabled)
|
|
|
|
#define BX_GET_ENABLE_A20() bx_pc_system.get_enable_a20()
|
|
|
|
|
2004-10-30 01:15:48 +04:00
|
|
|
#if BX_SUPPORT_A20
|
2007-12-26 21:39:15 +03:00
|
|
|
# define A20ADDR(x) ((bx_phy_address)(x) & bx_pc_system.a20_mask)
|
2004-10-30 01:15:48 +04:00
|
|
|
#else
|
2007-12-26 21:39:15 +03:00
|
|
|
# define A20ADDR(x) ((bx_phy_address)(x))
|
2004-10-30 01:15:48 +04:00
|
|
|
#endif
|
|
|
|
|
2007-01-05 16:40:47 +03:00
|
|
|
#if BX_SUPPORT_SMP
|
2007-03-07 00:12:20 +03:00
|
|
|
# define BX_TICK1_IF_SINGLE_PROCESSOR() \
|
|
|
|
if (BX_SMP_PROCESSORS == 1) BX_TICK1()
|
2007-12-09 21:36:05 +03:00
|
|
|
# define BX_TICKN_IF_SINGLE_PROCESSOR() \
|
|
|
|
if (BX_SMP_PROCESSORS == 1) BX_TICKN(n)
|
2007-01-05 16:40:47 +03:00
|
|
|
#else
|
|
|
|
# define BX_TICK1_IF_SINGLE_PROCESSOR() BX_TICK1()
|
2007-12-09 21:36:05 +03:00
|
|
|
# define BX_TICKN_IF_SINGLE_PROCESSOR() BX_TICKN(n)
|
2007-01-05 16:40:47 +03:00
|
|
|
#endif
|
|
|
|
|
2001-05-23 12:16:07 +04:00
|
|
|
// you can't use static member functions on the CPU, if there are going
|
|
|
|
// to be 2 cpus. Check this early on.
|
2006-01-18 21:35:38 +03:00
|
|
|
#if BX_SUPPORT_SMP
|
|
|
|
# if BX_USE_CPU_SMF
|
2001-05-23 12:16:07 +04:00
|
|
|
# error For SMP simulation, BX_USE_CPU_SMF must be 0.
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// Ways for the the external environment to report back information
|
|
|
|
// to the debugger.
|
|
|
|
//
|
|
|
|
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
# define BX_DBG_ASYNC_INTR bx_guard.async.irq
|
|
|
|
# define BX_DBG_ASYNC_DMA bx_guard.async.dma
|
|
|
|
|
|
|
|
# define BX_DBG_DMA_REPORT(addr, len, what, val) \
|
|
|
|
if (bx_guard.report.dma) bx_dbg_dma_report(addr, len, what, val)
|
|
|
|
# define BX_DBG_IAC_REPORT(vector, irq) \
|
|
|
|
if (bx_guard.report.irq) bx_dbg_iac_report(vector, irq)
|
|
|
|
# define BX_DBG_A20_REPORT(val) \
|
|
|
|
if (bx_guard.report.a20) bx_dbg_a20_report(val)
|
2007-10-09 23:49:23 +04:00
|
|
|
# define BX_DBG_IO_REPORT(port, size, op, val) \
|
|
|
|
if (bx_guard.report.io) bx_dbg_io_report(port, size, op, val)
|
2001-04-10 05:04:59 +04:00
|
|
|
# define BX_DBG_UCMEM_REPORT(addr, size, op, val) \
|
|
|
|
if (bx_guard.report.ucmem) bx_dbg_ucmem_report(addr, size, op, val)
|
|
|
|
#else // #if BX_DEBUGGER
|
|
|
|
// debugger not compiled in, use empty stubs
|
|
|
|
# define BX_DBG_ASYNC_INTR 1
|
|
|
|
# define BX_DBG_ASYNC_DMA 1
|
|
|
|
# define BX_DBG_DMA_REPORT(addr, len, what, val)
|
|
|
|
# define BX_DBG_IAC_REPORT(vector, irq)
|
|
|
|
# define BX_DBG_A20_REPORT(val)
|
|
|
|
# define BX_DBG_IO_REPORT(addr, size, op, val)
|
|
|
|
# define BX_DBG_UCMEM_REPORT(addr, size, op, val)
|
|
|
|
#endif // #if BX_DEBUGGER
|
|
|
|
|
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
|
|
|
#define MAGIC_LOGNUM 0x12345678
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
typedef class BOCHSAPI logfunctions {
|
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
|
|
|
char *prefix;
|
|
|
|
int type;
|
2002-07-14 17:23:10 +04:00
|
|
|
// values of onoff: 0=ignore, 1=report, 2=ask, 3=fatal
|
2001-05-23 06:37:52 +04:00
|
|
|
#define ACT_IGNORE 0
|
|
|
|
#define ACT_REPORT 1
|
2002-07-14 17:23:10 +04:00
|
|
|
#define ACT_ASK 2
|
2001-06-11 18:03:35 +04:00
|
|
|
#define ACT_FATAL 3
|
|
|
|
#define N_ACT 4
|
2001-06-11 10:35:18 +04:00
|
|
|
int onoff[N_LOGLEV];
|
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
|
|
|
class iofunctions *logio;
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
// default log actions for all devices, declared and initialized
|
|
|
|
// in logio.cc.
|
2002-11-15 21:31:55 +03:00
|
|
|
BOCHSAPI_CYGONLY static int default_onoff[N_LOGLEV];
|
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
|
|
|
public:
|
|
|
|
logfunctions(void);
|
|
|
|
logfunctions(class iofunctions *);
|
|
|
|
~logfunctions(void);
|
|
|
|
|
2002-10-06 18:16:23 +04:00
|
|
|
void info(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
|
|
|
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
|
|
|
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
2002-12-17 06:36:53 +03:00
|
|
|
void pass(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
2002-10-06 18:16:23 +04:00
|
|
|
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
2002-12-17 06:36:53 +03:00
|
|
|
void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
|
2003-02-26 05:41:30 +03:00
|
|
|
#if BX_EXTERNAL_DEBUGGER
|
|
|
|
virtual void ask (int level, const char *prefix, const char *fmt, va_list ap);
|
|
|
|
#else
|
2001-11-12 21:28:07 +03:00
|
|
|
void ask (int level, const char *prefix, const char *fmt, va_list ap);
|
2003-02-26 05:41:30 +03:00
|
|
|
#endif
|
2007-10-25 03:29:40 +04:00
|
|
|
void put(const char *);
|
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 settype(int);
|
|
|
|
void setio(class iofunctions *);
|
2001-06-08 00:31:20 +04:00
|
|
|
void setonoff(int loglev, int value) {
|
2001-06-11 10:35:18 +04:00
|
|
|
assert (loglev >= 0 && loglev < N_LOGLEV);
|
2001-06-08 00:31:20 +04:00
|
|
|
onoff[loglev] = value;
|
|
|
|
}
|
|
|
|
char *getprefix () { return prefix; }
|
|
|
|
int getonoff(int level) {
|
2001-06-11 10:35:18 +04:00
|
|
|
assert (level>=0 && level<N_LOGLEV);
|
2001-06-08 00:31:20 +04:00
|
|
|
return onoff[level];
|
|
|
|
}
|
- How to handle default log options has been somewhat confused for a long
time, so I've tried to improve it. Now the logfunctions class has a
static field default_onoff[] which represents the default actions for
each kind of log message. Default_onoff[] is initialized with static
data so it should be valid by the time it's used. This can be reached by
static accesors logfunctions::set_default_action and
logfunctions::get_default_action. It seemed appropriate to put the defaults
inside the logfunctions class, rather than in bx_options or siminterface.
However, to make them accessible to the config interface, I added similar
methods in siminterface that map to the accessors in logfunctions.
- logio.cc had two different definitions of LOG_THIS for different halves
of the file, which was ugly and confusing. (LOG_THIS is needed for BX_INFO,
BX_DEBUG, etc.) I removed the first definition and fixed the minor compile
problems that ensued. In the initializers for iofunctions, everything
is complicated because of the unpredictable order that constructors get
called. They must use this->log to print things, because genlog hasn't
been initialized yet.
- now if SIM->set_log_action(int mod, int level, int action) is called
with mod<0, it sets the action for all modules/devices instead of just one.
- modified: bochs.h logio.cc main.cc gui/siminterface.cc gui/siminterface.h
2002-09-20 21:56:22 +04:00
|
|
|
static void set_default_action (int loglev, int action) {
|
|
|
|
assert (loglev >= 0 && loglev < N_LOGLEV);
|
|
|
|
assert (action >= 0 && action < N_ACT);
|
|
|
|
default_onoff[loglev] = action;
|
|
|
|
}
|
|
|
|
static int get_default_action (int loglev) {
|
|
|
|
assert (loglev >= 0 && loglev < N_LOGLEV);
|
|
|
|
return default_onoff[loglev];
|
|
|
|
}
|
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
|
|
|
} logfunc_t;
|
|
|
|
|
2002-06-26 18:42:35 +04:00
|
|
|
#define BX_LOGPREFIX_SIZE 51
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
enum {
|
|
|
|
IOLOG=0, FDLOG, GENLOG, CMOSLOG, CDLOG, DMALOG, ETHLOG, G2HLOG, HDLOG, KBDLOG,
|
|
|
|
NE2KLOG, PARLOG, PCILOG, PICLOG, PITLOG, SB16LOG, SERLOG, VGALOG,
|
|
|
|
DEVLOG, MEMLOG, DISLOG, GUILOG, IOAPICLOG, APICLOG, CPU0LOG, CPU1LOG,
|
|
|
|
CPU2LOG, CPU3LOG, CPU4LOG, CPU5LOG, CPU6LOG, CPU7LOG, CPU8LOG, CPU9LOG,
|
|
|
|
CPU10LOG, CPU11LOG, CPU12LOG, CPU13LOG, CPU14LOG, CPU15LOG, CTRLLOG,
|
|
|
|
UNMAPLOG, SERRLOG, BIOSLOG, PIT81LOG, PIT82LOG, IODEBUGLOG, PCI2ISALOG,
|
2004-01-13 22:21:21 +03:00
|
|
|
PLUGINLOG, EXTFPUIRQLOG , PCIVGALOG, PCIUSBLOG, VTIMERLOG, STIMERLOG,
|
2006-09-24 20:58:13 +04:00
|
|
|
PCIIDELOG, PCIDEVLOG, PCIPNICLOG, SPEAKERLOG, BUSMLOG, GAMELOG, ACPILOG
|
2002-10-25 01:07:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class BOCHSAPI iofunctions {
|
2002-06-26 18:42:35 +04:00
|
|
|
int magic;
|
|
|
|
char logprefix[BX_LOGPREFIX_SIZE];
|
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
|
|
|
FILE *logfd;
|
|
|
|
class logfunctions *log;
|
|
|
|
void init(void);
|
|
|
|
void flush(void);
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
// Log Class types
|
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
|
|
|
public:
|
|
|
|
iofunctions(void);
|
|
|
|
iofunctions(FILE *);
|
|
|
|
iofunctions(int);
|
2001-11-12 21:28:07 +03:00
|
|
|
iofunctions(const char *);
|
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
|
|
|
~iofunctions(void);
|
|
|
|
|
2001-11-12 21:28:07 +03:00
|
|
|
void out(int facility, int level, const char *pre, const char *fmt, va_list 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-11-12 21:28:07 +03:00
|
|
|
void init_log(const char *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
|
|
|
void init_log(int fd);
|
|
|
|
void init_log(FILE *fs);
|
2006-09-09 15:28:52 +04:00
|
|
|
void exit_log();
|
2002-06-28 18:03:47 +04:00
|
|
|
void set_log_prefix(const char *prefix);
|
2006-09-17 22:09:33 +04:00
|
|
|
int get_n_logfns() { return n_logfn; }
|
|
|
|
logfunc_t *get_logfn(int index) { return logfn_list[index]; }
|
|
|
|
void add_logfn(logfunc_t *fn);
|
|
|
|
void remove_logfn(logfunc_t *fn);
|
|
|
|
void set_log_action(int loglevel, int action);
|
2001-11-12 21:28:07 +03:00
|
|
|
const char *getlevel(int i) {
|
2003-07-28 17:55:20 +04:00
|
|
|
static const char *loglevel[N_LOGLEV] = {
|
2001-06-08 00:31:20 +04:00
|
|
|
"DEBUG",
|
|
|
|
"INFO",
|
|
|
|
"ERROR",
|
2002-12-19 09:05:18 +03:00
|
|
|
"PANIC",
|
2002-12-17 06:36:53 +03:00
|
|
|
"PASS"
|
2001-06-08 00:31:20 +04:00
|
|
|
};
|
2003-07-28 17:55:20 +04:00
|
|
|
if (i>=0 && i<N_LOGLEV) return loglevel[i];
|
|
|
|
else return "?";
|
2001-06-08 00:31:20 +04:00
|
|
|
}
|
|
|
|
char *getaction(int i) {
|
2007-10-25 03:29:40 +04:00
|
|
|
static const char *name[] = { "ignore", "report", "ask", "fatal" };
|
2001-06-11 18:03:35 +04:00
|
|
|
assert (i>=ACT_IGNORE && i<N_ACT);
|
2007-10-25 03:29:40 +04:00
|
|
|
return (char *) name[i];
|
2001-06-08 00:31:20 +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
|
|
|
protected:
|
2001-05-23 06:37:52 +04:00
|
|
|
int n_logfn;
|
2002-12-14 11:51:36 +03:00
|
|
|
#define MAX_LOGFNS 128
|
2001-05-23 06:37:52 +04:00
|
|
|
logfunc_t *logfn_list[MAX_LOGFNS];
|
2007-10-25 03:29:40 +04:00
|
|
|
const char *logfn;
|
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
|
|
|
};
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
typedef class BOCHSAPI iofunctions iofunc_t;
|
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
|
|
|
|
|
|
|
|
|
|
|
#define SAFE_GET_IOFUNC() \
|
|
|
|
((io==NULL)? (io=new iofunc_t("/dev/stderr")) : io)
|
|
|
|
#define SAFE_GET_GENLOG() \
|
|
|
|
((genlog==NULL)? (genlog=new logfunc_t(SAFE_GET_IOFUNC())) : genlog)
|
|
|
|
|
2007-10-30 21:57:46 +03:00
|
|
|
#if BX_NO_LOGGING
|
|
|
|
|
2007-11-22 20:30:40 +03:00
|
|
|
#define BX_INFO(x)
|
|
|
|
#define BX_DEBUG(x)
|
|
|
|
#define BX_ERROR(x)
|
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
|
|
|
#define BX_PANIC(x) (LOG_THIS panic) x
|
2002-12-17 06:36:53 +03:00
|
|
|
#define BX_PASS(x) (LOG_THIS pass) x
|
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
|
|
|
|
|
2007-10-30 21:57:46 +03:00
|
|
|
#define BX_INFO(x) (LOG_THIS info) x
|
|
|
|
#define BX_DEBUG(x) (LOG_THIS ldebug) x
|
|
|
|
#define BX_ERROR(x) (LOG_THIS error) x
|
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
|
|
|
#define BX_PANIC(x) (LOG_THIS panic) x
|
2002-12-17 06:36:53 +03:00
|
|
|
#define BX_PASS(x) (LOG_THIS pass) x
|
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
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
BOCHSAPI extern iofunc_t *io;
|
|
|
|
BOCHSAPI extern logfunc_t *genlog;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#ifndef UNUSED
|
|
|
|
# define UNUSED(x) ((void)x)
|
|
|
|
#endif
|
|
|
|
|
2005-01-13 22:03:40 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2006-01-19 21:32:39 +03:00
|
|
|
#define FMT_ADDRX FMT_ADDRX64
|
2005-01-13 22:03:40 +03:00
|
|
|
#else
|
2006-01-19 21:32:39 +03:00
|
|
|
#define FMT_ADDRX FMT_ADDRX32
|
2005-01-13 22:03:40 +03:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2002-10-03 09:29:15 +04:00
|
|
|
#if BX_GDBSTUB
|
|
|
|
// defines for GDB stub
|
2006-10-26 21:27:04 +04:00
|
|
|
void bx_gdbstub_init(void);
|
2006-10-29 11:48:30 +03:00
|
|
|
void bx_gdbstub_break(void);
|
2002-10-03 09:29:15 +04:00
|
|
|
int bx_gdbstub_check(unsigned int eip);
|
|
|
|
#define GDBSTUB_STOP_NO_REASON (0xac0)
|
2002-10-22 16:50:56 +04:00
|
|
|
|
2006-01-18 21:35:38 +03:00
|
|
|
#if BX_SUPPORT_SMP
|
2002-10-22 16:50:56 +04:00
|
|
|
#error GDB stub was written for single processor support. If multiprocessor support is added, then we can remove this check.
|
|
|
|
// The big problem is knowing which CPU gdb is referring to. In other words,
|
|
|
|
// what should we put for "n" in BX_CPU(n)->dbg_xlate_linear2phy() and
|
|
|
|
// BX_CPU(n)->dword.eip, etc.
|
|
|
|
#endif
|
2002-10-03 09:29:15 +04:00
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
typedef struct {
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool floppy;
|
|
|
|
bx_bool keyboard;
|
|
|
|
bx_bool video;
|
|
|
|
bx_bool disk;
|
|
|
|
bx_bool pit;
|
|
|
|
bx_bool pic;
|
|
|
|
bx_bool bios;
|
|
|
|
bx_bool cmos;
|
|
|
|
bx_bool a20;
|
|
|
|
bx_bool interrupts;
|
|
|
|
bx_bool exceptions;
|
|
|
|
bx_bool unsupported;
|
|
|
|
bx_bool temp;
|
|
|
|
bx_bool reset;
|
|
|
|
bx_bool debugger;
|
|
|
|
bx_bool mouse;
|
|
|
|
bx_bool io;
|
|
|
|
bx_bool xms;
|
|
|
|
bx_bool v8086;
|
|
|
|
bx_bool paging;
|
|
|
|
bx_bool creg;
|
|
|
|
bx_bool dreg;
|
|
|
|
bx_bool dma;
|
|
|
|
bx_bool unsupported_io;
|
|
|
|
bx_bool serial;
|
|
|
|
bx_bool cdrom;
|
2007-11-20 21:36:26 +03:00
|
|
|
bx_bool print_timestamps;
|
2004-01-29 20:49:03 +03:00
|
|
|
#if BX_MAGIC_BREAKPOINT
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool magic_break_enabled;
|
2007-10-13 02:11:25 +04:00
|
|
|
#endif
|
2005-03-16 19:36:31 +03:00
|
|
|
#if BX_GDBSTUB
|
2004-11-06 13:50:03 +03:00
|
|
|
bx_bool gdbstub_enabled;
|
|
|
|
#endif
|
2001-06-12 17:07:43 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool apic;
|
|
|
|
bx_bool ioapic;
|
2001-05-23 12:16:07 +04:00
|
|
|
#endif
|
|
|
|
#if BX_DEBUG_LINUX
|
2002-10-25 15:44:41 +04:00
|
|
|
bx_bool linux_syscall;
|
2001-05-23 12:16:07 +04:00
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
void* record_io;
|
|
|
|
} bx_debug_t;
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
#define BX_ASSERT(x) do {if (!(x)) BX_PANIC(("failed assertion \"%s\" at %s:%d\n", #x, __FILE__, __LINE__));} while (0)
|
2001-05-09 00:18:04 +04:00
|
|
|
void bx_signal_handler (int signum);
|
2002-04-18 04:22:20 +04:00
|
|
|
int bx_atexit(void);
|
2002-10-25 01:07:56 +04:00
|
|
|
BOCHSAPI extern bx_debug_t bx_dbg;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
2004-10-30 01:15:48 +04:00
|
|
|
// memory access type (read/write/rw)
|
|
|
|
#define BX_READ 0
|
|
|
|
#define BX_WRITE 1
|
|
|
|
#define BX_RW 2
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2004-12-17 01:21:35 +03:00
|
|
|
#define DATA_ACCESS 0
|
|
|
|
#define CODE_ACCESS 1
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "memory/memory.h"
|
|
|
|
#include "pc_system.h"
|
2002-10-25 01:07:56 +04:00
|
|
|
#include "plugin.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "gui/gui.h"
|
2002-10-29 23:18:32 +03:00
|
|
|
#include "gui/textconfig.h"
|
2001-12-14 20:56:37 +03:00
|
|
|
#include "gui/keymap.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/* --- EXTERNS --- */
|
|
|
|
|
2002-11-11 20:09:57 +03:00
|
|
|
#if BX_GUI_SIGHANDLER
|
|
|
|
extern bx_bool bx_gui_sighandler;
|
|
|
|
#endif
|
|
|
|
|
2002-03-26 16:59:35 +03:00
|
|
|
// This value controls how often each I/O device's periodic() method
|
|
|
|
// gets called. The timer is set up in iodev/devices.cc.
|
|
|
|
#define BX_IODEV_HANDLER_PERIOD 100 // microseconds
|
|
|
|
//#define BX_IODEV_HANDLER_PERIOD 10 // microseconds
|
2001-06-10 00:01:12 +04:00
|
|
|
|
2001-06-08 11:20:07 +04:00
|
|
|
#define BX_PATHNAME_LEN 512
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-12-12 13:43:36 +03:00
|
|
|
#define BX_KBD_XT_TYPE 0
|
|
|
|
#define BX_KBD_AT_TYPE 1
|
|
|
|
#define BX_KBD_MF_TYPE 2
|
|
|
|
|
2002-09-03 12:34:17 +04:00
|
|
|
#define BX_N_OPTROM_IMAGES 4
|
2006-02-17 00:44:17 +03:00
|
|
|
#define BX_N_OPTRAM_IMAGES 4
|
2004-01-18 03:18:44 +03:00
|
|
|
#define BX_N_SERIAL_PORTS 4
|
2004-01-28 00:38:51 +03:00
|
|
|
#define BX_N_PARALLEL_PORTS 2
|
2003-01-28 19:58:10 +03:00
|
|
|
#define BX_N_USB_HUBS 1
|
2004-06-29 23:24:34 +04:00
|
|
|
#define BX_N_PCI_SLOTS 5
|
2002-09-03 12:34:17 +04:00
|
|
|
|
2006-01-18 21:35:38 +03:00
|
|
|
#if BX_SUPPORT_SMP
|
|
|
|
#define BX_SMP_PROCESSORS (bx_cpu_count)
|
|
|
|
#else
|
|
|
|
#define BX_SMP_PROCESSORS 1
|
|
|
|
#endif
|
|
|
|
|
2007-10-16 20:17:48 +04:00
|
|
|
void bx_center_print(FILE *file, char *line, int maxwidth);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#define BX_USE_PS2_MOUSE 1
|
|
|
|
|
|
|
|
#include "instrument.h"
|
|
|
|
|
2002-09-05 08:56:11 +04:00
|
|
|
// These are some convenience macros which abstract out accesses between
|
|
|
|
// a variable in native byte ordering to/from guest (x86) memory, which is
|
|
|
|
// always in little endian format. You must deal with alignment (if your
|
|
|
|
// system cares) and endian rearranging. Don't assume anything. You could
|
|
|
|
// put some platform specific asm() statements here, to make use of native
|
|
|
|
// instructions to help perform these operations more efficiently than C++.
|
|
|
|
|
|
|
|
|
2007-10-16 20:17:48 +04:00
|
|
|
#ifdef BX_LITTLE_ENDIAN
|
2002-09-05 08:56:11 +04:00
|
|
|
|
|
|
|
#define WriteHostWordToLittleEndian(hostPtr, nativeVar16) \
|
2002-09-07 01:54:58 +04:00
|
|
|
*((Bit16u*)(hostPtr)) = (nativeVar16)
|
2002-09-05 08:56:11 +04:00
|
|
|
#define WriteHostDWordToLittleEndian(hostPtr, nativeVar32) \
|
2002-09-07 01:54:58 +04:00
|
|
|
*((Bit32u*)(hostPtr)) = (nativeVar32)
|
2002-09-05 08:56:11 +04:00
|
|
|
#define WriteHostQWordToLittleEndian(hostPtr, nativeVar64) \
|
2002-09-07 01:54:58 +04:00
|
|
|
*((Bit64u*)(hostPtr)) = (nativeVar64)
|
2002-09-05 08:56:11 +04:00
|
|
|
#define ReadHostWordFromLittleEndian(hostPtr, nativeVar16) \
|
2002-09-07 01:54:58 +04:00
|
|
|
(nativeVar16) = *((Bit16u*)(hostPtr))
|
2002-09-05 08:56:11 +04:00
|
|
|
#define ReadHostDWordFromLittleEndian(hostPtr, nativeVar32) \
|
2002-09-07 01:54:58 +04:00
|
|
|
(nativeVar32) = *((Bit32u*)(hostPtr))
|
2002-09-05 08:56:11 +04:00
|
|
|
#define ReadHostQWordFromLittleEndian(hostPtr, nativeVar64) \
|
2002-09-07 01:54:58 +04:00
|
|
|
(nativeVar64) = *((Bit64u*)(hostPtr))
|
2002-09-05 08:56:11 +04:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define WriteHostWordToLittleEndian(hostPtr, nativeVar16) { \
|
|
|
|
((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar16); \
|
|
|
|
((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar16)>>8); \
|
|
|
|
}
|
|
|
|
#define WriteHostDWordToLittleEndian(hostPtr, nativeVar32) { \
|
|
|
|
((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar32); \
|
|
|
|
((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar32)>>8); \
|
|
|
|
((Bit8u *)(hostPtr))[2] = (Bit8u) ((nativeVar32)>>16); \
|
|
|
|
((Bit8u *)(hostPtr))[3] = (Bit8u) ((nativeVar32)>>24); \
|
|
|
|
}
|
|
|
|
#define WriteHostQWordToLittleEndian(hostPtr, nativeVar64) { \
|
|
|
|
((Bit8u *)(hostPtr))[0] = (Bit8u) (nativeVar64); \
|
|
|
|
((Bit8u *)(hostPtr))[1] = (Bit8u) ((nativeVar64)>>8); \
|
|
|
|
((Bit8u *)(hostPtr))[2] = (Bit8u) ((nativeVar64)>>16); \
|
|
|
|
((Bit8u *)(hostPtr))[3] = (Bit8u) ((nativeVar64)>>24); \
|
|
|
|
((Bit8u *)(hostPtr))[4] = (Bit8u) ((nativeVar64)>>32); \
|
|
|
|
((Bit8u *)(hostPtr))[5] = (Bit8u) ((nativeVar64)>>40); \
|
|
|
|
((Bit8u *)(hostPtr))[6] = (Bit8u) ((nativeVar64)>>48); \
|
|
|
|
((Bit8u *)(hostPtr))[7] = (Bit8u) ((nativeVar64)>>56); \
|
|
|
|
}
|
|
|
|
#define ReadHostWordFromLittleEndian(hostPtr, nativeVar16) { \
|
|
|
|
(nativeVar16) = ((Bit16u) ((Bit8u *)(hostPtr))[0]) | \
|
|
|
|
(((Bit16u) ((Bit8u *)(hostPtr))[1])<<8) ; \
|
|
|
|
}
|
|
|
|
#define ReadHostDWordFromLittleEndian(hostPtr, nativeVar32) { \
|
|
|
|
(nativeVar32) = ((Bit32u) ((Bit8u *)(hostPtr))[0]) | \
|
|
|
|
(((Bit32u) ((Bit8u *)(hostPtr))[1])<<8) | \
|
|
|
|
(((Bit32u) ((Bit8u *)(hostPtr))[2])<<16) | \
|
|
|
|
(((Bit32u) ((Bit8u *)(hostPtr))[3])<<24); \
|
|
|
|
}
|
|
|
|
#define ReadHostQWordFromLittleEndian(hostPtr, nativeVar64) { \
|
|
|
|
(nativeVar64) = ((Bit64u) ((Bit8u *)(hostPtr))[0]) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[1])<<8) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[2])<<16) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[3])<<24) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[4])<<32) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[5])<<40) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[6])<<48) | \
|
|
|
|
(((Bit64u) ((Bit8u *)(hostPtr))[7])<<56); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif /* BX_BOCHS_H */
|