* convert bx_bool -> bool in pc_system.cc/pc_system.h
* extract logfunctions class definition to separate include logio.h to simplify the bochs.h reading next step: try to minimize amount of includes in bochs.h as everyone in Bochs includes it for example it includes pc_system.h which is not necessary required to be included in all CPU source files
This commit is contained in:
parent
abac80801f
commit
a8013fdeba
125
bochs/bochs.h
125
bochs/bochs.h
@ -258,130 +258,7 @@ void print_statistics_tree(bx_param_c *node, int level = 0);
|
||||
# define BX_DBG_PHY_MEMORY_ACCESS(cpu, phy, len, memtype, rw, attr, data) /* empty */
|
||||
#endif // #if BX_DEBUGGER
|
||||
|
||||
#define MAGIC_LOGNUM 0x12345678
|
||||
|
||||
typedef class BOCHSAPI logfunctions
|
||||
{
|
||||
char *name;
|
||||
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];
|
||||
public:
|
||||
logfunctions(void);
|
||||
logfunctions(class iofunctions *);
|
||||
virtual ~logfunctions(void);
|
||||
|
||||
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);
|
||||
void fatal1(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
||||
void fatal(int level, 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 *);
|
||||
void setonoff(int loglev, int value) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
onoff[loglev] = value;
|
||||
}
|
||||
const char *get_name() const { return name; }
|
||||
const char *getprefix() const { return prefix; }
|
||||
int getonoff(int level) const {
|
||||
assert (level>=0 && level<N_LOGLEV);
|
||||
return onoff[level];
|
||||
}
|
||||
static void set_default_action(int loglev, int action) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
assert (action >= 0 && action < N_ACT);
|
||||
default_onoff[loglev] = action;
|
||||
}
|
||||
static int get_default_action(int loglev) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
return default_onoff[loglev];
|
||||
}
|
||||
} logfunc_t;
|
||||
|
||||
#define BX_LOGPREFIX_LEN 20
|
||||
|
||||
class BOCHSAPI iofunctions {
|
||||
int magic;
|
||||
char logprefix[BX_LOGPREFIX_LEN + 1];
|
||||
FILE *logfd;
|
||||
class logfunctions *log;
|
||||
void init(void);
|
||||
void flush(void);
|
||||
|
||||
// Log Class types
|
||||
public:
|
||||
iofunctions(void);
|
||||
iofunctions(FILE *);
|
||||
iofunctions(int);
|
||||
iofunctions(const char *);
|
||||
~iofunctions(void);
|
||||
|
||||
void out(int level, const char *pre, const char *fmt, va_list ap);
|
||||
|
||||
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);
|
||||
int get_n_logfns() const { return n_logfn; }
|
||||
logfunc_t *get_logfn(int index) { return logfn_list[index]; }
|
||||
void add_logfn(logfunc_t *fn);
|
||||
void remove_logfn(logfunc_t *fn);
|
||||
void set_log_action(int loglevel, int action);
|
||||
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
|
||||
logfunc_t *logfn_list[MAX_LOGFNS];
|
||||
const char *logfn;
|
||||
};
|
||||
|
||||
typedef class iofunctions iofunc_t;
|
||||
|
||||
#define SAFE_GET_IOFUNC() \
|
||||
((io==NULL)? (io=new iofunc_t("/dev/stderr")) : io)
|
||||
#define SAFE_GET_GENLOG() \
|
||||
((genlog==NULL)? (genlog=new logfunc_t(SAFE_GET_IOFUNC())) : genlog)
|
||||
|
||||
#if BX_NO_LOGGING
|
||||
|
||||
#define BX_INFO(x)
|
||||
#define BX_DEBUG(x)
|
||||
#define BX_ERROR(x)
|
||||
#define BX_PANIC(x) (LOG_THIS panic) x
|
||||
#define BX_FATAL(x) (LOG_THIS fatal1) x
|
||||
|
||||
#define BX_ASSERT(x)
|
||||
|
||||
#else
|
||||
|
||||
#define BX_INFO(x) (LOG_THIS info) x
|
||||
#define BX_DEBUG(x) (LOG_THIS ldebug) x
|
||||
#define BX_ERROR(x) (LOG_THIS error) x
|
||||
#define BX_PANIC(x) (LOG_THIS panic) x
|
||||
#define BX_FATAL(x) (LOG_THIS fatal1) x
|
||||
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
BOCHSAPI extern iofunc_t *io;
|
||||
BOCHSAPI extern logfunc_t *genlog;
|
||||
#include "logio.h"
|
||||
|
||||
#ifndef UNUSED
|
||||
# define UNUSED(x) ((void)x)
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
const int MAGIC_LOGNUM = 0x12345678;
|
||||
|
||||
// Just for the iofunctions
|
||||
|
||||
static int Allocio=0;
|
||||
|
149
bochs/logio.h
Normal file
149
bochs/logio.h
Normal file
@ -0,0 +1,149 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// $Id$
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2001-2021 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef BX_LOGIO_H
|
||||
#define BX_LOGIO_H
|
||||
|
||||
typedef class BOCHSAPI logfunctions
|
||||
{
|
||||
char *name;
|
||||
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];
|
||||
public:
|
||||
logfunctions(void);
|
||||
logfunctions(class iofunctions *);
|
||||
virtual ~logfunctions(void);
|
||||
|
||||
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);
|
||||
void fatal1(const char *fmt, ...) BX_CPP_AttrPrintf(2, 3);
|
||||
void fatal(int level, 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 *);
|
||||
void setonoff(int loglev, int value) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
onoff[loglev] = value;
|
||||
}
|
||||
const char *get_name() const { return name; }
|
||||
const char *getprefix() const { return prefix; }
|
||||
int getonoff(int level) const {
|
||||
assert (level>=0 && level<N_LOGLEV);
|
||||
return onoff[level];
|
||||
}
|
||||
static void set_default_action(int loglev, int action) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
assert (action >= 0 && action < N_ACT);
|
||||
default_onoff[loglev] = action;
|
||||
}
|
||||
static int get_default_action(int loglev) {
|
||||
assert (loglev >= 0 && loglev < N_LOGLEV);
|
||||
return default_onoff[loglev];
|
||||
}
|
||||
} logfunc_t;
|
||||
|
||||
#define BX_LOGPREFIX_LEN 20
|
||||
|
||||
class BOCHSAPI iofunctions {
|
||||
int magic;
|
||||
char logprefix[BX_LOGPREFIX_LEN + 1];
|
||||
FILE *logfd;
|
||||
class logfunctions *log;
|
||||
void init(void);
|
||||
void flush(void);
|
||||
|
||||
// Log Class types
|
||||
public:
|
||||
iofunctions(void);
|
||||
iofunctions(FILE *);
|
||||
iofunctions(int);
|
||||
iofunctions(const char *);
|
||||
~iofunctions(void);
|
||||
|
||||
void out(int level, const char *pre, const char *fmt, va_list ap);
|
||||
|
||||
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);
|
||||
int get_n_logfns() const { return n_logfn; }
|
||||
logfunc_t *get_logfn(int index) { return logfn_list[index]; }
|
||||
void add_logfn(logfunc_t *fn);
|
||||
void remove_logfn(logfunc_t *fn);
|
||||
void set_log_action(int loglevel, int action);
|
||||
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
|
||||
logfunc_t *logfn_list[MAX_LOGFNS];
|
||||
const char *logfn;
|
||||
};
|
||||
|
||||
typedef class iofunctions iofunc_t;
|
||||
|
||||
#define SAFE_GET_IOFUNC() \
|
||||
((io==NULL)? (io=new iofunc_t("/dev/stderr")) : io)
|
||||
#define SAFE_GET_GENLOG() \
|
||||
((genlog==NULL)? (genlog=new logfunc_t(SAFE_GET_IOFUNC())) : genlog)
|
||||
|
||||
#if BX_NO_LOGGING
|
||||
|
||||
#define BX_INFO(x)
|
||||
#define BX_DEBUG(x)
|
||||
#define BX_ERROR(x)
|
||||
#define BX_PANIC(x) (LOG_THIS panic) x
|
||||
#define BX_FATAL(x) (LOG_THIS fatal1) x
|
||||
|
||||
#define BX_ASSERT(x)
|
||||
|
||||
#else
|
||||
|
||||
#define BX_INFO(x) (LOG_THIS info) x
|
||||
#define BX_DEBUG(x) (LOG_THIS ldebug) x
|
||||
#define BX_ERROR(x) (LOG_THIS error) x
|
||||
#define BX_PANIC(x) (LOG_THIS panic) x
|
||||
#define BX_FATAL(x) (LOG_THIS fatal1) x
|
||||
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
BOCHSAPI extern iofunc_t *io;
|
||||
BOCHSAPI extern logfunc_t *genlog;
|
||||
|
||||
#endif
|
@ -75,7 +75,7 @@ void bx_pc_system_c::initialize(Bit32u ips)
|
||||
BX_DEBUG(("ips = %u", (unsigned) ips));
|
||||
}
|
||||
|
||||
void bx_pc_system_c::set_HRQ(bx_bool val)
|
||||
void bx_pc_system_c::set_HRQ(bool val)
|
||||
{
|
||||
HRQ = val;
|
||||
if (val)
|
||||
@ -119,10 +119,10 @@ bx_pc_system_c::outp(Bit16u addr, Bit32u value, unsigned io_len)
|
||||
bx_devices.outp(addr, value, io_len);
|
||||
}
|
||||
|
||||
void bx_pc_system_c::set_enable_a20(bx_bool value)
|
||||
void bx_pc_system_c::set_enable_a20(bool value)
|
||||
{
|
||||
#if BX_SUPPORT_A20
|
||||
bx_bool old_enable_a20 = enable_a20;
|
||||
bool old_enable_a20 = enable_a20;
|
||||
|
||||
if (value) {
|
||||
enable_a20 = 1;
|
||||
@ -159,7 +159,7 @@ void bx_pc_system_c::set_enable_a20(bx_bool value)
|
||||
#endif
|
||||
}
|
||||
|
||||
bx_bool bx_pc_system_c::get_enable_a20(void)
|
||||
bool bx_pc_system_c::get_enable_a20(void)
|
||||
{
|
||||
#if BX_SUPPORT_A20
|
||||
BX_DEBUG(("A20: get() = %u", (unsigned) enable_a20));
|
||||
@ -250,7 +250,7 @@ void bx_pc_system_c::register_state(void)
|
||||
// ================================================
|
||||
|
||||
int bx_pc_system_c::register_timer(void *this_ptr, void (*funct)(void *),
|
||||
Bit32u useconds, bx_bool continuous, bx_bool active, const char *id)
|
||||
Bit32u useconds, bool continuous, bool active, const char *id)
|
||||
{
|
||||
// Convert useconds to number of ticks.
|
||||
Bit64u ticks = (Bit64u) (double(useconds) * m_ips);
|
||||
@ -259,7 +259,7 @@ int bx_pc_system_c::register_timer(void *this_ptr, void (*funct)(void *),
|
||||
}
|
||||
|
||||
int bx_pc_system_c::register_timer_ticks(void* this_ptr, bx_timer_handler_t funct,
|
||||
Bit64u ticks, bx_bool continuous, bx_bool active, const char *id)
|
||||
Bit64u ticks, bool continuous, bool active, const char *id)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -322,7 +322,7 @@ void bx_pc_system_c::countdownEvent(void)
|
||||
{
|
||||
unsigned i, first = numTimers, last = 0;
|
||||
Bit64u minTimeToFire;
|
||||
bx_bool triggered[BX_MAX_TIMERS];
|
||||
bool triggered[BX_MAX_TIMERS];
|
||||
|
||||
// The countdown decremented to 0. We need to service all the active
|
||||
// timers, and invoke callbacks from those timers which have fired.
|
||||
@ -470,7 +470,7 @@ Bit64u bx_pc_system_c::time_nsec()
|
||||
|
||||
void bx_pc_system_c::start_timers(void) { }
|
||||
|
||||
void bx_pc_system_c::activate_timer_ticks(unsigned i, Bit64u ticks, bx_bool continuous)
|
||||
void bx_pc_system_c::activate_timer_ticks(unsigned i, Bit64u ticks, bool continuous)
|
||||
{
|
||||
#if BX_TIMER_DEBUG
|
||||
if (i >= numTimers)
|
||||
@ -504,7 +504,7 @@ void bx_pc_system_c::activate_timer_ticks(unsigned i, Bit64u ticks, bx_bool cont
|
||||
}
|
||||
}
|
||||
|
||||
void bx_pc_system_c::activate_timer(unsigned i, Bit32u useconds, bx_bool continuous)
|
||||
void bx_pc_system_c::activate_timer(unsigned i, Bit32u useconds, bool continuous)
|
||||
{
|
||||
Bit64u ticks;
|
||||
|
||||
@ -535,7 +535,7 @@ void bx_pc_system_c::activate_timer(unsigned i, Bit32u useconds, bx_bool continu
|
||||
activate_timer_ticks(i, ticks, continuous);
|
||||
}
|
||||
|
||||
void bx_pc_system_c::activate_timer_nsec(unsigned i, Bit64u nseconds, bx_bool continuous)
|
||||
void bx_pc_system_c::activate_timer_nsec(unsigned i, Bit64u nseconds, bool continuous)
|
||||
{
|
||||
Bit64u ticks;
|
||||
|
||||
@ -571,7 +571,7 @@ void bx_pc_system_c::deactivate_timer(unsigned i)
|
||||
timer[i].active = 0;
|
||||
}
|
||||
|
||||
bx_bool bx_pc_system_c::unregisterTimer(unsigned timerIndex)
|
||||
bool bx_pc_system_c::unregisterTimer(unsigned timerIndex)
|
||||
{
|
||||
#if BX_TIMER_DEBUG
|
||||
if (timerIndex >= numTimers)
|
||||
|
@ -42,11 +42,11 @@ private:
|
||||
// ===============================
|
||||
|
||||
struct {
|
||||
bx_bool inUse; // Timer slot is in-use (currently registered).
|
||||
bool inUse; // Timer slot is in-use (currently registered).
|
||||
Bit64u period; // Timer periodocity in cpu ticks.
|
||||
Bit64u timeToFire; // Time to fire next (in absolute ticks).
|
||||
bx_bool active; // 0=inactive, 1=active.
|
||||
bx_bool continuous; // 0=one-shot timer, 1=continuous periodicity.
|
||||
bool active; // 0=inactive, 1=active.
|
||||
bool continuous; // 0=one-shot timer, 1=continuous periodicity.
|
||||
bx_timer_handler_t funct; // A callback function for when the
|
||||
// timer fires.
|
||||
void *this_ptr; // The this-> pointer for C++ callbacks
|
||||
@ -90,12 +90,12 @@ public:
|
||||
|
||||
void initialize(Bit32u ips);
|
||||
int register_timer(void *this_ptr, bx_timer_handler_t, Bit32u useconds,
|
||||
bx_bool continuous, bx_bool active, const char *id);
|
||||
bx_bool unregisterTimer(unsigned timerID);
|
||||
bool continuous, bool active, const char *id);
|
||||
bool unregisterTimer(unsigned timerID);
|
||||
void setTimerParam(unsigned timerID, Bit32u param);
|
||||
void start_timers(void);
|
||||
void activate_timer(unsigned timer_index, Bit32u useconds, bx_bool continuous);
|
||||
void activate_timer_nsec(unsigned timer_index, Bit64u nseconds, bx_bool continuous);
|
||||
void activate_timer(unsigned timer_index, Bit32u useconds, bool continuous);
|
||||
void activate_timer_nsec(unsigned timer_index, Bit64u nseconds, bool continuous);
|
||||
void deactivate_timer(unsigned timer_index);
|
||||
unsigned triggeredTimerID(void) {
|
||||
return triggeredTimer;
|
||||
@ -121,9 +121,9 @@ public:
|
||||
}
|
||||
|
||||
int register_timer_ticks(void* this_ptr, bx_timer_handler_t, Bit64u ticks,
|
||||
bx_bool continuous, bx_bool active, const char *id);
|
||||
bool continuous, bool active, const char *id);
|
||||
void activate_timer_ticks(unsigned index, Bit64u instructions,
|
||||
bx_bool continuous);
|
||||
bool continuous);
|
||||
Bit64u time_usec();
|
||||
Bit64u time_nsec();
|
||||
Bit64u time_usec_sequential();
|
||||
@ -148,13 +148,13 @@ public:
|
||||
// Non-timer oriented features
|
||||
// ===========================
|
||||
|
||||
bx_bool HRQ; // Hold Request
|
||||
bool HRQ; // Hold Request
|
||||
|
||||
// Address line 20 control:
|
||||
// 1 = enabled: extended memory is accessible
|
||||
// 0 = disabled: A20 address line is forced low to simulate
|
||||
// an 8088 address map
|
||||
bx_bool enable_a20;
|
||||
bool enable_a20;
|
||||
|
||||
// start out masking physical memory addresses to:
|
||||
// 8086: 20 bits
|
||||
@ -165,9 +165,9 @@ public:
|
||||
// 386: 20 bits
|
||||
bx_phy_address a20_mask;
|
||||
|
||||
volatile bx_bool kill_bochs_request;
|
||||
volatile bool kill_bochs_request;
|
||||
|
||||
void set_HRQ(bx_bool val); // set the Hold ReQuest line
|
||||
void set_HRQ(bool val); // set the Hold ReQuest line
|
||||
|
||||
void raise_INTR(void);
|
||||
void clear_INTR(void);
|
||||
@ -180,8 +180,8 @@ public:
|
||||
|
||||
Bit32u inp(Bit16u addr, unsigned io_len) BX_CPP_AttrRegparmN(2);
|
||||
void outp(Bit16u addr, Bit32u value, unsigned io_len) BX_CPP_AttrRegparmN(3);
|
||||
void set_enable_a20(bx_bool value);
|
||||
bx_bool get_enable_a20(void);
|
||||
void set_enable_a20(bool value);
|
||||
bool get_enable_a20(void);
|
||||
void MemoryMappingChanged(void); // flush TLB in all CPUs
|
||||
void invlpg(bx_address addr); // flush TLB page in all CPUs
|
||||
void exit(void);
|
||||
|
Loading…
Reference in New Issue
Block a user