ACPI Initialization in Loader with Lua Bindings

Project Description

Intel™’s Advanced Configuration and Power Interface (ACPI) is an industry standard specification that revolutionized power management in computers by putting it in the hands of the operating system, rather than the BIOS. As it currently stands, it is widely available across 32-bit and 64-bit architectures, with specially tailored manuals towards Windows™ and UNIX™.

FreeBSD has implemented ACPI, utilizing Intel™’s ACPI Computer Architecture (ACPICA). To make it more manipulable, the goal of this project is to enumerate the ACPI namespace into Lua bindings. But, in order to have that, the namespace needs to be initialized in the loader, before the kernel. Therefore, the first major milestone of this project is to refactor ACPI’s initialization routines into the loader. The finality of this project is to have the ACPI namespace enumerated into a human readable api layer in Lua.

While the major benefit of this project is the scriptability of ACPI, the loader will benefit in other ways, such as reduced ACPI guesswork. Future goals of this project are to continue fleshing out ACPI branches into Lua until it is as scriptable as possible.

Approach to Solving the Problem

DESIGN CONTINGENCIES

Loader should remain as lightweight as possible

SOLUTION:

Supply the loader with only the necessary ACPI initialization functions so we can:


ACPI is not required for all FreeBSD use cases, nor is it generic for all architectures

SOLUTION:

Conditional compilation with preprocessor macros will guide mapping memory tables per architecture:

ACPI will not be included in Simple or Forth


Lua Bindings

In order to script ACPI, we will need to pass the ACPI namespace to Lua.

SOLUTION:

Walk the ACPI namespace and generate Lua bindings with user-friendly API layer


ACPI INITIALIZATION FUNCTIONS

FINAL IMPLEMENTATION

C FUNCTIONS PUSHED TO LUA STACK

LUA BINDINGS AND WRAPPERS FOR TESTING/DEMONSTRATION

Deliverables

Milestones

Week 1: June 2nd - 6th

MILESTONE 1:

Week 3: June 16th - 20th

MILESTONE 2:

Week 5: June 30th - July 4th

MILESTONE 3:

Week 6: July 7th - 11th

MILESTONE 4:

Week 7: July 14th - 18th

GSOC MIDTERM EVALUATION: ACPI initialized in the loader

Week 9: Planned Absence for Plant Biology 2025

Week 10: Aug 4th - 8th

MILESTONE 5:

Week 11: Aug 11th - 15th

MILESTONE 6:

Week 13: Aug 25th - 29th

MILESTONE 7:

Week 14: Sept 1st - 5th

GSOC FINAL EVALUATION: ACPI Lua bindings

Test Plan

The first major milestone is getting ACPI initialized in the loader rather than the kernel. In order to do this, I will need to implement the necessary ACPI startup routines. sys/dev/acpica/acpi.c,where the current ACPI startup routines live, will be refactored for this purpose, and a useful reference. Once we have them in the loader, we need to test to confirm that the tables are (1) loaded and (2) accessible to the kernel later.

ACPI in Loader - Architecture Specific Testing

This will be piecemeal. I will implement ACPI initialization for each architecture, each on different branches. This way, I can test each implementation on each architecture with VMs. Also, when I go to integrate them together, I will know it is an integration problem.

Lua Routines

This battle will be getting the namespace enumerated into Lua table(s). AcpiWalkNamespace() allows traversing the ACPI namespace, whereby it can populate our table using a callback function.

Unit testing will confirm…

C

Lua

Regression testing will occur…

C

Lua

The Code

Code

github

Notes

Write-up

my blog

ACPI

acpi(4)

ACPI User Guide

ACPI Specification Overview

Using and Debugging FreeBSD ACPI

OSDev Wiki ACPICA

Linux’s ACPI Device Tree - Representation of ACPI Namespace

STYLE

style(9)

style.lua(9)

LUA

Calling C Functions in Lua

Lua Reference Manual


CategoryGsoc

SummerOfCode2025Projects/ACPI Initialization in Loader With Lua Bindings (last edited 2025-06-04T19:59:33+0000 by MuhammadSaheed)