< The Linux Kernel

Welcome to the first article of the book. The article is named after USB class and Linux facility Human Interface Devices (HID). HID facility in Linux supports keyboard, mouse and other input devices. Console, multimedia (or just media), sound (audio), video, graphics also are in the focus of this article. Security and debugging topics are very related to user and human interactions so are described here too.

Char devices

A character device file is one of the most simple, fundamental and oldest concepts derived from UNIX. This kind of devices is used in many facilities from keyboard input to default interface for a sophisticated new driver. You can find a list of registered char devices on the beginning the listing of /proc/devices.

Key function cdev_add idadds a char device to the system.

Tip: Browse the cross-referencing site to explore nearby API and use cases


⚲ API:

register_chrdev id, unregister_chrdev id
alloc_chrdev_region id/ register_chrdev_region id, unregister_chrdev_region id

linux/cdev.h inc


βš™οΈ Internals:


πŸ“š References


πŸ’Ύ Historical

Security

The purpose of security is to restrict access across interfaces. One of the most frequently executed functions is may_open id . It rejects access of unauthorized users to open a file. It uses common function inode_permission id which check for access rights to a given inode.


The most common functions for changing ownership and access rights (modes) to files:


⚲ API, πŸ”§ TODO:

Credentials

⚲ API:

πŸ“š References

Cryptography

⚲ API:

βš™οΈ Internals:

πŸ“š References



πŸ“š References

Debugging


⚲ User-mode debug interfaces

βš™οΈ Internals

πŸ“š References

⚲ Kernel-mode debug facilities

Printing to log

Most common functions

  • pr_devel id- conditional debug-level message
  • pr_debug id- conditional debug-level or dynamic docmessage
    • ⌨ Example:
    • echo "module atkbd +pfl" | sudo tee /sys/kernel/debug/dynamic_debug/control

πŸ”§ TODO. More ...


βš™οΈ Internals


kgdb and kdb

⚲ Interfaces


βš™οΈ Internals


πŸ“š References



πŸ“š References

Subsystems

Advanced Linux Sound Architecture - ALSA

⚲ API:


πŸ“š References

Video4Linux - V4L2

⚲ API:

πŸ“š References

HID

Generic human interface devices

Input devices

Classic input devices are keyboard and mouse.


⚲ API:


πŸ‘ For example drivers/input/mousedev.c src


⌨ Hands on:

sudo hexdump /dev/input/mice # dump your mouse movements events from your kernel


βš™οΈ Internals:


πŸ“š References

HID devices

πŸ”§ TODO


⚲ API:

hiddev

USB HID devices (from the USB specification standpoint) that aren't direct human interface devices, like monitor controls and Uninterruptible Power Supplies. This module supports these devices separately using a separate event interface on /dev/usb/hiddevX (char 180:96 to 180:111) (βš™οΈ HIDDEV_MINOR_BASE id)

⚲ API:


βš™οΈ Internals: drivers/hid/usbhid/hiddev.c src, hiddev_fops id

πŸ“š References: HIDDEV - Care and feeding of your Human Interface Devices doc

Console

⚲ API:

βš™οΈ Internals:

πŸ“š References

Sound infrastructure

⚲ API:

πŸ“š References

Video

πŸ”§ TODO


⚲ API:

πŸ“š References

HI device drivers

The scope of this paragraph is about low level specific human interface drivers.


⚲ HID API:


βš™οΈ Internals


πŸ“š References

  • drivers/hid src
  • drivers/input src : keyboard & mouse, misc, serio, tablet, touchscreen, gameport, joystick
    • ⌨ Hands on:
    • echo "module atkbd +pfl" | sudo tee /sys/kernel/debug/dynamic_debug/control

USB HID

βš™οΈ Internals:

πŸ“š References

Multimedia

πŸ”§ TODO


πŸ—οΈ Acronyms:


⚲ API:


βš™οΈ Internals


πŸ“š References:


Sound

πŸ“š References

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.