Troubles with CMOS driver (exception when pressing a key)

Hi,

hitting a key on my machine causes an exception in the Calender class (invoked by GetTimeMills). I could trace this problem back to CMOS.java, where the wrong CMOS timer registers are read.

In the CMOS.getRegister method, the highest 3 bits of the old address value are retained. According to the ICH6 documentation (Intel I/O Controller Hub 6) which includes the Real Time Clock, only bit 7 (NMI Mask) should be preserved; all other bits belong to the register address.

Making this change in the code solves the problem, i.e.

public synchronized int getRegister(int register) {
// We must make sure that bit 7 of the address data is not
// changed, since it controls the NMI.
int addr = cmosIO.inPortByte(PRW8_ADDRESS);

addr &= 0x80; /* Clear lower 7 bits */
addr |= (register & 0x7F);

cmosIO.outPortByte(PRW8_ADDRESS, addr);
return cmosIO.inPortByte(PRW8_DATA);
}

Question: am I the only one to experience this? Shall I commit this change?

-Patrik

Committed it

Hi Patrick,

Seems to work fine, so i've committed it.

Ewout

Same for me

I test it with QEMU and i have same problem. I made same modification as you and it's seems work (no more exception) but i think setRegister method must be modify too.

- Fabien L.