FDD-book/examples/part-05/ch25-advanced/MAINTENANCE.md
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

2 KiB

myfirst

A demonstration character driver that carries the book's running example. This file is the operator-facing reference.

Overview

myfirst registers a pseudo-device at /dev/myfirst0 and serves a read-write message buffer, a set of ioctls, a sysctl tree, and a configurable debug-class logger.

Tunables

  • hw.myfirst.debug_mask_default (int, default 0) Initial value of dev.myfirst..debug.mask.
  • hw.myfirst.timeout_sec (int, default 5) Initial value of dev.myfirst..timeout_sec.
  • hw.myfirst.max_retries (int, default 3) Initial value of dev.myfirst..max_retries.
  • hw.myfirst.log_ratelimit_pps (int, default 10) Initial rate-limit ceiling (prints per second per class).

Sysctls

All sysctls live under dev.myfirst..

Read-only: version, open_count, total_reads, total_writes, message, message_len.

Read-write: debug.mask (mirror of debug_mask_default), timeout_sec, max_retries, log_ratelimit_pps.

Ioctls

Defined in myfirst_ioctl.h. Command magic 'M'.

  • MYFIRSTIOC_GETVER (0): returns MYFIRST_IOCTL_VERSION.
  • MYFIRSTIOC_RESET (1): zeros read/write counters.
  • MYFIRSTIOC_GETMSG (2): reads the in-driver message.
  • MYFIRSTIOC_SETMSG (3): writes the in-driver message.
  • MYFIRSTIOC_GETCAPS (5): returns MYF_CAP_* bitmask.

Command 4 was reserved during Chapter 23 draft work and retired before release. Do not reuse the number.

Events

Emitted through devctl_notify(9).

  • system=myfirst subsystem= type=MSG_CHANGED The operator-visible message was rewritten.

Version History

See Change Log below.

Change Log

1.8-maintenance

  • Added MYFIRSTIOC_GETCAPS (command 5).
  • Added tunables for timeout_sec, max_retries, log_ratelimit_pps.
  • Added rate-limited logging via ppsratecheck(9).
  • Added devctl_notify for MSG_CHANGED.
  • No breaking changes from 1.7.

1.7-integration

  • First end-to-end integration of ioctl, sysctl, debug.
  • Introduced MYFIRSTIOC_{GETVER,RESET,GETMSG,SETMSG}.

1.6-debug

  • Added DPRINTF framework and SDT probes.