Skip to content

Conversation

kpowkitty
Copy link
Contributor

@kpowkitty kpowkitty commented Aug 21, 2025

GSoC WIP under @bsdimp

Description:

Refactored ACPICA for partial initialization in the loader.
This work is the preface for Lua bindings.

For our Lua bindings, we want to be able to walk the
ACPI namespace and evaluate objects. So, I've taken what
the kernel does in acpi_Startup() as a starting point,
and added the ACPI initialization for this. That includes
AcpiInitializeSubsystem, AcpiInitializeTables,
AcpiEnableSubsystem, and AcpiLoadTables. It is initialized
in reduced hardware mode with events enabled, to (1)
match what our Lua interface desires and (2) create a
smaller subset of ACPICA for the loader environment.

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)

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:30
@github-actions
Copy link

github-actions bot commented Aug 21, 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 kpowkitty changed the title [GSoC WIP] stand/efi: ACPICA in Loader [GSoC WIP] stand/efi: ACPICA initialization Aug 21, 2025
/* Initialize root tables. */
if (ACPI_FAILURE(status = acpi_Startup())) {
printf("ACPI: Startup failed with status %s\n", AcpiFormatException(status));
printf("ACPI: Try disabling either ACPI or apic support.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this advice needs to be tailored to the loader.
And suggests we want a way to disable looking for ACPI which might be its own can of worms.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to have method headers and minimal error message. Let me know if a more verbose error message is preferred.

@@ -0,0 +1,1526 @@
/******************************************************************************
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to snag this diff, github's tool is useless for review.

* because ACPICA is fully compatible with other ACPI implementations.
* Changing this will revert ACPICA (and machine ASL) to pre-OSI behavior.
*/
#ifndef _STANDALONE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this false for the loader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. So, when I first was building, I was consistently getting a null reference on the _OSI node when I was printing the ACPI namespace for debug in one of the ACPI routines. May be my own error. I did test that it compiles and runs without the interjected print statements, so I reverted this change. Let me know if we should keep it.

@kpowkitty kpowkitty force-pushed the acpi_init branch 6 times, most recently from 764e41e to 4c39c41 Compare September 6, 2025 22:36
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 7, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 8, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 9, 2025
@kpowkitty kpowkitty changed the title [GSoC WIP] stand/efi: ACPICA initialization [GSoC WIP] efi: create libacpi Sep 12, 2025
kpowkitty added a commit to kpowkitty/freebsd-src that referenced this pull request Sep 12, 2025
Module for evaluating ACPI objects.

Currently being tested.

This work follows freebsd#1818.
@kpowkitty kpowkitty force-pushed the acpi_init branch 3 times, most recently from f822fba to eb02ef3 Compare September 24, 2025 23:59
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)
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