CN-121996304-A - Transplanting method and device for device driver between operating systems and electronic device
Abstract
The invention discloses a transplanting method and device for device drivers among operating systems and electronic equipment, and relates to the technical field of computers. And responding to the drive initialization operation of the target device in the first operating system, and starting a target drive program corresponding to the target device in the first operating system. And responding to the target driver to call a driver registration function interface in the first operating system, and registering a file operation structure of the target device in the second operating system into the created target structure. The file operation structure has encapsulated therein a driving function pointer for driving the target device. And packaging the resource manager of the first operating system into a target structure body, initializing the resource manager, registering the target equipment node by using the initialized resource manager, and accessing the target structure body through the target equipment node. Therefore, multiplexing of the encapsulated driving functions can be realized in the first operating system, and efficient migration and adaptation of the device driving among different operating systems can be realized.
Inventors
- ZHU HUA
- LING XIAOFENG
Assignees
- 地平线征程(上海)科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260127
Claims (13)
- 1. A method of inter-operating system device driven migration, comprising: Responding to a drive initialization operation of target equipment in a first operating system, and starting a target drive program corresponding to the target equipment in the first operating system; Responding to the target driver program to call a driving registration function interface, and registering a file operation structure body of the target device in a second operating system into the created target structure body, wherein a driving function pointer for driving the target device is packaged in the file operation structure body; And packaging the resource manager of the first operating system into the target structure body, initializing the resource manager, and registering a target equipment node by using the initialized resource manager, wherein the target equipment node is used for accessing the target structure body.
- 2. The method of claim 1, wherein the initializing the resource manager comprises: Registering, in the resource manager, a driver function pointer of the target device; the general driving function is used for accessing the target structure body through target parameters; and creating a function pointer mapping relation between the driving function pointer and the universal driving function in the resource manager according to the driving operation of the function pointer association.
- 3. The method according to claim 1 or 2, wherein the method further comprises: Responding to a user process to initiate a device driving operation request by accessing a target device node in the first operating system, generating a process message by utilizing a kernel of the first operating system, and sending the process message to a driving process of the first operating system; Analyzing the process message by using the driving process to acquire a message type and a target parameter in the process message, and determining a first driving function pointer in the first operating system according to the message type; Accessing a target structure body corresponding to the target equipment according to the first driving function pointer, the function pointer mapping relation in the first operating system and the target parameter, and determining a file operation structure body in the target structure body; And calling a second driving function pointer in the second operating system based on the file operation structure body, and executing equipment driving operation by using a driving function corresponding to the second driving function pointer.
- 4. The method of claim 3, wherein accessing the target structure corresponding to the target device according to the first driving function pointer, the function pointer mapping relationship in the first operating system, and the target parameter comprises: determining a target general driving function corresponding to the first driving function pointer according to the mapping relation of the function pointer in the first operating system; And accessing a target structure body corresponding to the target equipment based on the target universal driving function and the target parameter.
- 5. The method of claim 1, wherein the method further comprises: And responding to the target driver program to call a driving registration function interface, and registering the equipment information of the target equipment in the second operating system into the target structure body, wherein the equipment information is used for initializing the resource manager.
- 6. The method of claim 1, wherein the method further comprises: Responding to the target driver program to call an interrupt registration function interface in a driver management program, and creating a context for the target driver program by using the driver management program; Storing a mapping relation between the device interrupt number of the target device and the interrupt handling function pointer in the second operating system in a context corresponding to the target driver, and adding the context corresponding to the target driver into a device linked list of the first operating system; And creating an interrupt processing thread for the target driver, and determining a mapping relation between the interrupt processing thread and the device interrupt number of the target driver, wherein the interrupt processing thread is used for calling a context corresponding to the target driver in the device linked list.
- 7. The method of claim 6, wherein the method further comprises: In response to receiving an interrupt trigger message sent by a kernel of the first operating system, waking up an interrupt processing thread corresponding to an equipment interrupt number according to the equipment interrupt number in the interrupt trigger message; accessing a context corresponding to the target driver in the equipment linked list by using the interrupt processing thread, and acquiring an interrupt processing function pointer corresponding to the equipment interrupt number from the context; And calling an interrupt processing function pointed by the interrupt processing function pointer in the second operating system by using the interrupt processing thread, and executing interrupt processing operation by using the interrupt processing function.
- 8. The method of claim 6, wherein the method further comprises: and responding to the interrupt identifier returned by the kernel of the first operating system after receiving the equipment interrupt number, and storing the interrupt identifier in the context corresponding to the target driver.
- 9. The method of claim 8, wherein the method further comprises: Responding to the target driver program to call an interrupt control function interface in an operating system abstraction layer to acquire a device interrupt number transmitted by the interrupt control function interface, wherein the interrupt control function interface in the operating system abstraction layer is used for calling an interrupt shielding control interface in the first operating system; Traversing the context in the equipment linked list, and matching the equipment interrupt number in the context with the equipment interrupt number transmitted by the interrupt control function interface; Determining a context corresponding to the equipment interrupt number successfully matched, and acquiring an interrupt identifier in the context; And transmitting the interrupt identifier into the interrupt shielding control interface, and executing interrupt control operation.
- 10. The method of claim 6, wherein the method further comprises: Responding to the target driver program to call an interrupt cancellation function interface in a driver management program, and searching a corresponding context in the equipment linked list by using the equipment interrupt number of the target driver program; and deleting the context corresponding to the equipment interrupt number from the equipment linked list, and executing interrupt exit operation.
- 11. An inter-operating system device driven migration apparatus comprising: the first creating module is used for responding to the drive initialization operation of the target equipment in the first operating system and starting a target drive program corresponding to the target equipment in the first operating system; the second creation module is used for responding to the target driver to call a driving registration function interface and registering a file operation structure body of the target device in a second operation system into the created target structure body, wherein a driving function pointer used for driving the target device is packaged in the file operation structure body; The first registration module is used for packaging the resource manager of the first operating system into the target structure body, initializing the resource manager and registering a target equipment node by using the initialized resource manager, wherein the target equipment node is used for accessing the target structure body.
- 12. A computer readable storage medium storing a computer program which, when executed by a processor, is adapted to carry out the inter-operating system device driven migration method of any of the preceding claims 1-10.
- 13. An electronic device, the electronic device comprising: A processor; a memory for storing the processor-executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the inter-operating system device driven migration method of any of the above claims 1-10.
Description
Transplanting method and device for device driver between operating systems and electronic device Technical Field The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for transplanting device drivers between operating systems, and an electronic device. Background With the development of computer technology, operating systems are becoming increasingly diverse. Current operating systems may include non-real time operating systems such as Linux systems. In order to improve the real-time performance and reliability of the operating system, a microkernel real-time operating system with stronger real-time performance, such as a QNX system, is provided. The operating system can complete interaction between the user program and the equipment through equipment driving, and driving and controlling the equipment are achieved. In a practical application scenario, the driving of some devices only provides a packaged implementation oriented to a non-real-time operating system. If the device driver and control are implemented in the microkernel real-time operating system environment, the device driver in the non-real-time operating system environment needs to be transplanted into the microkernel real-time operating system. However, the microkernel real-time operating system and the non-real-time operating system are different in the driving mode of the device, so that the device driving cannot be directly transplanted between the operating systems. Moreover, the existing device driving transplanting modes are complex, so that the transplanting efficiency of the device driving is low. Disclosure of Invention In order to solve the technical problems, the present disclosure provides a method, an apparatus, and an electronic device for transplanting device drivers between operating systems, which can reduce the transplanting complexity of the device drivers, and further improve the transplanting efficiency of the device drivers between different operating systems. An embodiment of a first aspect of the present disclosure provides a migration method for device drivers between operating systems, which includes starting a target driver corresponding to a target device in a first operating system in response to a driver initialization operation on the target device in the first operating system, calling a driver registration function interface in response to the target driver, registering a file operation structure of the target device in a second operating system in the created target structure, encapsulating a driver function pointer for driving the target device in the file operation structure, encapsulating a resource manager of the first operating system in the target structure, initializing the resource manager, registering a target device node using the initialized resource manager, and using the target device node to access the target structure. The embodiment of the second aspect of the disclosure provides a migration device for device driving between operating systems, which comprises a first creation module, a second creation module, a first registration module and a first registration module, wherein the first creation module is used for responding to the driving initialization operation of target devices in a first operating system, starting target driving programs corresponding to the target devices in the first operating system, the second creation module is used for responding to the driving registration function interfaces called by the target driving programs, registering file operation structures of the target devices in the second operating system in the created target structures, driving function pointers for driving the target devices are packaged in the file operation structures, the first registration module is used for packaging resource managers of the first operating system in the target structures, initializing the resource managers, registering target device nodes by using the initialized resource managers, and the target device nodes are used for accessing the target structures. In a third aspect of the present disclosure, there is provided a computer-readable storage medium storing a computer program for implementing the migration method of device drivers between operating systems according to the first aspect of the present disclosure when the computer program is executed by a processor. An embodiment of a fourth aspect of the present disclosure provides an electronic device, where the electronic device includes a processor, a memory for storing executable instructions of the processor, and a processor for reading the executable instructions from the memory and executing the instructions to implement the migration method of the device driver between operating systems of the embodiment of the first aspect. The embodiment of the disclosure provides a migration method of device drivers among operating systems, which responds to the drive