Data read-write method, electronic device, program product and readable medium
By detecting the shutdown status and executing the shutdown process during the charging process of the electronic device, the problem of IRP timeout caused by the shutdown of the electronic device is solved, and the stability and integrity of the data reading and writing process are achieved.
Patent Information
- Application Number
- CN202411217901.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-08-29
AI Technical Summary
During the charging process of the electronic device, if ACPI is reading the NTC temperature value stored in the EC through I2C, the electronic device shuts down, causing the IRP timeout problem.
By detecting whether the electronic device is triggered to shut down, if the shutdown state is detected, the processor will perform the shutdown process of the electronic equipment based on the indicator information to ensure that the interface connection is disconnected before reading the temperature value. IRP timeout.
It effectively avoids the IRP timeout problem caused by the shutdown of electronic equipment and ensures the stability and integrity of the data reading and writing process.
Smart Images

Figure CN119336673A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data reading and writing method, an electronic device, a computer program product, and a computer-readable storage medium. Background Art
[0002] When the electronic device is charging, the processor can set the battery charging current based on the temperature value of the NTC thermistor (NTC temperature value for short). The processor can obtain the NTC temperature value from the embedded controller (EC) through the Advanced Configuration and Power Interface (ACPI). ACPI and EC communicate data based on I2C.
[0003] Before the electronic device enters the shutdown state, if ACPI is reading the NTC temperature value stored in the EC through I2C, the shutdown of the electronic device causes an I / O request packets (IRP) timeout problem to occur in the electronic device. Summary of the invention
[0004] The present application provides a data reading and writing method, an electronic device, a computer program product and a computer-readable storage medium, which can solve the problem of IRP timeout in an electronic device due to the shutdown of the electronic device during the process of writing the NTC temperature value on the EC side into the processor.
[0005] In order to achieve the above objectives, this application provides the following technical solutions:
[0006] In a first aspect, the present application provides a data reading and writing method for an embedded electronic device, the electronic device comprising a first processor and a second processor, the first processor and the second processor communicating data through a first interface; the data reading and writing method comprises: the electronic device is in a charging state, the first processor obtains a temperature value stored by the second processor through the first interface, and adjusts the charging current of the electronic device based on the temperature value, the temperature value is used to indicate the temperature of the electronic device; during the charging process of the electronic device, the first processor detects that the electronic device is triggered to shut down, then based on the indication information, executes the shutdown process of the electronic device, the indication information is used to indicate that the operation of the first processor obtaining the first temperature value through the first interface is completed.
[0007] It can be seen from the above content that: during the charging process of the electronic device, the first processor detects that the electronic device is triggered to shut down, that is, enters the S5 state, and the first processor can complete the shutdown process of the electronic device based on the indication information, avoiding the problem of IRP timeout caused by the first processor reading data through the first interface without a return message due to the shutdown of the electronic device during the process of writing the NTC temperature value on the EC side into the processor. It can be understood that the indication information is the return message of the first processor reading data through the first interface.
[0008] Based on the first aspect, in a possible implementation, during the charging process of the electronic device, after the first processor detects that the electronic device is triggered to shut down, the method further includes: the first processor sets the first flag to a second value. The first processor sets the first flag to the second value, such as False, to indicate that the electronic device is not in a normal state, that is, enters a shutdown state.
[0009] Based on the first aspect, in one possible implementation, the first processor detects that the electronic device is triggered to shut down, including: the first processor detects whether the connection between the second processor and the first interface is disconnected based on an instruction to obtain a temperature value; the first processor detects that the connection between the second processor and the first interface is disconnected.
[0010] In this implementation, before the first processor acquires the temperature value based on the temperature value acquisition instruction, it first detects whether the connection between the second processor and the first interface is disconnected, and then determines whether the electronic device is triggered to shut down. When the connection between the second processor and the first interface is disconnected, the first processor can complete the shutdown process of the electronic device based on the indication information, and it can also avoid the problem of IRP timeout caused by the first processor reading data through the first interface without a return message due to the shutdown of the electronic device during the process of writing the NTC temperature value on the EC side into the processor.
[0011] In some embodiments, the first processor detects that the connection between the second processor and the second interface is not disconnected based on the temperature value acquisition instruction, and then the first processor reads the temperature value stored by the second processor through the first interface. The first processor can read the temperature value by reading the temperature value once at a certain interval.
[0012] Based on the first aspect, in a possible implementation, before the first processor detects whether the connection between the second processor and the first interface is disconnected based on the temperature value acquisition instruction, the method further includes: the first processor determines that the first flag is a first value. The first value is used to indicate that the electronic device is in a normal state, such as True.
[0013] Based on the first aspect, in a possible implementation, detecting whether the connection between the second processor and the first interface is disconnected includes: the first processor detecting whether the first parameter indicates that the connection between the second processor and the first interface is disconnected.
[0014] Based on the first aspect, in one possible implementation, the electronic device further includes a third processor, and the first processor and the third processor communicate data through a second interface. The method further includes: when the third processor transmits first data to the first processor through the second interface, the third processor detects that the electronic device enters a low power consumption state, and the third processor stops transmitting the first data to the first processor through the second interface.
[0015] In this implementation, the third processor may be the MCU of the pressure-sensitive touch panel. When the third processor transmits the first data to the first processor through the second interface, the third processor detects that the electronic device has entered a low-power state, and the third processor stops transmitting the first data to the first processor through the second interface. This can avoid the problem of IRP timeout when the electronic device enters a low-power state due to the inability to be shut down due to data transmission through the second interface.
[0016] Based on the first aspect, in a possible implementation manner, the first data refers to maintenance data of the third processor. In some embodiments, the maintenance data includes: system logs and dot data.
[0017] Based on the first aspect, in a possible implementation, the method further includes: in response to the electronic device entering a low power consumption state, the first processor shuts down the second interface.
[0018] Based on the first aspect, in a possible implementation, it further includes: in response to the electronic device entering a normal state from a low power consumption state, the third processor transmits first data to the first processor through the second interface. The first data is data that was not successfully transmitted when the third processor transmitted data to the first processor through the second interface. Based on this, the electronic device enters a normal state from a low power consumption state, and the third processor transmits the first data to the first processor through the second interface, so that the data of the untransmitted function can be transmitted to the first processor again.
[0019] Based on the first aspect, in a possible implementation, before the third processor transmits the first data to the first processor through the second interface, the method further includes: the first processor opens the second interface and configures parameters of the second interface.
[0020] In a second aspect, the present application provides an electronic device comprising: multiple processors and a memory, the multiple processors comprising a first processor, a second processor and a third processor; the memory is coupled to the multiple processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and when the multiple processors execute the computer instructions, the electronic device executes the data reading and writing method as described in any one of the first aspects.
[0021] In a third aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed, is specifically used to implement the data reading and writing method as described in any one of the first aspects.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, which, when executed, is specifically used to implement the data reading and writing method as described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 The architecture diagram of the SOC reading the NTC temperature value provided in the embodiment of the present application;
[0024] Figure 2 A hardware structure diagram of an electronic device provided in an embodiment of the present application;
[0025] Figure 3 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0026] Figure 4 A timing diagram of a data reading and writing method provided in an embodiment of the present application;
[0027] Figure 5 This is a diagram showing the IRP timeout problem when the housekeeper application reads the MCU maintenance data;
[0028] Figure 6 A timing diagram of a data reading and writing method provided in another embodiment of the present application. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more; "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0030] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0031] The multiple involved in the embodiments of the present application means greater than or equal to two. It should be noted that in the description of the embodiments of the present application, the words "first", "second", etc. are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying an order.
[0032] During the charging process, the electronic device usually sets the charging current of the battery based on the temperature value of the NTC thermistor (NTC temperature value for short, which is the first temperature value). When the NTC temperature value is high, the charging current of the electronic device should be lowered to avoid overheating of the device. The NTC temperature value usually indicates the temperature of the electronic device. The electronic device can set thermistors in multiple locations to indicate the temperature of multiple areas of the electronic device. For example, the electronic device is a PC, and the PC is provided with thermistors in three locations, including: the location of the SOC (System-on-a-Chip, chip-level system), the location of the Type-C interface, and the location of the keyboard. In addition, the power management chip (Power Management IC, PMIC) can store the NTC temperature value.
[0033] The SOC (first processor) of the PC includes an ADSP (audio DSP) module, which is provided with an ARM PC charging module. The ARM PC charging module usually reads the NTC temperature value once every 5 seconds and sets the charging current value based on the NTC temperature value, but the ARM PC charging module cannot read the NTC temperature value directly from the PMIC.
[0034] The reasons were found: Figure 1 As shown, the SOC and PMIC are connected via the SPMI0 bus ( Figure 1 The clock line and data line of the SPMI0 bus are connected, but the SPMI0 bus is not enabled. Therefore, the ADSP cannot directly read the NTC temperature value on the PMIC side through the SPMI0 bus.
[0035] To this end, the embedded controller (EC) (second processor) can read and store the temperature value of the thermistor, and transmit the temperature value of the thermistor to ADSP through ACPI (first interface), which is a bridge for data communication with ADSP. Since the communication between ACPI and EC is based on I2C, and the communication between ACPI and ADSP is through Glink, ACPI cannot actively read the NTC temperature value from EC and write it to ADSP. A driver module in the driver layer of the operating system (OS) needs to call ACPI to drive ACPI to read the NTC temperature value stored in EC through I2C and then write it to ADSP.
[0036] When the electronic device is running and the OS system enters S5 (shutdown) from S0 (normal), if the driver module has called ACPI to read the NTC temperature value stored in the EC through I2C, but the OS system enters S5, the I2C driver module (also called ECDriver) is shut down, resulting in the failure of I2C data transmission, and the data read by ACPI is not returned and a response timeout occurs. In addition, ACPI calls I2C to read data again, which also results in unprocessed instructions, causing the OS system to have an IRP (input and output request packet, I / O request packets, referred to as IRP) timeout. The electronic device will enter the 900E state (the display screen is blue) and the shutdown fails.
[0037] Based on this, an embodiment of the present application provides a data reading and writing method for obtaining the NTC temperature value stored in the EC. The data reading and writing method can be applied to PC (personal computer), such as tablet computers, personal digital assistants (PDA), desktop, laptop, notebook computers, ultra-mobile personal computers (UMPC), handheld computers, netbooks and other electronic devices, which are embedded electronic devices.
[0038] Figure 2 An example of the composition of an electronic device provided in an embodiment of the present application.
[0039] like Figure 2 As shown, the electronic device 100 may include a processor 110 , an internal memory 120 , a display screen 130 , and the like.
[0040] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0041] The processor 110 may include one or more processing units, for example, the processor 110 may include a central processing unit (CPU), an embedded controller (EC), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, a smart sensor hub and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated in one or more processors.
[0042] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0043] The internal memory 120 may be used to store computer executable program codes, which may include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 120. The internal memory 120 may include a program storage area and a data storage area.
[0044] Electronic equipment in Figure 2 The hardware components shown also have operating systems running on them. operating system, operating system, Operating system, etc. It can be understood that the operating system runs on the SOC, and the operating system of the electronic device can be a layered architecture, which divides the operating system of the electronic device into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces.
[0045] In some embodiments, the operating system of the electronic device is Operating system. Figure 3 As shown in FIG. 1 , the Linux system can be divided into two layers, namely, the application (APP) layer and the driver (driver) layer from top to bottom. The driver layer can also be called the kernel layer (Linux Kernel). The functional modules in the two-layer structure are the functional modules running on the SOC. The SOC is also called the first processor.
[0046] The application layer may include a series of application packages. For example, Figure 3 As shown, the application package may include, but is not limited to, a housekeeper application.
[0047] The kernel layer is the layer between hardware and software. The kernel layer contains at least the driver module, BIOS module, BIOS ACPI module, etc. The BIOS module, or BIOS, is the Basic Input / Output System, which is responsible for initializing and testing hardware components. The BIOS ACPI module, or BIOS ACPI, is the power management module implemented in the BIOS. The functions of the driver module, BIOS ACPI module, and BIOS module can be found in the following corresponding Figure 4 and Figure 6 content.
[0048] Figure 3 The hardware layer also exemplarily shows that it includes three hardware components: EC, SOC and MCU of the touch panel. EC is also called the second processor. The MCU of the touch panel is also called the third processor.
[0049] It should be noted that although the embodiments of the present application The operating system is used as an example for explanation, but its basic principles are also applicable to electronic devices based on iOS, Windows and other operating systems.
[0050] Figure 4 A timing diagram of a data reading method for obtaining an NTC temperature value stored in an EC provided in an embodiment of the present application is shown.
[0051] To facilitate the introduction of this case, the following describes the implementation process of obtaining the resistance temperature value in three stages. The difference between the three stages lies in the difference in the timing when the electronic device enters the S5 state.
[0052] Stage 1: The electronic device is in S0 state and charging state, and has not entered S5 state.
[0053] like Figure 4 As shown, the data reading method includes:
[0054] S101 , the driving module determines whether the electronic device is in the AC state and the S0 state, and sets a flag to True.
[0055] In some embodiments, the driver module sets a flag, and the value of the flag can be divided into two, a first value, such as True, is used to indicate that the electronic device is in S0 state (normal state) and AC state, and a second value, such as False, is used to indicate that the electronic device is not in S0 state, such as in S5 state (power-off state), or not in AC state. AC state refers to charging state.
[0056] In some other embodiments, the driving module may also set two flags to indicate whether the electronic device is in the AC state and the S0 state, respectively. The first flag is a first value, such as True, which is used to indicate that the electronic device is in the AC state, and the first flag is a second value, such as False, which is used to indicate that the electronic device is not in the AC state; the second flag is a first value, such as True, which is used to indicate that the electronic device is in the S0 state, and the second flag is a second value, such as False, which is used to indicate that the electronic device is not in the S0 state.
[0057] The following description takes the example of a driver module setting a flag to indicate whether the electronic device is in the S0 state and the AC state.
[0058] The OS system of the electronic device is synchronized with the state of the electronic device, that is, if the electronic device is in the S0 state and the AC state, the OS system of the electronic device can indicate the S0 state and the AC state.
[0059] In some embodiments, the driving module may determine that the electronic device is in AC state based on a charging event. The charging event may be reported to the driving module by the charging interface or other components when the charging interface of the electronic device is connected to a power source.
[0060] In some embodiments, the driver module can determine that the electronic device is in the S0 state based on the power action of the OS system. After the electronic device is powered on, the OS system can generate the power action of powering on, so that the driver module can determine that the electronic device enters the S0 state based on the power action.
[0061] S102: Based on the flag being True, the driver module calls the BIOS ACPI module to call the NTC temperature value once every 5 seconds.
[0062] As shown in step S101, the flag is True, indicating that the electronic device is in S0 state, and the NTC temperature value on the EC side can be read normally. Therefore, the driver module can call the BIOS ACPI module to call the NTC temperature value once every 5S. Of course, 5S is only an example, and the BIOS ACPI module can also call the NTC temperature value once based on other time intervals.
[0063] The operation of the driving module determining that the flag is False may be referred to in the following step S109 and will not be described here.
[0064] In this embodiment, the driver module determines that the flag is True, that is, it determines that the electronic device is in S0 state and AC state, and then calls the BIOS ACPI module to call the NTC temperature value once every 5S, which can ensure to a certain extent that the BIOS ACPI module can successfully read the NTC temperature value of the EC through I2C.
[0065] S103. The BIOS ACPI module determines whether the EC is in a disconnected state.
[0066] In response to the call of the driver module, the BIOS ACPI module may further detect whether the EC is in a disconnected state through step S103 before reading the NTC temperature value of the EC through the I2C.
[0067] Among them, the electronic device is in S0 state, EC is also in S0 state, EC is connected to I2C, and EC is in connected state; when OS system sends shutdown command, EC will monitor the value of EC_S5_GPIO of SOC and be pulled down, which means OS system enters S5 state, EC will also enter S5 state. When EC enters S5 state, its connection with I2C will be disconnected, and EC is in disconnected state. EC_S5_GPIO can be understood as the connection interface between EC and SOC.
[0068] In some embodiments, the connection state and disconnection state of the EC may refer to whether the I2C to which the EC is connected is in a connection state or a disconnection state, that is, the EC can transmit data through the I2C, or cannot transmit data through the I2C.
[0069] In some embodiments, during operation, the OS system may call REG method to record the status of EC and I2C. When the OS system calls REG method to record the status of EC and I2C, the parameter arg1 (the first parameter) may be called to record the status of EC and I2C. For example, arg1 is 0, indicating that the EC is disconnected, that is, the EC cannot be connected to ACPI through I2C, and arg1 is 1, indicating that the EC remains connected, that is, the EC can remain connected to ACPI through I2C. Of course, 1 and 0 are only examples and do not constitute a restriction on the value of parameter arg1. In this way, the BIOS ACPI module can determine the status of EC and I2C based on the value of parameter arg1.
[0070] It should be noted that, in some embodiments, the BIOS ACPI module may also set a flag to record whether the EC is in a connected state or a disconnected state. The value of the flag can be divided into two: a first value, such as True, used to indicate that the EC is in a connected state, and a second value, such as False, used to indicate that the EC is in a disconnected state.
[0071] In the first stage, the electronic device is in the S0 state and the charging state, so the BIOS ACPI module can determine that the EC is not in the disconnected state, and the electronic device executes the following steps S104 to S108.
[0072] In this embodiment, the BIOS ACPI module determines that the EC is not in a disconnected state, and then based on the following steps S104 to S106, completes reading the NTC temperature value from the EC side and writes it into the ADSP module, which can further ensure that the BIOS ACPI module can successfully read the NTC temperature value of the EC through I2C, and will not be affected by the electronic device entering the S5 state, resulting in a failure in reading the NTC temperature value, causing an IRP timeout in the OS system, and the electronic device entering the 900E state.
[0073] S104. The BIOS ACPI module reads the NTC temperature value from the EC.
[0074] Among them, the EC can continuously record the NTC temperature value according to the collection order of the NTC temperature value. The BIOS ACPI module reads the NTC temperature value from the EC in response to the result that the EC is not in a disconnected state. In some embodiments, the BIOS ACPI module reads the NTC temperature value once every 5S based on the instruction of the driver module to call the BIOS ACPI module to call the NTC temperature value once every 5S. Of course, as mentioned above, the electronic device is provided with three thermistors, and the BIOS ACPI module can read the NTC temperature values of the three thermistors at one time.
[0075] S105. EC returns the NTC temperature value to the BIOS ACPI module.
[0076] In some embodiments, the BIOS ACPI module reads the NTC temperature value recorded by the EC through the GETW method, and the NTC temperature value is transmitted from the EC to the BIOS ACPI module through I2C.
[0077] S106. The BIOS ACPI module writes the NTC temperature value to the ADSP module.
[0078] The ADSP module can be understood as a small core of the SOC, which belongs to the kernel layer module. The BIOS ACPI module communicates with the ADSP module through Glink, so the BIOS ACPI module writes the NTC temperature value to the ADSP module through Glink.
[0079] S107. The BIOS ACPI module returns instruction information to the driver module to indicate that the reading and writing of the NTC temperature value is completed.
[0080] After the BIOS ACPI module writes the NTC temperature value to the ADSP module, it may return indication information to the driver module to indicate to the driver module that the BIOS ACPI module has completed the reading and writing of the NTC temperature value.
[0081] S108, the ADSP module sets the charging current based on the NTC temperature value.
[0082] The ADSP module sets the charging current according to the NTC temperature value written by the BIOS ACPI module. For this process, please refer to the relevant technology and will not be described in detail here.
[0083] The second stage: when the driver module receives the indication information returned by the BIOS ACPI module to determine that the reading and writing of the NTC temperature value is completed once, but the reading and writing of the next NTC temperature value is not started, the electronic device enters the S5 state from the S0 state.
[0084] S109: The driving module determines that the electronic device is not in the S0 state, and sets a flag to False.
[0085] In an application scenario, an electronic device is turned off after being charged. This may cause the driver module to detect that the electronic device is in a charging state and also detect that the electronic device enters the S5 state. In this case, the driver module determines that the electronic device is not in the S0 state and sets the flag to False.
[0086] In another application scenario, the electronic device is in a charging state, and after the driver module, the BIOS ACPI module, the ADSP module and the EC complete the reading and writing of the NTC temperature value once based on the aforementioned steps S101 to S107, the electronic device is turned off; when the electronic device is turned off, it is not in the S0 state, and the driver module sets the flag to False.
[0087] The way in which the driving module sets the value of the flag is as described in the aforementioned step S101 and will not be described in detail here.
[0088] If the driver module sets the flag to False, the driver module will not execute step S102, that is, it will not call the BIOSACPI module to call the NTC temperature value once every 5S. In this way, the electronic device is prevented from shutting down and entering the S5 state. The driver module is turned off, resulting in the failure of I2C data transmission, and the data read by ACPI is not returned, causing the OS system to have an IRP timeout, and the electronic device will enter the 900E state.
[0089] In some embodiments, the driver module can determine that the electronic device is in the S5 state based on the power action of the OS system. When the electronic device is turned off, the OS system can generate a power-off power action, so the driver module can determine that the electronic device enters the S5 state based on the power action.
[0090] Phase 3: After the driver module calls the BIOS ACPI module to call the NTC temperature value once every 5 seconds, the electronic device enters the S5 state from the S0 state.
[0091] S110 , the driving module determines whether the electronic device is in the AC state and the S0 state, and sets a flag to True.
[0092] The specific implementation method of this step is the same as that of the aforementioned step S101. Please refer to the content of the aforementioned step S101 and will not be repeated here.
[0093] S111, based on the flag being True, the driver module calls the BIOS ACPI module to call the NTC temperature value once every 5 seconds.
[0094] The specific implementation method of this step is the same as that of the aforementioned step S102. Please refer to the content of the aforementioned step S101 and will not be repeated here.
[0095] S112. The BIOS ACPI module determines whether the EC is in a disconnected state.
[0096] In an application scenario, the electronic device is in a charging state and in the S0 state. The driver module can set the flag to True based on step S110. After the driver module calls the BIOS ACPI module to call the NTC temperature value once every 5 seconds, the electronic device is turned off and enters the S5 state. The EC can be disconnected from the IC and is in a disconnected state. Based on this, the BIOS ACPI module determines that the EC is in a disconnected state.
[0097] If the BIOS ACPI module determines that the EC is in a disconnected state, step S113 is executed, and the contents of steps S104 to S106 are not executed. Therefore, this step is to detect the EC state before the BIOS ACPI module reads the NTC temperature value on the EC side, which can avoid the problem that the EC suddenly enters a disconnected state when the BIOS ACPI module reads the NTC temperature value on the EC side, causing the BIOS ACPI module to fail to read the NTC temperature value of the EC through I2C, causing the OS system to enter the S5 state and an IRP timeout, and the electronic device will enter the 900E state.
[0098] S113. The BIOS ACPI module returns indication information to the driver module to indicate that the reading and writing of the NTC temperature value is completed.
[0099] The specific implementation method of this step is the same as that of the aforementioned step S107. Please refer to the content of the aforementioned step S101 and will not be repeated here.
[0100] The electronic device is equipped with a pressure-sensitive touch panel. The maintenance and measurement data of the pressure-sensitive touch panel needs to be uploaded to the OS system so that the OS system can analyze the maintenance and measurement data. The electronic device is equipped with a housekeeper application. The pressure-sensitive touch panel includes a chip (a third processor), such as a microcontroller unit (MCU). The housekeeper application can periodically obtain the maintenance and measurement data stored in the MCU. The housekeeper application and the MCU are connected through a universal asynchronous receiver / transmitter (UART) (a second interface) for data transmission.
[0101] Figure 5 It shows the timing of the housekeeper application obtaining the maintenance data of the pressure-sensitive touch panel.
[0102] like Figure 5 As shown, when the electronic device is in S0 state, the housekeeper application can send an OpenUart instruction to the Basic Input Output System (BIOS) every 4 hours. In response to the instruction, the BIOS opens the UART serial port and configures the serial port parameters. After that, the housekeeper application can send a request to obtain the MCU data of the pressure-sensitive touch panel. After receiving the request, the MCU transfers the data to the UART serial port through direct memory access (DMA).
[0103] After the MCU finishes transmitting data, the housekeeper application also sends a CloseUart command to close the UART serial port.
[0104] During the process of transmitting the maintenance and measurement data stored in the MCU to the housekeeper application through the UART serial port, the electronic device enters the S3 state (also known as the MS state) from the S0 state, and the BIOS will call the PS3 method to control the UART serial port to enter the D3 state (low power state), that is, close the UART serial port. However, since the MCU is still sending maintenance and measurement data to the UART serial port, the register of the UART serial port will be in a protected state, and the closing instruction of the UART serial port cannot be written to the register of the UART serial port. The UART serial port closing response times out, and the OS system generates an IRP timeout, which in turn causes a blue screen problem on the display. The blue screen code is 0x133, and the electronic device fails to enter the low power state.
[0105] Among them, the S3 state belongs to Suspend to RAM. When the electronic device enters the S3 state, the electronic device's OS system, all applications and open documents are stored in the memory. Other components except the memory will stop supplying power, and the electronic device will enter a low-power state. Users can quickly wake up the electronic device by clicking on the keyboard, mouse and other components.
[0106] Based on this, another embodiment of the present application further provides a data reading and writing method for obtaining the maintenance and measurement data stored in the MCU. The data reading and writing method can also be applied to the electronic device proposed in the above content, and the type, structure and software architecture of the electronic device are not described in detail here.
[0107] Figure 6 A timing diagram of a data reading and writing method provided in an embodiment of the present application is shown.
[0108] like Figure 6 As shown, the data reading and writing methods include:
[0109] S201. The housekeeper application sends an OpenUart command to the BIOS every 4 hours.
[0110] When the electronic device is in S0 state, the maintenance data stored in the MCU needs to be reported to the housekeeper application. Based on this, the housekeeper application sends an OpenUart command every 4 hours, which is used to open the UART serial port between the housekeeper application and the MCU. It can be understood that the frequency of the housekeeper application sending the OpenUart command every 4 hours is an exemplary value and does not constitute a limit on the frequency of the housekeeper application sending the OpenUart command.
[0111] S202. BIOS responds to the OpenUart instruction, opens the UART serial port and configures serial port parameters.
[0112] In response to the OpenUart instruction, the BIOS opens the UART serial port and configures serial port parameters for the UART serial port, which may include: baud rate, data bit, parity bit, stop bit, etc. After the BIOS opens the UART serial port and configures the serial port parameters, the housekeeper application and the MCU can transmit data through the UART serial port.
[0113] S203: The housekeeper application sends a request to the MCU to obtain MCU data of the pressure-sensitive touch panel.
[0114] The MCU data of the pressure-sensitive touch panel refers to the maintenance data of the pressure-sensitive touch panel stored in the MCU, including the system log and dot data of the pressure-sensitive touch panel.
[0115] S204 . In response to the request, the MCU transmits the first data to the UART serial port via DMA.
[0116] Due to the limitation of the amount of data that the MCU transmits to the UART serial port at one time, the first data can be understood as the maintenance data of all or part of the pressure-sensitive touch panel stored by the MCU. In addition, the MCU transmits the first data to the UART serial port via DMA, and the first data transmitted by the UART serial port can be transmitted to the housekeeper application and stored by the housekeeper application. Therefore, the MCU transmits the first data to the UART serial port via DMA, which can also be understood as: the MCU adopts DMA technology to transmit the first data to the housekeeper application via the UART serial port.
[0117] Exemplarily, the maintenance and measurement data of the pressure-sensitive touch panel stored in the MCU includes: first data and second data. The MCU first transmits the first data to the UART serial port, and after the first data is transmitted, the MCU transmits the second data to the UART serial port.
[0118] S205 . The housekeeper application instructs the BIOS to enter the S3 state from the S0 state.
[0119] During the process of MCU transmitting the first data to the UART serial port, the OS system enters the S3 state from the S0 state. After the OS system enters the S3 state, the screen of the electronic device will be turned off.
[0120] The OS system entering the S3 state from the S0 state can refer to: directly entering the S3 state from the S0 state; or it can refer to the OS system entering the S3 state from the S0 state through the S1 state and the S2 state. Among them, the S1 state can refer to: the most power-consuming sleep mode, in which all registers of the SOC are refreshed, the SOC stops executing instructions, and the SOC and memory maintain power supply; the S2 state can refer to a deeper sleep state of S1, and the SOC stops supplying power.
[0121] In some embodiments, the housekeeper application sends an indication message to the BIOS, and the indication message may indicate that the OS system enters the S3 state from the S0 state. In one implementation, the OS system enters the S3 state, and the OS system issues an instruction through the housekeeper application to call the PTS method of the ACPI of the BIOS, and assigns a value to the flag, and the value may indicate whether the OS system is in the S3 state.
[0122] S206. The MCU detects that the electronic device is in the screen-off state and stops writing the first data to the UART.
[0123] As in the aforementioned step S205, after the OS system enters the S3 state, the screen of the electronic device will be off. The MCU can detect whether the electronic device is in the off state to determine whether the OS system enters the S3 state.
[0124] In some embodiments, the MCU detects whether the electronic device is in the screen-off state in the following manner:
[0125] When the OS system enters the S3 state, the housekeeper application can issue an instruction to call the PTS method of the ACPI of the BIOS to assign a value to the flag, which can indicate whether the OS system is in the S3 state. The BIOS can write the value of the flag to the MCU. Based on the value of the flag, the MCU determines whether the OS system is in the S3 state, that is, whether the electronic device is in the screen-off state.
[0126] When the MCU detects that the electronic device is in the screen-off state, it can determine that the OS system has entered the S3 state. Based on this, it stops writing the first data to the UART, which can release the register of the UART serial port, so that the register of the UART serial port can be written with the instruction to close the UART serial port, thereby avoiding the UART serial port closing response timeout, causing the OS system to generate an IRP timeout, and then causing the blue screen problem of the display.
[0127] S207: The housekeeper application sends a CloseUart instruction to the BIOS.
[0128] It can be understood that when the housekeeper application detects that the OS system has entered the S3 state, it sends a CloseUart instruction to the BIOS, and the CloseUart instruction is used to close the UART serial port.
[0129] In some embodiments, the housekeeper application detects that the data transmitted by the MCU through the UART serial port is not completely transmitted, and the data can be deleted. In the example, during the process of the MCU transmitting the first data to the housekeeper application, the OS system enters the S3 state from the S0 state, and the MCU detects that the electronic device is in the screen-off state and stops writing the first data to the UART. In this way, the housekeeper application cannot receive the complete first data, and the housekeeper application can delete the first data and not store it. Of course, in other embodiments, the housekeeper application can also save the first data.
[0130] S208. The BIOS responds to the CloseUart instruction, closes the UART serial port, and sets a serial port closing flag.
[0131] In some embodiments, the BIOS responds to the CloseUart instruction and calls the PS3 method to control the UART serial port to enter the D3 state. The way the UART serial port enters the D3 state is: the UART serial port is closed.
[0132] After the BIOS closes the UART serial port, a closed serial port flag may be set for the UART serial port, where the closed serial port flag indicates that the UART serial port is closed.
[0133] S209 , the housekeeper application instructs the BIOS to enter the OS system into the S0 state.
[0134] In some application scenarios, the OS system enters the S3 state, and the user clicks the keyboard or mouse, and the OS system can be reawakened and enter the S0 state. The housekeeper application can detect that the OS system enters the S0 state through the API interface. In some embodiments, the housekeeper application sends an indication message to the BIOS, and the indication message can indicate that the OS system enters the S0 state.
[0135] S210. The housekeeper application sends an OpenUart command to the BIOS every 4 hours.
[0136] When the housekeeper application detects that the OS system has entered the S0 state, it can send an OpenUart instruction to the BIOS. The specific implementation of this step can refer to the content of the aforementioned step S201, which will not be repeated here.
[0137] S211. BIOS responds to the OpenUart instruction, opens the UART serial port and configures serial port parameters.
[0138] The specific implementation method of step S211 can refer to the content of the aforementioned step S202, which will not be repeated here.
[0139] S212: The housekeeper application sends a request to the MCU to obtain MCU data of the pressure-sensitive touch panel.
[0140] The specific implementation method of step S212 can refer to the content of the aforementioned step S203, which will not be repeated here.
[0141] S213. In response to the request, the MCU transmits the first data to the UART serial port via DMA.
[0142] The specific implementation method of step S213 can refer to the content of the aforementioned step S204, which will not be repeated here.
[0143] It should be noted that the operation of MCU transmitting the first data to the UART serial port is interrupted because the OS system enters the S3 state. Therefore, after the MCU receives the request to obtain the MCU data of the pressure-sensitive touch panel, it responds to the request and transmits the first data to the UART serial port through DMA.
[0144] In some embodiments, step S212 may not be executed. After the BIOS responds to the OpenUart instruction, opens the UART serial port and configures the serial port parameters, the MCU may actively transmit the first data to the UART serial port through DMA. The first data transmitted by the UART serial port may be transmitted to the housekeeper application and stored by the housekeeper application.
[0145] Another embodiment of the present application further provides a computer-readable storage medium, which stores instructions, and when the computer-readable storage medium is executed on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.
[0146] The computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0147] Another embodiment of the present application further provides a computer program product including instructions. When the computer program product is run on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.
Claims
1. A data reading and writing method, characterized in that: Applicable to an embedded electronic device, the electronic device includes a first processor and a second processor, the first processor and the second processor perform data communication via a first interface; the method includes: The electronic device is in a charging state, the first processor obtains a temperature value stored by the second processor through the first interface, and adjusts a charging current of the electronic device based on the temperature value, wherein the temperature value is used to indicate a temperature of the electronic device; During the charging process of the electronic device, the first processor detects that the electronic device is triggered to shut down, and then executes the shutdown process of the electronic device based on indication information, where the indication information is used to indicate that the first processor has completed the operation of obtaining the temperature value through the first interface.
2. The data reading and writing method according to claim 1, characterized in that: During the charging process of the electronic device, after the first processor detects that the electronic device is triggered to shut down, the method further includes: The first processor sets the first flag to a second value.
3. The data reading and writing method according to claim 1, characterized in that: The first processor detects that the electronic device is triggered to shut down, including: The first processor detects, based on the temperature value acquisition instruction, whether the connection between the second processor and the first interface is disconnected; The first processor detects that the connection between the second processor and the first interface is disconnected.
4. The data reading and writing method according to claim 3, characterized in that: Before the first processor detects whether the connection between the second processor and the first interface is disconnected based on the temperature value acquisition instruction, the method further includes: The first processor determines a first flag as a first value.
5. The data reading and writing method according to claim 3, characterized in that: The detecting whether the connection between the second processor and the first interface is disconnected includes: The first processor detects whether the first parameter indicates that the second processor is disconnected from the first interface.
6. The data reading and writing method according to any one of claims 1 to 5, characterized in that: The electronic device further includes a third processor, the first processor and the third processor perform data communication via a second interface, and the method further includes: When the third processor transmits the first data to the first processor through the second interface, the third processor detects that the electronic device enters a low power consumption state, and the third processor stops transmitting the first data to the first processor through the second interface.
7. The data reading and writing method according to claim 6, characterized in that: The first data refers to the measurement data of the third processor.
8. The data reading and writing method according to claim 6 or 7, characterized in that: Also includes: In response to the electronic device entering a low power consumption state, the first processor shuts down the second interface.
9. The data reading and writing method according to any one of claims 6 to 8, characterized in that: Also includes: In response to the electronic device entering a normal state from the low power consumption state, the third processor transmits the first data to the first processor through the second interface.
10. The data reading and writing method according to claim 9, characterized in that: Before the third processor transmits the first data to the first processor through the second interface, the method further includes: The first processor opens the second interface and configures parameters of the second interface.
11. An electronic device, characterized in that: include: Multiple processors and memories; the multiple processors include a first processor, a second processor and a third processor; The memory is coupled to the multiple processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions. When the multiple processors execute the computer instructions, the electronic device executes the data reading and writing method as described in any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed, is specifically used to implement the data reading and writing method according to any one of claims 1 to 10.
13. A computer program product, characterized in that Instructions are stored thereon, and when the computer program product is run on an electronic device, the electronic device implements the data reading and writing method as described in any one of claims 1 to 10.
Citation Information
Patent Citations
Control method of terminal output current, and terminal
CN107147798A
Shutdown method and device, equipment and computer readable storage medium
CN108958811A
Electronic equipment shutdown control method and system
CN112596444A
Data transmission method, data transmission device, electronic equipment and medium
CN115665833A
Method and device for controlling shutdown of electronic equipment
CN117093140A