OS Operation

The running OS

How can I control timeslicing?

The PC has two timer sources that can be used. Normal practice is to use the Programmable Interval Timer (PIT) timer 0 to generate regular interrupts but there is an alternative timer source in the CMOS/RTC chip.

How do I control machine power consumption?

Official specifications for ACPI are available at http://www.acpi.info/
Check out the Linux ACPI-HOWTO http://www.columbia.edu/~ariel/acpi/
Intel provides an OS-independent reference ACPI implementation at http://www.acpica.org/

What is DMA?

  • DMA (Direct Memory Access) is a mechanism to allow transfers between memory and an I/O device without using the CPU. A DMA controller will generate the appropriate address bus and I/O bus signals to accomplish a transfer.
  • A popular misconception is that to use DMA the I/O port must be connected through the DMA controller. This is wrong. Rather the DMA controller orchestrates the existing system bus lines to accomplish the transfer. In principle DMA can thus control any device connected to the bus.
  • The CPU and the DMA controller cannot both control the system bus lines at the same time or they would conflict. Therefore the CPU has a 'DMA Request' input pin that allows the DMA controller or another device to request temporary control of the system bus lines. The CPU will respond with a 'DMA Acknowledge' signal when it is ready to relinqush control of the system buses (usually for a very short period).
  • Some devices are called bus masters. These incorporate an I/O subsystem and bus control functions. Like DMA they also request control of the system buses but are usually much faster and are dedicated to the ports that sit behind them.
  • DMA is little used on modern PCs which use faster bus mastering for their quicker devices. However, DMA is still used for floppy disk access and may be used on a parallel port in ECP mode and some sound cards.
  • The PC uses DMA channel 2 for floppy disk transfers. This is not to say that the floppy disk must use DMA, only that if you tell the floppy disk controller to use DMA it will trigger DMA channel 2.

How do I program the DMA?

  • When programming DMA bear in mind that the I/O port direction is the converse of that for memory. An I/O port write, for example, needs a memory read. For the PC the DMA direction usually refers to memory. So a DMA write is a DMA memory-write.
  • A PC's 8-bit and 16-bit DMA require some careful manipulation of the DMA address bits.
  • See how DMA works, the 8237 DMA controller, the DMA port map, and how to program the DMA.

How do I load something from a disk?

See under the boot process, above.

How do I draw some graphics on the screen?

You set up a graphics mode using BIOS int 10h first. Use VGA or VESA modes (the latter with linear frame buffer enabled). The BIOS is generally unavailable in the protected mode. To avoid programming the graphics hardware directly you way want to set up the graphics mode before you go protected. VGA and VESA LFB once set need no further interaction with the BIOS. VESA banked modes (the only VESA modes available if LFB isn't supported), however, do need a virtual 8086 task in protected mode. You'll also need VESA VBE (version 3 these days) doc from http://www.vesa.org/ for more details on VESA.

Check out a public domain graphics library http://www.talula.demon.co.uk/allegro/

Do all devices use fixed port addresses?

At first, yes. The keyboard, the mouse, the serial ports, the disk drives, etc., were all on fixed port addresses, for compatibility. Most devices were on the ISA bus.

Now, there are very few that do. Yes, some of these devices are still at fixed port addresses, called legacy devices, but even then, they are emulated by the firmware or other devices.

Now, most devices are on the PCI bus and the PCI bus allows for manipulation of the IO port addresses. Some PCI devices, such as a Hard Drive Controller, will be setup to use the Legacy port address at POST time and act as if it was still on the ISA bus. However, since it is on the PCI bus, your code can change the address it answers to.

For example, on the ISA bus and legacy hard drive controllers, there were capabilities to have up to four controllers with two drives each. Rarely did I see an existing third and fourth controller, but still there was the capability to do so. What if you wanted more than 8 drives? Today, you can plug in many PCI hard drive controllers, set them to any unused port IO address and use as many drives as you want as long as you have open PCI slots. (With the size of hard drives today, why would you need more than 2 :-)

With the addition of USB, you still need a way for the devices to communicate with the mobo, so you have a PCI USB controller that answers to a port IO address that you set it to. Since USB allows 127 devices per controller, all of the 127 devices are controlled by the single controller which answers to 1 IO address space.

++++Next Step
Where to Go Next
