kboot: Add our own lua bindings

Create a small wrapper around the new flua hash module so we can use it
here too. There's no 4th bindings, nor will they be created.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43874
This commit is contained in:
Warner Losh 2024-02-15 20:54:55 -07:00
parent f7781d030c
commit e34fd722ca
5 changed files with 31 additions and 1 deletions

View File

@ -62,6 +62,7 @@ BINDIR?= /boot
# LUAPATH is where we search for and install lua scripts.
LUAPATH?= /boot/lua
FLUASRC?= ${SRCTOP}/libexec/flua
FLUALIB?= ${SRCTOP}/lib/flua
LIBSA= ${BOOTOBJ}/libsa/libsa.a
.if ${MACHINE} == "i386"

View File

@ -33,7 +33,7 @@ VERSION_FILE= ${.CURDIR}/../loader/version
#
# will tell you how many kiB of lomem are available.
#
LOADERSIZE?= 550000 # Largest known safe size for loader.bin
LOADERSIZE?= 570000 # Largest known safe size for loader.bin
.PATH: ${BOOTSRC}/i386/loader

View File

@ -60,4 +60,11 @@ CFLAGS+= -Wall
DPADD= ${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT}
LDADD= ${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT}
# Add our own lua bindings until they are universal
.if ${LOADER_INTERP} == "lua"
SRCS+= \
lua_bindings.c
CFLAGS.lua_bindings.c+= -I${FLUALIB}/libhash
.endif
.include <bsd.prog.mk>

View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2024 Netflix, Inc.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "lua.h"
#include "lauxlib.h"
#include "lutils.h"
#include "lhash.h"
static void
lua_hash_bindings(lua_State *L)
{
luaL_requiref(L, "hash", luaopen_hash, 1);
lua_pop(L, 1); /* Remove lib */
}
LUA_COMPILE_SET(lua_hash_bindings);

View File

@ -27,6 +27,8 @@ SRCS+= gfx_utils.c
.PATH: ${FLUASRC}/modules
SRCS+= lfs.c
.PATH: ${FLUALIB}/libhash
SRCS+= lhash.c
WARNS?= 3
@ -36,6 +38,7 @@ CFLAGS+= -fno-stack-protector -D__BSD_VISIBLE
CFLAGS+= -I${BOOTSRC}/include -I${LIBLUASRC} -I${LUASRC} -I${LDRSRC}
CFLAGS.gfx_utils.c+= -I${SRCTOP}/sys/teken -I${SRCTOP}/contrib/pnglite
CFLAGS.lhash.c+= -I${FLUALIB}/libhash -I${SRCTOP}/sys/crypto/sha2
.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0
CFLAGS+= -fPIC