CN110489212B - Universal input/output port virtualization method and device and vehicle machine - Google Patents

Universal input/output port virtualization method and device and vehicle machine Download PDF

Info

Publication number
CN110489212B
CN110489212B CN201910770092.4A CN201910770092A CN110489212B CN 110489212 B CN110489212 B CN 110489212B CN 201910770092 A CN201910770092 A CN 201910770092A CN 110489212 B CN110489212 B CN 110489212B
Authority
CN
China
Prior art keywords
operating system
gpio port
end driver
port corresponding
interrupt
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
Application number
CN201910770092.4A
Other languages
Chinese (zh)
Other versions
CN110489212A (en
Inventor
付永杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Dongsoft Group Dalian Co ltd
Neusoft Corp
Original Assignee
Dongsoft Group Dalian Co ltd
Neusoft Corp
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Dongsoft Group Dalian Co ltd, Neusoft Corp filed Critical Dongsoft Group Dalian Co ltd
Priority to CN201910770092.4A priority Critical patent/CN110489212B/en
Publication of CN110489212A publication Critical patent/CN110489212A/en
Application granted granted Critical
Publication of CN110489212B publication Critical patent/CN110489212B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/102Program control for peripheral devices where the programme performs an interfacing function, e.g. device driver
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4411Configuring for operating with peripheral devices; Loading of device drivers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Abstract

The application discloses a method and a device for virtualizing a universal input/output port and a vehicle machine. The method is applied to a system on chip, and the system on chip at least runs a main operating system and a slave operating system; the master operating system directly controls a physical general purpose input output port GPIO port, and the slave operating system uses a virtual GPIO port through the master operating system; the method comprises the following steps: a back-end driver of the main operating system receives a request which is sent by a front-end driver of the slave operating system side and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port; the rear end of the main operating system drives a sysfs file for exporting the GPIO ports corresponding to the serial numbers so as to enable the GPIO ports corresponding to the serial numbers; and the rear end driver of the main operating system receives the direction of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system side, wherein the direction is input or output. By using the method, the GPIO ports can be simultaneously used by the main operating system and the slave operating system so as to meet the requirements of practical application scenes.

Description

Universal input/output port virtualization method and device and vehicle machine
Technical Field
The invention relates to the technical field of vehicle control, in particular to a method and a device for virtualizing a universal input/output port and a vehicle machine.
Background
The open source project ACRN is a virtualization scheme customized for embedded development, and has been gradually applied to the fields of industrial automation, IoT (Internet of Things), vehicle-mounted electronic intelligent cabin systems and the like because of its characteristics of light weight, real-time performance, open source and the like.
The ACRN supports a plurality of operating systems including a Linux System and an Android System, and also supports a plurality of operating systems, which are based on a Linux kernel, to be simultaneously run on the same SOC (System on Chip). In particular, one or more slave operating systems may be run simultaneously with one master operating system. Wherein, the main operating system is an SOS (Service OS), and the SOS is a Linux system; the slave operating system is a UOS (User OS), and the UOS may be an Android system or a Linux system.
At present, in a vehicle-mounted electronic intelligent cabin system, a GPIO (General Purpose Input Output) port is required to be used by both a master operating system and a slave operating system in many practical application scenarios, such as power control, notification of an abnormal detection state of a peripheral IC (Integrated Circuit), notification of an MCU (micro controller Unit) and notification of an SOC start state. At present, the ACRN cannot support the GPIO port to be used by the master operating system and the slave operating system at the same time, and only can use the GPIO port at one side of the master operating system or the slave operating system, so that the requirements of practical application scenes cannot be met.
Disclosure of Invention
In order to solve the technical problems in the prior art, the application provides a method, a device and a vehicle machine for virtualization of a general input/output port, which can enable a master operating system and a slave operating system to simultaneously use GPIO ports so as to meet the requirements of practical application scenarios.
The application provides a method for virtualizing a universal input/output port, which is applied to a system on chip, wherein the system on chip at least runs the following two different operating systems: a master operating system and a slave operating system; the master operating system directly controls a physical general purpose input output port GPIO port, and the slave operating system uses a virtual GPIO port through the master operating system;
the method comprises the following steps:
the back end driver of the main operating system receives a request which is sent by the front end driver of the slave operating system side and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port;
the rear end of the main operating system drives and derives the sysfs file of the GPIO port corresponding to the serial number so as to enable the GPIO port corresponding to the serial number;
and the rear end driver of the main operating system receives the direction of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system side, wherein the direction is input or output.
Optionally, when the direction of the GPIO port corresponding to the serial number is input, the method further includes:
the back end driver of the main operating system receives a read operation request which is sent by the front end driver of the auxiliary operating system and is used for reading the GPIO port corresponding to the serial number;
the rear end driver of the main operating system reads the value of the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number;
and the back end driver of the master operating system returns the value of the GPIO port corresponding to the serial number to the front end driver of the slave operating system.
Optionally, when the direction of the GPIO port corresponding to the number is input and the GPIO port corresponding to the number is defined as an interrupt port, the method further includes:
the back end driver of the main operating system receives the interrupt type of the GPIO port corresponding to the serial number sent by the front end driver of the auxiliary operating system, wherein the interrupt type is as follows: edge-triggered or level-triggered; the edge triggers include single edge triggers and dual edge triggers.
Optionally, when the interrupt type of the GPIO port corresponding to the number is defined as edge triggering, the method further includes:
when the rear-end driver of the main operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interruption type is edge triggering, the interruption is directly injected into the front-end driver of the slave operating system;
when the interrupt type of the GPIO port corresponding to the number is defined as level trigger, the method further includes:
and when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interruption type is level triggering, the slave operating system reads the value of the physical GPIO port corresponding to the serial number, and when the interruption type meets the level triggering interruption according to the value of the physical GPIO port, the master operating system injects the interruption into the front-end driver of the slave operating system.
Optionally, when the direction of the GPIO port corresponding to the serial number is output, the method further includes:
the back end driver of the main operating system receives a write operation request which is sent by the front end driver of the auxiliary operating system and is used for the GPIO port corresponding to the serial number; the request carries a value to be written into by the GPIO port corresponding to the serial number;
and the rear end driver of the main operating system writes the value to be written into the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number.
The present application further provides a device for universal type input/output port virtualization, the device comprising: a first receiving unit, an enabling unit and a second receiving unit;
the first receiving unit is used for receiving a request which is sent by a front-end driver on the side of the slave operating system and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port;
the enabling unit is used for deriving the sysfs file of the GPIO port corresponding to the serial number so as to enable the GPIO port corresponding to the serial number;
the second receiving unit is configured to receive a direction of the GPIO port corresponding to the serial number, where the direction is input or output, and the GPIO port is sent by the front-end driver on the slave operating system side.
Optionally, the apparatus further comprises: a third receiving unit, a reading unit and a returning unit;
the third receiving unit is configured to receive a read operation request, sent by the front-end driver of the slave operating system, for the GPIO port corresponding to the serial number;
the reading unit is used for reading the value of the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number;
and the return unit is used for returning the value of the GPIO port corresponding to the serial number to the front-end driver of the slave operating system.
Optionally, the apparatus further comprises: a fourth receiving unit;
the fourth receiving unit is configured to receive an interrupt type of the GPIO port corresponding to the number and sent by the front-end driver of the slave operating system, where the interrupt type is: edge-triggered or level-triggered; the edge triggers include single edge triggers and dual edge triggers.
Optionally, when the interrupt type of the GPIO port corresponding to the number is defined as edge triggering, the apparatus further includes: a first interrupt injection unit;
the first interrupt injection unit is used for directly injecting the interrupt to the front-end driver of the slave operating system when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interrupt type is edge trigger;
when the interrupt type of the GPIO port corresponding to the number is defined as level triggering, the apparatus further includes: a second interrupt injection unit;
and the second interrupt injection unit is used for reading the value of the physical GPIO port corresponding to the number by the slave operating system when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the number is interrupted and judges that the interrupt type is level trigger, and injecting the interrupt into the front-end driver of the slave operating system when the interrupt meeting the level trigger interrupt is determined according to the value of the physical GPIO port.
The application also provides a car machine, the car machine includes the system on chip, the system on chip includes above arbitrary the device of general type I/O virtualization.
Compared with the prior art, the method has the advantages that:
the method can be applied to a system-on-chip running at least two different operating systems: a master operating system and a slave operating system. Wherein, the general type IO mouth of main operating system direct control physics, the slave operating system uses virtual GPIO mouth through main operating system, specifically is: a back-end driver of the main operating system receives a request for using a virtual GPIO port, which is sent by a front-end driver of a slave operating system side, wherein the request carries the number of the GPIO port, the front-end system is used as a virtual GPIO port controller driver, and the back-end driver realizes the virtualization of GPIO port hardware; the back end of the main operating system drives a sysfs file for exporting the GPIO port corresponding to the serial number so as to enable the GPIO port corresponding to the serial number; the back end driver of the main operating system receives the direction of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system side, and the direction is input or output, even if the slave operating system can realize input and output through the GPIO port. By using the method provided by the embodiment of the application, the same GPIO can be simultaneously used by the master operating system and the slave operating system so as to meet the requirements of actual application scenarios.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a diagram illustrating a software architecture of a system on a chip according to the present application;
fig. 2 is a flowchart of a method for universal i/o virtualization according to an embodiment of the present disclosure;
fig. 3 is a flowchart of another method for general-purpose i/o virtualization according to a second embodiment of the present disclosure;
fig. 4 is a schematic diagram of a general-purpose type i/o virtualization apparatus according to a third embodiment of the present application;
fig. 5 is a schematic view of a vehicle machine provided in the fourth embodiment of the present application.
Detailed Description
At present, the ACRN cannot support the simultaneous use of GPIO ports by a main operating system and a slave operating system, and can only use GPIO at one side of the main operating system or the slave operating system, so that the requirements of practical application scenes cannot be met. The following description specifically takes the application of ACRN to an on-vehicle electronic intelligent cockpit system as an example.
For an ACRN-based onboard electronic intelligent cockpit system, its Instruments (ICs) run in the SOS (Service OS), which is a Linux system. Meanwhile, the IVI (In-Vehicle Infotainment) runs on one or more UOS (User OS), which may be an Android system or a Linux system.
For an actual vehicle-mounted electronic intelligent cabin system, many scenarios such as power supply control, detection state notification of peripheral IC abnormality (for example, overcurrent occurs when a USB interface is plugged into or unplugged from a peripheral device), MCU (micro controller Unit), SOC start state notification, and the like require that the SOS and the UOS use GPIO (General Purpose Input Output) at the same time. At present, the ACRN cannot support the SOS and the UOS to simultaneously use the same GPIO, and can only use the GPIO on one side of the SOS or the UOS, thereby influencing the function realization in practical application. It can be understood that the GPIO of the actual hardware includes many GPIO ports, and the GPIO port in the embodiment of the present application generally refers to one GPIO port in the GPIO hardware. When the UOS uses a plurality of GPIO ports, the use of the plurality of GPIO ports is required.
In order to solve the technical problems in the prior art, the application provides a method for virtualizing a general input/output port, which enables a master operating system to directly control a physical general input/output port GPIO port, and a slave operating system to use the virtual GPIO port through the master operating system, so that the master operating system and the slave operating system can simultaneously use the same physical GPIO, thereby meeting the requirements of actual application scenarios.
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment is as follows:
the embodiment of the application provides a method for virtualizing a universal input/output port, which is applied to a system on chip, wherein the system on chip at least runs the following two different operating systems: a master operating system and a slave operating system. The master operating system directly controls the physical GPIO port, and the slave operating system uses the virtual GPIO port through the master operating system. The master operating system and the slave operating system are based on Linux kernel, and the slave operating system may be multiple, and the specific number depends on the application scenario and the hardware capability, which is not specifically limited in the present application.
The software architecture of the system on chip is first explained in detail with reference to the drawings.
Referring to fig. 1, a diagram of a software architecture of a system on chip according to an embodiment of the present application is shown.
Wherein, the main operating system may be an SOS100, specifically, a Linux system; the slave operating system may be the UOS 200.
When the system on chip only runs one UOS, the UOS can be an Android system or a Linux system. When the system on chip runs a plurality of UOSs, the UOSs may all be Android systems, or all be Linux systems, or part of the UOSs may be Android systems, and part of the UOSs may be Linux systems.
The Linux system can adopt the pinctrl subsystem to manage all I/O pins including GPIOs, and has corresponding configuration modes for peripheral pins of the device.
The front-end driver 201 runs in the Linux kernel of the UOS200 and serves as a virtual GPIO controller driver.
The backend driver 101 runs in the ACRN-DM of the SOS100, and implements virtualization of GPIO hardware, and the device type thereof may be a PCI (Peripheral Component Interconnect) device.
The back-end driver 101 and the front-end driver 201 communicate with each other through MMIO (Memory-mapped I/O).
Referring to fig. 2, a flowchart of a method for virtualization of a general purpose type i/o port according to an embodiment of the present disclosure is shown.
The method comprises the following steps:
step 301: a back-end driver of the main operating system receives a request which is sent by a front-end driver of the slave operating system side and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port.
In actual use, the GPIO ports on the SOS100 side and the UOS200 side are numbered the same, and all physical GPIO ports are visible to the UOS 200.
When the UOS200 needs to operate on a GPIO port, a request to use the virtual GPIO port is first sent through the front-end driver 201, which is received by the back-end driver 101 of the SOS100 through MMIO.
The request for using the virtual GPIO port carries the number of the GPIO port. It should be noted that both SOS100 and UOS200 may access all GPIO ports, but the same GPIO port may only be exclusively owned by the SOS100 or UOS200 side, so the GPIO port that UOS200 applies for operation cannot be the GPIO port used by SOS 100.
Step 302: and the back end of the main operating system drives the sysfs file for exporting the GPIO ports corresponding to the serial numbers so as to enable the GPIO ports corresponding to the serial numbers.
The sysfs is a memory-based file system that functions to provide kernel information to user programs in the form of files. sysfs has two sets of interfaces, one for kernel space for mapping devices into the file system and another for user space for reading or operating the devices. The embodiment can map the GPIO port corresponding to the number into the file system through the sysfs file 102, and can enable the GPIO port corresponding to the number through the sysfs file 102.
Step 303: and the rear end driver of the main operating system receives the direction of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system side, wherein the direction is input or output.
Virtualization of the basic function of the GPIO port includes setting the direction of the GPIO port, wherein the direction of the GPIO port can be defined as an input or an output, i.e., IN or OUT. The front-end driver 201 of the UOS200 transmits the direction of the GPIO port corresponding to the number, and is received by the back-end driver 101 of the SOS100 through MMIO.
The back-end driver 101 exports the sysfs file corresponding to the GPIO port corresponding to the serial number, thereby enabling the GPIO port and realizing the setting of the direction of the GPIO port. Specifically, the back-end driver 101 may convert the sysfs file into actual hardware operations through the physical GPIO driver 103, thereby enabling the GPIO port.
Further, when the direction of the GPIO port corresponding to the serial number is input, the method may further include the steps of:
step 303 a: and the back end driver of the main operating system receives the read operation request of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system.
Step 303 b: and the rear end driver of the main operating system reads the value of the corresponding GPIO port through the sysfs file of the GPIO port corresponding to the serial number.
The GPIO port may have a high level and a low level, where the high level corresponds to a value of 1 and the low level corresponds to a value of 0.
Step 303 c: and the back end driver of the master operating system returns the value of the GPIO port corresponding to the serial number to the front end driver of the slave operating system.
The above describes a case where the direction of the GPIO port is input, and the following describes that when the direction of the GPIO port corresponding to the serial number is output, the method may further include the following steps:
step 303 d: the back end driver of the main operating system receives a write operation request which is sent by the front end driver of the slave operating system and corresponds to the GPIO port with the serial number; and requesting to carry the value which needs to be written into by the GPIO port corresponding to the serial number.
Step 303 e: and the rear end driver of the main operating system writes the values to be written into the GPIO ports corresponding to the numbers into the corresponding GPIO ports through the sysfs files of the GPIO ports corresponding to the numbers.
The method for virtualizing the general input/output port is applied to a system on chip, a main operating system running on the system on chip directly controls a physical general input/output port GPIO port, at least one slave operating system running on the system on chip, and the slave operating system uses a virtual GPIO port through the main operating system. By using the method provided by the embodiment of the application, the master operating system and the slave operating system can simultaneously use the same hardware GPIO to meet the requirements of actual application scenarios.
Furthermore, since the slave operating system can use the virtualized GPIO port as using the physical GPIO port, for some programs that need to use the physical GPIO port, these programs can be directly transplanted to the slave operating system without modification, and the development period of the programs can be reduced.
The above embodiment describes the working principle of the slave operating system for implementing direction setting of the GPIO port and reading and writing of the value of the GPIO port through the master operating system, and the working principle of the slave operating system for implementing GPIO port interrupt virtualization through the master operating system is described below with reference to the accompanying drawings.
Example two:
referring to fig. 3, this figure is a flowchart of another method for universal type i/o virtualization according to the second embodiment of the present application.
The method shown in the figure realizes the virtualization of GPIO interrupt, wherein the UOS is a slave operating system, and the SOS is a master operating system.
Interrupt types may include: edge triggered (edge triggered) or level triggered (level triggered). The edge trigger comprises a single edge trigger and a double edge trigger. The single-edge trigger may specifically include a rising-edge trigger and a falling-edge trigger.
When the interrupt type is triggered by a rising edge, the value of the physical GPIO port is changed from 0 to 1;
when the interrupt type is falling edge trigger, the value of the physical GPIO port is changed from 1 to 0.
Because level triggering cannot be directly realized, level triggering can be realized by edge triggering simulation, specifically by rising edge triggering and falling edge triggering simulation, for example, high level triggering can be converted into first rising edge triggering and then falling edge triggering, and at this time, the value of the GPIO port is changed from 0 to 1 and then from 1 to 0. The low level trigger can be converted into a state that a falling edge trigger occurs first and then a rising edge trigger occurs, and at the moment, the value of the GPIO port is changed from 1 to 0 and then is changed from 0 to 1.
With continued reference to fig. 1, all the interrupt type simulations are implemented in the back-end driver of the main operating system SOS, and since the interrupt types provided by the GPIO subsystem (including the gpiolib subsystem and the interrupt subsystem) through the sysfs interface are only edge-triggered and not level-triggered, the level-triggered interrupt needs to be converted into an edge-triggered type, specifically, implemented by dual-edge triggered simulation. When the interrupt is of the edge triggered type, the interrupt type setting of the SOS is the same as the UOS. When the SOS receives the interrupt trigger of the physical GPIO, the judgment is not made, and the interrupt is directly injected into the UOS, so that the response speed of the UOS to the interrupt of the edge trigger type can be improved. When the method is applied, all GPIO ports share one interrupt number so as to identify interrupt and inject the interrupt.
The method specifically comprises the following steps:
step 401: the front-end driver of the UOS sends a request to the back-end driver of the SOS to use the virtual GPIO port.
And the request for using the virtual GPIO port carries a number corresponding to the GPIO port.
Step 402: and the back end driver of the SOS writes the serial number corresponding to the GPIO port into the sysfs file.
Step 403: and the front end driver of the UOS sets the direction of the GPIO port corresponding to the serial number as input.
Step 404: the back end driver of the SOS sets the direction of the GPIO port corresponding to the serial number as input through the sysfs file. It should be noted that, when the GPIO port is used as the interrupt port, its direction needs to be set as an input, i.e., IN.
Step 405: the front-end driver of the UOS enables interrupts.
And the front-end driver of the UOS defines the GPIO port corresponding to the serial number as an interrupt port.
Step 406: the back-end driver of the SOS adds the sysfs file for the GPIO port to the epoll queue.
And the back-end driver of the SOS intercepts and captures the operation that the GPIO port corresponding to the serial number is defined as a middle fracture port by the front-end driver of the UOS, and the back-end driver adds the sysfs file of the physical GPIO port to the epoll monitoring queue.
epoll is the poll improved by Linux kernel for processing large-batch file descriptors, can significantly improve the utilization rate of a system CPU of a program under the condition that only a small amount of concurrent connections are active, can obtain an event without traversing the whole intercepted descriptor set, and only traverses the descriptor set asynchronously awakened by kernel IO event and added into a ready queue. epoll provides edge triggering in addition to horizontal triggering of IO events, so that a user space may cache an IO state, reduce invocation of epoll _ wait and epoll _ pwait, and improve application efficiency.
Specifically, the back-end driver adds a value attribute file in the sysfs file corresponding to the physical GPIO port to the epoll monitoring queue, where the value attribute file includes a value of the corresponding physical GPIO port.
Step 407: and the front-end driver of the UOS sets the interrupt type of the GPIO port corresponding to the serial number. The interrupt type is edge triggered or level triggered.
Step 408: and the back end driver of the SOS receives the interrupt type of the GPIO port corresponding to the serial number sent by the front end driver of the UOS, and if the interrupt type is an edge trigger type, the interrupt is directly set to the SOS. If the interrupt type is a level trigger type, the interrupt type is converted into a double-edge trigger type and then set to the SOS.
And the UOS sets the interrupt type of the GPIO port, the operation is intercepted by a back-end driver of the SOS, and if the interrupt type is one of edge trigger types, the back-end driver directly sets the interrupt type to the physical GPIO port through a sysfs file. If the interrupt is a level trigger type, the back end drive converts the level trigger type into a double-edge trigger type, namely, the level trigger type is formed by simulating a rising edge and a falling edge, and then the double-edge trigger type is set to a physical GPIO port.
Step 409: the interrupt type is determined by epoll loop.
And the back end driver of the SOS monitors a value attribute file in the sysfs file of the GPIO port in an epoll mode, and further monitors whether the GPIO port has interruption or not. For example, when the value of the physical GPIO port included in the value attribute file changes from 0 to 1, an edge-triggered interrupt, specifically, a rising edge trigger, occurs.
When the physical GPIO port has an interrupt, the back end of the SOS drives the epoll waiting function to release the block, and judges the interrupt type of the physical GPIO port.
And when the interrupt type of the GPIO port corresponding to the number is defined as edge triggering and the rear-end drive of the SOS judges that the physical GPIO port corresponding to the number is interrupted, the interrupt is directly injected into the front-end drive of the UOS when the interrupt type is judged to be edge triggering.
When the interrupt type of the GPIO port corresponding to the number is defined as level triggering and the rear-end drive of the SOS judges that the physical GPIO port corresponding to the number is interrupted, when the SOS judges that the interrupt type is level triggering, the UOS reads the value of the physical GPIO port corresponding to the number, and when the interrupt type meets the level triggering interrupt according to the value of the physical GPIO port, the interrupt is injected into the front-end drive of the UOS. Specifically, the SOS determines whether the level triggered interrupt is satisfied by the value of the GPIO.
Step 410: triggering the interrupt service routine of the UOS.
And triggering an interrupt service program of the UOS after the SOS injects the interrupt to the front-end drive of the UOS. In addition, the SOS records the GPIO port where the interrupt occurs, so that the UOS can read the GPIO port.
Step 411: the UOS reads the values of all GPIO interrupt registers.
Each GPIO port corresponds to one interrupt register, and the UOS reads the values of all the GPIO interrupt registers to determine the GPIO port with the interrupt.
Step 412: the UOS returns the value of the interrupt register to the SOS.
Step 413: the UOS triggers the GPIO port interrupt function.
And after the GPIO port is interrupted, an interrupt register corresponding to a virtual GPIO port of the UOS is set by the SOS.
By using the method for virtualizing the general purpose input/output port provided by the embodiment of the application, the slave operating system realizes the virtualization of the basic functions of the GPIO, specifically including the setting and reading of the direction of the GPIO port, the value of the GPIO port and the interrupt type. When the virtualization of the interrupt function is realized, the interrupt type of the GPIO port is directly set as the edge trigger type for the interrupt type of the GPIO port which is edge triggered; and for the GPIO port with the interrupt type being level trigger, setting the interrupt type as a double-edge trigger type. Each GPIO port is provided with a corresponding sysfs file, the main operating system can determine the GPIO port with interruption through the sysfs file corresponding to the GPIO port, and then obtains the value of the GPIO port according to the value attribute file in the sysfs file, when the interruption type of the GPIO port is an edge trigger type, the interruption is directly injected into the auxiliary operating system, and further the interruption time delay is reduced; and when the interrupt type of the GPIO port is a level trigger type, reading the value of the current GPIO port to judge whether the level trigger condition is met, injecting the interrupt into the slave operating system when the trigger condition is met, and further realizing the interrupt of the level trigger type through the interrupt simulation of the double-edge trigger type.
Example three:
based on the method for virtualizing a universal input/output port provided by the above implementation, an embodiment of the present application further provides a device for virtualizing a universal input/output port, where the device may be integrated into a system on chip, and the system on chip runs at least two different operating systems: a master operating system and a slave operating system. The master operating system and the slave operating system are based on Linux kernel, and there may be a plurality of slave operating systems, where the specific number depends on an application scenario and hardware capability, and the application is not particularly limited thereto. The following detailed description is made with reference to the accompanying drawings.
Referring to fig. 4, this figure is a schematic diagram of a device for common type i/o virtualization according to a third embodiment of the present application.
The device includes: a first receiving unit 501, an enabling unit 502 and a second receiving unit 503.
A first receiving unit 501, configured to receive a request sent from a front-end driver on the operating system side to use a virtual GPIO port.
The request for using the virtual GPIO port carries the number of the GPIO port.
The master operating system and the slave operating system can access all the GPIO ports, but the same GPIO port can only be exclusively occupied by the master operating system or the slave operating system, so that the GPIO port which the slave operating system applies for operation cannot be the GPIO port used by the master operating system.
And an enabling unit 502, configured to derive the sysfs file of the GPIO port corresponding to the number, so as to enable the GPIO port corresponding to the number.
And a second receiving unit 503, configured to receive a direction of the GPIO port corresponding to the number sent by the front-end driver on the operating system side, where the direction is input or output.
Virtualization of the basic function of the GPIO port includes setting the direction of the GPIO port, wherein the direction of the GPIO port can be defined as an input or an output, i.e., IN or OUT.
Further, when the direction of the GPIO port corresponding to the serial number is input, the apparatus further includes: a third receiving unit 504, a reading unit 505 and a returning unit 506.
The third receiving unit 504 is configured to receive a read operation request sent from a front-end driver of the operating system to the GPIO port corresponding to the number.
And the reading unit 505 is configured to read the value of the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number.
The GPIO port may have a high level and a low level, where the high level corresponds to a value of 1 and the low level corresponds to a value of 0.
And a returning unit 506, configured to return the value of the GPIO port corresponding to the number to the front-end driver of the slave operating system.
When the direction of the GPIO port corresponding to the serial number is output, the apparatus may further include: a fourth receiving unit 507 and a writing unit 508.
The fourth receiving unit 507 is configured to receive a write operation request sent from a front-end driver of the operating system to the GPIO port corresponding to the serial number.
The request carries a value which needs to be written into the GPIO port corresponding to the serial number.
And the writing unit 508 is configured to write, through the sysfs file of the GPIO port corresponding to the serial number, a value that needs to be written in by the GPIO port corresponding to the serial number into the GPIO port corresponding to the serial number.
Further, in order to implement virtualization of the GPIO port interrupt function, the apparatus further includes: a fourth receiving unit 509.
A fourth receiving unit 509, configured to receive an interrupt type of a GPIO port corresponding to a serial number sent by a front-end driver of the operating system.
The interrupt types are: edge triggered or level triggered. The edge trigger comprises a single edge trigger and a double edge trigger. The single-edge trigger may specifically include a rising-edge trigger and a falling-edge trigger.
When the interrupt type is triggered by a rising edge, the value of the physical GPIO port is changed from 0 to 1;
when the interrupt type is falling edge trigger, the value of the physical GPIO port is changed from 1 to 0.
The level triggering can be realized by edge triggering simulation, and particularly can be realized by rising edge triggering and falling edge triggering simulation.
When the interrupt type of the GPIO port corresponding to the number is defined as edge triggered, the apparatus may further include: a first interrupt injection unit 510.
And a first interrupt injection unit 510, configured to inject an interrupt to the front-end driver of the slave operating system when the back-end driver of the master operating system determines that the physical GPIO port corresponding to the learned number is interrupted and determines that the interrupt type is edge triggered.
When the interrupt type of the GPIO port corresponding to the number is defined as level trigger, the apparatus may further include: the second interrupt injection unit 511.
And the second interrupt injection unit 511 is configured to, when the rear-end driver of the master operating system determines that the physical GPIO port corresponding to the serial number is interrupted and determines that the interrupt type is level-triggered, read the value of the physical GPIO port corresponding to the serial number from the slave operating system, and inject an interrupt to the front-end driver of the slave operating system when it is determined that the level-triggered interrupt is satisfied according to the value of the physical GPIO port.
For specific working principles of each unit of the device, reference may be made to the relevant descriptions of the first embodiment and the second embodiment, which are not described herein again.
The device provided by the embodiment of the application can be applied to a system on chip, a main operating system running on the system on chip directly controls a physical general purpose input/output port GPIO port, and at least one slave operating system running on the system on chip uses a virtual GPIO port through the main operating system. By utilizing the device provided by the embodiment of the application, the GPIO can be simultaneously used by the master operating system and the slave operating system so as to meet the requirements of practical application scenarios.
Furthermore, since the slave operating system can use the virtualized GPIO port as the physical GPIO port, for some programs that need to use the physical GPIO port, these programs can be directly transplanted to the slave operating system without modification, and the development cycle of the programs can also be reduced.
In addition, when the virtualization of the interrupt function is realized, the interrupt type of the GPIO port is directly set as the edge trigger type for the interrupt type; and for the GPIO port with the interrupt type being level trigger, setting the interrupt type as a double-edge trigger type. Each GPIO port is provided with a corresponding sysfs file, the reading unit can determine the GPIO port with interruption through the sysfs files corresponding to the GPIO ports, further obtains the value of the GPIO port according to the value attribute file in the sysfs files, and determines the interruption type of the GPIO port according to the obtained value of the GPIO port. When the interrupt type of the GPIO port is an edge trigger type, the first interrupt injection unit directly injects the interrupt into the slave operating system, so that the interrupt delay is reduced; when the interrupt type of the GPIO port is a level trigger type, the reading unit reads the value of the current GPIO port to judge whether the level trigger condition is met, when the trigger condition is met, the second interrupt injection unit injects the interrupt into the slave operating system, and then the interrupt of the level trigger type is realized through the interrupt simulation of the double-edge trigger type.
Example four:
based on the method and the device for virtualizing the universal input/output port, the embodiment of the present application further provides a vehicle machine, which is specifically described below with reference to the accompanying drawings.
Referring to fig. 5, the figure is a schematic view of a vehicle machine provided in the fourth embodiment of the present application.
The vehicle 600 includes a system-on-chip 601, and the system-on-chip 601 includes a general purpose input/output port virtualization device 602.
The system-on-chip 601 runs at least two different operating systems: a master operating system and a slave operating system. The master operating system directly controls a physical general purpose input/output (GPIO) port, and the slave operating system uses a virtual GPIO port through the master operating system.
The master operating system and the slave operating system are based on Linux kernel, and the slave operating system may be multiple, and the specific number depends on the application scenario and the hardware capability, which is not specifically limited in the present application. The software architecture of the system on chip may specifically refer to fig. 1, and this embodiment is not described again.
For a description of the apparatus 602 for common type i/o virtualization, reference may be made to the third embodiment, and details of this embodiment are not described herein again.
The vehicle machine comprises a general input/output port virtualization device, so that a master operating system and a slave operating system can simultaneously use GPIO (general purpose input/output) to meet the requirements of actual application scenarios.
Furthermore, since the slave operating system can use the virtualized GPIO port as the physical GPIO port, for some programs that need to use the physical GPIO port, these programs can be directly transplanted to the slave operating system without modification, and the development cycle of the programs can also be reduced.
In addition, when the virtualization of the interrupt function is realized, the interrupt type of the GPIO port is directly set as the edge trigger type for the interrupt type; and for the GPIO port with the interrupt type being level trigger, setting the interrupt type as a double-edge trigger type. Each GPIO port is provided with a corresponding sysfs file, the main operating system can determine the GPIO port with interruption through the sysfs file corresponding to the GPIO port, and then obtains the value of the GPIO port according to the value attribute file in the sysfs file, when the interruption type of the GPIO port is an edge trigger type, the interruption is directly injected into the auxiliary operating system, and further the interruption time delay is reduced; and when the interrupt type of the GPIO port is a level trigger type, reading the value of the current GPIO port to judge whether the level trigger condition is met, injecting the interrupt into the slave operating system when the trigger condition is met, and further realizing the interrupt of the level trigger type through the interrupt simulation of the double-edge trigger type.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
The foregoing is merely a preferred embodiment of the invention and is not intended to limit the invention in any manner. Although the present invention has been described with reference to the preferred embodiments, it is not intended to be limited thereto. Those skilled in the art can make numerous possible variations and modifications to the present teachings, or modify equivalent embodiments to equivalent variations, without departing from the scope of the present teachings, using the methods and techniques disclosed above. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention are still within the scope of the protection of the technical solution of the present invention, unless the contents of the technical solution of the present invention are departed.

Claims (10)

1. A method for virtualization of a universal input/output port is applied to a system on chip, wherein the system on chip runs at least two different operating systems: a master operating system and a slave operating system; the master operating system directly controls a physical general purpose input output port GPIO port, and the slave operating system uses a virtual GPIO port through the master operating system;
the method comprises the following steps:
the back end driver of the main operating system receives a request which is sent by the front end driver of the slave operating system side and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port;
the rear end of the main operating system drives and derives the sysfs file of the GPIO port corresponding to the serial number so as to enable the GPIO port corresponding to the serial number;
and the rear end driver of the main operating system receives the direction of the GPIO port corresponding to the serial number sent by the front end driver of the slave operating system side, wherein the direction is input or output.
2. The method according to claim 1, wherein when the direction of the GPIO port corresponding to the number is input, further comprising:
the back end driver of the master operating system receives a read operation request which is sent by the front end driver of the slave operating system and is used for reading the GPIO port corresponding to the serial number;
the rear end driver of the main operating system reads the value of the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number;
and the back end driver of the master operating system returns the value of the GPIO port corresponding to the serial number to the front end driver of the slave operating system.
3. The method of claim 2, wherein when the direction of the GPIO port corresponding to the number is input and the GPIO port corresponding to the number is defined as an interrupt port, the method further comprises:
the back end driver of the main operating system receives the interrupt type of the GPIO port corresponding to the serial number sent by the front end driver of the auxiliary operating system, wherein the interrupt type is as follows: edge triggered or level triggered; the edge triggers include single edge triggers and dual edge triggers.
4. The method of claim 3, wherein when the interrupt type of the GPIO port corresponding to the number is defined as edge triggered, the method further comprises:
when the rear-end driver of the main operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interruption type is edge triggering, the interruption is directly injected into the front-end driver of the slave operating system;
when the interrupt type of the GPIO port corresponding to the number is defined as level trigger, the method further includes:
and when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interruption type is level triggering, the slave operating system reads the value of the physical GPIO port corresponding to the serial number, and when the interruption meeting the level triggering interruption is determined according to the value of the physical GPIO port, the master operating system injects the interruption into the front-end driver of the slave operating system.
5. The method of claim 1, wherein when the direction of the GPIO port corresponding to the number is output, further comprising:
the back end driver of the main operating system receives a write operation request which is sent by the front end driver of the auxiliary operating system and is used for the GPIO port corresponding to the serial number; the request carries a value to be written into by the GPIO port corresponding to the serial number;
and the rear end driver of the main operating system writes the value to be written into the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number.
6. The utility model provides a device of general type IO virtualization which characterized in that, is applied to the system-on-chip, the system-on-chip operation at least two kinds of following different operating systems: a master operating system and a slave operating system; the master operating system directly controls a physical general purpose input output port GPIO port, and the slave operating system uses a virtual GPIO port through the master operating system; the device comprises: a first receiving unit, an enabling unit and a second receiving unit;
the first receiving unit is used for receiving a request which is sent by a front-end driver on the side of the slave operating system and uses a virtual GPIO port; the request for using the virtual GPIO port carries the number of the GPIO port;
the enabling unit is used for deriving the sysfs file of the GPIO port corresponding to the serial number so as to enable the GPIO port corresponding to the serial number;
the second receiving unit is configured to receive a direction of the GPIO port corresponding to the serial number, where the direction is input or output, and the GPIO port is sent by the front-end driver on the slave operating system side.
7. The apparatus of claim 6, further comprising: a third receiving unit, a reading unit and a returning unit;
the third receiving unit is configured to receive a read operation request, sent by the front-end driver of the slave operating system, for the GPIO port corresponding to the serial number;
the reading unit is used for reading the value of the GPIO port corresponding to the serial number through the sysfs file of the GPIO port corresponding to the serial number;
and the return unit is used for returning the value of the GPIO port corresponding to the serial number to the front-end driver of the slave operating system.
8. The apparatus of claim 7, further comprising: a fourth receiving unit;
the fourth receiving unit is configured to receive an interrupt type of the GPIO port corresponding to the number and sent by the front-end driver of the slave operating system, where the interrupt type is: edge-triggered or level-triggered; the edge triggers include single edge triggers and dual edge triggers.
9. The apparatus of claim 8, wherein when the interrupt type of the GPIO port corresponding to the number is defined as edge triggered, the apparatus further comprises: a first interrupt injection unit;
the first interrupt injection unit is used for directly injecting the interrupt to the front-end driver of the slave operating system when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the serial number is interrupted and judges that the interrupt type is edge trigger;
when the interrupt type of the GPIO port corresponding to the number is defined as level trigger, the apparatus further includes: a second interrupt injection unit;
and the second interrupt injection unit is used for reading the value of the physical GPIO port corresponding to the number by the slave operating system when the rear-end driver of the master operating system judges that the physical GPIO port corresponding to the number is interrupted and judges that the interrupt type is level trigger, and injecting the interrupt into the front-end driver of the slave operating system when the interrupt meeting the level trigger interrupt is determined according to the value of the physical GPIO port.
10. A vehicle machine, characterized in that the vehicle machine comprises a system on chip, and the system on chip comprises the universal type i/o virtualization device according to any one of claims 6 to 9.
CN201910770092.4A 2019-08-20 2019-08-20 Universal input/output port virtualization method and device and vehicle machine Active CN110489212B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910770092.4A CN110489212B (en) 2019-08-20 2019-08-20 Universal input/output port virtualization method and device and vehicle machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910770092.4A CN110489212B (en) 2019-08-20 2019-08-20 Universal input/output port virtualization method and device and vehicle machine

Publications (2)

Publication Number Publication Date
CN110489212A CN110489212A (en) 2019-11-22
CN110489212B true CN110489212B (en) 2022-08-02

Family

ID=68552338

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910770092.4A Active CN110489212B (en) 2019-08-20 2019-08-20 Universal input/output port virtualization method and device and vehicle machine

Country Status (1)

Country Link
CN (1) CN110489212B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328314A (en) * 2021-12-31 2022-04-12 华勤通讯香港有限公司 Address automatic acquisition method, device, terminal equipment and storage medium

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018208915A1 (en) * 2017-05-10 2018-11-15 Qualcomm Incorporated Hardware event priority sensitive programmable transmit wait-window for virtual gpio finite state machine

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100874702B1 (en) * 2006-10-02 2008-12-18 삼성전자주식회사 Device Drivers and Methods for Efficiently Managing Flash Memory File Systems
US9417801B2 (en) * 2014-03-27 2016-08-16 Intel Corporation Virtual general-purpose I/O controller
US10140242B2 (en) * 2015-09-10 2018-11-27 Qualcomm Incorporated General purpose input/output (GPIO) signal bridging with I3C bus interfaces and virtualization in a multi-node network
CN105677383A (en) * 2015-12-28 2016-06-15 北京华大智宝电子系统有限公司 Method for updating data of smart card
CN106796530B (en) * 2016-12-22 2019-01-25 深圳前海达闼云端智能科技有限公司 A kind of virtual method, device and electronic equipment, computer program product
US10515044B2 (en) * 2017-11-01 2019-12-24 Qualcomm Incorporated Communicating heterogeneous virtual general-purpose input/output messages over an I3C bus
US11392512B2 (en) * 2018-10-16 2022-07-19 Intel Corporation USB method and apparatus in a virtualization environment with multi-VM

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018208915A1 (en) * 2017-05-10 2018-11-15 Qualcomm Incorporated Hardware event priority sensitive programmable transmit wait-window for virtual gpio finite state machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"Building Real-Time Embedded Applications on QduinoMC: A Web-Connected 3D Printer Case Study";Zhuoqun Cheng et.al;《2017 IEEE Real-Time and Embedded Technology and Applications Symposium (RTAS)》;20170421;全文 *

Also Published As

Publication number Publication date
CN110489212A (en) 2019-11-22

Similar Documents

Publication Publication Date Title
US10579305B2 (en) Method and apparatus for processing read/write request in physical machine
EP2202639B1 (en) Virtual machine monitor
EP3254199B1 (en) System and method for generating cross-core breakpoints in a multi-core microcontroller
CN101727414B (en) Technique for communicating interrupts in a computer system
EP3161628A1 (en) Intelligent gpu scheduling in a virtualization environment
US9251308B2 (en) Simulation method, system, and program
WO2022213832A1 (en) Computer device, virtualization acceleration device, remote control method and storage medium
US9418181B2 (en) Simulated input/output devices
CN110489212B (en) Universal input/output port virtualization method and device and vehicle machine
CN114691286A (en) Server system, virtual machine creation method and device
CN111857669A (en) Software and hardware decoupling software radar system, real-time design method and server
CN113849238B (en) Data communication method, device, electronic equipment and readable storage medium
CN111857943A (en) Data processing method, device and equipment
CN116561091A (en) Log storage method, device, equipment and readable storage medium
Zhang et al. NVMe-over-RPMsg: A virtual storage device model applied to heterogeneous multi-core SoCs
Ko et al. Hardware-in-the-loop simulation for CPU/GPU heterogeneous platforms
US11281482B2 (en) I/O emulation with abortion in virtualized environments including transfer of portions of non-real time I/O emulation to work threads prior to switching contexts
JP2001350648A (en) Microcomputer
US9965419B1 (en) Multiple-queue integer coalescing mapping algorithm with shared based time
CN114347072A (en) Robot controller simulation platform and virtual method thereof
CN115766783A (en) Data transmission method based on multiple vehicle-mounted machine operating systems and computer equipment
US9165099B2 (en) Adaptive clock management in emulation
CN112965801A (en) Virtual processor communication method and device
CN117933328A (en) Hardware accelerator, chip and computer equipment suitable for machine learning
da Silva Hardware IPC for a TrustZone-assisted Hypervisor

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