Implementation method and device of drive program, electronic equipment, storage medium and program product
By introducing the separate design of host drivers and slave drivers in the drivers, the problems of strong hardware coupling, difficulty in open source, and high development and maintenance costs are solved, and the isolation of hardware operations and the portability and maintainability of software are achieved.
Patent Information
- Application Number
- CN202411713229.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-18
Smart Images

Figure CN119645505A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of information technology and communication technology, and in particular to a method for implementing a driver, a device for implementing a driver, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] A driver is a key component in a computer operating system that defines how a hardware device interacts with the operating system.
[0003] In the operating system of the related art, the user space program interacts with the hardware device through the kernel space interface. Among them, the kernel space interface calls the driver interface, and the driver directly operates the hardware according to the working principle of the hardware. In the operating system of the related art, the operation process of the hardware device needs to be written into the driver, and the hardware information usually belongs to the company's professional, confidential and sensitive information. Directly exposing the hardware operation details in the open source system not only increases security risks, but also limits the open source and sharing of the code.
[0004] In addition, with the rapid development of hardware technology, the types and models of hardware devices are increasing, and each hardware device has its own specific operation mode and interface. This leads to the need for the driver under the operating system to write specific code for each hardware, which increases the workload of development and maintenance, and also makes cross-hardware platform software development more difficult. Summary of the invention
[0005] The present disclosure provides a technical solution for implementing a driver program.
[0006] According to one aspect of the present disclosure, a method for implementing a driver is provided, wherein the driver includes a host driver and a slave driver, wherein the host driver runs on a host operating system, and the slave driver runs on a slave operating system, and the method includes:
[0007] The host operating system responds to the hardware operation request by sending the hardware operation request to the slave operating system through the host driver;
[0008] The slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver.
[0009] In a possible implementation, the host operating system sends the hardware operation request to the slave operating system through the host driver in response to the hardware operation request, including:
[0010] The host operating system, in response to the hardware operation request, calls a first interface corresponding to the hardware operation request among the interfaces provided by the host driver;
[0011] The hardware operation request is sent to the slave operating system through the first interface.
[0012] In a possible implementation manner, sending the hardware operation request to the slave operating system through the first interface includes:
[0013] The first interface sends the hardware operation request to the slave operating system through an inter-process message.
[0014] In a possible implementation, the first interface sends the hardware operation request to the slave operating system through an inter-process message, including:
[0015] The first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system.
[0016] In a possible implementation, after the first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system, the method further includes:
[0017] The first interface sends an interrupt to the slave operating system;
[0018] The slave operating system reads the hardware operation request from the first shared memory in response to the interrupt.
[0019] In a possible implementation, the slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver, including:
[0020] The slave operating system, in response to the hardware operation request, calls a second interface corresponding to the hardware operation request among the interfaces provided by the slave driver;
[0021] The hardware operation corresponding to the hardware operation request is executed through the second interface.
[0022] In one possible implementation,
[0023] The slave operating system, in response to the hardware operation request, calls a second interface in the interface provided by the slave driver corresponding to the hardware operation request, comprising: the slave operating system, in response to the hardware operation request, calls the second interface in the interface provided by the slave driver corresponding to the hardware operation request according to the identification information of the specified hardware module and the identification information of the specified operation carried in the hardware operation request;
[0024] The executing the hardware operation corresponding to the hardware operation request through the second interface includes: executing the designated operation on the designated hardware module through the second interface.
[0025] In a possible implementation manner, after executing the hardware operation corresponding to the hardware operation request through the second interface, the method further includes:
[0026] The second interface sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message in response to the hardware operation request requiring receipt information.
[0027] In a possible implementation, the second interface sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message in response to the hardware operation request requiring receipt information, including:
[0028] The second interface writes the receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system in response to the hardware operation request requiring receipt information.
[0029] In a possible implementation manner, the driver includes a display driver.
[0030] According to one aspect of the present disclosure, a device for implementing a driver is provided, the driver comprising a host driver and a slave driver, the host driver running on a host operating system, the slave driver running on a slave operating system, the device comprising:
[0031] A first sending module, configured for the host operating system to send the hardware operation request to the slave operating system through the host driver in response to the hardware operation request;
[0032] An execution module is used for the slave operating system to respond to the hardware operation request and execute the hardware operation corresponding to the hardware operation request through the slave driver.
[0033] In a possible implementation manner, the first sending module is used to:
[0034] The host operating system, in response to the hardware operation request, calls a first interface corresponding to the hardware operation request among the interfaces provided by the host driver;
[0035] The hardware operation request is sent to the slave operating system through the first interface.
[0036] In a possible implementation manner, the first sending module is used to:
[0037] The first interface sends the hardware operation request to the slave operating system through an inter-process message.
[0038] In a possible implementation manner, the first sending module is used to:
[0039] The first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system.
[0040] In a possible implementation manner, the device further includes:
[0041] A second sending module, configured for the first interface to send an interrupt to the slave operating system;
[0042] A reading module is used for the slave operating system to read the hardware operation request from the first shared memory in response to the interrupt.
[0043] In a possible implementation, the execution module is used to:
[0044] The slave operating system, in response to the hardware operation request, calls a second interface corresponding to the hardware operation request among the interfaces provided by the slave driver;
[0045] The hardware operation corresponding to the hardware operation request is executed through the second interface.
[0046] In a possible implementation, the execution module is used to:
[0047] The slave operating system responds to the hardware operation request and calls a second interface corresponding to the hardware operation request in the interface provided by the slave driver according to the identification information of the specified hardware module and the identification information of the specified operation carried in the hardware operation request;
[0048] The specified operation is performed on the specified hardware module through the second interface.
[0049] In a possible implementation manner, the device further includes:
[0050] A third sending module is used for the second interface to respond to the hardware operation request requiring receipt information, and to send the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message.
[0051] In a possible implementation manner, the third sending module is used to:
[0052] The second interface writes the receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system in response to the hardware operation request requiring receipt information.
[0053] In a possible implementation manner, the driver includes a display driver.
[0054] According to one aspect of the present disclosure, an electronic device is provided, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.
[0055] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above method is implemented.
[0056] According to one aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.
[0057] In the disclosed embodiment, the driver includes a host driver and a slave driver, the host driver runs on the host operating system, the slave driver runs on the slave operating system, the host operating system responds to the hardware operation request, sends the hardware operation request to the slave operating system through the host driver, the slave operating system responds to the hardware operation request, and performs the hardware operation corresponding to the hardware operation request through the slave driver, thereby the host driver does not need to directly operate the hardware, can shield the hardware difference, and can operate different hardware devices by calling an interface with a specific process, which can solve the problems of strong hardware coupling, difficulty in opening source, high development and maintenance costs, and difficulty in cross-hardware platform development in the related art. The disclosed embodiment isolates the hardware operation on the slave operating system, which can achieve complete isolation of the host operating system / host driver from the hardware operation, improve the portability and maintainability of the software, and protect the security of the hardware information. In addition, this separation design method allows the host driver to provide a unified interface for a variety of hardware devices, while the specific hardware operation is performed by the slave driver according to the actual characteristics of the hardware. This not only simplifies the development and maintenance of the driver, but also improves the flexibility and scalability of the system.
[0058] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
[0059] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.
[0061] Figure 1 A flowchart of a method for implementing a driver program provided by an embodiment of the present disclosure is shown.
[0062] Figure 2 A schematic diagram showing a method for implementing a driver program provided by an embodiment of the present disclosure.
[0063] Figure 3 Another schematic diagram showing a method for implementing a driver program provided by an embodiment of the present disclosure.
[0064] Figure 4 A block diagram of a device for implementing a driver program provided by an embodiment of the present disclosure is shown.
[0065] Figure 5 A block diagram of an electronic device 1900 provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0066] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0067] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0068] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.
[0069] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0070] The driver in the related art has the following defects:
[0071] Strong hardware coupling: The drivers in related technologies are tightly coupled with specific hardware, making it difficult to adapt to the rapid iteration and diversification of hardware requirements;
[0072] Difficulty in open source: The code of the hardware operation process is directly exposed in the open source system, which increases security risks and limits the open source and sharing of the code;
[0073] High development and maintenance costs: Each hardware device requires specific driver code, which increases the workload of development and maintenance;
[0074] Difficulty in cross-hardware platform development: Software development for different hardware platforms requires specific adaptation for each hardware, which increases the complexity of development.
[0075] In order to solve the technical problems similar to those described above, the embodiment of the present disclosure provides a method for implementing a driver, wherein the driver includes a host driver and a slave driver, wherein the host driver runs on a host operating system, and the slave driver runs on a slave operating system, wherein the host operating system responds to a hardware operation request, and sends the hardware operation request to the slave operating system through the host driver, and the slave operating system responds to the hardware operation request, and performs the hardware operation corresponding to the hardware operation request through the slave driver, thereby the host driver does not need to directly operate the hardware, and can shield the hardware differences, and can operate different hardware devices by simply calling an interface with a specific process, which can solve the problems of strong hardware coupling, difficulty in opening source, high development and maintenance costs, and difficulty in cross-hardware platform development in the related art. The embodiment of the present disclosure isolates the hardware operation on the slave operating system, and can achieve complete isolation of the host operating system / host driver from the hardware operation, improve the portability and maintainability of the software, and protect the security of the hardware information. In addition, this separation design method allows the host driver to provide a unified interface for a variety of hardware devices, while the specific hardware operation is performed by the slave driver according to the actual characteristics of the hardware. This not only simplifies the development and maintenance of the driver, but also improves the flexibility and scalability of the system.
[0076] The implementation method of the driver provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
[0077] Figure 1 A flowchart of a method for implementing a driver provided in an embodiment of the present disclosure is shown. In one possible implementation, the execution subject of the method for implementing the driver may be a device for implementing the driver. For example, the method for implementing the driver may be executed by a terminal device or a server or other electronic device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device or a wearable device. In some possible implementations, the method for implementing the driver may be implemented by a processor calling computer-readable instructions stored in a memory. In an embodiment of the present disclosure, the driver includes a host driver and a slave driver. The host driver runs on a host operating system, and the slave driver runs on a slave operating system. As Figure 1 As shown, the implementation method of the driver program includes step S11 and step S12.
[0078] In step S11, the host operating system responds to the hardware operation request by sending the hardware operation request to the slave operating system through the host driver.
[0079] In step S12, the slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver.
[0080] In the embodiments of the present disclosure, the operating system may include a host operating system (Host OS) and a slave operating system (Slave OS). In some application scenarios, the host operating system may also be referred to as a main operating system, a host operating system, etc., and the slave operating system may also be referred to as a slave operating system, a slave operating system, etc., which are not limited here.
[0081] The host operating system can be any general-purpose operating system, such as the Linux operating system, Windows operating system, macOS, or an operating system customized for a specific application. The slave operating system can be a lightweight system optimized for hardware operation, such as an embedded system or a real-time operating system (RTOS). For example, the slave operating system can be the Linux operating system.
[0082] In the disclosed embodiment, the driver may include a host driver and a slave driver. In some application scenarios, the host driver may also be called a master driver, an upper layer driver, an abstract driver, etc., and the slave driver may also be called a slave driver, a lower layer driver, a hardware driver, etc., which are not limited here.
[0083] The host driver is a software component that runs on the host operating system. The host driver can define a set of hardware-independent interfaces for upper-level applications or system services to call. The interfaces provided by the host driver can allow upper-level applications or system services to request hardware operations in a unified manner without having to care about the specific details of the hardware. The host driver does not interact directly with the hardware device, but interacts with the slave driver through specific processes and communication mechanisms.
[0084] When designing and implementing a host driver, the operations of a specific type of hardware (such as a display controller, a network interface card, a storage device, etc.) can be abstracted and encapsulated to form a standardized operation sequence or process, and an interface can be provided to the outside. For example, the hardware-independent interfaces provided by the host driver may include, but are not limited to: an interface for opening / closing a device, an interface for reading and writing operations, an interface for configuring a device, an interface for querying a status, an interface for handling errors, an interface for controlling a device, an interface for controlling a data flow, and an interface for obtaining device properties.
[0085] A slave driver is a software component running on a slave operating system that interacts directly with hardware devices and performs specific hardware operations. A slave driver can be responsible for understanding the working principle and interface of the hardware, and perform corresponding hardware operations such as data reading and writing, device configuration, status query, etc. according to the hardware operation request forwarded by the host driver. When designing and implementing a slave driver, an interface can be obtained based on the operation abstraction of specific hardware (such as display controller, DisplayPort interface, HDMI interface, etc.) for the host driver to call.
[0086] The host driver can provide a unified interface for a variety of hardware devices, thereby achieving hardware independence and simplifying the development and maintenance of applications. The design of the slave driver can be targeted at specific hardware devices, so it can be customized and optimized according to the characteristics of the hardware. In the disclosed embodiment, the upper-level application interacts with the hardware through the host driver, without having to care about the specific details of the hardware, thereby improving the portability of the application. The isolation of the host operating system / host driver from the hardware operation can protect the security of hardware information and avoid exposing the details of hardware operations in an open source system. The host driver provides a unified interface for a variety of hardware devices, thereby simplifying the development and maintenance of the driver. The slave driver can be customized according to the characteristics of the hardware, thereby improving the flexibility and scalability of the system.
[0087] In a possible implementation, the driver includes a display driver. The display driver is a software component in a computer system responsible for managing a display device, and acts as an intermediary between an operating system and display hardware (such as a display, a graphics card).
[0088] Display drivers need to support various models and brands of graphics cards and monitors. This implementation provides a unified interface through the host driver, which can simplify the support for different hardware and enable applications to run seamlessly on different display devices. With the development of display technology, new display devices and features (such as high resolution, high refresh rate, etc.) continue to emerge. This implementation allows the slave driver to be customized for new hardware while the host driver remains unchanged, so as to quickly adapt to new hardware. In addition, display drivers have high performance requirements, especially in graphics-intensive applications. In this implementation, the slave driver can be optimized for specific hardware, such as using specific features of the graphics card to accelerate rendering, while the host driver can focus on providing efficient graphics command scheduling.
[0089] In other possible implementations, the driver may also be an audio driver, a network driver, a storage driver, a printer driver, etc., which is not limited here.
[0090] In a possible implementation, the ipc_msg_init function can be called to establish communication between the host operating system and the slave operating system and initialize the mechanism for transmitting messages. The ipc_msg_init function can be used to: allocate necessary system resources, such as memory, buffer, etc., for inter-process communication message transmission; establish a communication channel between the host operating system and the slave operating system, which may include setting up shared memory, message queues, sockets, etc.; initialize data structures used to store and manage messages, such as message queues, buffer pointers, etc.
[0091] In a possible implementation, the interrupt may be initialized in a communication mechanism between the host operating system and the slave operating system.
[0092] As an example of this implementation, interrupt initialization may include interrupt request (IRQ) configuration. In the interrupt request configuration, an interrupt request number may be configured. The interrupt request number is a unique identifier of the interrupt, which is used to distinguish different interrupt sources.
[0093] As an example of this implementation, interrupt initialization may include registering an interrupt handler (also called an interrupt service routine (ISR)) in the slave operating system, which may be used to process an interrupt signal sent from the host operating system.
[0094] As an example of this implementation, interrupt initialization may include registering an interrupt handler in the host operating system, which may be used to process an interrupt signal sent from the slave operating system.
[0095] In one possible implementation, the host operating system responds to a hardware operation request and sends the hardware operation request to the slave operating system through the host driver, including: the host operating system responds to the hardware operation request and calls a first interface corresponding to the hardware operation request in an interface provided by the host driver; and sends the hardware operation request to the slave operating system through the first interface.
[0096] In this implementation, the host operating system may receive a hardware operation request from a user space program or a system service. The hardware operation request may be any hardware-related operation to be performed, such as reading hardware status, sending data to hardware, etc. The host operating system may respond to the hardware operation request by calling a first interface provided by the host driver. The first interface may represent an interface provided by the host driver that corresponds to the hardware operation request.
[0097] Through the first interface, the host operating system can send the hardware operation request to the slave operating system. The sending process can involve serialization, packaging and transmission of data through an inter-process communication (IPC) mechanism. For example, the host driver can use an inter-process communication mechanism, such as a message queue, shared memory, socket, interrupt, etc., to ensure that the hardware operation request is correctly sent to the slave operating system.
[0098] The implementation allows the host operating system to be isolated from the details of hardware operations, improving the system's abstraction level and maintainability. At the same time, it also supports hardware independence because the host driver provides a unified interface. Regardless of the specific model and characteristics of the underlying hardware, the upper-level application can operate through the same interface.
[0099] In a possible implementation manner, sending the hardware operation request to the slave operating system through the first interface includes: sending the hardware operation request to the slave operating system through an inter-process message through the first interface.
[0100] In this implementation, inter-process messages allow the system to dynamically handle hardware operation requests, adapt to different hardware and different operation requirements, and improve the flexibility of the system. In addition, inter-process messages can be sent asynchronously, which means that the host operating system does not need to wait for the hardware operation to complete before continuing to perform other tasks, thereby improving the performance of the overall system.
[0101] In a possible implementation, the first interface sends the hardware operation request to the slave operating system through an inter-process message, including: the first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system.
[0102] In this implementation, the first shared memory can be used to store data sent by the host operating system to the slave operating system. The first shared memory can be accessed by the host operating system and the slave operating system.
[0103] The first interface can encapsulate the relevant information of the hardware operation request (such as operation type, parameters, etc.) into a message and write it to the first shared memory. The slave operating system can regularly check or monitor the changes of the first shared memory, or the slave operating system can respond to the interrupt from the host operating system to check the changes of the first shared memory. The slave operating system can respond to the detection of a new hardware operation request, read the hardware operation request, and the slave driver performs the corresponding hardware operation.
[0104] In this implementation, shared memory allows the host operating system and the slave operating system to read and write data directly in memory without copying or transferring the data multiple times, which can significantly increase the speed of data exchange. Since data is shared directly in memory, network communication or context switching between kernel space and user space is avoided, thereby reducing latency, which is particularly important for hardware operations that require fast response.
[0105] In other possible implementations, in addition to sending the hardware operation request to the slave operating system through an inter-process message, the first interface may also send the hardware operation request through an interrupt, direct memory access, etc., which is not limited here.
[0106] In the embodiment of the present disclosure, the host driver may notify the slave driver to execute a specific hardware operation by triggering an interrupt or sending an event.
[0107] In one possible implementation, after the first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system, the method further includes: the first interface sends an interrupt to the slave operating system; and the slave operating system reads the hardware operation request from the first shared memory in response to the interrupt.
[0108] In this implementation, after the first interface writes the hardware operation request into the first shared memory between the host operating system and the slave operating system, the first interface may send an interrupt signal to the slave operating system, wherein an interrupt is an asynchronous communication mechanism for notifying the receiving party (slave operating system) that there are new events or data to be processed.
[0109] The slave operating system may be configured with an interrupt handler for responding to an interrupt signal from the host operating system. When the slave operating system receives an interrupt signal, the interrupt handler is triggered. The triggered interrupt handler reads a hardware operation request from the first shared memory to perform a corresponding hardware operation. The slave operating system may perform specific operations on the hardware through the slave driver according to the read hardware operation request, such as data reading and writing, device configuration, etc.
[0110] In this implementation, the interrupt mechanism enables the slave operating system to respond to the host operating system's request in a timely manner, which is particularly important for hardware operations that require fast processing. In addition, the use of interrupts avoids the need for the slave operating system to constantly poll the first shared memory to check for new hardware operation requests, thereby saving processor resources and improving efficiency.
[0111] In one possible implementation, the slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver, including: the slave operating system responds to the hardware operation request and calls a second interface corresponding to the hardware operation request in an interface provided by the slave driver; and executes the hardware operation corresponding to the hardware operation request through the second interface.
[0112] In this implementation, the slave operating system can perform hardware operations through a specific interface provided by the slave driver. After receiving a hardware operation request, the slave operating system can call a corresponding interface (second interface) provided by the slave driver according to the type and content of the hardware operation request. This interface is specially designed to handle specific types of hardware operations. Through the second interface, the slave operating system will perform specific hardware operations, such as reading or writing hardware registers, configuring hardware device parameters, starting or stopping hardware devices, etc.
[0113] In this implementation, by encapsulating the hardware operation in the interface of the slave driver, the hardware operation is decoupled from the host operating system, which improves the modularity and maintainability of the system. Sensitive hardware operations are isolated in the slave operating system, reducing the risk of the host operating system directly exposing the hardware operation and enhancing the security of the system.
[0114] In a possible implementation, the slave operating system, in response to the hardware operation request, calls a second interface in an interface provided by the slave driver corresponding to the hardware operation request, including: the slave operating system, in response to the hardware operation request, calls the second interface in an interface provided by the slave driver corresponding to the hardware operation request according to identification information of a specified hardware module and identification information of a specified operation carried in the hardware operation request; and executing the hardware operation corresponding to the hardware operation request through the second interface includes: executing the specified operation on the specified hardware module through the second interface.
[0115] In this implementation, the hardware operation request carries the identification information of the specified hardware module (Module ID) and the identification information of the specified operation (Function ID). The identification information of the specified hardware module and the identification information of the specified operation can be used to determine the specific target and operation type of the hardware operation request.
[0116] According to the identification information of the specified hardware module and the identification information of the specified operation, the slave operating system can call the corresponding interface (second interface) provided by the slave driver. This interface is specially designed to handle the specified operation of the specified hardware module. Through the second interface, the slave operating system can perform specific hardware operations, such as reading or writing hardware registers, configuring hardware device parameters, starting or stopping hardware devices, etc.
[0117] In this implementation, by using the identification information of the specified hardware module and the identification information of the specified operation, the hardware module and the operation type to be operated can be accurately specified, thereby ensuring the accuracy and reliability of the hardware operation. The host operating system does not need to contain complex hardware operation logic, but only needs to send a request with identification information, which simplifies the design and implementation of the host operating system.
[0118] In the disclosed embodiment, after completing the hardware operation, the slave driver may return the result to the host driver through a callback or response mechanism.
[0119] In one possible implementation, after executing the hardware operation corresponding to the hardware operation request through the second interface, the method further includes: the second interface responds to the hardware operation request requesting receipt information, and sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message.
[0120] In this implementation, the second interface can determine whether it is necessary to send receipt information to the host operating system according to the hardware operation request. If not, only the hardware operation can be performed; if necessary, the receipt information can be sent to the host operating system.
[0121] After the hardware operation is completed, the second interface generates receipt information, for example, the receipt information may include the operation result, status code, any captured hardware status or error information. The second interface may send the receipt information to the host operating system through an inter-process message mechanism (such as a message queue, shared memory, socket, etc.). After receiving the receipt information, the host operating system may parse the receipt information to understand the result of the hardware operation. Based on the receipt information, the host operating system may perform further processing, such as updating the system status, notifying the user or application.
[0122] In this implementation, by sending the receipt information, the data consistency between the host operating system and the slave operating system can be ensured, and the host operating system can accurately know whether the hardware operation is successfully executed. In addition, the error information or status code contained in the receipt information can help the host operating system identify and handle problems that may occur in the hardware operation, thereby improving the robustness of the system.
[0123] In one possible implementation, the second interface responds to the hardware operation request requesting receipt information, and sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message, including: the second interface responds to the hardware operation request requesting receipt information, and writes the receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system.
[0124] In this implementation, the second shared memory can be used to store data sent by the slave operating system to the host operating system. The second shared memory can be accessed by the host operating system and the slave operating system.
[0125] In this implementation, after the second interface completes the hardware operation, receipt information may be generated and written into the second shared memory. In order to enable the host operating system to read the receipt information in a timely manner, a certain form of synchronization mechanism, such as a semaphore, an event flag, or an interrupt, may be used to notify the host operating system that the receipt information is ready. The host operating system may periodically check the second shared memory, or read the receipt information after receiving a synchronization notification, to understand the result of the hardware operation.
[0126] In this implementation, the second shared memory allows the slave operating system to directly write data into the memory, and the host operating system can directly read it. This direct access method reduces the steps of data transmission and improves the efficiency of data exchange. In applications that require fast response, such as real-time control systems, the second shared memory can ensure that the host operating system can quickly obtain the results processed by the slave operating system, thereby achieving fast system response.
[0127] The following describes the implementation method of the driver provided by the embodiment of the present disclosure through a specific application scenario. Figure 2 A schematic diagram of a method for implementing a driver provided by an embodiment of the present disclosure is shown. In this application scenario, the operating system includes a host operating system and a slave operating system. The host operating system may be a Linux operating system or a Windows operating system, and the slave operating system may be a Linux operating system.
[0128] like Figure 2 As shown, on the host operating system, system preparation may include loading and initializing a host driver. For example, if it is a display driver, the host driver may include a direct rendering manager (Direct Rendering Manager, DRM) driver and a display module driver (Display Module Drivers).
[0129] On the slave operating system, system preparation may include loading and initializing the slave driver. In addition, the slave driver may also initialize an inter-process communication mechanism, such as setting up shared memory or interrupts, etc., in order to communicate with the host operating system.
[0130] The host driver can send a hardware operation request to the slave operating system through an inter-process message. The slave operating system can respond to the hardware operation request and perform the specified hardware operation through the slave driver. The slave driver can determine whether it is necessary to send a receipt message to the host operating system according to the requirements of the hardware operation request. This may depend on the nature of the hardware operation and whether the host operating system needs to confirm the result of the operation. If a receipt message is required, the slave driver can send the receipt message to the host operating system through the same inter-process communication mechanism after completing the hardware operation. Among them, the receipt message may include the result of the operation, a status code or other relevant information.
[0131] After receiving the receipt information from the slave operating system, the host operating system can decide the subsequent process according to the receipt information, which may include updating the system status, notifying the user or application program of the result of the operation, or performing further operations when necessary.
[0132] Figure 3 Another schematic diagram showing a method for implementing a driver program provided by an embodiment of the present disclosure.
[0133] like Figure 3 As shown in FIG. 1 , the host driver can abstract the operation of specific hardware (such as display controller, DisplayPort, HDMI, etc.) into a unified, process-specific software interface. This means that regardless of the specific model and characteristics of the hardware, operations can be performed through these unified interfaces.
[0134] An upper-layer application or system service may issue a hardware operation request, wherein the hardware operation request may carry identification information of a specified hardware module and identification information of a specified operation.
[0135] The host operating system may, in response to the hardware operation request, call a first interface corresponding to the hardware operation request in the interface provided by the host driver. The first interface may send the hardware operation request to the slave operating system via an IPC message. Furthermore, the first interface may send an interrupt to the slave operating system.
[0136] The slave operating system may respond to the interruption and read the hardware operation request from the first shared memory. The slave operating system may respond to the hardware operation request and, according to the identification information of the designated hardware module and the identification information of the designated operation carried in the hardware operation request, call the second interface corresponding to the hardware operation request in the interface provided by the slave driver, and perform the designated operation on the designated hardware module through the second interface.
[0137] In response to the request for receipt information, the second interface may write receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system after the hardware operation is completed.
[0138] After receiving the receipt information, the host operating system can proceed with the subsequent process.
[0139] In this application scenario, by implementing communication between the host operating system and the slave operating system based on the inter-process communication mechanism, the communication efficiency between the host operating system and the slave operating system can be improved, and usually only takes a very short time (several microseconds to more than ten microseconds) to complete the entire hardware operation process.
[0140] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.
[0141] In addition, the present disclosure also provides a driver implementation device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any driver implementation method provided by the present disclosure. The corresponding technical solutions and technical effects can be found in the corresponding records in the method part and will not be repeated here.
[0142] Figure 4A block diagram of a device for implementing a driver provided by an embodiment of the present disclosure is shown. The driver includes a host driver and a slave driver, wherein the host driver runs on a host operating system and the slave driver runs on a slave operating system. Figure 4 As shown, the implementation device of the driver includes:
[0143] A first sending module 41, configured for the host operating system to respond to a hardware operation request by sending the hardware operation request to the slave operating system through the host driver;
[0144] The execution module 42 is used for the slave operating system to respond to the hardware operation request and execute the hardware operation corresponding to the hardware operation request through the slave driver.
[0145] In a possible implementation, the first sending module 41 is used to:
[0146] The host operating system, in response to the hardware operation request, calls a first interface corresponding to the hardware operation request among the interfaces provided by the host driver;
[0147] The hardware operation request is sent to the slave operating system through the first interface.
[0148] In a possible implementation, the first sending module 41 is used to:
[0149] The first interface sends the hardware operation request to the slave operating system through an inter-process message.
[0150] In a possible implementation, the first sending module 41 is used to:
[0151] The first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system.
[0152] In a possible implementation manner, the device further includes:
[0153] A second sending module, configured for the first interface to send an interrupt to the slave operating system;
[0154] A reading module is used for the slave operating system to read the hardware operation request from the first shared memory in response to the interrupt.
[0155] In a possible implementation, the execution module 42 is used to:
[0156] The slave operating system, in response to the hardware operation request, calls a second interface corresponding to the hardware operation request among the interfaces provided by the slave driver;
[0157] The hardware operation corresponding to the hardware operation request is executed through the second interface.
[0158] In a possible implementation, the execution module 42 is used to:
[0159] The slave operating system, in response to the hardware operation request, calls a second interface corresponding to the hardware operation request in the interfaces provided by the slave driver according to the identification information of the designated hardware module and the identification information of the designated operation carried in the hardware operation request;
[0160] The specified operation is performed on the specified hardware module through the second interface.
[0161] In a possible implementation manner, the device further includes:
[0162] A third sending module is used for the second interface to respond to the hardware operation request requiring receipt information, and to send the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message.
[0163] In a possible implementation manner, the third sending module is used to:
[0164] The second interface writes the receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system in response to the hardware operation request requiring receipt information.
[0165] In a possible implementation manner, the driver includes a display driver.
[0166] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. Its specific implementation and technical effects can refer to the description of the above method embodiments. For the sake of brevity, they will not be repeated here.
[0167] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium may be a non-volatile computer-readable storage medium, or may be a volatile computer-readable storage medium.
[0168] The embodiment of the present disclosure further provides a computer program, including a computer-readable code. When the computer-readable code is executed in an electronic device, a processor in the electronic device executes the above method.
[0169] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.
[0170] An embodiment of the present disclosure also provides an electronic device, comprising: one or more processors; and a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.
[0171] The electronic device may be provided as a terminal, a server, or a device in other forms.
[0172] Figure 5 1 is a block diagram of an electronic device 1900 provided in an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a terminal or a server. Figure 5 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0173] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as a Microsoft Server operating system (Windows Server 2003). TM ), a graphical user interface operating system launched by Apple (MacOS X TM ), a multi-user, multi-process computer operating system (Unix TM ), a free and open source Unix-like operating system (Linux TM ), an open source Unix-like operating system (FreeBSD TM ) or similar.
[0174] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.
[0175] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0176] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0177] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0178] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0179] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0180] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0181] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0182] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0183] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK) and the like.
[0184] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0185] If the technical solution of the embodiments of the present disclosure involves personal information, the product using the technical solution of the embodiments of the present disclosure has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of the embodiments of the present disclosure involves sensitive personal information, the product using the technical solution of the embodiments of the present disclosure has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the requirement of "explicit consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to collect his or her personal information; or on the device for processing personal information, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0186] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A method for implementing a driver, characterized in that: The driver comprises a host driver and a slave driver, wherein the host driver runs on a host operating system and the slave driver runs on a slave operating system, and the method comprises: The host operating system responds to the hardware operation request by sending the hardware operation request to the slave operating system through the host driver; The slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver.
2. The method according to claim 1, characterized in that The host operating system sends the hardware operation request to the slave operating system through the host driver in response to the hardware operation request, including: The host operating system, in response to the hardware operation request, calls a first interface corresponding to the hardware operation request among the interfaces provided by the host driver; The hardware operation request is sent to the slave operating system through the first interface.
3. The method according to claim 2, characterized in that The sending the hardware operation request to the slave operating system through the first interface includes: The first interface sends the hardware operation request to the slave operating system through an inter-process message.
4. The method according to claim 3, characterized in that The first interface sends the hardware operation request to the slave operating system through an inter-process message, including: The first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system.
5. The method according to claim 4, characterized in that After the first interface writes the hardware operation request into a first shared memory between the host operating system and the slave operating system, the method further includes: The first interface sends an interrupt to the slave operating system; The slave operating system reads the hardware operation request from the first shared memory in response to the interrupt.
6. The method according to claim 1, characterized in that The slave operating system responds to the hardware operation request and executes the hardware operation corresponding to the hardware operation request through the slave driver, including: The slave operating system, in response to the hardware operation request, calls a second interface corresponding to the hardware operation request among the interfaces provided by the slave driver; The hardware operation corresponding to the hardware operation request is executed through the second interface.
7. The method according to claim 6, characterized in that The slave operating system, in response to the hardware operation request, calls a second interface in the interface provided by the slave driver corresponding to the hardware operation request, comprising: the slave operating system, in response to the hardware operation request, calls the second interface in the interface provided by the slave driver corresponding to the hardware operation request according to the identification information of the specified hardware module and the identification information of the specified operation carried in the hardware operation request; The executing the hardware operation corresponding to the hardware operation request through the second interface includes: executing the designated operation on the designated hardware module through the second interface.
8. The method according to claim 6, characterized in that After executing the hardware operation corresponding to the hardware operation request through the second interface, the method further includes: The second interface sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message in response to the hardware operation request requiring receipt information.
9. The method according to claim 8, characterized in that The second interface sends the receipt information corresponding to the hardware operation request to the host operating system through an inter-process message in response to the hardware operation request requiring receipt information, including: The second interface writes the receipt information corresponding to the hardware operation request into the second shared memory of the host operating system and the slave operating system in response to the hardware operation request requiring receipt information.
10. The method according to claim 1, characterized in that The driver includes a display driver.
11. A device for implementing a driver, characterized in that: The driver comprises a host driver and a slave driver, wherein the host driver runs on a host operating system, and the slave driver runs on a slave operating system, and the device comprises: A first sending module, configured for the host operating system to send the hardware operation request to the slave operating system through the host driver in response to the hardware operation request; An execution module is used for the slave operating system to respond to the hardware operation request and execute the hardware operation corresponding to the hardware operation request through the slave driver.
12. An electronic device, characterized in that: include: one or more processors; a memory for storing executable instructions; The one or more processors are configured to call the executable instructions stored in the memory to execute the method according to any one of claims 1 to 10.
13. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. A computer program product comprising computer readable code, or a non-volatile computer readable storage medium carrying computer readable code, characterized in that: When the computer readable code is executed in an electronic device, a processor in the electronic device executes the method according to any one of claims 1 to 10.