WO2019072182A1 - Hardware abstraction layer multiplexing method and apparatus, operating system and device - Google Patents

Hardware abstraction layer multiplexing method and apparatus, operating system and device Download PDF

Info

Publication number
WO2019072182A1
WO2019072182A1 PCT/CN2018/109550 CN2018109550W WO2019072182A1 WO 2019072182 A1 WO2019072182 A1 WO 2019072182A1 CN 2018109550 W CN2018109550 W CN 2018109550W WO 2019072182 A1 WO2019072182 A1 WO 2019072182A1
Authority
WO
WIPO (PCT)
Prior art keywords
hardware
operating system
abstraction layer
hardware abstraction
application program
Prior art date
Application number
PCT/CN2018/109550
Other languages
French (fr)
Chinese (zh)
Inventor
方文骁
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2019072182A1 publication Critical patent/WO2019072182A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication

Abstract

Provided are a hardware abstraction layer multiplexing method and apparatus, an operating system and a device. The method comprises: in response to a hardware operation instruction, a first process of a first operating system invoking a first application program interface (API) in a virtual hardware abstraction layer (HAL) at a first operating system side, and sending an invoking request of the first API to a second operating system by means of cross-process communication, so that a second process in the second operating system invokes a second API in an HAL at a second operating system side so as to execute the hardware operation instruction, wherein the configuration of the first API in the virtual HAL corresponds to the configuration of the second API in the HAL at the second operating system side. By providing the virtual HAL at a first operating system side, the invoking of an API in the virtual HAL by the first operating system side can be transferred to a second operating system side by means of cross-process communication so as to realize the multiplexing of an HAL at the second operating system side by means of a first operating system, and the present invention is convenient to realize, and can be applied to any different operating systems.

Description

硬件抽象层复用方法、装置、操作系统和设备Hardware abstraction layer multiplexing method, device, operating system and device
本申请要求2017年10月13日递交的申请号为201710953523.1、发明名称为“硬件抽象层复用方法、装置、操作系统和设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. 201710953523.1, entitled "Hardware Abstraction Layer Reuse Method, Apparatus, Operating System, and Device", which is filed on October 13, 2017, the entire contents of which are incorporated herein by reference. In the application.
技术领域Technical field
本发明涉及操作系统技术领域,尤其涉及一种硬件抽象层复用方法、装置、操作系统和设备。The present invention relates to the field of operating system technologies, and in particular, to a hardware abstraction layer multiplexing method, apparatus, operating system, and device.
背景技术Background technique
手机等终端设备厂商在开发终端设备时,往往仅针对一种操作系统开发一套硬件抽象层(Hardware Abstraction Layer,简称HAL)。如果该终端设备中还需支持另一种操作系统,则最高效的方法就是重用即复用这套HAL。而往往两个不同的操作系统所基于的基础C库是不同的,这就对复用HAL带来了适配难度。When developing terminal devices, mobile terminal and other terminal equipment manufacturers often develop a hardware abstraction layer (HAL) for only one operating system. If the terminal device still needs to support another operating system, the most efficient method is to reuse or reuse the HAL. Often, the basic C libraries on which two different operating systems are based are different, which makes adaptation of the HAL multiplexed.
目前,最常使用的适配方案是直接采用Libhybris机制加载HAL,可以实现基于Bionic的安卓操作系统与基于Glibc的操作系统复用同一HAL,其中,Bionic为安卓操作系统的基础C库,Glibc为GNU操作系统的基础C库。为使用Libhybris机制,首先需要将HAL使用到的所有函数和数据结构在两个基础C库上做匹配,即建立两个基础C库中函数、数据结构的映射关系,而且还可能需要在两个基础C库中额外添加或者修改其中的函数。At present, the most commonly used adaptation scheme is to directly load the HAL using the Libhybris mechanism. The Bionic-based Android operating system and the Glibc-based operating system can be reused in the same HAL. Among them, Bionic is the basic C library of the Android operating system, and Glibc is The base C library for the GNU operating system. In order to use the Libhybris mechanism, it is first necessary to match all the functions and data structures used by the HAL on the two basic C libraries, that is, to establish the mapping relationship between functions and data structures in the two basic C libraries, and may also need to be in two Additional functions are added or modified in the base C library.
基于Libhybris机制仅能够实现上述特定两种操作系统对HAL的复用,局限性较大;而且还需要对两种基础C库做复杂的适配处理,实现难度较大。Based on the Libhybris mechanism, only the above two operating systems can be reused for HAL, and the limitation is large. Moreover, complex adaptation processing is required for the two basic C libraries, which is difficult to implement.
发明内容Summary of the invention
有鉴于此,本发明实施例提供一种硬件抽象层复用方法、装置、操作系统和设备,用以降低不同操作系统复用同一硬件抽象层的难度。In view of this, the embodiments of the present invention provide a hardware abstraction layer multiplexing method, device, operating system, and device, which are used to reduce the difficulty of multiplexing the same hardware abstraction layer by different operating systems.
第一方面,本发明实施例提供一种硬件抽象层复用方法,应用于第一操作系统的第一进程中,包括:In a first aspect, an embodiment of the present invention provides a hardware abstraction layer multiplexing method, which is applied to a first process of a first operating system, and includes:
响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口;Retrieving a first application interface in a virtual hardware abstraction layer corresponding to the first operating system in response to a hardware operation instruction;
通过跨进程通信将所述应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令;Sending, by the inter-process communication, the call request of the application program interface to the second operating system, so that the second process in the second operating system invokes the hardware abstraction layer corresponding to the second operating system according to the call request The second application program interface executes the hardware operation instruction;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
第二方面,本发明实施例提供一种硬件抽象层复用装置,应用于第一操作系统的第一进程中,包括:In a second aspect, the embodiment of the present invention provides a hardware abstraction layer multiplexing device, which is applied to a first process of a first operating system, and includes:
调用模块,用于响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口;Calling a module, in response to the hardware operation instruction, calling a first application interface in the virtual hardware abstraction layer corresponding to the first operating system;
发送模块,用于通过跨进程通信将所述第一应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令;a sending module, configured to send, by using a cross-process communication, a call request of the first application program interface to a second operating system, so that a second process in the second operating system invokes the second The second application program interface in the hardware abstraction layer corresponding to the operating system executes the hardware operation instruction;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
第三方面,本发明实施例提供一种操作系统,包括:应用程序框架层和虚拟硬件抽象层;In a third aspect, an embodiment of the present invention provides an operating system, including: an application framework layer and a virtual hardware abstraction layer;
所述应用程序框架层中包括一进程,该进程用于实现如第一方面所述的硬件抽象层复用方法;The application framework layer includes a process for implementing the hardware abstraction layer multiplexing method as described in the first aspect;
所述虚拟硬件抽象层中应用程序接口的配置与另一操作系统对应的硬件抽象层中应用程序接口的配置具有对应关系。所述虚拟硬件抽象层中应用程序接口的实现指示了将对虚拟硬件抽象层中应用程序接口的调用请求通过跨进程通信传输至另一操作系统。该操作系统对应于第一方面中的第一操作系统。The configuration of the application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the application program interface in the hardware abstraction layer corresponding to another operating system. Implementation of the application program interface in the virtual hardware abstraction layer indicates that a call request to an application interface in the virtual hardware abstraction layer is transmitted to another operating system through inter-process communication. The operating system corresponds to the first operating system in the first aspect.
第四方面,本发明实施例提供一种电子设备,该电子设备可以实现为用户终端设备,包括处理器和存储器,所述存储器用于存储支持用户终端设备执行上述第一方面中硬件抽象层复用方法的程序,所述处理器被配置为用于执行所述存储器中存储的程序。该电子设备中还可以包括通信接口,用于与其他设备或通信网络通信。In a fourth aspect, an embodiment of the present invention provides an electronic device, where the electronic device can be implemented as a user terminal device, including a processor and a memory, where the memory is used to store and support the user terminal device to perform the hardware abstraction layer recovery in the first aspect. In a program of a method, the processor is configured to execute a program stored in the memory. The electronic device can also include a communication interface for communicating with other devices or communication networks.
另外,本发明实施例提供了一种计算机存储介质,用于储存该电子设备所用的计算机软件指令,其包含用于执行上述第一方面中硬件抽象层复用方法所涉及的程序。In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions for the electronic device, which includes a program for performing the hardware abstraction layer multiplexing method in the above first aspect.
第五方面,本发明实施例提供一种硬件抽象层复用方法,应用于第一操作系统的第一进程中,包括:In a fifth aspect, an embodiment of the present invention provides a hardware abstraction layer multiplexing method, which is applied to a first process of a first operating system, and includes:
接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的;Receiving a call request sent by the second process in the second operating system by the cross-process communication, where the call request is the second process in the virtual hardware abstraction layer corresponding to the second operating system in response to the hardware operation instruction Triggered by an application interface;
根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令;And calling a second application program interface in the hardware abstraction layer corresponding to the second operating system to execute the hardware operation instruction according to the calling request;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
第六方面,本发明实施例提供一种硬件抽象层复用装置,应用于第一操作系统的第一进程中,包括:In a sixth aspect, the embodiment of the present invention provides a hardware abstraction layer multiplexing device, which is applied to a first process of a first operating system, and includes:
接收模块,用于接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的;a receiving module, configured to receive a call request sent by the second process in the second operating system by using the cross-process communication, where the call request is that the second process invokes the virtual hardware corresponding to the second operating system in response to the hardware operation instruction Triggered by the first application interface in the abstraction layer;
调用模块,用于根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令;a calling module, configured to invoke a second application program interface in a hardware abstraction layer corresponding to the second operating system according to the calling request, to execute the hardware operation instruction;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
第七方面,本发明实施例提供一种操作系统,包括:应用程序框架层和跨进程通信接口,应用程序框架层中包括一进程,该进程用于实现如第五方面所述的硬件抽象层复用方法。该操作系统对应于第五方面中的第一操作系统。In a seventh aspect, an embodiment of the present invention provides an operating system, including: an application framework layer and a cross-process communication interface, where the application framework layer includes a process, and the process is used to implement the hardware abstraction layer as described in the fifth aspect. Reuse method. The operating system corresponds to the first operating system in the fifth aspect.
第八方面,本发明实施例提供一种电子设备,该电子设备可以实现为用户终端设备,比如智能手机等,包括处理器和存储器,所述存储器用于存储支持该电子设备执行上述第五方面中硬件抽象层复用方法的程序,所述处理器被配置为用于执行所述存储器中存储的程序。该电子设备中还可以包括通信接口,用于与其他设备或通信网络通信。In an eighth aspect, an embodiment of the present invention provides an electronic device, where the electronic device can be implemented as a user terminal device, such as a smart phone, and the like, and includes a processor and a memory, where the memory is used to store and support the electronic device to perform the foregoing fifth aspect. A program of a hardware abstraction layer multiplexing method, the processor being configured to execute a program stored in the memory. The electronic device can also include a communication interface for communicating with other devices or communication networks.
另外,本发明实施例提供了一种计算机存储介质,用于储存该电子设备所用的计算机软件指令,其包含用于执行上述第五方面中硬件抽象层复用方法所涉及的程序。In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions for the electronic device, which includes a program for performing the hardware abstraction layer multiplexing method in the fifth aspect.
本发明实施例提供的硬件抽象层复用方法、装置、操作系统和设备,在某终端设备中包含有基于不同基础C库的第一操作系统和第二操作系统,初始开发的HAL是针对第二操作系统的,称为真实HAL。为使得第一操作系统能够复用该真实HAL,在第一操作系统侧设置虚拟HAL,该虚拟HAL中封装的应用程序接口(Application Program Interface,简称API)的配置与真实HAL中封装的API的配置具有对应关系,比如相同, 但是该虚拟HAL中封装的API的实现与真实HAL中封装的API的实现不同,虚拟HAL中封装的API实现指示了通过跨进程通信将第一操作系统侧调用的API传输至第二操作系统侧,而真实HAL中封装的API实现是实际完成API调用所需执行的相关操作信息。The hardware abstraction layer multiplexing method, device, operating system and device provided by the embodiments of the present invention include a first operating system and a second operating system based on different basic C libraries in a terminal device, and the initially developed HAL is directed to the first The second operating system is called the real HAL. In order to enable the first operating system to multiplex the real HAL, a virtual HAL is set on the first operating system side, and an application program interface (API) configured in the virtual HAL is configured with an API encapsulated in the real HAL. The configuration has a corresponding relationship, such as the same, but the implementation of the API encapsulated in the virtual HAL is different from the implementation of the API encapsulated in the real HAL. The API implementation encapsulated in the virtual HAL indicates that the first operating system side is called by cross-process communication. The API is transmitted to the second operating system side, and the API implementation encapsulated in the real HAL is related operational information that is required to actually perform the API call.
基于此,当第一操作系统侧响应于用户的操作而触发针对某硬件比如摄像头的硬件操作指令时,会触发位于第一操作系统侧的第一进程调用与该硬件对应的虚拟HAL中相应的第一API比如摄像头开启接口,从而,第一进程可以基于该第一API的实现,通过跨进程通信将调用该第一API的调用请求发送至第二操作系统侧,第二操作系统的第二进程收到该调用请求后,调用真实HAL中对应的第二API,从而根据该第二API的实现完成硬件操作指令的执行。本方案,仅需在第一操作系统侧设置上述虚拟HAL即使得虚拟HAL中API配置与真实HAL的API配置具有对应关系,并将虚拟HAL中的API实现设置为通过跨进程通信将对虚拟HAL中某个API的调用传递到对应于真实HAL的第二操作系统中,即可使得第一操作系统能够复用第二操作系统侧的真实HAL,实现方便,且可以适用于任意不同的操作系统。Based on this, when the first operating system side triggers a hardware operation instruction for a certain hardware such as a camera in response to the user's operation, the first process call on the first operating system side is triggered to call the corresponding corresponding virtual HAL corresponding to the hardware. The first API, such as the camera, opens the interface, so that the first process can send a call request to invoke the first API to the second operating system side, and the second operating system second, by cross-process communication based on the implementation of the first API. After receiving the call request, the process calls the corresponding second API in the real HAL, thereby completing the execution of the hardware operation instruction according to the implementation of the second API. In this solution, the virtual HAL needs to be set on the first operating system side, so that the API configuration in the virtual HAL has a corresponding relationship with the real HAL API configuration, and the API implementation in the virtual HAL is set to be a virtual HAL through cross-process communication. The call of an API is passed to the second operating system corresponding to the real HAL, so that the first operating system can reuse the real HAL of the second operating system side, which is convenient to implement and can be applied to any different operating system. .
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description of the drawings used in the embodiments or the prior art description will be briefly described below. Obviously, the drawings in the following description It is a certain embodiment of the present invention, and other drawings can be obtained from those skilled in the art without any creative work.
图1为本发明实施例提供的一种硬件抽象层复用场景示意图;FIG. 1 is a schematic diagram of a hardware abstraction layer multiplexing scenario according to an embodiment of the present invention;
图2为本发明实施例提供的一种硬件抽象层复用方法的流程图;2 is a flowchart of a hardware abstraction layer multiplexing method according to an embodiment of the present invention;
图3为本发明实施例提供的另一种硬件抽象层复用方法的流程图;FIG. 3 is a flowchart of another hardware abstraction layer multiplexing method according to an embodiment of the present invention;
图4为本发明实施例提供的又一种硬件抽象层复用方法的流程图;FIG. 4 is a flowchart of still another hardware abstraction layer multiplexing method according to an embodiment of the present invention;
图5为本发明实施例提供的一种硬件抽象层复用方法的交互图;FIG. 5 is an interaction diagram of a hardware abstraction layer multiplexing method according to an embodiment of the present invention;
图6为与图2所示实施例对应的一种硬件抽象层复用装置的结构示意图;6 is a schematic structural diagram of a hardware abstraction layer multiplexing device corresponding to the embodiment shown in FIG. 2;
图7为与图2所示实施例对应的一种操作系统的组成示意图;7 is a schematic diagram showing the composition of an operating system corresponding to the embodiment shown in FIG. 2;
图8为与图6所示硬件抽象层复用装置对应的电子设备的结构示意图;8 is a schematic structural diagram of an electronic device corresponding to the hardware abstraction layer multiplexing device shown in FIG. 6;
图9为与图3或图4所示实施例对应的一种硬件抽象层复用装置的结构示意图;9 is a schematic structural diagram of a hardware abstraction layer multiplexing device corresponding to the embodiment shown in FIG. 3 or FIG. 4;
图10为与图3或图4所示实施例对应的一种操作系统的组成示意图;10 is a schematic diagram showing the composition of an operating system corresponding to the embodiment shown in FIG. 3 or FIG. 4;
图11为与图9所示硬件抽象层复用装置对应的电子设备的结构示意图。FIG. 11 is a schematic structural diagram of an electronic device corresponding to the hardware abstraction layer multiplexing device shown in FIG. 9.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
在本发明实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本发明。在本发明实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义,“多种”一般包含至少两种,但是不排除包含至少一种的情况。The terms used in the embodiments of the present invention are for the purpose of describing particular embodiments only and are not intended to limit the invention. The singular forms "a", "the", "the" and "the" Generally, at least two types are included, but the case of including at least one is not excluded.
应当理解,本文中使用的术语“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系。It should be understood that the term "and/or" as used herein is merely an association describing the associated object, indicating that there may be three relationships, for example, A and/or B, which may indicate that A exists separately, while A and B, there are three cases of B alone. In addition, the character "/" in this article generally indicates that the contextual object is an "or" relationship.
应当理解,尽管在本发明实施例中可能采用术语第一、第二、第三等来描述XXX,但这些XXX不应限于这些术语。这些术语仅用来将XXX区分开。例如,在不脱离本发明实施例范围的情况下,第一XXX也可以被称为第二XXX,类似地,第二XXX也可以被称为第一XXX。It should be understood that although the terms first, second, third, etc. may be used to describe XXX in embodiments of the invention, these XXX should not be limited to these terms. These terms are only used to distinguish XXX. For example, the first XXX may also be referred to as a second XXX without departing from the scope of the embodiments of the present invention. Similarly, the second XXX may also be referred to as a first XXX.
取决于语境,如在此所使用的词语“如果”、“若”可以被解释成为“在……时”或“当……时”或“响应于确定”或“响应于检测”。类似地,取决于语境,短语“如果确定”或“如果检测(陈述的条件或事件)”可以被解释成为“当确定时”或“响应于确定”或“当检测(陈述的条件或事件)时”或“响应于检测(陈述的条件或事件)”。Depending on the context, the words "if" and "if" as used herein may be interpreted to mean "when" or "when" or "in response to determining" or "in response to detecting." Similarly, depending on the context, the phrase "if determined" or "if detected (conditions or events stated)" can be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event) "Time" or "in response to a test (condition or event stated)".
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的商品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种商品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的商品或者系统中还存在另外的相同要素。It should also be noted that the terms "including", "comprising" or "comprising" or any other variations thereof are intended to encompass a non-exclusive inclusion, such that the item or system comprising a plurality of elements includes not only those elements but also Other elements, or elements that are inherent to such goods or systems. An element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the item or system including the element, without further limitation.
另外,下述各方法实施例中的步骤时序仅为一种举例,而非严格限定。In addition, the sequence of steps in the following method embodiments is merely an example and is not strictly limited.
图1为本发明实施例提供的一种硬件抽象层复用场景示意图,如图1中所示,假设 某终端设备中包含有基于不同基础C库的两个操作系统OS_A与OS_B,其中,OS_A是基于基础C库——Libc_A开发的,OS_B是基于基础C库——Libc_B开发的A。对应于该场景,本发明实施例提供的硬件抽象层复用方法用于实现图1中所示两个操作系统——OS_A与OS_B对位于OS_A侧的HAL的复用。FIG. 1 is a schematic diagram of a hardware abstraction layer multiplexing scenario according to an embodiment of the present invention. As shown in FIG. 1 , a terminal device includes two operating systems OS_A and OS_B based on different basic C libraries, where OS_A is included. It is based on the basic C library, Libc_A, and OS_B is based on the basic C library, A developed by Libc_B. Corresponding to the scenario, the hardware abstraction layer multiplexing method provided by the embodiment of the present invention is used to implement multiplexing of the two operating systems shown in FIG. 1 , OS_A and OS_B, to the HAL located on the OS_A side.
假设初始开发的HAL是针对OS_A的,为与虚拟HAL区别,假设称为真实HAL。为使得OS_B能够复用该真实HAL,在OS_B侧设置虚拟HAL。具体地,该虚拟HAL中封装的API的配置(也可以称为定义)与真实HAL中封装的API的配置具有对应关系,其中,优选地,可以设置该虚拟HAL中封装的API的配置与真实HAL中封装的API的配置相同,但是该虚拟HAL中封装的API的实现与真实HAL中封装的API的实现不同,虚拟HAL中封装的API实现指示了通过跨进程通信将OS_B侧调用的API传输至OS_A侧,而真实HAL中封装的API实现是实际完成API调用所需执行的相关操作信息。Assume that the initially developed HAL is for OS_A, and is different from the virtual HAL, assuming it is called a real HAL. In order to enable OS_B to multiplex the real HAL, a virtual HAL is set on the OS_B side. Specifically, the configuration of the API encapsulated in the virtual HAL (which may also be referred to as a definition) has a corresponding relationship with the configuration of the API encapsulated in the real HAL. Preferably, the configuration and reality of the encapsulated API in the virtual HAL may be set. The configuration of the API encapsulated in the HAL is the same, but the implementation of the API encapsulated in the virtual HAL is different from the implementation of the API encapsulated in the real HAL. The API implementation encapsulated in the virtual HAL indicates that the API called by the OS_B side is transmitted through cross-process communication. To the OS_A side, the API implementation encapsulated in the real HAL is the relevant operational information required to actually complete the API call.
其中,虚拟HAL中封装的API的配置与真实HAL中封装的API的配置具有对应关系可以表现为一一对应关系,也可以表现为多对一的对应关系。举例来说,假设真实HAL中存在某个API配置为function(A,B,C),则虚拟HAL中与该API对应的API配置可以为:function(A),function(B),function(C),即形成三对一的对应关系。The mapping between the configuration of the API encapsulated in the virtual HAL and the configuration of the API encapsulated in the real HAL may be expressed as a one-to-one correspondence, or may be represented as a many-to-one correspondence. For example, if an API is configured as function(A, B, C) in the real HAL, the API configuration corresponding to the API in the virtual HAL can be: function(A), function(B), function(C ), that is, a three-to-one correspondence is formed.
其中,由于虚拟HAL中API实现的内容涉及到跨进程通信,因此,需要建立如图1中所示的上述两个操作系统间的跨进程通信(IPC)连接:IPC Bridge,如图中示意的IPC_A,IPC_B是该通信的两端接口。可选地,该跨进程通信可以预先建立好,以便后续直接使用,也可以在需要时实时建立。Wherein, since the content implemented by the API in the virtual HAL involves cross-process communication, it is necessary to establish an inter-process communication (IPC) connection between the above two operating systems as shown in FIG. 1 : IPC Bridge, as illustrated in the figure. IPC_A, IPC_B is the interface at both ends of the communication. Optionally, the cross-process communication may be pre-established for subsequent direct use, or may be established in real time as needed.
可以理解为,上述跨进程通信的建立,即为在OS_A侧建立接口IPC_A,在OS_B侧建立接口IPC_B,其中,IPC_A是基于Libc_A的,IPC_B是基于Libc_B的。It can be understood that the establishment of the above-mentioned cross-process communication is to establish an interface IPC_A on the OS_A side and an interface IPC_B on the OS_B side, wherein the IPC_A is based on Libc_A and the IPC_B is based on Libc_B.
可选地,该跨进程通信连接可以基于操作系统内核Kernel中提供的IPC机制实现,如Socket,OpenBinder,但是并不限于这两种实现方式。Optionally, the cross-process communication connection may be implemented based on an IPC mechanism provided in an operating system kernel Kernel, such as Socket, OpenBinder, but is not limited to the two implementation manners.
另外,本发明实施例中的真实HAL和虚拟HAL可以认为是针对终端设备中的某个硬件的抽象层,比如摄像头的硬件抽象层:camera HAL;或者,传感器的硬件抽象层:sensor HAL,等等。In addition, the real HAL and the virtual HAL in the embodiment of the present invention may be considered as an abstraction layer for a certain hardware in the terminal device, such as a hardware abstraction layer of the camera: camera HAL; or a hardware abstraction layer of the sensor: sensor HAL, etc. Wait.
基于上述两个操作系统的设置情况,举例来说,当OS_B侧某个相机应用程序响应于用户的操作而需要调用camera HAL来操作摄像头时,该相机应用程序可以启动一个进程,该进程可以认为是进程B,该进程B比如调用虚拟camera HAL中的某个API,假 设该API的配置和实现如下:Based on the setting conditions of the above two operating systems, for example, when a camera application on the OS_B side needs to call the camera HAL to operate the camera in response to the user's operation, the camera application can start a process, and the process can think Is process B, the process B, for example, calls an API in the virtual camera HAL, assuming that the configuration and implementation of the API is as follows:
bool open(int cameraId){Bool open(int cameraId){
return ipc_send(API_OPEN,cameraId);Return ipc_send(API_OPEN,cameraId);
}}
该API用于触发对摄像头的开启操作。其中,bool open(int cameraId)为该API的配置,{}中的内容为该API的实现。cameraId是调用参数,指示需要操作的是哪个摄像头,比如Id=0为前置摄像头,Id=1为后置摄像头。API_OPEN指示了是调用Open这个API,return把ipc_send的返回结果作为open的API结果返回。This API is used to trigger the opening operation of the camera. Among them, bool open (int cameraId) is the configuration of the API, and the content in {} is the implementation of the API. The cameraId is a call parameter indicating which camera needs to be operated, such as Id=0 for the front camera and Id=1 for the rear camera. API_OPEN indicates that the Open API is called, and return returns the result of ipc_send as the result of the open API.
可以看出,该API的实现指示了通过跨进程通信(IPC)向OS_A侧传递该API的调用。从而,进程B可以实时创建与OS_A侧某个预设进程称为进程A间的跨进程通信,并通过建立的跨进程通信将对该API的调用请求发送至进程A。该调用请求中可以携带有API调用相关参数,比如需要调用的API是哪个API的标识信息——API_OPEN,以及需要开启的是哪个摄像头——cameraId,从而,进程A可以根据该调用请求调用真实camera HAL中的对应API来完成相机应用程序所需对摄像头进行的操作。假设该对应API在真实camera HAL中的配置和实现如下:It can be seen that the implementation of this API indicates a call to pass the API to the OS_A side via cross-process communication (IPC). Therefore, the process B can create a cross-process communication with a certain preset process on the OS_A side called process A in real time, and send a call request for the API to the process A through the established cross-process communication. The call request may carry API call related parameters, such as which API identifier information to be called API_OPEN, and which camera needs to be turned on - cameraId, so that process A can call the real camera according to the call request. The corresponding API in the HAL is used to complete the operations required by the camera application for the camera application. Assume that the corresponding API is configured and implemented in the real camera HAL as follows:
Figure PCTCN2018109550-appb-000001
Figure PCTCN2018109550-appb-000001
其中,open(int cameraId)为该API的配置,{}中的内容为该API的实现。可以看出,该API在真实camera HAL中的实现于在虚拟camera HAL中的实现不同,在真实camera HAL中的实现具体为对相应硬件的操作信息等。Where open(int cameraId) is the configuration of the API, and the content in {} is the implementation of the API. It can be seen that the implementation of the API in the real camera HAL is different in the implementation of the virtual camera HAL, and the implementation in the real camera HAL is specifically the operation information of the corresponding hardware and the like.
上述举例中,虚拟HAL与真实HAL中API的配置相同,均为bool open(int cameraId)。In the above example, the virtual HAL is the same as the configuration of the API in the real HAL, and both are bool open (int cameraId).
值得说明的是,上述进程A是与真实camera HAL对应的进程,可以将该进程A视为真实camera HAL的服务进程,是预先创建的,而进程B可以视为客户端进程,该进程A可以是随着OS_A的启动而启动,之后一直监听是否有来自OA_B的客户端进程需要调用真实camera HAL中的API。It should be noted that the above process A is a process corresponding to the real camera HAL, and the process A can be regarded as a real camera HAL service process, which is pre-created, and the process B can be regarded as a client process, and the process A can It is started with the start of OS_A, and then it is monitored whether there is a client process from OA_B that needs to call the API in the real camera HAL.
通过在OS_B中设置虚拟HAL,且该虚拟HAL中API的配置与真实API的配置具有对应关系,比如可以直接复制自真实HAL即可形成虚拟HAL中的API配置。而虚拟HAL中API的实现仅需要提供IPC的发送功能以及提供相关调用参数即可,从而虚拟HAL相对于真实HAL来说,无需复杂的功能实现逻辑,即无需真正执行对硬件的操作 控制,实现简单。The virtual HAL is set in the OS_B, and the configuration of the API in the virtual HAL has a corresponding relationship with the configuration of the real API. For example, the API configuration in the virtual HAL can be formed by directly copying from the real HAL. The implementation of the API in the virtual HAL only needs to provide the sending function of the IPC and provide related calling parameters, so that the virtual HAL does not need complicated function realization logic with respect to the real HAL, that is, it does not need to actually perform the operation control of the hardware, and realize simple.
下面结合如下实施例,分别以上述不同操作系统的角度对本发明实施例提供的硬件抽象层复用方法进行介绍。The hardware abstraction layer multiplexing method provided by the embodiment of the present invention is introduced in the following embodiments in combination with the following embodiments.
图2为本发明实施例提供的一种硬件抽象层复用方法的流程图,本实施例提供的该硬件抽象层复用方法在图1所示的第一操作系统中实现,具有由第一操作系统中的第一进程执行。结合图1,假设本实施例中该第一操作系统为OS_B,第二操作系统为OS_A,第一进程为进程B,第二进程为进程A。如图2所示,该方法包括如下步骤:2 is a flowchart of a hardware abstraction layer multiplexing method according to an embodiment of the present invention. The hardware abstraction layer multiplexing method provided in this embodiment is implemented in the first operating system shown in FIG. The first process in the operating system executes. With reference to FIG. 1, it is assumed that the first operating system is OS_B, the second operating system is OS_A, the first process is process B, and the second process is process A. As shown in FIG. 2, the method includes the following steps:
201、响应于硬件操作指令,第一操作系统的第一进程调用第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口。201. In response to the hardware operation instruction, the first process of the first operating system invokes the first application interface in the virtual hardware abstraction layer corresponding to the first operating system.
可选地,实际应用中,进程B可以是由OS_B侧的应用程序或应用程序框架层启动的某个进程,比如为上述举例中相机应用程序启动的一个进程。可选地,该进程B也可以是与虚拟HAL对应的一个专用进程,用于对虚拟HAL中API进行调用,此时,该进程B可以供应用程序进行访问。Optionally, in an actual application, the process B may be a process initiated by an application or application framework layer on the OS_B side, such as a process initiated by the camera application in the above example. Optionally, the process B may also be a dedicated process corresponding to the virtual HAL, and is used to invoke the API in the virtual HAL. At this time, the process B may be accessed by the application.
比如:相机应用程序响应于用户触发的拍照操作指令,访问与摄像头对应的虚拟camera HAL对应的进程B,向该第一进程传递相关参数,比如摄像头标识camera0,以及工作模式——拍照。从而,进程B基于该参数调用虚拟camera HAL中的拍照API。For example, the camera application responds to the user-triggered photographing operation instruction, accesses the process B corresponding to the virtual camera HAL corresponding to the camera, and transmits relevant parameters to the first process, such as the camera identifier camera0, and the working mode—photographing. Thus, process B invokes the camera API in the virtual camera HAL based on this parameter.
202、第一进程通过跨进程通信将应用程序接口的调用请求发送至第二操作系统,以使第二操作系统中的第二进程根据调用请求调用第二操作系统对应的硬件抽象层中的第二应用程序接口执行硬件操作指令。202. The first process sends a call request of the application program interface to the second operating system by using the cross-process communication, so that the second process in the second operating system invokes the second in the hardware abstraction layer corresponding to the second operating system according to the call request. The second application interface executes hardware operation instructions.
其中,第一应用程序接口在虚拟HAL中的配置与第二应用程序接口在第二操作系统对应的HAL即真实HAL中的配置具有对应关系。The configuration of the first application program interface in the virtual HAL has a corresponding relationship with the configuration of the second application program interface in the HAL corresponding to the second operating system, that is, the real HAL.
本实施例中,假设上述对应关系体现为配置相同,从而上述第一API与第二API相同。In this embodiment, it is assumed that the above correspondence relationship is embodied as the same configuration, so that the first API is the same as the second API.
如前所述,进程B在调用某个API时,基于该API的实现,将通过跨进程通信将该API的调用请求发送至OS_A,以使OS_A中的进程A根据该调用请求调用进程B对应的真实HAL中的该API以执行硬件操作指令。其中,该API的实现中包含的内容指示了通过跨进程通信将API的调用参数传输至进程A中,该调用参数比如包括该API的标识以及该API对应的硬件标识。进程B可以从中提取出该调用参数,封装在调用请求中发送至进程A。As mentioned above, when process B calls an API, based on the implementation of the API, the call request of the API will be sent to OS_A through cross-process communication, so that process A in OS_A calls process B according to the call request. The API in the real HAL to execute hardware operation instructions. The content included in the implementation of the API indicates that the calling parameter of the API is transmitted to the process A through cross-process communication, and the calling parameter includes, for example, an identifier of the API and a hardware identifier corresponding to the API. Process B can extract the call parameters from it, and the package is sent to process A in the call request.
实际应用中,进程A调用真实HAL中进程B需要调用的API来执行上述硬件操作 指令,可能会涉及到硬件操作结果的回调即反馈给进程B,也可能不会涉及硬件操作结果的回调。比如,上述API可能仅是实现对比如查询用户终端设备共有几个摄像头,此时将不会有硬件操作结果的回调;再比如,上述API可能是实现触发摄像头进行录像,此时,会有硬件操作结果的回调,即将摄像头拍得的视频回调至第一进程。In the actual application, the process A calls the API that the process B needs to call in the real HAL to execute the above hardware operation instructions, which may involve the callback of the hardware operation result, that is, feedback to the process B, and may not involve the callback of the hardware operation result. For example, the above API may only implement a few cameras for querying the user terminal device, for example, there will be no callback of the hardware operation result; for example, the above API may be to trigger the camera to perform recording, and at this time, there will be hardware. The callback of the operation result, the video captured by the camera is called back to the first process.
因此,在涉及到硬件操作结果回调的情形下,进程B还需接收进程A反馈的硬件操作结果。Therefore, in the case of a hardware operation result callback, Process B also needs to receive the hardware operation result fed back by Process A.
可选地,该硬件操作结果可以包括:硬件数据,该硬件数据由执行硬件操作指令的硬件即与真实HAL对应的硬件产生,比如上述录像视频;或者,该硬件操作结果为硬件数据在共享内存中的存储地址;或者,该硬件操作结果为操作失败提示信息。Optionally, the hardware operation result may include: hardware data generated by hardware that executes hardware operation instructions, that is, hardware corresponding to the real HAL, such as the video recorded above; or the hardware operation result is hardware data in the shared memory. The storage address in the middle; or, the result of the hardware operation is an operation failure prompt message.
可选地,为了避免进程B与进程A间需要传输过大的数据量使得所需传输时间过长,从而使得对真实HAL和虚拟HAL的过长占用时间,影响其他需要调用真实HAL、虚拟HAL的进程的调用,进程A可以根据硬件数据的数据量的大小确定是直接向进程B反馈该硬件数据。比如,当该硬件数据的数据量小于预设阈值时,直接反馈至进程B,反之,将该硬件数据存入共享内存中,从而仅将该硬件数据在共享内存中的存储地址反馈给进程B,使得进程B从该共享内存中获取该硬件数据。其中,共享内存是预设的两个操作系统可以共用的存储空间。Optionally, in order to avoid the need to transmit excessive data between the process B and the process A, the required transmission time is too long, so that the excessive occupation time of the real HAL and the virtual HAL affects other needs to call the real HAL and the virtual HAL. The process call, process A can determine according to the size of the data volume of the hardware data is directly feedback to the process B the hardware data. For example, when the data volume of the hardware data is less than the preset threshold, the data is directly fed back to the process B. Otherwise, the hardware data is stored in the shared memory, so that only the storage address of the hardware data in the shared memory is fed back to the process B. So that process B gets the hardware data from the shared memory. The shared memory is a preset storage space that can be shared by two operating systems.
值得说明的是,上述操作失败提示信息可以视为是一种特殊的硬件操作结果,该操作失败提示信息是指进程A在接收到进程B发送的调用请求之后,在基于该调用请求调用真实HAL中相应API前,若识别出需调用的该API具有独占操作属性,进而确定该真实HAL对应的硬件处于忙碌状态时向进程B发送的。当该硬件处于忙碌状态时,说明有其他进程正在调用该真实HAL来操作该硬件,则此时进程A无法调用该真实HAL中的API,从而向第一进程反馈操作失败提示信息。其中,关于上述独占操作属性的说明将在后续实施例中详细介绍。It should be noted that the above operation failure prompt information can be regarded as a special hardware operation result. The operation failure prompt information refers to the process A, after receiving the call request sent by the process B, calling the real HAL based on the call request. Before the corresponding API, if it is identified that the API to be called has an exclusive operation attribute, and then it is determined that the hardware corresponding to the real HAL is in a busy state, it is sent to the process B. When the hardware is in a busy state, it indicates that another process is calling the real HAL to operate the hardware, and then the process A cannot call the API in the real HAL, thereby feeding back the operation failure prompt information to the first process. The description about the above exclusive operation attribute will be described in detail in the subsequent embodiments.
综上,本发明实施例提供的硬件抽象层复用方法,仅需在第一操作系统侧设置具有如下特征的虚拟HAL,即可以实现第一操作系统对第二操作系统对应的真实硬件抽象层的复用:虚拟HAL中设置的API的配置与真实HAL中API配置具有对应关系L,并将虚拟HAL中的API实现设置为通过跨进程通信将对虚拟HAL中某个API的调用传递到对应于真实HAL的第二操作系统中。该方案,实现方便,且可以适用于任意不同的操作系统。In summary, the hardware abstraction layer multiplexing method provided by the embodiment of the present invention only needs to set a virtual HAL with the following features on the first operating system side, that is, a real hardware abstraction layer corresponding to the second operating system by the first operating system can be implemented. Reuse: The configuration of the API set in the virtual HAL has a corresponding relationship with the API configuration in the real HAL, and the API implementation in the virtual HAL is set to communicate the call of an API in the virtual HAL to the corresponding through the inter-process communication. In the second operating system of the real HAL. This solution is easy to implement and can be applied to any different operating system.
图3为本发明实施例提供的另一种硬件抽象层复用方法的流程图,本实施例提供的该硬件抽象层复用方法由第一操作系统中的第一进程来执行。假设本实施例中的第一操作系统是图1所示的OS_A,第二操作系统是图1所示的OS_B,第一进程为图1所示的进程A,第二进程为图1所示的进程B,从而,如图3所示,该方法可以包括如下步骤:301、第一进程接收第二操作系统中第二进程通过跨进程通信发送的调用请求,调用请求是第二进程响应于硬件操作指令而调用第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的。FIG. 3 is a flowchart of another hardware abstraction layer multiplexing method according to an embodiment of the present invention. The hardware abstraction layer multiplexing method provided by this embodiment is performed by a first process in a first operating system. It is assumed that the first operating system in this embodiment is OS_A shown in FIG. 1, the second operating system is OS_B shown in FIG. 1, the first process is process A shown in FIG. 1, and the second process is as shown in FIG. Process B, and thus, as shown in FIG. 3, the method may include the following steps: 301: The first process receives a call request sent by the second process in the second operating system by using the cross-process communication, where the call request is a response of the second process The hardware operation instruction is triggered by calling the first application interface in the virtual hardware abstraction layer corresponding to the second operating system.
302、第一进程根据调用请求调用第一操作系统对应的硬件抽象层中的第二应用程序接口,以执行硬件操作指令。302. The first process invokes a second application program interface in the hardware abstraction layer corresponding to the first operating system according to the call request to execute the hardware operation instruction.
其中,第一应用程序接口在虚拟HAL中的配置与第二应用程序接口在第一操作系统OS_A对应的硬件抽象层即真实HAL中的配置具有对应关系。The configuration of the first application program interface in the virtual HAL has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer corresponding to the first operating system OS_A, that is, the real HAL.
本实施例中,假设上述对应关系体现为第一应用程序接口在虚拟HAL中的配置与第二应用程序接口在真实HAL中的配置相同,以下基于该假设进行说明。In this embodiment, it is assumed that the above correspondence relationship is that the configuration of the first application program interface in the virtual HAL is the same as the configuration of the second application program interface in the real HAL, and the following description is based on the assumption.
其中,上述调用请求中可以携带有进程B所要调用的API的标识以及需要操作的硬件的标识等信息,从而进程A可以据此调用真实HAL中相应的API。The call request may carry information such as an identifier of an API to be invoked by the process B and an identifier of the hardware to be operated, so that the process A can invoke the corresponding API in the real HAL accordingly.
进程A可以是预先设置在OS_A侧的一个进程,在OS_A启动时即存在。该进程A负责OS_B中的进程对OS_A所对应的真实HAL的调用,以便OS_B可以复用OS_A侧的真实HAL。The process A may be a process set in advance on the OS_A side, and exists when the OS_A is started. The process A is responsible for the call of the real HAL corresponding to the OS_A by the process in the OS_B, so that the OS_B can multiplex the real HAL on the OS_A side.
进程A执行上述步骤的具体过程可以参见前述实施例中的相关说明,在此不赘述。For the specific process of the process A, the related steps in the foregoing embodiments may be referred to, and details are not described herein.
图4为本发明实施例提供的又一种硬件抽象层复用方法的流程图,与图3所示实施例一样,本实施例提供的该硬件抽象层复用方法可以由第一操作系统中的第一进程来执行。假设本实施例中的第一操作系统是图1所示的OS_A,第二操作系统是图1所示的OS_B,第一进程为图1所示的进程A,第二进程为图1所示的进程B,从而,如图4所示,该方法可以包括如下步骤:FIG. 4 is a flowchart of still another hardware abstraction layer multiplexing method according to an embodiment of the present invention. The hardware abstraction layer multiplexing method provided by this embodiment may be used by the first operating system. The first process to execute. It is assumed that the first operating system in this embodiment is OS_A shown in FIG. 1, the second operating system is OS_B shown in FIG. 1, the first process is process A shown in FIG. 1, and the second process is as shown in FIG. Process B, and thus, as shown in FIG. 4, the method may include the following steps:
401、第一进程接收第二操作系统中第二进程通过跨进程通信发送的调用请求,调用请求是第二进程响应于硬件操作指令而调用第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的。401. The first process receives a call request sent by the second process in the second operating system by using the cross-process communication, where the call request is the first process in the virtual process abstraction layer corresponding to the second operating system in response to the hardware operation instruction. Triggered by the application interface.
402、第一进程根据调用请求确定需要调用第一操作系统对应的硬件抽象层中的第二应用程序接口,若识别出第二应用程序接口具有独占操作属性,则查看硬件抽象层对应的硬件的状态。402. The first process determines, according to the calling request, that the second application interface in the hardware abstraction layer corresponding to the first operating system needs to be invoked, and if the second application program interface has the exclusive operation attribute, the hardware corresponding to the hardware abstraction layer is viewed. status.
403、若硬件的状态表示硬件处于空闲状态,则第一进程根据调用请求调用第一操作系统对应的硬件抽象层中的第二应用程序接口,以执行硬件操作指令。403. If the state of the hardware indicates that the hardware is in an idle state, the first process invokes the second application program interface in the hardware abstraction layer corresponding to the first operating system according to the call request to execute the hardware operation instruction.
404、第一进程将硬件的状态置为忙碌状态。404. The first process sets the state of the hardware to a busy state.
405、若硬件执行硬件操作指令而产生的硬件数据的数据量小于预设阈值,则第一进程将硬件数据发送至第二进程;若硬件数据的数据量大于或等于预设阈值,则第一进程将硬件数据存入共享内存中,并将硬件数据在共享内存中的存储地址发送至第二进程。405. If the data quantity of the hardware data generated by the hardware execution hardware operation instruction is less than a preset threshold, the first process sends the hardware data to the second process; if the data quantity of the hardware data is greater than or equal to the preset threshold, the first The process stores the hardware data in the shared memory and sends the hardware data to the second process in the shared memory.
由于进程B发送的调用请求中会携带有进程B在虚拟HAL中所调用的第一API的标识,从而,进程A可以基于真实HAL中API配置与虚拟HAL中API配置见的对应关系,确定在真实HAL中与进程B所需调用的第一API对应的第二API。The call request sent by the process B carries the identifier of the first API invoked by the process B in the virtual HAL. Therefore, the process A can determine the correspondence between the API configuration in the real HAL and the API configuration in the virtual HAL. The second API in the real HAL that corresponds to the first API that Process B needs to call.
在一可选实施例中,进程A在接收到上述调用请求后,可以随即调用真实HAL中的相应的第二API。但是,在一些实际应用场景中,当进程A需要调用真实HAL中的该第二API来对该真实HAL所对应的硬件进行某种操作时,可能还有OS_A中的其他进程之前已经调用该真实HAL中的某个API正在对该硬件进行操作。而如果该硬件在同一时间仅能够被一个进程操作,即如果该硬件属于独占硬件,则此时不应该让进程A调用真实HAL中的该API。举例来说,假设某个进程正在控制摄像头进行拍照操作,则另一个进程就不能同时使用该摄像头了。In an optional embodiment, after receiving the above call request, the process A may immediately invoke the corresponding second API in the real HAL. However, in some practical application scenarios, when the process A needs to invoke the second API in the real HAL to perform some operation on the hardware corresponding to the real HAL, there may be other processes in the OS_A that have previously called the real An API in the HAL is operating on the hardware. And if the hardware can only be operated by one process at the same time, that is, if the hardware belongs to exclusive hardware, then process A should not be allowed to call the API in the real HAL. For example, if a process is controlling a camera to take a photo, another process cannot use the camera at the same time.
因此,为了避免不同进程对同一真实HAL的同时调用,即避免不同进程对同一硬件的同时从操作,进程A还提供了互斥机制,该互斥机制简单来说就是当真实HAL当前被某个进程调用时,进程A会将该真实HAL所对应硬件的状态置为忙碌状态,反之置为空闲状态,以避免多个进程对该真实HAL的同时调用。其中,该忙碌状态是指该硬件被某个进程占用,因此,该忙碌状态也指被占用状态,相应地,空闲状态也可以指未被占用状态。Therefore, in order to avoid simultaneous calls of different processes to the same real HAL, that is, to avoid simultaneous operations of different processes on the same hardware, process A also provides a mutual exclusion mechanism, which is simply when the real HAL is currently being When the process is invoked, the process A will set the state of the hardware corresponding to the real HAL to a busy state, and vice versa, to avoid simultaneous calls of the real HAL by multiple processes. The busy state means that the hardware is occupied by a certain process. Therefore, the busy state also refers to an occupied state. Accordingly, the idle state may also refer to an unoccupied state.
从而,为实现上述互斥功能,进程A在基于进程B的调用请求调用真实HAL中第二API之前,可以先识别该第二API是否具有独占操作属性,若识别出该第二API具有独占操作属性,则查看真实HAL所对应硬件的状态,如果该硬件的状态表示该硬件处于空闲状态,则进程A此时便可以根据进程B的调用请求调用真实HAL中第二API以执行硬件操作指令;而若该硬件的状态表示该硬件处于忙碌状态,则进程A则向进程A发送操作失败提示信息,此时说明该硬件正被其他进程操作。相反地,若识别出该第二API不具有独占操作属性,则说明此时即使有其他进程正在调用真实HAL来操作该硬件,进程A所调用的第二API的执行也不会影响到该其他进程的正常进行,此时,进程A也可 以调用真实HAL中第二API以执行硬件操作指令。Therefore, in order to implement the above mutual exclusion function, the process A may first identify whether the second API has an exclusive operation attribute before calling the second API in the real HAL based on the process B-based call request, and if the second API is identified as having an exclusive operation, Attribute, view the state of the hardware corresponding to the real HAL. If the state of the hardware indicates that the hardware is in an idle state, the process A can call the second API in the real HAL to execute the hardware operation instruction according to the call request of the process B; If the state of the hardware indicates that the hardware is busy, the process A sends an operation failure prompt message to the process A, indicating that the hardware is being operated by another process. Conversely, if it is recognized that the second API does not have an exclusive operation attribute, it means that even if another process is calling the real HAL to operate the hardware, the execution of the second API invoked by the process A does not affect the other. The process progresses normally. At this time, the process A can also call the second API in the real HAL to execute the hardware operation instruction.
本实施例中,上述第二API的独占操作属性,也可以称为排他操作属性,其含义可以理解为:如果允许不同进程同时调用该第二API对硬件进行某种操作,则该第二API不具有独占操作属性,相反地,如果不允许不同进程同时调用该第二API对硬件进行某种操作,则该第二API具有独占操作属性。举例来说,假设该第二API能够实现对摄像头的开启操作,则由于实际上某个进程已经开启摄像头的情况下,不允许另一进程再次开启摄像头,所以用于实现摄像头开启功能的该第二API具有独占操作属性。再比如,假设该第二API用于实现终端设备中包含的摄像头个数的查询功能,则由于实际上是可以允许多个进程同时查询摄像头个数的,所以该第二API不具有独占操作属性。In this embodiment, the exclusive operation attribute of the second API may also be referred to as an exclusive operation attribute, and the meaning thereof may be understood as: if a different process is allowed to simultaneously invoke the second API to perform some operation on the hardware, the second API There is no exclusive operation attribute. Conversely, if different processes are not allowed to simultaneously call the second API to perform some operation on the hardware, the second API has an exclusive operation attribute. For example, if the second API can implement the opening operation of the camera, the camera is not allowed to turn on the camera again because a certain process has actually turned on the camera. The second API has exclusive operational attributes. For example, if the second API is used to implement the query function of the number of cameras included in the terminal device, the second API does not have an exclusive operation attribute because it can actually allow multiple processes to simultaneously query the number of cameras. .
可选地,可以根据真实HAL中该第二API的配置来识别该第二API是否具有独占操作属性。比如,可以在该第二API的配置中设置某个字段,该字段的不同取值用于表示该第二API是否具有独占操作属性,比如00表示不具有独占操作属性,01表示具有独占操作属性。Optionally, whether the second API has an exclusive operation attribute may be identified according to a configuration of the second API in the real HAL. For example, a certain field may be set in the configuration of the second API, and different values of the field are used to indicate whether the second API has an exclusive operation attribute, for example, 00 means that there is no exclusive operation attribute, and 01 means that there is an exclusive operation attribute. .
在一可选实施例中,进程A可以在每接收到进程B发送的调用请求后,若识别出该调用请求在真实HAL中所对应的API具有独占操作属性,则随即进行硬件状态的查询。但是,在另一可选实施例中,进程A也可以仅在识别出需要调用的是具有独占操作属性的某种特定API时,才查看硬件的状态,以减少查询操作。因此,进程A在接收到进程B发送的调用请求后,若识别出该调用请求在真实HAL中所对应的第二API具有独占操作属性,并且该第二API是用于实现对硬件的开启操作的,此时才查看该硬件的状态。以摄像头应用为例来说,一般地,通过摄像头进行拍照的过程中,进程B可能需要依次调用开启摄像头、开启预览、拍照、关闭摄像头这几个API。进程B在虚拟HAL中调用开启摄像头的API时,进程A会接收到进程B发送的该开启摄像头的API对应的调用请求,进而,进程A识别出该API具有独占操作属性且用于实现摄像头的开启操作,则查询摄像头的状态,假设此时摄像头处于空闲状态,则进程A调用真实HAL中对应的开启摄像头的API对摄像头执行开启操作,并将摄像头的状态置为忙碌状态,此时,可选地,进程A也可以记录下将摄像头置为忙碌状态的进程为进程B。之后,可选地,进程A向进程B反馈开启成功指示,从而,进程B继续调用虚拟HAL中开启预览的API。此时,进程A在接收到该开启预览的API对应的调用请求后,即使识别出真实HAL中该开启预览的API具有独占操作属性,也可以不进行摄像头状态的查询,因为进程B还并未结束对摄像头的操作。直到进程A接收到进程B对关闭摄像头的API的调用请求, 识别出该关闭摄像头的API具有独占操作属性,且用于实现对摄像头的关闭操作,此时,进程A将摄像头的状态置为空闲状态,此时进程B对摄像头的操作结束。In an optional embodiment, after receiving the call request sent by the process B, the process A may perform the query of the hardware state if it recognizes that the API corresponding to the call request in the real HAL has an exclusive operation attribute. However, in another alternative embodiment, process A may also view the state of the hardware to reduce the query operation only when it recognizes that it needs to invoke a particular API with exclusive operational attributes. Therefore, after receiving the call request sent by the process B, the process A has the exclusive operation attribute of the second API corresponding to the call request in the real HAL, and the second API is used to implement the hardware opening operation. At this time, the status of the hardware is checked. Taking the camera application as an example, in general, during the process of taking a picture through the camera, the process B may need to sequentially call the APIs of turning on the camera, turning on the preview, taking a picture, and turning off the camera. When process B calls the API for enabling the camera in the virtual HAL, process A receives the call request corresponding to the API of the open camera sent by process B, and then process A recognizes that the API has an exclusive operation attribute and is used to implement the camera. When the operation is turned on, the state of the camera is queried. Assuming that the camera is in an idle state at this time, the process A calls the API of the corresponding camera in the real HAL to perform an opening operation on the camera, and sets the state of the camera to a busy state. Alternatively, process A can also record that the process that puts the camera in a busy state is process B. Then, optionally, the process A feeds back the success indication to the process B, so that the process B continues to invoke the API for opening the preview in the virtual HAL. At this time, after receiving the call request corresponding to the API for opening the preview, the process A may not perform the query of the camera state even if it recognizes that the API of the open preview in the real HAL has an exclusive operation attribute, because the process B has not yet End the operation of the camera. Until process A receives the call request of process B to close the camera's API, it recognizes that the API of the closed camera has an exclusive operation attribute, and is used to implement the closing operation of the camera. At this time, process A sets the state of the camera to idle. State, at this point, process B ends the operation of the camera.
因此,进程A若识别出第二API具有独占操作属性,并且第二API用于实现对硬件的关闭操作,则将硬件的状态置为空闲状态。另外,实际应用中,对真实HAL的调用,除了存在进程A需要调用真实HAL的情形外,还可能存在OS_A侧某应用程序启动的某个进程,假设称为第三进程需要调用真实HAL的情形。此时,第三进程在调用真实HAL前,需要向进程A查询该真实HAL对应的硬件的状态,以在该硬件处于空闲状态时对真实HAL进行调用。因此,进程A还可以接收OS_A中第三进程通过跨进程通信发送的用于查询真实HAL对应的硬件的状态的查询请求,并将硬件的状态发送给第三进程,以使第三进程根据该状态确定能否调用真实HAL。Therefore, if process A recognizes that the second API has an exclusive operation attribute, and the second API is used to implement a shutdown operation on the hardware, the state of the hardware is set to an idle state. In addition, in actual applications, in addition to the case where the process A needs to call the real HAL, there may be a process initiated by an application on the OS_A side, assuming that the third process needs to invoke the real HAL. . At this time, before calling the real HAL, the third process needs to query the process A for the state of the hardware corresponding to the real HAL to call the real HAL when the hardware is in an idle state. Therefore, the process A can also receive a query request for querying the state of the hardware corresponding to the real HAL sent by the third process in the OS_A through the inter-process communication, and send the state of the hardware to the third process, so that the third process according to the The state determines if the real HAL can be called.
如前述实施例中所述,为了避免对真实HAL的过长占用时间,进程A可以根据调用第二API而执行硬件操作指令时硬件所产生的硬件数据的数据量大小确定是直接将该硬件数据反馈给进程B,还是将该硬件数据在共享内存中的存储地址反馈至进程B。As described in the foregoing embodiment, in order to avoid excessively long occupation time of the real HAL, the process A may determine the data size of the hardware data generated by the hardware when executing the hardware operation instruction according to the second API, and directly determine the hardware data. Feedback to process B, or feedback the storage address of the hardware data in the shared memory to process B.
综上,在具有真实HAL的OS_A侧提供进程A,以监听来自OS_B的对真实HAL的调用请求,以便辅助完成OS_B对真实HAL的复用;另外,进程A还提供互斥机制,以避免多个进程对独占硬件所对应的该真实HAL的同时调用。In summary, the process A is provided on the OS_A side with the real HAL to listen for the call request from the OS_B to the real HAL, so as to assist the completion of the OS_B multiplexing of the real HAL; in addition, the process A also provides a mutual exclusion mechanism to avoid more The process calls the simultaneous HAL corresponding to the exclusive hardware.
图5为本发明实施例提供的一种硬件抽象层复用方法的交互图,结合图1,本实施例中该第一操作系统为OS_B,第二操作系统为OS_A,第一进程为进程B,第二进程为进程A。并且假设虚拟HAL中API配置与真实HAL中API配置相同。如图5所示,可以包括如下步骤:FIG. 5 is an interaction diagram of a hardware abstraction layer multiplexing method according to an embodiment of the present invention. In the embodiment, the first operating system is OS_B, the second operating system is OS_A, and the first process is process B. The second process is process A. Also assume that the API configuration in the virtual HAL is the same as the API configuration in the real HAL. As shown in FIG. 5, the following steps may be included:
501、响应于硬件操作指令,第一操作系统的第一进程调用第一操作系统对应的虚拟硬件抽象层中的应用程序接口。501. In response to the hardware operation instruction, the first process of the first operating system invokes an application program interface in a virtual hardware abstraction layer corresponding to the first operating system.
502、第一进程通过跨进程通信将应用程序接口的调用请求发送至第二操作系统中的第二进程。502. The first process sends an invocation request of the application program interface to the second process in the second operating system by cross-process communication.
503、第二进程识别出该应用程序接口具有独占操作属性,查看真实硬件抽象层对应的硬件的状态。503. The second process identifies that the application interface has an exclusive operation attribute, and checks the state of the hardware corresponding to the real hardware abstraction layer.
504、若硬件处于空闲状态,则第二进程根据调用请求调用第二操作系统对应的真实硬件抽象层中的所述应用程序接口,以执行硬件操作指令。504. If the hardware is in an idle state, the second process invokes the application program interface in the real hardware abstraction layer corresponding to the second operating system according to the call request to execute the hardware operation instruction.
505、第二进程将硬件的状态置为忙碌状态。505. The second process sets the state of the hardware to a busy state.
506、第二进程接收第二操作系统中第三进程通过跨进程通信发送的用于查询真实HAL对应的硬件的状态的查询请求。506. The second process receives a query request that is sent by the third process in the second operating system by using the cross-process communication to query the status of the hardware corresponding to the real HAL.
507、第二进程将指示硬件处于忙碌状态的查询响应发送给第三进程。507. The second process sends a query response indicating that the hardware is busy to the third process.
508、第三进程放弃调用真实HAL。508. The third process gives up calling the real HAL.
509、第二进程将硬件执行硬件操作指令而产生的硬件数据发送至第一进程。509. The second process sends hardware data generated by the hardware to execute the hardware operation instruction to the first process.
以下将详细描述本发明的一个或多个实施例的硬件抽象层复用装置。本领域技术人员可以理解,这些硬件抽象层复用装置均可使用市售的硬件组件通过本方案所教导的步骤进行配置来构成。A hardware abstraction layer multiplexing device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these hardware abstraction layer multiplexing devices can be constructed using commercially available hardware components configured by the steps taught by the present scheme.
图6为与图2所示实施例对应的一种硬件抽象层复用装置的结构示意图,如图6所示,该装置包括:调用模块11、发送模块12、接收模块13。FIG. 6 is a schematic structural diagram of a hardware abstraction layer multiplexing apparatus corresponding to the embodiment shown in FIG. 2. As shown in FIG. 6, the apparatus includes: a calling module 11, a sending module 12, and a receiving module 13.
调用模块11,用于响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口。The calling module 11 is configured to invoke a first application interface in the virtual hardware abstraction layer corresponding to the first operating system in response to the hardware operation instruction.
发送模块12,用于通过跨进程通信将所述应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令。The sending module 12 is configured to send the call request of the application program interface to the second operating system by cross-process communication, so that the second process in the second operating system invokes the second operation according to the call request The second application program interface in the hardware abstraction layer corresponding to the system executes the hardware operation instruction.
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
可选地,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置相同。Optionally, the configuration of the first application program interface in the virtual hardware abstraction layer is the same as the configuration of the second application program interface in the hardware abstraction layer.
可选地,该装置还包括:接收模块13。Optionally, the device further includes: a receiving module 13.
接收模块13,用于接收所述第二进程反馈的硬件操作结果。The receiving module 13 is configured to receive a hardware operation result fed back by the second process.
其中,所述硬件操作结果包括:The hardware operation result includes:
硬件数据,所述硬件数据由执行所述硬件操作指令的硬件产生;或者所述硬件数据在共享内存中的存储地址;或者操作失败提示信息;其中,所述硬件数据和所述存储地址是所述第二进程根据所述硬件数据的数据量大小确定是否发送的;所述操作失败提示信息是所述第二进程在确定所述硬件忙碌时发送的。Hardware data generated by hardware that executes the hardware operation instructions; or a storage address of the hardware data in a shared memory; or an operation failure prompt information; wherein the hardware data and the storage address are The second process determines whether to send according to the data size of the hardware data; the operation failure prompt information is sent by the second process when determining that the hardware is busy.
图6所示装置可以执行图2的方法,本实施例未详细描述的部分,可参考对图2所示实施例的相关说明。该技术方案的执行过程和技术效果参见图2所示实施例中的描述, 在此不再赘述。The apparatus shown in FIG. 6 can perform the method of FIG. 2. For the parts not described in detail in this embodiment, reference may be made to the related description of the embodiment shown in FIG. 2. For the implementation process and technical effects of the technical solution, refer to the description in the embodiment shown in FIG. 2, and details are not described herein again.
图7为与图2所示实施例对应的一种操作系统的组成示意图,如图7所示,该操作系统可以是图1所示的OS_B,该操作系统中包括:应用程序框架层和虚拟硬件抽象层。FIG. 7 is a schematic diagram of a composition of an operating system corresponding to the embodiment shown in FIG. 2. As shown in FIG. 7, the operating system may be OS_B shown in FIG. 1, and the operating system includes: an application framework layer and a virtual Hardware abstraction layer.
其中,所述应用程序框架层中包括一进程,该进程用于实现如图2所示实施例中所述的硬件抽象层复用方法。该进程可以是图2所示实施例中的进程B。The application framework layer includes a process for implementing the hardware abstraction layer multiplexing method described in the embodiment shown in FIG. 2. This process can be process B in the embodiment shown in FIG. 2.
参见前述实施例中的介绍,所述虚拟硬件抽象层中应用程序接口的配置与另一操作系统对应的硬件抽象层中应用程序接口的配置具有对应关系。所述虚拟硬件抽象层中应用程序接口的实现指示了将对虚拟硬件抽象层中应用程序接口的调用请求通过跨进程通信传输至另一操作系统。Referring to the introduction in the foregoing embodiment, the configuration of the application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the application program interface in the hardware abstraction layer corresponding to another operating system. Implementation of the application program interface in the virtual hardware abstraction layer indicates that a call request to an application interface in the virtual hardware abstraction layer is transmitted to another operating system through inter-process communication.
由于虚拟硬件抽象层中应用程序接口的实现涉及到跨进程通信,在一可选实施例中,该跨进程通信可以基于操作系统的内核中提供的跨进程通信机制比如Socket实现,因此,可选地,该操作系统中还可以包括如图7所示的内核。Since the implementation of the application interface in the virtual hardware abstraction layer involves cross-process communication, in an alternative embodiment, the cross-process communication can be implemented based on a cross-process communication mechanism such as a Socket provided in the kernel of the operating system, and thus, optional The operating system may also include a kernel as shown in FIG.
在一个可能的设计中,图6所示硬件抽象层复用装置的结构可实现为一电子设备,该电子设备为用户终端设备,比如智能手机、平板电脑、PC机等,如图8所示,该用户终端设备可以包括:处理器21和存储器22。其中,所述存储器22用于存储支持用户终端设备执行上述各所示实施例中提供的硬件抽象层复用方法的程序,所述处理器21被配置为用于执行所述存储器22中存储的程序。In a possible design, the structure of the hardware abstraction layer multiplexing device shown in FIG. 6 can be implemented as an electronic device, which is a user terminal device, such as a smart phone, a tablet computer, a PC, etc., as shown in FIG. The user terminal device may include a processor 21 and a memory 22. The memory 22 is configured to store a program for supporting a user terminal device to execute the hardware abstraction layer multiplexing method provided in each of the above-described embodiments, and the processor 21 is configured to execute the storage in the memory 22. program.
所述程序包括一条或多条计算机指令,其中,所述一条或多条计算机指令被所述处理器21执行时能够实现如下步骤:The program includes one or more computer instructions, wherein the one or more computer instructions are executed by the processor 21 to implement the following steps:
响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口;Retrieving a first application interface in a virtual hardware abstraction layer corresponding to the first operating system in response to a hardware operation instruction;
通过跨进程通信将所述应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令;Sending, by the inter-process communication, the call request of the application program interface to the second operating system, so that the second process in the second operating system invokes the hardware abstraction layer corresponding to the second operating system according to the call request The second application program interface executes the hardware operation instruction;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
可选地,所述处理器21还用于执行前述图2所示方法步骤中的全部或部分步骤。Optionally, the processor 21 is further configured to perform all or part of the steps of the foregoing method shown in FIG. 2.
其中,所述用户终端设备的结构中还可以包括通信接口23,用于用户终端设备与其他设备或通信网络通信。The structure of the user terminal device may further include a communication interface 23 for the user terminal device to communicate with other devices or a communication network.
另外,本发明实施例提供了一种计算机存储介质,用于储存用户终端设备所用的计 算机软件指令,其包含用于执行上述图2所示方法实施例中硬件抽象层复用方法所涉及的程序。In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by a user terminal device, which includes a program for performing the hardware abstraction layer multiplexing method in the foregoing method embodiment shown in FIG. .
图9为与图3或图4所示实施例对应的一种硬件抽象层复用装置的结构示意图,如图9所示,该装置包括:接收模块31、调用模块32。FIG. 9 is a schematic structural diagram of a hardware abstraction layer multiplexing apparatus corresponding to the embodiment shown in FIG. 3 or FIG. 4. As shown in FIG. 9, the apparatus includes: a receiving module 31 and a calling module 32.
接收模块31,用于接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的。The receiving module 31 is configured to receive a call request sent by the second process in the second operating system by using the cross-process communication, where the call request is that the second process invokes the virtual corresponding to the second operating system in response to the hardware operation instruction Triggered by the first application interface in the hardware abstraction layer.
调用模块32,用于根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令。The calling module 32 is configured to invoke a second application program interface in the hardware abstraction layer corresponding to the second operating system according to the calling request to execute the hardware operation instruction.
其中,其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
可选地,该装置还包括:查询模块33,设置模块34。Optionally, the device further includes: a query module 33, and a setting module 34.
查询模块33,用于若识别出所述第二应用程序接口具有独占操作属性,则查看所述硬件抽象层对应的硬件的状态。The querying module 33 is configured to check the state of the hardware corresponding to the hardware abstraction layer if it is recognized that the second application program interface has an exclusive operation attribute.
相应地,调用模块32具体用于:若查询模块33查出所述状态表示所述硬件处于空闲状态,则根据所述调用请求调用所述第二应用程序接口,以执行所述硬件操作指令。Correspondingly, the calling module 32 is specifically configured to: if the query module 33 detects that the state indicates that the hardware is in an idle state, invoke the second application program interface according to the call request to execute the hardware operation instruction.
设置模块34,用于在所述调用模块32的触发下,将所述硬件的状态置为忙碌状态。The setting module 34 is configured to set the state of the hardware to a busy state under the trigger of the calling module 32.
可选地,所述查询模块33具体用于:若识别出所述第二应用程序接口具有独占操作属性,并且所述第二应用程序接口用于实现对所述硬件的开启操作,则查看所述硬件的状态。Optionally, the querying module 33 is specifically configured to: if it is recognized that the second application program interface has an exclusive operation attribute, and the second application program interface is used to implement an opening operation on the hardware, State the hardware.
可选地,所述调用模块32具体用于:若识别出所述第二应用程序接口具有非独占操作属性,则根据所述调用请求调用所述第二应用程序接口,以执行所述硬件操作指令。Optionally, the calling module 32 is specifically configured to: if the second application program interface is identified as having a non-exclusive operation attribute, invoke the second application program interface according to the call request to perform the hardware operation instruction.
可选地,所述装置还包括:发送模块35。Optionally, the device further includes: a sending module 35.
发送模块35,用于将所述硬件操作指令对应的硬件操作结果反馈给所述第一进程。The sending module 35 is configured to feed back a hardware operation result corresponding to the hardware operation instruction to the first process.
可选地,该发送模块35具体用于:Optionally, the sending module 35 is specifically configured to:
若所述硬件执行所述硬件操作指令而产生的硬件数据的数据量小于预设阈值,则将所述硬件数据作为所述硬件操作结果发送至所述第一进程;And if the data amount of the hardware data generated by the hardware executing the hardware operation instruction is less than a preset threshold, sending the hardware data to the first process as the hardware operation result;
若所述硬件数据的数据量大于或等于所述预设阈值,则将所述硬件数据存入共享内存中,并将所述硬件数据在所述共享内存中的存储地址发送至所述第一进程。And if the data amount of the hardware data is greater than or equal to the preset threshold, storing the hardware data in a shared memory, and sending the storage address of the hardware data in the shared memory to the first process.
可选地,所述发送模块35还用于:Optionally, the sending module 35 is further configured to:
若所述状态表示所述硬件处于忙碌状态,则向所述第一进程发送操作失败提示信息。If the status indicates that the hardware is in a busy state, the operation failure prompt information is sent to the first process.
可选地,所述接收模块31还用于:接收所述第二操作系统中第三进程通过跨进程通信发送的查询请求,所述查询请求用于查询所述硬件的状态。Optionally, the receiving module 31 is further configured to: receive a query request sent by the third process in the second operating system by using a cross-process communication, where the query request is used to query a status of the hardware.
所述发送模块35还用于:将所述硬件的状态发送给所述第三进程,以使所述第三进程根据所述状态确定能否调用所述硬件抽象层。The sending module 35 is further configured to: send a status of the hardware to the third process, so that the third process determines whether the hardware abstraction layer can be invoked according to the status.
图9所示装置可以执行图3或图4所示实施例的方法,本实施例未详细描述的部分,可参考对图3或图4所示实施例的相关说明。该技术方案的执行过程和技术效果参见图3或图4所示实施例中的描述,在此不再赘述。The apparatus shown in FIG. 9 can perform the method of the embodiment shown in FIG. 3 or FIG. 4. For the parts not described in detail in this embodiment, reference may be made to the related description of the embodiment shown in FIG. 3 or FIG. For the implementation process and technical effects of the technical solution, refer to the description in the embodiment shown in FIG. 3 or FIG. 4, and details are not described herein again.
图10为与图3或图4所示实施例对应的一种操作系统的组成示意图,如图10所示,该操作系统可以是图1所示的OS_A,该操作系统中包括:应用程序框架层和跨进程通信接口。10 is a schematic diagram of a composition of an operating system corresponding to the embodiment shown in FIG. 3 or FIG. 4. As shown in FIG. 10, the operating system may be OS_A as shown in FIG. 1, and the operating system includes: an application framework. Layer and cross-process communication interfaces.
其中,所述应用程序框架层中包括一进程,该进程用于实现如图3或图4所示实施例中所述的硬件抽象层复用方法。该进程可以是图2所示实施例中的进程A。The application framework layer includes a process for implementing the hardware abstraction layer multiplexing method as described in the embodiment shown in FIG. 3 or FIG. 4. This process can be process A in the embodiment shown in FIG. 2.
参见前述实施例中的介绍,可选地,该操作系统中还可以包括硬件抽象层。该硬件抽象层中应用程序接口的配置与另一操作系统即图7所示操作系统对应的虚拟硬件抽象层中应用程序接口的配置具有对应关系。Referring to the introduction in the foregoing embodiment, optionally, the hardware abstraction layer may also be included in the operating system. The configuration of the application program interface in the hardware abstraction layer has a corresponding relationship with the configuration of the application program interface in the virtual hardware abstraction layer corresponding to the operating system shown in FIG.
上述跨进程通信接口,用于上述进程可以通过该跨进程通信接口接收另一操作系统发送的调用请求。The cross-process communication interface is used by the process to receive a call request sent by another operating system through the cross-process communication interface.
在一可选实施例中,该跨进程通信接口可以基于操作系统的内核中提供的跨进程通信机制比如Socket实现,因此,可选地,该操作系统中还可以包括如图10所示的内核。In an optional embodiment, the cross-process communication interface may be implemented based on a cross-process communication mechanism, such as a Socket, provided in a kernel of an operating system. Therefore, optionally, the operating system may further include a kernel as shown in FIG. .
在一个可能的设计中,图9所示硬件抽象层复用装置的结构可实现为一电子设备,该电子设备为用户终端设备,如图11所示,该用户终端设备可以包括:处理器41和存储器42。其中,所述存储器42用于存储支持用户终端设备执行上述各所示实施例中提供的硬件抽象层复用方法的程序,所述处理器41被配置为用于执行所述存储器42中存储的程序。In a possible design, the structure of the hardware abstraction layer multiplexing device shown in FIG. 9 can be implemented as an electronic device, and the electronic device is a user terminal device. As shown in FIG. 11, the user terminal device can include: a processor 41. And memory 42. The memory 42 is configured to store a program that supports the user terminal device to execute the hardware abstraction layer multiplexing method provided in each of the above-described embodiments, and the processor 41 is configured to execute the storage in the memory 42. program.
所述程序包括一条或多条计算机指令,其中,所述一条或多条计算机指令被所述处理器41执行时能够实现如下步骤:The program includes one or more computer instructions, wherein the one or more computer instructions are executed by the processor 41 to enable the following steps:
接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第 一应用程序接口触发的;Receiving a call request sent by the second process in the second operating system by the cross-process communication, where the call request is the second process in the virtual hardware abstraction layer corresponding to the second operating system in response to the hardware operation instruction Triggered by an application interface;
根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令;And calling a second application program interface in the hardware abstraction layer corresponding to the second operating system to execute the hardware operation instruction according to the calling request;
其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
可选地,所述处理器41还用于执行前述图3或图4所示方法步骤中的全部或部分步骤。Optionally, the processor 41 is further configured to perform all or part of the steps of the foregoing method shown in FIG. 3 or FIG. 4.
其中,所述用户终端设备的结构中还可以包括通信接口43,用于用户终端设备与其他设备或通信网络通信。The structure of the user terminal device may further include a communication interface 43 for the user terminal device to communicate with other devices or a communication network.
另外,本发明实施例提供了一种计算机存储介质,用于储存用户终端设备所用的计算机软件指令,其包含用于执行上述图3或图4所示方法实施例中硬件抽象层复用方法所涉及的程序。In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by a user terminal device, which includes a hardware abstraction layer multiplexing method for performing the foregoing method embodiment shown in FIG. 3 or FIG. The procedures involved.
以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, ie may be located A place, or it can be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. Those of ordinary skill in the art can understand and implement without deliberate labor.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助加必需的通用硬件平台的方式来实现,当然也可以通过硬件和软件结合的方式来实现。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以计算机产品的形式体现出来,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Through the description of the above embodiments, those skilled in the art can clearly understand that the embodiments can be implemented by adding a necessary general hardware platform, and can also be implemented by a combination of hardware and software. Based on the understanding, the above-mentioned technical solutions may be embodied in the form of a computer product in essence or in the form of a computer product, and the present invention may employ computer-usable storage in one or more computer-usable program codes. A form of computer program product embodied on a medium (including but not limited to disk storage, CD-ROM, optical storage, etc.).
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程硬件抽象层复用设备的处理器以产生一个机器,使得通过计算机或其他可编程硬件抽象层复用设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, a special purpose computer, an embedded processor, or other programmable hardware abstraction layer multiplexing device to produce a machine that multiplexes the processing of the device through a computer or other programmable hardware abstraction layer. The instructions executed by the apparatus generate means for implementing the functions specified in one or more blocks of the flowchart or in a block or blocks of the flowchart.
这些计算机程序指令也可存储在能引导计算机或其他可编程硬件抽象层复用设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable hardware abstraction layer multiplexing device to operate in a particular manner, such that instructions stored in the computer readable memory produce an article of manufacture including the instruction device. The instruction means implements the functions specified in one or more blocks of the flow or in a flow or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程硬件抽象层复用设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable hardware abstraction layer multiplexing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for use in a computer or other programmable device The instructions executed above provide steps for implementing the functions specified in one or more blocks of the flowchart or in a block or blocks of the flowchart.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。The memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory. Memory is an example of a computer readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer readable media includes both permanent and non-persistent, removable and non-removable media. Information storage can be implemented by any method or technology. The information can be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary storage of computer readable media, such as modulated data signals and carrier waves.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not limited thereto; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that The technical solutions described in the foregoing embodiments are modified, or the equivalents of the technical features are replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (19)

  1. 一种硬件抽象层复用方法,其特征在于,应用于第一操作系统的第一进程中,包括:A hardware abstraction layer multiplexing method, which is applied to a first process of a first operating system, including:
    响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口;Retrieving a first application interface in a virtual hardware abstraction layer corresponding to the first operating system in response to a hardware operation instruction;
    通过跨进程通信将所述应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令;Sending, by the inter-process communication, the call request of the application program interface to the second operating system, so that the second process in the second operating system invokes the hardware abstraction layer corresponding to the second operating system according to the call request The second application program interface executes the hardware operation instruction;
    其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
  2. 根据权利要求1所述的方法,其特征在于,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置相同。The method of claim 1, wherein the configuration of the first application interface in the virtual hardware abstraction layer is the same as the configuration of the second application program interface in the hardware abstraction layer.
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:
    接收所述第二进程反馈的硬件操作结果。Receiving a hardware operation result fed back by the second process.
  4. 根据权利要求3所述的方法,其特征在于,所述硬件操作结果包括:The method of claim 3, wherein the hardware operation result comprises:
    硬件数据,所述硬件数据由执行所述硬件操作指令的硬件产生;或者所述硬件数据在共享内存中的存储地址;或者操作失败提示信息;其中,所述硬件数据和所述存储地址是所述第二进程根据所述硬件数据的数据量大小确定是否发送的;所述操作失败提示信息是所述第二进程在确定所述硬件忙碌时发送的。Hardware data generated by hardware that executes the hardware operation instructions; or a storage address of the hardware data in a shared memory; or an operation failure prompt information; wherein the hardware data and the storage address are The second process determines whether to send according to the data size of the hardware data; the operation failure prompt information is sent by the second process when determining that the hardware is busy.
  5. 一种硬件抽象层复用装置,其特征在于,应用于第一操作系统的第一进程中,包括:A hardware abstraction layer multiplexing device, which is applied to a first process of a first operating system, and includes:
    调用模块,用于响应于硬件操作指令,调用所述第一操作系统对应的虚拟硬件抽象层中的第一应用程序接口;Calling a module, in response to the hardware operation instruction, calling a first application interface in the virtual hardware abstraction layer corresponding to the first operating system;
    发送模块,用于通过跨进程通信将所述第一应用程序接口的调用请求发送至第二操作系统,以使所述第二操作系统中的第二进程根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口执行所述硬件操作指令;a sending module, configured to send, by using a cross-process communication, a call request of the first application program interface to a second operating system, so that a second process in the second operating system invokes the second The second application program interface in the hardware abstraction layer corresponding to the operating system executes the hardware operation instruction;
    其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
  6. 一种操作系统,其特征在于,包括:应用程序框架层和虚拟硬件抽象层;An operating system, comprising: an application framework layer and a virtual hardware abstraction layer;
    所述应用程序框架层响应于硬件操作指令启动一进程,所述进程用于实现如权利要 求1至3中任一项所述的硬件抽象层复用方法;The application framework layer initiates a process for implementing the hardware abstraction layer multiplexing method according to any one of claims 1 to 3 in response to a hardware operation instruction;
    所述虚拟硬件抽象层中应用程序接口的配置与另一操作系统对应的硬件抽象层中应用程序接口的配置具有对应关系。The configuration of the application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the application program interface in the hardware abstraction layer corresponding to another operating system.
  7. 一种电子设备,其特征在于,包括存储器和处理器;其中,An electronic device, comprising: a memory and a processor; wherein
    所述存储器用于存储一条或多条计算机指令,其中,所述一条或多条计算机指令被所述处理器执行时实现如权利要求1至3中任一项所述的硬件抽象层复用方法。The memory is for storing one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the hardware abstraction layer multiplexing method according to any one of claims 1 to 3. .
  8. 一种硬件抽象层复用方法,其特征在于,应用于第一操作系统的第一进程中,包括:A hardware abstraction layer multiplexing method, which is applied to a first process of a first operating system, including:
    接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的;Receiving a call request sent by the second process in the second operating system by the cross-process communication, where the call request is the second process in the virtual hardware abstraction layer corresponding to the second operating system in response to the hardware operation instruction Triggered by an application interface;
    根据所述调用请求调用所述第一操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令;And calling a second application program interface in the hardware abstraction layer corresponding to the first operating system to execute the hardware operation instruction according to the calling request;
    其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
  9. 根据权利要求8所述的方法,其特征在于,所述根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令之前,还包括:The method according to claim 8, wherein the second application interface in the hardware abstraction layer corresponding to the second operating system is invoked according to the call request to execute the hardware operation instruction, include:
    若识别出所述第二应用程序接口具有独占操作属性,则查看所述硬件抽象层对应的硬件的状态;If it is recognized that the second application program interface has an exclusive operation attribute, view a state of the hardware corresponding to the hardware abstraction layer;
    若所述状态表示所述硬件处于空闲状态,则根据所述调用请求调用所述第二应用程序接口,以执行所述硬件操作指令;If the state indicates that the hardware is in an idle state, the second application program interface is invoked according to the call request to execute the hardware operation instruction;
    将所述硬件的状态置为忙碌状态。The state of the hardware is set to a busy state.
  10. 根据权利要求9所述的方法,其特征在于,所述方法还包括:The method of claim 9 wherein the method further comprises:
    若所述状态表示所述硬件处于忙碌状态,则向所述第一进程发送操作失败提示信息。If the status indicates that the hardware is in a busy state, the operation failure prompt information is sent to the first process.
  11. 根据权利要求9所述的方法,其特征在于,所述若识别出所述第二应用程序接口具有独占操作属性,则查看所述硬件抽象层对应的硬件的状态,包括:The method according to claim 9, wherein if the second application interface is identified as having an exclusive operation attribute, the status of the hardware corresponding to the hardware abstraction layer is viewed, including:
    若识别出所述第二应用程序接口具有独占操作属性,并且所述第二应用程序接口用于实现对所述硬件的开启操作,则查看所述硬件的状态。If it is recognized that the second application interface has an exclusive operation attribute, and the second application interface is used to implement an opening operation on the hardware, view the state of the hardware.
  12. 根据权利要求11所述的方法,其特征在于,所述方法还包括:The method of claim 11 wherein the method further comprises:
    若识别出所述第二应用程序接口具有独占操作属性,并且所述第二应用程序接口用于实现对所述硬件的关闭操作,则将所述硬件的状态置为空闲状态。If it is recognized that the second application interface has an exclusive operation attribute, and the second application interface is used to implement a shutdown operation on the hardware, the state of the hardware is set to an idle state.
  13. 根据权利要求8所述的方法,其特征在于,所述方法还包括:The method of claim 8 further comprising:
    若识别出所述第二应用程序接口不具有独占操作属性,则根据所述调用请求调用所述第二应用程序接口,以执行所述硬件操作指令。If it is recognized that the second application interface does not have an exclusive operation attribute, the second application interface is invoked according to the call request to execute the hardware operation instruction.
  14. 根据权利要求9或13所述的方法,其特征在于,所述方法还包括:The method according to claim 9 or 13, wherein the method further comprises:
    将所述硬件操作指令对应的硬件操作结果反馈给所述第一进程。And feeding back the hardware operation result corresponding to the hardware operation instruction to the first process.
  15. 根据权利要求14所述的方法,其特征在于,所述将所述硬件操作指令对应的硬件操作结果反馈给所述第一进程,包括:The method according to claim 14, wherein the feeding back the hardware operation result corresponding to the hardware operation instruction to the first process comprises:
    若所述硬件执行所述硬件操作指令而产生的硬件数据的数据量小于预设阈值,则将所述硬件数据作为所述硬件操作结果发送至所述第一进程;And if the data amount of the hardware data generated by the hardware executing the hardware operation instruction is less than a preset threshold, sending the hardware data to the first process as the hardware operation result;
    若所述硬件数据的数据量大于或等于所述预设阈值,则将所述硬件数据存入共享内存中,并将所述硬件数据在所述共享内存中的存储地址发送至所述第一进程。And if the data amount of the hardware data is greater than or equal to the preset threshold, storing the hardware data in a shared memory, and sending the storage address of the hardware data in the shared memory to the first process.
  16. 根据权利要求9所述的方法,其特征在于,所述方法还包括:The method of claim 9 wherein the method further comprises:
    接收所述第二操作系统中第三进程通过跨进程通信发送的查询请求,所述查询请求用于查询所述硬件的状态;Receiving a query request sent by the third process in the second operating system by using a cross-process communication, where the query request is used to query a state of the hardware;
    将所述硬件的状态发送给所述第三进程,以使所述第三进程根据所述状态确定能否调用所述硬件抽象层。Transmitting the state of the hardware to the third process to cause the third process to determine whether the hardware abstraction layer can be invoked according to the state.
  17. 一种硬件抽象层复用装置,其特征在于,应用于第一操作系统的第一进程中,包括:A hardware abstraction layer multiplexing device, which is applied to a first process of a first operating system, and includes:
    接收模块,用于接收第二操作系统中第二进程通过跨进程通信发送的调用请求,所述调用请求是所述第二进程响应于硬件操作指令而调用所述第二操作系统对应的虚拟硬件抽象层中的第一应用程序接口触发的;a receiving module, configured to receive a call request sent by the second process in the second operating system by using the cross-process communication, where the call request is that the second process invokes the virtual hardware corresponding to the second operating system in response to the hardware operation instruction Triggered by the first application interface in the abstraction layer;
    调用模块,用于根据所述调用请求调用所述第二操作系统对应的硬件抽象层中的第二应用程序接口,以执行所述硬件操作指令;a calling module, configured to invoke a second application program interface in a hardware abstraction layer corresponding to the second operating system according to the calling request, to execute the hardware operation instruction;
    其中,所述第一应用程序接口在所述虚拟硬件抽象层中的配置与所述第二应用程序接口在所述硬件抽象层中的配置具有对应关系。The configuration of the first application program interface in the virtual hardware abstraction layer has a corresponding relationship with the configuration of the second application program interface in the hardware abstraction layer.
  18. 一种操作系统,其特征在于,包括:An operating system, comprising:
    应用程序框架层和跨进程通信接口,所述应用程序框架层中包括一进程,所述进程 用于实现如权利要求8至16中任一项所述的硬件抽象层复用方法。An application framework layer and a cross-process communication interface, the application framework layer including a process for implementing the hardware abstraction layer multiplexing method according to any one of claims 8 to 16.
  19. 一种电子设备,其特征在于,包括存储器和处理器;其中,An electronic device, comprising: a memory and a processor; wherein
    所述存储器用于存储一条或多条计算机指令,其中,所述一条或多条计算机指令被所述处理器执行时实现如权利要求8至16中任一项所述的硬件抽象层复用方法。The memory is for storing one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the hardware abstraction layer multiplexing method according to any one of claims 8 to 16. .
PCT/CN2018/109550 2017-10-13 2018-10-10 Hardware abstraction layer multiplexing method and apparatus, operating system and device WO2019072182A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710953523.1 2017-10-13
CN201710953523.1A CN109669782A (en) 2017-10-13 2017-10-13 Hardware abstraction layer multiplexing method, device, operating system and equipment

Publications (1)

Publication Number Publication Date
WO2019072182A1 true WO2019072182A1 (en) 2019-04-18

Family

ID=66100422

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/109550 WO2019072182A1 (en) 2017-10-13 2018-10-10 Hardware abstraction layer multiplexing method and apparatus, operating system and device

Country Status (3)

Country Link
CN (1) CN109669782A (en)
TW (1) TW201937364A (en)
WO (1) WO2019072182A1 (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109669723B (en) * 2017-10-13 2023-06-13 斑马智行网络(香港)有限公司 Hardware access method, apparatus, device and machine readable medium
CN110708581B (en) * 2019-08-27 2021-09-24 海信视像科技股份有限公司 Display device and method for presenting multimedia screen saver information
CN112559199A (en) * 2019-09-24 2021-03-26 中兴通讯股份有限公司 Device and method for controlling android Bluetooth in glibc environment and terminal equipment
CN110933275B (en) * 2019-12-09 2021-07-23 Oppo广东移动通信有限公司 Photographing method and related equipment
WO2021120092A1 (en) * 2019-12-19 2021-06-24 Intel Corporation Hardware based abstraction sharing of hardware devices across computing platforms
CN113139176A (en) * 2020-01-20 2021-07-20 华为技术有限公司 Malicious file detection method, device, equipment and storage medium
CN111225153B (en) * 2020-01-21 2021-08-06 Oppo广东移动通信有限公司 Image data processing method, image data processing device and mobile terminal
CN111614900B (en) * 2020-05-26 2022-07-15 上海龙旗科技股份有限公司 Camera driving method and apparatus
CN112231017B (en) * 2020-10-27 2021-06-22 北京技德系统技术有限公司 Virtual keyboard and mouse method and device compatible with Android running environment running on Linux
CN113379589A (en) * 2021-07-06 2021-09-10 湖北亿咖通科技有限公司 Dual-system graphic processing method and device and terminal
CN113505007A (en) * 2021-07-12 2021-10-15 北京鲸鲮信息系统技术有限公司 Protocol stack data transmission method based on Linux system, computer equipment and storage medium
CN113852718B (en) * 2021-09-26 2022-11-15 北京字节跳动网络技术有限公司 Voice channel establishing method and device, electronic equipment and storage medium
CN114020364B (en) * 2021-11-16 2024-04-26 北京字节跳动网络技术有限公司 Sensor device adaptation method, device, electronic device and storage medium
CN115562765B (en) * 2022-12-05 2023-04-07 北京小米移动软件有限公司 Control method and device of positioning assembly, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001061490A2 (en) * 2000-02-17 2001-08-23 Tensilica, Inc. Abstraction of configurable processor functionality for operating systems portability
CN105808320A (en) * 2016-03-11 2016-07-27 四川安嵌科技有限公司 Equipment virtualization system and method based on Linux container
CN107077377A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 A kind of device virtualization method, device, system and electronic equipment, computer program product

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7581229B2 (en) * 2005-03-11 2009-08-25 Microsoft Corporation Systems and methods for supporting device access from multiple operating systems
CN105760239B (en) * 2016-02-03 2019-04-16 北京元心科技有限公司 Method and system for accessing third party library for first system in second system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001061490A2 (en) * 2000-02-17 2001-08-23 Tensilica, Inc. Abstraction of configurable processor functionality for operating systems portability
CN105808320A (en) * 2016-03-11 2016-07-27 四川安嵌科技有限公司 Equipment virtualization system and method based on Linux container
CN107077377A (en) * 2016-12-29 2017-08-18 深圳前海达闼云端智能科技有限公司 A kind of device virtualization method, device, system and electronic equipment, computer program product

Also Published As

Publication number Publication date
CN109669782A (en) 2019-04-23
TW201937364A (en) 2019-09-16

Similar Documents

Publication Publication Date Title
WO2019072182A1 (en) Hardware abstraction layer multiplexing method and apparatus, operating system and device
JP6092249B2 (en) Virtual channel for embedded process communication
US11138030B2 (en) Executing code referenced from a microservice registry
US11829787B2 (en) Multi-process model for cross-platform applications
WO2018161812A1 (en) User interface rendering method and device
JP5215779B2 (en) Information processing apparatus and information processing method
US10579442B2 (en) Inversion-of-control component service models for virtual environments
TW201833768A (en) Resource loading method and device
TW201544955A (en) Object oriented marshaling scheme for calls to a secure region
CN113939805A (en) Method and system for interprocess communication
US10848595B2 (en) Method and device for message sending and receiving based on a communication interface framework
WO2020042769A1 (en) Image information transmission method and apparatus, and storage medium and electronic device
CN110780930B (en) Method and device for starting Android system, electronic equipment and storage medium
CN112612536A (en) Method and device for controlling camera shooting based on Android application program in Linux system
EP4310667A1 (en) Ai application deployment method, and related platform, cluster, medium and program product
CN109889468B (en) Network data transmission method, system, device, equipment and storage medium
US20170286140A1 (en) Java-based offload service in a mainframe environment
WO2021056640A1 (en) Method and apparatus for controlling machinery device, and storage medium
WO2019085780A1 (en) Cloud storage system and method for achieving user-defined data processing in cloud storage system
CN111007932A (en) Temperature control system, temperature control method based on temperature control system and electronic equipment
CN113992854A (en) Image preview method and device, electronic equipment and computer readable storage medium
CN104570967B (en) Long-range control method and system based on android system
CN113821333A (en) Android application program migration method and device
CN109445960B (en) Application routing method, device and storage medium
WO2023050418A1 (en) Data processing method, data processing system, electronic device, and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18866036

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18866036

Country of ref document: EP

Kind code of ref document: A1