Pin control virtualization method, apparatus and electronic device
By configuring the pin controller state in the guest operating system and executing preset operations on the host operating system, the problem of GUEST OS being unable to configure the pin state is solved, enabling GUEST OS to access hardware resources and supporting the development and porting of low-level drivers.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-13
- Publication Date
- 2026-03-17
AI Technical Summary
In the existing technology, the PIN CONTROLLER can only be used by the HOST OS, and the GUEST OS cannot directly configure the pin status.
By configuring the pin controller's status and configuration information in the guest operating system and executing preset operations on the host operating system, the pin controller's status is virtualized, enabling the GUEST OS to configure the pin status through the Linux pinctrl framework.
This enables GUEST OS to configure pin states correctly, facilitating the development and porting of low-level drivers and enabling GUEST OS to access hardware resources.
Smart Images

Figure CN116166386B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of hardware control, and more specifically, to a pin control virtualization method, apparatus, and electronic device. Background Technology
[0002] Virtualization enables multiple operating systems to run on the same SoC (System on Chip). For example, systems built using a virtual machine monitor (hypervisor) can... Figure 1 As shown, a hypervisor is first run directly on the SOC, and then, with the help of the hypervisor, the host operating system (HOST OS, such as Linux-based) is started. The HOST OS can directly access the hardware resources on the SOC. Finally, with the help of the hypervisor, one or more guest operating systems (GUEST OS) are started.
[0003] A PIN controller is a piece of hardware used to control the pin states on a System-on-a-Chip (SoC), such as controlling the multiplexing, drive strength, and bias of a pin (or a group of pins). The `pinctrl` subsystem in Linux manages the pin states on the SoC. However, the PIN controller can only be used by the host operating system; the guest operating system cannot directly configure the pin states. Summary of the Invention
[0004] The purpose of this disclosure is to provide a pin control virtualization method, apparatus, and electronic device to solve the technical problem in the prior art that the PIN CONTROLLER can only be used by the HOST OS, and the GUEST OS cannot directly configure the pin state.
[0005] To achieve the above objectives, the first aspect of this disclosure provides a pin control virtualization method applied to a host operating system and a guest operating system built based on a virtual machine monitor (HVM), the method comprising:
[0006] The client operating system configures the status and configuration information of the pin controller in the device tree script (DTS) of the driver.
[0007] When performing a preset operation on the pin controller state, the preset operation is performed on the virtual pin controller state on the guest operating system side, and the state name and configuration information are sent to the host operating system.
[0008] Based on the status name and configuration information sent by the guest operating system, the preset operation is performed on the pin controller status on the host operating system, and the execution result is returned to the guest operating system.
[0009] Optionally, the preset operations include creating a pin controller state, configuring a pin controller state, and deleting a pin controller state.
[0010] Optionally, when creating the pin controller state, the method includes:
[0011] A virtual pin controller state is created on the client operating system side, and the state name and configuration information are sent to the host operating system;
[0012] The host operating system creates a pin controller state on the host operating system side based on the state name and configuration information sent by the guest operating system, and returns the creation result to the guest operating system.
[0013] Optionally, when configuring the pin controller state, the method includes:
[0014] The guest operating system sets the current state of the pin controller to unavailable and sends the state name of the current state to the host operating system;
[0015] After the host operating system receives the status name sent by the guest operating system, it sets the current status of the pin controller to unavailable.
[0016] Configure a new virtual pin controller state on the client operating system and send the name of the new pin controller state to the host operating system;
[0017] After obtaining the name of the new state of the pin controller, the host operating system configures the pin controller to the new state and returns the configuration result to the guest operating system.
[0018] Optionally, when deleting the pin controller status information, the method includes:
[0019] On the client operating system side, delete the virtual pin controller state and send the name of the state to be deleted to the host operating system;
[0020] After the main operating system obtains the state name that needs to be deleted, it deletes the pin controller state corresponding to the state name.
[0021] A second aspect of this disclosure provides a pin-controlled virtualization device for use in a host operating system and a guest operating system built based on a virtual machine monitor (hypervisor), the device comprising:
[0022] The configuration module is used to configure the status and configuration information of the pin controller in the device tree script (DTS) of the driver.
[0023] The client operation module is used to perform the preset operation on the virtual pin controller state on the client operating system side when the preset operation is performed on the pin controller state, and to send the state name and configuration information to the host operating system;
[0024] The host operation module is used to perform the preset operation on the pin controller status on the host operating system side according to the status name and configuration information sent by the guest operating system, and return the execution result to the guest operating system.
[0025] A third aspect of this disclosure provides a non-transitory computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in the first aspect.
[0026] A fourth aspect of this disclosure provides an electronic device, comprising:
[0027] A memory on which computer programs are stored;
[0028] A processor for executing the computer program in the memory to implement the steps of the method described in the first aspect.
[0029] In the scheme of this embodiment, the guest operating system configures the pin controller's state and configuration information in the device tree script (DTS) of the driver. When a preset operation is performed on the pin controller state, the preset operation is performed on the virtual pin controller state on the guest operating system side, and the state name and configuration information are sent to the host operating system. This allows the host operating system to perform the preset operation on the pin controller state on the host operating system side according to the state name and configuration information sent by the guest operating system, and return the execution result to the guest operating system. This solves the technical problem in the prior art that the PIN CONTROLLER can only be used by the HOST OS, and the GUEST OS cannot directly configure the pin state. This allows the GUEST OS to configure the pin state normally through the Linux pinctrl framework, which is convenient for the development and porting of low-level drivers.
[0030] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0031] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0032] Figure 1 This is a schematic diagram of a system built with a hypervisor according to an exemplary embodiment;
[0033] Figure 2 This is a flowchart illustrating a pin control virtualization method according to an exemplary embodiment;
[0034] Figure 3 This is a flowchart illustrating the creation of a Pinctrl state according to an exemplary embodiment;
[0035] Figure 4 This is a flowchart illustrating the configuration of the Pinctrl state according to an exemplary embodiment;
[0036] Figure 5 This is a block diagram illustrating a pin control virtualization device according to an exemplary embodiment. Detailed Implementation
[0037] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0038] In this specification, the pin controller is also referred to as Pinctrl, the pin controller state is also referred to as Pinctrl state, the guest operating system is also referred to as GUEST OS, and the host operating system is also referred to as HOST OS.
[0039] This disclosure provides a pin control virtualization method, applied to a host operating system and guest operating system built based on a virtual machine monitor (HVM). Figure 2 As shown, the method includes the following steps.
[0040] Step 201: The guest operating system configures the pin controller's state and configuration information in the driver's Device Tree Script (DTS). The DTS is used to define the pin controller's state. For example, it can define two states: "default" and "sleep." When the device is running normally, it is set to the "default" state; when the device is in sleep mode, it is set to the "sleep" state. Alternatively, it can define two states: "disable" and "enable."
[0041] Step 202: When performing a preset operation on the pin controller state, the preset operation is performed on the virtual pin controller state on the client operating system, and the state name and configuration information are sent to the host operating system.
[0042] The preset operations include any one of creating a Pinctrl state, configuring a Pinctrl state, and deleting a Pinctrl state.
[0043] Step 203: Based on the status name and configuration information sent by the guest operating system, perform the preset operation on the pin controller status on the host operating system and return the execution result to the guest operating system.
[0044] In this embodiment of the disclosure, the virtualization technology can be virtio, which is a semi-virtualization technology that enables the GUEST OS to access hardware resources. Through the virtio-based Pinctrl virtualization method, both the HOST OS and the GUEST OS can access the PIN CONTROLLER hardware, thereby achieving the purpose of configuring the pins.
[0045] Please refer to Figure 3 , Figure 3 This is a flowchart illustrating the creation of a Pinctrl state according to an exemplary embodiment. The scope of the Pinctrl state creation is the state defined in the Device Tree Script (DTS). When creating a Pinctrl state, it is created using a state name. The creation method includes the following steps.
[0046] Step 301: Create a virtual Pinctrl state on the GUEST OS side;
[0047] Step 302: Send the status name and configuration information to the HOST OS;
[0048] Step 303: The HOST OS creates the Pinctrl state on the HOST side based on the state name and configuration information passed by the GUEST OS.
[0049] Step 304, return result: success or failure.
[0050] Please refer to Figure 4 , Figure 4 This is a flowchart illustrating the configuration of a Pinctrl state according to an exemplary embodiment. The scope of the configured state is the state defined in the Device Tree Script (DTS). When configuring the Pinctrl state, it is configured by state name. Assuming that two states, disable and enable, are defined, the configuration method includes the following steps.
[0051] Step 401: First, disable the current state and send the name of the current state to the HOST OS;
[0052] Step 402: After the HOST OS obtains the status name passed from the front end (i.e., the guest operating system), it disables the status.
[0053] Step 403: The front-end sets a new state and sends the name of the new state to the HOST OS;
[0054] Step 404: After obtaining the new state name, the HOST OS configures itself to that state.
[0055] Step 405, return result: success or failure.
[0056] In this embodiment of the disclosure, when the GUEST OS restarts or the driver module is uninstalled, the Pinctrl state information needs to be deleted. The deletion method is as follows: the GUEST OS first deletes the virtual state on the GUEST OS side, and then sends the state name to the HOST OS, which deletes the state corresponding to that name.
[0057] In the scheme of this embodiment, the pinctrl state and configuration information are configured in the DTS; when creating a pinctrl state, the GUEST OS creates a virtual pinctrl state and notifies the HOST to create the corresponding state; when configuring a pinctrl state, the GUEST OS configures the virtual pinctrl state and notifies the HOST to configure the state; when deleting a pinctrl state, the GUEST OS deletes the virtual pinctrl state and notifies the HOST to delete the state, so that the GUEST OS can configure the pin (group) state through the Linux pinctrl framework.
[0058] Based on the same inventive concept, this disclosure also provides a pin-controlled virtualization device 500, applied in a host operating system and a guest operating system built based on a virtual machine monitor (hypervisor), such as... Figure 5As shown, the system includes a configuration module 501, used to configure the pin controller's status and configuration information in the driver's Device Tree Script (DTS); a client operation module 502, used to execute the preset operation on the virtual pin controller status on the client operating system side when performing a preset operation on the pin controller status, and send the status name and configuration information to the host operating system; and a host operation module 503, used to execute the preset operation on the pin controller status on the host operating system side according to the status name and configuration information sent by the client operating system, and return the execution result to the client operating system.
[0059] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0060] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the pin control virtualization method described above. For example, the computer-readable storage medium may be the memory including the program instructions described above, which may be executed by a processor of an electronic device to perform the pin control virtualization method described above.
[0061] In another exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program executable by a programmable device, the computer program having a code portion for performing the pin control virtualization method described above when executed by the programmable device.
[0062] In another exemplary embodiment, an electronic device is also provided, the electronic device including a memory storing a computer program thereon; and a processor for executing the computer program in the memory to perform the pin control virtualization method described above.
[0063] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0064] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0065] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A pin control virtualization method applied to a host operating system and a guest operating system constructed based on a hypervisor, characterized in that, The method comprises: The client operating system configures the state and configuration information of the pin controller in the device tree script (DTS) of the driver; When a preset operation is performed on the pin controller state, the preset operation is performed on the virtual pin controller state at the client operating system end, and the state name and configuration information are sent to the host operating system; According to the state name and configuration information sent by the client operating system, the preset operation is performed on the pin controller state at the host operating system end, and the execution result is returned to the client operating system; The preset operation includes creating a pin controller state, configuring a pin controller state, and deleting a pin controller state.
2. The method of claim 1, wherein, When the pin controller state is created, the method comprises: A virtual pin controller state is created at the client operating system end, and the state name and configuration information are sent to the host operating system; The host operating system creates a pin controller state at the host operating system end according to the state name and configuration information sent by the client operating system, and returns the creation result to the client operating system.
3. The method of claim 2, wherein, When the pin controller state is configured, the method comprises: The client operating system sets the current state of the pin controller as unavailable, and sends the state name of the current state to the host operating system; After the host operating system obtains the state name sent by the client operating system, the current state of the pin controller is set as unavailable; A virtual pin controller new state is configured at the client operating system end, and the name of the pin controller new state is sent to the host operating system; After the host operating system obtains the name of the pin controller new state, the pin controller is configured as the new state at the host operating system end, and the configuration result is returned to the client operating system.
4. The method of claim 3, wherein, When the pin controller state information is deleted, the method comprises: The client operating system deletes the virtual pin controller state at the client operating system end, and sends the state name to be deleted to the host operating system; After the host operating system obtains the state name to be deleted, the pin controller state corresponding to the state name is deleted.
5. A pin control virtualization apparatus applied in a host operating system and a guest operating system constructed based on a hypervisor, characterized in that, The device comprises: A configuration module for configuring the state and configuration information of the pin controller in the device tree script (DTS) of the driver; A client operating module for performing a preset operation on the virtual pin controller state at the client operating system end when the preset operation is performed on the pin controller state, and sending the state name and configuration information to the host operating system, wherein the preset operation includes creating a pin controller state, configuring a pin controller state, and deleting a pin controller state; A host operating module for performing the preset operation on the pin controller state at the host operating system end according to the state name and configuration information sent by the client operating system, and returning the execution result to the client operating system.
6. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to realize the steps of the method in any one of claims 1-4.
7. An electronic device, comprising: Comprise: a memory having stored thereon a computer program; a processor configured to execute the computer program in the memory to implement the steps of the method of any one of claims 1-4.
Citation Information
Patent Citations
Network access security protection method and device, electronic equipment and storage medium
CN115292005A
RTOS network sharing method based on virtual machine monitor
CN115599502A