Skip to content

Commit f797cb7

Browse files
committed
[GSoC WIP] liblua: ACPICA Lua bindings
GSoC WIP under @bsdimp Description: Lua bindings for ACPICA in loader. Currently working on AcpiEvaluateObject. Future interface work involves: AcpiWalkNamespace and callback functions AcpiAttachData/DetachData Sponsored by: Google Summer of Code 2025 Signed-off-by: Kayla Powell (AKA Kat) <kpowkitty@FreeBSD.org>
1 parent 458ac2b commit f797cb7

File tree

7 files changed

+509
-0
lines changed

7 files changed

+509
-0
lines changed

stand/efi/loader/Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,65 @@ SRCS= autoload.c \
3030
gfx_fb.c \
3131
8x16.c
3232

33+
# ACPICA Loader Initialization
34+
SRCS+= acpi_detect.c
35+
36+
.if ${MACHINE_ARCH} == "amd64"
37+
SRCS+= OsdMemory.c osunixxf.c
38+
39+
.PATH: ${.CURDIR}/../acpica/amd64/Osd/
40+
.PATH: ${.CURDIR}/../contrib/dev/acpica/os_specific/service_layers
41+
42+
CFLAGS+= -DACPI_SINGLE_THREADED \
43+
-DACPI_USE_NATIVE_RSDP_POINTER \
44+
-DACPI_USE_NATIVE_MEMORY_MAPPING \
45+
-DACPI_REDUCED_HARDWARE \
46+
-DACPI_EXCLUDE \
47+
-DACPI_DEBUG_OUTPUT
48+
49+
SRCS+= libefi.c utinit.c utglobal.c utresrc.c utlock.c utownerid.c \
50+
utcopy.c uthex.c utmath.c utstrsuppt.c utstrtoul64.c utpredef.c \
51+
uterror.c uteval.c utids.c utbuffer.c utmisc.c utalloc.c utxferror.c \
52+
utexcep.c utaddress.c utascii.c utcache.c utcksum.c utdebug.c \
53+
utdecode.c utdelete.c utmutex.c utobject.c utosi.c utstring.c \
54+
utxfinit.c utnonansi.c utstate.c tbxfload.c tbdata.c tbfadt.c \
55+
tbinstal.c tbprint.c tbutils.c tbxface.c tbxfroot.c tbfind.c \
56+
nsxfobj.c nsxfeval.c nsinit.c nsparse.c nsload.c nsrepair2.c \
57+
nsconvert.c nsrepair.c nsprepkg.c nsarguments.c nseval.c nsxfname.c \
58+
nsdump.c nswalk.c nssearch.c nsnames.c nsutils.c nsaccess.c nsalloc.c \
59+
nsobject.c nspredef.c dsinit.c dsfield.c dspkginit.c dsopcode.c \
60+
dsdebug.c dsmethod.c dscontrol.c dsobject.c dsutils.c dswexec.c \
61+
dswload2.c dswload.c dsmthdat.c dswstate.c dsargs.c dswscope.c \
62+
exregion.c exfldio.c exserial.c exstorob.c exstoren.c exdebug.c \
63+
exmutex.c exconcat.c exmisc.c exconfig.c excreate.c exoparg6.c \
64+
exoparg3.c exoparg2.c exoparg1.c exdump.c exprep.c exresop.c \
65+
exsystem.c exnames.c exresolv.c exstore.c exfield.c exconvrt.c \
66+
exresnte.c exutils.c extrace.c hwpci.c hwregs.c hwxface.c hwvalid.c \
67+
hwacpi.c evmisc.c evregion.c evrgnini.c evxface.c evevent.c evxfevnt.c \
68+
evhandler.c evxfregn.c psobject.c psloop.c pstree.c pswalk.c psopinfo.c \
69+
psscope.c psutils.c psargs.c psparse.c psxface.c psopcode.c init_acpi.c
70+
71+
# lua
72+
.PATH: ${.CURDIR}/../../liblua/acpi
73+
SRCS+= lacpi.c
74+
CFLAGS+= -I${.CURDIR}/../../liblua/acpi
75+
.endif
76+
77+
.PATH: ${.CURDIR}/../libefi
78+
.PATH: ${.CURDIR}/../acpica
79+
.PATH: ${.CURDIR}/../contrib/dev/acpica/components/utilities
80+
.PATH: ${.CURDIR}/../contrib/dev/acpica/components/hardware
81+
.PATH: ${.CURDIR}/../contrib/dev/acpica/components/events
82+
.PATH: ${SYSDIR}/contrib/dev/acpica/os_specific/service_layers
83+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/tables
84+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/namespace
85+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/utilities
86+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/dispatcher
87+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/executer
88+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/hardware
89+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/events
90+
.PATH: ${SYSDIR}/contrib/dev/acpica/components/parser
91+
3392
CFLAGS+= -I${.CURDIR}/../loader
3493
.if ${MK_LOADER_ZFS} != "no"
3594
CFLAGS+= -I${ZFSSRC}

stand/liblua/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ SRCS+= lfs.c
2929
.PATH: ${FLUALIB}/libhash
3030
SRCS+= lhash.c
3131

32+
# ACPI
33+
.PATH: ${LIBLUASRC}/acpi ${EFISRC}/acpica
34+
SRCS+= lacpi_object.c init_acpi.c
35+
CFLAGS+= -I${LIBLUASRC}/acpi -I${EFISRC}/acpica/include -I${SYSDIR}/contrib/dev/acpica/include
36+
3237
WARNS?= 3
3338

3439
CFLAGS+= -DLUA_PATH=\"${LUAPATH}\" -DLUA_PATH_DEFAULT=\"${LUAPATH}/\?.lua\"

stand/liblua/acpi/lacpi.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include <lua.h>
4+
#include <sys/linker_set.h>
5+
6+
#include <contrib/dev/acpica/include/acpi.h>
7+
8+
typedef int (*lua_module_init_fn)(lua_State *L);
9+
10+
struct lua_acpi_module {
11+
const char *mod_name;
12+
lua_module_init_fn init;
13+
};
14+
15+
SET_DECLARE(lua_acpi_modules, struct lua_acpi_module);
16+
17+
#define LUA_ACPI_COMPILE_SET(name, initfn) \
18+
static struct lua_acpi_module lua_##name = \
19+
{ \
20+
.mod_name = #name, \
21+
.init = initfn \
22+
}; \
23+
DATA_SET(lua_acpi_modules, lua_##name)
24+
25+
extern struct lacpi_handle {
26+
const char* pathname;
27+
ACPI_HANDLE handle;
28+
};

stand/liblua/acpi/lacpi_factory.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <lua.h>
2+
#include <lauxlib.h>
3+
#include <lualib.h>
4+
5+
int
6+
lacpi_create_mt_gc(lua_State *L, const char *mt, lua_CFunction gc_func)
7+
{
8+
if (luaL_newmetatable(L, mt)) {
9+
lua_pushcfunction(L, gc_func);
10+
lua_setfield(L, -2, "__gc");
11+
12+
lua_pushvalue(L, -1);
13+
lua_setfield(L, -2, "__index");
14+
}
15+
16+
return 1;
17+
}

stand/liblua/acpi/lacpi_factory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
int lacpi_create_mt_gc(lua_State *L, const char *mt, lua_CFunction gc_func);

0 commit comments

Comments
 (0)