feat: power down dGPUs on hybrid graphics laptops

This commit is contained in:
daniel committed 2026-10-01 13:09:26 +02:00
1 parent 7f12e1a150
commit 24f88ec4c6
23 files changed
+4325 -1130

No files matched your search

+66 -3
View File
@@ -31,6 +31,16 @@ namespace Hal {
ThermalZone,
PowerResource,
BufferField,
Event,
// A reference to a namespace node: what RefOf() yields, and what a
// name evaluates to when it names something that is not data (a
// device or power resource listed in a _PRx package, say).
Reference,
// A name inside a constant package, kept as written ("PG00",
// "\_SB.PCI0.PEG0") because its scope is only known to whoever
// reads the package. Interpreter::ResolveReference() turns it
// into a node.
NameRef,
};
// ============================================================================
@@ -63,7 +73,7 @@ namespace Hal {
static constexpr int InitialChildren = 8;
static constexpr int MaxStringLen = 64;
static constexpr int MaxBufferLen = 256;
static constexpr int MaxPackageElements = 32;
static constexpr int MaxPackageElements = 64;
static constexpr int MaxMethodArgs = 7;
static constexpr int MaxMethodLocals = 8;
@@ -102,10 +112,23 @@ namespace Hal {
uint32_t Length;
} Buffer;
// A package's constant form: its element bytes, left in the
// table they were declared in, and the declared element count. ACPI tables stay
// mapped for the life of the kernel, so pointing at them is
// both cheaper and free of the size cap a copy would carry --
// a GPIO community table runs well past MaxBufferLen.
struct {
const uint8_t* Data; // first element
uint32_t Length; // bytes of element encodings
uint32_t Count; // NumElements
} Package;
struct {
uint8_t ArgCount; // bits 0-2 of method flags
bool Serialized; // bit 3
uint32_t AmlOffset; // offset into DSDT AML where the method body starts
uint8_t Native; // NativeMethod; 0 = AML
const uint8_t* Table; // the table the body lives in
uint32_t AmlOffset; // offset into Table where the method body starts
uint32_t AmlLength; // length of the method body
} Method;
@@ -116,12 +139,33 @@ namespace Hal {
} Region;
struct {
uint32_t RegionNodeIndex; // index of the parent OperationRegion node
// Field / BankField: the OperationRegion node.
// IndexField: the index register field.
uint32_t RegionNodeIndex;
uint32_t BitOffset;
uint32_t BitLength;
uint8_t AccessType; // 0=Any, 1=Byte, 2=Word, 3=DWord, 4=QWord, 5=Buffer
uint8_t UpdateRule; // 0=Preserve, 1=WriteAsOnes, 2=WriteAsZeros
uint8_t Kind; // FieldKind
int32_t DataNodeIndex; // IndexField: the data register field
int32_t BankNodeIndex; // BankField: the bank select field
uint64_t BankValue; // BankField: value selecting this bank
} Field;
// CreateXxxField over a buffer. Source points at the object
// holding the buffer -- a namespace node's, or a local/arg slot
// of the method that created the field -- so reads and writes
// go through to it.
struct {
Object* Source;
uint32_t BitOffset;
uint32_t BitLength;
} BufferField;
struct {
int32_t Node;
} Reference;
struct {
uint8_t ProcId;
uint32_t PblkAddr;
@@ -132,6 +176,18 @@ namespace Hal {
Object() : Type(ObjectType::None), PkgIndex(-1), Integer(0) {}
};
enum class FieldKind : uint8_t {
Normal = 0,
Index = 1,
Bank = 2,
};
// Methods the OS provides rather than the firmware.
enum class NativeMethod : uint8_t {
None = 0,
Osi = 1, // \_OSI
};
// ============================================================================
// Package element store
@@ -155,6 +211,9 @@ namespace Hal {
// Rewind the transient ring. Called once per top-level evaluation.
void ResetTransient();
// True for an entry that outlives the evaluation that made it.
bool IsPersistent(int32_t index);
// Element access. Returns nullptr for an unknown entry or an
// out-of-range element.
Object* Element(int32_t index, int element);
@@ -219,6 +278,10 @@ namespace Hal {
// rebased onto a scope. Returns -1 if no scope contains it.
int32_t SearchUpward(const char* relative, int32_t scopeNodeIndex) const;
// Find the child of `parent` named `seg`; a short name is padded
// with '_' the way node names are stored. Returns -1 if absent.
int32_t FindChild(int32_t parentIndex, const char* seg) const;
// Get a node by index.
NamespaceNode* GetNode(int32_t index);
const NamespaceNode* GetNode(int32_t index) const;