Skip to content

Commit

Permalink
Merge pull request #2951 from Allofich/cmos
Browse files Browse the repository at this point in the history
CMOS log cleanup
  • Loading branch information
joncampbell123 authored Sep 30, 2021
2 parents d98859b + 13be1ba commit c92f8e0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
0.83.18
- Cleaned up and more accurately worded CMOS-related
log messages. (Allofich)
- Fixed the names of virtual files and files on mounted
FAT drive images being logged as "(null)". (Allofich)
- Fixed packed structure alignment problem with MSVC
Expand Down
58 changes: 28 additions & 30 deletions src/hardware/cmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ static void cmos_writereg(Bitu port,Bitu val,Bitu iolen) {

if (cmos.lock) // if locked, use locktime instead of current time
{
loctime = localtime((time_t*)&cmos.locktime.tv_sec);
loctime = localtime(&cmos.locktime.tv_sec);
}
else // not locked, use current time
{
struct timeval curtime;
gettimeofday(&curtime, NULL);
curtime.tv_sec += cmos.time_diff;
loctime = localtime((time_t*)&curtime.tv_sec);
loctime = localtime(&curtime.tv_sec);
}

switch (cmos.reg)
Expand Down Expand Up @@ -203,7 +203,7 @@ static void cmos_writereg(Bitu port,Bitu val,Bitu iolen) {
case 0x01: /* Seconds Alarm */
case 0x03: /* Minutes Alarm */
case 0x05: /* Hours Alarm */
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Trying to set alarm");
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Writing to an alarm register");
cmos.regs[cmos.reg] = (uint8_t)val;
return; // done
}
Expand Down Expand Up @@ -234,20 +234,18 @@ static void cmos_writereg(Bitu port,Bitu val,Bitu iolen) {
case 0x07: /* Date of month */
case 0x08: /* Month */
case 0x09: /* Year */
case 0x32: /* Century */
case 0x32: /* Century */
/* Ignore writes to change alarm */
if(!date_host_forced) break;
break;
case 0x01: /* Seconds Alarm */
case 0x03: /* Minutes Alarm */
case 0x05: /* Hours Alarm */
if(!date_host_forced) {
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Trying to set alarm");
cmos.regs[cmos.reg]=(uint8_t)val;
break;
}
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Writing to an alarm register");
cmos.regs[cmos.reg]=(uint8_t)val;
break;
case 0x0a: /* Status reg A */
cmos.regs[cmos.reg]=val & 0x7f;
if ((val & 0x70)!=0x20) LOG(LOG_BIOS,LOG_ERROR)("CMOS Illegal 22 stage divider value");
if ((val & 0x70)!=0x20) LOG(LOG_BIOS,LOG_ERROR)("CMOS:Illegal 22 stage divider value");
cmos.timer.div=(val & 0xf);
cmos_checktimer();
break;
Expand All @@ -257,7 +255,7 @@ static void cmos_writereg(Bitu port,Bitu val,Bitu iolen) {

cmos.ampm = !(val & 0x02);
cmos.bcd = !(val & 0x04);
if ((val & 0x10) != 0) LOG(LOG_BIOS,LOG_ERROR)("CMOS:Updated ended interrupt not supported yet");
if ((val & 0x10) != 0) LOG(LOG_BIOS,LOG_ERROR)("CMOS:'Update ended interrupt' not supported yet");
cmos.timer.enabled = (val & 0x40) > 0;
cmos.lock = (val & 0x80) != 0;

Expand All @@ -282,23 +280,23 @@ static void cmos_writereg(Bitu port,Bitu val,Bitu iolen) {
cmos.bcd=!(val & 0x4);
cmos.regs[cmos.reg]=val & 0x7f;
cmos.timer.enabled=(val & 0x40)>0;
if (val&0x10) LOG(LOG_BIOS,LOG_ERROR)("CMOS:Updated ended interrupt not supported yet");
if (val&0x10) LOG(LOG_BIOS,LOG_ERROR)("CMOS:'Update ended interrupt' not supported yet");
cmos_checktimer();
}
break;
case 0x0c:
case 0x0c: /* Status reg C */
if(date_host_forced) break;
case 0x0d:/* Status reg D */
case 0x0d: /* Status reg D */
if(!date_host_forced) {
cmos.regs[cmos.reg]=val & 0x80; /*Bit 7=1:RTC Pown on*/
cmos.regs[cmos.reg]=val & 0x80; /*Bit 7=1:RTC Power on*/
}
break;
case 0x0f: /* Shutdown status byte */
cmos.regs[cmos.reg]=val & 0x7f;
break;
default:
LOG(LOG_BIOS, LOG_NORMAL)("CMOS:Writing to register %x", cmos.reg);
cmos.regs[cmos.reg]=val & 0x7f;
LOG(LOG_BIOS,LOG_ERROR)("CMOS:WRite to unhandled register %x",cmos.reg);
}
}

Expand All @@ -312,7 +310,7 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {
(void)port;//UNUSED
(void)iolen;//UNUSED
if (cmos.reg>0x3f) {
LOG(LOG_BIOS,LOG_ERROR)("CMOS:Read from illegal register %x",cmos.reg);
LOG(LOG_BIOS,LOG_ERROR)("CMOS:Read attempted from illegal register %x",cmos.reg);
return 0xff;
}

Expand All @@ -322,7 +320,7 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {

if (cmos.lock) // if locked, use locktime instead of current time
{
loctime = localtime((time_t*)&cmos.locktime.tv_sec);
loctime = localtime(&cmos.locktime.tv_sec);
}
else // not locked, get current time
{
Expand All @@ -337,7 +335,7 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {
}

curtime.tv_sec += cmos.time_diff;
loctime = localtime((time_t*)&curtime.tv_sec);
loctime = localtime(&curtime.tv_sec);
}

switch (cmos.reg)
Expand Down Expand Up @@ -383,25 +381,25 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {

switch (cmos.reg) {
case 0x00: /* Seconds */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_sec);
return MAKE_RETURN(loctime->tm_sec);
case 0x02: /* Minutes */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_min);
return MAKE_RETURN(loctime->tm_min);
case 0x04: /* Hours */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_hour);
return MAKE_RETURN(loctime->tm_hour);
case 0x06: /* Day of week */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_wday + 1);
return MAKE_RETURN(loctime->tm_wday + 1);
case 0x07: /* Date of month */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_mday);
return MAKE_RETURN(loctime->tm_mday);
case 0x08: /* Month */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_mon + 1);
return MAKE_RETURN(loctime->tm_mon + 1);
case 0x09: /* Year */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_year % 100);
return MAKE_RETURN(loctime->tm_year % 100);
case 0x32: /* Century */
if(!date_host_forced) return MAKE_RETURN(loctime->tm_year / 100 + 19);
return MAKE_RETURN(loctime->tm_year / 100 + 19);
case 0x01: /* Seconds Alarm */
case 0x03: /* Minutes Alarm */
case 0x05: /* Hours Alarm */
if(!date_host_forced) return cmos.regs[cmos.reg];
return cmos.regs[cmos.reg];
case 0x0a: /* Status register A */
if(date_host_forced) {
// take bit 7 of reg b into account (if set, never updates)
Expand Down Expand Up @@ -541,7 +539,7 @@ static Bitu cmos_readreg(Bitu port,Bitu iolen) {
if( PS1AudioCard )
return 0xFF;
default:
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Read from reg %X",cmos.reg);
LOG(LOG_BIOS,LOG_NORMAL)("CMOS:Reading from register %X",cmos.reg);
return cmos.regs[cmos.reg];
}
}
Expand Down

0 comments on commit c92f8e0

Please sign in to comment.