Android leverages CmdLine to pass parameters from Preloader to kernel

Source: Internet
Author: User

To define the parameter Cus_param as an example, type int variable.

1. Preloader section
Platform.h (mediatek\platform\[$platform]\preloader\src\drivers\inc\platform.h)
Add the Cus_param variable to the following structure, and if it is a char type, note 4byte for it:
typedef struct {
U32 Magic;
boot_mode_t mode;
U32 E_flag;
U32 Log_port;
U32 log_baudrate;
U8 log_enable;
U8 Part_num;
U8 Reserved[2];
U32 Dram_rank_num;
U32 Dram_rank_size[4];
U32 Boot_reason;
U32 Meta_com_type;
U32 meta_com_id;
U32 Boot_time;
da_info_t Da_info;
Sec_limit Sec_limit;
part_hdr_t *part_info;
U8 Md_type[4];
U32 ddr_reserve_enable;
U32 ddr_reserve_success;
U32 Cus_param; MediaTek add
} boot_arg_t;

PLATFORM.C (mediatek\platform\[$platform]\preloader\src\drivers\platform.c)
Add an assignment to the Cus_param in this function, either through a function, or directly to the desired value:
void Platform_set_boot_args ()
{
#if cfg_boot_argument
Bootarg.magic = Boot_argument_magic;
Bootarg.mode = G_boot_mode;
Bootarg.e_flag = Sp_check_platform ();
Bootarg.log_port = Cfg_uart_log;
Bootarg.log_baudrate = cfg_log_baudrate;
Bootarg.log_enable = (U8) log_status ();
Bootarg.dram_rank_num = Get_dram_rank_nr ();
Get_dram_rank_size (bootarg.dram_rank_size);
Bootarg.boot_reason = G_boot_reason;
Bootarg.meta_com_type = (u32) g_meta_com_type;
bootarg.meta_com_id = g_meta_com_id;
Bootarg.boot_time = Get_timer (g_boot_time);

Bootarg.part_num = g_dram_buf->part_num;
Bootarg.part_info = g_dram_buf->part_info;

bootarg.ddr_reserve_enable = g_ddr_reserve_enable;
Bootarg.ddr_reserve_success= g_ddr_reserve_success;

MediaTek Add,mt_get_cus_param This function is customized to get the Cus_param function, please implement it yourself
Bootarg.cus_param = Mt_get_cus_param ();

2.LK part
Boot_mode.h (mediatek\platform\[$platform]\lk\include\platform\boot_mode.h)
Also add the Cus_param variable in the following structure, if it is a char type, note 4byte for it:
typedef struct {
U32 Maggic_number;
Bootmode Boot_mode;
U32 E_flag;
U32 Log_port;
U32 log_baudrate;
U8 log_enable;
U8 Part_num;
U8 Reserved[2];
U32 Dram_rank_num;
U32 Dram_rank_size[4];
U32 Boot_reason;
Meta_com_type Meta_com_type;
U32 meta_com_id;
U32 Boot_time;
da_info_t Da_info;
Sec_limit Sec_limit;
part_hdr_t *part_info;
U8 Md_type[4];
U32 ddr_reserve_enable;
U32 ddr_reserve_success;
U32 Cus_param; MediaTek Add, same as the Preloader section, two structures to be the same
} boot_argument;

MT_BOOT.C (BOOTABLE\BOOTLOADER\LK\APP\MT_BOOT\MT_BOOT.C)
In this function, add the Cus_param information to the CmdLine:
int boot_linux_from_storage (void)
{
.....
Strlen + = sprintf (Commanline, "%s fps=%1d", Commanline, Mt_disp_get_lcd_time ());
Strlen + = sprintf (Commanline, "%s cus_param=%1d", Commanline, G_boot_arg->cus_param); MediaTek add

3.Kernel part
Saved_command_line This is a global variable, in the driver file that you need for this parameter, the extern saved_command_line variable,
By finding the Cus_param string:
char * PTR;
int Cus_param;
ptr = Strstr (saved_command_line, "cus_param=");
PTR + = strlen ("cus_param=");
Cus_param = Simple_strtol (PTR, NULL, 10);
At this point Cus_param is the original int value.

Android leverages CmdLine to pass parameters from Preloader to kernel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.