summaryrefslogtreecommitdiff
path: root/acpi.c3l/acpi.c3
diff options
context:
space:
mode:
authorandromeda <andromeda@bsd.my.domain>2026-10-24 09:51:50 -0400
committerandromeda <andromeda@bsd.my.domain>2026-10-24 09:51:50 -0400
commit34d4c44cc60683c47ef31499791d27872fa358e7 (patch)
treec5a20bfd2e7e29792f32fa69bbe32a509ff0fd58 /acpi.c3l/acpi.c3
parenteb0f2cc6373393303c5a4cd83792dd79103b85de (diff)
add acpi.c3lHEADmaster
Diffstat (limited to 'acpi.c3l/acpi.c3')
-rw-r--r--acpi.c3l/acpi.c361
1 files changed, 61 insertions, 0 deletions
diff --git a/acpi.c3l/acpi.c3 b/acpi.c3l/acpi.c3
new file mode 100644
index 0000000..1842866
--- /dev/null
+++ b/acpi.c3l/acpi.c3
@@ -0,0 +1,61 @@
+/**
+ * Copyright (C) 2026 andromeda
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+**/
+
+module acpi;
+
+import c3os::util;
+
+extern fn int memcmp(void*, void*, usz);
+
+fn bool RootSystemDescriptionPointer.is_valid(&self)
+{
+ if (memcmp(&self.signature, "RSD PTR ", 8) != 0) return false;
+ if (self.revision != 2) return false;
+ char sum = 0;
+ for (int i = 0; i < 20; i++) sum += ((char*)self)[i];
+ if (sum != 0) return false;
+ for (int i = 0; i < RootSystemDescriptionPointer::size; i++) sum += ((char*)self)[i];
+ return (sum == 0);
+}
+
+fn bool ExtendedSystemDescriptionTable.is_valid(&self)
+{
+ if (memcmp(&self.signature, "XSDT", 4) != 0) return false;
+ if (self.revision != 1) return false;
+ char sum = 0;
+ for (uint i = 0; i < self.length; i++) sum += ((char*)self)[i];
+ if (sum != 0) return false;
+ return true;
+}
+
+fn bool DescriptionHeader.is_valid(&self)
+{
+ if (catch excuse = self.sig()) return false;
+ char sum = 0;
+ for (uint i = 0; i < self.length; i++) sum += ((char*)self)[i];
+ if (sum != 0) return false;
+ return true;
+}
+
+fn DescriptionHeaderSignature? DescriptionHeader.sig(&self)
+{
+ foreach (i, name : DescriptionHeaderSignature::names)
+ {
+ if (memcmp(name, &self.signature, 4) == 0) return (DescriptionHeaderSignature)i;
+ }
+ return INVALID_DESCRIPTION_HEADER~;
+}