Encoding Summary of the android HAL Interface

Source: Internet
Author: User

Encoding Summary of the android HAL Interface
Define a modulestruct xxx_module_t {hw_module_t common; xxx. Here we mainly use ops interfaces that can be operated on the module when it is not open. Sometimes we can leave it empty}
Struct xxx_mdoule HAL_MODULE_INFO_SYM = {fill the struct with hw_module_t
} // All hal modules have the same name. This structure is converted into an hmi descriptor during compilation for use when loading the corresponding so. At the same time, the load id must be consistent with hw_module_t.
The methods of hw_module_t generally needs to specify and implement an open interface, as shown below: typedef struct hw_module_methods_t {/** Open a specific device */
Int (* open) (const struct hw_module_t * module, const char * id, struct hw_device_t ** device);} hw_module_methods_t;

Generally, the xxx_device_t interface of the device to be used by a module is returned after open. The general structure is as follows. Note that when multiple encapsulation is performed, make sure that the hw_device_t is at the first address of the returned address: typedef struct xxx_device_t {hw_device_t common; xxx various ops functions that can operate on devices. } Or class xxx_xxxx_t: public struct xxx_device_t {xxx_xxx_t ();}
In the constructor, xxx_xxxx_t () {initialization of xxx_device_t is completed, including the ops required by the common and various framework layers}
Struct definition of hw_device_t: typedef struct hw_device_t {uint32_t tag; uint32_t version; struct completion * module; uint32_t reserved [12]; int (* close) (struct hw_device_t * device );

} Hw_device_t;

In conclusion, HAL provides interfaces to the upper layer through the struct xxx_device_t structure.

That is, the interface is contained in the struct xxx_device_t structure.

The specific execution is to return the open function under the function List member of the struct variable struct xxx_module_t HAL_MODULE_INFO_SYM to the upper layer.
Additional: the reason for naming all HAL modules HAL_MODULE_INFO_SYM is that this name will be replaced with a macro name HMI, that is, when the compiler combines the CPP of each module to produce the so library, an HMI symbol table exists internally. When this symbol table loads the module again, it will first perform the dlsym operation, specifically specifying that the symbol entry to be searched is "HMI", which requires that the current module must contain this symbol name. Therefore, each HAL library must ensure that its name is HAL_MODULE_INFO_SYM, because only this name will be replaced with HMI and then compiled into the SO file, SO that it will be loaded into the HMI portal, that is, hw_module_t.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.