| 
 | 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 | +[ ] lacpi_object.c  [ IN REVIEW #1819 ]    | 
 | 23 | +[ ] lacpi_data.c    [ IN PROGRESS ]    | 
 | 24 | +[ ] lacpi_walk.c    [ NOT STARTED ]    | 
 | 25 | +[ ] Demonstration Lua scripts & man page/handbook update    | 
 | 26 | + | 
 | 27 | +**Future goals of this project include arm64 compat.**  | 
 | 28 | + | 
 | 29 | +### For more information, please consult these resources:  | 
 | 30 | +[ACPI Lua Bindings FreeBSD project wiki page](https://wiki.freebsd.org/SummerOfCode2025Projects/ACPI%20Initialization%20in%20Loader%20With%20Lua%20Bindings)    | 
 | 31 | +[Write-up](https://kmpow.com/content/gsoc-writeup)  | 
 | 32 | + | 
 | 33 | +---------------  | 
 | 34 | + | 
 | 35 | +## Building  | 
 | 36 | +This project requires an amd64 UEFI FreeBSD system.  | 
 | 37 | + | 
 | 38 | +The current working version of this project is found on branch `acpi_init`.  | 
 | 39 | + | 
 | 40 | +1. Clone the repo & change branches    | 
 | 41 | +```  | 
 | 42 | +$ git clone [email protected]:kpowkitty/freebsd-src.git  | 
 | 43 | +$ git checkout acpi_init  | 
 | 44 | +```  | 
 | 45 | + | 
 | 46 | +2. Build the necessary dependencies  | 
 | 47 | +```  | 
 | 48 | +$ cd stand  | 
 | 49 | +$ make libsa  | 
 | 50 | +$ make liblua  | 
 | 51 | +$ cd efi  | 
 | 52 | +$ make libefi  | 
 | 53 | +```  | 
 | 54 | + | 
 | 55 | +3. Build the loader (`-j max_jobs`, where `max_jobs` specifies the number of jobs that `make` can run when you call it)  | 
 | 56 | +```  | 
 | 57 | +$ cd loader  | 
 | 58 | +$ make -j max_jobs  | 
 | 59 | +```  | 
 | 60 | + | 
 | 61 | +4. Install the `loader.efi` image  | 
 | 62 | +```  | 
 | 63 | +# make install  | 
 | 64 | +# cp /boot/loader.efi /boot/path/to/your/loader.efi  | 
 | 65 | +```  | 
 | 66 | + | 
 | 67 | +5. Reboot  | 
 | 68 | +```  | 
 | 69 | +# shutdown -r now  | 
 | 70 | +```  | 
 | 71 | + | 
 | 72 | +At this point, when your system restarts, ACPI has gone through the initialization  | 
 | 73 | +sequence in the loader.     | 
 | 74 | + | 
 | 75 | +The next leg of this project is using this initialization of ACPI to walk the   | 
 | 76 | +namespace and enumerate its objects into an API layer for Lua.  | 
 | 77 | + | 
 | 78 | +## System Recovery  | 
 | 79 | +In general cases, to recover your system, you need to mount your drive   | 
 | 80 | +on a live iso and replace your drive's `loader.efi` with the live iso image's `loader.efi`.   | 
0 commit comments