- changed format of log functions to use BX_ERROR instead of errmsg

This commit is contained in:
Bryce Denney 2001-05-24 22:20:41 +00:00
parent eacb6e5ccb
commit ccee158458
1 changed files with 23 additions and 24 deletions

View File

@ -1,7 +1,3 @@
#define errmsg(x) printf(x)
#define DEBUG 1
/* /*
*Emulator of an Intel 8254/82C54 Programmable Interval Timer. *Emulator of an Intel 8254/82C54 Programmable Interval Timer.
* *
@ -24,7 +20,10 @@
* write? * write?
*/ */
class pit_82C54 { #include "bochs.h"
#define LOG_THIS this->
class pit_82C54 : public logfunctions {
private: private:
@ -100,7 +99,7 @@ private:
thisctr.count_LSB_latched=1; thisctr.count_LSB_latched=1;
thisctr.count_MSB_latched=1; thisctr.count_MSB_latched=1;
case MSByte_multiple: case MSByte_multiple:
errmsg("Unknown behavior when latching during 2-part read."); BX_ERROR(("Unknown behavior when latching during 2-part read."));
//I guess latching and resetting to LSB first makes sense; //I guess latching and resetting to LSB first makes sense;
thisctr.read_state=LSByte_multiple; thisctr.read_state=LSByte_multiple;
thisctr.outlatch=thisctr.count & 0xFFFF; thisctr.outlatch=thisctr.count & 0xFFFF;
@ -108,7 +107,7 @@ private:
thisctr.count_MSB_latched=1; thisctr.count_MSB_latched=1;
break; break;
default: default:
errmsg("Unknown read mode found during latch command."); BX_ERROR(("Unknown read mode found during latch command."));
break; break;
} }
} }
@ -180,7 +179,7 @@ public:
void clock(Bit8u cnum) { void clock(Bit8u cnum) {
if(cnum>MAX_COUNTER) { if(cnum>MAX_COUNTER) {
errmsg("Counter number too high in clock"); BX_ERROR(("Counter number too high in clock");
} else { } else {
counter_type & thisctr = counter[cnum]; counter_type & thisctr = counter[cnum];
switch(thisctr.mode) { switch(thisctr.mode) {
@ -207,7 +206,7 @@ public:
thisctr.null_count=0; thisctr.null_count=0;
set_OUT(thisctr,0); set_OUT(thisctr,0);
if(thisctr.write_state==MSByte_multiple) { if(thisctr.write_state==MSByte_multiple) {
errmsg("Undefined behavior when loading a half loaded count."); BX_ERROR(("Undefined behavior when loading a half loaded count.")));
} }
} else { } else {
decrement(thisctr); decrement(thisctr);
@ -224,13 +223,13 @@ public:
thisctr.count=thisctr.inlatch; thisctr.count=thisctr.inlatch;
thisctr.null_count=0; thisctr.null_count=0;
if(thisctr.inlatch==1) { if(thisctr.inlatch==1) {
errmsg("ERROR: count of 1 is invalid in pit mode 2."); BX_ERROR(("ERROR: count of 1 is invalid in pit mode 2.");
} }
if(!thisctr.OUT) { if(!thisctr.OUT) {
set_OUT(thisctr,1); set_OUT(thisctr,1);
} }
if(thisctr.write_state==MSByte_multiple) { if(thisctr.write_state==MSByte_multiple) {
errmsg("Undefined behavior when loading a half loaded count."); BX_ERROR(("Undefined behavior when loading a half loaded count.")));
} }
thisctr.first_pass=0; thisctr.first_pass=0;
} else { } else {
@ -253,7 +252,7 @@ public:
thisctr.state_bit_1=thisctr.inlatch & 0x1; thisctr.state_bit_1=thisctr.inlatch & 0x1;
thisctr.null_count=0; thisctr.null_count=0;
if(thisctr.inlatch==1) { if(thisctr.inlatch==1) {
errmsg("Count of 1 is invalid in pit mode 3."); BX_ERROR(("Count of 1 is invalid in pit mode 3."));
} }
if(!thisctr.OUT) { if(!thisctr.OUT) {
set_OUT(thisctr,1); set_OUT(thisctr,1);
@ -261,7 +260,7 @@ public:
set_OUT(thisctr,0); set_OUT(thisctr,0);
} }
if(thisctr.write_state==MSByte_multiple) { if(thisctr.write_state==MSByte_multiple) {
errmsg("Undefined behavior when loading a half loaded count."); BX_ERROR(("Undefined behavior when loading a half loaded count."));
} }
thisctr.state_bit_2=0; thisctr.state_bit_2=0;
thisctr.first_pass=0; thisctr.first_pass=0;
@ -291,7 +290,7 @@ public:
thisctr.count=thisctr.inlatch; thisctr.count=thisctr.inlatch;
thisctr.null_count=0; thisctr.null_count=0;
if(thisctr.write_state==MSByte_multiple) { if(thisctr.write_state==MSByte_multiple) {
errmsg("Undefined behavior when loading a half loaded count."); BX_ERROR(("Undefined behavior when loading a half loaded count."));
} }
thisctr.first_pass=1; thisctr.first_pass=1;
} else { } else {
@ -315,7 +314,7 @@ public:
thisctr.count=thisctr.inlatch; thisctr.count=thisctr.inlatch;
thisctr.null_count=0; thisctr.null_count=0;
if(thisctr.write_state==MSByte_multiple) { if(thisctr.write_state==MSByte_multiple) {
errmsg("Undefined behavior when loading a half loaded count."); BX_ERROR(("Undefined behavior when loading a half loaded count."));
} }
thisctr.first_pass=1; thisctr.first_pass=1;
} else { } else {
@ -331,7 +330,7 @@ public:
thisctr.triggerGATE=0; thisctr.triggerGATE=0;
break; break;
default: default:
errmsg("Mode not implemented."); BX_ERROR(("Mode not implemented."));
thisctr.triggerGATE=0; thisctr.triggerGATE=0;
break; break;
} }
@ -346,13 +345,13 @@ public:
Bit8u read(Bit8u address) { Bit8u read(Bit8u address) {
if(address>MAX_ADDRESS) { if(address>MAX_ADDRESS) {
errmsg("Counter address incorrect in data read."); BX_ERROR(("Counter address incorrect in data read."));
} else if(address==CONTROL_ADDRESS) { } else if(address==CONTROL_ADDRESS) {
//Read from control word register; //Read from control word register;
/* This might be okay. If so, 0 seems the most logical /* This might be okay. If so, 0 seems the most logical
* return value from looking at the docs. * return value from looking at the docs.
*/ */
errmsg("Read from control word register not defined."); BX_ERROR(("Read from control word register not defined."));
return 0; return 0;
} else { } else {
//Read from a counter; //Read from a counter;
@ -361,7 +360,7 @@ public:
//Latched Status Read; //Latched Status Read;
if(thisctr.count_MSB_latched && if(thisctr.count_MSB_latched &&
(thisctr.read_state==MSByte_multiple) ) { (thisctr.read_state==MSByte_multiple) ) {
errmsg("Undefined output when status latched and count half read."); BX_ERROR(("Undefined output when status latched and count half read."));
} else { } else {
thisctr.status_latched=0; thisctr.status_latched=0;
return thisctr.status_latch; return thisctr.status_latch;
@ -406,7 +405,7 @@ public:
void write(Bit8u address, Bit8u data) { void write(Bit8u address, Bit8u data) {
if(address>MAX_ADDRESS) { if(address>MAX_ADDRESS) {
errmsg("Counter address incorrect in data write."); BX_ERROR(("Counter address incorrect in data write."));
} else if(address==CONTROL_ADDRESS) { } else if(address==CONTROL_ADDRESS) {
Bit8u SC, RW, M, BCD; Bit8u SC, RW, M, BCD;
controlword=data; controlword=data;
@ -473,7 +472,7 @@ public:
thisctr.write_state=LSByte_multiple; thisctr.write_state=LSByte_multiple;
break; break;
default: default:
errmsg("RW field invalid in control word write."); BX_ERROR(("RW field invalid in control word write."));
break; break;
} }
//All modes except mode 0 have initial output of 1.; //All modes except mode 0 have initial output of 1.;
@ -505,7 +504,7 @@ public:
thisctr.count_written=1; thisctr.count_written=1;
break; break;
default: default:
errmsg("write counter in invalid write state."); BX_ERROR(("write counter in invalid write state."));
break; break;
} }
switch(thisctr.mode) { switch(thisctr.mode) {
@ -532,7 +531,7 @@ public:
void set_GATE(Bit8u cnum, bool data) { void set_GATE(Bit8u cnum, bool data) {
if(cnum>MAX_COUNTER) { if(cnum>MAX_COUNTER) {
errmsg("Counter number incorrect in 82C54 set_GATE"); BX_ERROR(("Counter number incorrect in 82C54 set_GATE"));
} else { } else {
counter_type & thisctr = counter[cnum]; counter_type & thisctr = counter[cnum];
if((!thisctr.GATE)&&data) { if((!thisctr.GATE)&&data) {
@ -559,7 +558,7 @@ public:
bool read_OUT(Bit8u cnum) { bool read_OUT(Bit8u cnum) {
if(cnum>MAX_COUNTER) { if(cnum>MAX_COUNTER) {
errmsg("Counter number incorrect in 82C54 read_OUT"); BX_ERROR(("Counter number incorrect in 82C54 read_OUT"));
return 0; return 0;
} else { } else {
return counter[cnum].OUT; return counter[cnum].OUT;