Initialization for IA32

setup_memory analyzes the detected memory regions to find the maximal page frame number in the low memory region; high memory is of no use for the bootmem allocator because it is too complicated to handle. The global variable max_low_pfn holds the number of the highest mappable page. The kernel reports the amount of memory found in its boot logs.

[email protected]> dmesg

0MB HIGHMEM available. 511MB LOWMEM available.

Based on this information, setup_bootmem_allocator is then responsible to initiate all necessary steps to initialize the bootmem allocator. It first invokes the generic function init_bootmem, which itself is a front end for init_bootmem_core.

The purpose of init_bootmem_core is to perform the first initialization step of the bootmem allocator. The previously detected range of low-memory page frames is entered in the responsible bootmem_data_t instance, in this case, contig_bootmem_data. All pages are initially marked as used in the bitmap contig_bootmemdata->node_bootmem_map. Because init_bootmem_core is an architecture-independent function, it cannot yet know which pages are available for use and which are not. Some need special handling for architectural reasons, for example, page 0 on IA-32 systems. Some are already used, for instance, by the kernel image. The pages that can actually be used must be explicitly marked by the architecture-dependent code.

This marking is done with two architecture-specific functions: register_bootmem_low_pages frees all potentially usable memory pages by setting the corresponding bits in the bitmap to 0 so that the pages are marked as unused. IA-32 systems are supported in this task by the BIOS, which provides the kernel with a list of all usable memory areas — the e820 map — at an earlier point during initialization.

Since the bootmem allocator requires some memory pages to manage the reservation bitmap, these must be reserved first by calling reserve_bootmem.

However, there are still more regions that are already in use and must be marked accordingly. For this purpose, reserve_bootmem registers the corresponding pages after the event. The exact number of regions that must be registered depends highly on the kernel configuration. It is, for instance, required to reserve the zeroth page because this page is a special BIOS page on many machines that is required for some machine-specific functions to work properly. Other reserve_bootmem calls reserve configuration-dependent memory areas, for ACPI data or SMP boot-time configurations, for instance.

Continue reading here: Initialization for AMD64

Was this article helpful?

0 0