Disclosure of Invention
Aiming at the technical problems, the invention adopts the following technical scheme:
A hardware information access system includes a client and its corresponding driver, a display management component, a hardware simulation program, a processor, and a memory storing a computer program that when executed by the processor, performs the steps of:
s101, when the driver program sends an access request to the display management component to acquire target hardware information, a preset hijack means is adopted to hijack the access request to the hardware simulation program;
s102, when the access request meets a preset condition, returning simulated hardware information corresponding to the target hardware information to the client by the hardware simulation program;
s103, when the access request does not meet a preset condition, the hardware simulation program sends the access request to the display management component;
s104, returning the target hardware information to the hardware simulation program by the display management component;
and S105, returning the target hardware information to the client by the hardware simulation program.
Compared with the prior art, the hardware information access system provided by the invention has obvious beneficial effects, can achieve quite technical progress and practicality, has wide industrial utilization value, and has at least the following beneficial effects:
The invention provides a hardware information access system, which comprises a client, a corresponding driver, a display management component, a hardware simulation program, a processor and a memory storing the computer program, wherein when the computer program is executed by the processor, the step S101 is realized, when the driver sends an access request to the display management component to acquire target hardware information, a preset hijack means is adopted to hijack the access request to the hardware simulation program, when the access request meets preset conditions, the hardware simulation program returns simulation hardware information corresponding to the target hardware information to the client, when the access request does not meet the preset conditions, the hardware simulation program sends the access request to the display management component, S104, the display management component returns the target hardware information to the hardware simulation program, S105, and the hardware simulation program returns the target hardware information to the client.
It can be known that, additionally, a hardware simulation program is constructed, when the driver sends an access request to the display management component to acquire target hardware information, the access request is hijacked to the hardware simulation program, the hardware simulation program returns the simulation hardware information corresponding to the target hardware information to the client, the situation that the display management component cannot acquire the target hardware information due to the fact that no entity hardware equipment exists in the system is avoided, and therefore the abnormal condition of the driver is caused is avoided, the running stability of the driver is ensured, the driver is not required to be changed by the hardware simulation program, after the entity hardware equipment is acquired, the hardware information of the entity hardware equipment can be directly acquired by the driver, and the verification efficiency of the driver is improved.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
The embodiment provides a hardware information access system, which comprises a client, a corresponding driver, a display management component, a hardware simulation program, a processor and a memory storing a computer program, referring to fig. 1, a flow diagram of the hardware information access system when the computer program is executed by the processor is provided, and when the computer program is executed by the processor, the following steps are implemented:
s101, when the driver program sends an access request to the display management component to acquire target hardware information, a preset hijack means is adopted to hijack the access request to the hardware simulation program;
S102, when the access request meets a preset condition, returning simulated hardware information corresponding to the target hardware information to the client by the hardware simulation program;
s103, when the access request does not meet a preset condition, the hardware simulation program sends the access request to the display management component;
s104, returning the target hardware information to the hardware simulation program by the display management component;
and S105, returning the target hardware information to the client by the hardware simulation program.
The hardware information access system may include at least one client, where the processing flows of the drivers corresponding to the respective clients are the same, and in this embodiment, a single client is described as an example.
In this embodiment, the display management component may refer to an X Server component in a Linux system, and may be used to manage graphics display, and is mainly responsible for processing graphics output and receiving events from an input device, and transmitting the events to a corresponding application program and so on.
The hardware simulation program may include a plurality of simulation hardware information, where the simulation hardware information and the target hardware information may both refer to hardware information corresponding to the physical hardware device of the GPU chip, and the target hardware information may refer to hardware information required by the access request, and the simulation hardware information may refer to hardware information included in the hardware simulation program.
Specifically, the driver may send a plurality of access requests to the display management component to obtain the target hardware information corresponding to each access request, and similarly, the processing flows corresponding to each access request are the same, and in this embodiment, a single access request is described as an example.
When the access request does not meet the preset condition, the target hardware information corresponding to the access request is not possibly the hardware information which is important to care, or the target hardware information can be acquired from the display management component, and at the moment, the hardware simulation program accesses the display management component to acquire the target hardware information, and then the target hardware information is returned to the client.
In a specific implementation manner, the preset condition is that the target hardware information has corresponding simulation hardware information in the hardware simulation program.
Because only part of hardware information is possibly required to be focused in the verification process of the driver, when the hardware simulation program is written, the simulation hardware information corresponding to the part of hardware information required to be focused can be only contained, when the target hardware information required by the access request is consistent with the simulation hardware information, the simulation hardware information corresponding to the target hardware information is directly returned to the client by the hardware simulation program, the driver does not need to access the display management assembly, and therefore the situation that the display management assembly cannot acquire the target hardware information due to the fact that no entity hardware equipment exists is avoided, and the driver is abnormal is further caused, and the running stability of the driver is ensured.
In a specific embodiment, the system further includes a GPU kernel, and step S104 further includes the steps of:
S1041, when the display management component contains the target hardware information, returning the target hardware information to the hardware simulation program by the display management component;
S1042, when the display management component does not contain the target hardware information, the GPU kernel is accessed by the display management component to acquire the target hardware information, and the target hardware information is returned to the hardware simulator.
The GPU kernel also contains part of hardware information, and when the display management component does not contain the target hardware information, the display management component accesses the GPU kernel to acquire the target hardware information.
In a specific embodiment, the computer program when executed by a processor further performs the steps of:
S201, when the display management component returns the target hardware information to the hardware simulation program, an abnormal situation occurs, and the target hardware information is updated to the hardware simulation program as simulation hardware information.
In the complex scenario of driver verification, there may be hardware information that needs to be focused on that is not present in the hardware simulation program as simulated hardware information, in such a case, when the display management component returns the target hardware information to the hardware simulation program, an abnormal condition occurs, and according to the abnormal condition, the target hardware information is updated to the hardware simulation program as simulated hardware information.
In a specific embodiment, the display management component includes a number of reference hardware information;
The hardware simulation program comprises simulation hardware information corresponding to all the reference hardware information respectively.
The reference hardware information may refer to hardware information that can be acquired by the display management component, the hardware simulation program includes simulation hardware information corresponding to all the reference hardware information, which may indicate that the simulation hardware information included in the hardware simulation program covers all the reference hardware information, and further includes hardware information that cannot be acquired by the display management component.
In a specific embodiment, when the system further includes a GPU chip, the display management component includes a plurality of pieces of reference hardware information corresponding to the GPU chip;
when the computer program is executed by a processor, the following steps are implemented:
s301, when the driver program sends an access request to the display management component to acquire target hardware information, the display management component returns reference hardware information corresponding to the target hardware information to the client.
Wherein, when the system further comprises a GPU chip, the entity hardware equipment containing the GPU chip in the system is represented, in such a case, a hardware simulation program is not needed, when the driver sends an access request to the display management component to acquire the target hardware information, the reference hardware information corresponding to the target hardware information is directly returned to the client by the display management component, and therefore, the display management component can display the target hardware information, in this embodiment, after the entity hardware device of the GPU chip is obtained, only the use of the hardware simulation program is turned off, and the driver can be directly used to access the display management component to obtain the reference hardware information of the entity hardware device, so that the driver is not required to be modified, the convenience of applying the driver to the entity hardware device is improved, and the efficiency of verifying the driver is also improved.
In a specific embodiment, the hijacking means at least comprise function pointer tampering and code injection.
The hijacking means can also comprise DLL hijacking, buffer overflow hijacking and the like, and an implementer can select proper hijacking means according to actual conditions.
It can be seen that, in this embodiment, a hardware simulation program is additionally built, when the driver sends an access request to the display management component to obtain the target hardware information, the access request is hijacked to the hardware simulation program, and the hardware simulation program returns the simulation hardware information corresponding to the target hardware information to the client, so that the situation that the display management component cannot obtain the target hardware information due to the fact that no entity hardware device exists in the system is avoided, and therefore, the abnormal condition of the driver is caused, the running stability of the driver is ensured, and the driver does not need to be changed by using the hardware simulation program, after the entity hardware device is obtained, the hardware information of the entity hardware device can be directly obtained by using the driver, and the verification efficiency of the driver is improved.
While certain specific embodiments of the invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the invention. Those skilled in the art will also appreciate that many modifications may be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.