Infrastructure Middleware (Part 1): Hardware Abstraction...

33
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

Transcript of Infrastructure Middleware (Part 1): Hardware Abstraction...

Page 1: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

Infrastructure Middleware (Part 1):Hardware Abstraction Layer (HAL)

Douglas C. [email protected]

www.dre.vanderbilt.edu/~schmidt

Institute for Software Integrated Systems

Vanderbilt University Nashville, Tennessee, USA

Page 2: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

2

Learning Objectives in this Part of the Lesson• Understand the role the HAL plays

in Android’s system architectureApplication Frameworks

Operating System Kernel

System Libraries VM & Runtime

Hardware Abstraction Layer (HAL)

Bundled & Third-Party Apps

The HAL mediates interactions between the OS kernel layer & higher layers

Page 3: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

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

Page 4: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

4

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, so you needn’t know all the details

Page 5: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

5

Overview of Android HardwareAbstraction Layer

Page 6: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

6

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

See source.android.com/devices/#Hardware Abstraction Layer

Page 7: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

7

Application Frameworks

Bundled & Third-Party Apps

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture, e.g.• Decouples Android platform software

from hardware

Operating System Kernel

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

Page 8: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

8

Application Frameworks

Bundled & Third-Party Apps

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture, e.g.• Decouples Android platform software

from hardware• i.e., apps don’t break when hardware

changes

Operating System Kernel

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

Page 9: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

9

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture, e.g.• Decouples Android platform software

from hardware• Decouples Android framework layer

from the operating system layer

Operating System Kernel

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

Application Frameworks

Bundled & Third-Party Apps

Page 10: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

10

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture, e.g.• Decouples Android platform software

from hardware• Decouples Android framework layer

from the operating system layer• e.g., this layer can be programmed

via method calls on Java objects,rather than C system function calls

Operating System Kernel

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

Application Frameworks

Bundled & Third-Party Apps

Page 11: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

11

The Android Hardware Abstraction Layer (HAL)

• The HAL helps to separate concerns in the Android system architecture, e.g.• Decouples Android platform software

from hardware• Decouples Android framework layer

from the operating system layer• e.g., this layer can be programmed

via method calls on Java objects,rather than C system function calls

Operating System Kernel

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

Application Frameworks

Bundled & Third-Party Apps

App developers can thus focus on business logic, rather than low-level details

Page 12: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

12

The Android Hardware Abstraction Layer (HAL)

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

• Android’s HAL defines interfaces that driver modules must implement

See source.android.com/devices/#structure

Page 13: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

13

The Android Hardware Abstraction Layer (HAL)

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

• Android’s HAL defines interfaces that driver modules must implement

These driver modules do not run in the Android Linux kernel!

Page 14: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

14

The Android Hardware Abstraction Layer (HAL)

• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

See earlier lesson on the “Android Linux Kernel”

Page 15: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

15

The Android Hardware Abstraction Layer (HAL)

• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel• User space code can’t directly access

Android Linux kernel device driversApplication Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

See earlier lesson on the “Android Linux Kernel”

Page 16: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

16

The Android Hardware Abstraction Layer (HAL)

• The Android HAL is a user space C/C++ library layer, unlike device drivers residing in the Android Linux kernel• User space code can’t directly access

Android Linux kernel device drivers• Therefore apps & system services use

the HAL to interact w/kernel drivers

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

System Libraries VM Runtime

Hardware Abstraction Layer (HAL)

C/ C++

See www.dre.vanderbilt.edu/~schmidt/PDF/Android-HAL.pdf

Page 17: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

17

The Android Hardware Abstraction Layer (HAL)

• OEMs implement HAL driver modules for their proprietary hardwareC/ C+

+

See source.android.com/devices/#Hardware Abstraction Layer

Page 18: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

18

The Android Hardware Abstraction Layer (HAL)

C/ C++

See source.android.com/devices/camera

• e.g., camera hardware from an OEM has a camera system service & a camera HAL API

• OEMs implement HAL driver modules for their proprietary hardware

Page 19: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

19

The Android Hardware Abstraction Layer (HAL)

• Driver modules that implement HAL APIs are linked dynamically by AndroidC/ C+

+

See source.android.com/devices/#modules

Page 20: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

20

The Android Hardware Abstraction Layer (HAL)

• Driver modules that implement HAL APIs are linked dynamically by AndroidC/ C+

+

See source.android.com/devices/#modules

• e.g., when an app first accesses the camera hardware encapsulated by the camera HAL API

Page 21: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

21

Motivations forAndroid’s HardwareAbstraction Layer

Page 22: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

22

The Android Hardware Abstraction Layer (HAL)

• There are two types of motivations for Android’s user space HAL design

C/ C++

Page 23: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

23

The Android Hardware Abstraction Layer (HAL)

• One motivation is technicalC/ C+

+

Page 24: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

24

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

Hardware Abstraction Layer (HAL)

C/ C++

The Android Hardware Abstraction Layer (HAL)

• One motivation is technical• Shielding higher layers of

Android’s software stack fromLinux kernel idiosyncrasies

System Libraries VM & Runtime

Page 25: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

25

C/ C++

The Android Hardware Abstraction Layer (HAL)

• One motivation is technical• Shielding higher layers of

Android’s software stack fromLinux kernel idiosyncrasies• GNU Linux device drivers don’t

provide consistent support forcertain types of devices• It’s historical focus is on

laptops/desktops/servers

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

Hardware Abstraction Layer (HAL)

System Libraries VM & Runtime

Page 26: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

26

C/ C++

The Android Hardware Abstraction Layer (HAL)

• One motivation is technical• Shielding higher layers of

Android’s software stack fromLinux kernel idiosyncrasies• GNU Linux device drivers don’t

provide consistent support forcertain types of devices

• The HAL therefore defines a consistent object-oriented API for these hardware elements

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

Hardware Abstraction Layer (HAL)

System Libraries VM & Runtime

Page 27: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

27

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economicC/ C+

+

Page 28: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

28

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economic• Kernel device drivers are “GPL’d”

See en.wikipedia.org/wiki/GNU_General_Public_License

C/ C++

Page 29: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

29

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economic• Kernel device drivers are “GPL’d”

• The GPL requires OEMs give outsource code for their drivers

See en.wikipedia.org/wiki/GNU_General_Public_License

C/ C++

Page 30: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

30

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economic• Kernel device drivers are “GPL’d”

• The GPL requires OEMs give outsource 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

C/ C++

See hiqes.com/android-linux-kernel-drivers

Page 31: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

31

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economic• Kernel device drivers are “GPL’d”

• The GPL requires OEMs give outsource code for their drivers

• However, Android OEMs often use proprietary drivers

• Putting driver implementations in user-space HAL enables themnot to release the source code

C/ C++

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

Hardware Abstraction Layer (HAL)

System Libraries VM & Runtime

See www.apache.org/licenses/LICENSE-2.0

Page 32: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

32

The Android Hardware Abstraction Layer (HAL)

• Another motivation is economic• Kernel device drivers are “GPL’d”

• The GPL requires OEMs give outsource code for their drivers

• However, Android OEMs often use proprietary drivers

• Putting driver implementations in user-space HAL enables themnot to release the source code

• See Android licenses for details

C/ C++

See source.android.com/source/licenses.html

Application Frameworks

Operating System Kernel

Bundled & Third-Party Apps

Hardware Abstraction Layer (HAL)

System Libraries VM & Runtime

Page 33: Infrastructure Middleware (Part 1): Hardware Abstraction ...schmidt/cs891f/2017-PDFs/L4-pt1-HAL.pdfThe Android Hardware Abstraction Layer (HAL) • The Android HAL is a user space

33

End of Infrastructure Middleware (Part 1):

Hardware Abstraction Layer