Skip to content

Conversation

kpowkitty
Copy link
Contributor

@kpowkitty kpowkitty commented Aug 21, 2025

GSoC WIP under @bsdimp

Follows #1843 and #1818 in that order.

Description:
Lua bindings for ACPICA in loader to provide an interface for users to
print the ACPI namespace, attach/detach/get data off of device nodes,
and evaluate objects.

Please see man page commit for acpi.lua for more information

lacpi_object.c

Module for evaluating ACPI objects.
This module also provides the ability to convert pathnames into
their opaque pointer using get_handle.

lacpi_walk.c

Allows users to walk the namespace in the loader.
Currently works by walking the entire namespace and
storing each node in a 2D table of nodes.

Use case:
nodes = lacpi.walk.namespace()
for _, node in ipairs(nodes) do
print(node.path, node.lvl, node.hid, node.uid)
end

Future plans:
(1) better representation of nodes for the user when printed
(2) strategy patterns for how to receive the namespace

lacpi_data.c

Allows a user to post ACPI_OBJECTs onto namespace nodes.
See actypes.h for all possible ACPI_OBJECTs.

Sponsored by: Google Summer of Code 2025
Signed-off-by: Kayla Powell (AKA Kat) [email protected]

@kpowkitty kpowkitty requested a review from bsdimp as a code owner August 21, 2025 08:54
Copy link

github-actions bot commented Sep 5, 2025

Thank you for taking the time to contribute to FreeBSD!
There is an issue that needs to be fixed:

Please review CONTRIBUTING.md, then update and push your branch again.

kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
Description:
Continuation of freebsd#1819.

[WIP] Needs to be tested.
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
Description:
Continuation of freebsd#1819.

[WIP] Needs to be tested.
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
Description:
Continuation of freebsd#1819.

[WIP] Needs to be tested.
@kpowkitty kpowkitty force-pushed the lacpi_clean branch 5 times, most recently from 1f67a35 to 2452892 Compare September 25, 2025 01:06
Description:
Refactored ACPICA for partial initialization in the loader.
This work is the final preface for Lua bindings.

Work on this commit involves:
Subset ACPICA for loader land:
For our Lua bindings, we need to be able to walk
the ACPI namespace and evaluate objects.
To do so, we need AcpiInitializeSubsystem, AcpiInitializeTables,
AcpiEnableSubsystem, and AcpiLoadTables.

Notes:
-acpi_detect() moved into libacpi.
-Libacpi conditionally compiles ACPICA and glue code on amd64.
(arm64 will be addressed in a future update)
-AcpiEnableSubsystem is initialized in reduced hardware mode,
but with events enabled. This is so that we do not need to pull
in all of ACPI_HARDWARE, but can evaluate objects.
-Stubbed out Osd functions required for this limited initialization.
-Conditionally exclude functions to make a minimal subset designed
around loader's/lua binding's needs:
--Exclude AcpiInitializeObjects, as we do not need this for walking
the namespace and evaluating objects. (utxfinit.c)
--Exclude notify handlers or fixed event handlers. (evxface.c)
--Stub out print functions, as the loader does not have standard
output. (osunixxf.c)
--Stub out AcpiOsSleep and AcpiOsGetTimer, as the loader is not
multi-threaded and does not implement timers. (osunixxf.c)
These bindings have two conditions:
(1) Must be built on `amd64`
(2) Must be building `loader_lua`

If these conditions are met:
- Add liblua as a subdir in EFI
- Include liblua/acpi/include in loader/Makefile
- Add set_lua_acpi_modules to the loader compile set
- Add 'lacpi.h' to loader/main.c and reference the bindings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants