CN114385335A - Method, device, device and storage medium for using interrupt resources - Google Patents
Method, device, device and storage medium for using interrupt resources Download PDFInfo
- Publication number
- CN114385335A CN114385335A CN202111594568.7A CN202111594568A CN114385335A CN 114385335 A CN114385335 A CN 114385335A CN 202111594568 A CN202111594568 A CN 202111594568A CN 114385335 A CN114385335 A CN 114385335A
- Authority
- CN
- China
- Prior art keywords
- correspondence
- gpio
- index value
- hardware interrupt
- target
- 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.)
- Pending
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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4812—Task transfer initiation or dispatching by interrupt, e.g. masked
-
- 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/14—Handling requests for interconnection or transfer
- G06F13/20—Handling requests for interconnection or transfer for access to input/output bus
- G06F13/24—Handling requests for interconnection or transfer for access to input/output bus using interrupt
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Stored Programmes (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机技术领域,特别是涉及一种中断资源使用方法、一种中断资源的使用装置、一种电子设备以及一种存储介质。The present invention relates to the field of computer technology, and in particular, to a method for using interrupt resources, a device for using interrupt resources, an electronic device, and a storage medium.
背景技术Background technique
目前的计算机基本都具有GPIO(General-purpose input/output,通用输入输出)端口,用户(也即开发人员)可以通过GPIO端口实现多元化的功能设计,例如,可以将GPIO端口作为触发中断的输入端口,从而触发OS(Operating System,操作系统)进行中断处理。At present, computers basically have GPIO (General-purpose input/output, general-purpose input and output) ports. Users (that is, developers) can realize diversified functional designs through GPIO ports. For example, GPIO ports can be used as inputs for triggering interrupts. port, thereby triggering the OS (Operating System, operating system) to perform interrupt processing.
GPIO控制器是按照设置对GPIO端口进行输入或输出控制的控制电路,GPIO控制器上有多个GPIO引脚,目前,计算机厂商对GPIO控制器通常都有不同的设计和使用方式。在实际应用中,GPIO控制器的使用非常灵活,对GPIO中断资源往往存在多元化的定制使用,为GPIO中断资源的使用带来了不便。The GPIO controller is a control circuit that controls the input or output of the GPIO port according to the settings. There are multiple GPIO pins on the GPIO controller. At present, computer manufacturers usually have different designs and use methods for the GPIO controller. In practical applications, the use of the GPIO controller is very flexible, and there are often diversified customized uses of the GPIO interrupt resources, which brings inconvenience to the use of the GPIO interrupt resources.
在一些具体场景中,由于中断控制器的引脚数量有限,因此会存在多个GPIO引脚复用中断控制器的一个输入引脚的情况,并且在中断控制器引脚复用的情况下,还可能需要进一步对复用的中断控制器引脚实现GPIO中断资源的离散复用,也即复用同一中断控制器引脚的各GPIO引脚并不是连续标识的GPIO引脚。In some specific scenarios, due to the limited number of pins of the interrupt controller, there may be multiple GPIO pins multiplexing one input pin of the interrupt controller, and in the case of multiplexing the interrupt controller pins, It may also be necessary to further implement discrete multiplexing of GPIO interrupt resources for the multiplexed interrupt controller pins, that is, each GPIO pin that multiplexes the same interrupt controller pin is not a GPIO pin identified continuously.
然而,在某些中断资源的使用机制中,无法向OS传递复用且离散的GPIO中断资源,仅能够传递非复用或复用且连续(也即复用中断控制器同一输入引脚的各GPIO引脚是标识连续编号的GPIO引脚)的GPIO中断资源,进而无法针对GPIO中断资源复用且离散的情况进行GPIO中断服务定制。However, in the use mechanism of some interrupt resources, multiplexed and discrete GPIO interrupt resources cannot be passed to the OS, and only non-multiplexed or multiplexed and continuous (that is, multiplexed interrupt controller same input pin of each input pin) can be passed. GPIO pins are GPIO interrupt resources that identify consecutively numbered GPIO pins), so that GPIO interrupt service customization cannot be performed for the case where GPIO interrupt resources are multiplexed and discrete.
发明内容SUMMARY OF THE INVENTION
鉴于上述问题,提出了本发明实施例以便提供一种克服上述问题或者至少部分地解决上述问题的中断资源的使用方法,以在可传递中断资源的不同架构中,均能够针对GPIO中断资源复用且离散的情况进行GPIO中断服务定制。In view of the above problems, embodiments of the present invention are proposed to provide a method for using interrupt resources that overcomes the above problems or at least partially solves the above problems, so that in different architectures that can deliver interrupt resources, multiplexing of GPIO interrupt resources is possible And in discrete cases, GPIO interrupt service customization is performed.
相应的,本发明实施例还提供了一种中断资源的使用装置、一种电子设备以及一种存储介质,用以保证上述方法的实现及应用。Correspondingly, the embodiments of the present invention also provide a device for using interrupt resources, an electronic device, and a storage medium, so as to ensure the implementation and application of the above method.
为了解决上述问题,本发明实施例公开了一种中断资源的使用方法,包括:In order to solve the above problems, an embodiment of the present invention discloses a method for using interrupt resources, including:
在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系;In the kernel of firmware or operating system, construct the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the second correspondence between the GPIO pin identification and the index value;
完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系;After completing the construction, load the first correspondence and the second correspondence each time the operating system is started;
当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据所述用户申请中携带的所述目标GPIO引脚标识,从所述第二对应关系中,解析得到所述目标GPIO引脚标识对应的目标索引值;When receiving the user application for obtaining the interrupt resource corresponding to the target GPIO pin identifier, according to the target GPIO pin identifier carried in the user application, from the second correspondence, parse and obtain the target GPIO The target index value corresponding to the pin identification;
从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源。From the first correspondence, the target hardware interrupt resource corresponding to the target index value is obtained by parsing.
可选地,所述在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系的步骤,包括:Optionally, in the kernel of the firmware or the operating system, the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the relationship between the GPIO pin identification and the index value are constructed. The steps of the second correspondence include:
在固件中,通过高级配置和电源管理接口表,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;In the firmware, through the advanced configuration and power management interface table, the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource is constructed in the device information of the GPIO controller, and the GPIO pin identification and all the second correspondence between the index values, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载所述第一对应关系和所述第二对应关系的步骤,包括:The step of loading the first correspondence and the second correspondence includes:
从所述固件中加载所述高级配置和电源管理接口表,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。The advanced configuration and power management interface table is loaded from the firmware to obtain the first correspondence and the second correspondence from device information of the GPIO controller.
可选地,所述在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系的步骤,包括:Optionally, in the kernel of the firmware or the operating system, the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the relationship between the GPIO pin identification and the index value are constructed. The steps of the second correspondence include:
在固件或操作系统的内核中,通过设备树,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;In the kernel of the firmware or the operating system, through the device tree, the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource is constructed in the device information of the GPIO controller, and the GPIO pin identifier and all the second correspondence between the index values, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载所述第一对应关系和所述第二对应关系的步骤,包括:The step of loading the first correspondence and the second correspondence includes:
从所述固件或所述内核中加载所述设备树,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。The device tree is loaded from the firmware or the kernel to obtain the first correspondence and the second correspondence from device information of the GPIO controller.
可选地,所述构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系的步骤,包括:Optionally, the step of constructing the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the second correspondence between the GPIO pin identifier and the index value, includes:
将各个硬件中断资源作为第一数组元素,通过所述第一数组元素的数组下标表示所述硬件中断资源的索引值,构建所述硬件中断资源与所述索引值呈一一对应关系的第一数组;Each hardware interrupt resource is used as a first array element, the index value of the hardware interrupt resource is represented by the array subscript of the first array element, and the first array in which the hardware interrupt resource and the index value are in a one-to-one correspondence is constructed. an array;
通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个所述索引值作为所述第二数组元素,构建所述索引值与所述GPIO引脚标识呈一一对应关系的第二数组。Each GPIO pin identifier is represented by the array subscript of the second array element, and each of the index values is used as the second array element to construct a second array in which the index value and the GPIO pin identifier are in a one-to-one correspondence. array.
可选地,所述通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个所述索引值作为所述第二数组元素,构建所述索引值与所述GPIO引脚标识呈一一对应关系的第二数组的步骤,包括:Optionally, each GPIO pin identifier is represented by the array subscript of the second array element, each of the index values is used as the second array element, and the index value and the GPIO pin identifier are constructed to be the same. A step corresponding to the second array of relationships, comprising:
对于任一所述GPIO引脚标识,在所述GPIO引脚标识对应的GPIO引脚未与中断控制器中的任一输入引脚连接的情况下,将所述GPIO引脚标识表示为第二数组元素的数组下标时所对应的第二数组元素填充为所述第一数组元素的数组下标的非法值。For any of the GPIO pin identifications, in the case that the GPIO pin corresponding to the GPIO pin identification is not connected to any input pin in the interrupt controller, the GPIO pin identification is represented as the second The second array element corresponding to the array subscript of the array element is filled with the illegal value of the array subscript of the first array element.
可选地,在所述完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系之后,还包括:Optionally, after the completion of the construction, each time the operating system is started, after loading the first correspondence and the second correspondence, the method further includes:
构建各个所述硬件中断资源与软件中断资源的映射关系。A mapping relationship between each of the hardware interrupt resources and software interrupt resources is constructed.
可选地,在所述从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源之后,还包括:Optionally, after obtaining the target hardware interrupt resource corresponding to the target index value by parsing from the first correspondence, the method further includes:
根据所述映射关系,对所述目标硬件中断资源进行中断映射,得到所述所述目标硬件中断资源对应的目标软件中断资源;performing interrupt mapping on the target hardware interrupt resource according to the mapping relationship to obtain a target software interrupt resource corresponding to the target hardware interrupt resource;
将所述目标软件中断资源返回给提出所述用户申请的开发软件,以使用户根据所述目标软件中断资源定制中断例程。The target software interrupt resource is returned to the development software that applies for the user, so that the user can customize an interrupt routine according to the target software interrupt resource.
可选地,一个所述硬件中断资源包括中断控制器上连接有所述GPIO引脚的一个输入引脚的引脚编号。Optionally, one of the hardware interrupt resources includes the pin number of an input pin on the interrupt controller to which the GPIO pin is connected.
本发明实施例还公开了一种中断资源的使用装置,包括:The embodiment of the present invention also discloses a device for using interrupt resources, including:
第一构建模块,用于在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系;The first building module is used to construct, in the kernel of the firmware or the operating system, the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and between the GPIO pin identification and the index value The second correspondence of ;
加载模块,用于完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系;a loading module, configured to load the first correspondence and the second correspondence every time the operating system starts after completing the construction;
第一解析模块,用于当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据所述用户申请中携带的所述目标GPIO引脚标识,从所述第二对应关系中,解析得到所述目标GPIO引脚标识对应的目标索引值;The first parsing module is used to, when receiving a user application for obtaining the interrupt resource corresponding to the target GPIO pin identification, according to the target GPIO pin identification carried in the user application, from the second corresponding relationship , parsed to obtain the target index value corresponding to the target GPIO pin identification;
第二解析模块,用于从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源。A second parsing module, configured to parse and obtain the target hardware interrupt resource corresponding to the target index value from the first correspondence.
可选地,所述第一构建模块包括:Optionally, the first building block includes:
第一构建子模块,用于在固件中,通过高级配置和电源管理接口表,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;The first construction sub-module is used to construct the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller through the advanced configuration and the power management interface table in the firmware , and the second correspondence between the GPIO pin identification and the index value, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载模块包括:The loading module includes:
第一加载子模块,用于从所述固件中加载所述高级配置和电源管理接口表,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。A first loading submodule, configured to load the advanced configuration and power management interface table from the firmware, so as to obtain the first correspondence and the second correspondence from device information of the GPIO controller.
可选地,所述第一构建模块包括:Optionally, the first building block includes:
第二构建子模块,用于在固件或操作系统的内核中,通过设备树,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;The second building submodule is used to build the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller through the device tree in the firmware or the kernel of the operating system , and the second correspondence between the GPIO pin identification and the index value, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载模块包括:The loading module includes:
第二加载子模块,用于从所述固件或所述内核中加载所述设备树,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。The second loading submodule is configured to load the device tree from the firmware or the kernel, so as to obtain the first correspondence and the second correspondence from the device information of the GPIO controller.
可选地,所述第一构建模块包括:Optionally, the first building block includes:
第三构建子模块,用于将各个硬件中断资源作为第一数组元素,通过所述第一数组元素的数组下标表示所述硬件中断资源的索引值,构建所述硬件中断资源与所述索引值呈一一对应关系的第一数组;The third construction sub-module is configured to use each hardware interrupt resource as a first array element, use the array subscript of the first array element to indicate the index value of the hardware interrupt resource, and construct the hardware interrupt resource and the index The first array whose values are in a one-to-one correspondence;
第四构建子模块,用于通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个所述索引值作为所述第二数组元素,构建所述索引值与所述GPIO引脚标识呈一一对应关系的第二数组。The fourth construction submodule is used to represent each GPIO pin identification by the array subscript of the second array element, and each described index value is used as the second array element, and the index value and the GPIO pin identification are constructed. A second array in a one-to-one correspondence.
可选地,所述第四构建子模块具体用于:Optionally, the fourth building submodule is specifically used for:
对于任一所述GPIO引脚标识,在所述GPIO引脚标识对应的GPIO引脚未与中断控制器中的任一输入引脚连接的情况下,将所述GPIO引脚标识表示为第二数组元素的数组下标时所对应的第二数组元素填充为所述第一数组元素的数组下标的非法值。For any of the GPIO pin identifications, in the case that the GPIO pin corresponding to the GPIO pin identification is not connected to any input pin in the interrupt controller, the GPIO pin identification is represented as the second The second array element corresponding to the array subscript of the array element is filled with the illegal value of the array subscript of the first array element.
可选地,所述装置还包括:Optionally, the device further includes:
第二构建模块,用于构建各个所述硬件中断资源与软件中断资源的映射关系。The second building module is configured to build a mapping relationship between each of the hardware interrupt resources and software interrupt resources.
可选地,所述装置还包括:Optionally, the device further includes:
映射模块,用于根据所述映射关系,对所述目标硬件中断资源进行中断映射,得到所述目标硬件中断资源对应的目标软件中断资源;a mapping module, configured to perform interrupt mapping on the target hardware interrupt resource according to the mapping relationship to obtain a target software interrupt resource corresponding to the target hardware interrupt resource;
返回模块,用于将所述目标软件中断资源返回给提出所述用户申请的开发软件,以使用户根据所述目标软件中断资源定制中断例程。The returning module is configured to return the target software interrupt resource to the development software that applies for the user, so that the user can customize an interrupt routine according to the target software interrupt resource.
可选地,一个所述硬件中断资源包括中断控制器上连接有所述GPIO引脚的一个输入引脚的引脚编号。Optionally, one of the hardware interrupt resources includes the pin number of an input pin on the interrupt controller to which the GPIO pin is connected.
本发明实施例还公开了一种电子设备,包括有存储器、以及一个或者一个以上的程序,其中一个或者一个以上程序存储于存储器中,且经配置以由一个或者一个以上的处理器执行所述一个或者一个以上的程序,所述程序包含用于进行以下操作的指令:An embodiment of the present invention also discloses an electronic device including a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors One or more programs comprising instructions for:
在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系;In the kernel of firmware or operating system, construct the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the second correspondence between the GPIO pin identification and the index value;
完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系;After completing the construction, load the first correspondence and the second correspondence each time the operating system is started;
当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据所述用户申请中携带的所述目标GPIO引脚标识,从所述第二对应关系中,解析得到所述目标GPIO引脚标识对应的目标索引值;When receiving the user application for obtaining the interrupt resource corresponding to the target GPIO pin identifier, according to the target GPIO pin identifier carried in the user application, from the second correspondence, parse and obtain the target GPIO The target index value corresponding to the pin identification;
从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源。From the first correspondence, the target hardware interrupt resource corresponding to the target index value is obtained by parsing.
本发明实施例还公开了一种可读存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行如上所述的中断资源的使用方法。The embodiment of the present invention also discloses a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the above-mentioned method for using interrupt resources.
本发明实施例包括以下优点:The embodiments of the present invention include the following advantages:
在本发明实施例中,可通过索引值,间接构建GPIO引脚标识与硬件中断资源之间的对应关系,并且记录在固件或OS的内核中,当用户申请某个GPIO引脚的硬件中断资源时,OS读取并解析硬件中断资源与索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,进而OS可以根据这两个对应关系,向用户提供所申请的GPIO引脚的硬件中断资源。在本发明实施例中,由于索引值的定义不受一些机制中硬件中断资源是否复用、复用情况下是否连续的限制,因此,GPIO引脚标识与硬件中断资源之间的对应关系可以转换为第一对应关系和第二对应关系进行定义和传递,不仅可以实现复用且离散的硬件中断资源的使用,还能够实现复用且连续的硬件中断资源的使用,以及非复用的硬件中断资源的使用。In the embodiment of the present invention, the corresponding relationship between the GPIO pin identification and the hardware interrupt resource can be indirectly constructed through the index value, and recorded in the firmware or the kernel of the OS. When the user applies for the hardware interrupt resource of a GPIO pin When , the OS reads and parses the first correspondence between the hardware interrupt resource and the index value, and the second correspondence between the GPIO pin identifier and the index value, and then the OS can provide the user with The hardware interrupt resource of the requested GPIO pin. In the embodiment of the present invention, since the definition of the index value is not limited by whether the hardware interrupt resources are multiplexed and whether the multiplexing is continuous in some mechanisms, the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource can be converted Defining and transferring the first correspondence and the second correspondence can not only realize the use of multiplexed and discrete hardware interrupt resources, but also realize the use of multiplexed and continuous hardware interrupt resources, as well as the use of non-multiplexed hardware interrupts use of resources.
附图说明Description of drawings
图1是本发明的一种中断资源的使用方法的步骤流程图;1 is a flow chart of steps of a method for using interrupt resources of the present invention;
图2是本发明的电子设备中GPIO控制器、GPIO引脚、中断控制器与中央处理器之间的一种硬件连接示意图;2 is a schematic diagram of a hardware connection between a GPIO controller, a GPIO pin, an interrupt controller and a central processing unit in the electronic device of the present invention;
图3是本发明的一种GPIO的硬件中断资源的使用流程图;Fig. 3 is the use flow chart of the hardware interrupt resource of a kind of GPIO of the present invention;
图4是本发明的另一种GPIO的硬件中断资源的使用流程图;Fig. 4 is the use flow chart of the hardware interrupt resource of another kind of GPIO of the present invention;
图5是本发明的另一种中断资源的使用方法的步骤流程图;5 is a flow chart of steps of another method for using interrupt resources of the present invention;
图6是本发明的一种中断资源的使用装置的结构框图;6 is a structural block diagram of a device for using interrupt resources according to the present invention;
图7是根据一示例性实施例示出的一种用于使用中断资源的电子设备的结构框图。FIG. 7 is a structural block diagram of an electronic device for using interrupt resources according to an exemplary embodiment.
具体实施方式Detailed ways
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明作进一步详细的说明。In order to make the above objects, features and advantages of the present invention more clearly understood, the present invention will be described in further detail below with reference to the accompanying drawings and specific embodiments.
目前,针对GPIO中断资源存在复用且离散的问题,缺少统一的中断资源的使用方法,使得某些场景下,无法提供该问题的解决方法,进而使得基于中断资源进行中断功能开发的开发软件缺失相关的中断功能。At present, in view of the problem of multiplexing and discreteness of GPIO interrupt resources, there is a lack of a unified method for using interrupt resources, which makes it impossible to provide a solution to this problem in some scenarios, which makes the development software for interrupt function development based on interrupt resources missing. related interrupt function.
例如,对于通过ACPI(Advanced Configuration and Power ManagementInterface,高级配置和电源管理接口)表向OS提供中断资源的场景(也即通过ACPI机制向OS传递中断资源),由于ACPI机制只支持非复用或复用且连续的中断资源的定义,所以ACPI机制下,无法向OS传递复用且离散的中断资源。For example, for the scenario of providing interrupt resources to the OS through the ACPI (Advanced Configuration and Power Management Interface) table (that is, passing interrupt resources to the OS through the ACPI mechanism), since the ACPI mechanism only supports non-multiplexing or multiplexing Therefore, under the ACPI mechanism, multiplexed and discrete interrupt resources cannot be delivered to the OS.
目前,为了解决上述问题,通常会针对不同的使用场景添加解决上述问题的定制化流程。但是,由于定制化的差异性,需要针对不同场景进行单独适配,这样会导致开发软件的兼容性降低,并且需要维护多个场景下的开发软件处理过程,不利于开发软件的维护。At present, in order to solve the above problems, customized processes to solve the above problems are usually added for different usage scenarios. However, due to the differences in customization, it needs to be individually adapted for different scenarios, which will reduce the compatibility of the development software, and need to maintain the development software processing process in multiple scenarios, which is not conducive to the maintenance of the development software.
本发明实施例的核心构思之一在于,定义GPIO引脚标识与硬件中断资源之间的对应关系,并且记录在固件或OS的内核中,当用户申请某个GPIO引脚的硬件中断资源时,OS读取并解析GPIO引脚标识与硬件中断资源之间的对应关系,进而可以根据该对应关系提供所申请的GPIO引脚的硬件中断资源。One of the core concepts of the embodiment of the present invention is to define the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource, and record it in the firmware or the kernel of the OS. When a user applies for a hardware interrupt resource of a GPIO pin, The OS reads and parses the corresponding relationship between the GPIO pin identification and the hardware interrupt resource, and then can provide the requested hardware interrupt resource of the GPIO pin according to the corresponding relationship.
其中,为了使GPIO引脚标识与硬件中断资源之间的对应关系,能够在不同的使用机制(例如设备树机制、ACPI机制等)中均实现定义和传递,本发明实施例将GPIO引脚标识与硬件中断资源之间的对应关系,转化为硬件中断资源与索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,从而借助索引值来间接定义GPIO引脚标识与硬件中断资源之间的对应关系,由于索引值不受复用情况下GPIO引脚的标识必须连续编号的限制,因此,任一GPIO引脚可通过索引值对应到任意的硬件中断资源,如此,不仅能够在不同使用机制下,实现GPIO中断资源复用且离散的情况下的GPIO中断资源的传递,还能够实现GPIO中断资源非复用,以及复用且连续的情况下的GPIO中断资源的传递。Among them, in order to make the corresponding relationship between the GPIO pin identification and the hardware interrupt resource, the definition and transmission can be realized in different use mechanisms (such as the device tree mechanism, ACPI mechanism, etc.), the embodiment of the present invention uses the GPIO pin identification The corresponding relationship with the hardware interrupt resource is transformed into the first correspondence between the hardware interrupt resource and the index value, and the second correspondence between the GPIO pin identification and the index value, so that the GPIO is indirectly defined by the index value. The corresponding relationship between pin identification and hardware interrupt resources, because the index value is not limited by the continuous numbering of the GPIO pin identification in the case of multiplexing, therefore, any GPIO pin can correspond to any hardware interrupt through the index value Resource, in this way, not only can realize the transmission of GPIO interrupt resources in the case of multiplexing and discrete GPIO interrupt resources under different use mechanisms, but also realize the non-multiplexing of GPIO interrupt resources, and the GPIO in the case of multiplexing and continuous. Interrupt the delivery of resources.
参照图1,示出了本发明的一种中断资源的使用方法的步骤流程图,具体可以包括如下步骤:Referring to FIG. 1, there is shown a flow chart of the steps of a method for using an interrupt resource of the present invention, which may specifically include the following steps:
步骤101,在固件或操作系统的内核中,构建各个硬件中断资源与硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系。
参照图2,示出了电子设备中GPIO控制器、GPIO引脚、中断控制器与中央处理器(central processing unit,CPU)之间的一种硬件连接示意图,其中,GPIO控制器可对GPIO引脚进行输入或输出的控制,GPIO引脚可作为触发中断的引脚,与中断控制器电连接,中断控制器可在通过GPIO引脚接收到中断信号时,向中央处理器输出中断信号,中央处理器进而可以处理中断。Referring to FIG. 2, a schematic diagram of a hardware connection between a GPIO controller, GPIO pins, an interrupt controller and a central processing unit (CPU) in an electronic device is shown, wherein the GPIO controller can lead to the GPIO The pin is used for input or output control. The GPIO pin can be used as a pin for triggering an interrupt and is electrically connected to the interrupt controller. The interrupt controller can output an interrupt signal to the central processing unit when it receives an interrupt signal through the GPIO pin. The processor, in turn, can handle interrupts.
其中,一个硬件中断资源包括中断控制器上连接有GPIO引脚的一个输入引脚的引脚编号。Wherein, a hardware interrupt resource includes a pin number of an input pin connected with a GPIO pin on the interrupt controller.
中断控制器的一个输入引脚可以连接一个或多个GPIO引脚,在中断控制器的每个输入引脚都只连接一个GPIO引脚的情况下,GPIO的硬件中断资源为非复用;在中断控制器的任一输入引脚连接多个GPIO引脚的情况下,GPIO的硬件中断资源存在复用。An input pin of the interrupt controller can be connected to one or more GPIO pins. If each input pin of the interrupt controller is connected to only one GPIO pin, the hardware interrupt resources of the GPIO are non-multiplexed; When any input pin of the interrupt controller is connected to multiple GPIO pins, the hardware interrupt resources of the GPIO are multiplexed.
以图2所示的GPIO控制器包括6个GPIO引脚为例,6个GPIO引脚的标识分别为0-5,其中,GPIO引脚0、2和4均与中断控制器的输入引脚13电连接,GPIO引脚1、3和5均与中断控制器的输入引脚15电连接,也即GPIO的每个硬件中断资源均存在复用。Taking the GPIO controller shown in Figure 2 including 6 GPIO pins as an example, the identifications of the 6 GPIO pins are 0-5 respectively. Among them, GPIO pins 0, 2 and 4 are all related to the input pins of the interrupt controller. 13 is electrically connected, and the GPIO pins 1, 3 and 5 are all electrically connected to the input pin 15 of the interrupt controller, that is, each hardware interrupt resource of the GPIO is multiplexed.
进一步地,在GPIO的硬件中断资源存在复用的情况下,复用的输入引脚所连接的各个GPIO引脚的标识若为连续编号,则GPIO的硬件中断资源存在复用且连续的情况;复用的输入引脚所连接的各个GPIO引脚的标识若为离散编号(也即不连续编号),则GPIO的硬件中断资源存在复用且离散的情况。Further, in the case where the hardware interrupt resources of GPIO are multiplexed, if the identifier of each GPIO pin connected to the multiplexed input pin is a continuous number, then the hardware interrupt resources of GPIO are multiplexed and continuous; If the identifiers of the GPIO pins connected to the multiplexed input pins are discrete numbers (ie, discontinuous numbers), the hardware interrupt resources of the GPIOs are multiplexed and discrete.
根据电子设备中GPIO引脚与中断控制器的实际连接情况,可确定GPIO的硬件中断资源是非复用、复用且连续、复用且离散这三种情况中的哪种情况,进而可以根据GPIO的硬件中断资源的情况,在固件或操作系统的内核的代码中,构建各个硬件中断资源与硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系。According to the actual connection between the GPIO pin and the interrupt controller in the electronic device, it can be determined which of the three situations of the GPIO hardware interrupt resource is non-multiplexed, multiplexed and continuous, multiplexed and discrete. In the case of hardware interrupt resources, in the code of the firmware or the kernel of the operating system, build the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the first correspondence between the GPIO pin identification and the index value. Two correspondences.
在ACPI机制及类似机制下,直接定义GPIO引脚标识与硬件中断资源之间的对应关系是受限的,硬件中断资源复用情况下,同一硬件中断资源对应的GPIO引脚标识必须为连续编号。而在设备树机制及类似机制下,直接定义GPIO引脚标识与硬件中断资源之间的对应关系是不受限的,硬件中断资源复用情况下,同一硬件中断资源对应的GPIO引脚标识可以是离散编号。Under the ACPI mechanism and similar mechanisms, it is limited to directly define the correspondence between GPIO pin identifiers and hardware interrupt resources. In the case of hardware interrupt resource multiplexing, the GPIO pin identifiers corresponding to the same hardware interrupt resource must be consecutively numbered. . Under the device tree mechanism and similar mechanisms, it is not limited to directly define the correspondence between GPIO pin identifiers and hardware interrupt resources. In the case of hardware interrupt resource multiplexing, the GPIO pin identifiers corresponding to the same hardware interrupt resource can be is a discrete number.
因此,考虑到ACPI机制及类似机制对硬件中断资源复用情况下的限制,在本发明实施例中,可以借助索引值建立GPIO引脚标识与硬件中断资源之间的对应关系,索引值的定义及传递不受复用的硬件中断资源是否连续的限制,从而可以在ACPI机制及类似机制,以及设备树机制及类似机制下,均实现GPIO引脚标识与硬件中断资源之间的对应关系的定义和传递。Therefore, considering the limitation of the ACPI mechanism and similar mechanisms on the multiplexing of hardware interrupt resources, in the embodiment of the present invention, the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource can be established by means of the index value. The definition of the index value And the transmission is not limited by whether the multiplexed hardware interrupt resources are continuous, so that the definition of the correspondence between the GPIO pin identification and the hardware interrupt resources can be realized under the ACPI mechanism and similar mechanisms, as well as the device tree mechanism and similar mechanisms. and pass.
在本发明实施例中,可选地,固件可以为BIOS(Basic Input Output System,基本输入输出系统)。In this embodiment of the present invention, optionally, the firmware may be a BIOS (Basic Input Output System, basic input output system).
步骤102,完成构建后,当操作系统每次启动时,加载第一对应关系和第二对应关系。Step 102: After the construction is completed, each time the operating system is started, the first correspondence and the second correspondence are loaded.
在第一对应关系和第二对应关系构建完成后,电子设备后续每次上电后都可以加载第一对应关系和第二对应关系。具体地,当OS每次启动时,可以从固件或OS的内核中加载第一对应关系和第二对应关系,以待用户申请中断资源时使用。After the first correspondence and the second correspondence are constructed, the electronic device can load the first correspondence and the second correspondence after each subsequent power-on. Specifically, each time the OS is started, the first correspondence and the second correspondence may be loaded from the firmware or the kernel of the OS to be used when the user applies for the interrupt resource.
步骤103,当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据用户申请中携带的目标GPIO引脚标识,从第二对应关系中,解析得到目标GPIO引脚标识对应的目标索引值。
在OS运行过程中,用户可以申请目标GPIO引脚标识对应中断资源,其中,目标GPIO引脚标识也即任一GPIO引脚的标识。当OS接收到该用户申请时,可以获得用户申请中携带的目标GPIO引脚标识,之后可以从加载的第二对应关系中,解析得到目标GPIO引脚标识对应的目标索引值。During the OS running process, the user can apply for the interrupt resource corresponding to the target GPIO pin identifier, where the target GPIO pin identifier is the identifier of any GPIO pin. When the OS receives the user application, the target GPIO pin identifier carried in the user application can be obtained, and then the target index value corresponding to the target GPIO pin identifier can be obtained by parsing from the loaded second correspondence.
步骤104,从第一对应关系中,解析得到目标索引值对应的目标硬件中断资源。Step 104: From the first correspondence, analyze and obtain the target hardware interrupt resource corresponding to the target index value.
得到目标GPIO引脚标识对应的目标索引值之后,OS可以进一步从加载的第一对应关系中,解析得到目标索引值对应的目标硬件中断资源,该目标硬件中断资源也即目标GPIO引脚标识所对应的硬件中断资源。After obtaining the target index value corresponding to the target GPIO pin identifier, the OS can further parse and obtain the target hardware interrupt resource corresponding to the target index value from the loaded first correspondence, where the target hardware interrupt resource is also the target GPIO pin identifier. Corresponding hardware interrupt resource.
在本发明实施例中,可通过索引值,间接构建GPIO引脚标识与硬件中断资源之间的对应关系,并且记录在固件或OS的内核中,当用户申请某个GPIO引脚的硬件中断资源时,OS读取并解析硬件中断资源与索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,进而OS可以根据这两个对应关系,向用户提供所申请的GPIO引脚的硬件中断资源。在本发明实施例中,由于索引值的定义不受一些机制中硬件中断资源是否复用、复用情况下是否连续的限制,因此,GPIO引脚标识与硬件中断资源之间的对应关系可以转换为第一对应关系和第二对应关系进行定义和传递,不仅可以实现复用且离散的硬件中断资源的使用,还能够实现复用且连续的硬件中断资源的使用,以及非复用的硬件中断资源的使用。In the embodiment of the present invention, the corresponding relationship between the GPIO pin identification and the hardware interrupt resource can be indirectly constructed through the index value, and recorded in the firmware or the kernel of the OS. When the user applies for the hardware interrupt resource of a GPIO pin When , the OS reads and parses the first correspondence between the hardware interrupt resource and the index value, and the second correspondence between the GPIO pin identifier and the index value, and then the OS can provide the user with The hardware interrupt resource of the requested GPIO pin. In the embodiment of the present invention, since the definition of the index value is not limited by whether the hardware interrupt resources are multiplexed and whether the multiplexing is continuous in some mechanisms, the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource can be converted Defining and transferring the first correspondence and the second correspondence can not only realize the use of multiplexed and discrete hardware interrupt resources, but also realize the use of multiplexed and continuous hardware interrupt resources, as well as the use of non-multiplexed hardware interrupts use of resources.
进一步地,将复用且离散、复用且连续,或者非复用的硬件中断资源提供给开发软件后,用户可以在该开发软件中进行中断例程的定制,也即开发软件可以兼容中断资源的不同使用机制,提高了开发软件的兼容性,并且不需要维护多个场景下的开发软件处理过程,有利于开发软件的维护。Further, after the multiplexed and discrete, multiplexed and continuous, or non-multiplexed hardware interrupt resources are provided to the development software, the user can customize the interrupt routine in the development software, that is, the development software can be compatible with interrupt resources. The different use mechanisms of the software improve the compatibility of the development software, and do not need to maintain the development software processing process in multiple scenarios, which is conducive to the maintenance of the development software.
参照图3,示出了一种GPIO的硬件中断资源的使用流程图,其中,第一对应关系和第二对应关系可以在固件中进行定义,OS的内核可通过固件传参的方式读取出,并进行解析,进而再提供给开发软件,以供用户进行开发使用。Referring to FIG. 3, a flow chart of the use of hardware interrupt resources of a GPIO is shown, wherein the first correspondence and the second correspondence can be defined in the firmware, and the kernel of the OS can be read out by passing parameters through the firmware , and analyze it, and then provide it to the development software for users to develop and use.
参照图4,示出了另一种GPIO的硬件中断资源的使用流程图,其中,第一对应关系和第二对应关系可以在OS的内核中进行定义,OS的内核可以读取并进行解析,进而再提供给开发软件,以供用户进行开发使用。Referring to FIG. 4 , a flow chart of using hardware interrupt resources of another GPIO is shown, wherein the first correspondence and the second correspondence can be defined in the kernel of the OS, and the kernel of the OS can read and parse, And then provide the development software for the user to develop and use.
在实际应用中,可以根据中断资源的使用机制的不同,选择在固件中还是OS的内核中定义第一对应关系和第二对应关系。例如在ACPI机制下,可以在固件中进行第一对应关系和第二对应关系的定义,而在设备树机制下,可以在固件或OS的内核中进行第一对应关系和第二对应关系的定义。In practical applications, it is possible to choose whether to define the first correspondence and the second correspondence in the firmware or the kernel of the OS according to different use mechanisms of the interrupt resources. For example, under the ACPI mechanism, the first correspondence and the second correspondence can be defined in the firmware, while under the device tree mechanism, the first correspondence and the second correspondence can be defined in the firmware or the OS kernel .
其中,固件是一段在电子设备中固化的初始化代码,电子设备一上电就开始运行,用来进行必要的初始化,以保证OS的内核能够启动,从而为OS的运行做准备,如果固件无法为OS准备好必要的硬件环境,就不会进入到操作系统的启动。通常,固件运行的最后一步操作是将OS从硬盘分区转移到内存中,并将电子设备的控制权交给OS的内核。Among them, the firmware is a piece of initialization code that is solidified in the electronic device. The electronic device starts to run as soon as it is powered on, and is used to perform necessary initialization to ensure that the kernel of the OS can be started, so as to prepare for the operation of the OS. When the OS prepares the necessary hardware environment, it will not enter into the startup of the operating system. Usually, the last step in the firmware operation is to transfer the OS from the hard disk partition to the memory and hand over control of the electronic device to the OS's kernel.
参照图3,在一种可选的实施方式中,步骤101具体包括以下步骤:3, in an optional implementation manner, step 101 specifically includes the following steps:
S11:在固件中,通过高级配置和电源管理接口表,在GPIO控制器的设备信息中构建各个硬件中断资源与硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,其中,GPIO控制器的各个GPIO引脚均与中断控制器电连接。S11: In the firmware, through the advanced configuration and power management interface table, build the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller, as well as the GPIO pin identification and index A second correspondence between the values, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller.
相应地,步骤102中加载第一对应关系和第二对应关系的步骤,具体包括:Correspondingly, the step of loading the first correspondence and the second correspondence in
S21:从固件中加载高级配置和电源管理接口表,以从GPIO控制器的设备信息中获得第一对应关系和第二对应关系。S21: Load the advanced configuration and power management interface table from the firmware to obtain the first correspondence and the second correspondence from the device information of the GPIO controller.
其中,ACPI表提供了一种用于记录设备信息数据结构,可记录例如控制器、CPU等设备的设备信息,可以在固件中,根据各个设备信息构建出一个ACPI表,并在GPIO控制器的设备信息中增加第一对应关系和第二对应关系,从而将第一对应关系和第二对应关系作为GPIO控制器的设备信息中的自定义属性。Among them, the ACPI table provides a data structure for recording device information, which can record the device information of devices such as controllers and CPUs. In the firmware, an ACPI table can be constructed according to the information of each device, and it can be recorded in the GPIO controller. The first correspondence and the second correspondence are added to the device information, so that the first correspondence and the second correspondence are used as custom attributes in the device information of the GPIO controller.
当OS每次启动时,固件可以将ACPI表通过传参方式传递给OS,进而OS可以加载固件中定义的ACPI表,从而获得各个设备信息,OS加载GPIO控制器的设备信息时,便可获取到第一对应关系和第二对应关系。When the OS starts each time, the firmware can pass the ACPI table to the OS by passing parameters, and then the OS can load the ACPI table defined in the firmware to obtain each device information. When the OS loads the device information of the GPIO controller, it can obtain to the first correspondence and the second correspondence.
参照图3和图4,在另一种可选的实施方式中,步骤101具体包括以下步骤:3 and 4, in another optional implementation manner, step 101 specifically includes the following steps:
S12:在固件或操作系统的内核中,通过设备树,在GPIO控制器的设备信息中构建各个硬件中断资源与硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,其中,GPIO控制器的各个GPIO引脚均与中断控制器电连接。S12: In the firmware or the kernel of the operating system, through the device tree, build the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller, as well as the GPIO pin identification and index A second correspondence between the values, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller.
相应地,步骤102中加载第一对应关系和第二对应关系的步骤,具体包括:Correspondingly, the step of loading the first correspondence and the second correspondence in
S22:从固件或内核中加载设备树,以从GPIO控制器的设备信息中获得第一对应关系和第二对应关系。S22: Load the device tree from the firmware or the kernel to obtain the first correspondence and the second correspondence from the device information of the GPIO controller.
其中,设备树也提供了一种用于记录设备信息数据结构,可记录例如控制器、CPU等设备的设备信息,可以在固件或OS的内核中,根据各个设备信息构建出一个设备树,并在GPIO控制器的设备信息中增加第一对应关系和第二对应关系,从而将第一对应关系和第二对应关系作为GPIO控制器的设备信息中的自定义属性。Among them, the device tree also provides a data structure for recording device information, which can record the device information of devices such as controllers and CPUs. In the firmware or OS kernel, a device tree can be constructed according to each device information, and The first correspondence and the second correspondence are added to the device information of the GPIO controller, so that the first correspondence and the second correspondence are used as custom attributes in the device information of the GPIO controller.
当OS每次启动时,固件可以通过传参方式传递给OS的内核或者内核自身集成设备树,进而OS的内核可以依据设备树,从而获得各个设备信息,OS的内核加载GPIO控制器的设备信息时,便可获取到第一对应关系和第二对应关系。When the OS starts each time, the firmware can pass parameters to the OS kernel or the kernel itself integrates the device tree, and then the OS kernel can obtain the device information according to the device tree, and the OS kernel loads the device information of the GPIO controller. , the first corresponding relationship and the second corresponding relationship can be obtained.
本发明实施例提供了一种通用的GPIO中断资源的使用方法,无论是通过设备树还是ACPI表亦或是其它方式,且无论是GPIO中断资源复用、非复用、离散或连续,都可以使用该方法进行GPIO中断资源的定义、解析和使用。The embodiments of the present invention provide a general method for using GPIO interrupt resources, whether through a device tree, ACPI table or other methods, and whether GPIO interrupt resources are multiplexed, non-multiplexed, discrete or continuous, they can be Use this method to define, parse and use GPIO interrupt resources.
进一步地,步骤101中构建各个硬件中断资源与硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系的步骤,具体可以包括:Further, in
将各个硬件中断资源作为第一数组元素,通过第一数组元素的数组下标表示硬件中断资源的索引值,构建硬件中断资源与索引值呈一一对应关系的第一数组;Taking each hardware interrupt resource as the first array element, the index value of the hardware interrupt resource is represented by the array subscript of the first array element, and the first array in which the hardware interrupt resource and the index value are in a one-to-one correspondence is constructed;
通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个索引值作为第二数组元素,构建索引值与GPIO引脚标识呈一一对应关系的第二数组。Each GPIO pin identifier is represented by the array subscript of the second array element, and each index value is used as the second array element to construct a second array in which the index value and the GPIO pin identifier are in a one-to-one correspondence.
在本发明实施例中,可以在ACPI表或设备树中定义第一数组和第二数组。第一数组中包括多个第一数组元素,分别是不重复的各个硬件中断资源,对于任一硬件中断资源,可以将该硬件中断资源对应的数组下标作为该硬件中断资源的索引值,从而可以通过第一数组的各个数组下标索引硬件中断资源。第二数组中包括多个第二数组元素,第二数组通过数组下标表示每个GPIO引脚标识,第二数组元素即为各个GPIO引脚标识对应的硬件中断资源的索引值。In this embodiment of the present invention, the first array and the second array may be defined in an ACPI table or a device tree. The first array includes a plurality of first array elements, which are non-repetitive hardware interrupt resources. For any hardware interrupt resource, the array subscript corresponding to the hardware interrupt resource can be used as the index value of the hardware interrupt resource, so that Hardware interrupt resources may be indexed by respective array indices of the first array. The second array includes a plurality of second array elements, the second array represents each GPIO pin identifier by an array subscript, and the second array element is the index value of the hardware interrupt resource corresponding to each GPIO pin identifier.
以图2为例,第一数组A可以为{13,15},其中,第1个第一数组元素13为GPIO引脚0、2和4所对应的硬件中断资源,第2个第一数组元素15为GPIO引脚1、3和5所对应的硬件中断资源,其中,第一数组元素13的数组下标为0,第一数组元素15的数组下标为1。Taking Figure 2 as an example, the first array A can be {13,15}, where the first first array element 13 is the hardware interrupt resource corresponding to GPIO pins 0, 2 and 4, and the second first array element 13 Element 15 is the hardware interrupt resource corresponding to GPIO pins 1, 3 and 5, wherein the array subscript of the first array element 13 is 0, and the array subscript of the first array element 15 is 1.
相应地,第二数组B可以为{0,1,0,1,0,1},其中,6个第二数组元素的数组下标依次为0-5,分别表示GPIO引脚0-5。Correspondingly, the second array B may be {0, 1, 0, 1, 0, 1}, wherein the array subscripts of the six second array elements are 0-5 in sequence, respectively representing GPIO pins 0-5.
第1个第二数组元素0表示GPIO引脚0对应的硬件中断资源索引值为0,进而可以从第一数组A中找出数组下标为0的第一数组元素是13,也即表示GPIO引脚0对应的硬件中断资源为13。The first second array element 0 indicates that the hardware interrupt resource index value corresponding to GPIO pin 0 is 0, and then it can be found from the first array A that the first array element with the array subscript 0 is 13, which means GPIO The hardware interrupt resource corresponding to pin 0 is 13.
第2个第二数组元素1表示GPIO引脚1对应的硬件中断资源索引值为1,进而可以从第一数组A中找出数组下标为1的第一数组元素是15,也即表示GPIO引脚1对应的硬件中断资源为15。The second second array element 1 indicates that the hardware interrupt resource index value corresponding to GPIO pin 1 is 1, and then it can be found from the first array A that the first array element with the array subscript 1 is 15, which means GPIO The hardware interrupt resource corresponding to pin 1 is 15.
第3个第二数组元素0表示GPIO引脚2对应的硬件中断资源索引值为0,进而可以从第一数组A中找出数组下标为0的第一数组元素是13,也即表示GPIO引脚2对应的硬件中断资源为13。The third second array element 0 indicates that the hardware interrupt resource index value corresponding to GPIO pin 2 is 0, and then it can be found from the first array A that the first array element with the array subscript 0 is 13, which means GPIO The hardware interrupt resource corresponding to pin 2 is 13.
第4个第二数组元素1表示GPIO引脚3对应的硬件中断资源索引值为1,进而可以从第一数组A中找出数组下标为1的第一数组元素是15,也即表示GPIO引脚3对应的硬件中断资源为15。The fourth second array element 1 indicates that the hardware interrupt resource index value corresponding to GPIO pin 3 is 1, and then it can be found from the first array A that the first array element with the array subscript 1 is 15, which means GPIO The hardware interrupt resource corresponding to pin 3 is 15.
第5个第二数组元素0表示GPIO引脚4对应的硬件中断资源索引值为0,进而可以从第一数组A中找出数组下标为0的第一数组元素是13,也即表示GPIO引脚4对应的硬件中断资源为13。The fifth second array element 0 indicates that the hardware interrupt resource index value corresponding to GPIO pin 4 is 0, and then it can be found from the first array A that the first array element with the array subscript 0 is 13, which means GPIO The hardware interrupt resource corresponding to pin 4 is 13.
第6个第二数组元素1表示GPIO引脚5对应的硬件中断资源索引值为1,进而可以从第一数组A中找出数组下标为1的第一数组元素是15,也即表示GPIO引脚5对应的硬件中断资源为15。The sixth second array element 1 indicates that the hardware interrupt resource index value corresponding to GPIO pin 5 is 1, and then it can be found from the first array A that the first array element with the array subscript 1 is 15, which means GPIO The hardware interrupt resource corresponding to pin 5 is 15.
以上查找结果与图2所示的连接关系相符。The above search results are consistent with the connection relationship shown in Figure 2.
值得说明的是,本申请实施例虽然以数组结构来构建对应关系为例进行示例性说明,但第一对应关系及第二对应关系的构建并不一定局限于上述的举例,也可通过索引链表的形式来实现。以数组结构举例是因为数组结构本身属性带来了对应关系构建的便利性,因数组结构的属性在占用较少空间的情况下即可实现对应关系的构建。It is worth noting that although the embodiment of the present application uses an array structure to construct a corresponding relationship as an example for illustrative description, the construction of the first corresponding relationship and the second corresponding relationship is not necessarily limited to the above examples, and can also be constructed through an index linked list. form to achieve. Taking the array structure as an example is because the attributes of the array structure itself bring convenience to the construction of the corresponding relationship, because the attributes of the array structure can realize the construction of the corresponding relationship while occupying less space.
进一步可选地,上述通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个索引值作为第二数组元素,构建索引值与GPIO引脚标识呈一一对应关系的第二数组的步骤,具体可以包括:Further optionally, the above-mentioned array subscripts of the second array elements represent each GPIO pin identification, each index value is used as the second array element, and the index value and the GPIO pin identification are in a one-to-one correspondence relationship of the second array. The steps can specifically include:
对于任一GPIO引脚标识,在该GPIO引脚标识对应的GPIO引脚未与中断控制器中的任一输入引脚连接的情况下,将该GPIO引脚标识表示为第二数组元素的数组下标时所对应的第二数组元素填充为第一数组元素的数组下标的非法值。For any GPIO pin identification, in the case that the GPIO pin corresponding to the GPIO pin identification is not connected to any input pin in the interrupt controller, the GPIO pin identification is represented as an array of elements of the second array When subscripting, the corresponding second array element is filled with the illegal value of the array subscript of the first array element.
其中,对于任一GPIO引脚,在该GPIO引脚与中断控制器中的一个输入引脚连接的情况下,表示该GPIO引脚对应有硬件中断资源,因此,可以在第二数组中,将该GPIO引脚的标识对应的第二数组元素填充为第一数组元素的数组下标的合法值。而在该GPIO引脚未与中断控制器中的任何一个输入引脚连接的情况下,表示该GPIO引脚没有对应的硬件中断资源,因此,可以在第二数组中,将该GPIO引脚的标识对应的第二数组元素填充为第一数组元素的数组下标的非法值。Among them, for any GPIO pin, if the GPIO pin is connected to an input pin in the interrupt controller, it means that the GPIO pin corresponds to a hardware interrupt resource. Therefore, in the second array, the The second array element corresponding to the identifier of the GPIO pin is filled with the legal value of the array subscript of the first array element. In the case that the GPIO pin is not connected to any input pin in the interrupt controller, it means that the GPIO pin has no corresponding hardware interrupt resource. Therefore, in the second array, the GPIO pin's Identifies that the corresponding second array element is filled with an illegal value of the array subscript of the first array element.
以上述第一数组A{13,15}为例,在第一数组A中,第一数组元素的数组下标的合法值为0和1,第一数组元素的数组下标的非法值可以为负值(例如-1、-2等)或超过合法值范围{0,1}的正值(例如4、8等)。Taking the above first array A{13,15} as an example, in the first array A, the legal values of the array subscript of the first array element are 0 and 1, and the illegal value of the array subscript of the first array element can be a negative value (eg -1, -2, etc.) or positive values outside the legal value range {0,1} (eg 4, 8, etc.).
以第二数组B为{0,1,0,1,0,1}为例,第2个第二数组元素为1,是合法值,则可以从第一数组A中找出GPIO引脚1对应的硬件中断资源为13。Taking the second array B as {0,1,0,1,0,1} as an example, the second second array element is 1, which is a legal value, then you can find out the GPIO pin 1 from the first array A The corresponding hardware interrupt resource is 13.
再以第二数组B为{0,-1,0,1,0,1}为例,第2个第二数组元素为-1,是非法值,则无法从第一数组A中找出GPIO引脚1对应的硬件中断资源,表示GPIO引脚1没有对应的硬件中断资源。Taking the second array B as {0,-1,0,1,0,1} as an example, the second second array element is -1, which is an illegal value, so the GPIO cannot be found from the first array A The hardware interrupt resource corresponding to pin 1 indicates that there is no corresponding hardware interrupt resource for GPIO pin 1.
图5示出了本发明的另一种中断资源的使用方法实施例的步骤流程图,参照图5,还可选地,在步骤102中加载第一对应关系和第二对应关系之后,还可以包括以下步骤:FIG. 5 shows a flowchart of steps of another embodiment of a method for using interrupt resources according to the present invention. Referring to FIG. 5 , optionally, after the first correspondence and the second correspondence are loaded in
步骤105:构建各个硬件中断资源与软件中断资源的映射关系。Step 105: Build a mapping relationship between each hardware interrupt resource and software interrupt resource.
其中,各个硬件中断资源与软件中断资源的映射关系可以由相关软件进行构建和动态维护。The mapping relationship between each hardware interrupt resource and software interrupt resource may be constructed and dynamically maintained by relevant software.
相应地,在步骤104之后,还可以包括以下步骤:Correspondingly, after
步骤106:根据映射关系,对目标硬件中断资源进行中断映射,得到目标硬件中断资源对应的目标软件中断资源。Step 106: Perform interrupt mapping on the target hardware interrupt resource according to the mapping relationship to obtain the target software interrupt resource corresponding to the target hardware interrupt resource.
步骤107:将目标软件中断资源返回给提出用户申请的开发软件,以使用户根据目标软件中断资源定制中断例程。Step 107: Return the target software interrupt resource to the development software that has applied for the user, so that the user can customize the interrupt routine according to the target software interrupt resource.
其中,中断例程也即对外提供的中断功能接口或中断服务的集合。The interrupt routine is also a collection of interrupt function interfaces or interrupt services provided externally.
在实际应用中,由于硬件中断资源为较底层的数据,直接提供给使用开发软件的用户,会增加后续的开发难度,降低开发效率,因此,内核可以提供映射机制,从而将各个硬件中断资源映射为开发软件可用的软件中断资源,实现了很好的隔离和跨平台特性。映射后的软件中断资源具有响应优先级等机制,利于后续开发,对于使用开发软件进行开发的用户来说,几乎接触不到底层的硬件中断资源,为高效使用中央处理器资源提供了灵活性。In practical applications, since the hardware interrupt resources are lower-level data and are directly provided to users who use development software, it will increase the difficulty of subsequent development and reduce development efficiency. Therefore, the kernel can provide a mapping mechanism to map each hardware interrupt resource. The software interrupt resources available for developing software achieve good isolation and cross-platform features. The mapped software interrupt resources have response priority and other mechanisms, which are beneficial to subsequent development. For users who use development software for development, they can hardly touch the underlying hardware interrupt resources, providing flexibility for efficient use of CPU resources.
本发明实施例中,可以在电子设备任意一次上电后进行步骤101,并可以在电子设备后续每次上电后进行步骤102、105、103、104、106和107。In this embodiment of the present invention, step 101 may be performed after the electronic device is powered on any time, and steps 102, 105, 103, 104, 106, and 107 may be performed after each subsequent power-on of the electronic device.
在本发明实施例中,可通过索引值,间接构建GPIO引脚标识与硬件中断资源之间的对应关系,并且记录在固件或OS的内核中,当用户申请某个GPIO引脚的硬件中断资源时,OS读取并解析硬件中断资源与索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,进而OS可以根据这两个对应关系,向用户提供所申请的GPIO引脚的硬件中断资源。在本发明实施例中,由于索引值的定义不受一些机制中硬件中断资源是否复用、复用情况下是否连续的限制,因此,GPIO引脚标识与硬件中断资源之间的对应关系可以转换为第一对应关系和第二对应关系进行定义和传递,不仅可以实现复用且离散的硬件中断资源的使用,还能够实现复用且连续的硬件中断资源的使用,以及非复用的硬件中断资源的使用。In the embodiment of the present invention, the corresponding relationship between the GPIO pin identification and the hardware interrupt resource can be indirectly constructed through the index value, and recorded in the firmware or the kernel of the OS. When the user applies for the hardware interrupt resource of a GPIO pin When , the OS reads and parses the first correspondence between the hardware interrupt resource and the index value, and the second correspondence between the GPIO pin identifier and the index value, and then the OS can provide the user with The hardware interrupt resource of the requested GPIO pin. In the embodiment of the present invention, since the definition of the index value is not limited by whether the hardware interrupt resources are multiplexed and whether the multiplexing is continuous in some mechanisms, the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource can be converted Defining and transferring the first correspondence and the second correspondence can not only realize the use of multiplexed and discrete hardware interrupt resources, but also realize the use of multiplexed and continuous hardware interrupt resources, as well as the use of non-multiplexed hardware interrupts use of resources.
需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明实施例并不受所描述的动作顺序的限制,因为依据本发明实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本发明实施例所必须的。It should be noted that, for the sake of simple description, the method embodiments are described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the described action sequences, because According to embodiments of the present invention, certain steps may be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
参照图6,示出了本发明的一种中断资源的使用装置的结构框图,该装置300具体可以包括如下模块:Referring to FIG. 6, it shows a structural block diagram of an apparatus for using interrupt resources according to the present invention, and the
第一构建模块301,用于在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系;The
加载模块302,用于完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系;A
第一解析模块303,用于当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据所述用户申请中携带的所述目标GPIO引脚标识,从所述第二对应关系中,解析得到所述目标GPIO引脚标识对应的标索引值;The
第二解析模块304,用于从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源。The
可选地,所述第一构建模块301包括:Optionally, the
第一构建子模块,用于在固件中,通过高级配置和电源管理接口表,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;The first construction sub-module is used to construct the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller through the advanced configuration and the power management interface table in the firmware , and the second correspondence between the GPIO pin identification and the index value, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载模块302包括:The
第一加载子模块,用于从所述固件中加载所述高级配置和电源管理接口表,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。A first loading submodule, configured to load the advanced configuration and power management interface table from the firmware, so as to obtain the first correspondence and the second correspondence from device information of the GPIO controller.
可选地,所述第一构建模块301包括:Optionally, the
第二构建子模块,用于在固件或操作系统的内核中,通过设备树,在GPIO控制器的设备信息中构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系,其中,所述GPIO控制器的各个GPIO引脚均与中断控制器电连接;The second building submodule is used to build the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource in the device information of the GPIO controller through the device tree in the firmware or the kernel of the operating system , and the second correspondence between the GPIO pin identification and the index value, wherein each GPIO pin of the GPIO controller is electrically connected to the interrupt controller;
所述加载模块302包括:The
第二加载子模块,用于从所述固件或所述内核中加载所述设备树,以从所述GPIO控制器的设备信息中获得所述第一对应关系和所述第二对应关系。The second loading submodule is configured to load the device tree from the firmware or the kernel, so as to obtain the first correspondence and the second correspondence from the device information of the GPIO controller.
可选地,所述第一构建模块301包括:Optionally, the
第三构建子模块,用于将各个硬件中断资源作为第一数组元素,通过所述第一数组元素的数组下标表示所述硬件中断资源的索引值,构建所述硬件中断资源与所述索引值呈一一对应关系的第一数组;The third construction sub-module is configured to use each hardware interrupt resource as a first array element, use the array subscript of the first array element to indicate the index value of the hardware interrupt resource, and construct the hardware interrupt resource and the index The first array whose values are in a one-to-one correspondence;
第四构建子模块,用于通过第二数组元素的数组下标表示各个GPIO引脚标识,将各个所述索引值作为所述第二数组元素,构建所述索引值与所述GPIO引脚标识呈一一对应关系的第二数组。The fourth construction submodule is used to represent each GPIO pin identification by the array subscript of the second array element, and each described index value is used as the second array element, and the index value and the GPIO pin identification are constructed. A second array in a one-to-one correspondence.
可选地,所述第四构建子模块具体用于:Optionally, the fourth building submodule is specifically used for:
对于任一所述GPIO引脚标识,在所述GPIO引脚标识对应的GPIO引脚未与中断控制器中的任一输入引脚连接的情况下,将所述GPIO引脚标识表示为第二数组元素的数组下标时所对应的第二数组元素填充为所述第一数组元素的数组下标的非法值。For any of the GPIO pin identifications, in the case that the GPIO pin corresponding to the GPIO pin identification is not connected to any input pin in the interrupt controller, the GPIO pin identification is represented as the second The second array element corresponding to the array subscript of the array element is filled with the illegal value of the array subscript of the first array element.
可选地,所述装置300还包括:Optionally, the
第二构建模块,用于在操作系统的内核中,构建各个所述硬件中断资源与软件中断资源的映射关系表。The second building module is configured to build a mapping relationship table between each of the hardware interrupt resources and software interrupt resources in the kernel of the operating system.
可选地,所述装置300还包括:Optionally, the
第二加载模块,用于通过所述内核加载所述映射关系表;a second loading module, configured to load the mapping table through the kernel;
所述装置300还包括:The
映射模块,用于根据所述映射关系表,对所述目标硬件中断资源进行中断映射,得到所述目标硬件中断资源对应的目标软件中断资源;a mapping module, configured to perform interrupt mapping on the target hardware interrupt resource according to the mapping relationship table to obtain a target software interrupt resource corresponding to the target hardware interrupt resource;
返回模块,用于将所述目标软件中断资源返回给提出所述用户申请的开发软件,以使用户根据所述目标软件中断资源定制中断例程。The returning module is configured to return the target software interrupt resource to the development software that applies for the user, so that the user can customize an interrupt routine according to the target software interrupt resource.
可选地,一个所述硬件中断资源包括中断控制器上连接有所述GPIO引脚的一个输入引脚的引脚编号。Optionally, one of the hardware interrupt resources includes the pin number of an input pin on the interrupt controller to which the GPIO pin is connected.
在本发明实施例中,可通过索引值,间接构建GPIO引脚标识与硬件中断资源之间的对应关系,并且记录在固件或OS的内核中,当用户申请某个GPIO引脚的硬件中断资源时,OS读取并解析硬件中断资源与索引值之间的第一对应关系,以及GPIO引脚标识与索引值之间的第二对应关系,进而OS可以根据这两个对应关系,向用户提供所申请的GPIO引脚的硬件中断资源。在本发明实施例中,由于索引值的定义不受一些机制中硬件中断资源是否复用、复用情况下是否连续的限制,因此,GPIO引脚标识与硬件中断资源之间的对应关系可以转换为第一对应关系和第二对应关系进行定义和传递,不仅可以实现复用且离散的硬件中断资源的使用,还能够实现复用且连续的硬件中断资源的使用,以及非复用的硬件中断资源的使用。In the embodiment of the present invention, the corresponding relationship between the GPIO pin identification and the hardware interrupt resource can be indirectly constructed through the index value, and recorded in the firmware or the kernel of the OS. When the user applies for the hardware interrupt resource of a GPIO pin When , the OS reads and parses the first correspondence between the hardware interrupt resource and the index value, and the second correspondence between the GPIO pin identifier and the index value, and then the OS can provide the user with The hardware interrupt resource of the requested GPIO pin. In the embodiment of the present invention, since the definition of the index value is not limited by whether the hardware interrupt resources are multiplexed and whether the multiplexing is continuous in some mechanisms, the corresponding relationship between the GPIO pin identifier and the hardware interrupt resource can be converted Defining and transferring the first correspondence and the second correspondence can not only realize the use of multiplexed and discrete hardware interrupt resources, but also realize the use of multiplexed and continuous hardware interrupt resources, as well as the use of non-multiplexed hardware interrupts use of resources.
对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for related parts.
图7是根据一示例性实施例示出的一种用于开机显示的电子设备400的结构框图。例如,电子设备400可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。FIG. 7 is a structural block diagram of an
参照图7,电子设备400可以包括以下一个或多个组件:处理组件402,存储器404,电源组件406,多媒体组件408,音频组件410,输入/输出(I/O)的接口412,传感器组件414,以及通信组件416。7,
处理组件402通常控制电子设备400的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理元件402可以包括一个或多个处理器420来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件402可以包括一个或多个模块,便于处理组件402和其他组件之间的交互。例如,处理部件402可以包括多媒体模块,以方便多媒体组件408和处理组件402之间的交互。The
存储器404被配置为存储各种类型的数据以支持在设备400的操作。这些数据的示例包括用于在电子设备400上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器404可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。
电源组件406为电子设备400的各种组件提供电力。电源组件406可以包括电源管理系统,一个或多个电源,及其他与为电子设备400生成、管理和分配电力相关联的组件。
多媒体组件408包括在所述电子设备400和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。所述触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与所述触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件408包括一个前置摄像头和/或后置摄像头。当电子设备400处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。
音频组件410被配置为输出和/或输入音频信号。例如,音频组件410包括一个麦克风(MIC),当电子设备400处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器404或经由通信组件416发送。在一些实施例中,音频组件410还包括一个扬声器,用于输出音频信号。
I/O接口412为处理组件402和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/
传感器组件414包括一个或多个传感器,用于为电子设备400提供各个方面的状态评估。例如,传感器组件414可以检测到设备400的打开/关闭状态,组件的相对定位,例如所述组件为电子设备400的显示器和小键盘,传感器组件414还可以检测电子设备400或电子设备400一个组件的位置改变,用户与电子设备400接触的存在或不存在,电子设备400方位或加速/减速和电子设备400的温度变化。传感器组件414可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件414还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件414还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。
通信组件416被配置为便于电子设备400和其他设备之间有线或无线方式的通信。电子设备400可以接入基于通信标准的无线网络,如WiFi,2G或3G,或它们的组合。在一个示例性实施例中,通信组件416经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,所述通信组件416还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。
在示例性实施例中,电子设备400可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。In an exemplary embodiment,
在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器404,上述指令可由电子设备400的处理器420执行以完成上述方法。例如,所述非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium including instructions, such as
一种可读存储介质,当所述存储介质中的指令由电子设备的处理器执行时,使得电子设备能够执行一种中断资源的使用方法,所述方法包括:A readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute a method for using interrupt resources, the method comprising:
在固件或操作系统的内核中,构建各个硬件中断资源与所述硬件中断资源的索引值之间的第一对应关系,以及GPIO引脚标识与所述索引值之间的第二对应关系;In the kernel of firmware or operating system, construct the first correspondence between each hardware interrupt resource and the index value of the hardware interrupt resource, and the second correspondence between the GPIO pin identification and the index value;
完成构建后,当所述操作系统每次启动时,加载所述第一对应关系和所述第二对应关系;After completing the construction, load the first correspondence and the second correspondence each time the operating system is started;
当接收到用于获取目标GPIO引脚标识对应中断资源的用户申请时,根据所述用户申请中携带的所述目标GPIO引脚标识,从所述第二对应关系中,解析得到所述目标GPIO引脚标识对应的目标索引值;When receiving the user application for obtaining the interrupt resource corresponding to the target GPIO pin identifier, according to the target GPIO pin identifier carried in the user application, from the second correspondence, parse and obtain the target GPIO The target index value corresponding to the pin identification;
从所述第一对应关系中,解析得到所述目标索引值对应的所述目标硬件中断资源。From the first correspondence, the target hardware interrupt resource corresponding to the target index value is obtained by parsing.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other.
本领域内的技术人员应明白,本发明实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It should be understood by those skilled in the art that the embodiments of the embodiments of the present invention may be provided as a method, an apparatus, or a computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media having computer-usable program code embodied therein, including but not limited to disk storage, CD-ROM, optical storage, and the like.
本发明实施例是参照根据本发明实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。Embodiments of the present invention are described with reference to flowcharts and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the present invention. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing terminal equipment to produce a machine that causes the instructions to be executed by the processor of the computer or other programmable data processing terminal equipment Means are created for implementing the functions specified in the flow or flows of the flowcharts and/or the blocks or blocks of the block diagrams.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以预测方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal equipment to operate in a predictive manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising instruction means, the The instruction means implement the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing terminal equipment, so that a series of operational steps are performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby executing on the computer or other programmable terminal equipment The instructions executed on the above provide steps for implementing the functions specified in the flowchart or blocks and/or the block or blocks of the block diagrams.
尽管已描述了本发明实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明实施例范围的所有变更和修改。Although preferred embodiments of the embodiments of the present invention have been described, additional changes and modifications to these embodiments may be made by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the embodiments of the present invention.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or terminal device comprising a list of elements includes not only those elements, but also a non-exclusive list of elements. other elements, or also include elements inherent to such a process, method, article or terminal equipment. Without further limitation, an element defined by the phrase "comprises a..." does not preclude the presence of additional identical elements in the process, method, article or terminal device comprising said element.
以上对本发明所提供的一种中断资源的使用方法和装置、一种电子设备以及一种存储介质,进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。A method and device for using an interrupt resource, an electronic device, and a storage medium provided by the present invention have been described above in detail. In this paper, specific examples are used to illustrate the principles and implementations of the present invention. The description of the embodiment is only used to help understand the method of the present invention and its core idea; meanwhile, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in specific embodiments and application scope. As mentioned above, the contents of this specification should not be construed as limiting the present invention.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111594568.7A CN114385335A (en) | 2021-12-23 | 2021-12-23 | Method, device, device and storage medium for using interrupt resources |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111594568.7A CN114385335A (en) | 2021-12-23 | 2021-12-23 | Method, device, device and storage medium for using interrupt resources |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114385335A true CN114385335A (en) | 2022-04-22 |
Family
ID=81197263
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111594568.7A Pending CN114385335A (en) | 2021-12-23 | 2021-12-23 | Method, device, device and storage medium for using interrupt resources |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114385335A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116521198A (en) * | 2023-04-13 | 2023-08-01 | 广州汽车集团股份有限公司 | Data processing method, device, device, and computer-readable storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6219743B1 (en) * | 1998-09-30 | 2001-04-17 | International Business Machines Corporation | Apparatus for dynamic resource mapping for isolating interrupt sources and method therefor |
US20140237151A1 (en) * | 2013-02-15 | 2014-08-21 | International Business Machines Corporation | Determining a virtual interrupt source number from a physical interrupt source number |
CN107025132A (en) * | 2016-02-02 | 2017-08-08 | 龙芯中科技术有限公司 | Interrupt collocation method and device |
CN109906444A (en) * | 2016-09-05 | 2019-06-18 | Iot耐科特有限公司 | The equipment interface system and method for software definition |
CN113326069A (en) * | 2020-02-28 | 2021-08-31 | 广东龙芯中科电子科技有限公司 | Operating system starting method and device, electronic equipment and storage medium |
-
2021
- 2021-12-23 CN CN202111594568.7A patent/CN114385335A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6219743B1 (en) * | 1998-09-30 | 2001-04-17 | International Business Machines Corporation | Apparatus for dynamic resource mapping for isolating interrupt sources and method therefor |
US20140237151A1 (en) * | 2013-02-15 | 2014-08-21 | International Business Machines Corporation | Determining a virtual interrupt source number from a physical interrupt source number |
CN107025132A (en) * | 2016-02-02 | 2017-08-08 | 龙芯中科技术有限公司 | Interrupt collocation method and device |
CN109906444A (en) * | 2016-09-05 | 2019-06-18 | Iot耐科特有限公司 | The equipment interface system and method for software definition |
CN113326069A (en) * | 2020-02-28 | 2021-08-31 | 广东龙芯中科电子科技有限公司 | Operating system starting method and device, electronic equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
JKLINUX: "设备树里直接提供gpio口的中断号", pages 1 - 2, Retrieved from the Internet <URL:《https://blog.csdn.net/jklinux/article/details/78707537》> * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116521198A (en) * | 2023-04-13 | 2023-08-01 | 广州汽车集团股份有限公司 | Data processing method, device, device, and computer-readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
RU2766255C1 (en) | Voice control method and electronic device | |
US10969954B2 (en) | Electronic device for processing user input and method for processing user input | |
US20220050656A1 (en) | Method for displaying ui component and electronic device | |
JP6189000B2 (en) | Application installation package processing method, apparatus, program, and recording medium | |
WO2016041312A1 (en) | Application program running method and device | |
US20150333971A1 (en) | Method and device for managing processes of application program | |
WO2017071078A1 (en) | Communication module firmware and plug-in generation method and apparatus | |
JP2017505966A (en) | Firmware upgrade method, apparatus, program, and recording medium | |
US20170060260A1 (en) | Method and device for connecting external equipment | |
US9870239B2 (en) | Method and device for running application program | |
WO2017113666A1 (en) | Application interface switching method and device | |
CN114461239B (en) | Software upgrading system and software upgrading method | |
US9807219B2 (en) | Method and terminal for executing user instructions | |
EP2924552B1 (en) | Method and mobile terminal for executing user instructions | |
CN111752598A (en) | Page generating method, device, electronic device and storage medium | |
CN111966410B (en) | Start-up processing method and device, electronic equipment and storage medium | |
CN105183571A (en) | Function calling method and device | |
WO2021042991A1 (en) | Non-intrusive interaction method and electronic device | |
CN107463372B (en) | Data-driven page updating method and device | |
CN116048757A (en) | Task processing method, device, electronic equipment and storage medium | |
CN114385335A (en) | Method, device, device and storage medium for using interrupt resources | |
JP2017520877A5 (en) | ||
US11399359B2 (en) | Method and device for extending PBCH | |
CN114968877B (en) | Hardware management methods, adapters, hosts and storage media | |
US11308197B2 (en) | Intelligent device recognition using prompt frequency information |
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 |