Data writing method, device and storage medium
By receiving and determining the address of the write command under PMON, the user prevents the user from writing the wrong address segment under PMON, the problem of MAC address changes caused by user operation errors is solved, the stability of network device addresses is ensured, and network communication failure is avoided .
Patent Information
- Application Number
- CN201910559384.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-26
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2039-06-26
AI Technical Summary
When a user inputs the write command of the FLASH chip to the computer under PMON, due to operation errors or lack of understanding of the write operation characteristics, the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed, resulting in network communication failure.
By receiving the write command input by the user, it is determined whether the write address is in the preset address segment. If it is in the preset address segment, a warning message is pushed without executing the write command to prevent arbitrary changes of the MAC address.
It effectively protects the network device address stored in the memory from being changed at will, avoiding the problems of MAC address conflict and network communication failure.
Smart Images

Figure CN112148201B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer technology, and in particular to a data writing method, device and storage medium. Background Art
[0002] At present, some computers use a dedicated bridge chip group (referred to as: bridge chip) as the chipset of the computing system to provide the north-south bridge function for the processor. The bridge chip integrates two gigabyte Media Access Control Address (GMAC) controllers, which are connected to an external GMAC physical layer (PHY) chip through an interface and can be used as two network devices (also called network card devices) of the computer to achieve network communication. For the convenience of subsequent description, the two network devices are respectively referred to as network device 1 and network device 2.
[0003] The bridge chip mentioned above is connected to an external FLASH chip, and the MAC addresses of the two network devices of the bridge chip are stored in the fixed address segment of the first sector (Sector) of the address space of the FLASH chip. The computer's PMON integrates two write commands for the FLASH chip connected to the bridge chip, namely the byte write command and the file write command. Among them, the byte write command is used to write a byte of data in the address space of the FLASH chip. The file write command is used to write the data of a file in the address space of the FLASH chip. It should be understood that the write address of the byte write command and the file write command are both specified by the user, that is, the user specifies which address in the address space of the FLASH chip to start writing.
[0004] In the prior art, when a user inputs a write command about a FLASH chip (such as a byte write command or a file write command) to a computer under PMON, due to an operational error or a lack of understanding of the write operation characteristics of the FLASH chip, the MAC address of a network device stored in a fixed address segment of the FLASH chip may be changed at will (such as the MAC address being erased, the MAC address being rewritten, the MAC address being rewritten, etc.), thereby causing the computer to have no MAC address, or the MAC address conflicts with the MAC addresses of other network devices in the same local area network, causing the computer's network communication to fail. Summary of the invention
[0005] The present invention provides a data writing method, device and storage medium, which are used to solve the problem in the prior art that when a user inputs a write command about a FLASH chip to a computer under PMON, the MAC address of a network device stored in a fixed address segment of a FLASH chip is arbitrarily changed due to an operation error or a lack of understanding of the write operation characteristics of the FLASH chip.
[0006] A first aspect of the present invention provides a data writing method, the method comprising:
[0007] receiving a write command input by a user, wherein the write command is used to request to write the data to be written into the memory, and the write command includes a write address of the data to be written;
[0008] When the write address is within a preset address segment, a warning message is pushed, wherein the warning message is used to indicate that the write address is wrong; wherein the preset address segment includes an address range in which a target sector of the memory stores at least one network device address.
[0009] In a possible implementation, the method further includes:
[0010] When the write address is not within the preset address segment, the data to be written is written into the memory according to the write address.
[0011] In a possible implementation manner, the write command is a byte write command, and before pushing the warning information, the method further includes:
[0012] Determine whether there is a byte in the at least one network device address that is the same as a preset value, where the preset value is the value of the byte stored in the address space after the memory is erased;
[0013] If there is a byte with the same value as the preset value in the at least one network device address, the preset address segment is obtained.
[0014] In a possible implementation, the write command is a byte write command, the starting address of the preset address segment is the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment is the ending address of the target sector storing the at least one network device.
[0015] In a possible implementation manner, the write command is a file write command, and the preset address segment is an address segment of the target sector.
[0016] A second aspect of the present invention provides a data writing device, the device comprising:
[0017] A receiving module, used for receiving a write command input by a user, wherein the write command is used for requesting to write the data to be written into the memory, and the write command includes a write address of the data to be written;
[0018] A push module is used to push a warning message when the write address is within a preset address segment, wherein the warning message is used to indicate that the write address is wrong; wherein the preset address segment includes an address range in which a target sector of the memory stores at least one network device address.
[0019] In a possible implementation, the device further includes:
[0020] A writing module is used to write the data to be written into the memory according to the writing address when the writing address is not within the preset address segment.
[0021] In a possible implementation manner, the write command is a byte write command, and the device further includes:
[0022] a judgment module, used for judging whether there is a byte identical to a preset value in the at least one network device address before the push module pushes the warning information, wherein the preset value is the value of the byte stored in the address space after the memory is erased;
[0023] The acquisition module is used to acquire the preset address segment when there is a byte with the same value as the preset value in the at least one network device address.
[0024] In a possible implementation, the write command is a byte write command, the starting address of the preset address segment is the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment is the ending address of the target sector storing the at least one network device.
[0025] In a possible implementation manner, the write command is a file write command, and the preset address segment is an address segment of the target sector.
[0026] A third aspect of the present invention provides a data writing device, comprising: at least one processor and a memory;
[0027] The memory stores computer-executable instructions; and the at least one processor executes the computer-executable instructions stored in the memory to perform any method described in the first aspect.
[0028] A fourth aspect of the present invention provides a computer-readable storage medium, in which program instructions are stored. When the program instructions are executed by a processor, the method described in any one of the first aspects is implemented.
[0029] The data writing method, device and storage medium provided by the present invention can determine whether the write address is located in a preset address segment storing the address of at least one network device according to the write address carried by the write command. If the write address is located in the preset address segment, the write command is not executed, but a warning message indicating that the write address is wrong is pushed. In this way, the address of the network device stored in the memory can be protected from being changed at will, and the problem that the MAC address of the network device stored in the fixed address segment of the FLASH chip is changed at will due to an operation error or a lack of understanding of the write operation characteristics of the FLASH chip when the user inputs a write command about the FLASH chip to the computer under PMON can be solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 It is a schematic diagram of the structure of the computer;
[0032] Figure 2 A schematic diagram of a flow chart of a data writing method provided by the present invention;
[0033] Figure 3 A structural schematic diagram of a data writing device provided by the present invention;
[0034] Figure 4 A schematic structural diagram of another data writing device provided by the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] A chipset is a group of integrated circuit chips that work together to connect a computer's processor to the rest of the computer. In the computer world, the term chipset usually refers to the two main motherboard chips, the northbridge and the southbridge. Figure 1 A schematic diagram of the computer structure is shown in Figure 1As shown, currently, some computers use a dedicated bridge chip set (referred to as: bridge chip) as a chipset of a computing system to provide north-south bridge functions for the processor.
[0037] Media Access Control Address (MAC), also called hardware address, is unique. Therefore, in the process of network communication, MAC address is usually used to define the location of network devices. If a network device has no MAC address, or the MAC address of a network device conflicts with the MAC address of other network devices in the same LAN, network communication will fail.
[0038] The bridge chip mentioned above integrates two GMAC controllers, which are connected to an external GMAC physical layer (Physical, PHY) chip ( Figure 1 ), can be used as two network devices of the computer (also called network card devices) to realize the network communication of the computer. For the convenience of subsequent description, the two network devices are respectively called network device 1 and network device 2.
[0039] See also Figure 1 As shown, the computer includes a processor, a bridge chip and a FLASH chip connected in sequence, wherein, compared with the prior art, the FLASH chip is an additional memory external to the bridge chip, which is used to store the MAC address and other information of the network device. Specifically, the bridge chip mentioned above is externally connected to a FLASH chip, which can also be called a flash memory, and is a memory that still stores data information in a power-off state. The address space of the FLASH chip consists of multiple sectors (Sector), each of which has a size of 4KB, and the storage address of each sector is from 0x0000 to 0x0fff. In the prior art, the MAC addresses of the two network devices of the bridge chip are stored in the fixed address segment of the first Sector0 of the address space of the FLASH chip. Specifically, the MAC address of network device 1 is stored in the address segment of 0x0000 to 0x0005 of Sector0, occupying 6 bytes. The MAC address of network device 2 is stored in the address segment of 0x0010 to 0x0015 of Sector0, also occupying 6 bytes.
[0040] PMON is an open source software that combines some functions of the Basic Input Output System (BIOS) and bootloader. PMON is the "firmware" of the computer and can be regarded as a part of the computer's hardware. Its role in the computer is to perform the most basic initialization of the hardware and is the interface between the hardware and the operating system kernel. PMON integrates two write commands for the FLASH chip connected to the bridge chip, namely the byte write command and the file write command. Among them, the byte write command is used to write a byte of data in the address space of the FLASH chip. The file write command is used to write the data of a file in the address space of the FLASH chip. It should be understood that the write address of the byte write command and the file write command are both specified by the user (that is, the user needs to specify which address in the address space of the FLASH chip to start writing).
[0041] The FLASH chip supports erasing by sector size, that is, erasing at least 4KB of address space each time, and the value of the byte stored in the erased address space is 0xff. The characteristic of the FLASH chip write operation is that it must be erased before writing new data. That is, the address space to write new data must be the erased address space. In this application document, the concepts of address space and address are equivalent, and this embodiment does not distinguish between them.
[0042] When the user inputs a byte write command to the computer under PMON, and specifies that the write address of the data to be written is between 0x0000 and 0x0005 or between 0x0010 and 0x0015 of Sector0, the processor will not perform an erase operation when executing the byte write command, but will directly perform a write operation. At this time, if the value stored at the write address on the FLASH chip is 0xff, that is, the value stored in the address space indicated by the write address at the current moment is 0xff, the processor will mistakenly believe that the write address is the address after the data is erased, and the processor will directly perform the above write operation, resulting in the address of the network device stored in the FLASH chip being rewritten.
[0043] For example, assume that the MAC address of network device 1 located at 0x0000-0x0005 of Sector0 is 00:11:22:AB:FF:66. That is, the MAC address of network device 1 is stored in sector 0 of the FLASH chip, occupying 6 bytes of address space of sector 0. In other words, the MAC address of network device 1 can be regarded as 6 groups of data, each group of data occupies one byte of address space. That is, 00 occupies one byte of address space, 11 occupies one byte of address space, 22 occupies one byte of address space, AB occupies one byte of address space, FF occupies one byte of address space, and 66 occupies one byte of address space.
[0044] In this scenario, take the case where the user inputs a byte write command to the computer under PMON as an example. Assume that the data to be written indicated by the byte write command is AC, and the specified write address is 0x0004. In this example, because the value stored on 0x0004 is 0xff (that is, the value stored on the write address 0x0004 is 0xff), at this time, the processor will think that the write address 0x0004 is the address after the data is erased, and the processor will perform the write operation, rewriting the value stored on 0x0004 to AC, causing the MAC address of network device 1 to become 00:11:22:AB:AC:66. If the data to be written indicated by the byte write command is AC, the specified write address is 0x0005. In this example, because 0x0005 is stored as 0x66, not 0xff; at this time, the processor will think that the write address is the address after the data is not erased, and in this scenario, the processor will not perform the write operation. That is, the write fails.
[0045] That is, when the value stored in the address space corresponding to the write address specified by the byte write command is 0xff, the processor will execute the byte write command and use the byte to be written indicated by the byte write command to replace the value 0xff originally stored in the address space corresponding to the write address.
[0046] Accordingly, when the user inputs a file write command to the computer under PMON and specifies that the write address of the file to be written is located in the address segment of 0x0000 to 0x0FFF of Sector0, the processor will first perform the operation of erasing Sector0, resulting in the MAC address of network device 1 and the MAC address of network device 2 in the address segment of 0x0000 to 0x0015 stored in Sector0 being erased to 0xff. After completing the operation of erasing Sector0, the processor starts from the write address specified by the file write command and writes the data of the file to be written into Sector0. At this time, if the write address of the file to be written is between 0x0000 and 0x0015, the MAC address of network device 1 and the MAC address of network device 2 will be rewritten.
[0047] It should be understood that when the processor performs a write operation to the FLASH chip, the write operation can be performed through the bridge chip. Generally speaking, the bridge chip performs the write operation to the FLASH chip through a serial peripheral interface (Serial Peripheral Interface, SPI) controller. Therefore, in some embodiments, the byte write command can also be referred to as an SPI byte write command, the file write command can also be referred to as an SPI file write command, and the SPI byte write command and the SPI file write command can be collectively referred to as an SPI write command.
[0048] From the above description, it can be seen that due to the writing characteristics of the above-mentioned FLASH chip itself (that is, the address space for writing new data must be the erased address space, and the value stored in the erased address space is 0xFF, etc.), when the user inputs the write command about the FLASH chip to the computer, due to operational errors or lack of understanding of the write operation characteristics of the FLASH chip, it is easy to cause the MAC address of the network device stored in the fixed address segment of the FLASH chip to be changed at will (MAC address is erased, MAC address is rewritten, MAC address is rewritten, etc.), which in turn causes the computer to have no MAC address, or the MAC address conflicts with the MAC address of other network devices in the same local area network, causing the computer's network communication to fail.
[0049] Considering the above problems caused by the writing characteristics of the FLASH chip itself, the present invention provides a data writing method. When executing a write command, the processor can determine whether the write address is located in a preset address segment storing the address of at least one network device according to the write address carried by the write command. If the write address is located in the preset address segment, the write command is not executed, but a warning message indicating that the write address is wrong is pushed. In this way, the address of the network device stored in the memory can be protected from being changed at will, and the problem that the MAC address of the network device stored in the fixed address segment of the FLASH chip is changed at will due to an operation error or a lack of understanding of the write operation characteristics of the FLASH chip when the user inputs a write command about the FLASH chip to the computer can be solved. Among them, the address of the above network device is the MAC address of the network device.
[0050] The method provided by the present invention can be applied to an electronic device including a memory, the memory is used to store the MAC address of the network device, and has the following writing characteristics: the address space for writing new data must be an erased address space, and the value stored in the erased address space is a preset value, which can be 0xFF, for example. For example, the memory can be the aforementioned FLASH chip.
[0051] Taking the FLASH chip as an example, the electronic device to which the method provided by the present invention is applicable may be an electronic device (e.g., an electronic device) that provides a north-south bridge function for a processor through a bridge chip, and in which the MAC address of a network device of the bridge chip is stored in a FLASH chip externally connected to the bridge chip. Figure 1 The electronic device may use PMON as "firmware" to perform the most basic initialization on the hardware of the electronic device, or may use UEFI to perform the most basic initialization on the hardware of the electronic device, or may use other firmware to initialize the hardware of the electronic device. That is, the embodiment of the present invention does not limit the firmware used by the electronic device. In other words, the method provided in the embodiment of the present invention is applicable to any electronic device using the FLASH chip, and will not be listed one by one here.
[0052] The execution subject of the data writing method provided by the present invention can be a data writing device, which can be a driver, program code software, or a medium storing relevant execution code, such as a USB flash drive, etc.; or, the data writing device can also be a physical device integrated or installed with relevant execution code, such as a chip, a microcontroller unit (MCU for short), a computer, a computer and other electronic devices.
[0053] For example, the solution can be applied to a computer whose processor has the characteristics of high performance and low power consumption, and can be applied to servers, high-performance computers, low-energy data centers, personal high-performance computers, high-end desktop applications, high-throughput computing applications, industrial control, digital signal processing, high-end embedded applications, etc.
[0054] Combine the following Figure 1 The computer structure shown takes a processor integrated or installed with relevant execution code as an example, and describes the technical solution of the present invention in detail with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0055] Figure 2 The following is a flow chart of a data writing method provided by the present invention. Figure 2 As shown, the method includes:
[0056] S101. Receive a write command input by a user, where the write command is used to request to write data to be written into a memory, and the write command includes a write address of the data to be written.
[0057] The write command mentioned above can be, for example, the byte write command or the file write command mentioned above. Of course, the write command mentioned above can also be other types of write commands in the prior art, which will not be described in detail.
[0058] When the write command is a byte write command, the data to be written may be data of a byte size. When the write command is a file write command, the data to be written may be data of a file. In this scenario, the write command may also include the path where the file to be written is currently located.
[0059] The memory mentioned above can be any memory having a writing characteristic of erasing before writing new data, such as the FLASH chip mentioned above.
[0060] S102: Determine whether the write address is located in a preset address segment storing the address of at least one network device. If yes, execute step S103; if no, execute step S104.
[0061] The preset address segment includes an address range in which the target sector of the memory stores at least one network device address, that is, the target sector is a sector in the FLASH chip that stores the network device address. The preset address segment can be determined based on the address of at least one network device in the computer in the target sector and the write characteristics of the memory.
[0062] Taking the memory as a FLASH chip as an example, if the write command is a byte write command, the starting address of the preset address segment can be the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment can be the ending address of the target sector storing the at least one network device. Alternatively, the starting address of the preset address segment can be smaller than the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment can be larger than the ending address of the target sector storing the at least one network device.
[0063] If the write command is a file write command and the FLASH chip is erased according to the sector size, the preset address segment is the address segment of the target sector. Alternatively, the preset address segment includes the address segment of the target sector. It should be understood that if the FLASH chip is erased according to the block size, when the write command is a file write command, the preset address segment is the address segment of the block where the target sector is located, or the preset address segment includes the address segment of the block where the target sector is located. If the FLASH chip is erased according to the entire chip size, when the write command is a file write command, the preset address segment is the address segment of the chip where the target sector is located, or the preset address segment includes the address segment of the chip where the target sector is located.
[0064] Assume that the MAC address of network device 1 is stored in the address segment of 0x0000 to 0x0005 of Sector0 of the memory, which occupies 6 bytes. The MAC address of network device 2 is stored in the address segment of 0x0010 to 0x0015 of Sector0 of the memory, which also occupies 6 bytes. Taking the memory as a FLASH chip as an example, if the above-mentioned write command is a byte write command, the above-mentioned preset address segment can be 0x0000 to 0x0015 of Sector0. If the above-mentioned write command is a file write command and the FLASH chip is erased according to the sector size, the above-mentioned preset address segment can be, for example, 0x0000 to 0x0fff of Sector0.
[0065] Optionally, in some embodiments, when the write command is a byte write command, the processor may first determine whether there is a byte identical to a preset value in the at least one network device address, where the preset value is the value of the byte stored in the address space after the memory is erased. If there is a byte identical to the preset value in the at least one network device address, the processor then obtains the preset address segment and performs the determination of step S102 to identify whether the write address is within the preset address segment storing the address of at least one network device.
[0066] If there is no byte with the same value as the preset value in the at least one network device address, the processor can process the write command according to the existing byte write command processing method. That is, first determine whether the write address specified by the write command is the address after the data is erased. If so, execute the write command, and if not, do not execute the write command. At this time, since there is no byte with the same value as the preset value in the at least one network device address, even if the write address specified by the write command falls into the address range of the address of the storage network device, the address of the network device will not be rewritten.
[0067] S103: Push warning information, where the warning information is used to indicate that the write address is wrong.
[0068] When the write address specified by the write command input by the user is within the preset address segment storing the address of at least one network device, the processor no longer executes the write command, but pushes a warning message to inform the user that the write address is wrong. In this way, the problem of the address of the network device stored in the memory being arbitrarily changed can be avoided, and the problem of the computer's network communication failure caused by the change of the MAC address of the network device can be avoided.
[0069] Optionally, in some embodiments, the warning information may also be used to instruct the user to rewrite the write address of the data to be written. That is, the warning information may also include a command line that enables the user to re-enter the write address of the data to be written.
[0070] S104. Write the data to be written into the memory according to the write address.
[0071] Taking the memory as a FLASH chip as an example, when the write address specified by the write command input by the user is not located in the preset address segment storing the address of at least one network device, you can refer to the aforementioned process of how to write the data to be written according to the write command (byte write command or file write command) in the prior art.
[0072] The data writing method provided by the present invention is described below by using a specific example:
[0073] Taking the memory as a FLASH chip as an example, assuming that the MAC address of network device 1 is stored in the address segment 0x0000 to 0x0005 of Sector0 of the FLASH chip, occupying 6 bytes. The MAC address of network device 2 is stored in the address segment 0x0010 to 0x0015 of Sector0 of the FLASH chip, also occupying 6 bytes.
[0074] If the write command is a byte write command and the preset address segment is 0x0000 to 0x0015 of Sector0, then in this scenario, when the processor receives the byte write command entered by the user under PMON, if the write address specified by the byte write command is between 0x0000 and 0x0015 of Sector0, for example, 0x0001 of Sector0, the processor will refuse to execute the write command, and prompt the user through a warning message that the write address is wrong, and prompt the user to rewrite the write address. If the write address specified by the byte write command is not between 0x0000 and 0x0015 of Sector0, for example, 0x0016 of Sector0, the processor will perform the write operation according to the existing write process. For example, the processor will first determine whether the value stored on the write address is 0xff. If so, it will perform a write operation. If not, it will refuse to execute the write command.
[0075] If the write command is a file write command, the preset address segment is 0x0000 to 0x0fff of Sector0, and the FLASH chip is erased according to the sector size, then in this scenario, when the processor receives the file write command entered by the user under PMON, if the write address specified by the file write command is between 0x0000 and 0x0FFF of Sector0, for example, 0x0001 of Sector0, then the processor will refuse to execute the write command, and prompt the user through a warning message that the write address is wrong, and prompt the user to rewrite the write address. If the write address specified by the file write command is not between 0x0000 and 0x0fff of Sector0, for example, it is located in other sectors, the processor will perform the write operation according to the existing write process. For example, the processor first performs an erase operation on the sector, and then performs a write operation according to the write address.
[0076] Through the above method, the address of the network device stored in Sector0 of the FLASH chip can be protected from being changed arbitrarily, thereby avoiding the problem of the address of the network device stored in the FLASH chip being changed arbitrarily, and further avoiding the problem of computer network communication failure caused by the change of the MAC address of the network device.
[0077] In the data writing method provided by the present invention, the processor can judge whether the write address is located in a preset address segment storing the address of at least one network device according to the write address carried by the write command, and if the write address is located in the preset address segment, the write command is not executed, but a warning message indicating that the write address is wrong is pushed. In this way, the address of the network device stored in the memory can be protected from being changed at will, and the problem that the MAC address of the network device stored in the fixed address segment of the FLASH chip is changed at will due to an operation error or a lack of understanding of the write operation characteristics of the FLASH chip when the user inputs a write command about the FLASH chip to the computer under PMON can be solved.
[0078] It should be understood that although the above embodiments are all about how to protect the address of the network device stored in the memory from being changed at will, the method provided by the embodiment of the present invention is described and introduced. However, it can be understood by those skilled in the art that the above embodiments can also be applied to protect any data stored in the memory to prevent the data from being changed at will. In this scenario, the above preset address segment can be determined according to the address space where the data to be protected is located, and the implementation method is similar, which will not be repeated here.
[0079] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.
[0080] Figure 3 A schematic diagram of the structure of a data writing device provided by the present invention. The data writing device can implement part or all of the above-mentioned processor through a combination of software and / or hardware. For example, the data writing device can be a chip on the processor, or the data writing device can be the processor, etc.
[0081] like Figure 3 As shown, the data writing device may include: a receiving module 11 and a pushing module 12.
[0082] The receiving module 11 is used to receive a write command input by a user, wherein the write command is used to request to write the data to be written into the memory, and the write command includes a write address of the data to be written;
[0083] The push module 12 is used to push a warning message when the write address is within a preset address segment, wherein the warning message is used to indicate that the write address is wrong; wherein the preset address segment includes an address range in which a target sector of the memory stores at least one network device address.
[0084] Exemplarily, when the write command is a byte write command, the starting address of the preset address segment is the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment is the ending address of the target sector storing the at least one network device. When the write command is a file write command, the preset address segment is the address segment of the target sector.
[0085] Continue to refer to Figure 3 Optionally, in some embodiments, the above device may further include:
[0086] The writing module 13 is used to write the data to be written into the memory according to the writing address when the writing address is not within the preset address segment.
[0087] Continue to refer to Figure 3 Optionally, in some embodiments, when the write command is a byte write command, the apparatus may further include:
[0088] A judging module 14, used for judging whether there is a byte identical to a preset value in the at least one network device address before the pushing module 12 pushes the warning information, wherein the preset value is the value of the byte stored in the address space after the memory is erased;
[0089] The acquisition module 15 is used to acquire the preset address segment when there is a byte with the same value as the preset value in the at least one network device address.
[0090] The data writing device provided by the present invention can execute the above method embodiments, and its implementation principles and technical effects are similar, which will not be repeated here.
[0091] Figure 4 This is a schematic diagram of the structure of another data writing device provided by the present invention. Figure 4 As shown, the data writing device may include: at least one processor 21 and a memory 22 . Figure 4 The data writing device is shown taking a processor as an example, wherein:
[0092] The memory 22 is used to store programs. Specifically, the program may include program codes, and the program codes include computer operation instructions. The memory 22 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.
[0093] The processor 21 is used to execute the computer-executable instructions stored in the memory 22 to implement the data writing method in the above embodiment. The implementation principle and technical effect are similar and will not be repeated here.
[0094] The processor 21 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0095] Optionally, in a specific implementation, if the communication interface, the memory 22 and the processor 21 are implemented independently, the communication interface, the memory 22 and the processor 21 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0096] Optionally, in a specific implementation, if the communication interface, the memory 22 and the processor 21 are integrated on a chip, the communication interface, the memory 22 and the processor 21 can communicate with each other through an internal interface.
[0097] The present invention also provides a computer-readable storage medium, which may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes. Specifically, the computer-readable storage medium stores program instructions, which are used in the method in the above embodiment.
[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for writing data, It is characterized in that The method comprises: Receive a write command input by a user under PMON, the write command is used to request to write the data to be written into the memory, the write command includes the write address of the data to be written, wherein the memory is a FLASH chip, the FLASH chip has the following write characteristics: the address space for writing new data is an erased address space, and the write command includes a byte write command and a file write command; If the write command is a byte write command, determining whether there is a byte in at least one network device address that is the same as a preset value, wherein the preset value is the value of the byte stored in the address space after the memory is erased; If there is a byte in the at least one network device address that is the same as the preset value, obtaining the preset address segment; When the write address is within a preset address segment, a warning message is pushed, wherein the warning message is used to indicate that the write address is wrong; wherein the preset address segment includes an address range in which a target sector of the memory stores at least one network device address; If there is no byte identical to the preset value in the at least one network device address, first determine whether the write address specified by the write command is the address after the data is erased, if so, execute the write command, if not, do not execute the write command; If the write command is a file write command, and the preset address segment is the address segment of the target sector, when the write address is within the preset address segment, the write command is refused to be executed, and a warning message is provided to the user indicating a write address error; when the write address is not within the preset address segment, an erase operation of the sector is performed first, and then a write operation is performed according to the write address.
2. The method according to claim 1, It is characterized in that The method further comprises: When the write address is not within the preset address segment, the data to be written is written into the memory according to the write address.
3. The method according to claim 1 or 2, It is characterized in that If the write command is a byte write command, the starting address of the preset address segment is the starting address of the target sector storing the at least one network device, and the ending address of the preset address segment is the ending address of the target sector storing the at least one network device.
4. A data writing device, It is characterized in that The device comprises: A receiving module, used for receiving a write command input by a user under PMON, wherein the write command is used for requesting to write the data to be written into the memory, and the write command includes the write address of the data to be written, wherein the memory is a FLASH chip, and the FLASH chip has the following write characteristics: the address space for writing new data is an erased address space, and the write command includes a byte write command and a file write command; If the write command is a byte write command, the device further includes: A determination module, used for determining whether there is a byte identical to a preset value in at least one network device address, wherein the preset value is the value of the byte stored in the address space after the memory is erased; An acquisition module, configured to acquire a preset address segment when a byte having the same value as the preset value exists in the at least one network device address; A push module, used for pushing a warning message when the write address is within a preset address segment, wherein the warning message is used to indicate that the write address is wrong; wherein the preset address segment includes an address range in which a target sector of the memory stores at least one network device address; Wherein, if there is no byte identical to the preset value in the at least one network device address, first determine whether the write address specified by the write command is the address after the data is erased, if so, execute the write command, if not, do not execute the write command; Among them, if the write command is a file write command, the preset address segment is the address segment of the target sector, and when the write address is within the preset address segment, the write command is refused to be executed, and a warning message is provided to the user to prompt the user that the write address is wrong; when the write address is not within the preset address segment, the sector erase operation is performed first, and then the write operation is performed according to the write address.
5. The device according to claim 4, It is characterized in that The device also includes: A writing module is used to write the data to be written into the memory according to the writing address when the writing address is not within the preset address segment.
6. A data writing device, It is characterized in that include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory to perform the method according to any one of claims 1 to 3.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Monitoring method for controlling address failure of medium access on network card
CN101090344A
Address error detecting method for data storage device
JP1991095653A
Media access control address error detection method in a network card
TW200743022A
Method of write-protecting a MAC address
US20040236878A1
Data protecting method, memory controller and memory storage apparatus
US20130185479A1
