Understanding Android GPS HAL Driver

Understanding Android GPS HAL Driver

Alex Dou 

autoasm@yahoo.com


Android Hardware Abstraction Layer

The Android HAL (Hardware Abstraction Layer) is software layer that the user space device drivers reside in. According to Google's documents, the purpose of introducing the layer is to provide a unified interface for framework. Meanwhile the HAL is also a antidote for GPL, because anything that be put into kernel have to follow GPL to be open sourced.

Before understanding GPS HAL driver,let us take a look at the the HAL structure. 

The HAL driver is a .so file that under specific path. The .so file must export a hw_module_t symbol as an entry point of the driver. Through calling open() method of of the hw_module_t object, system can retrieve an instance of hw_device_t that represents the expected device. Once the device instance be returned, the android framework can manipulate on the device through methods of hw_device_t.

The below diagram shows relationship between these concepts.   

As a diagram shows, gps_device_t is a subclass of hw_device_t. Although the C Language does not support object-oriented concepts, from the view point of object module, the relation ship between gps_device_t and hw_device_t should be inheritence. 

GPS HAL Driver

As we discussed in the above section, the GPS driver is a subclass of HAL driver, it also provide a specific interface to manipulate GPS device.  Now, let us go deeper into the implementation of a typical GPS HAL driver.

Please see the below diagram

The GPS HAL driver contains a HAL_MODULE_INFO_SYM block as the entry. System can locate the entry easily because the symbol name is well-defined. Once the entry object is located, the gps_device_t instance can be created by calling open() of gps_module_methods which methods field points to. As we have discussed, the gps_device_t provides an method to export GPS-specific interface, now, the system can call dev->get_gps_interface() to obtain the GPS operations. 

So far, we have known the structure of GPS HAL driver and we understood the GPS driver loading process as well. I don't want talk more about how the GpsInerface workswith Underlying module, because 1. the GPS theory is too complex to discuss within the paper. 2. The implementation of GpsInterface highly depends on your system design, it can work with serial port to retrive location from external GPS module, it is also enable to call ioctrl() to interact with linux device driver.


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值