U-boot passes RAM and Linux kernel reads RAM parameters

U-Boot passes a variety of parameters to the Linux kernel, such as serial port settings, RAM information, video framebuffer details, and more. The Linux kernel processes these parameters by reading them from a structure known as "tag." U-Boot stores the data it needs to pass to the kernel in this tag structure. When the kernel starts, it receives the physical address of this structure. Using this address, the kernel parses the passed parameters through the `parse_tags` function. In this explanation, we focus on how U-Boot passes RAM information to the Linux kernel and how the kernel reads those parameters. 1. **How U-Boot Passes RAM Parameters to the Kernel** The `do_bootm_linux` function in `./lib_arm/bootm.c` is called when U-Boot boots a Linux kernel. This function handles various setup tasks, including creating the tag list that will be passed to the kernel. Inside `do_bootm_linux`, several functions are called to initialize different types of tags. For example: - `setup_start_tag(bd)` initializes the beginning of the tag list. - `setup_memory_tags(bd)` sets up memory-related tags, including RAM information. - `setup_end_tag(bd)` marks the end of the tag list. These functions fill the `struct tag` with data such as memory bank addresses and sizes. The `bd` structure holds board-specific information, including the RAM configuration. The `setup_memory_tags` function loops through all the memory banks defined in the board's `bd` structure and creates an `ATAG_MEM` entry for each one. It writes the start address and size of each memory bank into the tag structure. Finally, the kernel is started with the command `theKernel(0, machid, bd->bi_boot_params)`, where `bd->bi_boot_params` is the physical address of the tag list. This address is used by the kernel to parse the tags. 2. **How the Linux Kernel Reads the Parameters Passed by U-Boot** When the Linux kernel starts on an ARM platform, it eventually calls `start_kernel()`. Inside `start_kernel()`, the `setup_arch()` function is called, which handles architecture-specific initialization, including parsing the tags passed by U-Boot. The `setup_arch()` function uses the `__atags_pointer` variable, which points to the location of the tag list in memory. If this pointer is valid, the kernel uses it to access the tags. Otherwise, it falls back to the `mdesc->boot_params` value, which is set during board initialization. Once the tags are located, the kernel calls `parse_tags(tags)`, which processes each tag. For memory-related tags (`ATAG_MEM`), the `parse_tag_mem32()` function is called, which in turn calls `arm_add_memory(start, size)` to add the memory information to the kernel's internal `meminfo` structure. This allows the kernel to know the available RAM and how to manage it during boot. 3. **Understanding `bd` and `gd` in U-Boot** U-Boot maintains two important global structures: `gd_t` (global data) and `bd_t` (board data). The `gd_t` structure contains many global variables, including the `bd` pointer, which holds board-specific information like memory layout. The `bd_t` structure includes details such as the base address of SDRAM, the number of memory banks, and their respective start and size values. These values are used by U-Boot to construct the memory tags that are passed to the kernel. The `DECLARE_GLOBAL_DATA_PTR` macro is used to declare the `gd` pointer, which is stored in the R8 register on ARM platforms. This allows quick access to global data throughout the U-Boot code. 4. **Summary** In summary, U-Boot constructs a tag list containing essential system information, such as RAM configuration, and passes it to the Linux kernel. The kernel then processes these tags to understand the hardware environment. This interaction is crucial for proper system initialization and resource management. The version of U-Boot discussed here is 1.3.4, and the Linux kernel version is 2.6.28, running on an ARM platform.

Insulated Copper Tube Terminals

Insulated Copper Tube Terminals,High quality insulated terminal,copper tube terminal

Taixing Longyi Terminals Co.,Ltd. , https://www.txlyterminals.com