The present application is based on, and claims priority from Taiwan Patent Application Number 104141902, filed Dec. 14, 2015, the disclosure of which is hereby incorporated by reference herein in its entirety.
This disclosure relates to fast booting techniques, and, more particularly, to a method for initializing a peripheral device and an electronic device using the same.
A fast booting function installed in an electronic device, such as a smart phone, a smart appliance, a wearable device or an Internet of Things device makes digital information to be captured conveniently. The electronic device, when closing down, operates in a standby mode, rather than in a real shut-down mode. Although the standby mode reduces the booting time of the electronic device effectively, the electronic device still keeps consuming power and operating in a high power consumption state, which generates a great amount of carbon dioxide.
Currently, an electronic device has the power saving mechanism such as a hibernation or wakeup boot function where the device operates in a real shut down mode or hibernation mode to reduce power consumption. When booting, the electronic device is cold booting by a hibernation booting technique, as shown in
In step S04, a second snapshot image corresponding to a kernel of an operating system in the electronic device is created. In step S05, the first snapshot image and the second snapshot image are written into a permanent storage device of the electronic device. In step S06, the electronic device is powered off.
In step S14, a second snapshot image is loaded from the permanent storage device (about 0.8 second), in which the software settings of the one or more peripheral devices before the hibernation are resumed in step S141. In step S15, the one or more peripheral devices are resumed (about 2.4 seconds), in which the plurality of hardware register settings of the one or more peripheral devices before the hibernation are resumed in step S151. In step S16, the first snapshot image is loaded from the permanent storage device (about 3.0 seconds), and in step S17, a thaw process (e.g., wakeup process) of the electronic device is performed.
In the cold booting process of the electronic device of
Therefore, how to solve the problems of the above mentioned art is becoming an urgent issue.
In an embodiment according to the present disclosure, a method for initializing a peripheral device and an electronic device using the same are provided, which simplify an initialization process of the peripheral device and reduce the booting time of the electronic device.
In an embodiment according to the present disclosure, an electronic device having a hibernation or wakeup booting function comprises: one or more peripheral devices each having one or more registers; a memory having a data storing module; and an instruction capturing module. The instruction capturing module is configured to capture a plurality of hardware register settings from a driver execution process of the one or more peripheral devices, store the plurality of hardware register settings in the data storing module, and serialize or concatenate the plurality of hardware register settings in the data storing module to form serialized hardware register settings, when the electronic device is performing a non-hibernation resume or non-wakeup cold boot to execute an initialization process of the one or more peripheral devices, wherein the one or more peripheral devices are configured to be initialized by the serialized hardware register settings, when the electronic device is performing cold boot again due to a hibernation resume or wakeup to execute the initialization process of the one or more peripheral devices.
In an embodiment according to the present disclosure, a method for initializing a peripheral device comprises: providing an electronic device having a hibernation or wakeup booting function, wherein the electronic device comprises one or more peripheral devices and a memory, the one or more peripheral devices each have one or more registers, and the memory has a data storing module. The method further includes: capturing a plurality of hardware register settings from a driver execution process of the one or more peripheral devices; storing the plurality of hardware register settings in the data storing module; serializing or concatenating the plurality of hardware register settings in the data storing module to form serialized hardware register settings, when the electronic device is performing a non-hibernation resume or non-wakeup cold boot to execute an initialization process of the one or more peripheral devices; and initializing the one or more peripheral devices by the serialized hardware register settings, when the electronic device is performing cold boot again due to a hibernation resume or wakeup to execute the initialization process of the one or more peripheral devices.
The disclosure can be more fully understood by reading the following detailed description of the preferred embodiments, with reference made to the accompanying drawings, wherein:
In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the disclosed exemplary embodiments. However, that one or more embodiments may be practiced without these specific details. In other instances, well-known structures and devices are schematically shown in order to simplify the drawing.
When the electronic device 1 is performing a non-hibernation resume or non-wakeup cold boot (e.g., the first cold boot) to execute an initialization process of the one or more peripheral devices 2, the instruction capturing module 42 captures a plurality of hardware register settings (the hardware instructions 441) and corresponding information thereof (e.g., the execution time or instruction intervals of the hardware instructions) from a driver execution process (the execution process of one or more driving programs 44) of the one or more peripheral devices 2, without capturing a plurality of software settings (the software instructions 442). The instruction capturing module 42 stores a plurality of hardware register settings (the hardware instructions 441) and corresponding information thereof into the data storing module 41, and serializes or concatenates a plurality of hardware register settings (the hardware instructions 441) in the data storing module 41, so as to form serialized hardware register settings (serialized hardware instructions).
The optimization serialization module 43 optimizes an access order of the serialized hardware register settings according to an optimization algorithm to form optimized and serialized hardware register settings.
Then, when the electronic device 1 is performing cold boot (e.g., the second cold booting) due to a hibernation resume or wakeup to execute the initialization process of the one or more peripheral devices 2, the one or more peripheral devices 2 are initialized by the serialized hardware register settings (serialized hardware instructions), or the optimized and serialized hardware register settings (optimized and serialized hardware instructions).
In an embodiment, the electronic device 1 may be, but is not limited to a smart phone, a smart appliance, a wearable device, or an Internet of Things device. The memory 3 may be a volatile memory or a nonvolatile memory. The data storing module 41 may be a data structure or an array. The data structure may be a tree structure or a concatenate (LIST) structure. The array may be an instruction array, and the bus 5 may be a system bus or a sub-bus.
In an embodiment, the operating system 4 and the kernel 40 thereof are disposed in the memory 3, the data storing module 41, the instruction capturing module 42, the optimization serialization module 43 and the memory management module 45 are disposed in the kernel 40, and program codes of the data storing module 41, the instruction capturing module 42 and the optimization serialization module 43 may be centralized program codes combination at a single position or distributed program codes combination at a plurality of positions in the operating system 4.
Then, in step S24, a second snapshot image is loaded from a permanent storage device (not shown) of the electronic device 1, including step S241 in which software settings (the software instructions 442) of the one or more peripheral devices 2 are resumed back to a state before the electronic device 1 is hibernated. In step S25, the one or more peripheral devices 2 are resumed, including step S251 in which the plurality of hardware register settings (the hardware instructions 441) are resumed back to a state before the electronic device 1 is hibernated. In step S26, a first snapshot image is loaded from the permanent storage device. In step S27, a wakeup process of the electronic device 1 is performed.
When step S13 “the one or more peripheral devices are initialized” shown in
A shut-down process of the electronic device 1 of an embodiment according to the present disclosure may be the same as or similar to the shut-down process shown in
According to the above principle, the present disclosure could capture a plurality of hardware register settings H (e.g., H1-H4) or hardware instructions 441 from the driver execution process (execute the driving program 44) of the one or more peripheral devices 2, and serialize or concatenate the plurality of hardware register settings H (e.g., H1-H4) or the hardware instructions 441, so as to form serialized hardware register settings or serialized hardware instructions.
In an embodiment according to the present disclosure, since the plurality of hardware register settings H1-H7 (hardware instructions 441) are captured from the driver execution process of the one or more driving programs 44, and the plurality of hardware register settings H1-H7 (hardware instructions 441) are serialized or concatenated to form serialized hardware register settings (serialized hardware instructions), the serialized execution time of the one or more driving programs 44 is Tb. Therefore, the time needed for the plurality of software settings S1-S7 of the one or more driving programs 44 is saved, so as to obtain the reduced execution time of the one or more driving programs 44, that is Tc (i.e., Ta-Tb).
As shown in the embodiment of
In an embodiment, an optimization algorithm of the optimization serialization module 43 is used to optimize the serialized hardware instructions (see Tm1) or serialize an access order of the hardware register settings, so as to form optimized and serialized hardware instructions (see Tm3) or optimized and serialized hardware register settings. In an embodiment, the optimization algorithm of the optimization serialization module 43 inserts a plurality of hardware instructions 441 (e.g., B1-B4, C1-C6) into one or more idle time “idle” (see Tm2) sequentially, so as to form optimized and serialized hardware instructions (see Tm3) or optimized and serialized hardware register settings. When the electronic device 1 is performing a cold boot again (e.g., the second cold boot) to execute the initialization process of the one or more peripheral devices 2, the one or more peripheral devices 2 can be initialized by the optimized and serialized hardware instructions (see Tm3) or the optimized and serialized hardware register settings.
In an embodiment, the optimization algorithm serializes or concatenates, through the bus 5, the serialized hardware instructions (e.g., A1-A6, B1-B5, C1-C6 in the time distribution Tm1) into the optimized and serialized hardware instructions (e.g., A1, A2, A3, B1, . . . , C6 in the time distribution Tm3), the time distribution Tm3 of the optimized and serialized hardware instructions is a plurality of instruction-sending time (e.g., T1′, T2′, T3′, T7′, Tn′), and the plurality of instruction-sending time T1′-Tn′ may be the same or different from one another. Therefore, the reduced execution time of the bus 5 is Td.
As shown in the embodiment of
One or more nodes N (e.g., N2-N8) represent one or more peripheral devices 2 (e.g., L11-L13, L21-L23, L31), respectively, and a relation of the nodes N (e.g., N2-N8) represents dependency of a plurality of peripheral devices 2 (e.g., L11-L13, L21-L23, L31), when there are a plurality of peripheral devices. In an embodiment, nodes N2-N4 are disposed at the same layer (e.g., brotherhood relation), which indicates that the peripheral device L11-L13 are independent, without dependency. In another embodiment, nodes N2 and N5 are disposed at an upper layer and a lower layer, respectively, which indicates that the peripheral devices L11 and L21 are not independent, with dependency existing therebetween instead.
As shown in the embodiment of
In an embodiment, the driver execution process DP of the plurality of peripheral device 2 executes the nodes in the following order: (1) node N1 (root node), (2) a peripheral device L11 of node N2 (child node), (3) a peripheral device L12 of node N3, (4) a peripheral device L13 of node N4, (5) a peripheral device L12 of node N3, (6) a peripheral device L21 of node N5, (7) a peripheral device L22 of node N6, (8) a peripheral device L21 of node N5, (9) a peripheral device L23 of node N7, (10) a peripheral device L22 of node N6, and (11) a peripheral device L31 of node N8.
As shown in
When the one or more driving programs 44 reads/writes the one or more registers 21 with the virtual address of the second page 47 (step S31), a page fault is generated since the virtual address of the second page 47 is non-readable/non-writable, and a page fault processing unit 452 (step S32) is entered. The page fault processing unit 452 records readable/writable physical address and data of the one or more registers 21 into the data storing module 41 (step S33), and the driving program 44 reads/writes the one or more registers 21 through the virtual address of the first page 46 actually (step S34). The instruction capturing module 42 monitors reading/writing behaviors among the one or more driving programs 44, the memory 3, the register 21 and the page fault processing unit 452, so as to capture a plurality of hardware register settings (hardware instructions), wherein the reading/writing behaviors can be setting behaviors, input/output (I/O) behaviors or access behaviors.
As shown in
As shown in
As shown in the embodiment of
In an embodiment, in step S441, the memory 3 of the electronic device 13 provides or creates a data storing module 41, such as a data structure (a tree structure, a concatenated structure) or an array (an instruction array). In step S442, a plurality of hardware register settings (hardware instructions 441) and corresponding information thereof (e.g., the execution time or the instruction intervals for the hardware instructions) are captured from the driver execution process of the driving programs 44 of the one or more peripheral devices 2, so as to store the plurality of hardware register settings (hardware instructions 441) and corresponding information thereof in the data storing module 41. In step S443, the plurality of hardware register settings (hardware instructions 441) in the data storing module 41 are serialized or concatenated, so as to form serialized hardware register settings (serialized hardware instructions).
Step S444 can be executed or not to be executed optionally. In step S444, the access order of the serialized hardware register settings (serialized hardware instructions) is optimized, so as to form optimized and serialized hardware register settings (optimized and serialized hardware instructions).
The method for initializing one or more peripheral devices 2 according to the present disclosure has been described in details in
As shown in
In step S54, the one or more peripheral devices 2 are initialized by the serialized hardware register settings (serialized hardware instructions), or the optimized and serialized hardware register settings (optimized and serialized hardware instructions). In step S55, a hibernate file is loaded. In step S56, the one or more peripheral devices 2 are resumed. In step S57, a thaw process (e.g., wakeup process) of the electronic device 1 is performed.
It is known from the above description that in a method for initializing a peripheral device and an electronic device using the method according to the present disclosure, when the electronic device is performing a non-hibernation resume or non-wakeup cold boot for the first time to initialize one or more peripheral devices, a plurality of hardware register settings (hardware instructions) are captured from a driver execution process of one or more peripheral devices and stored in a data storing module (e.g., a tree structure), and a plurality of hardware register settings are serialized or concatenated to form serialized hardware register settings (serialized hardware instructions). Besides, the serialized hardware register settings (serialized hardware instructions) can be further optimized to form optimized and serialized hardware instructions.
Therefore, in a method for initializing a peripheral device and an electronic device using the method according to the present disclosure the initialization process of the one or more peripheral devices is simplified, and only the serialized hardware register settings (serialized hardware instructions) or the optimized and serialized hardware register settings (optimized and serialized hardware instructions) are executing to initialize the one or more peripheral devices when the electronic device is performing a hibernation resume or wakeup cold boot again. Therefore, the initialization time for the one or more peripheral devices and the booting time for the electronic device are reduced.
To those skilled in the art that various modifications and variations can be made to the disclosed embodiments without departure the principle of the disclosure. It is intended that the specification and examples be considered as exemplary only, with a true scope of the disclosure being indicated by the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
104141902 | Dec 2015 | TW | national |