|
| 1 | +# Google Summer of Code 2025 @ FreeBSD |
| 2 | +Mentor: Warner Losh @bsdimp <[email protected]> |
| 3 | +Student: Kayla (Kat) Powell @kpowkitty <[email protected]> |
| 4 | +--------------- |
| 5 | +## ACPI Initialization in Loader with Lua Bindings |
| 6 | +Intel's Advanced Configuration and Power Interface (ACPI) brought power management out of the BIOS |
| 7 | +and into the operating system. We can make it even more powerful by creating an interface |
| 8 | +to script it. Currently, the scripting language of choice in FreeBSD (rather than POSIX `sh`, `bash`, or `awk`) |
| 9 | +is Lua. Therefore, this project aims to initialize a portion of ACPI in the FreeBSD bootloader, with respect |
| 10 | +to its storage, memory, and stdlib constraints, so we can enumerate and evaluate objects on the device trees to |
| 11 | +provide an interface to Lua. |
| 12 | + |
| 13 | +## Milestones |
| 14 | +[x] `OsdMemory.c` for `amd64` (`arm64` postponed) |
| 15 | +[x] `AcpiInitializeSubsystem` |
| 16 | +[x] `AcpiInitializeTables` |
| 17 | +[x] `AcpiEnableSubsystem` in reduced hardware mode, with events enabled |
| 18 | +[x] `AcpiLoadTables` |
| 19 | +[x] `AcpiWalkNamespace` |
| 20 | +[x] `AcpiEvaluateObject` |
| 21 | +[x] ACPICA initialized in loader for `amd64` |
| 22 | +[ ] Enumerate the ACPI Namespace into human-readable API layer |
| 23 | +[ ] Lua API functionality for evaluating objects |
| 24 | +[ ] Demonstration Lua scripts & man page/handbook update |
| 25 | + |
| 26 | +**Future goals of this project include arm64 compat.** |
| 27 | + |
| 28 | +### For more information, please consult these resources: |
| 29 | +[ACPI Lua Bindings FreeBSD project wiki page](https://wiki.freebsd.org/SummerOfCode2025Projects/ACPI%20Initialization%20in%20Loader%20With%20Lua%20Bindings) |
| 30 | +[Write-up](https://kmpow.com/content/gsoc-writeup) |
| 31 | + |
| 32 | +--------------- |
| 33 | + |
| 34 | +## Building |
| 35 | +This project requires an amd64 UEFI FreeBSD system. |
| 36 | + |
| 37 | +The current working version of this project is found on branch `acpi_init`. |
| 38 | + |
| 39 | +1. Clone the repo & change branches |
| 40 | +``` |
| 41 | +$ git clone [email protected]:kpowkitty/freebsd-src.git |
| 42 | +$ git checkout acpi_init |
| 43 | +``` |
| 44 | + |
| 45 | +2. Build the necessary dependencies |
| 46 | +``` |
| 47 | +$ cd stand |
| 48 | +$ make libsa |
| 49 | +$ make liblua |
| 50 | +$ cd efi |
| 51 | +$ make libefi |
| 52 | +``` |
| 53 | + |
| 54 | +3. Build the loader (`-j max_jobs`, where `max_jobs` specifies the number of jobs that `make` can run when you call it) |
| 55 | +``` |
| 56 | +$ cd loader |
| 57 | +$ make -j max_jobs |
| 58 | +``` |
| 59 | + |
| 60 | +4. Install the `loader.efi` image |
| 61 | +``` |
| 62 | +# make install |
| 63 | +# cp /boot/loader.efi /boot/path/to/your/loader.efi |
| 64 | +``` |
| 65 | + |
| 66 | +5. Reboot |
| 67 | +``` |
| 68 | +# shutdown -r now |
| 69 | +``` |
| 70 | + |
| 71 | +At this point, when your system restarts, ACPI has gone through the initialization |
| 72 | +sequence in the loader. If using QEMU, one can redirect serial output to a file and |
| 73 | +see "Successful initialization of ACPI" message if built correctly. |
| 74 | +The next leg of this project will be using this initialization of ACPI to walk the |
| 75 | +namespace and enumerate its objects into an API layer for Lua. |
| 76 | + |
| 77 | +## System Recovery |
| 78 | +In general cases, to recover your system, you need to mount your drive |
| 79 | +on a live iso and replace your drive's `loader.efi` with the live iso image's `loader.efi`. |
0 commit comments