Created
January 25, 2025 01:12
-
-
Save genbtc/c465fb74d3fe5beef9d0ada4d2251a10 to your computer and use it in GitHub Desktop.
/tmp/fadt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import logging | |
import os | |
import struct | |
def BIT(num): | |
"""Returns a bit shifted by num""" | |
return 1 << num | |
def check_fadt(): | |
"""Check the kernel emitted a message specific to 6.0 or later indicating FADT had a bit set.""" | |
found = False | |
# try to look at FACP directly if not found (older kernel compat) | |
if not found: | |
logging.debug("Fetching low power idle bit directly from FADT") | |
target = os.path.join("/", "sys", "firmware", "acpi", "tables", "FACP") | |
try: | |
with open(target, "rb") as r: | |
r.seek(0x70) | |
found = struct.unpack("<I", r.read(4))[0] & BIT(21) | |
except PermissionError: | |
print_color("FADT check unavailable", colors.WARNING) | |
return True | |
if found: | |
message = "ACPI FADT supports Low-power S0 idle" | |
print(message, "✅") | |
else: | |
message = "ACPI FADT doesn't support Low-power S0 idle" | |
print(message, "❌") | |
return found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment