2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-09-05 08:56:11 +04:00
|
|
|
// $Id: bochs.h,v 1.88 2002-09-05 04:56:11 kevinlawton 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 */
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
extern "C" {
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2001-06-08 00:31:20 +04:00
|
|
|
#include <assert.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>
|
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 */
|
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>
|
|
|
|
#ifdef macintosh
|
|
|
|
# define SuperDrive "[fd:]"
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-04-10 05:53:28 +04:00
|
|
|
#include "osdep.h" /* platform dependent includes and defines */
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "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"
|
|
|
|
|
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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#if ((BX_DEBUGGER == 1) && (BX_NUM_SIMULATORS >= 2))
|
|
|
|
// =-=-=-=-=-=-=- Redirected to cosimulation debugger -=-=-=-=-=-=-=
|
|
|
|
#define BX_VGA_MEM_READ(addr) bx_dbg_ucmem_read(addr)
|
|
|
|
#define BX_VGA_MEM_WRITE(addr, val) bx_dbg_ucmem_write(addr, val)
|
|
|
|
#if BX_SUPPORT_A20
|
|
|
|
# define A20ADDR(x) ( (x) & bx_pc_system.a20_mask )
|
|
|
|
#else
|
|
|
|
# define A20ADDR(x) (x)
|
|
|
|
#endif
|
|
|
|
#define BX_INP(addr, len) bx_dbg_inp(addr, len)
|
|
|
|
#define BX_OUTP(addr, val, len) bx_dbg_outp(addr, val, len)
|
|
|
|
#define BX_HRQ (bx_pc_system.HRQ)
|
|
|
|
#define BX_RAISE_HLDA() bx_dbg_raise_HLDA()
|
|
|
|
#define BX_TICK1()
|
|
|
|
#define BX_INTR bx_pc_system.INTR
|
|
|
|
#define BX_SET_INTR(b) bx_dbg_set_INTR(b)
|
|
|
|
#if BX_SIM_ID == 0
|
|
|
|
# define BX_CPU_C bx_cpu0_c
|
|
|
|
# define BX_CPU bx_cpu0
|
|
|
|
# define BX_MEM_C bx_mem0_c
|
|
|
|
# define BX_MEM bx_mem0
|
|
|
|
#else
|
|
|
|
# define BX_CPU_C bx_cpu1_c
|
|
|
|
# define BX_CPU bx_cpu1
|
|
|
|
# define BX_MEM_C bx_mem1_c
|
|
|
|
# define BX_MEM bx_mem1
|
|
|
|
#endif
|
|
|
|
#define BX_SET_ENABLE_A20(enabled) bx_dbg_async_pin_request(BX_DBG_ASYNC_PENDING_A20, \
|
|
|
|
enabled)
|
|
|
|
#define BX_GET_ENABLE_A20() bx_pc_system.get_enable_a20()
|
2001-05-23 12:16:07 +04:00
|
|
|
#error FIXME: cosim mode not fixed yet
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#else
|
2001-05-23 12:16:07 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
// =-=-=-=-=-=-=- Normal optimized use -=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
|
|
|
#define BX_VGA_MEM_READ(addr) (bx_devices.vga->mem_read(addr))
|
|
|
|
#define BX_VGA_MEM_WRITE(addr, val) bx_devices.vga->mem_write(addr, val)
|
|
|
|
#if BX_SUPPORT_A20
|
|
|
|
# define A20ADDR(x) ( (x) & bx_pc_system.a20_mask )
|
|
|
|
#else
|
|
|
|
# define A20ADDR(x) (x)
|
|
|
|
#endif
|
|
|
|
//
|
|
|
|
// 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
|
|
|
// macros for DMA handling
|
|
|
|
#define BX_REGISTER_DMA8_CHANNEL(channel, dmaRead, dmaWrite, name) \
|
|
|
|
bx_dma.registerDMA8Channel(channel, dmaRead, dmaWrite, name)
|
|
|
|
#define BX_REGISTER_DMA16_CHANNEL(channel, dmaRead, dmaWrite, name) \
|
|
|
|
bx_dma.registerDMA16Channel(channel, dmaRead, dmaWrite, name)
|
|
|
|
#define BX_UNREGISTER_DMA_CHANNEL(channel) \
|
|
|
|
bx_dma.unregisterDMAChannel(channel)
|
|
|
|
#define BX_DMA_SET_DRQ(channel, val) bx_dma.set_DRQ(channel, val)
|
|
|
|
#define BX_DMA_GET_TC() bx_dma.get_TC()
|
|
|
|
#define BX_HRQ (bx_pc_system.HRQ)
|
|
|
|
#define BX_RAISE_HLDA() bx_dma.raise_HLDA()
|
|
|
|
#define BX_MEM_READ_PHYSICAL(phy_addr, len, ptr) \
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_MEM(0)->readPhysicalPage(BX_CPU(0), phy_addr, len, ptr)
|
2002-06-16 19:02:28 +04:00
|
|
|
#define BX_MEM_WRITE_PHYSICAL(addr, len, ptr) \
|
Now, when you compile with --enable-guest2host-tlb, non-paged
mode uses the notion of the guest-to-host TLB. This has the
benefit of allowing more uniform and streamlined acceleration
code in access.cc which does not have to check if CR0.PG
is set, eliminating a few instructions per guest access.
Shaved just a little off execution time, as expected.
Also, access_linear now breaks accesses which span two pages,
into two calls the the physical memory routines, when paging
is off, just like it always has for paging on. Besides
being more uniform, this allows the physical memory access
routines to known the complete data item is contained
within a single physical page, and stop reapplying the
A20ADDR() macro to pointers as it increments them.
Perhaps things can be optimized a little more now there too...
I renamed the routines to {read,write}PhysicalPage() as
a reminder that these routines now operate on data
solely within one page.
I also added a little code so that the paging module is
notified when the A20 line is tweaked, so it can dump
whatever mappings it wants to.
2002-09-05 06:31:24 +04:00
|
|
|
BX_MEM(0)->writePhysicalPage(BX_CPU(0), phy_addr, len, ptr)
|
2002-08-31 16:24:41 +04:00
|
|
|
// macro for PCI handling
|
2002-08-17 13:23:42 +04:00
|
|
|
#define BX_REGISTER_PCI_HANDLERS(this_ptr, pci_read, pci_write, devfunc, name) \
|
|
|
|
bx_pci.register_pci_handlers(this_ptr, pci_read, pci_write, devfunc, name)
|
2002-06-16 19:02:28 +04:00
|
|
|
|
2001-06-05 21:35:08 +04:00
|
|
|
#if BX_SMP_PROCESSORS==1
|
|
|
|
#define BX_CPU(x) (&bx_cpu)
|
|
|
|
#define BX_MEM(x) (&bx_mem)
|
|
|
|
#else
|
|
|
|
#define BX_CPU(x) (bx_cpu_array[x])
|
2001-05-23 12:16:07 +04:00
|
|
|
#define BX_MEM(x) (bx_mem_array[x])
|
2001-06-05 21:35:08 +04:00
|
|
|
#endif
|
|
|
|
|
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()
|
|
|
|
|
2001-05-23 12:16:07 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// you can't use static member functions on the CPU, if there are going
|
|
|
|
// to be 2 cpus. Check this early on.
|
|
|
|
#if (BX_SMP_PROCESSORS>1)
|
|
|
|
# if (BX_USE_CPU_SMF!=0)
|
|
|
|
# error For SMP simulation, BX_USE_CPU_SMF must be 0.
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
// #define BX_IAC() bx_pc_system.IAC()
|
|
|
|
#define BX_IAC() bx_devices.pic->IAC()
|
|
|
|
//#define BX_IAC() bx_dbg_IAC()
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
#if (BX_NUM_SIMULATORS > 1)
|
|
|
|
// for multiple simulators, we always need this info, since we're
|
|
|
|
// going to replay it.
|
|
|
|
# define BX_DBG_DMA_REPORT(addr, len, what, val) \
|
|
|
|
bx_dbg_dma_report(addr, len, what, val)
|
|
|
|
# define BX_DBG_IAC_REPORT(vector, irq) \
|
|
|
|
bx_dbg_iac_report(vector, irq)
|
|
|
|
# define BX_DBG_A20_REPORT(val) \
|
|
|
|
bx_dbg_a20_report(val)
|
|
|
|
# define BX_DBG_IO_REPORT(addr, size, op, val) \
|
|
|
|
bx_dbg_io_report(addr, size, op, val)
|
|
|
|
# define BX_DBG_UCMEM_REPORT(addr, size, op, val)
|
|
|
|
#else
|
|
|
|
// for a single simulator debug environment, we can optimize a little
|
|
|
|
// by conditionally calling, as per requested.
|
|
|
|
|
|
|
|
# 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)
|
|
|
|
# define BX_DBG_IO_REPORT(addr, size, op, val) \
|
|
|
|
if (bx_guard.report.io) bx_dbg_io_report(addr, size, op, val)
|
|
|
|
# define BX_DBG_UCMEM_REPORT(addr, size, op, val) \
|
|
|
|
if (bx_guard.report.ucmem) bx_dbg_ucmem_report(addr, size, op, val)
|
|
|
|
#endif // #if (BX_NUM_SIMULATORS > 1)
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
extern Bit8u DTPageDirty[];
|
|
|
|
#if BX_DYNAMIC_TRANSLATION
|
|
|
|
# define BX_DYN_DIRTY_PAGE(page) DTPageDirty[page] = 1;
|
|
|
|
#else
|
|
|
|
# define BX_DYN_DIRTY_PAGE(page)
|
|
|
|
#endif
|
|
|
|
|
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-09-03 12:34:17 +04:00
|
|
|
|
|
|
|
#define DEFAULT_LOG_ACTIONS(level) \
|
|
|
|
(level<=LOGLEV_INFO ? ACT_IGNORE \
|
|
|
|
: level==LOGLEV_ERROR ? ACT_REPORT \
|
|
|
|
: ACT_ASK)
|
|
|
|
|
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
|
|
|
typedef class logfunctions {
|
|
|
|
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;
|
|
|
|
public:
|
|
|
|
logfunctions(void);
|
|
|
|
logfunctions(class iofunctions *);
|
|
|
|
~logfunctions(void);
|
|
|
|
|
2001-11-12 21:28:07 +03:00
|
|
|
void info(const char *fmt, ...);
|
|
|
|
void error(const char *fmt, ...);
|
|
|
|
void panic(const char *fmt, ...);
|
|
|
|
void ldebug(const char *fmt, ...);
|
|
|
|
void fatal (const char *prefix, const char *fmt, va_list ap);
|
|
|
|
void ask (int level, const char *prefix, const char *fmt, va_list ap);
|
2001-06-27 23:16:01 +04:00
|
|
|
void put(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];
|
|
|
|
}
|
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
|
|
|
|
|
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 {
|
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);
|
|
|
|
// Log Class defines
|
|
|
|
#define IOLOG 0
|
|
|
|
#define FDLOG 1
|
|
|
|
#define GENLOG 2
|
|
|
|
#define CMOSLOG 3
|
|
|
|
#define CDLOG 4
|
|
|
|
#define DMALOG 5
|
|
|
|
#define ETHLOG 6
|
|
|
|
#define G2HLOG 7
|
|
|
|
#define HDLOG 8
|
|
|
|
#define KBDLOG 9
|
|
|
|
#define NE2KLOG 10
|
|
|
|
#define PARLOG 11
|
|
|
|
#define PCILOG 12
|
|
|
|
#define PICLOG 13
|
|
|
|
#define PITLOG 14
|
|
|
|
#define SB16LOG 15
|
|
|
|
#define SERLOG 16
|
|
|
|
#define VGALOG 17
|
|
|
|
#define STLOG 18 // state_file.cc
|
|
|
|
#define DEVLOG 19
|
|
|
|
#define MEMLOG 20
|
|
|
|
#define DISLOG 21
|
|
|
|
#define GUILOG 22
|
2001-05-23 12:16:07 +04:00
|
|
|
#define IOAPICLOG 23
|
|
|
|
#define APICLOG 24
|
|
|
|
#define CPU0LOG 25
|
|
|
|
#define CPU1LOG 26
|
|
|
|
#define CPU2LOG 27
|
|
|
|
#define CPU3LOG 28
|
|
|
|
#define CPU4LOG 29
|
|
|
|
#define CPU5LOG 30
|
|
|
|
#define CPU6LOG 31
|
|
|
|
#define CPU7LOG 32
|
|
|
|
#define CPU8LOG 33
|
|
|
|
#define CPU9LOG 34
|
|
|
|
#define CPU10LOG 35
|
|
|
|
#define CPU11LOG 36
|
|
|
|
#define CPU12LOG 37
|
|
|
|
#define CPU13LOG 38
|
|
|
|
#define CPU14LOG 39
|
|
|
|
#define CPU15LOG 40
|
2001-06-08 11:20:07 +04:00
|
|
|
#define CTRLLOG 41
|
2001-06-13 05:46:08 +04:00
|
|
|
#define UNMAPLOG 42
|
2001-06-16 23:29:59 +04:00
|
|
|
#define SERRLOG 43
|
2001-08-21 08:10:35 +04:00
|
|
|
#define BIOSLOG 42
|
2001-09-05 18:41:55 +04:00
|
|
|
#define PIT81LOG 45
|
|
|
|
#define PIT82LOG 46
|
2001-09-14 19:15:25 +04:00
|
|
|
#define IODEBUGLOG 47
|
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);
|
2002-06-28 18:03:47 +04:00
|
|
|
void set_log_prefix(const char *prefix);
|
2001-05-23 06:37:52 +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 set_log_action (int loglevel, int action);
|
2001-11-12 21:28:07 +03:00
|
|
|
const char *getlevel(int i) {
|
|
|
|
static const char *loglevel[4] = {
|
2001-06-08 00:31:20 +04:00
|
|
|
"DEBUG",
|
|
|
|
"INFO",
|
|
|
|
"ERROR",
|
2001-10-07 22:42:55 +04:00
|
|
|
"PANIC"
|
2001-06-08 00:31:20 +04:00
|
|
|
};
|
2001-11-12 21:28:07 +03:00
|
|
|
if (i>=0 && i<4) return loglevel[i];
|
2001-10-07 22:42:55 +04:00
|
|
|
else return "?";
|
2001-06-08 00:31:20 +04:00
|
|
|
}
|
|
|
|
char *getaction(int i) {
|
2001-06-11 18:03:35 +04:00
|
|
|
static char *name[] = { "ignore", "report", "ask", "fatal" };
|
|
|
|
assert (i>=ACT_IGNORE && i<N_ACT);
|
2001-06-08 00:31:20 +04:00
|
|
|
return name[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
|
|
|
protected:
|
2001-05-23 06:37:52 +04:00
|
|
|
int n_logfn;
|
2001-06-06 22:27:45 +04:00
|
|
|
#define MAX_LOGFNS 64
|
2001-05-23 06:37:52 +04:00
|
|
|
logfunc_t *logfn_list[MAX_LOGFNS];
|
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 *logfn;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
typedef class iofunctions iofunc_t;
|
|
|
|
|
|
|
|
|
|
|
|
#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)
|
2001-05-24 18:08:54 +04:00
|
|
|
/* #define NO_LOGGING */
|
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
|
|
|
#ifndef NO_LOGGING
|
|
|
|
|
|
|
|
#define BX_INFO(x) (LOG_THIS info) x
|
|
|
|
#define BX_DEBUG(x) (LOG_THIS ldebug) x
|
|
|
|
#define BX_ERROR(x) (LOG_THIS error) x
|
|
|
|
#define BX_PANIC(x) (LOG_THIS panic) x
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define EMPTY do { } while(0)
|
|
|
|
|
|
|
|
#define BX_INFO(x) EMPTY
|
|
|
|
#define BX_DEBUG(x) EMPTY
|
|
|
|
#define BX_ERROR(x) EMPTY
|
|
|
|
#define BX_PANIC(x) (LOG_THIS panic) x
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern iofunc_t *io;
|
|
|
|
extern logfunc_t *genlog;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#include "state_file.h"
|
|
|
|
|
|
|
|
#ifndef UNUSED
|
|
|
|
# define UNUSED(x) ((void)x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define uint8 Bit8u
|
|
|
|
#define uint16 Bit16u
|
|
|
|
#define uint32 Bit32u
|
|
|
|
|
|
|
|
|
|
|
|
#if BX_PROVIDE_CPU_MEMORY==1
|
|
|
|
# include "cpu/cpu.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_DISASM
|
|
|
|
# include "disasm/disasm.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_DYNAMIC_TRANSLATION
|
|
|
|
# include "dynamic/dynamic.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Boolean floppy;
|
|
|
|
Boolean keyboard;
|
|
|
|
Boolean video;
|
|
|
|
Boolean disk;
|
|
|
|
Boolean pit;
|
|
|
|
Boolean pic;
|
|
|
|
Boolean bios;
|
|
|
|
Boolean cmos;
|
|
|
|
Boolean a20;
|
|
|
|
Boolean interrupts;
|
|
|
|
Boolean exceptions;
|
|
|
|
Boolean unsupported;
|
|
|
|
Boolean temp;
|
|
|
|
Boolean reset;
|
|
|
|
Boolean debugger;
|
|
|
|
Boolean mouse;
|
|
|
|
Boolean io;
|
|
|
|
Boolean xms;
|
|
|
|
Boolean v8086;
|
|
|
|
Boolean paging;
|
|
|
|
Boolean creg;
|
|
|
|
Boolean dreg;
|
|
|
|
Boolean dma;
|
|
|
|
Boolean unsupported_io;
|
|
|
|
Boolean serial;
|
|
|
|
Boolean cdrom;
|
|
|
|
#ifdef MAGIC_BREAKPOINT
|
|
|
|
Boolean magic_break_enabled;
|
|
|
|
#endif /* MAGIC_BREAKPOINT */
|
2001-06-12 17:07:43 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2001-05-23 12:16:07 +04:00
|
|
|
Boolean apic;
|
|
|
|
Boolean ioapic;
|
|
|
|
#endif
|
|
|
|
#if BX_DEBUG_LINUX
|
|
|
|
Boolean linux_syscall;
|
|
|
|
#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);
|
2001-04-10 05:04:59 +04:00
|
|
|
extern bx_debug_t bx_dbg;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define BX_FLOPPY_NONE 10 // floppy not present
|
|
|
|
#define BX_FLOPPY_1_2 11 // 1.2M 5.25"
|
|
|
|
#define BX_FLOPPY_1_44 12 // 1.44M 3.5"
|
|
|
|
#define BX_FLOPPY_2_88 13 // 2.88M 3.5"
|
|
|
|
#define BX_FLOPPY_720K 14 // 720K 3.5"
|
2002-08-01 11:37:56 +04:00
|
|
|
#define BX_FLOPPY_360K 15 // 360K 5.25"
|
|
|
|
#define BX_FLOPPY_LAST 15 // last one
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
#define BX_READ 10
|
|
|
|
#define BX_WRITE 11
|
|
|
|
#define BX_RW 12
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "memory/memory.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum PCS_OP { PCS_CLEAR, PCS_SET, PCS_TOGGLE };
|
|
|
|
|
|
|
|
#include "pc_system.h"
|
|
|
|
|
|
|
|
#include "gui/gui.h"
|
2001-06-08 00:31:20 +04:00
|
|
|
#include "gui/control.h"
|
2001-12-14 20:56:37 +03:00
|
|
|
#include "gui/keymap.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
extern bx_gui_c bx_gui;
|
|
|
|
#include "iodev/iodev.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* --- EXTERNS --- */
|
|
|
|
|
|
|
|
#if ( BX_PROVIDE_DEVICE_MODELS==1 )
|
|
|
|
extern bx_devices_c bx_devices;
|
|
|
|
#endif
|
|
|
|
|
- I've added lots of comments in siminterface.h, and tried to clean up
the terminology a bit. In particular, the term "gui" has started
to mean different things in different contexts, so I've defined
some more specific names for the parts of the user interface, and
updated comments and some variable names to reflect it. See
siminterface.h for a more complete description of all of these.
VGAW: VGA display window and toolbar buttons, the traditional Bochs
display which is ported to X, win32, MacOS X, etc. Implemented
in gui/gui.* and platform dependent gui/*.cc files.
CI: configuration interface that lets the user change settings such
as floppy disk image, ne2k settings, log options. The CI consists
of two parts: configuration user interface (CUI) which does the
actual rendering to the screen and handles key/mouse/menu events,
and the siminterface object.
CUI: configuration user interface. This handles the user interactions
that allow the user to configure Bochs. To actually change any
values it talks to the siminterface object. One implementation of
the CUI is the text-mode menus in gui/control.cc. Another
implementation is (will be) the wxWindows menus and dialogs in
gui/wxmain.cc.
siminterface: the glue between the CUI and the simulation code,
accessible throughout the code by the global variable
bx_simulator_interface_c *SIM;
Among other things, siminterface methods allow the simulator to ask the
CUI to display things or ask for user input, and allows the CUI
to query and modify variables in the simulation code.
GUI: Literally, "graphical user interface". Until the configuration menus
and wxWindows came along, everyone understood that "gui" referred to the
VGA display window and the toolbar buttons because that's all there
was. Now that we have the wxWindows code, which implements both the VGAW
and the CUI, while all other platforms implement only the VGAW, it's not
so clear. So, I'm trying to use VGAW, CI, and CUI consistently since
they are more specific.
control panel: This has been used as another name for the configuration
interface. "control panel" is also somewhat unspecific and it sounds
like it would be graphical with buttons and sliders, but our text-mode
thing is not graphical at all. I've replaced "control panel" with
"configuration interface" wherever I could find it. In configure script,
the --disable-control-panel option is still supported, but it politely
suggests that you use --disable-config-interface instead.
- clean up comments in siminterface,wx* code
- add comments and examples for bx_param_* and BxEvents
- remove some obsolete stuff: notify_*_args,
bx_simulator_interface_c::[sg]et_enabled() methods
- in siminterface.cc, move a few bx_real_sim_c methods to where they belong,
with the rest of the methods. No changes to the actual methods.
- remove some DOS ^M's which crept in and confused my editor.
2002-08-26 19:31:23 +04:00
|
|
|
void bx_init_before_config_interface ();
|
2002-04-18 04:22:20 +04:00
|
|
|
|
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
|
|
|
|
|
|
|
char *bx_find_bochsrc (void);
|
2001-10-07 02:31:31 +04:00
|
|
|
int bx_parse_cmdline (int arg, int argc, char *argv[]);
|
2001-06-13 17:36:12 +04:00
|
|
|
int bx_read_configuration (char *rcfile);
|
2001-06-11 10:35:18 +04:00
|
|
|
int bx_write_configuration (char *rcfile, int overwrite);
|
2002-08-30 18:22:47 +04:00
|
|
|
void bx_reset_options (void);
|
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
|
|
|
|
|
|
|
typedef struct {
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_string_c *Opath;
|
|
|
|
bx_param_num_c *Oaddress;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_rom_options;
|
|
|
|
|
|
|
|
typedef struct {
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_string_c *Opath;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_vgarom_options;
|
|
|
|
|
|
|
|
typedef struct {
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_num_c *Osize;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_mem_options;
|
|
|
|
|
2001-11-12 05:35:09 +03:00
|
|
|
typedef struct {
|
2002-08-24 21:11:33 +04:00
|
|
|
bx_param_bool_c *Oenabled;
|
2001-11-12 05:35:09 +03:00
|
|
|
bx_param_string_c *Ooutfile;
|
|
|
|
} bx_parport_options;
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
typedef struct {
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_string_c *Opath;
|
|
|
|
bx_param_bool_c *OcmosImage;
|
|
|
|
bx_param_num_c *Otime0;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_cmos_options;
|
|
|
|
|
|
|
|
typedef struct {
|
2001-06-21 22:34:50 +04:00
|
|
|
bx_param_bool_c *Ovalid;
|
|
|
|
bx_param_num_c *Oioaddr;
|
|
|
|
bx_param_num_c *Oirq;
|
2001-06-21 23:27:05 +04:00
|
|
|
bx_param_string_c *Omacaddr;
|
2001-06-21 22:34:50 +04:00
|
|
|
bx_param_string_c *Oethmod;
|
|
|
|
bx_param_string_c *Oethdev;
|
2002-05-02 11:54:22 +04:00
|
|
|
bx_param_string_c *Oscript;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_ne2k_options;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
// These options are used for a special hack to load a
|
|
|
|
// 32bit OS directly into memory, so it can be run without
|
|
|
|
// any of the 16bit real mode or BIOS assistance. This
|
|
|
|
// is for the development of freemware, so we don't have
|
|
|
|
// to implement real mode up front.
|
2001-06-21 23:57:21 +04:00
|
|
|
#define Load32bitOSNone 0
|
2001-04-10 05:04:59 +04:00
|
|
|
#define Load32bitOSLinux 1
|
|
|
|
#define Load32bitOSNullKernel 2 // being developed for freemware
|
2001-06-20 18:01:39 +04:00
|
|
|
#define Load32bitOSLast 2
|
|
|
|
bx_param_num_c *OwhichOS;
|
|
|
|
bx_param_string_c *Opath;
|
|
|
|
bx_param_string_c *Oiolog;
|
|
|
|
bx_param_string_c *Oinitrd;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_load32bitOSImage_t;
|
|
|
|
|
2001-06-11 10:35:18 +04:00
|
|
|
typedef struct {
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_string_c *Ofilename;
|
2002-06-26 18:42:35 +04:00
|
|
|
bx_param_string_c *Oprefix;
|
2001-06-11 10:35:18 +04:00
|
|
|
// one array item for each log level, indexed by LOGLEV_*.
|
2001-06-11 18:03:35 +04:00
|
|
|
// values: ACT_IGNORE, ACT_REPORT, ACT_ASK, ACT_FATAL
|
2001-06-11 10:35:18 +04:00
|
|
|
unsigned char actions[N_LOGLEV];
|
|
|
|
} bx_log_options;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
typedef struct {
|
2001-06-21 22:34:50 +04:00
|
|
|
bx_param_bool_c *Opresent;
|
|
|
|
bx_param_string_c *Omidifile;
|
|
|
|
bx_param_string_c *Owavefile;
|
|
|
|
bx_param_string_c *Ologfile;
|
|
|
|
bx_param_num_c *Omidimode;
|
|
|
|
bx_param_num_c *Owavemode;
|
|
|
|
bx_param_num_c *Ologlevel;
|
|
|
|
bx_param_num_c *Odmatimer;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_sb16_options;
|
|
|
|
|
2001-12-14 20:56:37 +03:00
|
|
|
typedef struct {
|
|
|
|
bx_param_bool_c *OuseMapping;
|
|
|
|
bx_param_string_c *Okeymap;
|
|
|
|
} bx_keyboard_options;
|
|
|
|
|
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
|
|
|
|
#define BX_N_SERIAL_PORTS 1
|
|
|
|
#define BX_N_PARALLEL_PORTS 1
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
typedef struct {
|
|
|
|
bx_floppy_options floppya;
|
|
|
|
bx_floppy_options floppyb;
|
|
|
|
bx_disk_options diskc;
|
|
|
|
bx_disk_options diskd;
|
2002-09-03 12:34:17 +04:00
|
|
|
bx_serial_options com[BX_N_SERIAL_PORTS];
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_cdrom_options cdromd;
|
|
|
|
bx_rom_options rom;
|
|
|
|
bx_vgarom_options vgarom;
|
2002-09-03 09:38:09 +04:00
|
|
|
bx_rom_options optrom[BX_N_OPTROM_IMAGES]; // Optional rom images
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_mem_options memory;
|
2002-09-03 12:34:17 +04:00
|
|
|
bx_parport_options par[BX_N_PARALLEL_PORTS]; // parallel ports
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_sb16_options sb16;
|
2002-04-23 11:44:34 +04:00
|
|
|
bx_param_num_c *Obootdrive;
|
|
|
|
bx_param_bool_c *OfloppySigCheck;
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_num_c *Ovga_update_interval;
|
|
|
|
bx_param_num_c *Okeyboard_serial_delay;
|
2002-03-26 16:51:48 +03:00
|
|
|
bx_param_num_c *Okeyboard_paste_delay;
|
2001-12-12 13:43:36 +03:00
|
|
|
bx_param_enum_c *Okeyboard_type;
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_num_c *Ofloppy_command_delay;
|
|
|
|
bx_param_num_c *Oips;
|
|
|
|
bx_param_bool_c *Omouse_enabled;
|
|
|
|
bx_param_bool_c *Oprivate_colormap;
|
2001-08-16 16:35:52 +04:00
|
|
|
#if BX_WITH_AMIGAOS
|
2001-08-16 00:17:19 +04:00
|
|
|
bx_param_bool_c *Ofullscreen;
|
2001-08-16 06:00:31 +04:00
|
|
|
bx_param_string_c *Oscreenmode;
|
|
|
|
#endif
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_bool_c *Oi440FXSupport;
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_cmos_options cmos;
|
|
|
|
bx_ne2k_options ne2k;
|
2001-06-20 18:01:39 +04:00
|
|
|
bx_param_bool_c *OnewHardDriveSupport;
|
2001-04-10 05:04:59 +04:00
|
|
|
bx_load32bitOSImage_t load32bitOSImage;
|
2001-06-11 10:35:18 +04:00
|
|
|
bx_log_options log;
|
2001-12-14 20:56:37 +03:00
|
|
|
bx_keyboard_options keyboard;
|
2002-08-09 10:16:43 +04:00
|
|
|
bx_param_string_c *Ouser_shortcut;
|
2001-04-10 05:04:59 +04:00
|
|
|
} bx_options_t;
|
|
|
|
|
|
|
|
extern bx_options_t bx_options;
|
|
|
|
|
2001-06-19 20:25:41 +04:00
|
|
|
void bx_center_print (FILE *file, char *line, int maxwidth);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#if BX_PROVIDE_CPU_MEMORY==1
|
|
|
|
#else
|
|
|
|
// # include "external_interface.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BX_USE_PS2_MOUSE 1
|
|
|
|
|
2001-06-10 00:01:12 +04:00
|
|
|
int bx_init_hardware ();
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#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++.
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
#define WriteHostWordToLittleEndian(hostPtr, nativeVar16) \
|
|
|
|
*(hostPtr) = (nativeVar16)
|
|
|
|
#define WriteHostDWordToLittleEndian(hostPtr, nativeVar32) \
|
|
|
|
*(hostPtr) = (nativeVar32)
|
|
|
|
#define WriteHostQWordToLittleEndian(hostPtr, nativeVar64) \
|
|
|
|
*(hostPtr) = (nativeVar64)
|
|
|
|
#define ReadHostWordFromLittleEndian(hostPtr, nativeVar16) \
|
|
|
|
(nativeVar16) = *(hostPtr)
|
|
|
|
#define ReadHostDWordFromLittleEndian(hostPtr, nativeVar32) \
|
|
|
|
(nativeVar32) = *(hostPtr)
|
|
|
|
#define ReadHostQWordFromLittleEndian(hostPtr, nativeVar64) \
|
|
|
|
(nativeVar64) = *(hostPtr)
|
|
|
|
|
|
|
|
#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 */
|