Skip to content

Prequel: The Foundation

Cultivation Stage: Mortal Foundation Building Kernel Focus: C language (the kernel dialect), assembly language, and low-level fundamentals

Opening Words

The Great Dao has no form, yet it gives birth to heaven and earth. At the beginning of all things, the foundation comes first.

If a kernel cultivator cannot understand the mysteries of C, or grasp the fine grain of assembly, he is no different from a mortal holding a sword: the blade may be sharp, but an unsteady hand makes it useless.

This volume does not tell a story.

It explains principles.

But principles themselves can be the best kind of story.

Chapters in This Volume

ChapterTitleCore Topic
OriginThe Dao Gives Birth to OneThe seven foundations, and a consciousness in the chaos
1The Dao of PointersPointers, arrays, memory layout, stack and heap
2The Art of StructuresStructure alignment, bit fields, , linked lists
3Compiler Secret ArtsGCC extensions: , ,
4Registers and InstructionsRISC-V 64 assembly basics, registers, common instructions
5Inline Assembly syntax, constraints, and the fusion of C and assembly
6Bit Operations and AtomicsBit operations, CAS, , spinlock basics
7Barriers and Impermanence, memory barriers, compiler barriers, out-of-order execution
8The Dao of the Preprocessor#define, conditional compilation, variadic macros, token pasting
9Memory LayoutVirtual address space, stack and heap, kernel address space
10The Dao of ELFELF format, segments and sections, symbol tables, relocation
FinalFoundation UnifiedTen foundations become one, and the road begins

Why Read the Prequel

Kernel code is not ordinary C code. It is full of:

  • Invisible GCC extensions (__attribute__((packed)), , )
  • Assembly embedded inside C (asm volatile, system calls)
  • Techniques ordinary programmers almost never use (, , bit-field operations)
  • Precise control over hardware behavior (memory barriers, atomic operations, cache-line alignment)

These are the "spiritual energy" of the kernel world. Without them, reading kernel source is like reading a heavenly scripture with mortal eyes.

Kernel Sources Covered

  • - basic type definitions
  • - compiler macros and extensions
  • - kernel linked lists
  • - the macro
  • - memory barriers
  • arch/riscv/include/asm/ - RISC-V architecture-specific assembly

同道留言

0 条
尚无留言

Enlightenment of the kernel through cultivation