refactor: adopt current style(9) license header order (copyright before SPDX)

Update all example sources, man pages, and chapter code blocks to the
current FreeBSD header convention: plain /* opening, copyright lines
first, SPDX-License-Identifier after them. Add missing headers to
ch21/ch22 example files and missing copyright lines in ch08/ch16/ch36.
Rewrite chapter 37 prose (en, pt_BR, es_ES, zh_CN) and the submission
checklist, which previously taught the /*- marker and SPDX-first order.
This commit is contained in:
Abdelkader Boudih 2026-08-26 02:32:55 +01:00
parent de69c0932f
commit 127eb3863c
174 changed files with 727 additions and 644 deletions

View file

@ -238,10 +238,10 @@ Now create `myfirst.c`, the actual driver source. This first version is **minima
Here's the skeleton:
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*/

View file

@ -3614,11 +3614,11 @@ The `myfirst` driver at the end of Chapter 15 uses every primitive Part 3 introd
The companion source under `examples/part-03/ch15-more-synchronization/stage4-final/` includes the complete `myfirst_sync.h`. For reference, here is a full version that can be used as a template.
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* myfirst_sync.h: the named synchronisation vocabulary of the
* myfirst driver.
*

View file

@ -495,7 +495,7 @@ Chapter 16's file layout was `myfirst.c` for the driver lifecycle, `myfirst_hw.c
Create `myfirst_sim.c` alongside the Chapter 16 files. The first version is small:
```c
/*-
/*
* myfirst_sim.c -- Chapter 17 simulated hardware backend.
*
* Adds a callout that drives autonomous register changes, a
@ -3873,11 +3873,11 @@ If you want to go deeper into the topics Chapter 17 touched, the following are g
The complete `myfirst_sim.h` as it stands at the end of Chapter 17, for quick reference. The source is also in `examples/part-04/ch17-simulating-hardware/stage5-final/myfirst_sim.h`.
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* myfirst_sim.h -- Chapter 17 simulation API.
*
* The simulation layer turns the Chapter 16 static register block into

View file

@ -501,11 +501,11 @@ The priority values are negative by convention so that the numerically lowest va
Putting it all together, here is the Chapter 18 Stage 1 driver, presented as a single self-contained file that grows out of the Chapter 17 skeleton. The file name is `myfirst_pci.c`; it is new in Chapter 18 and lives alongside the existing `myfirst.c`, `myfirst_hw.c`, and `myfirst_sim.c`.
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* myfirst_pci.c -- Chapter 18 Stage 1 PCI probe/attach skeleton.
*
* At this stage the driver only probes, attaches, and detaches.
@ -597,11 +597,11 @@ MODULE_VERSION(myfirst, 1);
The companion header, `myfirst_pci.h`:
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* myfirst_pci.h -- Chapter 18 PCI interface for the myfirst driver.
*/
@ -2643,11 +2643,11 @@ Reading this file after writing Chapter 18's driver is a short exercise in patte
### The Top of the File
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2006 Marcel Moolenaar All rights reserved.
* Copyright (c) 2001 M. Warner Losh <imp@FreeBSD.org>
*
* SPDX-License-Identifier: BSD-2-Clause
...
*/

View file

@ -696,11 +696,11 @@ macros in earlier chapters; here we are focusing on how they
arrange themselves on the page.
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Your Name <you@example.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
@ -785,9 +785,9 @@ MODULE_VERSION(mydev, 1);
MODULE_DEPEND(mydev, pci, 1, 1, 1);
```
Several things are worth noticing. The copyright header uses the
`/*-` opening marker, which the automatic licence-harvesting
script recognises. The SPDX line names the licence explicitly.
Several things are worth noticing. The copyright header opens
with a plain `/*` comment, states the copyright first, and then
names the licence explicitly with the SPDX line.
The indentation is tabs, not spaces, as mandated by `style(9)`.
The function declarations are tab-separated, also per `style(9)`.
The `DRIVER_MODULE` and related macros appear at the bottom, in
@ -888,14 +888,13 @@ as a panic message.
#### Copyright Header Form
The copyright header uses the `/*-` opening marker. This marker
is magic. An automated tool harvests licences from the tree by
looking for multi-line comments that start in column 1 with `/*-`.
Using the marker flags the block as a licence; using a regular
`/*` does not. Immediately after `/*-`, the next significant line
should be `SPDX-License-Identifier:` followed by the SPDX licence
code, such as `BSD-2-Clause`. Then come one or more `Copyright`
lines. Then the licence text.
The copyright header is a multi-line comment starting in column 1
with a plain `/*`. Older files open with `/*-`, a marker that a
licence-harvesting tool once relied on; `style(9)` no longer asks
for the dash in new code. The first significant lines are one or
more `Copyright` lines. After the copyright lines comes
`SPDX-License-Identifier:` followed by the SPDX licence code,
such as `BSD-2-Clause`. Then, optionally, the licence text.
#### Function Declarations and Definitions
@ -1204,9 +1203,10 @@ this as a quick self-check before moving on to Section 3.
- File names that do not match the driver. If the driver is
`mydev`, the main source file is `mydev.c`, not `main.c` or
`driver.c`.
- Missing or incorrect copyright header. The header uses `/*-` as
the opening marker, the SPDX identifier comes first, and the
licence text matches one of the project's accepted licences.
- Missing or incorrect copyright header. The header opens with
`/*`, the copyright lines come first, the SPDX identifier
follows them, and the licence text matches one of the project's
accepted licences.
- Spaces instead of tabs. `style(9)` is explicit about tabs, and
the style checker will flag space indentation immediately.
- Missing parentheses on `return` expressions. A recurring small
@ -1351,11 +1351,11 @@ has a specific structure, documented in `style(9)`. Let us walk
through a complete header and examine every part.
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Your Name <you@example.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
@ -1382,22 +1382,23 @@ through a complete header and examine every part.
*/
```
The opening `/*-` is not a typo. The dash after the star is
significant. An automated script in the tree harvests licence
information from files by looking for multi-line comments that
start in column 1 with the sequence `/*-`. Using `/*-` flags the
block as a licence; using plain `/*` does not. `style(9)` is
explicit: if you want the tree's licence harvester to pick up
your licence correctly, use `/*-` for the opening line.
The opening is a plain `/*` in column 1. You will still see `/*-`
at the top of many files in the tree: the dash was a marker for an
automated licence-harvesting script, and for years `style(9)`
required it. The current `style(9)` has dropped that requirement,
so new code opens the header with `/*` and relies on the SPDX line
to identify the licence.
Immediately after the opening is the SPDX-License-Identifier
line. SPDX is a standardised vocabulary for describing licences
in machine-readable form. The line tells the harvester which
licence the file is under, and it does so in a form that cannot be
Immediately after the opening come the copyright lines, then the
SPDX-License-Identifier line. SPDX is a standardised vocabulary
for describing licences in machine-readable form. The line names
the licence the file is under in a form that cannot be
misinterpreted. Use `BSD-2-Clause` for a two-clause BSD licence,
`BSD-3-Clause` for a three-clause BSD licence. For other licences,
consult the SPDX identifier list at `https://spdx.org/licenses/`.
Do not invent identifiers.
Do not invent identifiers. Note the order: `style(9)` says to
write the copyright lines before the SPDX identifier. Older files
have it the other way around; new code should not.
The copyright line names the year and the copyright holder. Use
your full legal name, or the name of your employer if you are
@ -1466,12 +1467,12 @@ The convention in the tree for derivative works is to preserve
the original copyright line and add your own as a separate line:
```c
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 1998 Original Author <original@example.com>
* Copyright (c) 2026 Your Name <you@example.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* [licence text]
*/
```
@ -1546,17 +1547,17 @@ never prepared for submission, you will need to add the proper
header to each file. The steps are:
1. Decide on the licence. For a new driver, use BSD-2-Clause.
2. Write the SPDX identifier line.
3. Write the copyright line with your name, email, and the year
2. Write the copyright line with your name, email, and the year
of first creation.
3. Write the SPDX identifier line after the copyright line.
4. Paste in the standard BSD-2-Clause licence text.
5. Verify that the opening is `/*-` and the file starts in
5. Verify that the opening is `/*` and the file starts in
column 1.
6. Verify that there is a single blank line after the closing
`*/`.
7. Repeat for each file: the `.c` files, the `.h` files, the
manual page (where the licence appears as `.\" -` style
comments rather than `/*-` style), and any other files that
manual page (where the licence appears as `.\"` style
comments rather than `/*` style), and any other files that
contain substantial content.
For the Makefile, as noted earlier, a licence header is
@ -1568,8 +1569,8 @@ shown in Section 2 is trivial enough that no header is required.
There is no single automated tool that validates every aspect of
a FreeBSD copyright header. The `checkstyle9.pl` script catches
some kinds of formatting errors near the header. The licence
harvester in the tree works on the `/*-` marker and the SPDX
line. The most reliable validation, however, is to compare your
tooling in the tree works on the SPDX line. The most reliable
validation, however, is to compare your
header directly against a known-good header from a recent commit
in the tree, such as the header in
`/usr/src/sys/dev/null/null.c` or any recently added driver.
@ -1586,8 +1587,8 @@ saves enormous amounts of time. The FreeBSD Project accepts
BSD-2-Clause, BSD-3-Clause, and a few other permissive licences
for historical files. New contributions should default to
BSD-2-Clause. The copyright header uses a specific form, opening
with `/*-`, followed by an SPDX identifier, followed by one or
more copyright lines, followed by the standard licence text. Code
with `/*`, followed by one or more copyright lines, followed by
an SPDX identifier, followed by the standard licence text. Code
derived from other projects carries its original licence
obligations forward, and derivative work must preserve the
original attributions. Code you did not write yourself requires
@ -1696,11 +1697,11 @@ hypothetical `mydev` driver. Save it as `mydev.4`, run
the kind of manual page you can adapt to your own driver.
```text
.\"-
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2026 Your Name <you@example.com>
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Redistribution and use in source and binary forms, with or
.\" without modification, are permitted provided that the
.\" following conditions are met:
@ -1808,8 +1809,9 @@ with `.\"`. These are mdoc comments. They are not rendered in the
manual page output. They exist to carry the copyright header and
any notes to future editors.
The opening marker is `.\"-` with a dash, equivalent to the `/*-`
in C files. The licence harvester recognises it.
The opening line is a plain `.\"`, equivalent to the `/*` opening
in C files. As in C files, the copyright line comes first and the
SPDX identifier follows it.
The `.Dd` macro sets the document date. It is formatted as month,
day, year with full month name. The project's mdoc style is to
@ -3609,14 +3611,14 @@ Steps:
`.c` file, each `.h` file, and the manual page.
2. For each file, check the existing header. If it is missing or
malformed, replace it with a known-good template.
3. Use `/*-` as the opening of the header in `.c` and `.h` files.
Use `.\"-` as the opening in the manual page.
4. Include the SPDX-License-Identifier line with the appropriate
licence, typically `BSD-2-Clause`.
5. Add your name and email to the Copyright line.
3. Use `/*` as the opening of the header in `.c` and `.h` files.
Use `.\"` as the opening in the manual page.
4. Add your name and email to the Copyright line.
5. Include the SPDX-License-Identifier line, after the Copyright
line, with the appropriate licence, typically `BSD-2-Clause`.
6. Include the standard licence text.
7. Verify that the file starts in column 1 with the `/*-` or
`.\"-` opening.
7. Verify that the file starts in column 1 with the `/*` or
`.\"` opening.
Success criterion: every file has a correctly-formatted header
that matches the conventions of files already in the tree.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Lab 7.4, variant B.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Lab 7.4, variant A.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 0 of Chapter 7: minimal kernel module scaffold.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 1 of Chapter 7: minimal Newbus pseudo-device.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 2 of Chapter 7: complete minimal pseudo-device driver.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 0 of Chapter 8: the Chapter 7 driver with a structured device

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 1 of Chapter 8: add an alias so /dev/myfirst points at

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 2 of Chapter 8: per-open state via devfs_set_cdevpriv().

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 3 of Chapter 8: two-node driver with data and control nodes.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2025 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Stage 4 of Chapter 8: multiple cdevs plus destroy_dev_drain.

View file

@ -1,4 +1,6 @@
/*-
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* hold_myfirst: open /dev/myfirst/0 and sleep. Used for Challenge 2 to

View file

@ -1,4 +1,6 @@
/*-
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* parallel_probe: open a device node multiple times from a single

View file

@ -1,4 +1,6 @@
/*-
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* probe_myfirst: a tiny userland probe for the Chapter 8 myfirst driver.

View file

@ -1,4 +1,6 @@
/*-
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* stat_myfirst: print stat(2) metadata for one or more device-file

View file

@ -1,4 +1,6 @@
/*-
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* stress_probe: loop open() and close() on a device node many times.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Chapter 9, Stage 1: a static-message read path.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Chapter 9, Stage 2: a write-once / read-many buffer.

View file

@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Your Name
*
* SPDX-License-Identifier: BSD-2-Clause
* All rights reserved.
*
* Chapter 9, Stage 3: a first-in / first-out echo driver.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cb_test.c: simple sanity tests for the cbuf userland implementation.
*/

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: userland implementation of the byte-oriented circular buffer.
*/

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer.
*
* The buffer does not lock; the caller is responsible for whatever

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 10, Stage 2: circular-buffer integration.
*
* Replaces the Stage 3 linear FIFO from Chapter 9 with a true

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 10, Stage 3: blocking and non-blocking I/O.
*
* Builds on Stage 2 by adding mtx_sleep(9) on the empty/full

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 10, Stage 4: poll support and refactor.
*
* Adds d_poll, selinfo for read and write readiness, and refactors

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 10, Stage 5: minimal d_mmap on top of Stage 4.
*
* Lets user space mmap(2) the cbuf's backing memory read-only.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* mmap_myfirst.c: read-only mmap tester for /dev/myfirst (Stage 5).
*
* Maps the cbuf's backing memory and dumps the first 64 bytes. The

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* producer_consumer.c: a two-process load test for /dev/myfirst.
*
* Forks a child writer and uses the parent as the reader. Each side

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* rw_myfirst_nb.c: non-blocking behaviour tester for /dev/myfirst.
*
* Exercises Stage 3+ of Chapter 10:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* rw_myfirst_v2.c: sized fill/drain tester for /dev/myfirst.
*
* Usage:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* stress_rw.c: a single-process stress harness for /dev/myfirst.
*
* Runs through a small table of (block size, repeat count) pairs.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 11, Stage 1: DELIBERATELY UNSAFE race-demo driver.
*
* This driver is structurally identical to the Chapter 10 Stage 4 driver,

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 11, Stage 2: concurrent-safe with documented locking.
*
* Functionally identical to the Chapter 10 Stage 4 driver. The

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 11, Stage 3: migrate byte counters to counter(9).
*
* Builds on Stage 2 by replacing sc->bytes_read and sc->bytes_written,

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 11, Stage 5: KASSERTs throughout, ready for a debug kernel.
*
* Builds on Chapter 11 Stage 3 (counter(9) migration) by adding KASSERT

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* lat_tester.c: measure read latency against /dev/myfirst and print
* a simple bucketed histogram. Useful for observing the cost of
* the driver's mutex under various load conditions.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* mp_stress.c: a multi-process stress tester for /dev/myfirst.
*
* Forks NWRITERS writer children and NREADERS reader children.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* mt_reader.c: multiple threads reading from one descriptor of
* /dev/myfirst. Exercises the driver's handling of multiple
* concurrent readers on the same fh.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 12, Stage 1: condition variables replace anonymous channels.
*
* Builds on Chapter 11 Stage 5 (counter9 + KASSERTs). Replaces the

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 12, Stage 2: bounded reads via cv_timedwait_sig.
*
* Builds on Chapter 12 Stage 1 (cv channels) by adding two new sysctls:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 12, Stage 3: sx-protected configuration subsystem.
*
* Builds on Stage 2 (bounded reads) by adding a runtime configuration

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 12, Stage 4: the final synchronized driver.
*
* Combines all of Chapter 12: cv channels (Stage 1), bounded reads

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* config_writer.c: stress the Chapter 12 driver's configuration
* sysctls by toggling debug_level and soft_byte_limit at high
* frequency for a configurable duration.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* timeout_tester.c: verify that the Chapter 12 driver's bounded
* read returns EAGAIN after approximately the configured timeout
* when no data is available.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 13, Stage 1: heartbeat callout only.
*
* Builds on Chapter 12 Stage 4 by adding one callout:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 13, Stage 2: heartbeat + watchdog callouts.
*
* Builds on Stage 1 by adding the watchdog callout:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 13, Stage 3: heartbeat + watchdog + tick source.
*
* Builds on Stage 2 by adding the tick source callout:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 13, Stage 4: the final timer-enhanced driver.
*
* Builds on Chapter 12 Stage 4 by adding three callouts:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* poll_waiter.c: a trivial poll(2) client for /dev/myfirst.
*
* Compile with:

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 14, Stage 1: the first task.
*
* Starts from Chapter 13 Stage 4 and adds one task, enqueued from the

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 14, Stage 2: the private taskqueue.
*
* Builds on Chapter 14 Stage 1 by creating a private taskqueue

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 14, Stage 3: deliberate coalescing and a delayed reset.
*
* Builds on Stage 2 by adding bulk_writer_task (to demonstrate

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.h: a fixed-size byte-oriented circular buffer for the
* Chapter 10 myfirst driver.
*

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Chapter 14, Stage 4: the final taskqueue-enhanced driver.
*
* Builds on Chapter 13 Stage 4 by adding a private taskqueue and three

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* signal_read: start a blocking read on /dev/myfirst, receive a
* signal after a delay, report how many bytes were delivered before
* the signal interrupted the read.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* writer_cap_test: start N concurrent writers that open /dev/myfirst
* and write a short burst. Used to stress the writer-cap semaphore
* introduced in Chapter 15 Stage 1.

View file

@ -1,8 +1,8 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
/*
* Copyright (c) 2026 Edson Brandi
*
* SPDX-License-Identifier: BSD-2-Clause
*
* cbuf.c: kernel-side implementation of the byte-oriented circular
* buffer for the Chapter 10 myfirst driver.
*

Some files were not shown because too many files have changed in this diff Show more