Suggested addition to Bran's Known Bugs
Posted: Tue Jun 08, 2010 11:35 pm
I understand the tutorial is located elsewhere, but it is referenced here and there is a Known Bugs page here.
In Bran's discussion of the Programmable Interval Timer, there is the following function. I have aded the comment and the first line of code.
In Bran's discussion of the Programmable Interval Timer, there is the following function. I have aded the comment and the first line of code.
Code: Select all
void timer_phase(int hz)
{
/*
* The low order 16 bits of divisor is sent to the PIT to load a 16 bit countdown timer.
* Any value of hz that results in divisor being greater than 64k will produce erratic
* results because only the low 16 bits of the resulting divisor will be used.
* The smallest value of hz acceptable is thus 19.
* The bios usually will set the countdown register at the largest possible value
* 64k-1, resulting in an interrupt frequency of 18.2065 Hz.
* see http://wiki.osdev.org/Programmable_interval_timer
*/
if (hz < 19) hz = 19; /* see comment above */
int divisor = 1193180 / hz; /* Calculate our divisor */
outportb(0x43, 0x36); /* Set our command byte 0x36 */
outportb(0x40, divisor & 0xFF); /* Set low byte of divisor */
outportb(0x40, divisor >> 8); /* Set high byte of divisor */
}