mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-30 10:38:55 +00:00
parent
6b94e65a95
commit
954aff7002
@ -152,25 +152,29 @@ class Launchpad_child : public Genode::Child_policy,
|
|||||||
Genode::Id_space<Genode::Parent::Server> &server_id_space() override {
|
Genode::Id_space<Genode::Parent::Server> &server_id_space() override {
|
||||||
return _session_requester.id_space(); }
|
return _session_requester.id_space(); }
|
||||||
|
|
||||||
Genode::Service &resolve_session_request(Genode::Service::Name const &service_name,
|
Genode::Child_policy::Route
|
||||||
Genode::Session_state::Args const &args) override
|
resolve_session_request(Genode::Service::Name const &service_name,
|
||||||
|
Genode::Session_label const &label) override
|
||||||
{
|
{
|
||||||
|
auto route = [&] (Genode::Service &service) {
|
||||||
|
return Genode::Child_policy::Route { .service = service,
|
||||||
|
.label = label,
|
||||||
|
.diag = Genode::Session::Diag() }; };
|
||||||
|
|
||||||
Genode::Service *service = nullptr;
|
Genode::Service *service = nullptr;
|
||||||
|
|
||||||
/* check for config file request */
|
/* check for config file request */
|
||||||
if ((service = _config_policy
|
if ((service = _config_policy.resolve_session_request_with_label(service_name, label)))
|
||||||
.resolve_session_request(service_name.string(), args.string())))
|
return route(*service);
|
||||||
return *service;
|
|
||||||
|
|
||||||
/* check for "session_requests" ROM request */
|
/* check for "session_requests" ROM request */
|
||||||
Genode::Session_label const label(Genode::label_from_args(args.string()));
|
|
||||||
if (service_name == Genode::Rom_session::service_name()
|
if (service_name == Genode::Rom_session::service_name()
|
||||||
&& label.last_element() == Genode::Session_requester::rom_name())
|
&& label.last_element() == Genode::Session_requester::rom_name())
|
||||||
return _session_requester.service();
|
return route(_session_requester.service());
|
||||||
|
|
||||||
/* if service is provided by one of our children, use it */
|
/* if service is provided by one of our children, use it */
|
||||||
if ((service = _find_service(_child_services, service_name)))
|
if ((service = _find_service(_child_services, service_name)))
|
||||||
return *service;
|
return route(*service);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle special case of the demo scenario when the user uses
|
* Handle special case of the demo scenario when the user uses
|
||||||
@ -189,7 +193,7 @@ class Launchpad_child : public Genode::Child_policy,
|
|||||||
if (service_name != "Input"
|
if (service_name != "Input"
|
||||||
&& service_name != "Framebuffer"
|
&& service_name != "Framebuffer"
|
||||||
&& ((service = _find_service(_parent_services, service_name))))
|
&& ((service = _find_service(_parent_services, service_name))))
|
||||||
return *service;
|
return route(*service);
|
||||||
|
|
||||||
Genode::warning(name(), ": service ", service_name, " not available");
|
Genode::warning(name(), ": service ", service_name, " not available");
|
||||||
throw Genode::Service_denied();
|
throw Genode::Service_denied();
|
||||||
@ -206,7 +210,7 @@ class Launchpad_child : public Genode::Child_policy,
|
|||||||
Child_service(_child_services, service_name,
|
Child_service(_child_services, service_name,
|
||||||
_session_requester.id_space(),
|
_session_requester.id_space(),
|
||||||
_child.session_factory(), *this,
|
_child.session_factory(), *this,
|
||||||
_child.ram_session_cap(),
|
_child.pd_session_cap(),
|
||||||
_child.pd_session_cap());
|
_child.pd_session_cap());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef _INCLUDE__SCOUT__CANVAS_H_
|
#ifndef _INCLUDE__SCOUT__CANVAS_H_
|
||||||
#define _INCLUDE__SCOUT__CANVAS_H_
|
#define _INCLUDE__SCOUT__CANVAS_H_
|
||||||
|
|
||||||
|
#include <base/allocator.h>
|
||||||
#include <scout/texture_allocator.h>
|
#include <scout/texture_allocator.h>
|
||||||
#include <os/pixel_rgba.h>
|
#include <os/pixel_rgba.h>
|
||||||
#include <util/color.h>
|
#include <util/color.h>
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Printf wrapper for Genode
|
|
||||||
* \date 2008-07-24
|
|
||||||
* \author Norman Feske
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2008-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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _INCLUDE__SCOUT__PRINTF_H_
|
|
||||||
#define _INCLUDE__SCOUT__PRINTF_H_
|
|
||||||
|
|
||||||
#include <base/printf.h>
|
|
||||||
|
|
||||||
namespace Scout { using Genode::printf; }
|
|
||||||
|
|
||||||
#endif /* _INCLUDE__SCOUT__PRINTF_H_ */
|
|
@ -1,7 +1,6 @@
|
|||||||
SRC_C = mini_c.c
|
|
||||||
SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \
|
SRC_CC = snprintf.cc vsnprintf.cc atol.cc strtol.cc strtod.cc \
|
||||||
malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \
|
malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \
|
||||||
printf.cc
|
mini_c.cc
|
||||||
|
|
||||||
STDINC = yes
|
STDINC = yes
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2019-01-13 38882b356b93cc25f3e703714b588ac7530ec214
|
2019-01-20 351e8fe91513154f62f015378e400386ffa07778
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "section.h"
|
#include "section.h"
|
||||||
|
|
||||||
#include <launchpad/launchpad.h>
|
#include <launchpad/launchpad.h>
|
||||||
#include <base/printf.h>
|
|
||||||
|
|
||||||
template <typename PT>
|
template <typename PT>
|
||||||
class Launchpad_window : public Scout::Scrollbar_listener,
|
class Launchpad_window : public Scout::Scrollbar_listener,
|
||||||
@ -170,7 +169,7 @@ class Launchpad_window : public Scout::Scrollbar_listener,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!ce) {
|
if (!ce) {
|
||||||
PWRN("child entry lookup failed");
|
Genode::warning("child entry lookup failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,6 @@
|
|||||||
#include "styles.h"
|
#include "styles.h"
|
||||||
#include "fade_icon.h"
|
#include "fade_icon.h"
|
||||||
|
|
||||||
#include <base/printf.h>
|
|
||||||
#include <base/snprintf.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define LOADBAR_RGBA _binary_loadbar_rgba_start
|
#define LOADBAR_RGBA _binary_loadbar_rgba_start
|
||||||
#define REDBAR_RGBA _binary_redbar_rgba_start
|
#define REDBAR_RGBA _binary_redbar_rgba_start
|
||||||
#define WHITEBAR_RGBA _binary_whitebar_rgba_start
|
#define WHITEBAR_RGBA _binary_whitebar_rgba_start
|
||||||
@ -226,27 +222,31 @@ class Kbyte_loadbar : public Loadbar<PT>
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char _label[32];
|
typedef Genode::String<32> Label;
|
||||||
|
|
||||||
void _print_kbytes(int kbytes, char *dst, int dst_len)
|
Label _label { };
|
||||||
|
|
||||||
|
struct Kbytes
|
||||||
{
|
{
|
||||||
if (kbytes >= 10*1024)
|
int const _value;
|
||||||
Genode::snprintf(dst, dst_len, "%d MByte", kbytes / 1024);
|
|
||||||
else
|
Kbytes(int value) : _value(value) { }
|
||||||
Genode::snprintf(dst, dst_len, "%d KByte", kbytes);
|
|
||||||
}
|
void print(Genode::Output &out) const
|
||||||
|
{
|
||||||
|
if (_value >= 10*1024)
|
||||||
|
Genode::print(out, _value/1024, " MByte");
|
||||||
|
else
|
||||||
|
Genode::print(out, _value, " KByte");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void _update_label()
|
void _update_label()
|
||||||
{
|
{
|
||||||
char value_buf[16];
|
_label = Label(Kbytes(Loadbar<PT>::value()), " / ",
|
||||||
char max_buf[16];
|
Kbytes(Loadbar<PT>::max_value()));
|
||||||
|
|
||||||
_print_kbytes(Loadbar<PT>::value(), value_buf, sizeof(value_buf));
|
Loadbar<PT>::txt(_label.string());
|
||||||
_print_kbytes(Loadbar<PT>::max_value(), max_buf, sizeof(max_buf));
|
|
||||||
|
|
||||||
Genode::snprintf(_label, sizeof(_label), "%s / %s", value_buf, max_buf);
|
|
||||||
|
|
||||||
Loadbar<PT>::txt(_label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -254,7 +254,6 @@ class Kbyte_loadbar : public Loadbar<PT>
|
|||||||
Kbyte_loadbar(Loadbar_listener *listener, Scout::Font *font = 0):
|
Kbyte_loadbar(Loadbar_listener *listener, Scout::Font *font = 0):
|
||||||
Loadbar<PT>(listener, font)
|
Loadbar<PT>(listener, font)
|
||||||
{
|
{
|
||||||
_label[0] = 0;
|
|
||||||
_update_label();
|
_update_label();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include <scout/platform.h>
|
#include <scout/platform.h>
|
||||||
#include <scout/tick.h>
|
#include <scout/tick.h>
|
||||||
#include <scout/user_state.h>
|
#include <scout/user_state.h>
|
||||||
#include <scout/printf.h>
|
|
||||||
#include <scout/nitpicker_graphics_backend.h>
|
#include <scout/nitpicker_graphics_backend.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -42,18 +41,18 @@ class Avail_quota_update : public Scout::Tick
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ram_session &_ram;
|
Pd_session &_pd;
|
||||||
Launchpad &_launchpad;
|
Launchpad &_launchpad;
|
||||||
size_t _avail = 0;
|
size_t _avail = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Avail_quota_update(Ram_session &ram, Launchpad &launchpad)
|
Avail_quota_update(Pd_session &pd, Launchpad &launchpad)
|
||||||
:
|
:
|
||||||
_ram(ram), _launchpad(launchpad)
|
_pd(pd), _launchpad(launchpad)
|
||||||
{
|
{
|
||||||
schedule(200);
|
schedule(200);
|
||||||
}
|
}
|
||||||
@ -63,7 +62,7 @@ class Avail_quota_update : public Scout::Tick
|
|||||||
*/
|
*/
|
||||||
int on_tick()
|
int on_tick()
|
||||||
{
|
{
|
||||||
size_t new_avail = _ram.avail_ram().value;
|
size_t new_avail = _pd.avail_ram().value;
|
||||||
|
|
||||||
/* update launchpad window if needed */
|
/* update launchpad window if needed */
|
||||||
if (new_avail != _avail)
|
if (new_avail != _avail)
|
||||||
@ -108,7 +107,7 @@ struct Main : Scout::Event_handler
|
|||||||
|
|
||||||
Launchpad_window<Pixel_rgb565>
|
Launchpad_window<Pixel_rgb565>
|
||||||
_launchpad { _env, _graphics_backend, _initial_position, _initial_size,
|
_launchpad { _env, _graphics_backend, _initial_position, _initial_size,
|
||||||
_max_size, _env.ram().avail_ram().value };
|
_max_size, _env.pd().avail_ram().value };
|
||||||
|
|
||||||
void _process_config()
|
void _process_config()
|
||||||
{
|
{
|
||||||
@ -117,7 +116,7 @@ struct Main : Scout::Event_handler
|
|||||||
|
|
||||||
bool const _config_processed = (_process_config(), true);
|
bool const _config_processed = (_process_config(), true);
|
||||||
|
|
||||||
Avail_quota_update _avail_quota_update { _env.ram(), _launchpad };
|
Avail_quota_update _avail_quota_update { _env.pd(), _launchpad };
|
||||||
|
|
||||||
User_state _user_state { &_launchpad, &_launchpad,
|
User_state _user_state { &_launchpad, &_launchpad,
|
||||||
_initial_position.x(), _initial_position.y() };
|
_initial_position.x(), _initial_position.y() };
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#define _ELEMENTS_H_
|
#define _ELEMENTS_H_
|
||||||
|
|
||||||
#include <scout/parent_element.h>
|
#include <scout/parent_element.h>
|
||||||
#include <scout/printf.h>
|
|
||||||
#include <scout/string.h>
|
#include <scout/string.h>
|
||||||
#include <scout/fader.h>
|
#include <scout/fader.h>
|
||||||
#include <scout/platform.h>
|
#include <scout/platform.h>
|
||||||
|
@ -12,10 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <base/env.h>
|
#include <base/env.h>
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
#include <launchpad/launchpad.h>
|
#include <launchpad/launchpad.h>
|
||||||
#include <dataspace/capability.h>
|
|
||||||
#include <rom_session/connection.h>
|
|
||||||
#include <base/snprintf.h>
|
|
||||||
#include "elements.h"
|
#include "elements.h"
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
@ -54,25 +52,19 @@ class Config_registry
|
|||||||
|
|
||||||
struct Config_registry::Entry : List<Config_registry::Entry>::Element
|
struct Config_registry::Entry : List<Config_registry::Entry>::Element
|
||||||
{
|
{
|
||||||
Dataspace_capability _init_dataspace(char const *name)
|
String<128> const name;
|
||||||
|
|
||||||
|
Constructible<Attached_rom_dataspace> dataspace { };
|
||||||
|
|
||||||
|
Dataspace_capability ds_cap { };
|
||||||
|
|
||||||
|
Entry(char const *prg_name) : name(prg_name)
|
||||||
{
|
{
|
||||||
char buf[256];
|
|
||||||
snprintf(buf, sizeof(buf), "%s.config", name);
|
|
||||||
Rom_connection *config = 0;
|
|
||||||
try {
|
try {
|
||||||
config = new (*_alloc_ptr) Rom_connection(*_env_ptr, buf);
|
dataspace.construct(*_env_ptr, String<256>(name, ".config").string());
|
||||||
return config->dataspace();
|
ds_cap = dataspace->cap();
|
||||||
}
|
}
|
||||||
catch (...) { }
|
catch (...) { }
|
||||||
return Dataspace_capability();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dataspace_capability const dataspace;
|
|
||||||
char name[128];
|
|
||||||
|
|
||||||
Entry(char const *prg_name) : dataspace(_init_dataspace(prg_name))
|
|
||||||
{
|
|
||||||
strncpy(name, prg_name, sizeof(name));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,14 +73,14 @@ Dataspace_capability Config_registry::config(char const *name)
|
|||||||
{
|
{
|
||||||
/* lookup existing configuration */
|
/* lookup existing configuration */
|
||||||
for (Entry *e = _configs.first(); e; e = e->next())
|
for (Entry *e = _configs.first(); e; e = e->next())
|
||||||
if (strcmp(name, e->name) == 0)
|
if (e->name == name)
|
||||||
return e->dataspace;
|
return e->ds_cap;
|
||||||
|
|
||||||
/* if lookup failed, create and register new config */
|
/* if lookup failed, create and register new config */
|
||||||
Entry *entry = new (*_alloc_ptr) Entry(name);
|
Entry *entry = new (*_alloc_ptr) Entry(name);
|
||||||
_configs.insert(entry);
|
_configs.insert(entry);
|
||||||
|
|
||||||
return entry->dataspace;
|
return entry->ds_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +90,7 @@ Dataspace_capability Config_registry::config(char const *name)
|
|||||||
|
|
||||||
void Launcher::init(Genode::Env &env, Allocator &alloc)
|
void Launcher::init(Genode::Env &env, Allocator &alloc)
|
||||||
{
|
{
|
||||||
static Launchpad launchpad(env, env.ram().avail_ram().value);
|
static Launchpad launchpad(env, env.pd().avail_ram().value);
|
||||||
_launchpad_ptr = &launchpad;
|
_launchpad_ptr = &launchpad;
|
||||||
_alloc_ptr = &alloc;
|
_alloc_ptr = &alloc;
|
||||||
_env_ptr = &env;
|
_env_ptr = &env;
|
||||||
|
@ -69,9 +69,9 @@ struct Scout::Main : Scout::Event_handler
|
|||||||
|
|
||||||
bool const _event_handler_registered = (_platform.event_handler(*this), true);
|
bool const _event_handler_registered = (_platform.event_handler(*this), true);
|
||||||
|
|
||||||
Area const _max_size { 530, 620 };
|
Area const _max_size { 530, 620 };
|
||||||
Point const _initial_position { 256, 80 };
|
Point const _initial_position { 256, 80 };
|
||||||
Area const _initial_size { 530, 400 };
|
Area const _initial_size { 530, 400 };
|
||||||
|
|
||||||
Config const _config { };
|
Config const _config { };
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ void Png_image::fill_cache(Canvas_base &canvas)
|
|||||||
&interlace_type, int_p_NULL, int_p_NULL);
|
&interlace_type, int_p_NULL, int_p_NULL);
|
||||||
|
|
||||||
_min_size = Scout::Area(w, h);
|
_min_size = Scout::Area(w, h);
|
||||||
printf("png is %d x %d, depth=%d\n", _min_size.w(), _min_size.h(), bit_depth);
|
log("png is ", _min_size, " depth=", bit_depth);
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
png_set_palette_to_rgb(png_ptr);
|
png_set_palette_to_rgb(png_ptr);
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <scout/tick.h>
|
#include <scout/tick.h>
|
||||||
#include <scout/printf.h>
|
|
||||||
|
|
||||||
using namespace Scout;
|
using namespace Scout;
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ void Tick::_enqueue()
|
|||||||
{
|
{
|
||||||
/* do not enqueue twice */
|
/* do not enqueue twice */
|
||||||
if (++_active > 1) {
|
if (++_active > 1) {
|
||||||
// printf("enqueue twice? ticks scheduled=%d\n", ticks_scheduled());
|
|
||||||
_active--;
|
_active--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -94,10 +92,7 @@ void Tick::schedule(time period)
|
|||||||
int Tick::ticks_scheduled()
|
int Tick::ticks_scheduled()
|
||||||
{
|
{
|
||||||
int num_ticks = 0;
|
int num_ticks = 0;
|
||||||
printf("now=%d\n", (int)now);
|
for (Tick *curr = head; curr; curr = curr->_next, num_ticks++);
|
||||||
for (Tick *curr = head; curr; curr = curr->_next, num_ticks++)
|
|
||||||
printf("ticks_scheduled:\n %d: curr=%p, deadline=%d\n",
|
|
||||||
(int)num_ticks, curr, (int)curr->_deadline);
|
|
||||||
return num_ticks;
|
return num_ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Launchpad::Launchpad(Env &env, unsigned long initial_quota)
|
|||||||
0 /* null-termination */
|
0 /* null-termination */
|
||||||
};
|
};
|
||||||
for (unsigned i = 0; names[i]; i++)
|
for (unsigned i = 0; names[i]; i++)
|
||||||
new (_heap) Launchpad_child::Parent_service(_parent_services, names[i]);
|
new (_heap) Launchpad_child::Parent_service(_parent_services, env, names[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -129,13 +129,15 @@ void Launchpad::process_config(Genode::Xml_node config_node)
|
|||||||
|
|
||||||
Xml_node config_node = node.sub_node("config");
|
Xml_node config_node = node.sub_node("config");
|
||||||
|
|
||||||
/* allocate dataspace for config */
|
config_node.with_raw_node([&] (char const *start, size_t length) {
|
||||||
size_t const size = config_node.size();
|
|
||||||
config_ds = _env.ram().alloc(size);
|
|
||||||
|
|
||||||
/* copy configuration into new dataspace */
|
/* allocate dataspace for config */
|
||||||
Attached_dataspace attached(_env.rm(), config_ds);
|
config_ds = _env.ram().alloc(length);
|
||||||
memcpy(attached.local_addr<char>(), config_node.addr(), size);
|
|
||||||
|
/* copy configuration into new dataspace */
|
||||||
|
Attached_dataspace attached(_env.rm(), config_ds);
|
||||||
|
memcpy(attached.local_addr<char>(), start, length);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add launchpad entry */
|
/* add launchpad entry */
|
||||||
@ -154,10 +156,10 @@ Launchpad_child *Launchpad::start_child(Launchpad_child::Name const &binary_name
|
|||||||
Launchpad_child::Name const unique_name = _get_unique_child_name(binary_name);
|
Launchpad_child::Name const unique_name = _get_unique_child_name(binary_name);
|
||||||
log("using unique child name \"", unique_name, "\"");
|
log("using unique child name \"", unique_name, "\"");
|
||||||
|
|
||||||
if (ram_quota.value > _env.ram().avail_ram().value) {
|
if (ram_quota.value > _env.pd().avail_ram().value) {
|
||||||
warning("child's ram quota is higher than our available quota, using available quota");
|
warning("child's ram quota is higher than our available quota, using available quota");
|
||||||
|
|
||||||
size_t const avail = _env.ram().avail_ram().value;
|
size_t const avail = _env.pd().avail_ram().value;
|
||||||
size_t const preserved = 256*1024;
|
size_t const preserved = 256*1024;
|
||||||
|
|
||||||
if (avail < preserved) {
|
if (avail < preserved) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <base/printf.h>
|
#include <base/log.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -8,9 +8,7 @@ extern "C" {
|
|||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
static void user_read_data(png_structp, png_bytep, png_size_t)
|
static void user_read_data(png_structp, png_bytep, png_size_t) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int, char **)
|
int main(int, char **)
|
||||||
{
|
{
|
||||||
@ -34,7 +32,7 @@ int main(int, char **)
|
|||||||
&interlace_type, int_p_NULL, int_p_NULL);
|
&interlace_type, int_p_NULL, int_p_NULL);
|
||||||
int _min_w = w;
|
int _min_w = w;
|
||||||
int _min_h = h;
|
int _min_h = h;
|
||||||
printf("png is %d x %d, depth=%d\n", _min_w, _min_h, bit_depth);
|
log("png is ", _min_w, " x ", _min_h, ", depth=", bit_depth);
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
png_set_palette_to_rgb(png_ptr);
|
png_set_palette_to_rgb(png_ptr);
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Mini C dummy functions
|
|
||||||
* \author Christian Helmuth
|
|
||||||
* \date 2008-07-24
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2008-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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef GENODE_RELEASE
|
|
||||||
#define printf(...)
|
|
||||||
#endif /* GENODE_RELEASE */
|
|
||||||
|
|
||||||
int sprintf(char *str, const char *format, ...)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
FILE *fopen(const char *path, const char *mode)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
FILE *fdopen(int fildes, const char *mode)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int fclose(FILE *fp)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int fprintf(FILE *stream, const char *format, ...)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
unsigned fread(void *ptr, unsigned size, unsigned nmemb, FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int fputc(int c, FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int fflush(FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int fseek(FILE *stream, long offset, int whence)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
long ftell(FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
void clearerr(FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); }
|
|
||||||
int ferror(FILE *stream)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
int puts(const char *s)
|
|
||||||
{ printf("%s", s); return 1; }
|
|
||||||
int putchar(int c)
|
|
||||||
{ printf("%c", c); return c; }
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
int abs(int j)
|
|
||||||
{
|
|
||||||
return j < 0 ? -j : j;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* in alloc_env_backend.cc
|
|
||||||
void *calloc(unsigned nmemb, unsigned size)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/* in base/cxx
|
|
||||||
void *memcpy(void *dest, const void *src, unsigned n);
|
|
||||||
*/
|
|
||||||
char *strcpy(char *dest, const char *src)
|
|
||||||
{ return strncpy(dest, src, ~0); }
|
|
||||||
char *strcat(char *dest, const char *src)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
||||||
|
|
||||||
static inline size_t min(size_t v1, size_t v2) { return v1 < v2 ? v1 : v2; }
|
|
||||||
|
|
||||||
char *strncpy(char *dst, const char *src, size_t n)
|
|
||||||
{
|
|
||||||
n = min(n, strlen(src) + 1);
|
|
||||||
memcpy(dst, src, n);
|
|
||||||
if (n > 0) dst[n - 1] = 0;
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *strerror(int errnum)
|
|
||||||
{ printf("%s: not implemented\n", __func__); return 0; }
|
|
81
repos/demo/src/lib/mini_c/mini_c.cc
Normal file
81
repos/demo/src/lib/mini_c/mini_c.cc
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* \brief Mini C dummy functions
|
||||||
|
* \author Christian Helmuth
|
||||||
|
* \date 2008-07-24
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2008-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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <base/log.h>
|
||||||
|
|
||||||
|
#define NOT_IMPLEMENTED Genode::log(__func__, " not implemented")
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int sprintf(char *, const char *, ...)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int printf(const char *, ...)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
FILE *fopen(const char *, const char *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
FILE *fdopen(int, const char *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int fclose(FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int fprintf(FILE *, const char *, ...)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
size_t fwrite(const void *, size_t, size_t, FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
unsigned fread(void *, unsigned, unsigned, FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int fputc(int, FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int fflush(FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int fseek(FILE *, long, int)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
long ftell(FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
void clearerr(FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; }
|
||||||
|
int ferror(FILE *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
int puts(const char *s)
|
||||||
|
{ Genode::log("%s", s); return 1; }
|
||||||
|
int putchar(int c)
|
||||||
|
{ Genode::log("%c", c); return c; }
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int abs(int j)
|
||||||
|
{
|
||||||
|
return j < 0 ? -j : j;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
char *strcpy(char *dest, const char *src)
|
||||||
|
{ return strncpy(dest, src, ~0); }
|
||||||
|
char *strcat(char *, const char *)
|
||||||
|
{ NOT_IMPLEMENTED; return 0; }
|
||||||
|
|
||||||
|
static inline size_t min(size_t v1, size_t v2) { return v1 < v2 ? v1 : v2; }
|
||||||
|
|
||||||
|
char *strncpy(char *dst, const char *src, size_t n)
|
||||||
|
{
|
||||||
|
n = min(n, strlen(src) + 1);
|
||||||
|
memcpy(dst, src, n);
|
||||||
|
if (n > 0) dst[n - 1] = 0;
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *strerror(int) { NOT_IMPLEMENTED; return 0; }
|
||||||
|
|
||||||
|
} /* extern "C" */
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Mini C printf()
|
|
||||||
* \author Norman Feske
|
|
||||||
* \date 2008-10-23
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2008-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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <base/printf.h>
|
|
||||||
|
|
||||||
extern "C" void printf(const char *format, ...)
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
va_start(list, format);
|
|
||||||
|
|
||||||
Genode::vprintf(format, list);
|
|
||||||
|
|
||||||
va_end(list);
|
|
||||||
}
|
|
@ -79,7 +79,8 @@ static long config_fb_y = 260;
|
|||||||
/**
|
/**
|
||||||
* Window title
|
* Window title
|
||||||
*/
|
*/
|
||||||
static const char *config_title = "Liquid Framebuffer";
|
typedef Genode::String<128> Title;
|
||||||
|
static Title config_title { "Liquid Framebuffer" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize handle
|
* Resize handle
|
||||||
@ -94,63 +95,16 @@ static bool config_decoration = true;
|
|||||||
/**
|
/**
|
||||||
* Parse configuration
|
* Parse configuration
|
||||||
*/
|
*/
|
||||||
static void read_config(Genode::Xml_node config_node)
|
static void read_config(Genode::Xml_node node)
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
config_fb_x = node.attribute_value("xpos", config_fb_x);
|
||||||
|
config_fb_y = node.attribute_value("ypos", config_fb_y);
|
||||||
try {
|
config_fb_width = node.attribute_value("width", config_fb_width);
|
||||||
char buf[16];
|
config_fb_height = node.attribute_value("height", config_fb_height);
|
||||||
config_node.attribute("animate").value(buf, sizeof(buf));
|
config_title = node.attribute_value("title", config_title);
|
||||||
|
config_animate = node.attribute_value("animate", true);
|
||||||
if (!strcmp("off", buf)) config_animate = false;
|
config_decoration = node.attribute_value("decoration", true);
|
||||||
else if (!strcmp("on", buf)) config_animate = true;
|
config_resize_handle = node.attribute_value("resize_handle", true);
|
||||||
else
|
|
||||||
Genode::printf("Warning: invalid value for animate declaration,\n"
|
|
||||||
" valid values are 'on', 'off.\n'");
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
config_alpha = config_animate;
|
|
||||||
|
|
||||||
try { config_node.attribute("xpos").value(&config_fb_x); }
|
|
||||||
catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try { config_node.attribute("ypos").value(&config_fb_y); }
|
|
||||||
catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try { config_node.attribute("width").value(&config_fb_width); }
|
|
||||||
catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try { config_node.attribute("height").value(&config_fb_height); }
|
|
||||||
catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try {
|
|
||||||
static char buf[64];
|
|
||||||
config_node.attribute("title").value(buf, sizeof(buf));
|
|
||||||
config_title = buf;
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try {
|
|
||||||
char buf[16];
|
|
||||||
config_node.attribute("decoration").value(buf, sizeof(buf));
|
|
||||||
|
|
||||||
if (!strcmp("off", buf)) config_decoration = false;
|
|
||||||
else if (!strcmp("on", buf)) config_decoration = true;
|
|
||||||
else
|
|
||||||
Genode::printf("Warning: invalid value for decoration declaration,\n"
|
|
||||||
" valid values are 'on', 'off.\n'");
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
try {
|
|
||||||
char buf[16];
|
|
||||||
config_node.attribute("resize_handle").value(buf, sizeof(buf));
|
|
||||||
|
|
||||||
if (!strcmp("off", buf)) config_resize_handle = false;
|
|
||||||
else if (!strcmp("on", buf)) config_resize_handle = true;
|
|
||||||
else
|
|
||||||
Genode::printf("Warning: invalid value for resize_handle declaration,\n"
|
|
||||||
" valid values are 'on', 'off.\n'");
|
|
||||||
} catch (Xml_node::Nonexistent_attribute) { }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -218,7 +172,7 @@ class Liquid_fb::Main : public Scout::Event_handler
|
|||||||
Framebuffer_window<Pixel_rgb565>
|
Framebuffer_window<Pixel_rgb565>
|
||||||
_fb_win { _graphics_backend, window_content(),
|
_fb_win { _graphics_backend, window_content(),
|
||||||
_initial_position, _initial_size, _max_size,
|
_initial_position, _initial_size, _max_size,
|
||||||
config_title, config_alpha,
|
config_title.string(), config_alpha,
|
||||||
config_resize_handle, config_decoration };
|
config_resize_handle, config_decoration };
|
||||||
|
|
||||||
/* create background animator if configured */
|
/* create background animator if configured */
|
||||||
@ -260,7 +214,7 @@ class Liquid_fb::Main : public Scout::Event_handler
|
|||||||
|
|
||||||
try { read_config(_config.xml()); } catch (...) { }
|
try { read_config(_config.xml()); } catch (...) { }
|
||||||
|
|
||||||
_fb_win.name(config_title);
|
_fb_win.name(config_title.string());
|
||||||
_fb_win.config_alpha(config_alpha);
|
_fb_win.config_alpha(config_alpha);
|
||||||
_fb_win.config_resize_handle(config_resize_handle);
|
_fb_win.config_resize_handle(config_resize_handle);
|
||||||
_fb_win.config_decoration(config_decoration);
|
_fb_win.config_decoration(config_decoration);
|
||||||
|
@ -85,7 +85,7 @@ class Window_content : public Scout::Element
|
|||||||
unsigned char *alpha;
|
unsigned char *alpha;
|
||||||
Genode::Texture<Genode::Pixel_rgb565> texture;
|
Genode::Texture<Genode::Pixel_rgb565> texture;
|
||||||
|
|
||||||
Fb_texture(Genode::Ram_session &ram, Genode::Region_map &local_rm,
|
Fb_texture(Genode::Ram_allocator &ram, Genode::Region_map &local_rm,
|
||||||
Genode::Allocator &alloc,
|
Genode::Allocator &alloc,
|
||||||
unsigned w, unsigned h, bool config_alpha)
|
unsigned w, unsigned h, bool config_alpha)
|
||||||
:
|
:
|
||||||
@ -128,7 +128,7 @@ class Window_content : public Scout::Element
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Genode::Ram_session &_ram;
|
Genode::Ram_allocator &_ram;
|
||||||
Genode::Region_map &_rm;
|
Genode::Region_map &_rm;
|
||||||
Genode::Allocator &_alloc;
|
Genode::Allocator &_alloc;
|
||||||
bool _config_alpha;
|
bool _config_alpha;
|
||||||
@ -157,7 +157,7 @@ class Window_content : public Scout::Element
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Window_content(Genode::Ram_session &ram, Genode::Region_map &rm,
|
Window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||||
Genode::Allocator &alloc, unsigned fb_w, unsigned fb_h,
|
Genode::Allocator &alloc, unsigned fb_w, unsigned fb_h,
|
||||||
Input::Session_component &input_session,
|
Input::Session_component &input_session,
|
||||||
bool config_alpha)
|
bool config_alpha)
|
||||||
@ -270,7 +270,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Session>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void init_window_content(Genode::Ram_session &ram, Genode::Region_map &rm,
|
void init_window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm,
|
||||||
Genode::Allocator &alloc,
|
Genode::Allocator &alloc,
|
||||||
Input::Session_component &input_component,
|
Input::Session_component &input_component,
|
||||||
unsigned fb_w, unsigned fb_h, bool config_alpha)
|
unsigned fb_w, unsigned fb_h, bool config_alpha)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "elements.h"
|
#include "elements.h"
|
||||||
|
|
||||||
extern Scout::Element *window_content();
|
extern Scout::Element *window_content();
|
||||||
extern void init_window_content(Genode::Ram_session &, Genode::Region_map &,
|
extern void init_window_content(Genode::Ram_allocator &, Genode::Region_map &,
|
||||||
Genode::Allocator &, Input::Session_component &,
|
Genode::Allocator &, Input::Session_component &,
|
||||||
unsigned fb_w, unsigned fb_h, bool config_alpha);
|
unsigned fb_w, unsigned fb_h, bool config_alpha);
|
||||||
extern void init_services(Genode::Env &, Input::Session_component &);
|
extern void init_services(Genode::Env &, Input::Session_component &);
|
||||||
|
Loading…
Reference in New Issue
Block a user