Message notification method and apparatus
This application provides a message notification method and apparatus. One example message notification method includes: A flash memory receives a first sleep request from a master chip. The flash memory detects an execution status of a working command initiated by a local end. The working command is used to initiate a read/write operation with the master chip. The flash memory sends a first notification to the master chip, where the first notification indicates the execution status of the working command.
1 . A message notification method, applied to a flash memory of a terminal device, wherein the terminal device further comprises a master chip, and the method comprises:
receiving, by the flash memory, a first sleep request from the master chip;
detecting, by the flash memory, an execution status of a working command initiated by a local end, wherein the working command comprises a command to initiate a read/write operation with the master chip;
sending, by the flash memory, a first notification to the master chip, wherein the first notification indicates the execution status of the working command and whether the first sleep request that is received from the master chip conflicts with execution of the working command, wherein the first notification indicates that there is a working command in a being-executed state or a to-be-executed state and that the first sleep request conflicts with execution of the working command; and
after the sending the first notification to the master chip, receiving by the flash memory, a second sleep request from the master chip.
2 . The method according to claim 1 , wherein after the sending, by the flash memory, a first notification to the master chip, the method further comprises:
continuing, by the flash memory, to execute the working command.
3 . The method according to claim 1 , wherein after the sending, by the flash memory, a first notification to the master chip, the method further comprises:
disabling, by the flash memory, a command sending function; and
entering, by the flash memory, a sleep state.
4 . The method according to claim 3 , wherein the command sending function is disabled by at least one of a physical layer or firmware of the flash memory.
5 . The method according to claim 1 , wherein a protocol stack of the flash memory comprises a physical layer and firmware; and
the detecting, by the flash memory, an execution status of a working command comprises:
sending, by the physical layer, an interrupt processing request to the firmware after receiving the first sleep request;
detecting, by the firmware, the execution status of the working command in response to the interrupt processing request; and
sending, by the firmware, a detection result to the physical layer.
6 . An electronic device, comprising:
a flash memory;
a read-only memory; and
one or more computer programs, wherein the one or more computer programs are stored in the read-only memory, and when the computer programs are executed by the flash memory, the electronic device is enabled to perform the message notification method according to claim 1 .
7 . The method according to claim 1 , wherein the sending, by the flash memory, a first notification to the master chip further comprises:
configuring, by firmware of the flash memory, a register at a physical layer of the flash memory; and
indicating, by the register, the flash memory to send the first notification to the master chip.
8 . A message notification apparatus, used in a flash memory of a terminal device, wherein the terminal device further comprises a master chip, and the apparatus comprises a transceiver and at least one processor, wherein
the transceiver is configured to receive a first sleep request from the master chip;
the at least one processor is configured to detect an execution status of a working command initiated by a local end, wherein the working command comprises a command to initiate a read/write operation with the master chip; and
the transceiver is further configured to send a first notification to the master chip, wherein the first notification indicates the execution status of the working command and whether the first sleep request that is received from the master chip conflicts with execution of the working command, wherein a protocol stack of the flash memory comprises a physical layer and firmware, the transceiver is configured to be used by the physical layer to send an interrupt processing request to the firmware after the first sleep request is received, the firmware is configured to detect the execution status of the working command in response to the interrupt processing request, and the firmware is configured to send a detection result to the physical layer.
9 . The apparatus according to claim 8 , wherein the first notification indicates that there is a working command in a being-executed state or a to-be-executed state and that the first sleep request conflicts with execution of the working command.
10 . The apparatus according to claim 9 , wherein the at least one processor is further configured to continue to execute the working command after the first notification is sent to the master chip.
11 . The apparatus according to claim 9 , wherein the transceiver is further configured to receive a second sleep request from the master chip after the flash memory sends the first notification to the master chip.
12 . The apparatus according to claim 8 , wherein the first notification indicates that there is no working command in a being-executed state or a to-be-executed state and that the first sleep request does not conflict with execution of the working command.
13 . The apparatus according to claim 12 , wherein the transceiver is further configured to: after the flash memory sends the first notification to the master chip, disable a command sending function and enter a sleep state.
14 . The apparatus according to claim 13 , wherein the command sending function is disabled by at least one of a physical layer or firmware of the flash memory.
15 . The apparatus according to claim 8 , wherein the sending a first notification to the master chip further comprises:
configuring, by the firmware of the flash memory, a register at the physical layer of the flash memory; and
indicating, by the register, the flash memory to send the first notification to the master chip.
16 . A message notification method, applied to a master chip of a terminal device, wherein the terminal device further comprises a flash memory, and the method comprises:
sending, by the master chip, a first sleep request to the flash memory; and
receiving, by the master chip, a first notification from the flash memory, wherein the first notification indicates an execution status of a working command and whether the first sleep request that is received from the master chip conflicts with execution of the working command, and the working command comprises a command for the flash memory to initiate a read/write operation with the master chip, wherein the first notification indicates that there is a working command in a being-executed state or a to-be-executed state and that the first sleep request conflicts with execution of the working command; and
after the receiving, by the master chip, a first notification from the flash memory, the method further comprises:
starting, by the master chip, a timer; and
sending, by the master chip, a second sleep request to the flash memory after the timer expires.
17 . The method according to claim 16 , wherein the timer is started by firmware of the master chip or by a universal flash storage host controller interface (UFSHCI).
18 . A message notification apparatus, used in a master chip of a terminal device, wherein the terminal device further comprises a flash memory, and the apparatus comprises a transmitter and a receiver, wherein
the transmitter is configured to send a first sleep request to the flash memory; and
the receiver is configured to receive a first notification from the flash memory, wherein the first notification indicates an execution status of a working command and whether the first sleep request that is received from the master chip conflicts with execution of the working command, and the working command comprises a command for the flash memory to initiate a read/write operation with the master chip, wherein the first notification indicates that there is a working command in a being-executed state or a to-be-executed state and that the first sleep request conflicts with execution of the working command, and the apparatus further comprises:
at least one processor, configured to start a timer; and wherein
the transmitter is further configured to send a second sleep request to the flash memory after the timer expires.
19 . The apparatus according to claim 18 , wherein the timer is started by firmware of the master chip or by a universal flash storage host controller interface (UFSHICI).
20 . The apparatus according to claim 18 , wherein a protocol stack of the master chip comprises firmware and a physical layer.