
How the Kernel Returns Errors and How errno Gets Set
The kernel returns -errno in the result register, and the C library turns values from -4095 to -1 into errno and a return of -1. See the raw path and the rules.
Everything you need to level up your coding skills.

The kernel returns -errno in the result register, and the C library turns values from -4095 to -1 into errno and a return of -1. See the raw path and the rules.

Follow a FreeRTOS context switch on Cortex-M4F from the yield request to the PendSV handler, and see which registers hardware stacks and which software saves.

Run a program under strace, read each line as name, arguments and result, then filter, follow child processes and write the trace to a file to find real faults.

A system call is the controlled jump from a user program into the kernel. See how write() becomes a syscall instruction, a number in rax and a return value.

Replace hand-written register accessors with regmap: one config for I2C or SPI, read and write, update_bits, caching and a debugfs register dump on Linux 6.12.

Build a complete I2C client driver for a TMP102-style sensor on Linux 6.12: id tables, probe, SMBus reads, a sysfs attribute, device tree node and test output.

Write a RISC-V machine-mode trap handler in assembly: set mtvec, save registers, decode mcause, advance mepc past ecall and return with mret.

Turn on the Raspberry Pi I2C and SPI buses with dtparam lines in config.txt or raspi-config, confirm the device nodes appear, and change bus speeds.

Move a NASM boot sector into 32-bit protected mode, set up a flat GDT and a stack, then call a freestanding C function that writes to VGA text memory.

Expose an SPI device as /dev/spidevB.C, set mode, speed and word size with ioctl, and run full-duplex transfers with SPI_IOC_MESSAGE in a small C program.

Choose between legacy BIOS and UEFI for a hobby OS by comparing the CPU mode at entry, boot media, memory map, graphics and tooling, with a decision table.

Load i2c-dev, scan a bus with i2cdetect, read and write registers with i2cget and i2cset, and do the same in C through /dev/i2c-N and ioctl on Linux.
We send one email when a new post is published. No spam.