The k project

Input/Outputs

I/O Ports

Port I/O allows the cpu to communicate with an external device. There are 65536 available I/O port addresses. To send data to I/O port mapped devices, you can use the instruction OUT (and OUTS). To receive data from I/O port mapped devices, you can use the instruction IN (and INS).

Usually, I/O ports can’t be accessed from userland, but this behavior can be customized, with the IOPL value in EFLAGS and the TSS.

In K, you will need I/O ports for: - The serial driver - The PIC - The PIT - The Keyboard

Memory-mapped I/O

Memory-mapped I/O is accessed as normal memory, and access to memory-mapped is protected the same way the memory is protected (segmentation or pagination).

Memory-mapped devices have an address range of physical memory allowed to them. It implies that the memory-mapped I/O address space has the same size as the physical address space of your CPU.

In K, you will use memory-mapped I/O for the VGA framebuffer.

Resources