Hardware configuration method, electronic equipment and storage medium

Through the hardware universal interface between the first processor and the second processor, the network card register is configured to achieve a more secure network card driver, which solves the problem of low configuration security in the prior art and improves system performance and efficiency .

CN119003394APending Publication Date: 2024-11-22PHYTIUM TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411139132.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

When configuring the Gigabit Media Access Controller (GMAC) interface, existing network card drivers need to specify the actual meaning and offset of the network card register-related bits, resulting in low configuration security.

Method used

Through the hardware universal interface between the first processor and the second processor, the second processor sends hardware configuration commands to the first processor, and the first processor configures preset registers according to these commands, so that the target hardware device is based on preset The target configuration value of the register realizes the target configuration function, avoiding attention to the meaning and offset of the relevant bits in the register.

Benefits of technology

Improves the configuration security of network card registers, reduces the share of the second processor, and improves system performance and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119003394A_ABST
    Figure CN119003394A_ABST
Patent Text Reader

Abstract

The invention provides a hardware configuration method, electronic equipment and a storage medium, and relates to the technical field of computers. The method is applied to a first processor, the first processor, a second processor and target equipment are in communication connection through a first bus, and the method comprises the following steps: receiving a hardware configuration command sent by the second processor through a hardware universal interface; the preset register is configured according to the hardware configuration command, so that the target hardware equipment realizes the target configuration function based on the target configuration value of the preset register, and the first processor can quickly configure the target hardware equipment according to the hardware configuration command issued by the second processor; in this way, the meaning and offset of related bits in the preset register do not need to be concerned in the configuration process, the exposure risk of specific configuration and functions of the preset register can be reduced, the configuration safety can be improved, the occupancy rate of the second processor can be reduced, and the performance and efficiency of the second processor can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a hardware configuration method, an electronic device and a storage medium. Background Art

[0002] The network card driver is a driver for the hardware device used to manage the network card (NIC) in the computer system. The function of the network card driver is to manage the hardware interface of the network device, including controlling the sending and receiving of data, setting network parameters, and processing the encapsulation and unpacking of data packets.

[0003] In the prior art, when configuring a network port driver for a network port device connected via a Gigabit Media Access Controller (GMAC) interface, it is often necessary to specify in detail the actual meaning and offset of the relevant bits of the network card register in order to correctly read and write the corresponding register.

[0004] It can be seen that the configuration method of the existing network card driver will completely expose the specific configuration and functions of the network card registers, and there is a problem of low configuration security. Summary of the invention

[0005] The purpose of the present application is to provide a hardware configuration method, an electronic device and a storage medium to address the deficiencies in the above-mentioned prior art, so that a first processor can quickly configure a target hardware device according to a hardware configuration command issued by a second processor, so that there is no need to pay attention to the meaning and offset of relevant bits in a preset register during the configuration process, which can reduce the risk of exposure to the specific configuration and function of the preset register and improve configuration security.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, the present invention provides a hardware configuration method, which is applied to a first processor, wherein the first processor, a second processor, and a target device are communicatively connected via a first bus, and the method comprises:

[0008] Receiving a hardware configuration command sent by the second processor through a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of the target hardware device;

[0009] The preset register is configured according to the hardware configuration command, so that the target hardware device implements the target configuration function based on the target configuration value of the preset register.

[0010] In an optional implementation manner, the first processor and the second processor are respectively connected to a shared memory for communication, and the receiving of a hardware configuration command sent by the second processor through a hardware universal interface includes:

[0011] Obtaining the hardware configuration command from the shared memory;

[0012] The hardware configuration command is written into the shared memory by the second processor through a hardware universal interface.

[0013] In an optional embodiment, the method further comprises:

[0014] The configuration status identifier is written into the shared memory, so that the second processor can obtain the hardware configuration result corresponding to the hardware configuration request through the configuration status identifier in the shared memory.

[0015] In an optional implementation manner, the receiving a hardware configuration command sent by the second processor through a hardware universal interface includes:

[0016] Polling and monitoring whether there is a new hardware configuration command in the shared memory;

[0017] If it exists, the new hardware configuration command is obtained from the shared memory.

[0018] In an optional implementation manner, after obtaining the hardware configuration command from the shared memory, the method further includes:

[0019] Obtain and record the index corresponding to the tail pointer register in the shared memory;

[0020] After the second processor writes a hardware configuration command to the shared memory through the hardware universal interface, the second processor updates the index corresponding to the tail pointer register in the shared memory.

[0021] In an optional implementation manner, the polling and monitoring whether there is a new hardware configuration command in the shared memory includes:

[0022] Polling to obtain the current index corresponding to the tail pointer register in the shared memory;

[0023] If it is determined that the current index corresponding to the tail pointer register is different from the historical index recorded by the first processor, it is determined that there is a new hardware configuration command in the shared memory.

[0024] In an optional implementation, the hardware configuration command is specifically copied by the second processor to the shared memory based on a memory copy technology by a preset structure, wherein the member variables of the preset structure include: a main command word and a sub-command word, and each of the hardware configuration commands can be stored in a preset queue as a queue element.

[0025] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0026] In an optional implementation, the first processor is an RV processor, and the target hardware device is a network card device accessed through a Gigabit Media Access Controller (GMAC) interface.

[0027] In a second aspect, the present invention provides a hardware configuration method, which is applied to a second processor, wherein the second processor, the first processor, and the target device are communicatively connected via a first bus, and the method comprises:

[0028] Obtaining a hardware configuration request for a target hardware device, the hardware configuration request comprising: a hardware configuration command;

[0029] The hardware configuration command is sent to the first processor through the hardware universal interface, so that the first processor configures the preset register according to the hardware configuration command, wherein the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

[0030] In an optional implementation manner, the second processor and the first processor are respectively connected to a shared memory for communication, and sending the hardware configuration command to the first processor through the hardware universal interface so that the first processor configures the preset register according to the hardware configuration command includes:

[0031] The hardware configuration command is written into the shared memory through the hardware universal interface, so that the first processor obtains the hardware configuration command from the shared memory and configures the preset register according to the hardware configuration command.

[0032] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0033] In a third aspect, the present invention provides a hardware configuration device, applied to a first processor, wherein the first processor, a second processor, and a target device are communicatively connected via a first bus, and the hardware configuration device comprises:

[0034] A receiving module, configured to receive a hardware configuration command sent by the second processor through a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of the target hardware device;

[0035] The configuration module is used to configure the preset register according to the hardware configuration command, so that the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

[0036] In an optional implementation manner, the first processor and the second processor are respectively connected to a shared memory for communication, and the receiving module is specifically used to obtain the hardware configuration command from the shared memory;

[0037] The hardware configuration command is written into the shared memory by the second processor through a hardware universal interface.

[0038] In an optional implementation, the hardware configuration device further includes: a writing module, configured to write a configuration status identifier into the shared memory, so that the second processor can obtain a hardware configuration result corresponding to the hardware configuration request through the configuration status identifier in the shared memory.

[0039] In an optional implementation manner, the receiving module is specifically used to poll and monitor whether there is a new hardware configuration command in the shared memory;

[0040] If it exists, the new hardware configuration command is obtained from the shared memory.

[0041] In an optional implementation manner, the receiving module is further used to obtain and record the index corresponding to the tail pointer register in the shared memory;

[0042] After the second processor writes a hardware configuration command to the shared memory through the hardware universal interface, the second processor updates the index corresponding to the tail pointer register in the shared memory.

[0043] In an optional implementation manner, the receiving module is specifically used to poll and obtain a current index corresponding to a tail pointer register in the shared memory;

[0044] If it is determined that the current index corresponding to the tail pointer register is different from the historical index recorded by the first processor, it is determined that there is a new hardware configuration command in the shared memory.

[0045] In an optional implementation, the hardware configuration command is specifically copied by the second processor to the shared memory based on a memory copy technology by a preset structure, wherein the member variables of the preset structure include: a main command word and a sub-command word, and each of the hardware configuration commands can be stored in a preset queue as a queue element.

[0046] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0047] In an optional implementation, the first processor is an RV processor, and the target hardware device is a network card device accessed through a Gigabit Media Access Controller (GMAC) interface.

[0048] In a second aspect, the present invention provides a hardware configuration device, applied to a second processor, wherein the second processor, the first processor, and the target device are communicatively connected via a first bus, and the hardware configuration device comprises:

[0049] An acquisition module is used to acquire a hardware configuration request for a target hardware device, wherein the hardware configuration request includes: a hardware configuration command;

[0050] The sending module is used to send the hardware configuration command to the first processor through the hardware universal interface, so that the first processor configures the preset register according to the hardware configuration command, wherein the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

[0051] In an optional embodiment, the second processor and the first processor are respectively connected to a shared memory for communication, and the sending module is specifically used to write the hardware configuration command into the shared memory through the hardware universal interface, so that the first processor obtains the hardware configuration command from the shared memory and configures the preset register according to the hardware configuration command.

[0052] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0053] In a fifth aspect, the present invention provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the storage medium communicate via a second bus, and the processor executes the machine-readable instructions to perform the steps of the hardware configuration method as described in any of the foregoing implementations.

[0054] In a sixth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the hardware configuration method as described in any of the aforementioned implementation modes are executed.

[0055] The beneficial effects of this application are:

[0056] In the hardware configuration method, electronic device and storage medium provided in the embodiment of the present application, the method is applied to a first processor, and the first processor, the second processor, and the target device are communicatively connected via a first bus. The method includes: receiving a hardware configuration command sent by the second processor via a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of the target hardware device; configuring a preset register according to the hardware configuration command so that the target hardware device implements a target configuration function based on a target configuration value of the preset register. By applying the embodiment of the present application, the first processor can quickly configure the target hardware device according to the hardware configuration command issued by the second processor, thereby achieving the goal of not having to pay attention to the meaning and offset of relevant bits in the preset register during the configuration process, which can not only reduce the risk of exposure of the specific configuration and function of the preset register and improve configuration security, but also reduce the occupancy rate of the second processor and improve the performance and efficiency of the second processor. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A schematic diagram of a hardware configuration system provided in an embodiment of the present application;

[0059] Figure 2 A flowchart of a hardware configuration method provided in an embodiment of the present application;

[0060] Figure 3 A flowchart of another hardware configuration method provided in an embodiment of the present application;

[0061] Figure 4 A flowchart of another hardware configuration method provided in an embodiment of the present application;

[0062] Figure 5 A flowchart of another hardware configuration method provided in an embodiment of the present application;

[0063] Figure 6 A schematic diagram of a hardware configuration principle provided in an embodiment of the present application;

[0064] Figure 7 A flowchart of another hardware configuration method provided in an embodiment of the present application;

[0065] Figure 8 A schematic diagram of functional modules of a hardware configuration device provided in an embodiment of the present application;

[0066] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0068] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0069] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0070] In the prior art, when configuring a network port driver for a network port device connected via a Gigabit Media Access Controller (GMAC) interface, it is often necessary to specify in detail the actual meaning and offset of the relevant bits of the network card register in order to correctly read and write the corresponding register.

[0071] In view of this, the present application implements a hardware configuration method, in which the first processor can quickly configure the target hardware device according to the hardware configuration command issued by the second processor, so that there is no need to pay attention to the meaning and offset of the relevant bits in the preset register during the configuration process. This can not only reduce the risk of exposure to the specific configuration and function of the preset register and improve configuration security, but also reduce the occupancy of the second processor and improve the performance and efficiency of the system.

[0072] Figure 1 Schematic diagram of a hardware configuration system provided in an embodiment of the present application. The hardware configuration system includes a first processor 10, a second processor 20, a target hardware device 30 and a shared memory 60. Optionally, as Figure 1 As shown, the first processor 10 , the second processor 20 and the target hardware device 30 are communicatively connected via the first bus 40 , and the first processor 10 and the second processor 20 are communicatively connected to the shared memory 60 respectively, and the first processor 10 and the second processor 20 can access the shared memory 60 .

[0073] In some embodiments, the hardware configuration system may further include a double data rate synchronous dynamic random access memory (DDR, Double Data Rate SDRAM) 50. The first processor 10 and the second processor 20 may access the DDR via the first bus 40. The DDR may store relevant programs in the hardware configuration process.

[0074] Optionally, in some embodiments, according to actual application scenarios, each device in the above hardware configuration system may exchange data based on direct memory access (DMA) technology, which is not limited here.

[0075] The first processor 10 can be used to process data transmission and control of the target hardware device, and has the function of configuring preset registers in the target hardware device according to the hardware configuration command. Optionally, the first processor can be an RV (RISC-V) core, which is recorded as an RV processor in this case.

[0076] Optionally, the second processor as the main processor may be a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a microcontroller unit (MCU), a field-programmable gate array (FPGA), etc., without limitation herein.

[0077] Optionally, the target hardware device 30 can be a network interface card (NIC) device, an audio device, a secure digital device, a first device that communicates based on an integrated circuit bus, a second device that communicates based on an integrated circuit built-in audio bus, or a third device that communicates based on a serial peripheral interface.

[0078] The secure digital device may include a storage device using the SD (Secure Digital) standard; a first device communicating based on an integrated circuit bus, that is, a first device communicating based on an integrated circuit bus (Inter-Integrated Circuit Bus, I 2 C) Devices for communication, for example, may include: I 2 C interface sensors, display drivers, microcontrollers MCU, audio codecs, etc.

[0079] A second device that communicates based on an integrated circuit built-in audio bus, that is, based on an integrated circuit built-in audio bus (Inter-IC Sound, I 2 S) for communication, for example, may include: audio interface chip, audio amplifier, high definition television (HDTV), set-top box (STB), etc.; a third device based on serial peripheral interface for communication, that is, a device based on serial peripheral interface (SPI) for communication, for example, may include: SPI interface sensor, EEPROM, Flash memory, etc.

[0080] It should be noted that the types of target hardware devices are not limited to the above examples. Depending on the actual application scenarios, other types of hardware devices may also be included, such as high-definition audio (HDA), low-speed devices (LSD), integrated circuit built-in audio display port (DisplayPort I2S, DPI2S) devices, hard disk drives, etc.

[0081] In order to better understand the present application, the following embodiments are described by taking the first processor as an RV processor, the second processor as a central processing unit (CPU), and the target hardware device as a network card device as an example. Wherein, when the target hardware device is a network card device, the network card device can optionally access the first bus based on a Gigabit Media Access Controller (GMAC) interface.

[0082] Figure 2 A flowchart of a hardware configuration method provided in an embodiment of the present application is provided. The hardware configuration method can be applied to a first processor in the above hardware configuration system, wherein the first processor, the second processor, and the target device are connected to each other through a first bus. Figure 2 As shown, the method includes:

[0083] Step 101: Receive a hardware configuration command sent by a second processor through a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of a target hardware device.

[0084] Optionally, the hardware configuration request of the target hardware device can be generated by the user acting on the second processor, or generated by the second processor when the target hardware device first accesses the target hardware configuration system. This is not limited here and may vary according to actual application scenarios.

[0085] The second processor has a hardware universal interface. After obtaining the hardware configuration request of the target hardware device, the second processor can generate a corresponding hardware configuration command and send it to the first processor dedicated to hardware configuration.

[0086] In some embodiments, the hardware configuration command may carry an identifier of a preset register to be configured and a target configuration value corresponding to the preset register. It is understandable that different target configuration values ​​may be configured for the preset register when used to implement different configuration functions.

[0087] Step 102: configure the preset register according to the hardware configuration command, so that the target hardware device implements the target configuration function based on the target configuration value of the preset register.

[0088] The hardware configuration command may be used to configure a preset register in a target hardware device. By configuring a value corresponding to the preset register as a target configuration value according to the hardware configuration command, the target hardware device may support a target configuration function.

[0089] In some embodiments, when performing configuration, the first processor may send the hardware configuration command to a controller in the target hardware device, and the controller in the target hardware device may configure the preset register in the target hardware device according to the hardware configuration command. Of course, the specific configuration method is not limited to this and may vary according to the actual application scenario.

[0090] Optionally, the target hardware device is a network card device as an example for illustration, and the target configuration function implemented by the target hardware device may include: register reset, register configuration, register status acquisition, etc., which are not limited here. It should be noted that different preset registers will correspond to different target hardware devices, for example, the preset register in the network card device may be a MAC register.

[0091] It can be seen that by introducing the first processor to perform independent operations on the hardware configuration of the target hardware device, not only can the coupling of the software and hardware configurations in the device driver be reduced and the hardware testing efficiency be improved, but also the occupancy rate of the second processor can be reduced, that is, there is no need to configure the hardware device of the target hardware device through the second processor, which can improve the performance and efficiency of the second processor.

[0092] It should be noted that the software configuration operation of the target hardware device can be completed before the hardware configuration operation, or the software configuration operation can be performed after the hardware configuration operation is completed, which is not limited here. The software configuration operation of the target hardware device may include but is not limited to: setting the working mode of the controller in the target hardware device (for example, full-duplex / half-duplex mode), performing data packet sending and receiving management, interrupt processing, etc., which is not limited here and can be flexibly set according to the actual application scenario.

[0093] In summary, an embodiment of the present application provides a hardware configuration method, which is applied to a first processor, and the first processor, the second processor, and the target device are communicatively connected via a first bus. The method includes: receiving a hardware configuration command sent by the second processor via a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of the target hardware device; configuring a preset register according to the hardware configuration command, so that the target hardware device implements a target configuration function based on a target configuration value of the preset register. By applying the embodiment of the present application, the first processor can quickly configure the target hardware device according to the hardware configuration command issued by the second processor, thereby achieving the goal of not having to pay attention to the meaning and offset of relevant bits in the preset register during the configuration process, which can not only reduce the risk of exposure to the specific configuration and function of the preset register and improve configuration security, but also reduce the occupancy rate of the second processor and improve the performance and efficiency of the second processor.

[0094] In addition, it should be noted that, since the present application introduces the first processor to perform separate operations on the hardware configuration of the target hardware device, it can also reduce the coupling of software and hardware configurations in the device driver and improve hardware testing efficiency.

[0095] In an optional embodiment, the first processor and the second processor are respectively connected to a shared memory for communication, and the above-mentioned receiving the hardware configuration command sent by the second processor through the hardware universal interface includes: obtaining the hardware configuration command from the shared memory; wherein the hardware configuration command is written into the shared memory by the second processor through the hardware universal interface.

[0096] The second processor can write the hardware configuration command into the shared memory through the hardware universal interface, and the first processor obtains the hardware configuration command through the shared memory. That is, the first processor and the second processor share data through the shared memory.

[0097] It is understandable that by writing the hardware configuration command into the shared memory, the first processor can avoid making a system call to the second processor, or performing kernel transfer, which can improve the transmission efficiency of the hardware configuration command and thus improve the hardware configuration efficiency of the target hardware device.

[0098] Of course, it should be noted that the second processor can also transmit the hardware configuration command to the first processor through a message passing mechanism, direct memory access (DMA) technology, etc., which is not limited here and can be flexibly set according to the actual application scenario.

[0099] Figure 3 A flowchart of another hardware configuration method provided in an embodiment of the present application. In an optional implementation, as Figure 3 As shown, the above method also includes:

[0100] Step 201: Write a configuration status identifier into a shared memory, so that a second processor can obtain a hardware configuration result corresponding to a hardware configuration request through the configuration status identifier in the shared memory.

[0101] After the first processor configures the preset register in the target hardware device according to the hardware configuration command, it can generate a configuration status identifier according to the configuration result of the preset register and write the configuration status identifier into the shared memory.

[0102] Optionally, the configuration status flag may indicate whether the configuration of the preset register is successful.

[0103] It is understandable that the second processor can obtain the configuration status identifier corresponding to the hardware configuration command from the shared memory, and then know the hardware configuration result of the target hardware device according to the obtained configuration status identifier.

[0104] By applying the embodiment of the present application, by writing the configuration status identifier into the shared memory, the second processor can know the hardware configuration result of the target hardware device according to the configuration status identifier so as to perform the next hardware configuration operation, which can improve the applicability of the hardware configuration method.

[0105] Figure 4 A flowchart of another hardware configuration method provided in an embodiment of the present application. In an optional implementation, as Figure 4 As shown, the above-mentioned receiving the hardware configuration command sent by the second processor through the hardware universal interface includes:

[0106] Step 301: poll and monitor whether there is a new hardware configuration command in the shared memory.

[0107] Step 302: If it exists, obtain the new hardware configuration command from the shared memory.

[0108] Optionally, the first processor may monitor in a polling monitoring manner whether there is a new hardware configuration command in the shared memory, and if so, configure a preset register in the target hardware device based on the new hardware configuration command.

[0109] In some embodiments, the polling time may be set to 10 seconds, 30 seconds, 1 minute, etc., which is not limited here and can be flexibly set according to actual application scenarios.

[0110] Optionally, when monitoring whether there is a new hardware configuration command in the shared memory, it can be determined according to the writing time or storage address of the hardware configuration command in the shared memory.

[0111] For example, each time the second processor writes a hardware configuration command to the shared memory through the hardware universal interface, the write time can be synchronized and written into the shared memory; for the first processor, each time it obtains a hardware configuration command from the shared memory, it can also obtain its corresponding write time, and compare the write time with the historical write time corresponding to the historical hardware configuration command obtained by it to see if they are the same. If they are different, it is considered that there is a new hardware configuration command in the shared memory, otherwise, it is considered that there is no new hardware configuration command in the shared memory.

[0112] For another example, each time the second processor writes a hardware configuration command to the shared memory through the hardware universal interface, the first processor can also obtain the corresponding storage address each time it obtains the hardware configuration command from the shared memory, and compare the storage time with the historical storage time corresponding to the historical hardware configuration command obtained by it to see if they are the same. If they are different, it is considered that there is a new hardware configuration command in the shared memory; otherwise, it is considered that there is no new hardware configuration command in the shared memory.

[0113] Of course, the method of monitoring whether there is a new hardware configuration command in the shared memory is not limited to the above example, and can be flexibly set according to actual application scenarios.

[0114] By applying the embodiments of the present application, when a new hardware configuration command arrives in the shared memory, the first processor can promptly obtain the hardware configuration command and perform related hardware configuration operations according to the above method, thereby improving the hardware configuration efficiency for the target hardware device.

[0115] In an optional embodiment, after obtaining the hardware configuration command from the shared memory, the above method also includes: obtaining and recording the index corresponding to the tail pointer register in the shared memory; wherein, after the second processor writes the hardware configuration command to the shared memory through the hardware universal interface, it updates the index corresponding to the tail pointer register in the shared memory.

[0116] Among them, the index corresponding to the tail pointer register can indicate the current valid storage address in the shared memory.

[0117] For the second processor, after writing the hardware configuration command to the shared memory through the hardware universal interface, it can update the index corresponding to the tail pointer register in the shared memory, that is, it can update the current valid storage address indicated by the tail pointer register.

[0118] For the first processor, after obtaining the hardware configuration command from the shared memory, it can also synchronously record the index corresponding to the tail pointer register in the shared memory, so that it can subsequently compare the recorded index with the current index corresponding to the tail pointer register in the shared memory, and through comparison, determine whether there is a new hardware configuration command in the shared memory.

[0119] Figure 5 A flowchart of another hardware configuration method provided in an embodiment of the present application. In an optional implementation, as Figure 5 As shown, the above polling monitors whether there are new hardware configuration commands in the shared memory, including:

[0120] Step 401: poll to obtain the current index corresponding to the tail pointer register in the shared memory.

[0121] Step 402: If it is determined that the current index corresponding to the tail pointer register is different from the index recorded by the first processor, it is determined that there is a new hardware configuration command in the shared memory.

[0122] Based on the above description, it can be understood that the writing of a new hardware configuration command will cause the current index corresponding to the tail pointer register in the shared memory to be updated.

[0123] Optionally, during the polling process, the first processor may poll to obtain the current index corresponding to the tail pointer register in the shared memory. If the index recorded by the first processor is the same as the current index corresponding to the tail pointer register in the shared memory, it is determined that there is no new hardware configuration command in the shared memory; otherwise, it is determined that there is a new hardware configuration command in the shared memory.

[0124] In summary, by introducing the index corresponding to the tail pointer register in the shared memory, it is possible to quickly determine whether there is a new hardware configuration command in the shared memory, thereby improving the hardware configuration efficiency.

[0125] In an optional implementation, the hardware configuration command is specifically copied by the second processor to the shared memory based on the memory copy technology, wherein the member variables of the preset structure include: a main command word and a sub-command word, and each hardware configuration command can be stored as a queue element in the preset queue.

[0126] Optionally, the preset queue may include a preset number of queue elements, wherein the preset number may be 50, 64, 100, etc., which is not limited here and can be flexibly set according to actual application scenarios.

[0127] Among them, for the second processor, it can write one or more hardware configuration commands to the write shared memory through the hardware universal interface. Optionally, when writing multiple hardware configuration commands, the multiple hardware configuration commands can be stored in a preset queue in sequence according to the writing time. In some embodiments, if the preset queue is full, the preset queue can be deleted and then written.

[0128] It should be noted that the storage method of the hardware configuration commands in the shared memory is not limited to this and can be flexibly set according to actual application scenarios.

[0129] Optionally, the representation of the preset structure may be as follows:

[0130]

[0131] Figure 6 A schematic diagram of a hardware configuration principle provided in an embodiment of the present application. Figure 6 As shown, the above-mentioned related configuration process is further described. Among them, the second processor can copy the preset structure phytmac_msg_info to the shared memory based on the memory copy technology (for example, memcpy copy).

[0132] Optionally, refer to Figure 6As shown, the shared memory can be divided into multiple fixed-size spaces for storing a preset structure phytmac_msg_info to form a TX queue. Optionally, the size of the TX queue can be 64, and each queue element is used to store a phytmac_msg_info structure.

[0133] It should be noted that, when copying, refer to step a, the second processor can assign the hardware configuration command to the preset structure phytmac_msg_info, and then write it into the TX queue in the shared memory (sharememory) through memcpy memory copy, thereby completing the issuance of a hardware configuration command, refer to step b, and update the index currently pointed to by the tail pointer register (ie, TX_TAIL_REG).

[0134] Optionally, the first processor can poll and monitor the tail pointer register (i.e., TX_TAIL_REG) of the shared memory to determine whether a new command has arrived. When the current index corresponding to the tail pointer register (i.e., TX_TAIL_REG) is inconsistent with the historical index saved in the first processor, the first processor determines that there is a new hardware configuration command in the shared memory.

[0135] When the first processor determines that there is a new hardware configuration command in the shared memory, referring to step c, the first processor configures the preset register according to the command word and sub-command word content in the phytmac_msg_info structure of the new hardware configuration command in the shared memory, and writes the returned response data and status parameters into the para

[64] field in the phytmac_msg_info structure.

[0136] Further, after completing the configuration of the preset register, the first processor may set flags (configuration status flag) in the phytmac_msg_info structure to 1 to indicate that the operation is completed.

[0137] It can be understood that for the second processor, it can obtain the returned response data and status parameters from the phytmac_msg_info structure, and check whether the flags bit is set to 1. If it is 1, it is determined that the current hardware configuration operation for the preset register has been completed, and subsequent actions are performed; if it is 0, it is determined that the current hardware configuration operation for the preset register has not been completed, that is, the configuration has failed.

[0138] It should be noted that the relevant processing process of the first processor can be specifically completed by the RV core in the first processor. For the second processor, it can also process the interruption generated when sending and receiving messages.

[0139] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of a preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0140] Among them, taking the target hardware device as a network card device as an example, the main command words corresponding to the network card device can be divided into three categories: register reset, register configuration, and register status acquisition. Among them, each main command word can include multiple sub-command words, each sub-command word is used to implement a sub-function, and each sub-function can meet the hardware configuration requirements in different scenarios.

[0141] It can be understood that based on the main command word, by introducing sub-command words, the main hardware configuration function corresponding to the main command word can be decomposed into multiple sub-functions, and then the sub-functions can be set according to the sub-command words. Through the flexible coordination of sub-functions, the hardware configuration requirements in different scenarios can be met.

[0142] Optionally, in combination with the representation of the above-mentioned preset structure, the main command word and the sub-command word in the hardware configuration command can be assigned to cmd_id and cmd_subid in the phytmac_msg_info structure, respectively. In some embodiments, taking the target hardware device as a network card device as an example, the above-mentioned preset register can be a MAC register. It should be noted that each command word can indicate the value of the bit in the preset register for different configuration functions, that is, the value of the bit in the preset register can be set through each command word, avoiding the problem of poor readability when setting through cumbersome bit sequences, that is, through the definition of command words and sub-command words, the readability of the hardware configuration command can be improved, thereby lowering the usage threshold of configuration personnel and improving the applicability of the hardware configuration method.

[0143] In an optional implementation manner, in some embodiments, the first processor may be an RV processor, and the target hardware device is a network card device accessed through a gigabit media access controller GMAC interface.

[0144] Of course, the target hardware device may also include at least one of the following devices: a network interface card, an audio device, a secure digital device, a first device that communicates based on an integrated circuit bus, a second device that communicates based on an integrated circuit built-in audio bus, and a third device that communicates based on a serial peripheral interface.

[0145] For the description of the target hardware device, please refer to the above related content, which will not be repeated here.

[0146] In summary, the application of the embodiments of the present application can ensure that the driving process of the target hardware device is executed normally, and the hardware configuration commands can be executed sequentially and correctly during the hardware configuration process, and the corresponding returned data and status are correct and accurate. In addition, other operations of the target hardware device are not affected. For example, when the target hardware device is a network card, the normal sending and receiving of network data can be guaranteed, and the adaptability is strong.

[0147] Figure 7 A flowchart of another hardware configuration method provided in an embodiment of the present application. The hardware configuration method can be applied to the second processor in the above hardware configuration system, where the second processor, the first processor, and the target device are connected to each other via a first bus. Figure 7 As shown, the hardware configuration method includes:

[0148] Step 501: Obtain a hardware configuration request for a target hardware device, where the hardware configuration request includes: a hardware configuration command.

[0149] Step 502: Send a hardware configuration command to the first processor through the hardware universal interface, so that the first processor configures the preset register according to the hardware configuration command, wherein the target hardware device can implement the target configuration function based on the target configuration value of the preset register.

[0150] In summary, by applying the embodiments of the present application, by introducing the first processor to perform independent operations on the hardware configuration of the target hardware device, not only can the coupling of the software and hardware configurations in the device driver be reduced and the hardware testing efficiency be improved, but also the occupancy rate of the second processor can be reduced and the performance and efficiency of the second processor can be improved.

[0151] In an optional implementation manner, the second processor and the first processor are respectively connected to a shared memory for communication, and the hardware configuration command is sent to the first processor through the hardware universal interface so that the first processor configures the preset register according to the hardware configuration command, including:

[0152] The hardware configuration command is written into the shared memory through the hardware universal interface, so that the first processor obtains the hardware configuration command from the shared memory and configures the preset register according to the hardware configuration command.

[0153] By applying the embodiments of the present application, by writing the hardware configuration command into the shared memory, the first processor can avoid making a system call to the second processor, or performing kernel transfer, which can improve the transmission efficiency of the hardware configuration command and thus improve the hardware configuration efficiency of the target hardware device.

[0154] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of a preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0155] By applying the embodiments of the present application, based on the main command word, by introducing sub-command words, the main hardware configuration function corresponding to the main command word can be decomposed into multiple sub-functions, and then the sub-functions can be set according to the sub-command words. The flexible coordination of the sub-functions can meet the hardware configuration requirements in different scenarios.

[0156] Figure 8 This is a functional module diagram of a hardware configuration device provided in an embodiment of the present application. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Figure 8 As shown, the hardware configuration device 100 is applied to a first processor, the first processor, the second processor, and the target device are communicatively connected via a first bus, and the hardware configuration device 100 includes:

[0157] The receiving module 110 is used to receive a hardware configuration command sent by the second processor through the hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of a target hardware device;

[0158] The configuration module 120 is used to configure the preset register according to the hardware configuration command, so that the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

[0159] In an optional implementation, the first processor and the second processor are respectively connected to a shared memory for communication, and the receiving module is specifically used to obtain the hardware configuration command from the shared memory;

[0160] The hardware configuration command is written into the shared memory by the second processor through the hardware universal interface.

[0161] In an optional implementation, the hardware configuration device further includes: a writing module, configured to write a configuration status identifier into the shared memory, so that the second processor can obtain a hardware configuration result corresponding to the hardware configuration request through the configuration status identifier in the shared memory.

[0162] In an optional implementation, the receiving module 110 is specifically used to poll and monitor whether there is a new hardware configuration command in the shared memory;

[0163] If it exists, get the new hardware configuration command from the shared memory.

[0164] In an optional implementation, the receiving module 110 is further used to obtain and record the index corresponding to the tail pointer register in the shared memory;

[0165] After the second processor writes the hardware configuration command to the shared memory through the hardware universal interface, the second processor updates the index corresponding to the tail pointer register in the shared memory.

[0166] In an optional implementation, the receiving module 110 is specifically configured to poll and obtain a current index corresponding to a tail pointer register in the shared memory;

[0167] If it is determined that the current index corresponding to the tail pointer register is different from the historical index recorded by the first processor, it is determined that there is a new hardware configuration command in the shared memory.

[0168] In an optional implementation, the hardware configuration command is specifically copied by the second processor to the shared memory based on the memory copy technology, wherein the member variables of the preset structure include: a main command word and a sub-command word, and each hardware configuration command can be stored as a queue element in the preset queue.

[0169] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of a preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0170] In an optional implementation manner, the first processor is an RV processor, and the target hardware device is a network card device accessed through a gigabit media access controller GMAC interface.

[0171] Optionally, the present invention provides a hardware configuration device, which is applied to a second processor, wherein the second processor, the first processor, and the target device are communicatively connected via a first bus, and the hardware configuration device comprises:

[0172] The acquisition module is used to acquire a hardware configuration request for a target hardware device, wherein the hardware configuration request includes: a hardware configuration command;

[0173] The sending module is used to send the hardware configuration command to the first processor through the hardware universal interface, so that the first processor configures the preset register according to the hardware configuration command, wherein the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

[0174] In an optional implementation, the second processor and the first processor are respectively connected to a shared memory for communication, and the sending module is specifically used to write the hardware configuration command into the shared memory through the hardware universal interface, so that the first processor obtains the hardware configuration command from the shared memory and configures the preset register according to the hardware configuration command.

[0175] In an optional implementation, the hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate a target configuration value of a preset register, and the sub-command word and the main command word are in a hierarchical relationship.

[0176] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.

[0177] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0178] Fig. 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device can be integrated into the above-mentioned hardware configuration device. Fig. 9 As shown, the electronic device may include: a processor 210, a storage medium 220 and a bus 230, the storage medium 220 stores machine-readable instructions executable by the processor 210, when the electronic device is running, the processor 210 and the storage medium 220 communicate through the second bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.

[0179] Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method embodiment are executed. The specific implementation method and technical effect are similar and will not be repeated here.

[0180] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0181] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0182] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0183] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.

[0184] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0185] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A hardware configuration method, characterized in that: Applied to a first processor, the first processor, a second processor, and a target hardware device are communicatively connected via a first bus, the method comprising: receiving a hardware configuration command sent by the second processor through a hardware universal interface, wherein the hardware configuration command is obtained by the second processor according to a hardware configuration request of the target hardware device; The preset register is configured according to the hardware configuration command, so that the target hardware device implements the target configuration function based on the target configuration value of the preset register.

2. The method according to claim 1, characterized in that The first processor and the second processor are respectively communicatively connected to a shared memory, and the receiving of a hardware configuration command sent by the second processor through a hardware universal interface includes: Obtaining the hardware configuration command from the shared memory; The hardware configuration command is written into the shared memory by the second processor through a hardware universal interface.

3. The method according to claim 2, characterized in that The method further comprises: The configuration status identifier is written into the shared memory, so that the second processor can obtain the hardware configuration result corresponding to the hardware configuration request through the configuration status identifier in the shared memory.

4. The method according to claim 2, characterized in that The receiving a hardware configuration command sent by the second processor through the hardware universal interface includes: Polling and monitoring whether there is a new hardware configuration command in the shared memory; If so, the new hardware configuration command is obtained from the shared memory.

5. The method according to claim 2, characterized in that After obtaining the hardware configuration command from the shared memory, the method further includes: Obtain and record the index corresponding to the tail pointer register in the shared memory; Wherein, after the second processor writes the hardware configuration command to the shared memory through the hardware universal interface, it updates the index corresponding to the tail pointer register in the shared memory.

6. The method according to claim 4, characterized in that The polling and monitoring of whether there is a new hardware configuration command in the shared memory includes: Polling to obtain the current index corresponding to the tail pointer register in the shared memory; If it is determined that the current index corresponding to the tail pointer register is different from the historical index recorded by the first processor, it is determined that a new hardware configuration command exists in the shared memory.

7. The method according to claim 2, characterized in that The hardware configuration command is specifically copied by the second processor to the shared memory based on the memory copy technology, wherein the member variables of the preset structure include: a main command word and a sub-command word, and each of the hardware configuration commands can be stored in the preset queue as a queue element.

8. The method according to any one of claims 1 to 7, characterized in that The hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate the target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

9. The method according to any one of claims 1 to 7, characterized in that The first processor is an RV processor, and the target hardware device is a network card device accessed through a gigabit media access controller (GMAC) interface.

10. A hardware configuration method, characterized in that: Applied to a second processor, where the second processor, the first processor, and the target hardware device are connected via a first bus, the method comprising: Obtaining a hardware configuration request for a target hardware device, the hardware configuration request including: a hardware configuration command; The hardware configuration command is sent to the first processor through the hardware universal interface, so that the first processor configures the preset register according to the hardware configuration command, wherein the target hardware device can realize the target configuration function based on the target configuration value of the preset register.

11. The method according to claim 10, characterized in that The second processor and the first processor are respectively communicatively connected to a shared memory, and sending the hardware configuration command to the first processor through the hardware universal interface so that the first processor configures the preset register according to the hardware configuration command includes: The hardware configuration command is written into the shared memory through the hardware universal interface, so that the first processor obtains the hardware configuration command from the shared memory and configures the preset register according to the hardware configuration command.

12. The method according to claim 10 or 11, characterized in that The hardware configuration command includes: a main command word and a sub-command word, wherein the main command word and the sub-command word are used to indicate the target configuration value of the preset register, and the sub-command word and the main command word are in a hierarchical relationship.

13. An electronic device, characterized in that: include: A processor, a storage medium, and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate via a second bus, and the processor executes the machine-readable instructions to perform the steps of the hardware configuration method according to any one of claims 1 to 12.

14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the hardware configuration method according to any one of claims 1 to 12 are executed.

Citation Information

Cited By

  • Command control method and peripheral control system

    CN122633609A

  • Command control method and peripheral control system

    CN122633609B