Skip to content

Commit 5c16e1e

Browse files
committed
lacpi: Loader compilation
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
1 parent 3951472 commit 5c16e1e

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

stand/efi/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SUBDIR.${MK_LOADER_IA32}+= libefi32
77
SUBDIR.${MK_FDT}+= fdt
88
SUBDIR.yes+= libacpi
99
SUBDIR.${MK_LOADER_IA32}+= libacpi32
10+
SUBDIR.yes+= ../liblua
1011
SUBDIR.yes+= .WAIT
1112

1213
SUBDIR.yes+= boot1 gptboot
@@ -16,8 +17,4 @@ SUBDIR.${MK_LOADER_LUA}+= loader_lua
1617
SUBDIR.${MK_LOADER_IA32}+= loader_ia32
1718
SUBDIR.yes+= loader_simp
1819

19-
.if !defined(MK_FORTH) && !defined(MK_LOADER_IA32) && defined(MK_LOADER_LUA)
20-
SUBDIR.yes+= liblua
21-
.endif
22-
2320
.include <bsd.subdir.mk>

stand/efi/loader/Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ CFLAGS+= -DEFI
7272

7373
.if ${MACHINE} == "amd64" && ${DO32:U0} == 0
7474
CFLAGS+= -I${EFISRC}/libacpi/acpi/include
75+
CFLAGS+= -I${EFISRC}/../liblua/acpi/include
7576
.endif
7677

7778
.if defined(HAVE_FDT) && ${MK_FDT} != "no"
@@ -127,6 +128,20 @@ LDFLAGS+= -Wl,--threads=1
127128

128129
CLEANFILES+= ${LOADER}.efi
129130

131+
# ACPI Lua bindings compile set
132+
.if ${__arch} == "amd64" && ${DO32:U0} == 0 && ${LOADER} == "loader_lua"
133+
LACPI_COMPILE_SET= -j set_lua_acpi_modules
134+
.else
135+
LACPI_COMPILE_SET=
136+
.endif
137+
138+
# To protect ACPI init and lua bindings
139+
.if ${LOADER} == "loader_lua"
140+
CFLAGS+= -DLACPI=1
141+
.else
142+
CFLAGS+= -DLACPI=0
143+
.endif
144+
130145
${LOADER}.efi: ${PROG}
131146
@if ${NM} ${.ALLSRC} | grep ' U '; then \
132147
echo "Undefined symbols in ${.ALLSRC}"; \
@@ -137,6 +152,7 @@ ${LOADER}.efi: ${PROG}
137152
-j .dynamic -j .dynsym -j .rel.dyn \
138153
-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
139154
-j set_X${LOADER_INTERP}_compile_set \
155+
${LACPI_COMPILE_SET} \
140156
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
141157

142158
LIBEFI= ${BOOTOBJ}/efi/libefi/libefi.a
@@ -154,9 +170,4 @@ LDADD= ${LDR_INTERP} ${LIBEFI} ${LIBSAFDT} ${LIBEFI_FDT} ${LIBSA} \
154170
${LIBACPI}
155171
.endif
156172

157-
.if ${__arch} == "amd64" && ${DO32:U0} == 0
158-
DPADD+= ${LIBLUA}
159-
LDADD+= ${LIBLUA}
160-
.endif
161-
162173
.include <bsd.prog.mk>

stand/efi/loader/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#define ACPI_SYSTEM_XFACE
6969

7070
// If defined amd64 && loader_lua
71-
#if defined(__amd64__) && defined(MK_LOADER_LUA)
71+
#if defined(__amd64__) && LACPI
7272
#include <init_acpi.h>
7373
#include <lacpi.h>
7474
#else
@@ -1237,11 +1237,13 @@ main(int argc, CHAR16 *argv[])
12371237

12381238
devinit();
12391239

1240-
#if defined(__amd64__) && defined(MK_LOADER_LUA)
1240+
#if defined(__amd64__) && LACPI
12411241
/* Initialize ACPI Subsystem and Tables. */
12421242
if ((ret = init_acpi()) != 0) {
12431243
printf("Failed to initialize ACPI\n.");
12441244
}
1245+
1246+
lacpi_interp_ref();
12451247
#endif
12461248

12471249
/*

0 commit comments

Comments
 (0)