uboot kernel at boot time, some of the parameters passed to the kernel. It is said that there are two ways bootloader pass parameters to the kernel, the other I do not know, this article describes only the tag structure of the arm architecture mass participation under way.
uboot kernel at boot time, it will pass some parameters, including: RAM location and size of the command line parameters, initrd starting position and size, framebuffer physical address and size of the development board versions.
uboot put every parameter packaged into a structure tag (tag structure see Table 1), tag list to ATAG_CORE tag starting to ATAG_NONE tag as the end of the other parameters in these two between the start tag and the end tag . tag structure placed side by side in a physical memory address (in my development board is set to PHYS_SDRAM_1 + 0x100). So long as the kernel to get this starting physical location, you can parse them one by one tag.
- struct tag {
- struct tag_header HDR;
- Union {
- struct tag_core Core;
- struct tag_mem32 mem;
- struct tag_videotext Videotext;
- struct tag_ramdisk ramdisk;
- struct tag_initrd initrd;
- struct tag_serialnr serialnr;
- struct tag_revision Revision;
- struct tag_videolfb videolfb;
- struct tag_cmdline cmdline;
- / *
- * Acorn specific
- * /
- struct tag_acorn Acorn;
- / *
- * DC21285 specific
- * /
- struct tag_memclk MEMCLK;
- } U;
- };
- int do_bootm_linux ( int flag, int argc, char * argv [], bootm_headers_t * images)
- {
- bd_t * bd = gd-> bd;
- char * s;
- int machid = bd-> bi_arch_number;
- void (* theKernel) ( int zero, int Arch, uint params);
- # Ifdef CONFIG_CMDLINE_TAG
- char * CommandLine = getenv ( "bootargs" );
- # Endif
- IF ((flag! = 0) && (flag! = BOOTM_STATE_OS_GO))
- return 1;
- theKernel = ( void (*) ( int , int , uint)) images-> EP;
- s = getenv ( "machid" );
- IF (s) {
- machid = simple_strtoul (s, NULL, 16);
- printf ( "Using machid 0x% x from environment \ N" , machid);
- }
- show_boot_progress (15);
- debug ( "# # Transferring Control to Linux (at address% 08lx) ... \ N" ,
- (Ulong) theKernel);
- # If defined (CONFIG_SETUP_MEMORY_TAGS) | | \
- defined (CONFIG_CMDLINE_TAG) | | \
- defined (CONFIG_INITRD_TAG) | | \
- defined (CONFIG_SERIAL_TAG) | | \
- defined (CONFIG_REVISION_TAG) | | \
- defined (CONFIG_LCD) | | \
- defined (CONFIG_VFD)
- setup_start_tag (bd);
- # Ifdef CONFIG_SERIAL_TAG
- setup_serial_tag (¶ ms);
- # Endif
- # Ifdef CONFIG_REVISION_TAG
- setup_revision_tag (¶ ms);
- # Endif
- # Ifdef CONFIG_SETUP_MEMORY_TAGS
- setup_memory_tags (bd);
- # Endif
- # Ifdef CONFIG_CMDLINE_TAG
- setup_commandline_tag (bd, commandline);
- # Endif
- # Ifdef CONFIG_INITRD_TAG
- IF (images-> rd_start && images-> rd_end)
- setup_initrd_tag (bd, images-> rd_start, images-> rd_end);
- # Endif
- # If defined (CONFIG_VFD) | | defined (CONFIG_LCD)
- setup_videolfb_tag ((gd_t *) gd);
- # Endif
- setup_end_tag (bd);
- # Endif
- / * We assume that the kernel is in place * /
- printf ( "\ nStarting kernel ... \ N \ N" );
- # Ifdef CONFIG_USB_DEVICE
- {
- extern void udc_disconnect ( void );
- udc_disconnect ();
- }
- # Endif
- cleanup_before_linux ();
- theKernel (0, machid, bd-> bi_boot_params);
- / * Does not return * /
- return 1;
- }
The above code is the process of uboot create kernel parameters, each parameter of the specific implementation, refer lib_arm/bootm.c
Note tag list constructed by the uboot, kernel is responsible for parsing tag list, so uboot and the kernel on the tag list of the structure must have the same definition. If you need to add a new uboot tag type, kernel section also need to add the appropriate type of resolution.
No comments:
Post a Comment