Porting the script to the kernel is a cool thing, Lua has been ported to the kernel of NetBSD, there is a project called Lunatik to the Linux kernel, but only to support x86, not support arm, search on the internet, did not find ready, so I researched the next, Now share it.
Ported to arm platform, mainly to re-implement SETJMP and longjmp two functions, the online related information is very few, finally found a KLIBC project, there is setmp and longjmp arm platform implementation, so directly to use, needless to say, It is exciting to see the script execute in the kernel and print out "Hello,world". Here is the method used, the specific code can go to the following location to download:
Https://github.com/negtise/luak-arm
1, download the code first, download it and put the Lunatik directory inside the Lib directory.
2. Configure the kernel:
2.1 Modify Lib/kconfig, add the following configuration
Config Lunatik
TriState "Enable Lunatik Lua Engine"
Default Y
Help
Enables the Lunatik LUA engine which allows execution of LUA code
2.2 Configuring LUA to generate KO files
Perform:
Make Arch=arm Menuconfig
And then:
Config Lunatik to compile as Module
Library Routines--->
<M> Enable Lunatik Lua Engine
3. Compiling:
Make Arch=arm cross_compile=arm-linux-gnueabi-modules Subdirs=lib/lunatik
Will generate a Luak.ko
4. Commissioning:
Execute the following command:
Cat/proc/kmsg &
echo 9 >/PROC/SYS/KERNEL/PRINTK
Insmod Luak.ko
echo "Print (' Hello,world ')" >/sys/class/lunak/eval
If one is OK, it will output:
Hello,world
This is done from the kernel.
5. How do I extend the functionality?
You can view the code in the Bindings directory.
How to migrate Lua to the Linux kernel on the arm platform