CN112231007B - Device driving method based on user mode and kernel mode driving cooperative processing framework - Google Patents
Device driving method based on user mode and kernel mode driving cooperative processing framework Download PDFInfo
- Publication number
- CN112231007B CN112231007B CN202011233583.4A CN202011233583A CN112231007B CN 112231007 B CN112231007 B CN 112231007B CN 202011233583 A CN202011233583 A CN 202011233583A CN 112231007 B CN112231007 B CN 112231007B
- Authority
- CN
- China
- Prior art keywords
- kernel
- mode
- driver
- user
- user mode
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/4401—Bootstrapping
- G06F9/4411—Configuring for operating with peripheral devices; Loading of device drivers
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/10—Program control for peripheral devices
- G06F13/102—Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The invention discloses a device driving method based on a user mode and kernel mode driving cooperative processing framework, which comprises the following steps of initializing the user mode and kernel mode driving cooperative processing framework: the kernel state driver is used as a loadable kernel module to run in a kernel space and is used for providing a stable kernel state driver development interface; the user mode driver is used as a shared library and positioned in a user space and used for providing an interface for the development of the user mode driver; when the application program in the user space calls the user mode driver, the user mode driver interacts with the kernel mode driver through the user mode driver, or directly interacts with the kernel mode driver through the character device and the DMA buffer device, and therefore operation on the designated device is completed. The invention can realize the cooperative processing of the user mode and the kernel mode driver, and jointly complete the interaction with hardware, thereby greatly simplifying the development and maintenance process of the driver and improving the stability and reliability of the kernel.
Description
Technical Field
The invention relates to the field of computer operating systems, in particular to a device driving method based on a user mode and kernel mode driving cooperative processing framework in a Linux system.
Background
With the development of computer technology, Linux is no longer limited to be applied to the field of servers and terminal systems, and is gradually widely applied to mobile devices. However, the peripheral problem is always an important factor influencing the development of the Linux system, mainly because the drive development under Linux is complex and requires to comply with GPL protocol public source code, which results in insufficient drive development of some equipment manufacturers. Nowadays, the proportion of device driver code in the kernel is increasing, especially for the drivers that are transplanted and developed by the enterprise themselves, when problems occur in these drivers, such as illegal memory access, the whole system may be crashed. Research has shown that drivers under Linux have a 3 to 7 times higher probability of causing system crash than other kernels.
At present, in order to improve robustness and reliability of driving, various researches are carried out in related fields at home and abroad, such as user state driving. The drive is typically implemented with a Minix system by running it as a user process. The Minix system is an operating system based on a micro-kernel architecture, the kernel only comprises key parts such as process management and memory management, and other modules are used as a modular user space process and comprise device drivers. Such an implementation inevitably has a problem of performance degradation, and thus has not been available for large-scale use. Like the UIO in Linux, Direct Memory Access (DMA) in user space is not supported, which limits its application to devices requiring DMA support. Therefore, how to better give consideration to performance and stability and completely support the functions of hardware equipment is a main research direction of Linux user-mode driver design.
Disclosure of Invention
The technical problems to be solved by the invention are as follows: aiming at the requirements of the Linux user mode driver on both performance and stability and the existing imperfect framework function, the invention provides the equipment driving method based on the user mode and kernel mode driving cooperative processing framework.
In order to solve the technical problems, the invention adopts the technical scheme that:
a device driving method based on a user mode and kernel mode driving cooperative processing framework comprises the following steps:
1) initializing a user mode and kernel mode drive cooperative processing framework, wherein the user mode and kernel mode drive cooperative processing framework comprises: the kernel mode driver is used as a loadable kernel module to run in a kernel space and is used for providing a stable kernel mode driver development interface; the user mode driver is used as a shared library and positioned in a user space and used for providing an interface for the development of the user mode driver; the kernel mode driver and the user mode driver are interacted through a sys file system interface, character equipment/dev/deviceX and DMA buffer equipment/dev/u-dmabaufX;
2) when the application program in the user space calls the user mode driver, the user mode driver interacts with the kernel mode driver through the user mode driver, or directly interacts with the kernel mode driver through the character device/dev/deviceX and the DMA buffer device/dev/u-dmabaufX, so that the operation of the designated device is completed.
Optionally, initializing the user mode and kernel mode driver coprocessing framework in step 1) further includes: firstly, constructing a drive equipment structure body and an equipment information structure body in a kernel, wherein the field of each item in the drive equipment structure body comprises an equipment owner, a secondary equipment ID number and an interrupt event count, and the field of each item in the equipment information structure body comprises an equipment name, a drive version, an open function open (), a release function release (), and an interrupt processing function; then, when registering the equipment, associating a corresponding driving equipment structure body and an equipment information structure body for each equipment, and associating an equipment monitor structure body to track the interrupt event counter value of each character equipment/dev/deviceX; the initialization user state and kernel state drive cooperative processing framework tracks the interrupt event counter value of each device through a device listener structure, the kernel state drive judges whether the interrupt event counter in the listener is inconsistent with the interrupt event counter value in the device structure through polling to trigger interrupt processing, and at the moment, an event notifier is called to notify a user state drive to exit a blocking state to execute an interrupt processing function; the interrupt event counters in the device listener fabric are only copied and updated in the execute device open operation open () and read operation read ().
Optionally, initializing the user mode and kernel mode driver cooperative processing framework in step 1) further includes: the user mode and kernel mode driver cooperative processing framework realizes a write operation function wirte (), when the operation function wirte () is called, a disable or enable interrupt function irqcontrol () realized by a kernel mode driver is called to disable or enable interrupt, and if the disable or enable interrupt function irqcontrol () is not realized by the driver, the write operation function wirte () returns that the method does not realize the message-ENOSYS.
Optionally, the step 1) of initializing the user mode and kernel mode to drive the cooperative processing framework further includes the following steps of mapping a physical address to a virtual address: s1) kernel mode driving applies for a memory page; s2) the kernel mode driver creates a sysfs directory through a data communication mechanism based on the sys file system, writes the address and the size, and then transmits the initial address and the size of the physical memory to be shared to a user mode; s3) the user mode driver obtains the initial address and size of the physical memory to be shared through accessing the device attribute file under the system/directory; s4) implements the mapping of the physical memory to the virtual memory by the mapping function mmap ().
Optionally, the step of the kernel mode driver applying for the memory page in step S1) includes: the kernel state driver acquires a memory page application page by adopting a memory page acquisition function get _ order, then calls a physical memory page allocation function get _ free _ page to allocate continuous physical memory pages, and returns a virtual address; and calls a set page reservation flag function SetPageReserved to flag that the page is already occupied.
Optionally, the step of writing the address and the size in step S2) includes: the virtual address and the address size returned by calling the physical memory page allocation function _ get _ free _ page are written into the sysfs attribute file of the device in the sys file system by means of a virtual file system communication mechanism.
Optionally, in step S3), the acquiring, by the user-state driver, the physical memory start address and size to be shared by accessing the device property file in the/sys/directory specifically means that the user-state driver opens the memory device file/dev/mem through an open function open, and takes the physical address read from the virtual file system directory file as the offset of the file/dev/mem and the size as the length.
In addition, the invention also provides a device driving device based on the user mode and kernel mode driving cooperative processing framework, which comprises a microprocessor and a memory which are connected with each other, wherein the microprocessor is programmed or configured to execute the steps of the device driving method based on the user mode and kernel mode driving cooperative processing framework.
In addition, the invention also provides a device driving device based on the user mode and kernel mode driving cooperative processing framework, which comprises a microprocessor and a memory which are connected with each other, wherein the memory is stored with a computer program which is programmed or configured to execute the device driving method based on the user mode and kernel mode driving cooperative processing framework.
In addition, the present invention also provides a computer readable storage medium, in which a computer program programmed or configured to execute the aforementioned device driving method based on the user-mode and kernel-mode driven co-processing framework is stored.
Compared with the prior art, the invention has the following advantages:
1. aiming at the requirements of the prior Linux user mode driver on the consideration of performance and stability and the incompleteness of the prior framework function, the invention realizes the equipment driving method based on the user mode and kernel mode driving cooperative processing framework, the invention finally divides the driver into two parts, and a few parts of functions are realized in the kernel space, and the functions of resource registration and interrupt processing are mainly realized; most function realization is located in user space to complete other work of hardware control, and kernel space and user space under the framework are driven to cooperatively process to jointly complete interaction with hardware. The invention can realize the cooperative processing of the user mode and the kernel mode driver, and jointly complete the interaction with hardware, thereby greatly simplifying the development and maintenance process of the driver and improving the stability and reliability of the kernel.
2. The invention is more suitable for the drive development of the following hardware: (1) the device has a mappable memory. The equipment can be completely controlled by operating the memory. (2) The device will typically generate an interrupt.
3. Although the present invention is also subject to limitations, there are many benefits to using the present invention: (1) only a small kernel module needs to be developed and maintained. (2) Most development work is in user space, so all tools and development libraries can be used. (3) The kernel does not need to be recompiled when the user state driver is updated.
Drawings
FIG. 1 is an architecture diagram of a user-mode and kernel-mode driver co-processing framework in a Linux system according to an embodiment.
Fig. 2 is a schematic diagram of the user-state-driven operation based on the framework provided by the invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the following detailed description of the present invention with reference to the accompanying drawings will specifically describe the implementation method of the present invention. It should be understood that the embodiments described herein are only for explaining the present invention, and are not intended to limit the present invention.
The device driving method based on the user mode and kernel mode driving cooperative processing framework in the embodiment comprises the following steps:
1) as shown in fig. 1, the method for initializing a User mode and kernel mode Driver Framework (User Space Driver Framework, hereinafter referred to as Framework USDF) includes:
a Kernel space driver (Kernel space driver) which operates in a Kernel space as a Loadable Kernel Module (LKM) and is used for providing a stable Kernel space driver development interface;
the user state driver (US driver) is positioned in the user space as a shared library and is used for providing an interface for the development of the user state driver;
the kernel state driver and the user state driver are interacted through a sys file system (sysfs) interface, a character device/dev/deviceX and a DMA buffer device/dev/u-dmabaufx;
2) when the application program in the user space calls the user mode driver, the user mode driver interacts with the kernel mode driver through the user mode driver, or directly interacts with the kernel mode driver through the character device/dev/deviceX and the DMA buffer device/dev/u-dmabaufX, so that the operation of the specified device is completed.
In this embodiment, initializing the user mode and kernel mode driver coprocessing framework in step 1) further includes: firstly, a drive equipment structure body and an equipment information structure body are built in a kernel, the field of each item in the drive equipment structure body comprises an equipment owner, a secondary equipment ID number and an interrupt event count, and the field of each item in the equipment information structure body comprises an equipment name, a drive version, an open function open (), a release function release (), and an interrupt processing function; then, when registering the equipment, associating a corresponding driving equipment structure body and an equipment information structure body for each equipment, and associating an equipment monitor structure body to track the interrupt event counter value of each character equipment/dev/deviceX; the initialization user state and kernel state drive cooperative processing framework tracks the interrupt event counter value of each device through a device listener structure, the kernel state drive judges whether the interrupt event counter in the listener is inconsistent with the interrupt event counter value in the device structure through polling to trigger interrupt processing, and at the moment, an event notifier is called to notify a user state drive to exit a blocking state to execute an interrupt processing function; the interrupt event counter in the device listener structure is only copied and updated in the open operation open () and read operation read () of the executing device.
In this embodiment, initializing the user mode and kernel mode driver coprocessing framework in step 1) further includes: the user mode and kernel mode driver cooperative processing framework realizes a write operation function wirte (), when the operation function wirte () is called, a disable or enable interrupt function irqcontrol () realized by a kernel mode driver is called to disable or enable interrupt, and if the disable or enable interrupt function irqcontrol () is not realized by the driver, the write operation function wirte () returns that the method does not realize the message-ENOSYS.
As shown in fig. 2, when initializing the user mode and kernel mode to drive the cooperative processing framework in step 1) of this embodiment, the following steps of mapping a physical address to a virtual address are further included: s1) kernel mode driving applies for a memory page; s2) the kernel mode driver creates a sysfs directory through a data communication mechanism based on the sys file system, writes addresses and sizes, and accordingly transmits the initial address and the size of the physical memory to be shared to a user mode; s3) the user mode driver acquires the initial address and size of the physical memory to be shared through accessing the device attribute file under the system/sys/directory; s4) implements the mapping of the physical memory to the virtual memory by the mapping function mmap ().
In this embodiment, the step of applying for the memory page by the kernel mode driver in step S1) includes: the kernel state driver acquires a memory page application page by adopting a memory page acquisition function get _ order, then calls a physical memory page allocation function get _ free _ page to allocate continuous physical memory pages, and returns a virtual address; and calls a set page reservation flag function SetPageReserved to flag that the page is already occupied.
In this embodiment, the step of writing the address and the size in step S2) includes: the virtual address and the address size returned by calling the physical memory page allocation function _ get _ free _ page are written into the sysfs attribute file of the device in the sys file system by means of a virtual file system communication mechanism.
In this embodiment, in step S3), the obtaining, by the user state driver, the starting address and the size of the physical memory to be shared through accessing the device attribute file under the/sys/directory specifically means that the user state driver opens the memory device file/dev/mem through the open function open, and takes the physical address read from the virtual file system directory file as the offset of the file/dev/mem and the size as the length. The space of the/dev/mem file is mapped to the user space by the offset and the length, and the process of the user space uses the obtained address to read and write the physical memory device, thereby finally realizing the communication between the kernel space and the user space.
In the user mode and Kernel mode driver cooperative processing framework of this embodiment, a Kernel mode driver operates in a Kernel space as a Loadable Kernel Module (LKM), provides a user space device driver development standard interface, and includes a device registration function, an open/close function, a device query function, a device attribute acquisition function, a memory operation function, and an interrupt processing function. The user mode driver is used as a shared library for a dynamic library developed by the user mode driver, and the library further expands and encapsulates the interface functions and is used for developing the user mode driver. The driver running in the kernel mode is also used as a loadable kernel module, which only needs to realize few functions, most of the functions are completed by the framework, and the work is only two: 1. distributing and recording resources required by the equipment and registering user mode equipment; 2. a small portion of an Interrupt Service Routine (Interrupt Service Routine) is implemented. While most of the rest of the work is performed by the generic API provided by the user-mode and kernel-mode driver co-processing framework. In addition, the user-mode and kernel-mode driver co-processing framework generates a set of directories and property files for each device in sysfs. The user mode driver can search equipment, obtain the address and the size of the mapping memory, the version of the kernel mode driver and the like through the attribute files. After the device is registered, the device node is presented in a/dev/deviceX mode, wherein X represents the secondary ID number of the character device and is increased from 0. The physical addresses of the hardware devices may be accessed by the device nodes, and the framework automatically performs mapping from physical addresses to logical addresses by further encapsulating mmap () functions, while accessing the device's corresponding I/O ports or registers. The mmap () function of the framework improves the safety when the memory is mapped by limiting the function to map only the memory of the device. If the kernel state driver is allocated with a plurality of shared memory spaces, the mmap () function uses the offset parameter to represent which space is mapped. If the nth memory space is to be mapped, then offset = N × getpagesize (). The attribute of the equipment is provided by the equipment file and the sysfs attribute files, and the user state driver acquires the specific attribute of the equipment by accessing the files, so that the communication between the two parties is realized. In the interrupt processing, the kernel mode driver informs the user mode device driver through a blocking call, the blocking call is opened when the interrupt occurs, and meanwhile, if the interrupt frequently occurs, the overhead is reduced by polling. The user state driver running under the framework waits for the occurrence of an interrupt by executing a read () operation to enter a blocking state, and exits the blocking state after receiving the interrupt. The framework also implements poll () system calls, so select () functions can also be used to wait for interrupts, and timeout parameters are provided to implement a wait for interrupts for a limited time. In this embodiment, the device interrupt count uses a signed 32-bit integer, and if the value read by the user state driver is 1 greater than the last value read, then all is normal. If the difference is greater than 1, it indicates that the interrupt was missed. The framework creates and uses the device file/dev/u-dmabaufx as an interface to access the DMA buffer. The user space driver may use the read ()/write () function to make read and write accesses from the user space by mapping the DMA buffer to the user space after opening the device file. The physical address of the assigned DMA buffer will be obtained by storing it in the sysfs attribute file for the user space driver. When the/dev/u-dmabaufx device file is opened, the CPU cache of the allocated DMA buffer may be disabled by setting the O _ SYNC flag. While the CPU cache may also be flushed or invalidated while remaining enabled.
For I/O port access, the framework USDF provides a set of functions for I/O port applications, reading data on the ports, through which the kernel state driver can pass information for one or more port regions to the user space, including the name, start, size and type of the port region to be displayed. The character device/dev/u-dmabaufx is used as a file system interface for accessing the DMA buffer, the DMA buffer is mapped to a user space through a mmap () function after the device is opened, and the mmap () calls a DMA _ alloc _ coherent () function to allocate continuous physical memory through CMA. The framework creates a file attribute file in the sysfs file system for each attribute of the allocated DMA buffers, including physical address, size, sync pattern, sync offset, sync direction, consistency, etc. The driving program running under the framework is divided into two parts: the kernel mode driver is operated in a kernel mode as a simple loadable kernel module, is responsible for creating one or more memory resources and IRQs, and realizes an interrupt handler and registers equipment creating equipment nodes. And secondly, the user mode driver realizes most of driving functions, and maps the memory and receives the interrupt notification by accessing the equipment node. The invention realizes a framework of user mode and kernel mode driver cooperative processing, and provides a method, which can divide a driver into two parts finally, wherein a few parts of functions are realized in a kernel space, and mainly realize resource registration and interrupt processing functions; most of the function implementation is located in user space to accomplish other tasks of hardware control. The framework improves the functional defects of the existing framework, and completes the interaction with hardware together through the kernel space and user space drive cooperative processing. In summary, the device driving method for the user mode and kernel mode driver co-processing framework in this embodiment implements a user mode and kernel mode driver co-processing framework, where the framework is divided into two parts, and one part is used as a loadable kernel module and runs in a kernel space to provide a stable kernel mode driver development interface; and one part is a shared library, and in a user mode, an interface is provided for user mode driven development. The kernel state driver registers as a character device to the framework through an interface provided by the framework and creates a sysfs attribute file, and the user state driver finally completes interaction with the kernel state driver by operating the device such as opening/closing, reading/writing and the like and reading a sysfs file system interface. The framework realizes the DMA support of the user mode by independently creating a character device. The user mode and kernel mode drivers realized under the invention are cooperatively processed to jointly complete the interaction with hardware, thereby greatly simplifying the development and maintenance process of the drivers and improving the stability and reliability of the kernel.
In addition, the present embodiment also provides a device driver apparatus for driving a co-processing framework based on a user mode and a kernel mode, including a microprocessor and a memory, which are connected to each other, where the microprocessor is programmed or configured to execute the steps of the device driving method for driving a co-processing framework based on a user mode and a kernel mode.
In addition, the present embodiment also provides a device driving apparatus based on a user mode and kernel mode driving cooperative processing framework, which includes a microprocessor and a memory connected to each other, where the memory stores a computer program programmed or configured to execute the device driving method based on the user mode and kernel mode driving cooperative processing framework.
In addition, the present embodiment also provides a computer-readable storage medium, where a computer program programmed or configured to execute the device driving method based on the user-mode and kernel-mode driver co-processing framework is stored in the computer-readable storage medium.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein. The present application is directed to methods, apparatus (systems), and computer program products according to embodiments of the present application, wherein the instructions that execute on the flowcharts and/or processors of the computer program product create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and the scope of the present invention is not limited to the above embodiments, and all technical solutions that belong to the idea of the present invention belong to the scope of the present invention. It should be noted that modifications and embellishments within the scope of the invention may occur to those skilled in the art without departing from the principle of the invention, and are considered to be within the scope of the invention.
Claims (7)
1. A device driving method based on a user mode and kernel mode driving cooperative processing framework is characterized by comprising the following steps:
1) initializing a user mode and kernel mode drive cooperative processing framework, wherein the user mode and kernel mode drive cooperative processing framework comprises: the kernel state driver is used as a loadable kernel module to run in a kernel space and is used for providing a stable kernel state driver development interface; the user mode driver is used as a shared library and positioned in a user space and used for providing an interface for the development of the user mode driver; the kernel mode driver and the user mode driver are interacted through a sys file system interface, character equipment/dev/deviceX and DMA buffer equipment/dev/u-dmabaufX;
2) when an application program in a user space calls a user mode driver, the user mode driver interacts with the kernel mode driver through the user mode driver, or directly interacts with the kernel mode driver through a character device/dev/deviceX and a DMA buffer device/dev/u-dmabaufX, so that the operation of a designated device is completed;
when initializing the user mode and kernel mode driver cooperative processing framework in step 1), the method further comprises the following steps: firstly, constructing a drive equipment structure body and an equipment information structure body in a kernel, wherein the field of each item in the drive equipment structure body comprises an equipment owner, a secondary equipment ID number and an interrupt event count, and the field of each item in the equipment information structure body comprises an equipment name, a drive version, an open function open (), a release function release (), and an interrupt processing function; then, when registering the equipment, associating a corresponding driving equipment structure body and an equipment information structure body for each equipment, and associating an equipment monitor structure body to track the interrupt event counter value of each character equipment/dev/deviceX; the initialization user mode and kernel mode drive cooperative processing framework tracks the interrupt event counter value of each device through a device monitor structural body, the kernel mode drive judges whether the interrupt event counter in the monitor is inconsistent with the interrupt event counter value in the device structural body through polling to trigger interrupt processing, and at the moment, an event notifier is called to notify a user mode drive to exit a blocking state to execute an interrupt processing function; the interrupt event counter in the device listener structure is copied and updated only in the open operation open () and the read operation read () of the execution device; the step 1) of initializing the user mode and kernel mode to drive the cooperative processing framework further comprises the following steps of mapping the physical address to the virtual address: s1) kernel mode driving applies for a memory page; s2) the kernel mode driver creates a sysfs directory through a data communication mechanism based on the sys file system, writes the address and the size, and then transmits the initial address and the size of the physical memory to be shared to a user mode; s3) the user mode driver obtains the initial address and size of the physical memory to be shared through accessing the device attribute file under the system/directory; s4) implements the mapping of the physical memory to the virtual memory by the mapping function mmap ().
2. The device driving method according to claim 1, wherein initializing the user-mode and kernel-mode driver co-processing framework in step 1) further comprises: the user mode and kernel mode driver cooperative processing framework realizes a write operation function wirte (), when the operation function wirte () is called, a disable or enable interrupt function irqcontrol () realized by a kernel mode driver is called to disable or enable interrupt, and if the disable or enable interrupt function irqcontrol () is not realized by the driver, the write operation function wirte () returns that the method does not realize the message-ENOSYS.
3. The device driving method based on the user mode and kernel mode driver cooperative processing framework as claimed in claim 1, wherein the step of the kernel mode driver applying for the memory page in step S1) includes: the kernel state driver acquires a memory page application page by adopting a memory page acquisition function get _ order, then calls a physical memory page allocation function get _ free _ page to allocate continuous physical memory pages, and returns a virtual address; and calls a set page reservation flag function SetPageReserved to flag that the page is already occupied.
4. The device driving method based on the user-mode and kernel-mode driver co-processing framework according to claim 3, wherein the step of writing the address and size in step S2) comprises: the virtual address and the address size returned by calling the physical memory page allocation function _ get _ free _ page are written into the sysfs attribute file of the device in the sys file system by means of a virtual file system communication mechanism.
5. The device driving method according to claim 3, wherein in step S3), the user state driver obtains the physical memory start address and size to be shared by accessing the device attribute file under the/sys/directory in the user state driver, specifically, the user state driver opens the memory device file/dev/mem through an open function open, and takes the physical address read from the virtual file system directory file as the offset of the file/dev/mem and the size as the length.
6. A device driving apparatus based on a user-mode and kernel-mode driving cooperative processing framework, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the steps of the device driving method based on the user-mode and kernel-mode driving cooperative processing framework according to any one of claims 1 to 5.
7. A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, the computer program being programmed or configured to execute the device driving method based on the user-mode and kernel-mode driver co-processing framework according to any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011233583.4A CN112231007B (en) | 2020-11-06 | 2020-11-06 | Device driving method based on user mode and kernel mode driving cooperative processing framework |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011233583.4A CN112231007B (en) | 2020-11-06 | 2020-11-06 | Device driving method based on user mode and kernel mode driving cooperative processing framework |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112231007A CN112231007A (en) | 2021-01-15 |
CN112231007B true CN112231007B (en) | 2022-08-19 |
Family
ID=74123391
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011233583.4A Active CN112231007B (en) | 2020-11-06 | 2020-11-06 | Device driving method based on user mode and kernel mode driving cooperative processing framework |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112231007B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112817986B (en) * | 2021-02-26 | 2022-03-22 | 北京易捷思达科技发展有限公司 | Data structure repairing method and device suitable for Linux production environment |
CN114296808B (en) * | 2021-12-23 | 2022-12-02 | 科东(广州)软件科技有限公司 | Pin configuration method and device, electronic equipment and storage medium |
CN117407054A (en) * | 2022-07-07 | 2024-01-16 | 华为技术有限公司 | Interrupt processing method, electronic device, and storage medium |
CN115391066B (en) * | 2022-08-31 | 2023-06-30 | 瀚博半导体(上海)有限公司 | Data interaction method and device for chip and artificial intelligent chip |
CN115840938B (en) * | 2023-02-21 | 2023-05-09 | 山东捷讯通信技术有限公司 | File monitoring method and device |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104123194A (en) * | 2014-07-16 | 2014-10-29 | 上海斐讯数据通信技术有限公司 | Communication structure and method for kernel mode and user mode |
CN105022954A (en) * | 2015-07-07 | 2015-11-04 | 中国人民解放军国防科学技术大学 | Dynamic running method for security kernel service of tristate operating system in Feiteng CPU |
CN111858004A (en) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | TEE expansion-based real-time application dynamic loading method and system for computer security world |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8434098B2 (en) * | 2008-02-07 | 2013-04-30 | Microsoft Corporation | Synchronizing split user-mode/kernel-mode device driver architecture |
US8806511B2 (en) * | 2010-11-18 | 2014-08-12 | International Business Machines Corporation | Executing a kernel device driver as a user space process |
-
2020
- 2020-11-06 CN CN202011233583.4A patent/CN112231007B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104123194A (en) * | 2014-07-16 | 2014-10-29 | 上海斐讯数据通信技术有限公司 | Communication structure and method for kernel mode and user mode |
CN105022954A (en) * | 2015-07-07 | 2015-11-04 | 中国人民解放军国防科学技术大学 | Dynamic running method for security kernel service of tristate operating system in Feiteng CPU |
CN111858004A (en) * | 2020-07-21 | 2020-10-30 | 中国人民解放军国防科技大学 | TEE expansion-based real-time application dynamic loading method and system for computer security world |
Also Published As
Publication number | Publication date |
---|---|
CN112231007A (en) | 2021-01-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112231007B (en) | Device driving method based on user mode and kernel mode driving cooperative processing framework | |
US10846145B2 (en) | Enabling live migration of virtual machines with passthrough PCI devices | |
KR0170565B1 (en) | Method and apparatus for management of mapped and unmapped regions of memory in a microkernel data processing system | |
US9218302B2 (en) | Page table management | |
US8151275B2 (en) | Accessing copy information of MMIO register by guest OS in both active and inactive state of a designated logical processor corresponding to the guest OS | |
US10740148B2 (en) | Accelerated data operations in virtual environments | |
US20090106479A1 (en) | Managing memory systems containing components with asymmetric characteristics | |
US11836091B2 (en) | Secure memory access in a virtualized computing environment | |
US10565131B2 (en) | Main memory including hardware accelerator and method of operating the same | |
US8065441B2 (en) | Method and apparatus for supporting universal serial bus devices in a virtualized environment | |
TWI783034B (en) | System and method for implementing drive | |
CN112732344A (en) | Cooperative work system and method of user mode driver and kernel mode driver | |
US20080010432A1 (en) | System and Method for Thread Creation and Memory Management In An Object-Oriented Programming Environment | |
US8887162B2 (en) | Persistent local storage for processor resources | |
TWI452468B (en) | Method for sharing memory of virtual machine and computer system using the same | |
Leis et al. | Cloud-Native Database Systems and Unikernels: Reimagining OS Abstractions for Modern Hardware | |
Bell et al. | Hardware Acceleration with Zero-Copy Memory Management for Heterogeneous Computing | |
US7694301B1 (en) | Method and system for supporting input/output for a virtual machine | |
US11385927B2 (en) | Interrupt servicing in userspace | |
US20230027307A1 (en) | Hypervisor-assisted transient cache for virtual machines | |
Bindhammer et al. | Device driver programming in a transactional DSM operating system | |
Yang et al. | A RISC-V On-chip Operating System Based on Rust | |
Dibble et al. | Programming embedded systems: interacting with the embedded platform | |
CN112347058A (en) | Data encryption and decryption method, system and equipment | |
CN118069373A (en) | Electronic component, electronic device and memory management method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |