CN112148201A - Data writing method, device and storage medium - Google Patents
Data writing method, device and storage medium Download PDFInfo
- Publication number
- CN112148201A CN112148201A CN201910559384.3A CN201910559384A CN112148201A CN 112148201 A CN112148201 A CN 112148201A CN 201910559384 A CN201910559384 A CN 201910559384A CN 112148201 A CN112148201 A CN 112148201A
- Authority
- CN
- China
- Prior art keywords
- address
- write
- write command
- preset
- writing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000004891 communication Methods 0.000 description 14
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000002093 peripheral effect Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000005265 energy consumption Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0638—Organizing or formatting or addressing of data
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0646—Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
- G06F3/0652—Erasing, e.g. deleting, data cleaning, moving of data to a wastebasket
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0673—Single storage device
- G06F3/0679—Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Storage Device Security (AREA)
Abstract
本发明提供一种数据写入方法、装置及存储介质,该方法包括:接收用户输入的写入命令,所述写入命令用于请求将待写入数据写入存储器,所述写入命令包括所述待写入数据的写入地址;当所述写入地址位于预设地址段内时,推送警告信息,所述警告信息用于指示所述写入地址错误;其中,所述预设地址段包括所述存储器的目标扇区存储至少一个网络设备地址的地址范围。本发明提供的数据写入方法、装置及存储介质,能够解决现有技术中用户在PMON下向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,而导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改的问题。
The present invention provides a data writing method, device and storage medium. The method includes: receiving 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 The write address of the data to be written; when the write address is located in the preset address segment, push warning information, and the warning information is used to indicate that the write address is wrong; wherein, the preset address A segment includes an address range in which a target sector of the memory stores at least one network device address. The data writing method, device and storage medium provided by the present invention can solve the problem in the prior art that when a user inputs a writing command about a FLASH chip to a computer under PMON, due to operational errors or ignorance of the writing operation characteristics of the FLASH chip , which leads to the problem that the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed.
Description
技术领域technical field
本发明涉及计算机技术,尤其涉及一种数据写入方法、装置及存储介质。The present invention relates to computer technology, and in particular, to a data writing method, device and storage medium.
背景技术Background technique
目前,一些计算机使用专用桥片组(简称:桥片)作为计算系统的芯片组,为处理器提供南北桥功能。该桥片集成有两路吉字节媒体访问控制地址(gigabyte Media AccessControl Address,GMAC)控制器,该两路GMAC控制器通过接口连接外置的GMAC物理层(Physical,PHY)芯片,可以作为计算机的两个网络设备(也可以称为网卡设备),实现网络通信。为了便于后续描述,该两个网络设备分别称为网络设备1和网络设备2。At present, some computers use a dedicated bridge chip set (abbreviation: bridge chip) as a chip set of a computing system to provide a north-south bridge function for the processor. The bridge chip integrates two gigabyte media access control address (GMAC) controllers. The two GMAC controllers are connected to an external GMAC physical layer (Physical, PHY) chip through an interface, which can be used as a computer The two network devices (also known as network card devices) implement network communication. For the convenience of subsequent description, the two network devices are referred to as network device 1 and network device 2 respectively.
上述所说的桥片外接有FLASH芯片,桥片的两个网络设备的MAC地址存储在该FLASH芯片的地址空间的第一个扇区(Sector)的固定地址段中。计算机的PMON上集成了2个关于桥片外接的FLASH芯片的写命令,分别是字节写入命令和文件写入命令。其中,字节写入命令,用于在FLASH芯片的地址空间中写入一个字节的数据。文件写入命令,用于在FLASH芯片的地址空间中写入一个文件的数据。应理解,字节写入命令和文件写入命令,均由用户指定写入地址,即由用户指定需要从FLASH芯片的地址空间的哪个地址开始写入。The above-mentioned bridge chip is connected with a 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 PMON of the computer integrates two write commands about the FLASH chip connected to the bridge chip, which are the byte write command and the file write command. Among them, the byte write command is used to write one 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 is specified by the user, that is, the user specifies which address in the address space of the FLASH chip needs to be written from.
现有技术中,用户在PMON下向计算机输入关于FLASH芯片的写入命令(例如字节写入命令或文件写入命令)时,因操作失误或者对FLASH芯片的写操作特性的不了解,易导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改(例如MAC地址被擦除、MAC地址被重写、MAC地址被改写等),进而导致计算机出现无MAC地址,或MAC地址与同一局域网中其它网络设备的MAC地址冲突的情况,造成计算机的网络通信失败。In the prior art, when the user inputs a write command (such as a byte write command or a file write command) about the FLASH chip to the computer under PMON, due to operational errors or ignorance 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 in the FLASH chip to be changed at will (for example, the MAC address is erased, the MAC address is rewritten, the MAC address is rewritten, etc.), which in turn causes the computer to have no MAC address, or MAC address In the case of conflict with the MAC addresses of other network devices in the same local area network, the network communication of the computer fails.
发明内容SUMMARY OF THE INVENTION
本发明提供一种数据写入方法、装置及存储介质,用于解决现有技术中用户在PMON下向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,而导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改的问题。The present invention provides a data writing method, a device and a storage medium, which are used to solve problems in the prior art when a user inputs a writing command about a FLASH chip to a computer under PMON, due to operational errors or the characteristics of the writing operation to the FLASH chip. Without understanding, the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed.
本发明第一方面提供一种数据写入方法,该方法包括:A first aspect of the present invention provides a data writing method, the method comprising:
接收用户输入的写入命令,所述写入命令用于请求将待写入数据写入存储器,所述写入命令包括所述待写入数据的写入地址;receiving a write command input by a user, the write command is used to request to write data to be written into the memory, and the write command includes a write address of the data to be written;
当所述写入地址位于预设地址段内时,推送警告信息,所述警告信息用于指示所述写入地址错误;其中,所述预设地址段包括所述存储器的目标扇区存储至少一个网络设备地址的地址范围。When the write address is within a preset address segment, push warning information, where the warning information is used to indicate that the write address is wrong; wherein the preset address segment includes the target sector of the memory storing at least An address range of network device addresses.
在一种可能的实施方式中,所述方法还包括:In a possible implementation, the method further includes:
当所述写入地址未位于所述预设地址段内时,根据所述写入地址,将所述待写入数据写入所述存储器中。When the write address is not located in the preset address segment, the to-be-written data is written into the memory according to the write address.
在一种可能的实施方式中,所述写入命令为字节写入命令,所述推送警告信息之前,所述方法还包括:In a possible implementation manner, the write command is a byte write command, and before pushing the warning information, the method further includes:
判断所述至少一个网络设备地址中是否存在与预设取值相同的字节,所述预设取值为所述存储器擦除后的地址空间存储的字节的值;Determine whether there is a byte with the same preset value in the at least one network device address, and the preset value is the value of the byte stored in the address space after the memory has been erased;
若所述至少一个网络设备地址中存在与所述预设取值相同的字节,则获取所述预设地址段。If a byte with the same preset value exists in the at least one network device address, obtain the preset address segment.
在一种可能的实施方式中,所述写入命令为字节写入命令,所述预设地址段的起始地址为所述目标扇区存储所述至少一个网络设备的起始地址、所述预设地址段的结束地址为所述目标扇区存储所述至少一个网络设备的结束地址。In a possible implementation manner, the write command is a byte write command, and the starting address of the preset address segment is the starting address of the target sector for storing the at least one network device, all The end address of the preset address segment is the end address where the target sector stores the at least one network device.
在一种可能的实施方式中,所述写入命令为文件写入命令,所述预设地址段为所述目标扇区的地址段。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.
本发明第二方面提供一种数据写入装置,所述装置包括:A second aspect of the present invention provides a data writing device, the device comprising:
接收模块,用于接收用户输入的写入命令,所述写入命令用于请求将待写入数据写入存储器,所述写入命令包括所述待写入数据的写入地址;a receiving module, configured to receive a write command input by a user, where the write command is used to request to write data to be written into the memory, and the write command includes a write address of the data to be written;
推送模块,用于在所述写入地址位于预设地址段内时,推送警告信息,所述警告信息用于指示所述写入地址错误;其中,所述预设地址段包括所述存储器的目标扇区存储至少一个网络设备地址的地址范围。A push module, configured to push warning information when the write address is within a preset address segment, where the warning information is used to indicate that the write address is wrong; wherein the preset address segment includes the memory The target sector stores an address range of at least one network device address.
在一种可能的实施方式中,所述装置还包括:In a possible implementation, the device further includes:
写入模块,用于在所述写入地址未位于所述预设地址段内时,根据所述写入地址,将所述待写入数据写入所述存储器中。The writing module is configured to write the data to be written into the memory according to the writing address when the writing address is not located in the preset address segment.
在一种可能的实施方式中,所述写入命令为字节写入命令,所述装置还包括:In a possible implementation manner, the write command is a byte write command, and the apparatus further includes:
判断模块,用于在所述推送模块推送警告信息之前,判断所述至少一个网络设备地址中是否存在与预设取值相同的字节,所述预设取值为所述存储器擦除后的地址空间存储的字节的值;The judgment module is used to judge whether there is a byte with the same preset value in the at least one network device address before the push module pushes the warning information, and the preset value is the value after the memory is erased. The value of the byte stored in the address space;
获取模块,用于在所述至少一个网络设备地址中存在与所述预设取值相同的字节时,获取所述预设地址段。An obtaining module, configured to obtain the preset address segment when a byte with the same preset value exists in the at least one network device address.
在一种可能的实施方式中,所述写入命令为字节写入命令,所述预设地址段的起始地址为所述目标扇区存储所述至少一个网络设备的起始地址、所述预设地址段的结束地址为所述目标扇区存储所述至少一个网络设备的结束地址。In a possible implementation manner, the write command is a byte write command, and the starting address of the preset address segment is the starting address of the target sector for storing the at least one network device, all The end address of the preset address segment is the end address where the target sector stores the at least one network device.
在一种可能的实施方式中,所述写入命令为文件写入命令,所述预设地址段为所述目标扇区的地址段。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.
本发明第三方面提供一种数据写入装置,包括:至少一个处理器和存储器;A third aspect of the present invention provides a data writing device, comprising: at least one processor and a 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 of any one of the first aspects.
本发明第四方面提供一种计算机可读存储介质,该计算机可读存储介质中存储有程序指令,所述程序指令被处理器执行时实现第一方面任一项所述的方法。A fourth aspect of the present invention provides a computer-readable storage medium, where program instructions are stored in the computer-readable storage medium, and when the program instructions are executed by a processor, any one of the methods described in the first aspect is implemented.
本发明提供的数据写入方法、装置及存储介质,处理器能够根据写入命令所携带的写入地址,判断该写入地址是否位于存储有至少一个网络设备的地址的预设地址段内,若该写入地址位于该预设地址段内,则不执行该写入命令,而是推送用于指示所述写入地址错误的警告信息。通过这种方式,可以保护存储在存储器中的网络设备的地址不会被随意更改,可以解决用户在PMON下向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,而导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改的问题。In the data writing method, device and storage medium provided by the present invention, the processor can judge whether the write address is located in the 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 within 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 arbitrarily changed, which can solve the problem that when the user inputs a write command about the FLASH chip to the computer under PMON, due to an operation error or a write operation to the FLASH chip The lack of understanding of the characteristics leads to the problem that the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1为计算机的结构示意图;Fig. 1 is the structural representation of computer;
图2为本发明提供的一种数据写入方法的流程示意图;2 is a schematic flowchart of a data writing method provided by the present invention;
图3为本发明提供的一种数据写入装置的结构示意图;3 is a schematic structural diagram of a data writing device provided by the present invention;
图4为本发明提供的另一种数据写入装置的结构示意图。FIG. 4 is a schematic structural diagram of another data writing device provided by the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
芯片组是指一组共同工作的集成电路芯片,负责将计算机的处理器和计算机的其他部分相连接。在计算机领域,芯片组一词通常指两个主要的主板芯片,即北桥和南桥。图1为计算机的结构示意图,如图1所示,目前,一些计算机使用专用桥片组(简称:桥片)作为计算系统的芯片组,为处理器提供南北桥功能。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 north bridge and the south bridge. FIG. 1 is a schematic diagram of the structure of a computer. As shown in FIG. 1 , at present, some computers use a dedicated bridge chip group (abbreviation: bridge chip) as a chip group of a computing system to provide a north-south bridge function for the processor.
媒体访问控制地址(Media Access Control Address,MAC),也叫硬件地址,具有唯一性。因此,在网络通信过程中,通常都使用MAC地址定义网络设备的位置。网络设备无MAC地址,或网络设备的MAC地址与同一局域网中其它网络设备的MAC地址冲突,都会造成网络通信失败。A Media Access Control Address (MAC), also called a hardware address, is unique. Therefore, in the process of network communication, the MAC address is usually used to define the location of the network device. If the network device has no MAC address, or the MAC address of the network device conflicts with the MAC addresses of other network devices in the same local area network, network communication will fail.
上述所说的桥片集成有两路GMAC控制器,该两路GMAC控制器通过接口连接外置的GMAC物理层(Physical,PHY)芯片(图1中未示出),可以作为计算机的两个网络设备(也可以称为网卡设备),实现计算机的网络通信。为了便于后续描述,该两个网络设备分别称为网络设备1和网络设备2。The above-mentioned bridge chip integrates two GMAC controllers, and the two GMAC controllers are connected to an external GMAC physical layer (Physical, PHY) chip (not shown in Figure 1) through an interface, which can be used as two A network device (also known as a network card device) implements network communication of a computer. For the convenience of subsequent description, the two network devices are referred to as network device 1 and network device 2 respectively.
参阅图1所示,计算机包括依次连接的处理器、桥片和FLASH芯片,其中,相较于现有技术,该FLASH芯片为额外外接在桥片外的存储器,用于存储网络设备的MAC地址和其他信息。具体的,上述所说的桥片外接有FLASH芯片,该FLASH芯片也可以称为闪存,是一种在断电状态下仍保持存储数据信息的存储器。FLASH芯片的地址空间由多个扇区(Sector)组成,每个扇区的大小为4KB,每个扇区的存储地址从0x0000至0x0fff。现有技术中,桥片的两个网络设备的MAC地址存储在该FLASH芯片的地址空间的第一个Sector0的固定地址段中。具体地,网络设备1的MAC地址存放在Sector0的0x0000至0x0005的地址段中,占6个字节。网络设备2的MAC地址存放在Sector0的0x0010至0x0015地址段中,也占6个字节。Referring to FIG. 1, the computer includes a processor, a bridge chip and a FLASH chip that are connected in sequence, wherein, compared with the prior art, the FLASH chip is an additional memory outside the bridge chip for storing the MAC address of the network device. and other information. Specifically, the above-mentioned bridge chip is externally connected with a FLASH chip, and the FLASH chip may also be called a flash memory, which is a memory that keeps storing data and information in a power-off state. The address space of the FLASH chip consists of multiple sectors (Sectors), the size of each sector is 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 in the address space of the FLASH chip. Specifically, the MAC address of the network device 1 is stored in the address segment from 0x0000 to 0x0005 of Sector0, occupying 6 bytes. The MAC address of network device 2 is stored in the address segment 0x0010 to 0x0015 of Sector0, which also occupies 6 bytes.
PMON是一个兼备基本输入输出系统(Basic Input Output System,BIOS)和bootloader部分功能的开放源码软件。PMON是计算机的“固件”,可以视为是计算机的硬件的一部分,在计算机中的作用是对硬件进行最基本的初始化,是硬件与操作系统内核的接口。PMON上集成了2个关于桥片外接的FLASH芯片的写命令,分别是字节写入命令和文件写入命令。其中,字节写入命令,用于在FLASH芯片的地址空间中写入一个字节的数据。文件写入命令,用于在FLASH芯片的地址空间中写入一个文件的数据。应理解,字节写入命令和文件写入命令,均由用户指定写入地址(即需要用户指定从FLASH芯片的地址空间的哪个地址开始写入)。PMON is an open source software that has both basic input output system (Basic Input Output System, BIOS) and some functions of bootloader. PMON is the "firmware" of the computer, which can be regarded as a part of the hardware of the computer. Its function in the computer is to perform the most basic initialization of the hardware, and it is the interface between the hardware and the operating system kernel. The PMON integrates two write commands about the FLASH chip connected to the bridge chip, which are byte write commands and file write commands. Among them, the byte write command is used to write one 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 is specified by the user (that is, the user needs to specify which address in the address space of the FLASH chip to start writing from).
该FLASH芯片支持按Sector大小擦除,即每次最少擦除4KB大小的地址空间,擦除后的地址空间存储的字节的值为0xff。FLASH芯片写操作的特点是,必须先擦除后才能写入新数据。即,写入新数据的地址空间一定是被擦除过的地址空间。在本申请文件中,地址空间和地址的概念等同,本实施例对此不进行区分。The FLASH chip supports erasing according to the size of the sector, that is, erasing at least 4KB of address space each time, and the value of the bytes stored in the erased address space is 0xff. The characteristic of the FLASH chip write operation is that it must be erased before new data can be written. That is, the address space where new data is written must be the address space that has been erased. In this application document, the concepts of address space and address are the same, and this embodiment does not distinguish them.
当用户在PMON下向计算机输入字节写入命令,并指定待写入数据的写入地址位于Sector0的0x0000至0x0005之间或0x0010至0x0015之间时,处理器在执行该字节写入命令时,不会执行擦除操作,而是会直接执行写操作。此时,若FLASH芯片上该写入地址上存储的值为0xff,即当前时刻该写入地址所指示的地址空间中存储的值为0xff,处理器会误认为该写入地址为擦除数据后的地址,则处理器会直接执行上述写入操作,导致FLASH芯片所存储的网络设备的地址被改写。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, when the processor executes the byte write command , the erase operation will not be performed, but the write operation will be performed directly. At this time, if the value stored in 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 mistake the write address as erasing data After the address, the processor will directly perform the above write operation, causing the address of the network device stored in the FLASH chip to be rewritten.
例如,假定位于Sector0的0x0000-0x0005的网络设备1的MAC地址为00:11:22:AB:FF:66。即,网络设备1的MAC地址存储在FLASH芯片的扇区Sector0中,占用该扇区Sector0的6个字节的地址空间。换而言之,网络设备1的MAC地址可以视为6组数据,每组数据占用一个字节的地址空间。即,00占用一个字节的地址空间,11占用一个字节的地址空间,22占用一个字节的地址空间,AB占用一个字节的地址空间,FF占用一个字节的地址空间,66占用一个字节的地址空间。For example, assume that the MAC address of network device 1 at 0x0000-0x0005 of Sector0 is 00:11:22:AB:FF:66. That is, the MAC address of the network device 1 is stored in the sector Sector0 of the FLASH chip, occupying an address space of 6 bytes in the sector Sector0. In other words, the MAC address of the network device 1 can be regarded as 6 groups of data, and each group of data occupies an address space of one byte. 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 bytes of address space.
在该场景下,以用户在PMON下向计算机输入字节写入命令为例,假定该字节写入命令所指示的待写入数据为AC,所指定的写入地址为0x0004。在该示例下,因0x0004上存储的值为0xff(即写入地址0x0004上存储的值为0xff),此时,处理器会认为该写入地址0x0004为经过擦除数据后的地址,则处理器会执行该写操作,将0x0004上存储的值改写为AC,导致网络设备1的MAC地址变为00:11:22:AB:AC:66。若该字节写入命令所指示的待写入数据为AC,所指定的写入地址为0x0005。在该示例下,因0x0005所上存储为0x66,并非是0xff;此时,处理器会认为该写入地址为未经过擦除数据后的地址,在该场景下,处理器不会执行该写操作。即,写入失败。In this scenario, taking the user inputting a byte write command to the computer under PMON as an example, it is assumed that the data to be written indicated by the byte write command is AC, and the specified write address is 0x0004. In this example, since the value stored at 0x0004 is 0xff (that is, the value stored at the write address 0x0004 is 0xff), at this time, the processor will consider the write address 0x0004 to be the address after erasing the data, and then process The controller will perform the write operation, rewriting the value stored on 0x0004 to AC, resulting in the MAC address of network device 1 becoming 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 consider the write address to be the address after erasing the data, and in this scenario, the processor will not execute the write operate. That is, writing fails.
也就是说,当字节写入命令所指定的写入地址对应的地址空间中存储的值是0xff时,处理器会执行该字节写入命令,使用该字节写入命令所指示的待写入字节替代该写入地址对应的地址空间中原本存储的值0xff。That is to say, 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 The write byte replaces the value 0xff originally stored in the address space corresponding to the write address.
相应地,当用户在PMON下向计算机输入文件写入命令,并指定待写入文件的写入地址位于Sector0的0x0000至0x0FFF的地址段时,处理器会先执行擦除Sector0的操作,导致存储在Sector0中的0x0000至0x0015地址段的网络设备1的MAC地址和网络设备2的MAC地址均会被擦成0xff。处理器在完成擦除Sector0的操作后,从文件写入命令指定的写入地址开始,往Sector0中写入该待写入文件的数据。此时,若该待写入文件的写入地址位于0x0000至0x0015之间,则会导致网络设备1的MAC地址和网络设备2的MAC地址被重新改写。Correspondingly, 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 from 0x0000 to 0x0FFF of Sector0, the processor will first perform the operation of erasing Sector0, resulting in the storage of The MAC address of network device 1 and the MAC address of network device 2 in the 0x0000 to 0x0015 address range in Sector0 will be 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 to-be-written file into Sector0. At this time, if the write address of the to-be-written file is between 0x0000 and 0x0015, the MAC address of the network device 1 and the MAC address of the network device 2 will be rewritten.
应理解,上述处理器在向FLASH芯片执行写入操作时,可以通过桥片来执行该写入操作。通常而言,桥片通过串行外设接口(Serial Peripheral Interface,SPI)控制器向FLASH芯片执行该写入操作,因此,在一些实施例中,上述字节写入命令也可以称为SPI字节写入命令,文件写入命令也可以称为SPI文件写入命令,SPI字节写入命令和SPI文件写入命令可以统称为SPI写入命令。It should be understood that, when the above-mentioned processor performs the 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 above byte write command may also be referred to as an SPI word Section write command, file write command can also be called SPI file write command, SPI byte write command and SPI file write command can be collectively called SPI write command.
通过上述描述可以看出,由于上述FLASH芯片自身的写特点(即写入新数据的地址空间一定是被擦除过的地址空间,以及,擦除后的地址空间存储的值为0xFF等),致使用户向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,易导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改(MAC地址被擦除、MAC地址被重写、MAC地址被改写等),进而导致计算机出现无MAC地址,或MAC地址与同一局域网中其它网络设备的MAC地址冲突的情况,造成计算机的网络通信失败。It can be seen from the above description that due to the writing characteristics of the above-mentioned FLASH chip itself (that is, the address space in which new data is written must be the address space that has been erased, 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, the MAC address of the network device stored in the fixed address segment in the FLASH chip is easily changed due to operational errors or ignorance of the write operation characteristics of the FLASH chip (MAC address). The address is erased, the MAC address is rewritten, the MAC address is rewritten, etc.), which in turn causes 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, resulting in the computer's network communication failure.
考虑到上述因FLASH芯片自身的写特点所导致的问题,本发明提供了一种数据写入方法,处理器在执行写入命令时,能够根据写入命令所携带的写入地址,判断该写入地址是否位于存储有至少一个网络设备的地址的预设地址段内,若该写入地址位于该预设地址段内,则不执行该写入命令,而是推送用于指示所述写入地址错误的警告信息。通过这种方式,可以保护存储在存储器中的网络设备的地址不会被随意更改,可以解决用户向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,而导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改的问题。其中,上述网络设备的地址即为该网络设备的MAC地址。Considering the above-mentioned problems caused by the writing characteristics of the FLASH chip itself, the invention provides a data writing method, when the processor executes the writing command, it can judge the writing according to the writing address carried by the writing command. Whether the incoming address is located in the preset address segment where the address of at least one network device is stored, if the write address is located in the preset address segment, the write command is not executed, but is pushed to instruct the write Address error warning message. In this way, the address of the network device stored in the memory can be protected from being arbitrarily changed, which can solve the problem that when the user inputs a write command about the FLASH chip to the computer, due to operational errors or inconsistent write operation characteristics of the FLASH chip Understand the problem that the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed. The address of the above network device is the MAC address of the network device.
本发明所提供的方法可以适用于包括存储器的电子设备,该存储器用于存储网络设备的MAC地址、且具有如下写特点:写入新数据的地址空间一定是被擦除过的地址空间,以及,擦除后的地址空间存储的值为预设值,该预设值例如可以为0xFF。例如,该存储器可以为前述所说的FLASH芯片。The method provided by the present invention can be applied to an electronic device including a memory, which is used to store the MAC address of the network device and has the following writing characteristics: the address space in which new data is written must be the address space that has been erased, and , the value stored in the erased address space is a preset value, and the preset value may be, for example, 0xFF. For example, the memory can be the aforementioned FLASH chip.
以FLASH芯片为例,本发明所提供的方法所适用的电子设备,可以为通过桥片为处理器提供南北桥功能、且桥片的网络设备的MAC地址存储在桥片外接的FLASH芯片的电子设备(例如图1所示的计算机)。该电子设备可以使用PMON作为“固件”,对电子设备的硬件进行最基本的初始化,也可以使用UEFI,对电子设备的硬件进行最基本的初始化,也可以采用其他固件对电子设备的硬件进行初始化。即,本发明实施例对该电子设备所使用的固件不进行限定。也就是说,本发明实施例所提供的方法,适用于任一使用该FLASH芯片的电子设备,在此不再一一列举。Taking the FLASH chip as an example, the electronic equipment to which the method provided by the present invention is applicable can be the electronic device that provides the north-south bridge function for the processor through the bridge chip, and the MAC address of the network device of the bridge chip is stored in the electronic device of the FLASH chip external to the bridge chip. equipment (such as the computer shown in Figure 1). The electronic device can use PMON as "firmware" to initialize the hardware of the electronic device, or use UEFI to initialize the hardware of the electronic device, or 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. That is to say, the methods provided by the embodiments of the present invention are applicable to any electronic device using the FLASH chip, and are not listed one by one here.
本发明所提供的数据写入方法的执行主体可以为数据写入装置,该数据写入装置可以为驱动程序、程序代码软件,也可以为存储有相关执行代码的介质,例如,U盘等;或者,该数据写入装置还可以为集成或安装有相关执行代码的实体装置,例如,芯片、微控制单元(Microcontroller Unit,简称MCU)、电脑、计算机等电子设备。The execution body of the data writing method provided by the present invention may be a data writing device, and the data writing device may be a driver program, program code software, or a medium storing relevant execution codes, such as a U disk, etc.; Alternatively, the data writing device may also be a physical device integrated or installed with relevant execution codes, such as a chip, a Microcontroller Unit (MCU for short), a computer, a computer and other electronic equipment.
举例来说,该方案可应用于计算机中,该计算机的处理器具有高性能低功耗的特点,可应用于服务器、高性能计算机、低能耗数据中心、个人高性能计算机、高端桌面应用、高吞吐计算应用、工业控制、数字信号处理、高端嵌入式应用等。For example, the solution can be applied to a computer, the processor of which has the characteristics of high performance and low power consumption, and can be applied to servers, high performance computers, low energy consumption data centers, personal high performance computers, high-end desktop applications, high Throughput computing applications, industrial control, digital signal processing, high-end embedded applications, etc.
下面结合图1所示的计算机结构,以集成或安装有相关执行代码的处理器为例,以具体地实施例对本发明的技术方案进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。The technical solution of the present invention will be described in detail with specific embodiments in conjunction with the computer structure shown in FIG. 1 , taking a processor integrated or installed with relevant execution codes as an example. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
图2为本发明提供的一种数据写入方法的流程示意图。如图2所示,该方法包括:FIG. 2 is a schematic flowchart of a data writing method provided by the present invention. As shown in Figure 2, the method includes:
S101、接收用户输入的写入命令,所述写入命令用于请求将待写入数据写入存储器,所述写入命令包括所述待写入数据的写入地址。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.
上述所说的写入命令例如可以为前述所说的字节写入命令或文件写入命令。当然,上述写入命令还可以为现有技术中其他类型的写入命令,对此不再赘述。The above-mentioned write command can be, for example, the above-mentioned byte write command or file write command. Of course, the above write command may also be other types of write commands in the prior art, which will not be repeated here.
当上述写入命令为字节写入命令时,待写入数据可以为一个字节大小的数据。当上述写入命令为文件写入命令时,待写入数据可以为一个文件的数据。在该场景下,该写入命令还可以包括待写入文件当前所在的路径。When the above write command is a byte write command, the data to be written may be data of a size of one byte. When the above 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 further include the path where the file to be written is currently located.
上述所说的存储器可以为任一具有先擦除后才能写入新数据的写特点的存储器,例如前述所说的FLASH芯片。The above-mentioned memory may be any memory that has the write characteristic of writing new data after erasing, such as the above-mentioned FLASH chip.
S102、判断所述写入地址是否位于存储有至少一个网络设备的地址的预设地址段内。若是,则执行步骤S103,若否,则执行步骤S104。S102. Determine whether the write address is located in a preset address segment in which the address of at least one network device is stored. If yes, go to step S103, if not, go to step S104.
其中,所述预设地址段包括所述存储器的目标扇区存储至少一个网络设备地址的地址范围,即上述目标扇区为FLASH芯片中存储有网络设备地址的扇区。该预设地址段具体可以根据计算机中至少一个网络设备的地址在目标扇区中的地址,以及,存储器的写特点来确定。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. Specifically, the preset address segment may be determined according to the address of the address of at least one network device in the computer in the target sector, and the write characteristics of the memory.
以存储器为FLASH芯片为例,若所述写入命令为字节写入命令,则所述预设地址段的起始地址可以为目标扇区存储所述至少一个网络设备的起始地址、所述预设地址段的结束地址为所述目标扇区存储所述至少一个网络设备的结束地址。或者,所述预设地址段的起始地址可以小于目标扇区存储所述至少一个网络设备的起始地址、所述预设地址段的结束地址可以大于目标扇区存储所述至少一个网络设备的结束地址。Taking the memory as a FLASH chip as an example, if the write command is a byte write command, then the start address of the preset address segment can be the target sector to store the start address of the at least one network device, all The end address of the preset address segment is the end address where the target sector stores the at least one network device. Alternatively, the starting address of the preset address segment may be smaller than the starting address of the target sector for storing the at least one network device, and the ending address of the preset address segment may be greater than the target sector storing the at least one network device. end address of .
若所述写入命令为文件写入命令、且FLASH芯片是按照扇区大小擦除,则所述预设地址段为所述目标扇区的地址段。或者,所述预设地址段包括目标扇区的地址段。应理解,若FLASH芯片是按照块大小擦除,则所述写入命令为文件写入命令时,所述预设地址段为所述目标扇区所在的块的地址段,或者,所述预设地址段包括所述目标扇区所在的块的地址段。若FLASH芯片是按照整片大小擦除,则所述写入命令为文件写入命令时,所述预设地址段为所述目标扇区所在的片的地址段,或者,所述预设地址段包括目标扇区所在的片的地址段。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 is. It is assumed that the address segment includes the address segment of the block where the target sector is located. If the FLASH chip is erased according to the size of the entire chip, when the write command is a file write command, the preset address segment is the address segment of the slice where the target sector is located, or the preset address The segment includes the address segment of the slice where the target sector is located.
假定网络设备1的MAC地址存放在存储器的Sector0的0x0000至0x0005的地址段中,占6个字节。网络设备2的MAC地址存放在存储器的Sector0的0x0010至0x0015地址段中,也占6个字节。以存储器为FLASH芯片为例,若上述写入命令为字节写入命令,则上述预设地址段可以为Sector0的0x0000至0x0015。若上述写入命令为文件写入命令、且FLASH芯片是按照扇区大小擦除,则上述预设地址段例如可以为Sector0的0x0000至0x0fff。It is assumed that the MAC address of the network device 1 is stored in the address segment from 0x0000 to 0x0005 of Sector0 of the memory, occupying 6 bytes. The MAC address of the network device 2 is stored in the address segment 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 write command is a byte write command, the above preset address segment may be 0x0000 to 0x0015 of Sector0. If the above write command is a file write command and the FLASH chip is erased according to the sector size, the above preset address segment may be, for example, 0x0000 to 0x0fff of Sector0.
可选的,在一些实施例中,当所述写入命令为字节写入命令时,处理器还可以先判断所述至少一个网络设备地址中是否存在与预设取值相同的字节,所述预设取值为所述存储器擦除后的地址空间存储的字节的值。若所述至少一个网络设备地址中存在与所述预设取值相同的字节,则处理器再获取所述预设地址段,并执行步骤S102的判断,以甄别所述写入地址是否位于存储有至少一个网络设备的地址的预设地址段内。Optionally, in some embodiments, when the write command is a byte write command, the processor may first determine whether there is a byte with the same preset value in the at least one network device address, The preset value is the value of the byte stored in the address space after the memory has been erased. If there is a byte with the same preset value in the at least one network device address, the processor then obtains the preset address segment, and executes the judgment of step S102 to determine whether the write address is located in the In a preset address segment where the address of at least one network device is stored.
若所述至少一个网络设备地址中不存在与所述预设取值相同的字节,则处理器可以按照现有的字节写入命令的处理方式,对该写入命令进行处理。即,先判断写入命令所指定的写入地址是否为经过擦除数据后的地址,若是,则执行该写入命令,若否,则不执行该写入命令。此时,由于该至少一个网络设备地址中不存在预设取值相同的字节,因此,即便写入命令所指定的写入地址落入存储网络设备的地址的地址范围,也不会发生网络设备的地址被改写的情况。If a byte with the same preset value does not exist in the at least one network device address, the processor may process the write command according to the existing processing mode of the byte write command. That is, it is first judged whether the write address specified by the write command is the address after erasing the data, 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 preset value in the at least one network device address, even if the write address specified by the write command falls within the address range of the address of the storage network device, no network When the address of the device is overwritten.
S103、推送警告信息,所述警告信息用于指示所述写入地址错误。S103. Push warning information, where the warning information is used to indicate that the write address is incorrect.
当用户输入的写入命令所指定的写入地址位于存储有至少一个网络设备的地址的预设地址段内时,处理器不再执行该写入命令,而是推送警告信息,以告知用户写入地址错误。通过这种方式,可以避免存储在存储器中的网络设备的地址被随意更改的问题,进而可以避免因网络设备MAC地址被更改,而造成计算机的网络通信失败的问题。When the write address specified by the write command input by the user is located in 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 to write Incorrect address. In this way, the problem that the address of the network device stored in the memory is arbitrarily changed can be avoided, and the problem of network communication failure of the computer caused by the change of the MAC address of the network device can be avoided.
可选的,在一些实施例中,所述警告信息还可以用于指示用户重写所述待写入数据的写入地址。即,该警告信息还可以包括能够让用户重新输入待写入数据的写入地址的命令行。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 further include a command line that enables the user to re-input the write address of the data to be written.
S104、根据所述写入地址,将所述待写入数据写入所述存储器中。S104. Write the data to be written into the memory according to the write address.
以存储器为FLASH芯片为例,则当用户输入的写入命令所指定的写入地址没有位于存储有至少一个网络设备的地址的预设地址段内时,可以参见前述关于现有技术中如何根据写入命令(字节写入命令或文件写入命令)写入待写入数据的过程。Taking the memory as a FLASH chip as an example, then when the specified write address of the write command input by the user is not located in the preset address segment where the address of at least one network device is stored, it can be referred to the foregoing about how according to the prior art. The write command (byte write command or file write command) is the process of writing the data to be written.
下面通过一个具体的示例来对本发明提供的数据写入方法进行说明:The data writing method provided by the present invention is described below through a specific example:
以存储器为FLASH芯片为例,假定网络设备1的MAC地址存放在FLASH芯片的Sector0的0x0000至0x0005的地址段中,占6个字节。网络设备2的MAC地址存放在FLASH芯片的Sector0的0x0010至0x0015地址段中,也占6个字节。Taking the memory as a FLASH chip as an example, it is assumed that the MAC address of the network device 1 is stored in the address segment from 0x0000 to 0x0005 of Sector0 of the FLASH chip, occupying 6 bytes. The MAC address of the network device 2 is stored in the 0x0010 to 0x0015 address segment of Sector0 of the FLASH chip, which also occupies 6 bytes.
若写入命令为字节写入命令、预设地址段为Sector0的0x0000至0x0015,则在该场景下,当处理器接收到用户在PMON下输入的字节写入命令时,若该字节写入命令所指定的写入地址位于Sector0的0x0000至0x0015之间,例如为Sector0的0x0001,则处理器会拒绝执行写入命令,并通过警告信息提示用户写入地址错误,并提示用户重写写入地址。若该字节写入命令所指定的写入地址没有位于Sector0的0x0000至0x0015,例如为Sector0的0x0016,则处理器会按照现有的写入流程,执行写入操作。例如,处理器会先判断写入地址上存储的值是否为0xff,若是,则进行写操作,若否,则拒绝执行写入命令。If the write command is a byte write command and the preset address segment is 0x0000 to 0x0015 of Sector0, in this scenario, when the processor receives a byte write command input by the user under PMON, if the byte If the write address specified by the 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 that the write address is wrong with a warning message, and prompt the user to rewrite write address. If the write address specified by the byte write command is not located at 0x0000 to 0x0015 of Sector0, such as 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 in the write address is 0xff, if so, perform the write operation, and if not, refuse to execute the write command.
若写入命令为文件写入命令、预设地址段为Sector0的0x0000至0x0fff、FLASH芯片是按照扇区大小擦除,则在该场景下,当处理器接收到用户在PMON下输入的文件写入命令时,若该文件写入命令所指定的写入地址位于Sector0的0x0000至0x0FFF之间,例如为Sector0的0x0001,则处理器会拒绝执行该写入命令,并通过警告信息提示用户写入地址错误,并提示用户重写写入地址。若该文件写入命令所指定的写入地址没有位于Sector0的0x0000至0x0fff,例如,位于其它Sector,则处理器会按照现有的写入流程,执行写入操作。例如,处理器先执行扇区的擦除操作,再根据写入地址,执行写入操作。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, in this scenario, when the processor receives the file write input from the user under PMON When entering the command, if the write address specified by the file write command is between 0x0000 and 0x0FFF of Sector0, such as 0x0001 of Sector0, the processor will refuse to execute the write command and prompt the user to write through a warning message. The address is wrong and the user is prompted to rewrite the write address. If the write address specified by the file write command is not located in 0x0000 to 0x0fff of Sector0, for example, in another Sector, the processor will perform the write operation according to the existing write process. For example, the processor first performs the erase operation of the sector, and then performs the write operation according to the write address.
通过上述方式,可以保护存储在FLASH芯片的Sector0中的网络设备的地址不会被随意更改,可以避免存储在FLASH芯片中的网络设备的地址被随意更改的问题,进而可以避免因网络设备MAC地址被更改,而造成计算机的网络通信失败的问题。Through the above method, the address of the network device stored in Sector0 of the FLASH chip can be protected from being arbitrarily changed, and the problem of the address of the network device stored in the FLASH chip being arbitrarily changed can be avoided, thereby avoiding the MAC address of the network device. The problem is that the computer's network communication fails due to changes.
本发明提供的数据写入方法,处理器能够根据写入命令所携带的写入地址,判断该写入地址是否位于存储有至少一个网络设备的地址的预设地址段内,若该写入地址位于该预设地址段内,则不执行该写入命令,而是推送用于指示所述写入地址错误的警告信息。通过这种方式,可以保护存储在存储器中的网络设备的地址不会被随意更改,可以解决用户在PMON下向计算机输入关于FLASH芯片的写入命令时,因操作失误或者对FLASH芯片的写操作特性的不了解,而导致存储在FLASH芯片中固定地址段的网络设备的MAC地址被随意更改的问题。In the data writing method provided by the present invention, the processor can judge whether the writing address is located in the preset address segment storing the address of at least one network device according to the writing address carried by the writing command, and if the writing address is If it 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 arbitrarily changed, which can solve the problem that when the user inputs a write command about the FLASH chip to the computer under PMON, due to an operation error or a write operation to the FLASH chip The lack of understanding of the characteristics leads to the problem that the MAC address of the network device stored in the fixed address segment in the FLASH chip is arbitrarily changed.
应理解,虽然上述实施例均以如何保护存储在存储器中的网络设备的地址不会被随意更改,对本发明实施例提供的方法进行了说明和介绍。但是,本领域技术人员可以理解的是,上述实施例也可以适用于保护存储在存储器中的任意数据,以避免该数据不会被随意更改。在该场景下,上述预设地址段可以根据所需要保护的数据所在的地址空间确定,其实现方式类似,对此不再赘述。It should be understood that although the above embodiments all describe and introduce the method provided by the embodiment of the present invention in terms of how to protect the address of the network device stored in the memory from being arbitrarily changed. However, those skilled in the art can understand that the above embodiments can also be applied to protect any data stored in the memory, so as to prevent the data from being arbitrarily changed. In this scenario, the above-mentioned preset address segment may be determined according to the address space in which the data to be protected is located, and the implementation manner is similar, which will not be repeated here.
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by program instructions related to hardware, the aforementioned program may be stored in a computer-readable storage medium, and when the program is executed, execute It includes the steps of the above method embodiments; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
图3为本发明提供的一种数据写入装置的结构示意图。该数据写入装置可以通过软件和/或硬件的结合实现上述处理器的部分或全部,例如,该数据写入装置可以为处理器上的一个芯片、或者,该数据写入装置可以为该处理器等。FIG. 3 is a schematic structural diagram of a data writing device provided by the present invention. The data writing device may implement part or all of the above-mentioned processor through a combination of software and/or hardware, for example, the data writing device may be a chip on the processor, or the data writing device may be the processor device, etc.
如图3所示,该数据写入装置可以包括:接收模块11和推送模块12。其中,As shown in FIG. 3 , the data writing apparatus may include: a receiving
接收模块11,用于接收用户输入的写入命令,所述写入命令用于请求将待写入数据写入存储器,所述写入命令包括所述待写入数据的写入地址;a receiving
推送模块12,用于在所述写入地址位于预设地址段内时,推送警告信息,所述警告信息用于指示所述写入地址错误;其中,所述预设地址段包括所述存储器的目标扇区存储至少一个网络设备地址的地址范围。The
示例性的,当所述写入命令为字节写入命令时,所述预设地址段的起始地址为所述目标扇区存储所述至少一个网络设备的起始地址、所述预设地址段的结束地址为所述目标扇区存储所述至少一个网络设备的结束地址。当所述写入命令为文件写入命令时,所述预设地址段为所述目标扇区的地址段。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, the preset address The end address of the address segment stores the end address of the at least one network device for the target sector. When the write command is a file write command, the preset address segment is the address segment of the target sector.
继续参照图3,可选的,在一些实施例中,上述装置还可以包括:Continuing to refer to FIG. 3 , optionally, in some embodiments, the foregoing apparatus may further include:
写入模块13,用于在所述写入地址未位于所述预设地址段内时,根据所述写入地址,将所述待写入数据写入所述存储器中。The
继续参照图3,可选的,在一些实施例中,当所述写入命令为字节写入命令时,上述装置还可以包括:Continuing to refer to FIG. 3 , optionally, in some embodiments, when the write command is a byte write command, the above apparatus may further include:
判断模块14,用于在所述推送模块12推送警告信息之前,判断所述至少一个网络设备地址中是否存在与预设取值相同的字节,所述预设取值为所述存储器擦除后的地址空间存储的字节的值;The
获取模块15,用于在所述至少一个网络设备地址中存在与所述预设取值相同的字节时,获取所述预设地址段。The obtaining
本发明提供的数据写入装置,可以执行上述方法实施例,其实现原理和技术效果类似,在此不再赘述。The data writing device provided by the present invention can execute the above method embodiments, and the implementation principles and technical effects thereof are similar, and are not repeated here.
图4为本发明提供的另一种数据写入装置的结构示意图。如图4所示,该数据写入装置可以包括:至少一个处理器21和存储器22。图4示出的是以一个处理器为例的数据写入装置,其中,FIG. 4 is a schematic structural diagram of another data writing device provided by the present invention. As shown in FIG. 4 , the data writing apparatus may include: at least one
存储器22,用于存放程序。具体地,程序可以包括程序代码,所述程序代码包括计算机操作指令。存储器22可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。The
处理器21用于执行所述存储器22存储的计算机执行指令,以实现上述实施例中的数据写入方法,其实现原理和技术效果类似,在此不再赘述。The
其中,处理器21可能是一个中央处理器(Central Processing Unit,简称为CPU),或者是特定集成电路(Application Specific Integrated Circuit,简称为ASIC),或者是被配置成实施本发明实施例的一个或多个集成电路。The
可选的,在具体实现上,如果通信接口、存储器22和处理器21独立实现,则通信接口、存储器22和处理器21可以通过总线相互连接并完成相互间的通信。所述总线可以是工业标准体系结构(Industry Standard Architecture,简称为ISA)总线、外部设备互连(Peripheral Component,简称为PCI)总线或扩展工业标准体系结构(Extended IndustryStandard Architecture,简称为EISA)总线等。所述总线可以分为地址总线、数据总线、控制总线等,但并不表示仅有一根总线或一种类型的总线。Optionally, in terms of specific implementation, if the communication interface, the
可选的,在具体实现上,如果通信接口、存储器22和处理器21集成在一块芯片上实现,则通信接口、存储器22和处理器21可以通过内部接口完成相同间的通信。Optionally, in terms of specific implementation, if the communication interface, the
本发明还提供了一种计算机可读存储介质,该计算机可读存储介质可以包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random AccessMemory)、磁盘或者光盘等各种可以存储程序代码的介质。具体的,该计算机可读存储介质中存储有程序指令,程序指令用于上述实施例中的方法。The present invention also provides a computer-readable storage medium, the computer-readable storage medium may include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) Various media that can store program codes, such as , magnetic disk or optical disk. Specifically, program instructions are stored in the computer-readable storage medium, and the program instructions are used for the methods in the foregoing embodiments.
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention. scope.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910559384.3A CN112148201B (en) | 2019-06-26 | 2019-06-26 | Data writing method, device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910559384.3A CN112148201B (en) | 2019-06-26 | 2019-06-26 | Data writing method, device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112148201A true CN112148201A (en) | 2020-12-29 |
CN112148201B CN112148201B (en) | 2024-12-03 |
Family
ID=73869665
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910559384.3A Active CN112148201B (en) | 2019-06-26 | 2019-06-26 | Data writing method, device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112148201B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0395653A (en) * | 1989-09-08 | 1991-04-22 | Nippon Telegr & Teleph Corp <Ntt> | Address error detecting method for data storage device |
WO1993009495A1 (en) * | 1991-11-05 | 1993-05-13 | Australian Tech Support Pty. Ltd. | Computer memory protection |
US6122758A (en) * | 1997-05-13 | 2000-09-19 | Micron Electronics, Inc. | System for mapping environmental resources to memory for program access |
US20040236878A1 (en) * | 2003-05-20 | 2004-11-25 | Wei-Han Chang | Method of write-protecting a MAC address |
TW200743022A (en) * | 2006-05-02 | 2007-11-16 | Inventec Corp | Media access control address error detection method in a network card |
CN101090344A (en) * | 2006-06-13 | 2007-12-19 | 英业达股份有限公司 | Detection Method of Media Access Control Address Error on Network Card |
US8086585B1 (en) * | 2008-09-30 | 2011-12-27 | Emc Corporation | Access control to block storage devices for a shared disk based file system |
US20130185479A1 (en) * | 2012-01-13 | 2013-07-18 | Phison Electronics Corp. | Data protecting method, memory controller and memory storage apparatus |
-
2019
- 2019-06-26 CN CN201910559384.3A patent/CN112148201B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0395653A (en) * | 1989-09-08 | 1991-04-22 | Nippon Telegr & Teleph Corp <Ntt> | Address error detecting method for data storage device |
WO1993009495A1 (en) * | 1991-11-05 | 1993-05-13 | Australian Tech Support Pty. Ltd. | Computer memory protection |
US6122758A (en) * | 1997-05-13 | 2000-09-19 | Micron Electronics, Inc. | System for mapping environmental resources to memory for program access |
US20040236878A1 (en) * | 2003-05-20 | 2004-11-25 | Wei-Han Chang | Method of write-protecting a MAC address |
TW200743022A (en) * | 2006-05-02 | 2007-11-16 | Inventec Corp | Media access control address error detection method in a network card |
CN101090344A (en) * | 2006-06-13 | 2007-12-19 | 英业达股份有限公司 | Detection Method of Media Access Control Address Error on Network Card |
US8086585B1 (en) * | 2008-09-30 | 2011-12-27 | Emc Corporation | Access control to block storage devices for a shared disk based file system |
US20130185479A1 (en) * | 2012-01-13 | 2013-07-18 | Phison Electronics Corp. | Data protecting method, memory controller and memory storage apparatus |
Also Published As
Publication number | Publication date |
---|---|
CN112148201B (en) | 2024-12-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110032405B (en) | System boot code memory management method, memory device and electronic system using the same | |
JP5636034B2 (en) | Mediation of mount times for data usage | |
US20180267920A1 (en) | Expansion component | |
KR101395778B1 (en) | Memory card and memory system including the same and operating method thereof | |
TWI423026B (en) | Data writing method, memory controller and memory storage apparatus | |
US20040068644A1 (en) | Booting from non-linear memory | |
TWI693518B (en) | Data storage devices and methods for firmware failure prevention | |
US9372741B2 (en) | Data storage device and operating method thereof | |
US10977050B2 (en) | Method for managing system boot code memory, memory device and electronic system using the same | |
CN111026325B (en) | Flash memory controller, method for controlling flash memory controller, and related electronic device | |
US11314453B2 (en) | Memory system managing map data based on risk of malware—infection of host, and operating method thereof | |
JP7355876B2 (en) | Program startup method, equipment, and storage medium | |
KR20110078171A (en) | Bootable volatile memory device, memory module and processing system having same, and method of booting processing system using same | |
CN112148201A (en) | Data writing method, device and storage medium | |
CN113032008B (en) | Electronic processing device and memory control method | |
CN113646745A (en) | Disabling software persistence | |
KR100575927B1 (en) | How to boot from mobile terminal | |
US12019880B2 (en) | Flash memory data protection using bad block markers and a flashing tool | |
CN116880905B (en) | A data storage method, device, storage medium and electronic equipment | |
CN113515405B (en) | Address management method and device | |
CN110968441B (en) | Memory card access device and method | |
CN116820849A (en) | Memory SPD read and write test methods, devices, electronic equipment and storage media | |
CN118277352A (en) | BIOS log information reading and writing method, computer equipment and computer storage medium | |
CN119473412A (en) | Control systems, motherboards and electronic equipment | |
CN106033321A (en) | Response reading method and data transmission system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant after: Loongson Zhongke Technology Co.,Ltd. Address before: 100095 Building 2, Longxin Industrial Park, Zhongguancun environmental protection technology demonstration park, Haidian District, Beijing Applicant before: LOONGSON TECHNOLOGY Corp.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |