Thanks for wanting to contribute to the project. This document covers some requirements and overall style and conventions that should be followed. Please read it carefully before submitting contributions.
Every commit must be signed off by at least one (1) human contributor:
git commit -s
This adds a Signed-off-by: Your Name <your@email> trailer certifying that you wrote the
change (or otherwise have reviewed the commit and have the right to submit it) and agree
to contribute it under the project's license, per the Developer Certificate of Origin (the
DCO file in this repository - also at https://developercertificate.org).
AI-assisted contributions are allowed, subject to the following:
-
A human must be in the loop at all times. AI tools may assist, but a human contributor must drive the work, review and understand every generated change, and take full responsibility for it. Do not submit code you have not read and understood.
-
The assistance must be disclosed. Any commit produced with material AI help must carry an
Assisted-by:trailer using a format similar to the Linux kernel's AI coding assistant format:Assisted-by: AGENT_NAME:MODEL_VERSIONAGENT_NAMEis the AI tool or framework (e.g.Codex,Claude, ...).MODEL_VERSIONis the full model identifier, all lowercase, including any numeric, snapshot, or version suffix. Do not shorten it to the model family (e.g. usegpt-5-5, notgpt-5; useclaude-opus-4-8, notclaude-opus). -
Do not add
Co-authored-by:trailers for the AI assistant. TheAssisted-by:trailer already serves that purpose. -
The human contributor still signs off (see above).
Signed-off-by:is the human's certification of, and responsibility for, the change.Assisted-by:only records which tool helped. It does not replace the sign-off or the human review.
Unreviewed, bulk, or fully-automated submissions are not accepted.
For the bootloader proper, C11 with GNU extensions (AKA gnu11) and other common extensions
is used, where "common" means any extension that has been supported by both GCC and Clang
for a number of years (ideally 5 or more).
For build and host tools (i.e. C code under tools/ and host/), strictly conforming C99
with no extensions must be used.
- Use British spelling.
- No hard tabs. Spaces for indentation and alignment. 4-space per indentation level.
- Always avoid vertical alignment to minimise vertical blast radius on changes.
- Comments are sparse: explain a non-obvious why, never restate the what. Don't narrate; avoid useless comments.
- Stick to ASCII: avoid em-dashes and other non-ASCII characters in code, comments, commit messages, and documentation, unless the non-ASCII character is essential to the work.
- Do not add per-file license headers.
- Do not edit vendored/fetched/generated files (i.e. anything in
3RDPARTY.md, or not ingit ls-files). - As a catch-all, match the surrounding code: indentation, braces, naming, idiom. Mirror the conventions used by the file you edit.
The project follows a relatively standard C coding style. It boils down to:
-
Snake-case for most identifiers.
-
Uppercase snake-case for macros.
-
No pointless
typedefs, especially forstructs. Always use the fullstruct name var;declaration style for those. -
Right aligned pointers (i.e.
struct something *ptr). -
Same line curly braces for blocks, including for functions (i.e.
if (...) {,void func(void) {, ...). -
Same line closing block brace and else (i.e.
} else {). -
Blocks should always be used for
if,for,while,do, and similar. This means no blockless constructs such as:if (condition) func();
Instead, this should always be:
if (condition) { func(); }
-
For
switch/caseconstructs, the indentation should look like this:switch (variable) { case 'A': { func(); break; } case 'B': { other_func(); break; } default: { something_else(); break; } }
And, as shown, all cases should be curly braced blocks.
-
Never do things such as
if(),while(), ... - Always put a space between keywords (i.e. not functions/function pointers) and parentheses.
As with anything, there are always exceptions to these style rules, under given contexts.
- One logical change per commit. No "and" commits - split unrelated changes apart.
- Commit message: a
<area>: <imperative summary>subject. Most commits should be subject-only; add a body only when the change has a non-obvious rationale or detail that genuinely does not fit in the subject, and keep it brief. Try your best to keep both the subject and any body lines within 80-column terminals asgit logshows them (it indents the message by 4 spaces, so aim for roughly 72 columns and wrap the body accordingly). The<imperative summary>should begin with a uppercase letter, while<area>should be all lowercase.<area>is often the path to the{.c,.h}pair insidecommon/(e.g.lib/acpi:ordrivers/gop:), or sometimes more generic concepts such asbuild:ordocs:. Host tools usehost/<name>:, build-time tools usetools/<name>:, BIOS stage 1 usesstage1/{cd,hdd,pxe,decompressor,gdt}:, and for everything else just follow whatever established convention.