Broadly speaking, a high level OS as described above has five components. These are the boot loader, Board Support Package or BSP, device drivers, middleware, and finally the UI and applications. It's important to know the function of these components befoTe you can do OS porting.
This is a piece of software that_ resides on the non volatile or persistent memory of a computer system, which is responsible for loading the main OS. The need for a boot loader comes from the fact that non volatile memory such as ROM is limited in size and he entire OS run-time image cannot fit into it.
Also, the computer hardware alone (without software) cannot handle complex file-systems and peripherals such as those on hard-disks and flash memories. So, in a typical system, after a power-on or a reset, the CPU starts executing the boot loader code residing in the ROM. The boot loader contains code to initialize peripherals of the CPU to a minimal extent - just enough to obtain the OS run-time image from a peripheral device to the main memory (RAM) and transfer the control to the OS start code.
The boot loader can obtain the OS Image from a local storage device such as a hard disk, compact flash card or download it via a serial connection, Ethernet connection or an USB interface. The boot loader may have to uncompress the OS Image in case it is stored in compressed form.
Modern boot loaders, such as UBOOT (used mostly for Linux) and EBOOT (used for Windows CE) contain a host of other features such, as supports multiple CPUs (ARM, PPC, MIPS, X86), Execute from Flash (NOR Flash), File download from serial, Ethernet, USB etc. Some OS terminology may include boot loader as a part of the Board Support Package (BSP).
Board Support Package
The BSP for an operating system is an implementation specific code for a given HW board containing the CPU and other peripheral devices such as memory and memory controllers, timers, interrupt controllers, USB, Ethernet etc. In case of a SoC, a large part of the 'board' is inside the IC, on the same silicon chip as the CPU core itself.
The BSP provides an abstraction of the hardware (CPU and peripherals) to the generic OS interfaces. It facilitates communication between the OS and target HW device and includes code to manage memory, handle interrupts, timers, power management, bus abstraction, generic I/O control codes (lOCTLs), and so on.
The BSP is one of the most complex parts of the OS porting and integration effort and contains code for the following essential OS services:
Memory Management: The OS may use virtual memory to manage the RAM. The BSP contains code to initialize the Memory Management Unit (MMU) and provide an interface to the higher level OS layers to setup the memory access data structures such as page tables.
Timer: The OS uses the timer for many functions including task scheduling - which is vital for its functioning. The BSP contains code to initialize the timer hardware as per the needs of the OS.
Interrupt Handler: All peripherals to the CPU, such as Serial Bus, USB, Camera Interface etc. typically use interrupts to signal the CPU about data availability or data transfer completions. The CPU then executes the appropriate Interrupt service routines (ISR) to take the necessary actions. The BSP initialČizes the Interrupt mechanism.
Power Management: The OS needs to conserve power on most devices by providing p'ower saving modes such as Full Power, Hibernation, Sleep etc. When the system restarts, it needs to invoke the correct code to handle the wake-up. The BSP initializes the power management system of the Soc. Many more functionalities related to the OS operations are a part of the BSP, which need to be implemented or ported in order to make the OS utilize all features of the underlying soc.