convert define to enum

add const to some function methods
tab2space
This commit is contained in:
Shwartsman 2023-10-20 22:34:37 +03:00
parent 873f62e298
commit ab1e94b13c
17 changed files with 188 additions and 170 deletions

View File

@ -24,7 +24,8 @@
#define MAX_MULTIPLE_SECTORS 16
typedef enum _sense {
SENSE_NONE = 0, SENSE_NOT_READY = 2, SENSE_ILLEGAL_REQUEST = 5,
SENSE_NONE = 0, SENSE_NOT_READY = 2,
SENSE_ILLEGAL_REQUEST = 5,
SENSE_UNIT_ATTENTION = 6
} sense_t;

View File

@ -33,6 +33,8 @@
#define BX_IODEBUG_THIS this->
#define BX_IODEBUG_MAX_AREAS 30
bx_iodebug_c *theIODebugDevice = NULL;
PLUGIN_ENTRY_FOR_MODULE(iodebug)

View File

@ -24,8 +24,6 @@
#if BX_SUPPORT_IODEBUG
#define BX_IODEBUG_MAX_AREAS 30
class bx_iodebug_c : public bx_iodebug_stub_c {
public:
bx_iodebug_c();

View File

@ -120,9 +120,11 @@ class cdrom_base_c;
else if (io_len == 4) \
BX_DEBUG(("write PCI register 0x%02X value 0x%08X (len=4)", addr, value));
#define BX_PCI_BAR_TYPE_NONE 0
#define BX_PCI_BAR_TYPE_MEM 1
#define BX_PCI_BAR_TYPE_IO 2
enum {
BX_PCI_BAR_TYPE_NONE = 0,
BX_PCI_BAR_TYPE_MEM = 1,
BX_PCI_BAR_TYPE_IO = 2
};
#define BX_PCI_ADVOPT_NOACPI 0x01
#define BX_PCI_ADVOPT_NOHPET 0x02

View File

@ -30,10 +30,12 @@
# define BX_KEY_THIS this->
#endif
#define MOUSE_MODE_RESET 10
#define MOUSE_MODE_STREAM 11
#define MOUSE_MODE_REMOTE 12
#define MOUSE_MODE_WRAP 13
enum {
MOUSE_MODE_RESET = 10,
MOUSE_MODE_STREAM = 11,
MOUSE_MODE_REMOTE = 12,
MOUSE_MODE_WRAP = 13
};
class bx_keyb_c : public bx_devmodel_c {
public:
@ -107,7 +109,7 @@ private:
Bit8u saved_mode; // the mode prior to entering wrap mode
bool enable;
Bit8u get_status_byte ()
Bit8u get_status_byte()
{
// top bit is 0 , bit 6 is 1 if remote mode.
Bit8u ret = (Bit8u) ((mode == MOUSE_MODE_REMOTE) ? 0x40 : 0);
@ -118,7 +120,7 @@ private:
return ret;
}
Bit8u get_resolution_byte ()
Bit8u get_resolution_byte()
{
Bit8u ret = 0;
@ -126,22 +128,19 @@ private:
case 1:
ret = 0;
break;
case 2:
ret = 1;
break;
case 4:
ret = 2;
break;
case 8:
ret = 3;
break;
default:
genlog->panic("mouse: invalid resolution_cpmm");
};
}
return ret;
}

View File

@ -31,9 +31,11 @@
#define BX_PARPORT_MAXDEV 2
#define BX_PAR_DATA 0
#define BX_PAR_STAT 1
#define BX_PAR_CTRL 2
enum {
BX_PAR_DATA = 0,
BX_PAR_STAT = 1,
BX_PAR_CTRL = 2
};
typedef struct {
Bit8u data;

View File

@ -31,10 +31,12 @@
#define BX_PCI_DEVICE(device, function) ((device)<<3 | (function))
#define BX_PCI_INTA 1
#define BX_PCI_INTB 2
#define BX_PCI_INTC 3
#define BX_PCI_INTD 4
enum {
BX_PCI_INTA = 1,
BX_PCI_INTB = 2,
BX_PCI_INTC = 3,
BX_PCI_INTD = 4
};
class bx_pci_vbridge_c;

View File

@ -48,9 +48,11 @@ extern "C" {
#define BX_PC_CLOCK_XTL 1843200.0
#define BX_SER_RXIDLE 0
#define BX_SER_RXPOLL 1
#define BX_SER_RXWAIT 2
enum {
BX_SER_RXIDLE = 0,
BX_SER_RXPOLL = 1,
BX_SER_RXWAIT = 2
};
#define BX_SER_THR 0
#define BX_SER_RBR 0
@ -63,15 +65,17 @@ extern "C" {
#define BX_SER_MSR 6
#define BX_SER_SCR 7
#define BX_SER_MODE_NULL 0
#define BX_SER_MODE_FILE 1
#define BX_SER_MODE_TERM 2
#define BX_SER_MODE_RAW 3
#define BX_SER_MODE_MOUSE 4
#define BX_SER_MODE_SOCKET_CLIENT 5
#define BX_SER_MODE_SOCKET_SERVER 6
#define BX_SER_MODE_PIPE_CLIENT 7
#define BX_SER_MODE_PIPE_SERVER 8
enum {
BX_SER_MODE_NULL = 0,
BX_SER_MODE_FILE = 1,
BX_SER_MODE_TERM = 2,
BX_SER_MODE_RAW = 3,
BX_SER_MODE_MOUSE = 4,
BX_SER_MODE_SOCKET_CLIENT = 5,
BX_SER_MODE_SOCKET_SERVER = 6,
BX_SER_MODE_PIPE_CLIENT = 7,
BX_SER_MODE_PIPE_SERVER = 8
};
enum {
BX_SER_INT_IER,

View File

@ -29,11 +29,13 @@
//#define WIN32_RECEIVE_RAW
#endif
#define P_NONE 0
#define P_ODD 1
#define P_EVEN 2
#define P_HIGH 3
#define P_LOW 4
enum {
P_NONE = 0,
P_ODD = 1,
P_EVEN = 2,
P_HIGH = 3,
P_LOW = 4
};
#define RAW_EVENT_BREAK -1
#define RAW_EVENT_CTS_ON -2

View File

@ -71,13 +71,14 @@ typedef Bit64s Bits;
#define INTFREQU ((fltype)(14318180.0 / 288.0)) // clocking of the chip
#define OF_TYPE_ATT 0
#define OF_TYPE_DEC 1
#define OF_TYPE_REL 2
#define OF_TYPE_SUS 3
#define OF_TYPE_SUS_NOKEEP 4
#define OF_TYPE_OFF 5
enum {
OF_TYPE_ATT = 0,
OF_TYPE_DEC = 1,
OF_TYPE_REL = 2,
OF_TYPE_SUS = 3,
OF_TYPE_SUS_NOKEEP = 4,
OF_TYPE_OFF = 5
};
#define ARC_CONTROL 0x00
#define ARC_TVS_KSR_MUL 0x20
@ -92,7 +93,6 @@ typedef Bit64s Bits;
#define ARC_SECONDSET 0x100 // second operator set for OPL3
#define OP_ACT_OFF 0x00
#define OP_ACT_NORMAL 0x01 // regular channel activated (bitmasked)
#define OP_ACT_PERC 0x02 // percussion channel activated (bitmasked)

View File

@ -229,12 +229,12 @@ public:
void scsi_write_complete(void *req, int ret);
void scsi_write_data(Bit32u tag);
Bit8u* scsi_get_buf(Bit32u tag);
const char *get_serial_number() {return drive_serial_str;}
const char *get_serial_number() const { return drive_serial_str; }
int scsi_do_modepage_hdr(Bit8u *p, Bit8u sub_page, Bit8u page_code, int len);
int scsi_do_modepage(Bit8u *p, Bit8u pc, Bit8u sub_page, Bit8u page_code);
void set_inserted(bool value);
bool get_inserted() {return inserted;}
bool get_locked() {return locked;}
bool get_inserted() const { return inserted; }
bool get_locked() const { return locked; }
static void seek_timer_handler(void *);
bool save_requests(const char *path);
void restore_requests(const char *path);

View File

@ -31,10 +31,12 @@
#define BX_IODEV_USB_COMMON_H
// for the Packet Capture code to work, these four must remain as is
#define USB_TRANS_TYPE_ISO 0
#define USB_TRANS_TYPE_INT 1
#define USB_TRANS_TYPE_CONTROL 2
#define USB_TRANS_TYPE_BULK 3
enum {
USB_TRANS_TYPE_ISO = 0,
USB_TRANS_TYPE_INT = 1,
USB_TRANS_TYPE_CONTROL = 2,
USB_TRANS_TYPE_BULK = 3
};
#define USB_CONTROL_EP 0
@ -54,18 +56,22 @@
#define USB_RET_ASYNC (-6)
// these must remain in this order, 0 -> 3
#define USB_SPEED_LOW 0
#define USB_SPEED_FULL 1
#define USB_SPEED_HIGH 2
#define USB_SPEED_SUPER 3
enum {
USB_SPEED_LOW = 0,
USB_SPEED_FULL = 1,
USB_SPEED_HIGH = 2,
USB_SPEED_SUPER = 3
};
#define USB_STATE_NOTATTACHED 0
#define USB_STATE_ATTACHED 1
//#define USB_STATE_POWERED 2
#define USB_STATE_DEFAULT 3
#define USB_STATE_ADDRESS 4
#define USB_STATE_CONFIGURED 5
#define USB_STATE_SUSPENDED 6
enum {
USB_STATE_NOTATTACHED = 0,
USB_STATE_ATTACHED = 1,
//USB_STATE_POWERED = 2,
USB_STATE_DEFAULT = 3,
USB_STATE_ADDRESS = 4,
USB_STATE_CONFIGURED = 5,
USB_STATE_SUSPENDED = 6
};
#define USB_DIR_OUT 0
#define USB_DIR_IN 0x80
@ -228,8 +234,8 @@ public:
virtual bool set_option(const char *option) { return 0; }
virtual void runtime_config() {}
bool get_connected() { return d.connected; }
int get_speed() { return d.speed; }
bool get_connected() const { return d.connected; }
int get_speed() const { return d.speed; }
bool set_speed(int speed)
{
if ((speed >= d.minspeed) && (speed <= d.maxspeed)) {
@ -239,7 +245,7 @@ public:
return 0;
}
}
int get_min_speed() { return d.minspeed; }
int get_min_speed() const { return d.minspeed; }
int get_default_speed(int speed) {
if ((speed >= d.minspeed) && (speed <= d.maxspeed))
return speed;
@ -251,38 +257,34 @@ public:
int get_mps(const int ep) {
return (ep < USB_MAX_ENDPOINTS) ? d.endpoint_info[ep].max_packet_size : 0;
}
int get_max_burst_size(const int ep) {
int get_max_burst_size(int ep) const {
return (ep < USB_MAX_ENDPOINTS) ? d.endpoint_info[ep].max_burst_size : 0;
}
int get_max_payload(const int ep) {
int get_max_payload(int ep) const {
return (ep < USB_MAX_ENDPOINTS) ? (d.endpoint_info[ep].max_burst_size * d.endpoint_info[ep].max_packet_size) : 0;
}
#if HANDLE_TOGGLE_CONTROL
int get_toggle(const int ep) {
int get_toggle(int ep) const {
return ((ep & 0x7F) < USB_MAX_ENDPOINTS) ? d.endpoint_info[(ep & 0x7F)].toggle : 0;
}
void set_toggle(const int ep, const int toggle) {
void set_toggle(int ep, int toggle) {
if ((ep & 0x7F) < USB_MAX_ENDPOINTS)
d.endpoint_info[(ep & 0x7F)].toggle = toggle;
}
#endif
bool get_halted(const int ep) {
bool get_halted(int ep) const {
return ((ep & 0x7F) < USB_MAX_ENDPOINTS) ? d.endpoint_info[(ep & 0x7F)].halted : 0;
}
void set_halted(const int ep, const bool halted) {
void set_halted(int ep, const bool halted) {
if ((ep & 0x7F) < USB_MAX_ENDPOINTS)
d.endpoint_info[(ep & 0x7F)].halted = halted;
}
Bit8u get_type() {
return d.type;
}
Bit8u get_aIface() {
return d.alt_iface;
}
Bit8u get_type() const { return d.type; }
Bit8u get_aIface() const { return d.alt_iface; }
Bit8u get_address() const { return d.addr; }
Bit8u get_address() {return d.addr;}
void set_async_mode(bool async) { d.async_mode = async; }
void set_event_handler(void *dev, USBCallback *cb, int port)
{

View File

@ -33,11 +33,13 @@
#define BX_IODEV_USB_HID_H
// Physical Descriptor Items
#define HID_PHYS_BIAS_NOT_APP 0
#define HID_PHYS_BIAS_RIGHT_HAND 1
#define HID_PHYS_BIAS_LEFT_HAND 2
#define HID_PHYS_BIAS_BOTH_HANDS 3
#define HID_PHYS_BIAS_EITHER_HAND 4
enum {
HID_PHYS_BIAS_NOT_APP = 0,
HID_PHYS_BIAS_RIGHT_HAND = 1,
HID_PHYS_BIAS_LEFT_HAND = 2,
HID_PHYS_BIAS_BOTH_HANDS = 3,
HID_PHYS_BIAS_EITHER_HAND = 4
};
typedef enum
{

View File

@ -316,17 +316,21 @@ enum { PLS_U0 = 0, PLS_U1, PLS_U2, PLS_U3_SUSPENDED, PLS_DISABLED, PLS_RXDETECT,
#define EP_DIR_IN 1
// Slot State
#define SLOT_STATE_DISABLED_ENABLED 0
#define SLOT_STATE_DEFAULT 1
#define SLOT_STATE_ADDRESSED 2
#define SLOT_STATE_CONFIGURED 3
enum {
SLOT_STATE_DISABLED_ENABLED = 0,
SLOT_STATE_DEFAULT = 1,
SLOT_STATE_ADDRESSED = 2,
SLOT_STATE_CONFIGURED = 3
};
// EP State
#define EP_STATE_DISABLED 0
#define EP_STATE_RUNNING 1
#define EP_STATE_HALTED 2
#define EP_STATE_STOPPED 3
#define EP_STATE_ERROR 4
enum {
EP_STATE_DISABLED = 0,
EP_STATE_RUNNING = 1,
EP_STATE_HALTED = 2,
EP_STATE_STOPPED = 3,
EP_STATE_ERROR = 4
};
#define TRB_GET_STYPE(x) (((x) & (0x1F << 16)) >> 16)
#define TRB_SET_STYPE(x) (((x) & 0x1F) << 16)

View File

@ -62,10 +62,11 @@
#include "param_names.h"
#include "virt_timer.h"
const Bit64u BX_MAX_VIRTUAL_TIME = BX_CONST64(0x7fffffff);
//Important constant #defines:
#define USEC_PER_SECOND (1000000)
// define a macro to convert floating point numbers into 64-bit integers.
// In MSVC++ you can convert a 64-bit float into a 64-bit signed integer,
// but it will not convert a 64-bit float into a 64-bit unsigned integer.

View File

@ -27,8 +27,6 @@
// should be adjusted if want to support more SMP processors
#define BX_MAX_VIRTUAL_TIMERS (32)
#define BX_MAX_VIRTUAL_TIME (0x7fffffff)
class BOCHSAPI bx_virt_timer_c : public logfunctions {
private:
@ -128,8 +126,7 @@ public:
void start_timers(void);
//activate a deactivated but registered timer.
void activate_timer(unsigned timer_index, Bit32u useconds,
bool continuous);
void activate_timer(unsigned timer_index, Bit32u useconds, bool continuous);
//deactivate (but don't unregister) a currently registered timer.
void deactivate_timer(unsigned timer_index);