got CMOS time invalid error, each time after I run my kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

got CMOS time invalid error, each time after I run my kernel

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: got CMOS time invalid error, each time after I run my ke

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post 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
blackoil
Member
Member
Posts: 146
Joined: Mon Feb 12, 2007 4:45 am

Post 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
Post Reply