coreboot/payloads/libpayload/libc
Subrata Banik 893a2b008a libpayload: Add coreboot boot mode table
This commit adds a new coreboot table, CB_TAG_BOOT_MODE, to pass
platform boot mode information to the payload.

The new table defines flags for low-battery mode and off-mode charging,
which are essential for a payload to properly initialize the charger
driver.

The cb_parse_boot_mode function is added to read this information, and
the sysinfo_t structure is updated to store the parsed boot mode data.

This ensures that the payload can accurately determine the system's
power state at boot and payload operations are also in sync with the
boot firmware.

The following scenarios were tested and verified:

Scenario 1: Low-battery, no charger
 - coreboot detects the low-battery state and performs an immediate
   shutdown after displaying the low-battery splash screen.

Scenario 2: Low-battery, charger attached
 - coreboot detects the low-battery state but continues booting because
   a charger is present. The payload receives the low-battery
   information (using the same source as coreboot) and correctly
   initiates the charging process.

Scenario 3: Off-mode charging
 - The system boots directly from an S5 state due to a charger being
   plugged in. coreboot detects the off-mode state, skips the firmware
   splash screen, and hands off control to the payload, which then
   starts charging.

Scenario 4: Normal boot
 - The system boots without any low-battery or off-mode conditions.
   coreboot and the payload both detect a normal boot (using the same
   information), bypass charging initialization, and proceed to boot the
   operating system.

TEST=Able to build and boot on google/quenbi device and verify the boot
mode flag is correctly passed.

Change-Id: Iec25c6fdfcdc5ea7c397d2430ac7b545e1e068f2
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/89015
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-09-05 04:22:27 +00:00
..
args.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
console.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
coreboot.c libpayload: Add coreboot boot mode table 2025-09-05 04:22:27 +00:00
ctype.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
fmap.c libpayload: Remove legacy CBFS API 2024-02-22 21:18:39 +00:00
fpmath.c libpayload: Add simple 32.32 fixed-point math API 2020-07-09 00:32:11 +00:00
getopt_long.c commonlib: Change GCD function to always use 64 bits 2024-02-08 13:13:58 +00:00
hexdump.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
lib.c libpayload: Fix strsep() edge cases 2025-08-13 17:44:31 +00:00
libgcc.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
lp_vboot.c libpayload: Add vboot and reboot utility functions 2023-09-18 15:42:31 +00:00
Makefile.mk libpayload: Unify selfboot() implementations 2025-02-11 20:59:57 +00:00
malloc.c libpayload: Add dma_allocator_range() 2023-11-21 13:50:53 +00:00
memory.c libpayload: Use Kconfig for architecture memcpy, not weak symbols 2025-05-22 19:27:24 +00:00
printf.c libpayload: Fix clang fallthrough warning 2023-08-28 02:12:25 +00:00
qsort.c libpayload: Fix whitespace errors 2013-06-27 14:46:43 +02:00
rand.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
readline.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
selfboot.c libpayload: Unify selfboot() implementations 2025-02-11 20:59:57 +00:00
string.c libpayload: Fix strsep() edge cases 2025-08-13 17:44:31 +00:00
strlcpy.c libpayload: Implement strlcpy 2011-07-07 22:29:35 +02:00
sysinfo.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
time.c libpayload: Use Kconfig instead of weak symbol for arch_ndelay() 2025-05-22 19:27:30 +00:00