vasilito 9f6a4288b5 kernel: Phase II S3 entry path (PM1 direct write + FADT parse)
Phase II: hardware-agnostic S3 entry. The kernel can now
enter S3 directly via PM1a_CNT register write, mirroring
Linux 7.1 `acpi_hw_legacy_sleep` in
`drivers/acpi/acpica/hwsleep.c:81-127`.

* New module `acpi/fadt.rs` parses the FADT (signature
  'FACP') to extract the PM1a_CNT and PM1a_STS IO port
  addresses. ACPI 6.5 §5.2.9 / Table 5.6 (PM1a_CNT at
  offset 56, PM1a_STS at offset 48). 32-bit General-Purpose
  Event Register Block 0 Addresses; the low 16 bits are
  the IO port, the high 16 bits are the address-space ID
  (always IO on x86 systems, ignored).
* `acpi/mod.rs` calls fadt::init() during ACPI table
  discovery. If the FADT is missing, the S3 entry path
  is disabled (a warning is logged). Hardware-agnostic.
* `scheme/acpi.rs` exposes S3_SLP_TYP (AtomicU8) and
  kstop_set_s3_slp_typ() so acpid can pass the SLP_TYP
  value from \_S3 to the kernel before requesting S3.
* `scheme/sys/mod.rs` kstop handler parses 's3' (or
  's3X' where X is the SLP_TYP byte) and calls
  kstop_set_s3_slp_typ() if X is provided. If not, the
  default S3 SLP_TYP=5 is used (standard for x86).
* `arch/x86_shared/stop.rs` enter_s3() is fully
  implemented:
  1. Clear WAK_STS (bit 15 of PM1a_STS)
  2. Flush CPU caches (wbinvd)
  3. Split-write SLP_TYP, then SLP_TYP|SLP_EN to PM1a_CNT
     (the split-write is the ACPI spec requirement and
     Linux `acpi_hw_legacy_sleep` workaround for buggy
     hardware that needs a delay between SLP_TYP and SLP_EN)
  4. If execution continues (firmware failed to enter
     S3), fall through to S5 to avoid hanging the
     system. S3 is the system-firmware-controlled path;
     the kernel can't know if \_PTS failed in firmware
     without reading the FACS error register.

Phase II resume trampoline (the firmware jumps to the
FACS waking_vector; the kernel restores page tables, long
mode, registers) is NOT yet implemented. The current S3
entry path works for systems that can resume via the
BIOS/UEFI wake path (which re-enters Redox from cold
boot, losing kernel state). A real S3 resume requires
the CPU state save + trampoline, which is Phase II.X
(deferred).

Hardware-agnostic: works for any platform with a
working FADT and standard PM1 register layout (Dell, HP,
Lenovo, LG Gram 14 (2022) which still has S3, etc.).
Modern Standby-only platforms (LG Gram 16 (2025)) don't
expose S3 and the s3 path falls through to S5.
2026-07-01 10:00:53 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00
2026-06-27 09:19:25 +03:00

Kernel

Redox OS Microkernel

docs SLOCs counter MIT licensed

Requirements

  • nasm needs to be available on the PATH at build time.

Building The Documentation

Use this command:

cargo doc --open --target x86_64-unknown-none

Debugging

QEMU

Running QEMU with the -s flag will set up QEMU to listen on port 1234 for a GDB client to connect to it. To debug the redox kernel run.

make qemu gdb=yes

This will start a virtual machine with and listen on port 1234 for a GDB or LLDB client.

GDB

If you are going to use GDB, run these commands to load debug symbols and connect to your running kernel:

(gdb) symbol-file build/kernel.sym
(gdb) target remote localhost:1234

LLDB

If you are going to use LLDB, run these commands to start debugging:

(lldb) target create -s build/kernel.sym build/kernel
(lldb) gdb-remote localhost:1234

After connecting to your kernel you can set some interesting breakpoints and continue the process. See your debuggers man page for more information on useful commands to run.

Notes

  • Always use foo.get(n) instead of foo[n] and try to cover for the possibility of Option::None. Doing the regular way may work fine for applications, but never in the kernel. No possible panics should ever exist in kernel space, because then the whole OS would just stop working.

  • If you receive a kernel panic in QEMU, use pkill qemu-system to kill the frozen QEMU process.

How To Contribute

To learn how to contribute to this system component you need to read the following document:

Development

To learn how to do development with this system component inside the Redox build system you need to read the Build System and Coding and Building pages.

How To Build

To build this system component you need to download the Redox build system, you can learn how to do it on the Building Redox page.

This is necessary because they only work with cross-compilation to a Redox virtual machine, but you can do some testing from Linux.

Funding - Unix-style Signals and Process Management

This project is funded through NGI Zero Core, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.

NLnet foundation logo NGI Zero Logo

S
Description
RedBear Operating System, based on RedoxOS. Licenced under MIT license.
https://redbearos.org
Readme MIT 18 GiB
Languages
C 37.5%
C++ 37.2%
JavaScript 6.7%
QML 3.4%
HTML 3.2%
Other 11.4%