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.


已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页