Page 1 of 1
got CMOS time invalid error, each time after I run my kernel
Posted: Sun Dec 16, 2007 9:49 am
by blackoil
I set rtc as:
mov al,0xB
out 0x70,al
mov al,00010100b ;24hours, update ended interrupt
out 0x71,al
ISR8:
pushad
mov al,0x0C
out 0x70,al
in al,0x71
mov al,EOI
out PIC8259B_Port_Command,al
out PIC8259A_Port_Command,al
popad
iret
Re: got CMOS time invalid error, each time after I run my ke
Posted: Sun Dec 16, 2007 11:35 am
by Brendan
Hi,
The BIOS probably uses a 12 hour clock and BCD encoding, rather than a 24 hour clock with binary encoding. Completely changing the time clock's format is going to confuse the BIOS, which is why you're getting an "invalid time" error during boot.
Never change the BCD/binary or 12/24 hour flags - read the flags in register 0x0B and use them to determine how to decode/encode values in other RTC registers.
Also, other OSs will assume the RTC is set to UTC or local time or standard time, so you shouldn't set your own time without asking the user if you should use UTC or local time or standard time. IMHO the RTC should *always* be set to UTC in all computers, but unfortunately Microsoft don't agree with sane people.
Cheers,
Brendan
Posted: Sun Dec 16, 2007 8:35 pm
by blackoil
thanks brendan,
and I found that I couldn't changed the keystroke rate on my intel mother board, there is no any BIOS option completely. Whatever I sent to 0x60, I got the same keystroke rate. Is it normal?
Mulder
Posted: Sun Dec 16, 2007 8:38 pm
by Brendan
Hi,
blackoil wrote:and I found that I couldn't changed the keystroke rate on my intel mother board, there is no any BIOS option completely. Whatever I sent to 0x60, I got the same keystroke rate. Is it normal?
That depends - is it a USB keyboard?
Cheers,
Brendan
Posted: Sun Dec 16, 2007 9:21 pm
by blackoil
extremely grandma model, big 5pin head, has to use converter for ps/2 interface. Maybe my typerate routine is incorrect, or intel bios hard coded, as I can't find any option related to keyboard.
I try to use BCD format, the intel BIOS doesn't complain now. Maybe other BIOS won't complain, only intel's.
Mulder
Posted: Sun Dec 16, 2007 9:53 pm
by Brendan
Hi,
blackoil wrote:extremely grandma model, big 5pin head, has to use converter for ps/2 interface. Maybe my typerate routine is incorrect, or intel bios hard coded, as I can't find any option related to keyboard.
That should still work - if you change the typematic rate after boot it should remain changed until you reboot or reset the keyboard (where "reset the keyboard" includes using an older "mechanical switch" style KVM switch, which is like unplugging the keyboard and plugging it back in - keyboard does full reset and sends a BAT).
blackoil wrote:I try to use BCD format, the intel BIOS doesn't complain now. Maybe other BIOS won't complain, only intel's.
I did the same thing years ago and got the same problem. I'm not sure which computer I was using back then, but the BIOS wasn't written by Intel (probably a "new" Pentium machine with an
AMI BIOS).
Cheers,
Brendan
Posted: Sun Dec 16, 2007 10:38 pm
by blackoil
I use these codes to initialize Keyboard in real mode with cli, but seems
Code: Select all
IBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_IBF
jnz IBF8042
ret
OBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_OBF
jz OBF8042
ret
.enableA20: call IBF8042
mov al,0xD1
out PS2_Port_Command,al
.typerate: call IBF8042
mov al,0xF3
out PS2_Port_Data,al
call IBF8042
mov al,0x00
out PS2_Port_Data,al
call OBF8042
in al,PS2_Port_Data
Edited by Brendan: Added code tags
Posted: Mon Dec 17, 2007 2:34 am
by blackoil
;Final revision, works well under DOS
;in Bochs, you can see the KB typematic rate has been changed in log file
Code: Select all
PS2_Port_Command equ 0x64
PS2_Port_Status equ 0x64
PS2_Port_Data equ 0x60
PS2_KB_Bit_IBF equ 00000010b
PS2_KB_Bit_OBF equ 00000001b
bits 16
org 256
cli
call IBF8042
mov al,0xF3
out PS2_Port_Data,al
call IBF8042
mov al,0x1F
out PS2_Port_Data,al
sti
int 0x20
IBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_IBF
jnz IBF8042
ret
OBF8042: nop,,nop,,nop,,nop,,nop
in al,PS2_Port_Status
test al,PS2_KB_Bit_OBF
jz OBF8042
ret
Edited by Brendan: Added code tags