2. Linux Kernel Organization
• Linux supports numerous architectures this
means that it can be run on many types of
processors, which include alpha, arm, i386,
ia64, ppc, ppc64, and s390x.
• Most of the source code is written in C and is
hardware independent
• A portion of the code is heavily hardware
dependent and is written in a mix of C and
assembly for the particular architecture.
• The heavily machine-dependent portion is
wrapped by a long list of system calls that serve
as an interface.
Embedded Linux Course
10. Bootstrap Loader
• Not to be confused with a bootloader, many
architectures use a bootstrap loader (or second-stage
loader) to load the Linux kernel image into
memory.
• Some bootstrap loaders perform checksum
verification of the kernel image, and most
perform decompression and relocation of the
kernel image.
• The bootloader controls the board upon power-up
and does not rely on the Linux kernel in any
way
Embedded Linux Course
11. Bootstrap Loader (cont.)
• In contrast, the bootstrap loader's primary
purpose in life is to act as the glue between a
board-level bootloader and the Linux kernel
• It is the bootstrap loader's responsibility to
provide a proper context for the kernel to run in,
as well as perform the necessary steps to
decompress and relocate the kernel binary
image
• It is similar to the concept of a primary and
secondary loader found in the PC architecture.
Embedded Linux Course
13. ARM boot control flow
Uboot
Embedded Linux Course
head.o
head.o
main.o
start
start
start_kernel
Power On
Boot loader Bootstrap
loader
Kernel
vmlinux
Kernel
arch/arm/boot/compressed/head.S main.o
arch/arm/kernel/head.S
14. Kernel Entry Point: head.o
• arch/<ARCH>/kernel/head.S
• The head.o module performs architecture- and
often CPU-specific initialization in preparation for
the main body of the kernel. CPU-specific tasks
are kept as generic as possible across
processor families
• Machine-specific initialization is performed
elsewhere
Embedded Linux Course
15. head.o performs the following tasks
• Checks for valid processor and architecture
• Creates initial page table entries
• Enables the processor's memory management
unit (MMU)
• Establishes limited error detection and reporting
• Jumps to the start of the kernel proper, main.c
Embedded Linux Course
16. Kernel Startup: main.c
• Every architecture's head.o module has a similar
construct for passing control to the kernel
proper.
– b start_kernel
• start_kernel() located in .../init/main.c.
• main.c does all the startup work for the Linux
kernel, from initializing the first kernel thread all
the way to mounting a root file system and
executing the very first user space Linux
application program.
Embedded Linux Course
17. Further Study
• See the architecture-dependent portions of the
linux source code, for example, system
initialization and bootstrapping, exception vector
handling, address translation, and device I/O.
• Cross-Referencing Linux
– http://lxr.linux.no
To create a device driver, the programmer must have a
register-leve specification for a given piece of hardware
Embedded Linux Course