CN105335178A - Startup control method and apparatus - Google Patents
- ️Wed Feb 17 2016
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a start control method, as shown in fig. 1, including:
101: after receiving a starting-up instruction, the terminal executes a bootstrap program and then receives a mode selection instruction;
in the embodiment of the invention, the bootstrap program is a bootloader which can initialize input devices such as keys, a touch screen and the like, a basic hardware interface, an external memory and the like; the instruction for mode selection may be received after the execution of the boot program. The mode selection command specifies the selected activation mode, which is used to indicate the manner in which to activate, for example: a particular individual function is initiated, or the initiation of all functions.
102: determining a starting mode designated by the mode selection instruction, and determining resource configuration corresponding to the starting mode; the resource configuration defines service and application configurations associated with the launch mode;
in the embodiment of the present invention, the start mode may correspond to one or several independent functions, and an independent function may correspond to some associated server and application configurations, such as:
when the multimedia player function is used, a display screen, an audio module, a gravity sensor, an external TF card (Trans-flash card) and the like need to be started;
when the camera or the video camera function is used, a camera, a flash lamp, a display screen, a TF card and the like need to be started;
using the flashlight function, the flashlight needs to be started;
the function of the recorder is used, and an audio module and a display screen need to be started;
using the function of a Global Positioning System (GPS) navigator, a display screen, a GPS module, a TF card, an audio module, and the like are required to be started;
when the electronic book function is used, a display screen and a TF card need to be started.
The above examples of independent functions are not exhaustive and should not be construed as limiting the embodiments of the present invention.
In the embodiment of the present invention, the resource configuration only needs to have a function of defining the service and application configuration associated with the foregoing start mode, and two optional implementation solutions are provided in the embodiment of the present invention, which are specifically as follows: the resource allocation includes: a kernel configured in the virtual memory disk image file and corresponding to the starting mode automatically starts a resource file; or the virtual memory disk image file corresponding to the starting mode. In the following embodiments, specific applications of the two implementation schemes in the android system will be exemplified.
103: and loading the resource configuration and the kernel image file, and then starting the terminal.
In the embodiment of the invention, the mode selection instruction is appointed in the starting process, and the starting is carried out according to the starting mode appointed by the mode selection instruction, the starting mode corresponds to the resource configuration, the service and the application configuration related to the starting mode are defined in the resource configuration, so that all the applications and services are not required to be started every time, the starting item can be matched with the current requirement, the starting speed is accelerated, the starting time is shortened, and the resources of the terminal are saved.
In the embodiment of the present invention, for different implementation schemes for defining the service and the application configuration associated with the foregoing startup mode, a receiving manner and a processing flow of a mode selection instruction corresponding thereto are also provided, which are specifically as follows: optionally, if the resource is configured to be a kernel self-starting resource file corresponding to a starting mode configured in the virtual memory disk image file, the receiving the mode selection instruction includes: loading a default virtual memory disk image file, and then receiving a mode selection instruction;
the loading the resource configuration includes:
after determining that the kernel self-starting resource file corresponding to the starting mode exists, modifying the starting configuration and restarting the virtual memory disk image file, so that the virtual memory disk image file and the kernel self-starting resource file corresponding to the starting mode in the virtual memory disk image file are loaded in the restarting process.
After the terminal is started, because only part of functions and services may be started at this time, and other functions and services may need to be used in a subsequent use process, the embodiment of the present invention provides a scheme for switching the starting mode, which specifically includes: after the terminal is started, the method further includes:
after receiving a mode switching instruction, starting an application program configured with a starting item corresponding to the mode switching instruction, and starting the starting item corresponding to the mode switching instruction through the application program; or after receiving a mode switching instruction, recording a starting mode corresponding to the mode switching instruction, and then restarting; or after receiving the mode switching instruction, recording the resource configuration corresponding to the starting mode corresponding to the mode switching instruction, and then restarting.
In the two schemes, the former scheme does not need to be restarted and has higher speed. The latter scheme can enable the system to operate more stably and reliably through restarting. In the former mode, the application program that has the startup item that does not correspond to the mode switching instruction may be closed.
For the switching schemes of different starting modes, the embodiment of the present invention further provides a flow scheme for implementing a specific switching instruction, which is specifically as follows: the recording of the resource configuration corresponding to the start mode corresponding to the mode switching instruction includes:
if the resource is configured to be a kernel self-starting resource file corresponding to a starting mode configured in the virtual memory disk image file, writing the file name of the kernel self-starting resource file corresponding to the starting mode corresponding to the mode switching instruction into a parameter linked list;
and if the resource is configured as a virtual memory disk image file corresponding to the starting mode, writing the file address of the virtual memory disk image file corresponding to the starting mode corresponding to the mode switching instruction into the parameter linked list.
The embodiment of the invention can overcome the defect that a certain independent function module of the existing smart phone cannot be quickly started under special conditions, improve the resource utilization efficiency of the smart phone and greatly shorten the starting time of the function module. The embodiments of the present invention will be described in detail below with reference to the accompanying drawings. The following examples are all described by taking the android system as an example.
Fig. 2 is a schematic diagram of the device structure of the smartphone.
The smart phone comprises an input module, a storage module, a baseband and application processing module, a radio frequency module, a peripheral function module and a power supply module.
And the input module comprises a key and a touch screen and is used for inputting a user instruction.
The memory module includes a flash memory and a RAM (Random-access memory, for short, Random access memory). The flash memory is mainly used for backing up programs and data, and the RAM memory is used as a memory for loading and operating programs. When the computer is started, the codes of the flash memory need to be copied into the RAM memory for execution.
And the radio frequency module is used for realizing wireless communication and transmitting wireless data back to the baseband and the application processing module.
The baseband and application processing module processes baseband signals and application programs to complete system control, and is provided with interfaces connected with other external sub-modules.
The peripheral function modules comprise a camera, audio equipment, a display screen, a flash lamp, a radio, keys, various sensors, Bluetooth, WIFI (Wireless-Fidelity), GPS (Global position System), TF (TransFlash) cards and other peripheral modules.
The power module provides power for all modules in the device, and the power of each sub-module can independently control the switch so as to achieve the purpose of power saving.
The embodiment of the invention adopts the following method to realize the quick start of the terminal equipment:
the method comprises the following steps: multiple Ramdisk images select loading.
Fig. 3 depicts a schematic diagram of the method.
Rc file in Ramdisk image file specifies the service and application configuration that needs to be opened or closed in each boot mode. Rc needs to be compiled into a Ramdisk image in advance, and after kernel loads Zimage, kernel cannot be operated before kernel is loaded. Therefore, for each boot mode, there is one Ramdisk image. In the bootloader stage, the bootloader program selects a Ramdisk image to load according to the user input. The input mode can be a key or a touch screen. Rc file is analyzed by the system after kernel loading is completed, so each starting mode shares one kernel image, and only a plurality of Ramdisk image files need to be stored. Each Ramdisk mirror image corresponds to a fixed flash storage address space, and a bootloader loads Ramdisk mirror image files of specified addresses according to user input.
As shown in fig. 3, each init.rc corresponds to an independent startup mode, and the camera quick start configuration, the player quick start configuration, and the radio quick start configuration are sequentially performed from 1 to n.
Fig. 4 is a flowchart of method 1 according to an embodiment of the present invention, please refer to fig. 2 and fig. 3 together, and the starting steps are as follows:
s401, pressing a starting-up key by a user;
s402, powering on the system, and resetting the CPU;
and S403, after the CPU is successfully reset, executing a bootloader program, and initializing peripheral devices such as a hardware interface, a touch screen, a key and the like, a memory device and the like. The hardware interface can realize bottom layer communication, the input module and the display screen work normally, the system can receive external key input information and can print information (for example, information for prompting a user to select a starting mode) on the screen;
s404, the system detects whether a key is input. The input information can be from keys or a touch screen. Entering S405 if the quick start condition (n) is satisfied, and entering S407 if the quick start condition is not satisfied;
s405, if a key is input and the key input meets the input condition of the quick start mode (for example, a certain quick start mode is selected), loading mirror image files such as zimage and Ramdisk corresponding to the quick start mode; in the step, Ramdisk (n) mirror image is loaded;
and S406, starting the independent function module, and finishing quick start.
S407, if the key input does not meet the condition, loading mirror image files such as zimage and default Ramdisk; in the step, Ramdisk (def) mirror images are loaded;
and S408, normally starting the terminal.
And S409, after the user uses the independent function module, the system can open the services and programs of the other modules and switch to other modes. The specific implementation of this step is separately detailed in the following examples.
The method 2 comprises the following steps: rc files are selectively loaded by a single mirror image.
Fig. 5 depicts a functional block diagram of this method.
When the system is started, only one Ramdisk mirror image file is loaded, and a plurality of init. And operating after the kernel is loaded, firstly analyzing a default Init _ def.rc configuration file, simultaneously detecting an external input state, selecting the rc configuration file loaded when the next startup is carried out, then automatically restarting and entering a quick startup mode. And the method can only load the specified init.rc file after restarting because the init.rc file cannot be reloaded after the kernel runs.
In fig. 5, each init.rc corresponds to an independent startup mode, and the camera quick start configuration, the player quick start configuration, and the radio quick start configuration are sequentially performed from 1 to n.
Fig. 6 is a flowchart of method 2 according to an embodiment of the present invention, please refer to fig. 2 and fig. 5 together, and the starting steps are as follows:
s601, pressing a starting button by a user;
s602, powering on the system, and resetting the CPU;
s603, after the CPU is successfully reset, executing a bootloader program, initializing peripheral devices such as a hardware interface, a touch screen, a key and the like, a memory device and the like;
s604, loading a Zimage and ramdisk mirror image, namely copying the mirror image file from a flash to an RAM for running;
s605, starting a kernel, and loading a default Init _ def.rc file by a system; rc (def) is loaded in the step;
s606, kernel detects whether a key is input; if yes, and the input condition of the quick start mode is satisfied, assuming that the quick start condition (n) is satisfied, the process proceeds to S607, and the quick start condition is not satisfied, the process proceeds to S613;
the information input in this step may be from a key or a touch screen.
S607, if the input condition of the quick start mode is met, the start configuration is modified, and the system appoints the Init.rc file to be loaded for next start; rc (n) is specified in this step;
the starting configuration is stored in a parameter linked list, and the parameter linked list is placed at a fixed physical address and can be transmitted among bootloaders, kernel and android.
S608, automatically restarting the system;
s609, loading a Zimage and ramdisk mirror image, namely copying the mirror image file from the flash to the RAM for running;
s610, starting a kernel, and loading a specified init.rc (n) file;
s611, starting an independent function module;
s612, switching other modes: after the user uses the independent function module, the system can open the service and program of the other modules, use the whole functions of the terminal or enter other modes. The specific implementation of this step is separately detailed in the following examples.
S613, the terminal is normally started, and image files such as zimage and Ramdisk are loaded in the step, wherein the kernel is started and loaded with a default init.
Comparison of the above two methods:
the method 2 occupies less flash storage resources. Since method 2 has only one Ramdisk file while method 1 has multiple Ramdisk files. Generally, one Ramdisk file is 2MB-4MB in size, which is equivalent to 2-4MB of space for storing Ramdisk images by a flash in each boot mode. However, the storage space of the terminal is mostly over 1G at present, so the influence on the space occupation can be almost ignored. Method 2 starts at a slightly slower rate. Since method 2 adds one system restart process, the start-up time may be several seconds more than method 1. The above two methods can be chosen according to the need for speed and the hardware conditions.
The embodiment of the invention provides two modes for switching, and can realize switching among various starting modes.
Scheme 1: after the terminal is started, the input module of the system detects a user switching instruction, and then mode switching operation is carried out. The instruction input can be input through physical keys, touch screen interface keys and the like. After the switching instruction is activated, the system starts an upper APP application program, the program starts and loads pre-configured starting services and programs one by one, and services and applications which are not needed in the mode are forbidden.
The operation of scheme 1 may present a certain risk that not all services can be opened by upper layer applications. In addition, due to the complex association between some services, a certain service may not be started or may fail to be started, which may cause other services or applications to fail to be started, thereby risking system instability. Therefore, the embodiment of the present invention provides another preferred implementation scheme as follows:
scheme 2: after the terminal is started, the input module of the system detects a user switching instruction, and then mode switching operation is carried out. If a loading mode is selected by adopting a plurality of Ramdisk mirror images, an address for loading the Ramdisk mirror images at the next starting is appointed, and the configuration is written into a parameter linked list for calling bootloader at the next starting. If a single mirror image is adopted and a plurality of init.rc files are selected to be loaded, the name of the loaded init.rc file at the next starting is appointed, and the configuration is written into a parameter linked list for being called by a kernel at the next starting. And after the configuration of the starting parameters is finished, automatically restarting the system and entering a corresponding starting mode.
Compared with the scheme 1 and the scheme 2, the system has more complete operation of closing and starting the service and the program, and the system operation is more stable and reliable. The disadvantage is that a restart procedure is required and the switching time is relatively long.
The independent functional module mentioned in the embodiment of the present invention may be a combination of one or several peripheral modules, such as:
the functions of the multimedia player are used, and a display screen, an audio module, a gravity sensor, an external TF card and the like are required to be started;
when the camera or the video camera function is used, a camera, a flash lamp, a display screen, a TF card and the like need to be started;
using the flashlight function, the flashlight needs to be started;
the function of the recorder is used, and an audio module and a display screen need to be started;
the GPS navigator function is used, and a display screen, a GPS module, a TF card, an audio module and the like are required to be started;
when the electronic book function is used, a display screen and a TF card need to be started.
The following embodiments give examples of application of two independent functions, and illustrate the embodiments of the present invention, specifically as follows:
an example of a fast-start camera module (using method 1):
in the power-off state, a user presses down the power key and presses down the side key at the same time;
powering on the system, operating the bootloader, detecting that a side key is pressed, and displaying a quick start mode option on a screen;
a user inputs a camera start mode;
bootloader copies Zimage mirror image and Ramdisk (1) (containing camera quick start configuration file) mirror image from flash to RAM;
the Kernel is started, the Init _1.rc configuration file is analyzed, related functional modules such as a camera, a display screen and a TF card are opened, and a camera photographing program is operated; the photographing program can further open modules such as a flash lamp and the like according to the requirements of a user;
after the user finishes using the camera, the user can select a switching menu on the operation interface to switch to other modes.
An example of a fast start multimedia play module (using method 2):
in the power-off state, a user presses down the power key and presses down the side key at the same time;
powering on a system, operating a bootloader, and copying Zimage mirror images and Ramdisk mirror images from a flash to a RAM;
the Kernel analyzes the Init _ def.rc default configuration file and starts, and simultaneously, detects that a side key is pressed down, and displays a quick start mode option on a screen;
a user inputs a multimedia playing mode;
kernel specifies that Init _2.rc (multimedia player configuration) is loaded when the system is started next time, the new configuration is stored in a parameter linked list of a fixed address, and then the system is automatically restarted;
the method comprises the following steps that a system is powered on, a bootloader runs, Zimage mirror images and Ramdisk mirror images are copied to a RAM from a flash, and meanwhile a parameter linked list with starting configuration information is transmitted to a kernel;
kernel analyzes the configuration file of Init _2.rc, opens related function modules such as a display screen, an audio module, a TF card and a sensor, and runs a multimedia player program;
after the user finishes using the camera, the user can select a switching menu on the operation interface to switch to other modes.
An embodiment of the present invention further provides a start control device, as shown in fig. 7, including:
the instruction receiving unit 701 is configured to execute a boot program after receiving a boot instruction, and then receive a mode selection instruction;
a mode determination unit 702 configured to determine a start mode specified by the mode selection instruction;
a configuration determining unit 703, configured to determine a resource configuration corresponding to the start mode; the resource configuration defines service and application configurations associated with the launch mode;
a resource loading unit 704, configured to load the resource configuration and the kernel image file, and then start the terminal.
In the embodiment of the invention, the bootstrap program is a bootloader which can initialize input devices such as keys, a touch screen and the like, a basic hardware interface, an external memory and the like; the instruction for mode selection may be received after the execution of the boot program. The mode selection command specifies the selected activation mode, which is used to indicate the manner in which to activate, for example: a particular individual function is initiated, or the initiation of all functions.
In the embodiment of the present invention, the start mode may correspond to one or several independent functions, and an independent function may correspond to some associated server and application configurations, such as:
when the multimedia player function is used, a display screen, an audio module, a gravity sensor, an external TF card (Trans-flash card) and the like need to be started;
when the camera or the video camera function is used, a camera, a flash lamp, a display screen, a TF card and the like need to be started;
using the flashlight function, the flashlight needs to be started;
the function of the recorder is used, and an audio module and a display screen need to be started;
using the function of a Global Positioning System (GPS) navigator, a display screen, a GPS module, a TF card, an audio module, and the like are required to be started;
when the electronic book function is used, a display screen and a TF card need to be started.
The above examples of independent functions are not exhaustive and should not be construed as limiting the embodiments of the present invention.
In the embodiment of the invention, the mode selection instruction is appointed in the starting process, and the starting is carried out according to the starting mode appointed by the mode selection instruction, the starting mode corresponds to the resource configuration, the service and the application configuration related to the starting mode are defined in the resource configuration, so that all the applications and services are not required to be started every time, the starting item can be matched with the current requirement, the starting speed is accelerated, the starting time is shortened, and the resources of the terminal are saved.
In the embodiment of the present invention, the resource configuration only needs to have a function of defining the service and application configuration associated with the foregoing start mode, and two optional implementation solutions are provided in the embodiment of the present invention, which are specifically as follows: optionally, the resource configuration includes:
a kernel configured in the virtual memory disk image file and corresponding to the starting mode automatically starts a resource file; or the virtual memory disk image file corresponding to the starting mode.
In the embodiment of the present invention, for different implementation schemes for defining the service and the application configuration associated with the foregoing startup mode, a receiving manner and a processing flow of a mode selection instruction corresponding thereto are also provided, which are specifically as follows: further, as shown in FIG. 8,
the instruction receiving unit 701 is configured to, if the resource is configured to be a kernel self-starting resource file corresponding to a start mode and configured in a virtual memory disk image file, first load a default virtual memory disk image file, and then receive a mode selection instruction; the start control device further includes:
a resource determining unit 801, configured to determine whether a kernel self-starting resource file corresponding to the start mode exists;
a configuration modification unit 802, configured to modify and restart the startup configuration after determining that the kernel self-startup resource file corresponding to the startup mode exists;
the resource loading unit 704 is configured to load the virtual memory disk image file during a reboot process, and a kernel self-starting resource file corresponding to a start mode in the virtual memory disk image file.
After the terminal is started, because only part of functions and services may be started at this time, and other functions and services may need to be used in a subsequent use process, the embodiment of the present invention provides a scheme for switching the starting mode, which specifically includes: further, as shown in fig. 9, the start control device further includes:
the instruction receiving unit 701 is further configured to receive a mode switching instruction after the terminal is started;
a startup item control unit 901, configured to start an application program configured with a startup item corresponding to the mode switching instruction after the instruction receiving unit 701 receives the mode switching instruction, and start the startup item corresponding to the mode switching instruction through the application program;
or, the instruction receiving unit 701 is further configured to receive a mode switching instruction after the terminal is started; as shown in fig. 10, the start control device further includes:
a recording unit 1001, configured to record a start mode corresponding to the mode switching instruction after the instruction receiving unit 701 receives the mode switching instruction, or record a resource configuration corresponding to the start mode corresponding to the mode switching instruction after the instruction receiving unit 701 receives the mode switching instruction;
a restart control unit 1002, configured to restart the terminal after the recording unit 1001 completes recording.
In the two schemes, the former scheme does not need to be restarted and has higher speed. The latter scheme can enable the system to operate more stably and reliably through restarting.
For the switching schemes of different starting modes, the embodiment of the present invention further provides a flow scheme for implementing a specific switching instruction, which is specifically as follows: optionally, the recording unit 1001 is configured to, if the resource is configured as a kernel self-starting resource file corresponding to a start mode configured in a virtual memory disk image file, write a file name of the kernel self-starting resource file corresponding to the start mode corresponding to the mode switching instruction into a parameter linked list;
and if the resource is configured as a virtual memory disk image file corresponding to the starting mode, writing the file address of the virtual memory disk image file corresponding to the starting mode corresponding to the mode switching instruction into the parameter linked list.
It should be noted that, in the above device embodiment, each included unit is only divided according to functional logic, but is not limited to the above division as long as the corresponding function can be achieved; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
In addition, it is understood by those skilled in the art that all or part of the steps in the above method embodiments may be implemented by related hardware, and the corresponding program may be stored in a computer readable storage medium, where the above mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the embodiment of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.