We are developing an operating system for my personal research and practical education. For the academic purpose, this motivation is similar to MINIX, but we do not focus on theories. Our main objective is to provide knowledges on hardware-related programming. This is one of the most difficult and complex parts when we start the development of operating system from scratch.
The source code is available at the public github repository.
Programmable Interval Timer (PIT), Intel 8253/8254 implements a crystal oscillator and generates a periodic or interval signal output. Usually, the signal output is handled by CPU as an interrupt through PIC. Here, PIT is used as timer.
The I/O port assignment of PC/AT-compatible machines is summarized in Input/output base address in Wikipedia [external]. In PC/AT-compatible machines, port 40h, 41h, and 42h are connected to the data I/O ports of counter 0, 1, and 2, respectively.
The document of Intel 8254 PIT is found in 8254 PROGRAMMABLE INTERVAL TIMER [external,pdf].
In the official manual of Intel 8253/8254, mode 3 supports odd values. However, it is recommended to be even values for mode 3 in Programmable Interval Timer [external]. I don't know why OSes typically use mode 3 instead of mode 2...