Remove nit_log
This commit is contained in:
parent
60f597431a
commit
8537b8f139
|
@ -1,14 +0,0 @@
|
|||
include_rules
|
||||
|
||||
PKGS = vfs genode-gems genode-os genode-base genode-prg
|
||||
|
||||
: foreach *.cc |> $(CC) `pkg-config --cflags $(PKGS)` -c %f -o %o |> %B.o {objs}
|
||||
: {objs} |> $(LD) `pkg-config --libs $(PKGS)` %f -o %o |> %d {binary}
|
||||
|
||||
: {binary} |> !strip_to_depot |>
|
||||
|
||||
: archives | {binary} |> !archives_to_depot |> {package}
|
||||
: runtime | {binary} |> !runtime_to_depot |> {package}
|
||||
|
||||
: |> !publish_bin |>
|
||||
: |> !publish_pkg |>
|
|
@ -1,2 +0,0 @@
|
|||
@SDK_USER@/src/vfs/@SDK_VERSION@
|
||||
@DEPOT_USER@/src/nit_log/@DEPOT_VERSION@
|
|
@ -1,166 +0,0 @@
|
|||
|
||||
#include "session_requests.h"
|
||||
|
||||
/* gems includes */
|
||||
#include <gems/vfs.h>
|
||||
#include <gems/vfs_font.h>
|
||||
|
||||
/* Genode includes */
|
||||
#include <nitpicker_session/connection.h>
|
||||
#include <framebuffer_session/connection.h>
|
||||
#include <base/component.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/log.h>
|
||||
#include <base/heap.h>
|
||||
#include <os/pixel_rgb565.h>
|
||||
#include <os/surface.h>
|
||||
#include <nitpicker_gfx/tff_font.h>
|
||||
#include <nitpicker_gfx/box_painter.h>
|
||||
#include <log_session/connection.h>
|
||||
#include <root/component.h>
|
||||
#include <base/component.h>
|
||||
#include <base/session_label.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/log.h>
|
||||
#include <util/list.h>
|
||||
|
||||
|
||||
namespace Nit_log {
|
||||
using namespace Genode;
|
||||
typedef Surface_base::Point Point;
|
||||
typedef Surface_base::Area Area;
|
||||
typedef Surface_base::Rect Rect;
|
||||
|
||||
struct Canvas;
|
||||
class Session_component;
|
||||
struct Main;
|
||||
|
||||
typedef Genode::Id_space<Session_component> Session_space;
|
||||
}
|
||||
|
||||
|
||||
struct Nit_log::Canvas
|
||||
{
|
||||
Genode::Env &_env;
|
||||
|
||||
Heap _heap { _env.ram(), _env.rm() };
|
||||
|
||||
Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
Root_directory _root { _env, _heap, _config.xml().sub_node("vfs") };
|
||||
|
||||
Vfs_font _font { _heap, _root, "fonts/text/regular" };
|
||||
|
||||
Nitpicker::Connection _nitpicker { _env };
|
||||
Framebuffer::Session &_fb { *_nitpicker.framebuffer() };
|
||||
|
||||
Dataspace_capability _fb_ds_cap()
|
||||
{
|
||||
_nitpicker.buffer(_nitpicker.mode(), false);
|
||||
return _fb.dataspace();
|
||||
}
|
||||
|
||||
Attached_dataspace _fb_ds { _env.rm(), _fb_ds_cap() };
|
||||
|
||||
Nitpicker::Session::View_handle _view { _nitpicker.create_view() };
|
||||
|
||||
typedef Pixel_rgb565 PT;
|
||||
|
||||
Surface_base::Area _size { (unsigned)_fb.mode().width() >> 2,
|
||||
(unsigned)_fb.mode().height() >> 2 };
|
||||
|
||||
Surface<PT> _surface { _fb_ds.local_addr<PT>(), _size };
|
||||
|
||||
void _refresh() { _fb.refresh(0, 0, _size.w(), _size.h()); }
|
||||
|
||||
Canvas(Genode::Env &env) : _env(env)
|
||||
{
|
||||
_nitpicker.enqueue<Nitpicker::Session::Command::Geometry>(
|
||||
_view, Rect(Point(0, 0), _size));
|
||||
|
||||
_nitpicker.enqueue<Nitpicker::Session::Command::To_front>(
|
||||
_view, Nitpicker::Session::View_handle());
|
||||
_nitpicker.execute();
|
||||
|
||||
_surface.clip(Rect(Point(0, 0), _size));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Nit_log::Session_component final : public Rpc_object<Log_session>
|
||||
{
|
||||
private:
|
||||
|
||||
Session_space::Element _sessions_elem;
|
||||
Session_label const _label;
|
||||
|
||||
public:
|
||||
|
||||
Session_component(Session_space &space,
|
||||
Session_space::Id id,
|
||||
Session_label const &label)
|
||||
:
|
||||
_sessions_elem(*this, space, id),
|
||||
_label(label)
|
||||
{
|
||||
}
|
||||
|
||||
size_t write(Log_session::String const &msg) override
|
||||
{
|
||||
log(msg.string());
|
||||
return msg.size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct Nit_log::Main final : Session_request_handler
|
||||
{
|
||||
Genode::Env &_env;
|
||||
|
||||
Canvas _canvas { _env };
|
||||
|
||||
Sliced_heap _session_heap { _env.pd(), _env.rm() };
|
||||
|
||||
Session_space _sessions { };
|
||||
|
||||
Session_requests_rom session_requests { _env, *this };
|
||||
|
||||
Main(Genode::Env &env) : _env(env) { }
|
||||
|
||||
void handle_session_create(Session_state::Name const &name,
|
||||
Parent::Server::Id pid,
|
||||
Session_state::Args const &args) override
|
||||
{
|
||||
if (name != "LOG") throw Service_denied();
|
||||
|
||||
Session_space::Id const id { pid.value };
|
||||
Session_label const label = label_from_args(args.string());
|
||||
|
||||
Session_component *session = new (_session_heap)
|
||||
Session_component(_sessions, id, label);
|
||||
|
||||
_env.parent().deliver_session_cap(pid, _env.ep().manage(*session));
|
||||
}
|
||||
|
||||
void handle_session_upgrade(Parent::Server::Id,
|
||||
Session_state::Args const &) override
|
||||
{ }
|
||||
|
||||
void handle_session_close(Parent::Server::Id pid) override
|
||||
{
|
||||
Session_space::Id id { pid.value };
|
||||
_sessions.apply<Session_component&>(
|
||||
id, [&] (Session_component &session)
|
||||
{
|
||||
_env.ep().dissolve(session);
|
||||
destroy(_session_heap, &session);
|
||||
_env.parent().session_response(pid, Parent::SESSION_CLOSED);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Component::construct(Genode::Env &env)
|
||||
{
|
||||
static Nit_log::Main inst(env);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<runtime ram="8M" caps="128" binary="nit_log">
|
||||
|
||||
<requires>
|
||||
<file_system label="fonts"/>
|
||||
<nitpicker/>
|
||||
</requires>
|
||||
|
||||
<provides> <log/> </provides>
|
||||
|
||||
<content>
|
||||
<rom label="nit_log"/>
|
||||
<rom label="libc.lib.so"/>
|
||||
<rom label="libm.lib.so"/>
|
||||
<rom label="vfs.lib.so"/>
|
||||
</content>
|
||||
|
||||
<config>
|
||||
<vfs>
|
||||
<dir name="fonts">
|
||||
<fs label="fonts"/>
|
||||
</dir>
|
||||
</vfs>
|
||||
</config>
|
||||
|
||||
</runtime>
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* \brief Utilities for handling the 'session_requests' ROM
|
||||
* \author Emery Hemingway
|
||||
* \date 2018-04-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
|
||||
#ifndef __SESSION_REQUESTS_H_
|
||||
#define __SESSION_REQUESTS_H_
|
||||
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/session_state.h>
|
||||
#include <base/component.h>
|
||||
|
||||
namespace Genode {
|
||||
struct Session_request_handler;
|
||||
class Session_requests_rom;
|
||||
};
|
||||
|
||||
|
||||
struct Genode::Session_request_handler : Interface
|
||||
{
|
||||
virtual void handle_session_create(Session_state::Name const &,
|
||||
Parent::Server::Id,
|
||||
Session_state::Args const &) = 0;
|
||||
virtual void handle_session_upgrade(Parent::Server::Id,
|
||||
Session_state::Args const &) { }
|
||||
virtual void handle_session_close(Parent::Server::Id) = 0;
|
||||
};
|
||||
|
||||
|
||||
class Genode::Session_requests_rom : public Signal_handler<Session_requests_rom>
|
||||
{
|
||||
private:
|
||||
|
||||
Parent &_parent;
|
||||
Session_request_handler &_requests_handler;
|
||||
|
||||
Attached_rom_dataspace _parent_rom;
|
||||
|
||||
void _process()
|
||||
{
|
||||
_parent_rom.update();
|
||||
Xml_node requests = _parent_rom.xml();
|
||||
|
||||
auto const create_fn = [&] (Xml_node request)
|
||||
{
|
||||
Parent::Server::Id const id {
|
||||
request.attribute_value("id", ~0UL) };
|
||||
|
||||
typedef Session_state::Name Name;
|
||||
typedef Session_state::Args Args;
|
||||
|
||||
Name name { };
|
||||
Args args { };
|
||||
|
||||
try {
|
||||
name = request.attribute_value("service", Name());
|
||||
args = request.sub_node("args").decoded_content<Args>();
|
||||
} catch (...) {
|
||||
Genode::error("failed to parse request ", request);
|
||||
return;
|
||||
}
|
||||
|
||||
try { _requests_handler.handle_session_create(name, id, args); }
|
||||
catch (Service_denied) {
|
||||
_parent.session_response(id, Parent::SERVICE_DENIED); }
|
||||
catch (Insufficient_ram_quota) {
|
||||
_parent.session_response(id, Parent::INSUFFICIENT_RAM_QUOTA); }
|
||||
catch (Insufficient_cap_quota) {
|
||||
_parent.session_response(id, Parent::INSUFFICIENT_CAP_QUOTA); }
|
||||
catch (...) {
|
||||
error("unhandled exception while creating session");
|
||||
_parent.session_response(id, Parent::SERVICE_DENIED);
|
||||
throw;
|
||||
}
|
||||
};
|
||||
|
||||
auto const upgrade_fn = [&] (Xml_node request)
|
||||
{
|
||||
Parent::Server::Id const id {
|
||||
request.attribute_value("id", ~0UL) };
|
||||
|
||||
typedef Session_state::Args Args;
|
||||
Args args { };
|
||||
try { args = request.sub_node("args").decoded_content<Args>(); }
|
||||
catch (...) {
|
||||
Genode::error("failed to parse request ", request);
|
||||
return;
|
||||
}
|
||||
|
||||
_requests_handler.handle_session_upgrade(id, args);
|
||||
};
|
||||
|
||||
auto const close_fn = [&] (Xml_node request)
|
||||
{
|
||||
Parent::Server::Id const id {
|
||||
request.attribute_value("id", ~0UL) };
|
||||
_requests_handler.handle_session_close(id);
|
||||
};
|
||||
|
||||
/* close sessions to free resources */
|
||||
requests.for_each_sub_node("close", close_fn);
|
||||
|
||||
/* service existing sessions */
|
||||
requests.for_each_sub_node("upgrade", upgrade_fn);
|
||||
|
||||
/* create new sessions */
|
||||
requests.for_each_sub_node("create", create_fn);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Session_requests_rom(Genode::Env &env,
|
||||
Session_request_handler &requests_handler)
|
||||
: Signal_handler<Session_requests_rom>(env.ep(), *this, &Session_requests_rom::_process),
|
||||
_parent(env.parent()),
|
||||
_requests_handler(requests_handler),
|
||||
_parent_rom(env, "session_requests")
|
||||
{
|
||||
_parent_rom.sigh(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a signal to this requests handler
|
||||
*/
|
||||
void schedule() {
|
||||
Signal_transmitter(*this).submit(); }
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue