android系统开发--HAL层开发基础

android系统开发--HAL层开发基础

ID:41091481

大小:43.00 KB

页数:5页

时间:2019-08-16

android系统开发--HAL层开发基础_第1页
android系统开发--HAL层开发基础_第2页
android系统开发--HAL层开发基础_第3页
android系统开发--HAL层开发基础_第4页
android系统开发--HAL层开发基础_第5页
资源描述:

《android系统开发--HAL层开发基础》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、android系统开发--HAL层开发基础AndroidHAL层,即硬件抽象层,是Google响应厂家“希望不公开源码”的要求推出的新概念1,源代码和目标位置源代码:/hardware/libhardware目录,该目录的目录结构如下:/hardware/libhardware/hardware.c编译成libhardware.so,目标位置为/system/lib目录/hardware/libhardware/include/hardware目录下包含如下头文件:hardware.h通用硬件模块头文件co

2、pybit.hcopybit模块头文件gralloc.hgralloc模块头文件lights.h背光模块头文件overlay.hoverlay模块头文件qemud.hqemud模块头文件sensors.h传感器模块头文件/hardware/libhardware/modules目录下定义了很多硬件模块这些硬件模块都编译成xxx.xxx.so,目标位置为/system/lib/hw目录2,HAL层的实现方式JNI->通用硬件模块->硬件模块->内核驱动接口具体一点:JNI->libhardware.so->x

3、xx.xxx.so->kernel具体来说:androidframeworks中JNI调用/hardware/libhardware/hardware.c中定义的hw_get_module函数来获取硬件模块,然后调用硬件模块中的方法,硬件模块中的方法直接调用内核接口完成相关功能3,通用硬件模块(libhardware.so)(1)头文件为:/hardware/libhardware/include/hardware/hardware.h头文件中主要定义了通用硬件模块结构体hw_module_t,声明了JNI

4、调用的接口函数hw_get_modulehw_module_t定义如下:typedefstructhw_module_t{/**tagmustbeinitializedtoHARDWARE_MODULE_TAG*/uint32_ttag;/**majorversionnumberforthemodule*/uint16_tversion_major;/**minorversionnumberofthemodule*/uint16_tversion_minor;/**Identifierofmodule*/c

5、onstchar*id;/**Nameofthismodule*/constchar*name;/**Author/owner/implementorofthemodule*/constchar*author;/**Modulesmethods*/structhw_module_methods_t*methods;//硬件模块的方法/**module'sdso*/void*dso;/**paddingto128bytes,reservedforfutureuse*/uint32_treserved[32-7

6、];}hw_module_t;硬件模块方法结构体hw_module_methods_t定义如下:typedefstructhw_module_methods_t{/**Openaspecificdevice*/int(*open)(conststructhw_module_t*module,constchar*id,structhw_device_t**device);}hw_module_methods_t;只定义了一个open方法,其中调用的设备结构体参数hw_device_t定义如下:typedefs

7、tructhw_device_t{/**tagmustbeinitializedtoHARDWARE_DEVICE_TAG*/uint32_ttag;/**versionnumberforhw_device_t*/uint32_tversion;/**referencetothemodulethisdevicebelongsto*/structhw_module_t*module;/**paddingreservedforfutureuse*/uint32_treserved[12];/**Closethi

8、sdevice*/int(*close)(structhw_device_t*device);}hw_device_t;hw_get_module函数声明如下:inthw_get_module(constchar*id,conststructhw_module_t**module);参数id为模块标识,定义在/hardware/libhardware/include/hardware目录下的硬件模块头文件中,参数

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。