Arch: Hardware Basics - rFronteddu/general_wiki GitHub Wiki

Notorious registers

  • Program Counter (PC): Contains the address of the next instruction to be executed. Automatically incremented each time an instruction is fetched.
  • Stack Pointer (SP): Processors access large amounts of external read/write RAM which facilitates temporary storage of data. The stack is a way of saving and restoring temporary values in external memory. The stack works on a LIFO basis. Some processor's stacks grow upwards towards the top of memory whilst others grow downwards towards the bottom, or base, of memory. Some support both types.
  • Processor Status (PS): This registers holds instructions' results and other information about the current state of the processor (such as if the processor is operating in kernel or user mode).

Memory

The fastest memory is known as cache. Very fast but expensive. Some processors have one cache to contain both instructions and data while others have separate ones. Cache and main memories must be kept in step (coherent), when one is modified the change must be reflected in the other. This is done partially by the HW and partially by the OS.

Buses

System components are interconnected by connection systems known as buses. The system bus is divided into three logical functions; the address bus (specifies memory locations for the data transfers), the data bus (holds the data transferred, also bidirectional, allows data to be read into the CPU and written from the CPU), and the control bus (various lines used to route timing and control signals throughout the system). Well known examples are ISA and PCI. Controllers in peripherals are connected to the CPU through buses. Controllers are processors like the CPU and they can be viewed as intelligent helpers to the CPU. Controllers usually have registers the CPU can read and write to control them. Each controller on a bus can be individually addressed by the CPU, this is so that the SW device driver can write to its registers and thus control it.

Address Spaces

The system bus connects the CPU with the main memory and is separate from the buses connecting the CPU with peripherals. The memory space the peripherals exist in is known as I/O space. The CPU can access both the system and the I/O space memory, whereas the controllers themselves can only access system memory indirectly with the help of the CPU.

When controllers need to read/write large amounts of data directly to or from system memory (for example when user data is being written to the HD), Direct Memory Access (DMA) controllers are used to allow HW peripherals to directly access system memory under strict control and supervision of the CPU.

Timers

Modern PC include a peripheral called the Real Time Clock (RTC). This provides reliable time of day and accurate timing interval. The RTC has its own battery so that it continues to run even when the PC is not powered on.