2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2001-10-03 17:10:38 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-10-16 23:19:34 +03:00
|
|
|
// Copyright (C) 2001-2019 The Bochs Project
|
2001-04-10 05:04:59 +04:00
|
|
|
//
|
|
|
|
// 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
|
2010-02-12 01:12:17 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-04-10 05:58:07 +04:00
|
|
|
//
|
2008-02-06 01:57:43 +03:00
|
|
|
// bochs.h is the master header file for all C++ code. It includes all
|
2001-04-10 05:58:07 +04:00
|
|
|
// the system header files needed by bochs, and also includes all the bochs
|
2008-02-06 01:57:43 +03:00
|
|
|
// C++ header files. Because bochs.h and the files that it includes has
|
2001-04-10 05:58:07 +04:00
|
|
|
// structure and class definitions, it cannot be called from C code.
|
2008-02-06 01:57:43 +03:00
|
|
|
//
|
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.
|
2014-02-15 04:23:36 +04:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2002-10-04 01:07:04 +04:00
|
|
|
#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
|
|
|
|
2008-02-06 01:57:43 +03:00
|
|
|
#include "osdep.h" /* platform dependent includes and defines */
|
2006-09-26 23:16:10 +04:00
|
|
|
#include "bx_debug/debug.h"
|
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
|
2011-12-25 12:52:34 +04:00
|
|
|
int bx_begin_simulation(int argc, char *argv[]);
|
2006-03-12 01:40:32 +03:00
|
|
|
void bx_stop_simulation();
|
|
|
|
char *bx_find_bochsrc(void);
|
2017-04-22 13:17:54 +03:00
|
|
|
const char *get_builtin_variable(const char *varname);
|
2011-12-25 12:52:34 +04:00
|
|
|
int bx_parse_cmdline(int arg, int argc, char *argv[]);
|
|
|
|
int bx_read_configuration(const char *rcfile);
|
|
|
|
int bx_write_configuration(const char *rcfile, int overwrite);
|
2012-01-07 18:14:53 +04:00
|
|
|
void bx_reset_options(void);
|
2012-04-06 17:15:27 +04:00
|
|
|
void bx_set_log_actions_by_device(bx_bool panic_flag);
|
2012-01-07 18:14:53 +04:00
|
|
|
// special config parameter and options functions for plugins
|
2011-12-25 12:52:34 +04:00
|
|
|
void bx_init_std_nic_options(const char *name, bx_list_c *menu);
|
2012-01-08 16:43:46 +04:00
|
|
|
void bx_init_usb_options(const char *usb_name, const char *pname, int maxports);
|
2013-01-26 22:17:23 +04:00
|
|
|
int bx_parse_param_from_list(const char *context, const char *input, bx_list_c *list);
|
2011-12-25 12:52:34 +04:00
|
|
|
int bx_parse_nic_params(const char *context, const char *param, bx_list_c *base);
|
2012-01-07 18:14:53 +04:00
|
|
|
int bx_parse_usb_port_params(const char *context, bx_bool devopt,
|
|
|
|
const char *param, int maxports, bx_list_c *base);
|
2013-01-20 02:37:15 +04:00
|
|
|
int bx_write_param_list(FILE *fp, bx_list_c *base, const char *optname, bx_bool multiline);
|
2012-01-07 18:14:53 +04:00
|
|
|
int bx_write_usb_options(FILE *fp, int maxports, bx_list_c *base);
|
2014-10-14 19:59:10 +04:00
|
|
|
|
2006-01-28 19:16:03 +03:00
|
|
|
Bit32u crc32(const Bit8u *buf, int len);
|
2014-10-14 19:59:10 +04:00
|
|
|
|
|
|
|
// used to print param tree from debugger
|
2014-11-16 01:03:52 +03:00
|
|
|
void print_tree(bx_param_c *node, int level = 0, bx_bool xml = BX_FALSE);
|
2002-10-25 01:07:56 +04:00
|
|
|
|
2014-10-14 19:59:10 +04:00
|
|
|
#if BX_ENABLE_STATISTICS
|
|
|
|
// print statistics
|
|
|
|
void print_statistics_tree(bx_param_c *node, int level = 0);
|
|
|
|
#define INC_STAT(stat) (++(stat))
|
|
|
|
#else
|
|
|
|
#define INC_STAT(stat)
|
|
|
|
#endif
|
|
|
|
|
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)
|
|
|
|
|
2008-04-18 20:47:45 +04:00
|
|
|
#define BXRS_HEX_PARAM_SIMPLE32(parent, name) \
|
|
|
|
new bx_shadow_num_c(parent, #name, (Bit32u*)&(name), BASE_HEX)
|
|
|
|
#define BXRS_HEX_PARAM_SIMPLE64(parent, name) \
|
|
|
|
new bx_shadow_num_c(parent, #name, (Bit64u*)&(name), BASE_HEX)
|
|
|
|
|
2006-05-28 21:07:57 +04:00
|
|
|
#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
|
2012-10-03 19:49:45 +04:00
|
|
|
#define BX_RAISE_INTR() bx_pc_system.raise_INTR()
|
|
|
|
#define BX_CLEAR_INTR() bx_pc_system.clear_INTR()
|
2011-08-31 20:33:12 +04:00
|
|
|
#define BX_HRQ bx_pc_system.HRQ
|
2002-06-16 19:02:28 +04:00
|
|
|
|
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
|
2008-10-02 10:49:20 +04:00
|
|
|
# define A20ADDR(x) ((bx_phy_address)(x) & bx_pc_system.a20_mask)
|
2004-10-30 01:15:48 +04:00
|
|
|
#else
|
2008-10-02 10:49:20 +04:00
|
|
|
# define A20ADDR(x) ((bx_phy_address)(x))
|
2004-10-30 01:15:48 +04: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)
|
2015-02-19 23:23:08 +03:00
|
|
|
# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, memtype, rw, data) \
|
|
|
|
bx_dbg_lin_memory_access(cpu, lin, phy, len, memtype, rw, data)
|
|
|
|
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, memtype, rw, why, data) \
|
|
|
|
bx_dbg_phy_memory_access(cpu, phy, len, memtype, rw, why, data)
|
2001-04-10 05:04:59 +04:00
|
|
|
#else // #if BX_DEBUGGER
|
|
|
|
// debugger not compiled in, use empty stubs
|
|
|
|
# define BX_DBG_ASYNC_INTR 1
|
|
|
|
# define BX_DBG_ASYNC_DMA 1
|
2015-02-19 23:23:08 +03:00
|
|
|
# define BX_DBG_DMA_REPORT(addr, len, what, val) /* empty */
|
|
|
|
# define BX_DBG_IAC_REPORT(vector, irq) /* empty */
|
|
|
|
# define BX_DBG_A20_REPORT(val) /* empty */
|
|
|
|
# define BX_DBG_IO_REPORT(port, size, op, val) /* empty */
|
|
|
|
# define BX_DBG_LIN_MEMORY_ACCESS(cpu, lin, phy, len, memtype, rw, data) /* empty */
|
|
|
|
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, memtype, rw, attr, data) /* empty */
|
2001-04-10 05:04:59 +04:00
|
|
|
#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
|
|
|
|
|
2008-02-08 00:08:55 +03:00
|
|
|
typedef class BOCHSAPI logfunctions
|
|
|
|
{
|
2011-12-29 23:51:54 +04:00
|
|
|
char *name;
|
2008-02-08 00:08:55 +03:00
|
|
|
char *prefix;
|
|
|
|
int onoff[N_LOGLEV];
|
|
|
|
class iofunctions *logio;
|
|
|
|
// default log actions for all devices, declared and initialized
|
|
|
|
// in logio.cc.
|
|
|
|
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:
|
2008-02-08 00:08:55 +03:00
|
|
|
logfunctions(void);
|
|
|
|
logfunctions(class iofunctions *);
|
2014-11-22 14:43:40 +03:00
|
|
|
virtual ~logfunctions(void);
|
2008-02-08 00:08:55 +03: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);
|
|
|
|
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
2016-12-30 13:04:06 +03:00
|
|
|
void fatal1(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
2016-12-29 20:22:46 +03:00
|
|
|
void fatal(int level, const char *prefix, const char *fmt, va_list ap, int exit_status);
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
void warn(int level, const char *prefix, const char *fmt, va_list ap);
|
|
|
|
void ask(int level, const char *prefix, const char *fmt, va_list ap);
|
2011-12-29 23:51:54 +04:00
|
|
|
void put(const char *p);
|
|
|
|
void put(const char *n, const char *p);
|
2008-02-08 00:08:55 +03:00
|
|
|
void setio(class iofunctions *);
|
|
|
|
void setonoff(int loglev, int value) {
|
|
|
|
assert (loglev >= 0 && loglev < N_LOGLEV);
|
|
|
|
onoff[loglev] = value;
|
|
|
|
}
|
2012-03-28 01:30:34 +04:00
|
|
|
const char *get_name() const { return name; }
|
|
|
|
const char *getprefix() const { return prefix; }
|
|
|
|
int getonoff(int level) const {
|
2008-02-08 00:08:55 +03:00
|
|
|
assert (level>=0 && level<N_LOGLEV);
|
|
|
|
return onoff[level];
|
|
|
|
}
|
2012-03-28 01:30:34 +04:00
|
|
|
static void set_default_action(int loglev, int action) {
|
2008-02-08 00:08:55 +03:00
|
|
|
assert (loglev >= 0 && loglev < N_LOGLEV);
|
|
|
|
assert (action >= 0 && action < N_ACT);
|
|
|
|
default_onoff[loglev] = action;
|
|
|
|
}
|
2012-03-28 01:30:34 +04:00
|
|
|
static int get_default_action(int loglev) {
|
2008-02-08 00:08:55 +03:00
|
|
|
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;
|
|
|
|
|
2013-12-29 14:41:11 +04:00
|
|
|
#define BX_LOGPREFIX_LEN 20
|
2002-06-26 18:42:35 +04:00
|
|
|
|
2002-10-25 01:07:56 +04:00
|
|
|
class BOCHSAPI iofunctions {
|
2008-02-08 00:08:55 +03:00
|
|
|
int magic;
|
2013-12-29 14:41:11 +04:00
|
|
|
char logprefix[BX_LOGPREFIX_LEN + 1];
|
2008-02-08 00:08:55 +03:00
|
|
|
FILE *logfd;
|
|
|
|
class logfunctions *log;
|
|
|
|
void init(void);
|
|
|
|
void flush(void);
|
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
|
|
|
// 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:
|
2008-02-08 00:08:55 +03:00
|
|
|
iofunctions(void);
|
|
|
|
iofunctions(FILE *);
|
|
|
|
iofunctions(int);
|
|
|
|
iofunctions(const char *);
|
|
|
|
~iofunctions(void);
|
|
|
|
|
2009-01-10 14:47:10 +03:00
|
|
|
void out(int level, const char *pre, const char *fmt, va_list ap);
|
2008-02-08 00:08:55 +03:00
|
|
|
|
|
|
|
void init_log(const char *fn);
|
|
|
|
void init_log(int fd);
|
|
|
|
void init_log(FILE *fs);
|
|
|
|
void exit_log();
|
|
|
|
void set_log_prefix(const char *prefix);
|
2012-03-28 01:30:34 +04:00
|
|
|
int get_n_logfns() const { return n_logfn; }
|
2008-02-08 00:08:55 +03:00
|
|
|
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);
|
2012-03-28 01:30:34 +04:00
|
|
|
const char *getlevel(int i) const;
|
|
|
|
const char *getaction(int i) const;
|
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/bochs.h ./bochs.h
--- /home/volker/bochs/bochs/bochs.h 2016-08-12 19:06:18.803209189 +0200
+++ ./bochs.h 2016-12-28 00:41:20.000627252 +0100
@@ -2,7 +2,7 @@
// $Id: bochs.h 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2015 The Bochs Project
+// Copyright (C) 2001-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -276,8 +276,9 @@
void error(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void panic(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
void ldebug(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
- void fatal (const char *prefix, const char *fmt, va_list ap, int exit_status);
- void ask (int level, const char *prefix, const char *fmt, va_list ap);
+ void fatal(const char *prefix, const char *fmt, va_list ap, int exit_status);
+ void warn(int level, const char *prefix, const char *fmt, va_list ap);
+ void ask(int level, const char *prefix, const char *fmt, va_list ap);
void put(const char *p);
void put(const char *n, const char *p);
void setio(class iofunctions *);
@@ -334,7 +335,8 @@
void set_log_action(int loglevel, int action);
const char *getlevel(int i) const;
const char *getaction(int i) const;
-
+ int isaction(const char *val) const;
+
protected:
int n_logfn;
#define MAX_LOGFNS 512
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/CHANGES ./CHANGES
--- /home/volker/bochs/bochs/CHANGES 2016-12-26 10:45:44.000000000 +0100
+++ ./CHANGES 2016-12-28 15:54:25.127088081 +0100
@@ -1,5 +1,8 @@
Changes after 2.6.8 release:
+- General
+ - Added new log action "warn", designed to show a message box on error events.
+
- Configure and compile
- Added Android host platform support.
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/config.cc ./config.cc
--- /home/volker/bochs/bochs/config.cc 2016-05-03 21:15:09.158016000 +0200
+++ ./config.cc 2016-12-27 19:53:10.461420368 +0100
@@ -2062,15 +2062,8 @@
actstr = strtok(NULL, "");
if (actstr != NULL) {
def_action = !strcmp(module, "action");
- if (!strcmp(actstr, "fatal"))
- action = ACT_FATAL;
- else if (!strcmp (actstr, "report"))
- action = ACT_REPORT;
- else if (!strcmp (actstr, "ignore"))
- action = ACT_IGNORE;
- else if (!strcmp (actstr, "ask"))
- action = ACT_ASK;
- else {
+ action = SIM->is_action_name(actstr);
+ if (action < ACT_IGNORE) {
PARSE_ERR(("%s: %s directive malformed.", context, params[0]));
free(param);
return -1;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/sdl2.cc ./gui/sdl2.cc
--- /home/volker/bochs/bochs/gui/sdl2.cc 2016-08-12 19:06:18.811209142 +0200
+++ ./gui/sdl2.cc 2016-12-28 12:33:39.534288819 +0100
@@ -2,7 +2,7 @@
// $Id: sdl2.cc 12935 2016-08-12 17:06:14Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2014-2015 The Bochs Project
+// Copyright (C) 2014-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -1478,20 +1478,16 @@
SDL_MessageBoxData msgboxdata;
SDL_MessageBoxButtonData buttondata[4];
int level, retcode;
-#if BX_DEBUGGER || BX_GDBSTUB
- int defbtn = 3;
-#else
- int defbtn = 2;
-#endif
char message[512];
level = event->u.logmsg.level;
- sprintf(message, "%s %s", event->u.logmsg.prefix, event->u.logmsg.msg);
+ sprintf(message, "Device: %s\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
msgboxdata.flags = SDL_MESSAGEBOX_ERROR;
msgboxdata.window = window;
msgboxdata.title = SIM->get_log_level_name(level);
msgboxdata.message = message;
- msgboxdata.numbuttons = defbtn + 1;
+ msgboxdata.numbuttons = 2;
msgboxdata.buttons = buttondata;
msgboxdata.colorScheme = NULL;
buttondata[0].flags = 0;
@@ -1500,14 +1496,18 @@
buttondata[1].flags = 0;
buttondata[1].buttonid = BX_LOG_ASK_CHOICE_CONTINUE_ALWAYS;
buttondata[1].text = "Alwayscont";
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ msgboxdata.numbuttons = 3;
+ buttondata[2].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
+ buttondata[2].buttonid = BX_LOG_ASK_CHOICE_DIE;
+ buttondata[2].text = "Quit";
#if BX_DEBUGGER || BX_GDBSTUB
- buttondata[2].flags = 0;
- buttondata[2].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
- buttondata[2].text = "Debugger";
-#endif
- buttondata[defbtn].flags = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT;
- buttondata[defbtn].buttonid = BX_LOG_ASK_CHOICE_DIE;
- buttondata[defbtn].text = "Quit";
+ msgboxdata.numbuttons = 4;
+ buttondata[3].flags = 0;
+ buttondata[3].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
+ buttondata[3].text = "Debugger";
+#endif
+ }
if (SDL_ShowMessageBox(&msgboxdata, &retcode) < 0) {
return -1;
} else {
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.cc ./gui/siminterface.cc
--- /home/volker/bochs/bochs/gui/siminterface.cc 2016-12-05 19:56:56.729685000 +0100
+++ ./gui/siminterface.cc 2016-12-28 11:14:02.004075717 +0100
@@ -2,7 +2,7 @@
// $Id: siminterface.cc 12981 2016-12-05 18:56:56Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2015 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -100,6 +100,7 @@
virtual int get_log_action(int mod, int level);
virtual void set_log_action(int mod, int level, int action);
virtual const char *get_action_name(int action);
+ virtual int is_action_name(const char *val);
virtual int get_default_log_action(int level) {
return logfunctions::get_default_action(level);
}
@@ -123,6 +124,7 @@
virtual void set_notify_callback(bxevent_handler func, void *arg);
virtual void get_notify_callback(bxevent_handler *func, void **arg);
virtual BxEvent* sim_to_ci_event(BxEvent *event);
+ virtual int log_warn(const char *prefix, int level, const char *msg);
virtual int log_ask(const char *prefix, int level, const char *msg);
virtual void log_msg(const char *prefix, int level, const char *msg);
virtual void set_log_viewer(bx_bool val) { bx_log_viewer = val; }
@@ -420,6 +422,11 @@
return io->getaction(action);
}
+int bx_real_sim_c::is_action_name(const char *val)
+{
+ return io->isaction(val);
+}
+
const char *bx_real_sim_c::get_log_level_name(int level)
{
return io->getlevel(level);
@@ -575,6 +582,21 @@
}
}
+int bx_real_sim_c::log_warn(const char *prefix, int level, const char *msg)
+{
+ BxEvent be;
+ be.type = BX_SYNC_EVT_LOG_ASK;
+ be.u.logmsg.prefix = prefix;
+ be.u.logmsg.level = level;
+ be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_MSGBOX_WARN;
+ // default return value in case something goes wrong.
+ be.retcode = BX_LOG_NOTIFY_FAILED;
+ // calling notify
+ sim_to_ci_event(&be);
+ return be.retcode;
+}
+
// returns 0 for continue, 1 for alwayscontinue, 2 for die.
int bx_real_sim_c::log_ask(const char *prefix, int level, const char *msg)
{
@@ -583,6 +605,7 @@
be.u.logmsg.prefix = prefix;
be.u.logmsg.level = level;
be.u.logmsg.msg = msg;
+ be.u.logmsg.flag = BX_LOG_ASK_ASKDLG;
// default return value in case something goes wrong.
be.retcode = BX_LOG_NOTIFY_FAILED;
// calling notify
@@ -1157,16 +1180,10 @@
} else if (!strncmp(string, "PANIC=", 6)) {
type = LOGLEV_PANIC;
}
- if (!strcmp(string+j, "ignore")) {
- action = ACT_IGNORE;
- } else if (!strcmp(string+j, "report")) {
- action = ACT_REPORT;
- } else if (!strcmp(string+j, "ask")) {
- action = ACT_ASK;
- } else if (!strcmp(string+j, "fatal")) {
- action = ACT_FATAL;
+ action = is_action_name(string+j);
+ if (action >= ACT_IGNORE) {
+ set_log_action(dev, type, action);
}
- set_log_action(dev, type, action);
} else {
if (i == 1) {
BX_ERROR(("restore_logopts(): log module '%s' not found", devname));
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/siminterface.h ./gui/siminterface.h
--- /home/volker/bochs/bochs/gui/siminterface.h 2016-03-31 19:24:37.451025427 +0200
+++ ./gui/siminterface.h 2016-12-28 11:11:21.036683362 +0100
@@ -168,6 +168,7 @@
typedef enum {
ACT_IGNORE = 0,
ACT_REPORT,
+ ACT_WARN,
ACT_ASK,
ACT_FATAL,
N_ACT
@@ -178,11 +179,11 @@
// normally all action choices are available for all event types. The exclude
// expression allows some choices to be eliminated if they don't make any
// sense. For example, it would be stupid to ignore a panic.
-#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
- /* can't die or ask, on debug or info events */ \
- (type <= LOGLEV_INFO && (choice == ACT_ASK || choice == ACT_FATAL)) \
- /* can't ignore panics */ \
- || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
+#define BX_LOG_OPTS_EXCLUDE(type, choice) ( \
+ /* can't die, ask or warn, on debug or info events */ \
+ (type <= LOGLEV_INFO && (choice >= ACT_WARN)) \
+ /* can't ignore panics */ \
+ || (type == LOGLEV_PANIC && choice == ACT_IGNORE) \
)
// floppy / cdrom media status
@@ -392,6 +393,7 @@
// synchronizing threads, etc. for each.
typedef struct {
Bit8u level;
+ Bit8u flag;
const char *prefix;
const char *msg;
} BxLogMsgEvent;
@@ -419,6 +421,12 @@
BX_LOG_NOTIFY_FAILED
};
+enum {
+ BX_LOG_ASK_ASKDLG,
+ BX_LOG_ASK_MSGBOX_WARN,
+ BX_LOG_ASK_MSGBOX_QUIT
+};
+
// Event type: BX_SYNC_EVT_GET_DBG_COMMAND
//
// This is a synchronous event sent from the simulator to the debugger
@@ -675,6 +683,7 @@
virtual int get_default_log_action(int level) {return -1;}
virtual void set_default_log_action(int level, int action) {}
virtual const char *get_action_name(int action) {return NULL;}
+ virtual int is_action_name(const char *val) {return -1;}
virtual const char *get_log_level_name(int level) {return NULL;}
virtual int get_max_log_level() {return -1;}
@@ -715,6 +724,9 @@
// send an event from the simulator to the CI.
virtual BxEvent* sim_to_ci_event(BxEvent *event) {return NULL;}
+ // called from simulator when it hits errors, to warn the user
+ // before continuing simulation
+ virtual int log_warn(const char *prefix, int level, const char *msg) {return -1;}
// called from simulator when it hits serious errors, to ask if the user
// wants to continue or not
virtual int log_ask(const char *prefix, int level, const char *msg) {return -1;}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/textconfig.cc ./gui/textconfig.cc
--- /home/volker/bochs/bochs/gui/textconfig.cc 2016-12-05 20:15:59.112637000 +0100
+++ ./gui/textconfig.cc 2016-12-28 12:44:43.079411258 +0100
@@ -2,7 +2,7 @@
// $Id: textconfig.cc 12983 2016-12-05 19:15:59Z sshwarts $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2013 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -552,8 +552,8 @@
}
static const char *log_options_prompt1 = "Enter the ID of the device to edit, or -1 to return: [-1] ";
-static const char *log_level_choices[] = { "ignore", "report", "ask", "fatal", "no change" };
-static int log_level_n_choices_normal = 4;
+static const char *log_level_choices[N_ACT+1] = { "ignore", "report", "warn", "ask", "fatal", "no change" };
+static int log_level_n_choices_normal = N_ACT;
void bx_log_options(int individual)
{
@@ -589,7 +589,7 @@
bx_print_log_action_table();
for (int level=0; level<SIM->get_max_log_level(); level++) {
char prompt[1024];
- int action, default_action = 4; // default to no change
+ int action, default_action = N_ACT; // default to no change
sprintf(prompt, "Enter action for %s event on all devices: [no change] ", SIM->get_log_level_name(level));
// do show the no change choice (choices=4)
if (ask_menu(prompt, "", log_level_n_choices_normal+1, log_level_choices, default_action, &action)<0)
@@ -718,47 +718,50 @@
event->retcode = event->u.param.param->text_ask(stdin, stderr);
return event;
case BX_SYNC_EVT_LOG_ASK:
- {
- int level = event->u.logmsg.level;
- fprintf(stderr, "========================================================================\n");
- fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
- fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
- fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
- fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
- fprintf(stderr, " cont - continue execution\n");
- fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
- fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
- fprintf(stderr, " die - stop execution now\n");
- fprintf(stderr, " abort - dump core %s\n",
- BX_HAVE_ABORT ? "" : "(Disabled)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ int level = event->u.logmsg.level;
+ fprintf(stderr, "========================================================================\n");
+ fprintf(stderr, "Event type: %s\n", SIM->get_log_level_name (level));
+ fprintf(stderr, "Device: %s\n", event->u.logmsg.prefix);
+ fprintf(stderr, "Message: %s\n\n", event->u.logmsg.msg);
+ fprintf(stderr, "A %s has occurred. Do you want to:\n", SIM->get_log_level_name (level));
+ fprintf(stderr, " cont - continue execution\n");
+ fprintf(stderr, " alwayscont - continue execution, and don't ask again.\n");
+ fprintf(stderr, " This affects only %s events from device %s\n", SIM->get_log_level_name (level), event->u.logmsg.prefix);
+ fprintf(stderr, " die - stop execution now\n");
+ fprintf(stderr, " abort - dump core %s\n",
+ BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
- fprintf(stderr, " debug - continue and return to bochs debugger\n");
+ fprintf(stderr, " debug - continue and return to bochs debugger\n");
#endif
#if BX_GDBSTUB
- fprintf(stderr, " debug - hand control to gdb\n");
+ fprintf(stderr, " debug - hand control to gdb\n");
#endif
- int choice;
+ int choice;
ask:
- if (ask_menu("Choose one of the actions above: [%s] ", "",
- log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
- event->retcode = -1;
- // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
- if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
- fflush(stdout);
- fflush(stderr);
- event->retcode = choice;
- }
- return event;
- case BX_ASYNC_EVT_REFRESH:
- case BX_ASYNC_EVT_DBG_MSG:
- case BX_ASYNC_EVT_LOG_MSG:
- // The text mode interface does not use these events, so just ignore
- // them.
- return event;
- default:
- fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
- return event;
+ if (ask_menu("Choose one of the actions above: [%s] ", "",
+ log_action_n_choices, log_action_ask_choices, 2, &choice) < 0)
+ event->retcode = -1;
+ // return 0 for continue, 1 for alwayscontinue, 2 for die, 3 for debug.
+ if (!BX_HAVE_ABORT && choice==BX_LOG_ASK_CHOICE_DUMP_CORE) goto ask;
+ fflush(stdout);
+ fflush(stderr);
+ event->retcode = choice;
+ } else {
+ // warning prompt not implemented
+ event->retcode = 0;
+ }
+ return event;
+ case BX_ASYNC_EVT_REFRESH:
+ case BX_ASYNC_EVT_DBG_MSG:
+ case BX_ASYNC_EVT_LOG_MSG:
+ // The text mode interface does not use these events, so just ignore
+ // them.
+ return event;
+ default:
+ fprintf(stderr, "textconfig: notify callback called with event type %04x\n", event->type);
+ return event;
}
assert(0); // switch statement should return
}
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/win32dialog.cc ./gui/win32dialog.cc
--- /home/volker/bochs/bochs/gui/win32dialog.cc 2014-06-20 11:32:02.034026376 +0200
+++ ./gui/win32dialog.cc 2016-12-28 12:50:14.148888740 +0100
@@ -2,7 +2,7 @@
// $Id: win32dialog.cc 12381 2014-06-20 09:31:56Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2003-2014 The Bochs Project
+// Copyright (C) 2003-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
#include "win32res.h"
#include "win32paramdlg.h"
-const char log_choices[5][16] = {"ignore", "log", "ask user", "end simulation", "no change"};
+const char log_choices[N_ACT+1][16] = {"ignore", "log", "warn user", "ask user", "end simulation", "no change"};
HWND GetBochsWindow()
{
@@ -97,12 +97,16 @@
SetWindowText(GetDlgItem(hDlg, IDASKMSG), event->u.logmsg.msg);
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and don't ask again");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
#endif
- SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
+ } else {
+ SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 0, 0);
+ }
SetFocus(GetDlgItem(hDlg, IDASKLIST));
return FALSE;
case WM_CLOSE:
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.cc ./gui/wxdialog.cc
--- /home/volker/bochs/bochs/gui/wxdialog.cc 2015-01-07 17:17:40.447882000 +0100
+++ ./gui/wxdialog.cc 2016-12-27 20:30:44.997609007 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.cc 12594 2015-01-07 16:17:40Z sshwarts $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -208,7 +208,6 @@
: wxDialog(parent, id, wxT(""), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
- //static int integers[LOG_OPTS_N_CHOICES_NORMAL] = {0, 1, 2, 3};
static wxString names[] = ADVLOG_OPTS_TYPE_NAMES;
SetTitle(ADVLOG_OPTS_TITLE);
vertSizer = new wxBoxSizer(wxVERTICAL);
@@ -1563,7 +1562,7 @@
bool includeNoChange)
{
static wxString choices[] = LOG_OPTS_CHOICES;
- static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4};
+ static int integers[LOG_OPTS_N_CHOICES] = {0, 1, 2, 3, 4, 5};
wxChoice *control = new wxChoice(parent, id, wxDefaultPosition, wxDefaultSize);
int lastChoice = 0; // remember index of last choice
int nchoice = includeNoChange? LOG_OPTS_N_CHOICES : LOG_OPTS_N_CHOICES_NORMAL;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxdialog.h ./gui/wxdialog.h
--- /home/volker/bochs/bochs/gui/wxdialog.h 2014-12-23 20:30:12.896090221 +0100
+++ ./gui/wxdialog.h 2016-12-27 20:34:28.518389938 +0100
@@ -2,7 +2,7 @@
// $Id: wxdialog.h 12576 2014-12-23 19:30:03Z vruppert $
////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -354,10 +354,10 @@
#define LOG_OPTS_PROMPT wxT("How should Bochs respond to each type of event?")
#define LOG_OPTS_TYPE_NAMES { wxT("Debug events"), wxT("Info events"), wxT("Error events"), wxT("Panic events") }
#define LOG_OPTS_N_TYPES 4
-#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
-#define LOG_OPTS_N_CHOICES_NORMAL 4
-#define LOG_OPTS_N_CHOICES 5 // number of choices, including "no change"
-#define LOG_OPTS_NO_CHANGE 4 // index of "no change"
+#define LOG_OPTS_CHOICES { wxT("ignore"), wxT("log"), wxT("warn user"), wxT("ask user"), wxT("end simulation"), wxT("no change") }
+#define LOG_OPTS_N_CHOICES_NORMAL 5
+#define LOG_OPTS_N_CHOICES 6 // number of choices, including "no change"
+#define LOG_OPTS_NO_CHANGE 5 // index of "no change"
#define LOG_OPTS_ADV wxT("For additional control over how each device responds to events, use the menu option \"Log ... By Device\".")
wxFlexGridSizer *gridSizer;
wxChoice *action[LOG_OPTS_N_TYPES];
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/wxmain.cc ./gui/wxmain.cc
--- /home/volker/bochs/bochs/gui/wxmain.cc 2016-12-26 17:12:57.470174541 +0100
+++ ./gui/wxmain.cc 2016-12-28 12:15:26.035961463 +0100
@@ -2,7 +2,7 @@
// $Id: wxmain.cc 13006 2016-12-26 16:12:54Z vruppert $
/////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2002-2014 The Bochs Project
+// Copyright (C) 2002-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -1158,6 +1158,10 @@
#if !BX_DEBUGGER && !BX_GDBSTUB
dlg.EnableButton(dlg.DEBUG, FALSE);
#endif
+ if (be->u.logmsg.flag != BX_LOG_ASK_ASKDLG) {
+ dlg.EnableButton(dlg.DIE, FALSE);
+ dlg.EnableButton(dlg.DUMP, FALSE);
+ }
dlg.SetContext(wxString(be->u.logmsg.prefix, wxConvUTF8));
dlg.SetMessage(wxString(be->u.logmsg.msg, wxConvUTF8));
int n = dlg.ShowModal();
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/gui/x.cc ./gui/x.cc
--- /home/volker/bochs/bochs/gui/x.cc 2016-12-27 17:26:59.622665119 +0100
+++ ./gui/x.cc 2016-12-28 12:03:10.963351647 +0100
@@ -2687,11 +2687,7 @@
} else {
size_x = 30 + maxlen * 6;
}
- if (lines < 3) {
- size_y = 90;
- } else {
- size_y = 60 + lines * 15;
- }
+ size_y = 70 + lines * 15;
x11_dialog_c *xdlg = new x11_dialog_c(name, size_x, size_y,
(mode == XDLG_SIMPLE) ? 1 : 2);
ypos = 34;
@@ -2729,11 +2725,21 @@
bx_param_string_c *sparam;
bx_param_enum_c *eparam;
bx_list_c *list;
+ char message[256];
switch (event->type)
{
case BX_SYNC_EVT_LOG_ASK:
- event->retcode = x11_ask_dialog(event);
+ if (event->u.logmsg.flag == BX_LOG_ASK_ASKDLG) {
+ event->retcode = x11_ask_dialog(event);
+ } else if (event->u.logmsg.flag == BX_LOG_ASK_MSGBOX_WARN) {
+ const char *title = SIM->get_log_level_name(event->u.logmsg.level);
+ sprintf(message, "Device: %s\n\nMessage: %s", event->u.logmsg.prefix,
+ event->u.logmsg.msg);
+ bx_param_bool_c bparam(NULL, "warn", title, message, 1);
+ x11_message_box(&bparam, XDLG_SIMPLE);
+ event->retcode = 0;
+ }
return event;
case BX_SYNC_EVT_ASK_PARAM:
param = event->u.param.param;
diff -urNX /home/volker/exclude-bochs /home/volker/bochs/bochs/logio.cc ./logio.cc
--- /home/volker/bochs/bochs/logio.cc 2015-05-10 08:55:18.678940963 +0200
+++ ./logio.cc 2016-12-28 00:40:40.395736643 +0100
@@ -2,7 +2,7 @@
// $Id: logio.cc 12759 2015-05-10 06:55:16Z vruppert $
/////////////////////////////////////////////////////////////////////////
//
-// Copyright (C) 2001-2014 The Bochs Project
+// Copyright (C) 2001-2016 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@ -50,11 +50,25 @@
else return "?";
}
+static const char *act_name[N_ACT] = { "ignore", "report", "warn", "ask", "fatal" };
+
const char* iofunctions::getaction(int i) const
{
- static const char *name[] = { "ignore", "report", "ask", "fatal" };
assert (i>=ACT_IGNORE && i<N_ACT);
- return name[i];
+ return act_name[i];
+}
+
+int iofunctions::isaction(const char *val) const
+{
+ int action = -1;
+
+ for (int i = 0; i < N_ACT; i++) {
+ if (!strcmp(val, act_name[i])) {
+ action = ACT_IGNORE + i;
+ break;
+ }
+ }
+ return action;
}
void iofunctions::flush(void)
@@ -414,6 +428,11 @@
logio->out(LOGLEV_ERROR, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_ERROR] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_ERROR, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_ERROR] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_ERROR, prefix, fmt, ap);
@@ -438,6 +457,11 @@
logio->out(LOGLEV_PANIC, prefix, fmt, ap);
va_end(ap);
+ if (onoff[LOGLEV_PANIC] == ACT_WARN) {
+ va_start(ap, fmt);
+ warn(LOGLEV_PANIC, prefix, fmt, ap);
+ va_end(ap);
+ }
if (onoff[LOGLEV_PANIC] == ACT_ASK) {
va_start(ap, fmt);
ask(LOGLEV_PANIC, prefix, fmt, ap);
@@ -465,6 +489,36 @@
// the actions ask() and fatal() are not supported here
}
+void logfunctions::warn(int level, const char *prefix, const char *fmt, va_list ap)
+{
+ // Guard against reentry on warn() function. The danger is that some
+ // function that's called within warn() could trigger another
+ // BX_ERROR that could call warn() again, leading to infinite
+ // recursion and infinite asks.
+ static char in_warn_already = 0;
+ char buf1[1024];
+ if (in_warn_already) {
+ fprintf(stderr, "logfunctions::warn() should not reenter!!\n");
+ return;
+ }
+ in_warn_already = 1;
+ vsnprintf(buf1, sizeof(buf1), fmt, ap);
+ // FIXME: facility set to 0 because it's unknown.
+
+ // update vga screen. This is useful because sometimes useful messages
+ // are printed on the screen just before a panic. It's also potentially
+ // dangerous if this function calls ask again... That's why I added
+ // the reentry check above.
+ SIM->refresh_vga();
+
+ // ensure the text screen is showing
+ SIM->set_display_mode(DISP_MODE_CONFIG);
+ SIM->log_warn(prefix, level, buf1);
+ // return to simulation mode
+ SIM->set_display_mode(DISP_MODE_SIM);
+ in_warn_already = 0;
+}
+
void logfunctions::ask(int level, const char *prefix, const char *fmt, va_list ap)
{
// Guard against reentry on ask() function. The danger is that some
2016-12-28 18:06:34 +03:00
|
|
|
int isaction(const char *val) const;
|
|
|
|
|
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:
|
2008-02-08 00:08:55 +03:00
|
|
|
int n_logfn;
|
2009-02-20 18:38:36 +03:00
|
|
|
#define MAX_LOGFNS 512
|
2008-02-08 00:08:55 +03:00
|
|
|
logfunc_t *logfn_list[MAX_LOGFNS];
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2013-11-07 23:38:23 +04:00
|
|
|
typedef class 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
|
2016-12-30 13:04:06 +03:00
|
|
|
#define BX_FATAL(x) (LOG_THIS fatal1) 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
|
|
|
|
2008-05-10 22:04:37 +04:00
|
|
|
#define BX_ASSERT(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
|
2016-12-30 13:04:06 +03:00
|
|
|
#define BX_FATAL(x) (LOG_THIS fatal1) 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
|
|
|
|
2008-06-13 01:02:54 +04:00
|
|
|
#if BX_ASSERT_ENABLE
|
|
|
|
#define BX_ASSERT(x) do {if (!(x)) BX_PANIC(("failed assertion \"%s\" at %s:%d\n", #x, __FILE__, __LINE__));} while (0)
|
|
|
|
#else
|
|
|
|
#define BX_ASSERT(x)
|
|
|
|
#endif
|
2008-05-10 22:04:37 +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
|
|
|
#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
|
|
|
|
|
2011-03-16 01:18:40 +03:00
|
|
|
//Generic MAX and MIN Functions
|
|
|
|
#define BX_MAX(a,b) ((a) > (b) ? (a) : (b))
|
|
|
|
#define BX_MIN(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
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
|
|
|
|
2008-05-11 00:39:53 +04:00
|
|
|
#if BX_PHY_ADDRESS_LONG
|
2013-02-13 01:26:23 +04:00
|
|
|
#define FMT_PHY_ADDRX FMT_PHY_ADDRX64
|
2008-05-11 00:39:53 +04:00
|
|
|
#else
|
|
|
|
#define FMT_PHY_ADDRX FMT_ADDRX32
|
|
|
|
#endif
|
|
|
|
|
2008-05-10 02:33:37 +04:00
|
|
|
#define FMT_LIN_ADDRX FMT_ADDRX
|
|
|
|
|
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 interrupts;
|
|
|
|
bx_bool exceptions;
|
2007-11-20 21:36:26 +03:00
|
|
|
bx_bool print_timestamps;
|
2008-01-22 00:36:58 +03:00
|
|
|
#if BX_DEBUGGER
|
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;
|
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
|
2008-02-08 00:08:55 +03:00
|
|
|
} bx_debug_t;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2012-08-26 16:32:10 +04:00
|
|
|
#if BX_SHOW_IPS
|
|
|
|
BOCHSAPI_MSVCONLY void bx_show_ips_handler(void);
|
|
|
|
#endif
|
|
|
|
void CDECL 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
|
|
|
|
2011-04-21 17:27:42 +04:00
|
|
|
#if BX_SUPPORT_APIC
|
2010-05-15 13:23:50 +04:00
|
|
|
// determinted by XAPIC option
|
|
|
|
BOCHSAPI extern Bit32u apic_id_mask;
|
2011-04-21 17:27:42 +04:00
|
|
|
#endif
|
2010-05-15 13:23:50 +04:00
|
|
|
|
2008-12-06 01:34:42 +03:00
|
|
|
// memory access type (read/write/execute/rw)
|
2004-10-30 01:15:48 +04:00
|
|
|
#define BX_READ 0
|
|
|
|
#define BX_WRITE 1
|
2008-12-06 01:34:42 +03:00
|
|
|
#define BX_EXECUTE 2
|
|
|
|
#define BX_RW 3
|
2004-12-17 01:21:35 +03:00
|
|
|
|
2009-11-15 23:50:41 +03:00
|
|
|
// types of reset
|
|
|
|
#define BX_RESET_SOFTWARE 10
|
|
|
|
#define BX_RESET_HARDWARE 11
|
|
|
|
|
2016-08-12 20:06:14 +03:00
|
|
|
#include "memory/memory-bochs.h"
|
2001-04-10 05:04:59 +04:00
|
|
|
#include "pc_system.h"
|
|
|
|
#include "gui/gui.h"
|
|
|
|
|
|
|
|
/* --- EXTERNS --- */
|
|
|
|
|
2002-11-11 20:09:57 +03:00
|
|
|
#if BX_GUI_SIGHANDLER
|
|
|
|
extern bx_bool bx_gui_sighandler;
|
|
|
|
#endif
|
|
|
|
|
2012-10-30 21:25:33 +04:00
|
|
|
// This value controls how often each I/O device's timer handler
|
2002-03-26 16:59:35 +03:00
|
|
|
// gets called. The timer is set up in iodev/devices.cc.
|
2012-10-30 21:25:33 +04:00
|
|
|
#define BX_IODEV_HANDLER_PERIOD 1000 // 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
|
2008-02-06 01:57:43 +03:00
|
|
|
#define BX_KBD_MF_TYPE 2
|
2001-12-12 13:43:36 +03:00
|
|
|
|
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
|
2004-06-29 23:24:34 +04:00
|
|
|
#define BX_N_PCI_SLOTS 5
|
2009-01-02 14:51:03 +03:00
|
|
|
#define BX_N_USER_PLUGINS 8
|
2002-09-03 12:34:17 +04:00
|
|
|
|
2008-01-01 21:12:31 +03:00
|
|
|
void bx_center_print(FILE *file, const char *line, unsigned maxwidth);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#include "instrument.h"
|
|
|
|
|
2011-12-29 02:43:18 +04:00
|
|
|
BX_CPP_INLINE Bit16u bx_bswap16(Bit16u val16)
|
|
|
|
{
|
|
|
|
return (val16<<8) | (val16>>8);
|
|
|
|
}
|
|
|
|
|
2013-05-24 21:58:49 +04:00
|
|
|
#if !defined(__MORPHOS__)
|
2011-12-29 02:43:18 +04:00
|
|
|
#if BX_HAVE___BUILTIN_BSWAP32
|
|
|
|
#define bx_bswap32 __builtin_bswap32
|
|
|
|
#else
|
|
|
|
BX_CPP_INLINE Bit32u bx_bswap32(Bit32u val32)
|
|
|
|
{
|
|
|
|
val32 = ((val32<<8) & 0xFF00FF00) | ((val32>>8) & 0x00FF00FF);
|
|
|
|
return (val32<<16) | (val32>>16);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if BX_HAVE___BUILTIN_BSWAP64
|
|
|
|
#define bx_bswap64 __builtin_bswap64
|
|
|
|
#else
|
|
|
|
BX_CPP_INLINE Bit64u bx_bswap64(Bit64u val64)
|
|
|
|
{
|
|
|
|
Bit32u lo = bx_bswap32((Bit32u)(val64 >> 32));
|
|
|
|
Bit32u hi = bx_bswap32((Bit32u)(val64 & 0xFFFFFFFF));
|
|
|
|
return ((Bit64u)hi << 32) | (Bit64u)lo;
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-24 21:58:49 +04:00
|
|
|
#endif // !MorphOS
|
2011-12-29 02:43:18 +04:00
|
|
|
|
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
|
|
|
|
2019-10-16 23:19:34 +03:00
|
|
|
BX_CPP_INLINE void WriteHostWordToLittleEndian(Bit16u *hostPtr, Bit16u nativeVar16)
|
|
|
|
{
|
|
|
|
*(hostPtr) = nativeVar16;
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostDWordToLittleEndian(Bit32u *hostPtr, Bit32u nativeVar32)
|
|
|
|
{
|
|
|
|
*(hostPtr) = nativeVar32;
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostQWordToLittleEndian(Bit64u *hostPtr, Bit64u nativeVar64)
|
|
|
|
{
|
2016-08-12 20:06:14 +03:00
|
|
|
#ifdef ANDROID
|
|
|
|
// Resolve problems with unaligned access
|
2019-10-16 23:19:34 +03:00
|
|
|
((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);
|
2016-08-12 20:06:14 +03:00
|
|
|
#else
|
2019-10-16 23:19:34 +03:00
|
|
|
*(hostPtr) = nativeVar64;
|
2016-08-12 20:06:14 +03:00
|
|
|
#endif
|
2019-10-16 23:19:34 +03:00
|
|
|
}
|
|
|
|
|
2019-10-16 23:46:00 +03:00
|
|
|
BX_CPP_INLINE Bit16u ReadHostWordFromLittleEndian(Bit16u *hostPtr)
|
|
|
|
{
|
|
|
|
return *(hostPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE Bit32u ReadHostDWordFromLittleEndian(Bit32u *hostPtr)
|
|
|
|
{
|
|
|
|
return *(hostPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE Bit64u ReadHostQWordFromLittleEndian(Bit64u *hostPtr)
|
|
|
|
{
|
2016-08-12 20:06:14 +03:00
|
|
|
#ifdef ANDROID
|
|
|
|
// Resolve problems with unaligned access
|
2019-10-16 23:46:00 +03:00
|
|
|
Bit64u 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);
|
|
|
|
return nativeVar64
|
2016-08-12 20:06:14 +03:00
|
|
|
#else
|
2019-10-16 23:46:00 +03:00
|
|
|
return *(hostPtr);
|
2016-08-12 20:06:14 +03:00
|
|
|
#endif
|
2019-10-16 23:46:00 +03:00
|
|
|
}
|
2002-09-05 08:56:11 +04:00
|
|
|
|
2019-10-16 23:46:00 +03:00
|
|
|
#else // !BX_LITTLE_ENDIAN
|
2002-09-05 08:56:11 +04:00
|
|
|
|
2013-05-24 21:58:49 +04:00
|
|
|
#ifdef __MORPHOS__
|
|
|
|
|
|
|
|
#define bx_bswap16 bx_ppc_bswap16
|
|
|
|
#define bx_bswap32 bx_ppc_bswap32
|
|
|
|
#define bx_bswap64 bx_ppc_bswap64
|
|
|
|
|
2019-10-16 23:19:34 +03:00
|
|
|
BX_CPP_INLINE void WriteHostWordToLittleEndian(Bit16u *hostPtr, Bit16u nativeVar16)
|
|
|
|
{
|
|
|
|
bx_ppc_store_le16(hostPtr, nativeVar16);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
2019-10-16 23:19:34 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostDWordToLittleEndian(Bit32u *hostPtr, Bit32u nativeVar32)
|
|
|
|
{
|
|
|
|
bx_ppc_store_le32(hostPtr, nativeVar32);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
2019-10-16 23:19:34 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostQWordToLittleEndian(Bit64u *hostPtr, Bit64u nativeVar64)
|
|
|
|
{
|
|
|
|
bx_ppc_store_le64(hostPtr, nativeVar64);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
|
|
|
|
2019-10-16 23:46:00 +03:00
|
|
|
BX_CPP_INLINE Bit16u ReadHostWordFromLittleEndian(Bit16u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_ppc_load_le16(hostPtr);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
2019-10-16 23:46:00 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE Bit32u ReadHostDWordFromLittleEndian(Bit32u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_ppc_load_le32(hostPtr);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
2019-10-16 23:46:00 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE Bit64u ReadHostQWordFromLittleEndian(Bit64u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_ppc_load_le64(hostPtr);
|
2013-05-24 21:58:49 +04:00
|
|
|
}
|
|
|
|
|
2019-10-16 23:19:34 +03:00
|
|
|
#else // !__MORPHOS__
|
2013-05-24 21:58:49 +04:00
|
|
|
|
2019-10-16 23:19:34 +03:00
|
|
|
BX_CPP_INLINE void WriteHostWordToLittleEndian(Bit16u *hostPtr, Bit16u nativeVar16)
|
|
|
|
{
|
|
|
|
*(hostPtr) = bx_bswap16(nativeVar16);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
2019-10-16 23:19:34 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostDWordToLittleEndian(Bit8u *hostPtr, Bit32u nativeVar32)
|
|
|
|
{
|
|
|
|
*(hostPtr) = bx_bswap32(nativeVar32);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
2019-10-16 23:19:34 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE void WriteHostQWordToLittleEndian(Bit8u *hostPtr, Bit64u nativeVar64)
|
|
|
|
{
|
|
|
|
*(hostPtr) = bx_bswap64(nativeVar64);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
|
|
|
|
2019-10-16 23:46:00 +03:00
|
|
|
BX_CPP_INLINE Bit16u ReadHostWordFromLittleEndian(Bit16u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_bswap16(*hostPtr);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
2019-10-16 23:46:00 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE Bit32u ReadHostDWordFromLittleEndian(Bit32u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_bswap32(*hostPtr);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
2019-10-16 23:46:00 +03:00
|
|
|
|
|
|
|
BX_CPP_INLINE Bit64u ReadHostQWordFromLittleEndian(Bit64u *hostPtr)
|
|
|
|
{
|
|
|
|
return bx_bswap64(*hostPtr);
|
2008-02-07 23:43:13 +03:00
|
|
|
}
|
|
|
|
|
2002-09-05 08:56:11 +04:00
|
|
|
#endif
|
|
|
|
|
2013-05-24 21:58:49 +04:00
|
|
|
#endif
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif /* BX_BOCHS_H */
|