Infrastructure Middleware (Part 1): Hardware Abstraction Layer (HAL)
Douglas C. Schmidt [email protected] www.dre.vanderbilt.edu/~schmidt
Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA Learning Objectives in this Part of the Lesson • Understand the role the HAL plays Bundled & Third-Party Apps in Android’s system architecture Application Frameworks System Libraries VM & Runtime Hardware Abstraction Layer (HAL) Operating System Kernel
The HAL mediates interactions between2 the OS kernel layer & higher layers Learning Objectives in this Part of the Lesson • Understand the role the HAL plays in Android’s system architecture • Know the technical & economic factors that motivated Google & its original equipment manufacturer (OEM) partners to add a HAL to the Android software stack
3 Learning Objectives in this Part of the Lesson • Understand the role the HAL plays in Android’s system architecture • Know the technical & economic factors that motivated Google & its original equipment manufacturer (OEM) partners to add a HAL to the Android software stack
Android apps rarely access the HAL directly,4 so you needn’t know all the details Overview of Android Hardware Abstraction Layer
5 The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture
Bundled & Third-Party Apps
Application Frameworks
System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
See source.android.com/devices6 /#Hardware Abstraction Layer The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture, e.g.
• Decouples Android platform software Bundled & Third-Party Apps
from hardware Application Frameworks
System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
7 The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture, e.g.
• Decouples Android platform software Bundled & Third-Party Apps
from hardware Application Frameworks
• i.e., apps don’t break when hardware System Libraries VM Runtime changes Hardware Abstraction Layer (HAL)
Operating System Kernel
8 The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture, e.g.
• Decouples Android platform software Bundled & Third-Party Apps
from hardware Application Frameworks
• Decouples Android framework layer System Libraries VM Runtime from the operating system layer Hardware Abstraction Layer (HAL)
Operating System Kernel
9 The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture, e.g.
• Decouples Android platform software Bundled & Third-Party Apps
from hardware Application Frameworks
• Decouples Android framework layer System Libraries VM Runtime from the operating system layer Hardware Abstraction Layer (HAL) • e.g., this layer can be programmed via method calls on Java objects, Operating System Kernel rather than C system function calls
10 The Android Hardware Abstraction Layer (HAL) C/ C++
• The HAL helps to separate concerns in the Android system architecture, e.g.
• Decouples Android platform software Bundled & Third-Party Apps
from hardware Application Frameworks
• Decouples Android framework layer System Libraries VM Runtime from the operating system layer Hardware Abstraction Layer (HAL) • e.g., this layer can be programmed via method calls on Java objects, Operating System Kernel rather than C system function calls
App developers can thus focus on business11 logic, rather than low-level details The Android Hardware Abstraction Layer (HAL) C/ C++
• Android’s HAL defines interfaces that driver modules must implement
Bundled & Third-Party Apps
Application Frameworks
System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
See source.android.com/devices12 /#structure The Android Hardware Abstraction Layer (HAL) C/ C++
• Android’s HAL defines interfaces that driver modules must implement
Bundled & Third-Party Apps
Application Frameworks
System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
These driver modules do not run13 in the Android Linux kernel! The Android Hardware Abstraction Layer (HAL) C/ C++
• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel Bundled & Third-Party Apps
Application Frameworks
System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
See earlier lesson on the14 “Android Linux Kernel” The Android Hardware Abstraction Layer (HAL) C/ C++
• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel Bundled & Third-Party Apps • User space code can’t directly access Application Frameworks Android Linux kernel device drivers System Libraries VM Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
See earlier lesson on the15 “Android Linux Kernel” The Android Hardware Abstraction Layer (HAL) C/ C++
• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel Bundled & Third-Party Apps • User space code can’t directly access Application Frameworks Android Linux kernel device drivers System Libraries VM Runtime • Therefore apps & system services use the HAL to interact w/kernel drivers Hardware Abstraction Layer (HAL) Operating System Kernel
See www.dre.vanderbilt.edu/~16schmidt/PDF/Android-HAL.pdf The Android Hardware Abstraction Layer (HAL) C/ C++
• OEMs implement HAL driver modules for their proprietary hardware
See source.android.com/devices17/#Hardware Abstraction Layer The Android Hardware Abstraction Layer (HAL) C/ C++
• OEMs implement HAL driver modules for their proprietary hardware
• e.g., camera hardware from an OEM has a camera system service & a camera HAL API
See source.android.com/devices/camera18 The Android Hardware Abstraction Layer (HAL) C/ C++
• Driver modules that implement HAL APIs are linked dynamically by Android
See source.android.com/devices19 /#modules The Android Hardware Abstraction Layer (HAL) C/ C++
• Driver modules that implement HAL APIs are linked dynamically by Android
• e.g., when an app first accesses the camera hardware encapsulated by the camera HAL API
See source.android.com/devices20 /#modules Motivations for Android’s Hardware Abstraction Layer
21 The Android Hardware Abstraction Layer (HAL) C/ C++
• There are two types of motivations for Android’s user space HAL design
22 The Android Hardware Abstraction Layer (HAL) C/ C++
• One motivation is technical
23 The Android Hardware Abstraction Layer (HAL) C/ C++
• One motivation is technical Bundled & Third-Party Apps • Shielding higher layers of Android’s software stack from Application Frameworks Linux kernel idiosyncrasies System Libraries VM & Runtime
Hardware Abstraction Layer (HAL)
Operating System Kernel
24 The Android Hardware Abstraction Layer (HAL) C/ C++
• One motivation is technical Bundled & Third-Party Apps • Shielding higher layers of Android’s software stack from Application Frameworks Linux kernel idiosyncrasies • GNU Linux device drivers don’t System Libraries VM & Runtime provide consistent support for certain types of devices Hardware Abstraction Layer (HAL) • It’s historical focus is on Operating System Kernel laptops/desktops/servers
25 The Android Hardware Abstraction Layer (HAL) C/ C++
• One motivation is technical Bundled & Third-Party Apps • Shielding higher layers of Android’s software stack from Application Frameworks Linux kernel idiosyncrasies • GNU Linux device drivers don’t System Libraries VM & Runtime provide consistent support for certain types of devices Hardware Abstraction Layer (HAL) • The HAL therefore defines a Operating System Kernel consistent object-oriented API for these hardware elements
26 The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic
27 The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic • Kernel device drivers are “GPL’d”
See en.wikipedia.org/wiki/GNU_General_Public_License28 The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic • Kernel device drivers are “GPL’d” • The GPL requires OEMs give out source code for their drivers
See en.wikipedia.org/wiki/GNU_General_Public_License29 The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic • Kernel device drivers are “GPL’d” • The GPL requires OEMs give out source code for their drivers • However, Android OEMs often use proprietary drivers • i.e., they don’t want to give out the source code for them
See hiqes.com/android30-linux-kernel-drivers The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic Bundled & Third-Party Apps • Kernel device drivers are “GPL’d” • The GPL requires OEMs give out Application Frameworks source code for their drivers System Libraries VM & Runtime • However, Android OEMs often use proprietary drivers Hardware Abstraction Layer (HAL) • Putting driver implementations in user-space HAL enables them Operating System Kernel not to release the source code
See www.apache.org/licenses/LICENSE31 -2.0 The Android Hardware Abstraction Layer (HAL) C/ C++
• Another motivation is economic Bundled & Third-Party Apps • Kernel device drivers are “GPL’d” • The GPL requires OEMs give out Application Frameworks source code for their drivers System Libraries VM & Runtime • However, Android OEMs often use proprietary drivers Hardware Abstraction Layer (HAL) • Putting driver implementations in user-space HAL enables them Operating System Kernel not to release the source code • See Android licenses for details
See source.android.com/source/licenses.html32 End of Infrastructure Middleware (Part 1): Hardware Abstraction Layer
33