RTC Rate? VESA mode?

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
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

RTC Rate? VESA mode?

Post by pcmattman »

Does anyone know how to find out how many times per second the RTC 'ticks'? I need to be able to write sleep functions that work on seconds, at the moment it's on ticks. Any ideas?

Also, how can I access and enable VESA modes from my C kernel (without a vm) and what's this whole 'plane switching' idea?
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

Real time clock? It either ticks at the processor's clock speed or 2^15 times per second.

And if you do a search on this forum, you should find a way to change VESA modes using outb.
My OS is Perception.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: RTC Rate? VESA mode?

Post by Combuster »

Also, how can I access and enable VESA modes from my C kernel (without a vm)
C + protected mode + no vm + vesa eliminates pretty much all options without considerable amounts of hacking/work :-/

the only clean option:
4: write an emulator

Given that, you might consider lowering your standards and either
1: leave protected mode, call int, return (which requires a decent amount asm, violating the C premise)
2: virtual 8086 mode (violating the vm premise)
3: VBE protected mode interface (requires 16-bit pm code, assembly once again, also IIRC its poorly supported)
5: write specific drivers (violating the VESA premise, since at this point it becomes a native mode instead of a VESA mode, limited support, since high-resolutions are nonstandard and a VGA doesnt provide those without hurting your eyes)

Where 1 and 2 are the most common solutions, 1 being the easiest, and 2 being technically better.
what's this whole 'plane switching' idea?
A standard video mode only provides access to the framebuffer from 0xA0000-0xAFFFF (64k). Many resolutions don't fit in that. Vesa and VGA provide methods to access all of their memory through that area using bank switching/plane switching respectively. What you do is tell the video card to map Axxxxh to location y*xxxx+z in its framebuffer. Changing y and z are considered bank/plane switches.

for VESA cards you can simply do an int 0x10 call, and the card will change its 'z' (y is always 1)

for VGA cards you have to write to the vga ports to achieve the same thing. However, on the vga y will generally equal 4 and z can only be 0..3, while on a VESA z can contain very large values.

Since this approach can be troublesome, many modern video cards use a linear framebuffer: the location you write to becomes something like 0xE0000000 + location, which is in such a location that its not hampered by the 64k limit from ancient times.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: RTC Rate? VESA mode?

Post by Brendan »

Hi,
pcmattman wrote:Does anyone know how to find out how many times per second the RTC 'ticks'?
The RTC periodic interrupt (IRQ 8) should be configured by the BIOS to generate an IRQ every 976.5625 us (a frequency of 1024 Hz). It can also be programmed for different frequencies, ranging from 8192 Hz to 2 Hz in powers of 2 (or 122.0703125 us to 500 ms).

Before the RTC will generate any IRQ you need to enable the periodic IRQ in "RTC Register C". There's also other IRQ sources (a once per second "update IRQ" and an "alarm IRQ"). If you enable more than one IRQ source then you'll need to check which IRQ source caused the IRQ within the IRQ 8 handler.


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.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: RTC Rate? VESA mode?

Post by pcmattman »

Combuster wrote:Given that, you might consider lowering your standards and either
1: leave protected mode, call int, return (which requires a decent amount asm, violating the C premise)
2: virtual 8086 mode (violating the vm premise)
Can you give me any sites/tutorials about virtual 8086 mode? I've looked at the intel manuals, but I need some basic code to get started. Is it based on the TSS or not?
Post Reply