# Linux Kernel Module Cheat

### 24.20. gem5 bootloaders

Certain ISAs like ARM have bootloaders that are automatically run before the main image to setup basic system state.

We cross compile those bootloaders from source automatically during `./build-gem5`.

As of gem5 bcf041f257623e5c9e77d35b7531bae59edc0423, the source code of the bootloaderes can be found under:

    system/arm/

and their selection can be seen under: `src/dev/arm/RealView.py`, e.g.:

        def setupBootLoader(self, cur_sys, loc):
            if not cur_sys.boot_loader:
                cur_sys.boot_loader = [ loc('boot_emm.arm64'), loc('boot_emm.arm') ]

The bootloader basically just sets up a bit of CPU state and jumps to the kernel entry point.

In aarch64 at least, CPUs other than CPU0 are also started up briefly, run some initialization, and are made wait on a WFE. This can be seen easily by booting a multicore Linux kernel run with gem5 ExecAll trace format.