Determine Startup Mode in Android Kernel

Source: Internet
Author: User

Determine Startup Mode in Android Kernel

The problem occurs in the driver group. A problem is that the voltage value set in a driver of the kernel cannot be set to the same as that set in normal mode when started in other modes. In normal mode, the voltage value is 3.3 v, the other mode is 3.0 v. The normal mode is set to 3.3v to solve the problem, but this also brings about a problem that occurs when the abnormal mode (Recovery) is started.

The solution is to let the kernel driver know the startup mode and set the voltage value dynamically.

First, from the perspective of the startup mode, we know that Android determines that the startup mode is usually dependent on the Bootloader startup to check whether the magic key is pressed and then pass it to different kernel parameters. Do you know that the common kernel parameters are stored in/proc/kernel line? To identify the difference, you can only look at it. However, no commands such as cat can be used in the Recovery mode, so the kernel in the Recovery line cannot be obtained. Fortunately, I have previous experience in kernel debugging. I know that the kernel content in cmdline will be printed in the serial port during kernel startup. With the content, you can find out the difference. The differences are as follows:

The text indicates that when the mtdparts parameter is started in abnormal mode, there will be an "0x00002000 @ 0x00000000 (parameter ),"; <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + records/PW + records + m/logs/records/K/records + records/records + b7d1eK49sirvtax5MG/records + records/X6aGj0tTPwsrHztK4 + records + lyo8L3A + Environment + ICo8L3A + Environment + ICo8L3A + Environment + IDwvcD4KPHA + Environment + CjxwPiA8L3A + Environment "Virtual TouchScreen ""

Static struct input_dev * vts_dev;

# Define VTS_MIN_XC 0

# Define VTS_MAX_XC 320

# Define VTS_MIN_YC 0

# Define VTS_MAX_YC 480

Static int _ initdata vts_max_xc = VTS_MAX_XC;

Static int _ initdata vts_max_yc = VTS_MAX_YC;

# Ifndef MODULE

Static int _ initdata vts_use = 0;

/**

* Parse options, format must be vts = widthxheigth

*/

Static int _ init vts_setup (char * str)

{

Char buf [64];

Char * p;

Int xc, yc;

Vts_use = 1;

/* This code reference from: http://blog.chinaunix.net/uid-20729605-id-2876040.html

* Start mode. Normal Mode: "parameter" is not included; other mode: "parameter" is included ".

* Use the _ setup method in the kernel. After registration, the kernel detects whether there is any content.

* Check whether the keyword "parameter" exists in str. If the keyword "parameter" is not found, the system starts normally. If the keyword "parameter" is not found, the system starts in other modes.

* If (isHad)

* Normal_boot = 0;

* Else

* Normal_boot = 1;

* When setting the voltage, determine the value of normal_boot as follows:

* If (normal_boot)

* Voltage = 3.3 v;

*/

/*

Strncpy (buf, str, sizeof (buf ));

P = strchr (buf, 'x ');

If (! P)

Goto out;

* P = '\ 0 ';

Xc = simple_strtoul (buf, NULL, 0 );

Yc = simple_strtoul (p + 1, NULL, 0 );

If (! Xc |! Yc)

Goto out;

Vts_max_xc = xc;

Vts_max_yc = yc;

Return 1;

Out:

Printk (KERN_WARNING "vts: option format must be like 'vts = widthxheigth '."

"Use default config vts = % dx % d \ n", vts_max_xc, vts_max_yc );

*/

Return 0;

}

_ Setup ("mtdparts =", vts_setup );

# Endif

Static int _ init vts_init (void)

{

Int err;

# Ifndef MODULE

If (! Vts_use)

Return-ENODEV;

# Endif

Vts_dev = input_allocate_device ();

If (! Vts_dev ){

Printk (KERN_ERR "vts: not enough memory \ n ");

Err =-ENOMEM;

Goto fail1;

}

Vts_dev-> name = DRIVER_DESC;

Vts_dev-> phys = "vts/input0 ";

Vts_dev-> id. bustype = BUS_VIRTUAL;

Vts_dev-> id. vendor= 0x0000;

Vts_dev-> id. product = 0x0000;

Vts_dev-> id. version = 0x0100;

Vts_dev-> evbit [0] = BIT_MASK (EV_KEY) | BIT_MASK (EV_ABS );

Vts_dev-> keybit [BIT_WORD (BTN_TOUCH)] = BIT_MASK (BTN_TOUCH );

Input_set_abs_params (vts_dev, ABS_X, VTS_MIN_XC, vts_max_xc, 0, 0 );

Input_set_abs_params (vts_dev, ABS_Y, VTS_MIN_YC, vts_max_yc, 0, 0 );

Err = input_register_device (vts_dev );

If (err)

Goto fail2;

Return 0;

Fail2:

Input_free_device (vts_dev );

Fail1:

Return err;

}

Module_init (vts_init );

# Ifdef MODULE

Static void _ exit vts_exit (void)

{

Input_unregister_device (vts_dev );

Input_free_device (vts_dev );

}

Module_exit (vts_exit );

# Endif

MODULE_AUTHOR ("Niu Tao ");

MODULE_DESCRIPTION (DRIVER_DESC );

MODULE_LICENSE ("GPL ");

For more information about _ setup, see _ setup's Role in the kernel.

For the _ setup instance, see virtual touch screen driver + how to transmit parameters to the driver through startup parameters.

Related Article

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.