mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-11 13:22:33 +00:00
parent
44e5f1c2d4
commit
f96b5b89f2
repos
gems/src/server/terminal_mux
libports/src/test
os/src/test
@ -13,12 +13,12 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <libc/component.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
#include <base/session_label.h>
|
||||
#include <libc/component.h>
|
||||
#include <libc/allocator.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <root/component.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
/* terminal includes */
|
||||
@ -349,7 +349,7 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
|
||||
* RAM costs significantly, which would break all connections to this
|
||||
* server.
|
||||
*/
|
||||
Genode::Heap _heap { _env.ram(), _env.rm() };
|
||||
Genode::Allocator &_heap;
|
||||
|
||||
protected:
|
||||
|
||||
@ -371,14 +371,15 @@ class Terminal::Root_component : public Genode::Root_component<Session_component
|
||||
* Constructor
|
||||
*/
|
||||
Root_component(Genode::Env &env,
|
||||
Genode::Allocator &md_alloc,
|
||||
Genode::Allocator &heap,
|
||||
Ncurses &ncurses,
|
||||
Session_manager &session_manager)
|
||||
:
|
||||
Genode::Root_component<Session_component>(env.ep(), md_alloc),
|
||||
Genode::Root_component<Session_component>(env.ep(), heap),
|
||||
_env(env),
|
||||
_ncurses(ncurses),
|
||||
_session_manager(session_manager)
|
||||
_session_manager(session_manager),
|
||||
_heap(heap)
|
||||
{ }
|
||||
};
|
||||
|
||||
@ -664,17 +665,17 @@ struct Main
|
||||
{
|
||||
Genode::Env &env;
|
||||
|
||||
Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
|
||||
Libc::Allocator heap;
|
||||
|
||||
Registry registry;
|
||||
Ncurses ncurses;
|
||||
Ncurses ncurses { heap };
|
||||
Status_window status_window { ncurses };
|
||||
Menu menu { ncurses, registry, status_window };
|
||||
|
||||
User_input user_input { ncurses };
|
||||
Session_manager session_manager { ncurses, registry, status_window, menu };
|
||||
|
||||
Terminal::Root_component root { env, sliced_heap, ncurses, session_manager };
|
||||
Terminal::Root_component root { env, heap, ncurses, session_manager };
|
||||
|
||||
Timer::Connection timer { env };
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/log.h>
|
||||
#include <base/env.h>
|
||||
#include <base/allocator.h>
|
||||
|
||||
/* libc and ncurses includes */
|
||||
#include <ncurses.h>
|
||||
@ -68,13 +68,13 @@ void Ncurses::Window::horizontal_line(int line)
|
||||
|
||||
Ncurses::Window *Ncurses::create_window(int x, int y, int w, int h)
|
||||
{
|
||||
return new (Genode::env()->heap()) Ncurses::Window(x, y, w, h);
|
||||
return new (_alloc) Ncurses::Window(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
void Ncurses::destroy_window(Ncurses::Window *window)
|
||||
{
|
||||
Genode::destroy(Genode::env()->heap(), window);
|
||||
Genode::destroy(_alloc, window);
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ int Ncurses::read_character()
|
||||
}
|
||||
|
||||
|
||||
Ncurses::Ncurses()
|
||||
Ncurses::Ncurses(Genode::Allocator &alloc) : _alloc(alloc)
|
||||
{
|
||||
/*
|
||||
* Redirect stdio to terminal
|
||||
|
@ -7,10 +7,14 @@
|
||||
#ifndef _NCURSES_CXX_H_
|
||||
#define _NCURSES_CXX_H_
|
||||
|
||||
namespace Genode { class Allocator; }
|
||||
|
||||
class Ncurses
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Allocator &_alloc;
|
||||
|
||||
unsigned _columns;
|
||||
unsigned _lines;
|
||||
|
||||
@ -52,7 +56,7 @@ class Ncurses
|
||||
|
||||
void do_update();
|
||||
|
||||
Ncurses();
|
||||
Ncurses(Genode::Allocator &);
|
||||
|
||||
void cursor_visible(bool);
|
||||
|
||||
|
@ -157,10 +157,11 @@ void test_dynamic_cast_call(Object_base *o)
|
||||
b->func();
|
||||
}
|
||||
|
||||
static void test_dynamic_cast()
|
||||
static void test_dynamic_cast(Genode::Allocator &heap)
|
||||
{
|
||||
Object *o = new (Genode::env()->heap()) Object;
|
||||
Object *o = new (heap) Object;
|
||||
test_dynamic_cast_call(o);
|
||||
destroy(heap, o);
|
||||
}
|
||||
|
||||
|
||||
@ -222,7 +223,7 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
printf("Catch exceptions in program\n");
|
||||
printf("---------------------------\n");
|
||||
printf("exception in remote procedure call:\n");
|
||||
try { Rom_connection rom("unknown_file"); }
|
||||
try { Rom_connection rom(env, "unknown_file"); }
|
||||
catch (Rom_connection::Rom_connection_failed) { printf("caught\n"); }
|
||||
|
||||
printf("exception in program: ");
|
||||
@ -250,7 +251,7 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
|
||||
printf("Dynamic cast\n");
|
||||
printf("------------\n");
|
||||
test_dynamic_cast();
|
||||
test_dynamic_cast(heap);
|
||||
printf("\n");
|
||||
|
||||
printf("Shared-object API\n");
|
||||
|
@ -12,8 +12,8 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
#include <base/log.h>
|
||||
#include <libc/component.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
/* Lua includes */
|
||||
@ -22,11 +22,15 @@
|
||||
#include <lauxlib.h>
|
||||
|
||||
|
||||
static Timer::Session & timer_session()
|
||||
{
|
||||
static Timer::Connection timer;
|
||||
namespace Moon {
|
||||
|
||||
return timer;
|
||||
struct Main;
|
||||
struct Env
|
||||
{
|
||||
Timer::Session &timer;
|
||||
Genode::Ram_session &ram;
|
||||
};
|
||||
Env *env;
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +46,7 @@ static int l_msleep(lua_State *lua)
|
||||
}
|
||||
luaL_checknumber(lua, 1);
|
||||
|
||||
timer_session().msleep(lua_tonumber(lua, 1));
|
||||
Moon::env->timer.msleep(lua_tonumber(lua, 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -59,7 +63,7 @@ static int l_quota(lua_State *lua)
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_pushnumber(lua, Genode::env()->ram_session()->quota());
|
||||
lua_pushnumber(lua, Moon::env->ram.quota());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -116,18 +120,32 @@ static char const *exec_string =
|
||||
;
|
||||
|
||||
|
||||
int main()
|
||||
struct Moon::Main
|
||||
{
|
||||
lua_State *lua = lua_open();
|
||||
Libc::Env &_env;
|
||||
|
||||
/* initialize libs */
|
||||
luaopen_base(lua);
|
||||
Timer::Connection _timer { _env };
|
||||
|
||||
/* register Genode Lua library */
|
||||
luaL_register(lua, "Genode", l_genode);
|
||||
Moon::Env _moon_env { _timer, _env.ram() };
|
||||
|
||||
if (luaL_dostring(lua, exec_string) != 0)
|
||||
Genode::log(lua_tostring(lua, -1));
|
||||
Main(Libc::Env &env) : _env(env)
|
||||
{
|
||||
Moon::env = &_moon_env;
|
||||
|
||||
lua_close(lua);
|
||||
}
|
||||
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,3 +1,3 @@
|
||||
TARGET = test-moon
|
||||
LIBS = luacxx posix
|
||||
LIBS = luacxx libc
|
||||
SRC_CC = main.cc
|
||||
|
@ -211,7 +211,8 @@ struct Faulting_loader_grand_child_test
|
||||
|
||||
/* import config into loader session */
|
||||
{
|
||||
Attached_dataspace ds(loader->alloc_rom_module("config", config_size()));
|
||||
Attached_dataspace ds(env.rm(),
|
||||
loader->alloc_rom_module("config", config_size()));
|
||||
memcpy(ds.local_addr<char>(), config(), config_size());
|
||||
loader->commit_rom_module("config");
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
/* Genode includes */
|
||||
#include <base/component.h>
|
||||
#include <base/log.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <framebuffer_session/connection.h>
|
||||
#include <base/attached_dataspace.h>
|
||||
#include <util/reconstructible.h>
|
||||
@ -38,8 +37,10 @@ class Test_environment
|
||||
|
||||
enum State { STRIPES, ALL_BLUE, ALL_GREEN, ALL_RED, COLORED };
|
||||
|
||||
Framebuffer::Connection _fb;
|
||||
Genode::Env &_env;
|
||||
|
||||
Framebuffer::Mode _mode;
|
||||
Framebuffer::Connection _fb { _env, _mode };
|
||||
Ds _fb_ds;
|
||||
Genode::Signal_handler<Test_environment> _mode_sigh;
|
||||
Genode::Signal_handler<Test_environment> _sync_sigh;
|
||||
@ -61,9 +62,11 @@ class Test_environment
|
||||
|
||||
public:
|
||||
|
||||
Test_environment(Genode::Entrypoint &ep)
|
||||
: _mode_sigh(ep, *this, &Test_environment::_mode_handle),
|
||||
_sync_sigh(ep, *this, &Test_environment::_sync_handle)
|
||||
Test_environment(Genode::Env &env)
|
||||
:
|
||||
_env(env),
|
||||
_mode_sigh(_env.ep(), *this, &Test_environment::_mode_handle),
|
||||
_sync_sigh(_env.ep(), *this, &Test_environment::_sync_handle)
|
||||
{
|
||||
_fb.mode_sigh(_mode_sigh);
|
||||
_fb.sync_sigh(_sync_sigh);
|
||||
@ -137,7 +140,7 @@ void Test_environment::_mode_handle()
|
||||
if (_fb_ds.is_constructed())
|
||||
_fb_ds.destruct();
|
||||
|
||||
_fb_ds.construct(_fb.dataspace());
|
||||
_fb_ds.construct(_env.rm(), _fb.dataspace());
|
||||
|
||||
Genode::log("framebuffer is ", _mode);
|
||||
|
||||
@ -152,8 +155,6 @@ void Test_environment::_mode_handle()
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
Genode::log("--- Test framebuffer ---\n");
|
||||
static Test_environment te(env.ep());
|
||||
Genode::log("--- Test framebuffer ---");
|
||||
static Test_environment te(env);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user