mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
Move lua/moon to genode-world
Issue genodelabs/genode-world#282 Fixes #4414
This commit is contained in:
committed by
Norman Feske
parent
76dde9d0ec
commit
a9b8b6e6c2
@@ -1 +0,0 @@
|
|||||||
INC_DIR += $(call select_from_ports,lua)/include/lua
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
INC_DIR += $(call select_from_ports,lua)/include/lua
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
LUA_DIR := $(call select_from_ports,lua)/src/lib/lua/src
|
|
||||||
LIBS += libc libm
|
|
||||||
INC_DIR += $(LUA_DIR)
|
|
||||||
CC_DEF = -DLUA_ANSI -DLUA_USE_MKSTEMP
|
|
||||||
|
|
||||||
# core objects
|
|
||||||
LUA_CORE_C = lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c \
|
|
||||||
lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c \
|
|
||||||
lundump.c lvm.c lzio.c
|
|
||||||
|
|
||||||
# library objects, e.g. string handling
|
|
||||||
LUA_LIB_C = lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c ltablib.c \
|
|
||||||
lstrlib.c loadlib.c linit.c
|
|
||||||
|
|
||||||
vpath %.c $(LUA_DIR)
|
|
||||||
|
|
||||||
# vi: set ft=make :
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# Lua library (ANSI C variant)
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(REP_DIR)/lib/mk/lua.inc
|
|
||||||
|
|
||||||
SRC_C = $(LUA_CORE_C) $(LUA_LIB_C)
|
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#
|
|
||||||
# Lua library (C++ variant)
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(REP_DIR)/lib/mk/lua.inc
|
|
||||||
|
|
||||||
SRC_C = $(LUA_CORE_C) $(LUA_LIB_C)
|
|
||||||
|
|
||||||
# force compilation with C++ compiler
|
|
||||||
CUSTOM_CC = $(CXX)
|
|
||||||
CC_WARN += -Wno-sign-compare
|
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
db8c61d08efef779e25ed3339b11f8230af43ccd
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
LICENSE := MIT
|
|
||||||
VERSION := 5.1.5
|
|
||||||
DOWNLOADS := lua.archive
|
|
||||||
|
|
||||||
URL(lua) := http://www.lua.org/ftp/lua-$(VERSION).tar.gz
|
|
||||||
SHA(lua) := 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333
|
|
||||||
DIR(lua) := src/lib/lua
|
|
||||||
|
|
||||||
DIRS := include/lua
|
|
||||||
DIR_CONTENT(include/lua) := $(addprefix src/lib/lua/src/,\
|
|
||||||
lua.h lauxlib.h luaconf.h lualib.h)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
if {[get_cmd_switch --autopilot] && [have_board riscv_qemu]} {
|
|
||||||
puts "Autopilot mode is not supported on this platform."
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Lua C++ library test
|
|
||||||
#
|
|
||||||
|
|
||||||
build "core init timer test/moon"
|
|
||||||
|
|
||||||
create_boot_directory
|
|
||||||
|
|
||||||
install_config {
|
|
||||||
<config>
|
|
||||||
<parent-provides>
|
|
||||||
<service name="PD"/>
|
|
||||||
<service name="ROM"/>
|
|
||||||
<service name="LOG"/>
|
|
||||||
<service name="IO_PORT"/>
|
|
||||||
<service name="IO_MEM"/>
|
|
||||||
<service name="IRQ"/>
|
|
||||||
<service name="CPU"/>
|
|
||||||
</parent-provides>
|
|
||||||
<default-route>
|
|
||||||
<any-service> <parent/> <any-child/> </any-service>
|
|
||||||
</default-route>
|
|
||||||
<default caps="100"/>
|
|
||||||
<start name="timer">
|
|
||||||
<resource name="RAM" quantum="1M"/>
|
|
||||||
<provides> <service name="Timer"/> </provides>
|
|
||||||
</start>
|
|
||||||
<start name="test-moon">
|
|
||||||
<resource name="RAM" quantum="1G"/>
|
|
||||||
<config>
|
|
||||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
|
||||||
<libc stdout="/dev/log"/>
|
|
||||||
</config>
|
|
||||||
</start>
|
|
||||||
</config>
|
|
||||||
}
|
|
||||||
|
|
||||||
build_boot_image {
|
|
||||||
core init timer test-moon
|
|
||||||
ld.lib.so libc.lib.so vfs.lib.so libm.lib.so
|
|
||||||
}
|
|
||||||
|
|
||||||
append qemu_args " -nographic "
|
|
||||||
|
|
||||||
run_genode_until {.*test-moon.*Finished\..*} 40
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
TARGET = test-lua
|
|
||||||
LIBS = lua libc libm
|
|
||||||
SRC_CC = main.cc
|
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)/..
|
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
TARGET = test-luacxx
|
|
||||||
LIBS = luacxx libc libm
|
|
||||||
SRC_CC = main.cc
|
|
||||||
|
|
||||||
vpath main.cc $(PRG_DIR)/..
|
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Lua C++ library test
|
|
||||||
* \author Christian Helmuth
|
|
||||||
* \date 2012-05-06
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2012-2017 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU Affero General Public License version 3.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Genode includes */
|
|
||||||
#include <base/log.h>
|
|
||||||
#include <libc/component.h>
|
|
||||||
#include <timer_session/connection.h>
|
|
||||||
|
|
||||||
/* Lua includes */
|
|
||||||
#include <lua.h>
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Moon {
|
|
||||||
|
|
||||||
struct Main;
|
|
||||||
struct Env
|
|
||||||
{
|
|
||||||
Timer::Session &timer;
|
|
||||||
Genode::Pd_session &pd;
|
|
||||||
};
|
|
||||||
Env *env;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lua: Sleep for milliseconds
|
|
||||||
*/
|
|
||||||
static int l_msleep(lua_State *lua)
|
|
||||||
{
|
|
||||||
if (lua_gettop(lua) != 1) {
|
|
||||||
lua_pushstring(lua, "msleep: invalid number of arguments");
|
|
||||||
lua_error(lua);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
luaL_checknumber(lua, 1);
|
|
||||||
|
|
||||||
Moon::env->timer.msleep(lua_tonumber(lua, 1));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lua: Return RAM quota
|
|
||||||
*/
|
|
||||||
static int l_quota(lua_State *lua)
|
|
||||||
{
|
|
||||||
if ((lua_gettop(lua) != 0)) {
|
|
||||||
lua_pushstring(lua, "quota: invalid number of arguments");
|
|
||||||
lua_error(lua);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_pushnumber(lua, Moon::env->pd.ram_quota().value);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lua: Log arguments
|
|
||||||
*/
|
|
||||||
static int l_log(lua_State *lua)
|
|
||||||
{
|
|
||||||
int n = lua_gettop(lua);
|
|
||||||
|
|
||||||
for (int i = 1; i <= n; ++i) {
|
|
||||||
if (lua_isstring(lua, i))
|
|
||||||
Genode::log(lua_tostring(lua, i));
|
|
||||||
else if (lua_isnil(lua, i))
|
|
||||||
Genode::log("nil");
|
|
||||||
else if (lua_isboolean(lua, i))
|
|
||||||
Genode::log(lua_toboolean(lua, i) ? "true" : "false");
|
|
||||||
else
|
|
||||||
Genode::log(luaL_typename(lua, i), ": ", lua_topointer(lua, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lua library for Genode functions
|
|
||||||
*/
|
|
||||||
static const struct luaL_reg l_genode[] = {
|
|
||||||
{ "log", l_log },
|
|
||||||
{ "msleep", l_msleep },
|
|
||||||
{ "quota", l_quota },
|
|
||||||
{ 0, 0 } /* end of list */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static char const *exec_string =
|
|
||||||
"local a = { }\n"
|
|
||||||
"Genode.log(a)\n"
|
|
||||||
"a.foo = \"foo\"\n"
|
|
||||||
"a.bar = \"bar\"\n"
|
|
||||||
"Genode.log(a.foo .. \" \" .. a.bar)\n"
|
|
||||||
"\n"
|
|
||||||
"print(\"Our RAM quota is \"..Genode.quota()..\" bytes.\")\n"
|
|
||||||
"\n"
|
|
||||||
"print(\"Going to sleep...\")\n"
|
|
||||||
"for i=1,4 do\n"
|
|
||||||
" Genode.msleep(i * 1000)\n"
|
|
||||||
" print(\"Slept well for \"..i..\" seconds.\")\n"
|
|
||||||
"end\n"
|
|
||||||
"print(\"Finished.\")\n"
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
struct Moon::Main
|
|
||||||
{
|
|
||||||
Libc::Env &_env;
|
|
||||||
|
|
||||||
Timer::Connection _timer { _env };
|
|
||||||
|
|
||||||
Moon::Env _moon_env { _timer, _env.pd() };
|
|
||||||
|
|
||||||
Main(Libc::Env &env) : _env(env)
|
|
||||||
{
|
|
||||||
Libc::with_libc([&] () {
|
|
||||||
Moon::env = &_moon_env;
|
|
||||||
|
|
||||||
lua_State *lua = lua_open();
|
|
||||||
|
|
||||||
/* initialize libs */
|
|
||||||
luaopen_base(lua);
|
|
||||||
|
|
||||||
/* register Genode Lua library */
|
|
||||||
luaL_register(lua, "Genode", l_genode);
|
|
||||||
|
|
||||||
if (luaL_dostring(lua, exec_string) != 0)
|
|
||||||
Genode::log(lua_tostring(lua, -1));
|
|
||||||
|
|
||||||
lua_close(lua);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void Libc::Component::construct(Libc::Env &env) { static Moon::Main instance(env); }
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
TARGET = test-moon
|
|
||||||
LIBS = luacxx libc base
|
|
||||||
SRC_CC = main.cc
|
|
||||||
|
|
||||||
CC_CXX_WARN_STRICT =
|
|
||||||
@@ -30,7 +30,6 @@ lx_hybrid_exception
|
|||||||
lx_hybrid_pthread_ipc
|
lx_hybrid_pthread_ipc
|
||||||
microcode
|
microcode
|
||||||
migrate
|
migrate
|
||||||
moon
|
|
||||||
netperf_lwip
|
netperf_lwip
|
||||||
netperf_lwip_bridge
|
netperf_lwip_bridge
|
||||||
netperf_lwip_usb
|
netperf_lwip_usb
|
||||||
|
|||||||
Reference in New Issue
Block a user