From c8ee04268800a5b14dd565032dc969d7a2f621cc Mon Sep 17 00:00:00 2001 From: Gerwin Klein Date: Fri, 4 Jul 2025 12:45:09 +1000 Subject: [PATCH] manual/README.md: include API doc generation Migrate documentation of the API docs generation process here from the docsite where it is too much out of view. Here it is closer to where it is needed an more likely to get updated when things change. Compared to the docsite version, this has applied: - standard wrap column - markdown lints - adjusted headings - `object-api-sel4-arch.xml` etc renames - include RISC-V in structure Signed-off-by: Gerwin Klein --- manual/README.md | 191 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 3 deletions(-) diff --git a/manual/README.md b/manual/README.md index 01241c057..cc89b32c1 100644 --- a/manual/README.md +++ b/manual/README.md @@ -4,14 +4,199 @@ SPDX-License-Identifier: CC-BY-SA-4.0 --> -seL4 Reference Manual -===================== +# seL4 Reference Manual + +## Build To build a PDF use make -You will need recent version of `LaTeX` and `doxygen`. +You will need recent version of `LaTeX` and `doxygen` as well as the seL4 python +dependencies. The main source file is `manual.tex`, most of the text is in `parts/`, and most of the API reference is generated with `doxygen`. + +## API Generation + +The documentation of the seL4 API is automatically generated from +comments in the source code. This section documents the process. + +### Types of API + +seL4 has two types of API, system calls and object invocations. + +- Top-level system calls are generally for message passing, for example `Call`, + `Send`, and `Recv`. In addition there are also debugging and benchmarking + system calls which can be enabled with a build flag. +- Object invocations are regular message-passing system calls, usually `Call`, + where the recipient is effectively the kernel itself and the message encodes + some operation on a kernel object. Some examples are `TCB_Resume` and + `CNode_Copy`. Some kernel objects and object invocations are specific to a + particular processor architecture, for instance `X86_Page_Map`, and + `ARM_VCPU_InjectIrq`. + +Almost all system calls, including `Call`, `Send`, and `Recv`, are in fact +object invocations under the hood, for instance on endpoint or notification +objects -- they just provide a top-level API for message passing. The only +"true" system calls are `Yield`, debug and benchmark operations. + +The API documentation in the manual is divided into the following hierarchy: + +- System Calls + - General System Calls + - Debugging System Calls + - Benchmarking System Calls +- Architecture-Independent Object Methods +- x86-Specific Object Methods + - General x86 Object Methods + - IA32 Object Methods + - x86_64 Object Methods +- ARM-Specific Object Methods + - General ARM Object Methods + - aarch32 Object Methods + - aarch64 Object Methods +- RISC-V-Specific Object Methods + +The process of generating API docs is different between System Calls and Object +Invocations, though each process has some parts in common. + +### Common + +#### Approach + +Documentation for each seL4 API is written in the form of doxygen comments in C +header files. The rest of the seL4 manual is written in LaTeX. To generate API +documentation for the manual, we generate LaTeX files from doxygen comments +which are then included in the manual. + +Rather than using doxygen's LaTeX output directly, we use doxygen to generate +XML files. A custom script then parses the XML and produces the final LaTeX +output. This is because we already have an established style for API +documentation in our manual, and it was easier to generate LaTeX in this style +ourselves from some simple (ie. easy to parse) intermediate format (ie. XML) +rather than try to coerce doxygen into generating perfectly-styled LaTeX. + +The script that translates doxygen-generated xml into LaTeX is in: +[manual/tools/parse_doxygen_xml.py](https://github.com/seL4/seL4/blob/master/manual/tools/parse_doxygen_xml.py). + +#### Custom Notation in Doxygen Comments + +Some parts of the API documentation reference other parts of the manual. +Additionally, there are some custom formatting rules we'd like to apply to the +API docs in the manual that aren't understood by doxygen. To achieve both these +goals, we introduce some additional XML tags which we explicitly add to doxygen +comments inside @xmlonly ... @endxmlonly blocks. + +Here's a description of all the custom tags: + +```xml + + + + + + + + + + + + + + + + + +``` + +Note that these must appear within `@xmlonly` ... `@endxmlonly` blocks in +order to function. + +#### Required Documentation + +Each function in the API must have the following documentation: + +- a `@xmlonly