mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 06:33:31 +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 {
|
||||
return _session_requester.id_space(); }
|
||||
|
||||
Genode::Service &resolve_session_request(Genode::Service::Name const &service_name,
|
||||
Genode::Session_state::Args const &args) override
|
||||
Genode::Child_policy::Route
|
||||
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;
|
||||
|
||||
/* check for config file request */
|
||||
if ((service = _config_policy
|
||||
.resolve_session_request(service_name.string(), args.string())))
|
||||
return *service;
|
||||
if ((service = _config_policy.resolve_session_request_with_label(service_name, label)))
|
||||
return route(*service);
|
||||
|
||||
/* 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()
|
||||
&& 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 = _find_service(_child_services, service_name)))
|
||||
return *service;
|
||||
return route(*service);
|
||||
|
||||
/*
|
||||
* 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"
|
||||
&& service_name != "Framebuffer"
|
||||
&& ((service = _find_service(_parent_services, service_name))))
|
||||
return *service;
|
||||
return route(*service);
|
||||
|
||||
Genode::warning(name(), ": service ", service_name, " not available");
|
||||
throw Genode::Service_denied();
|
||||
@ -206,7 +210,7 @@ class Launchpad_child : public Genode::Child_policy,
|
||||
Child_service(_child_services, service_name,
|
||||
_session_requester.id_space(),
|
||||
_child.session_factory(), *this,
|
||||
_child.ram_session_cap(),
|
||||
_child.pd_session_cap(),
|
||||
_child.pd_session_cap());
|
||||
}
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef _INCLUDE__SCOUT__CANVAS_H_
|
||||
#define _INCLUDE__SCOUT__CANVAS_H_
|
||||
|
||||
#include <base/allocator.h>
|
||||
#include <scout/texture_allocator.h>
|
||||
#include <os/pixel_rgba.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 \
|
||||
malloc_free.cc memcmp.cc strlen.cc memset.cc abort.cc \
|
||||
printf.cc
|
||||
mini_c.cc
|
||||
|
||||
STDINC = yes
|
||||
|
||||
|
@ -1 +1 @@
|
||||
2019-01-13 38882b356b93cc25f3e703714b588ac7530ec214
|
||||
2019-01-20 351e8fe91513154f62f015378e400386ffa07778
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "section.h"
|
||||
|
||||
#include <launchpad/launchpad.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
template <typename PT>
|
||||
class Launchpad_window : public Scout::Scrollbar_listener,
|
||||
@ -170,7 +169,7 @@ class Launchpad_window : public Scout::Scrollbar_listener,
|
||||
break;
|
||||
|
||||
if (!ce) {
|
||||
PWRN("child entry lookup failed");
|
||||
Genode::warning("child entry lookup failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,6 @@
|
||||
#include "styles.h"
|
||||
#include "fade_icon.h"
|
||||
|
||||
#include <base/printf.h>
|
||||
#include <base/snprintf.h>
|
||||
|
||||
|
||||
#define LOADBAR_RGBA _binary_loadbar_rgba_start
|
||||
#define REDBAR_RGBA _binary_redbar_rgba_start
|
||||
#define WHITEBAR_RGBA _binary_whitebar_rgba_start
|
||||
@ -226,27 +222,31 @@ class Kbyte_loadbar : public Loadbar<PT>
|
||||
{
|
||||
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)
|
||||
Genode::snprintf(dst, dst_len, "%d MByte", kbytes / 1024);
|
||||
else
|
||||
Genode::snprintf(dst, dst_len, "%d KByte", kbytes);
|
||||
}
|
||||
int const _value;
|
||||
|
||||
Kbytes(int value) : _value(value) { }
|
||||
|
||||
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()
|
||||
{
|
||||
char value_buf[16];
|
||||
char max_buf[16];
|
||||
_label = Label(Kbytes(Loadbar<PT>::value()), " / ",
|
||||
Kbytes(Loadbar<PT>::max_value()));
|
||||
|
||||
_print_kbytes(Loadbar<PT>::value(), value_buf, sizeof(value_buf));
|
||||
_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);
|
||||
Loadbar<PT>::txt(_label.string());
|
||||
}
|
||||
|
||||
public:
|
||||
@ -254,7 +254,6 @@ class Kbyte_loadbar : public Loadbar<PT>
|
||||
Kbyte_loadbar(Loadbar_listener *listener, Scout::Font *font = 0):
|
||||
Loadbar<PT>(listener, font)
|
||||
{
|
||||
_label[0] = 0;
|
||||
_update_label();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <scout/platform.h>
|
||||
#include <scout/tick.h>
|
||||
#include <scout/user_state.h>
|
||||
#include <scout/printf.h>
|
||||
#include <scout/nitpicker_graphics_backend.h>
|
||||
|
||||
#include "config.h"
|
||||
@ -42,18 +41,18 @@ class Avail_quota_update : public Scout::Tick
|
||||
{
|
||||
private:
|
||||
|
||||
Ram_session &_ram;
|
||||
Launchpad &_launchpad;
|
||||
size_t _avail = 0;
|
||||
Pd_session &_pd;
|
||||
Launchpad &_launchpad;
|
||||
size_t _avail = 0;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
@ -63,7 +62,7 @@ class Avail_quota_update : public Scout::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 */
|
||||
if (new_avail != _avail)
|
||||
@ -108,7 +107,7 @@ struct Main : Scout::Event_handler
|
||||
|
||||
Launchpad_window<Pixel_rgb565>
|
||||
_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()
|
||||
{
|
||||
@ -117,7 +116,7 @@ struct Main : Scout::Event_handler
|
||||
|
||||
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,
|
||||
_initial_position.x(), _initial_position.y() };
|
||||
|
@ -15,7 +15,6 @@
|
||||
#define _ELEMENTS_H_
|
||||
|
||||
#include <scout/parent_element.h>
|
||||
#include <scout/printf.h>
|
||||
#include <scout/string.h>
|
||||
#include <scout/fader.h>
|
||||
#include <scout/platform.h>
|
||||
|
@ -12,10 +12,8 @@
|
||||
*/
|
||||
|
||||
#include <base/env.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <launchpad/launchpad.h>
|
||||
#include <dataspace/capability.h>
|
||||
#include <rom_session/connection.h>
|
||||
#include <base/snprintf.h>
|
||||
#include "elements.h"
|
||||
|
||||
using namespace Genode;
|
||||
@ -54,25 +52,19 @@ class Config_registry
|
||||
|
||||
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 {
|
||||
config = new (*_alloc_ptr) Rom_connection(*_env_ptr, buf);
|
||||
return config->dataspace();
|
||||
dataspace.construct(*_env_ptr, String<256>(name, ".config").string());
|
||||
ds_cap = dataspace->cap();
|
||||
}
|
||||
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 */
|
||||
for (Entry *e = _configs.first(); e; e = e->next())
|
||||
if (strcmp(name, e->name) == 0)
|
||||
return e->dataspace;
|
||||
if (e->name == name)
|
||||
return e->ds_cap;
|
||||
|
||||
/* if lookup failed, create and register new config */
|
||||
Entry *entry = new (*_alloc_ptr) Entry(name);
|
||||
_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)
|
||||
{
|
||||
static Launchpad launchpad(env, env.ram().avail_ram().value);
|
||||
static Launchpad launchpad(env, env.pd().avail_ram().value);
|
||||
_launchpad_ptr = &launchpad;
|
||||
_alloc_ptr = &alloc;
|
||||
_env_ptr = &env;
|
||||
|
@ -69,9 +69,9 @@ struct Scout::Main : Scout::Event_handler
|
||||
|
||||
bool const _event_handler_registered = (_platform.event_handler(*this), true);
|
||||
|
||||
Area const _max_size { 530, 620 };
|
||||
Point const _initial_position { 256, 80 };
|
||||
Area const _initial_size { 530, 400 };
|
||||
Area const _max_size { 530, 620 };
|
||||
Point const _initial_position { 256, 80 };
|
||||
Area const _initial_size { 530, 400 };
|
||||
|
||||
Config const _config { };
|
||||
|
||||
|
@ -104,7 +104,7 @@ void Png_image::fill_cache(Canvas_base &canvas)
|
||||
&interlace_type, int_p_NULL, int_p_NULL);
|
||||
|
||||
_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)
|
||||
png_set_palette_to_rgb(png_ptr);
|
||||
|
@ -12,7 +12,6 @@
|
||||
*/
|
||||
|
||||
#include <scout/tick.h>
|
||||
#include <scout/printf.h>
|
||||
|
||||
using namespace Scout;
|
||||
|
||||
@ -24,7 +23,6 @@ void Tick::_enqueue()
|
||||
{
|
||||
/* do not enqueue twice */
|
||||
if (++_active > 1) {
|
||||
// printf("enqueue twice? ticks scheduled=%d\n", ticks_scheduled());
|
||||
_active--;
|
||||
return;
|
||||
}
|
||||
@ -94,10 +92,7 @@ void Tick::schedule(time period)
|
||||
int Tick::ticks_scheduled()
|
||||
{
|
||||
int num_ticks = 0;
|
||||
printf("now=%d\n", (int)now);
|
||||
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);
|
||||
for (Tick *curr = head; curr; curr = curr->_next, num_ticks++);
|
||||
return num_ticks;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ Launchpad::Launchpad(Env &env, unsigned long initial_quota)
|
||||
0 /* null-termination */
|
||||
};
|
||||
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");
|
||||
|
||||
/* allocate dataspace for config */
|
||||
size_t const size = config_node.size();
|
||||
config_ds = _env.ram().alloc(size);
|
||||
config_node.with_raw_node([&] (char const *start, size_t length) {
|
||||
|
||||
/* copy configuration into new dataspace */
|
||||
Attached_dataspace attached(_env.rm(), config_ds);
|
||||
memcpy(attached.local_addr<char>(), config_node.addr(), size);
|
||||
/* allocate dataspace for config */
|
||||
config_ds = _env.ram().alloc(length);
|
||||
|
||||
/* copy configuration into new dataspace */
|
||||
Attached_dataspace attached(_env.rm(), config_ds);
|
||||
memcpy(attached.local_addr<char>(), start, length);
|
||||
});
|
||||
}
|
||||
|
||||
/* 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);
|
||||
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");
|
||||
|
||||
size_t const avail = _env.ram().avail_ram().value;
|
||||
size_t const avail = _env.pd().avail_ram().value;
|
||||
size_t const preserved = 256*1024;
|
||||
|
||||
if (avail < preserved) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <base/printf.h>
|
||||
#include <base/log.h>
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
@ -8,9 +8,7 @@ extern "C" {
|
||||
|
||||
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 **)
|
||||
{
|
||||
@ -34,7 +32,7 @@ int main(int, char **)
|
||||
&interlace_type, int_p_NULL, int_p_NULL);
|
||||
int _min_w = w;
|
||||
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)
|
||||
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
|
||||
*/
|
||||
static const char *config_title = "Liquid Framebuffer";
|
||||
typedef Genode::String<128> Title;
|
||||
static Title config_title { "Liquid Framebuffer" };
|
||||
|
||||
/**
|
||||
* Resize handle
|
||||
@ -94,63 +95,16 @@ static bool config_decoration = true;
|
||||
/**
|
||||
* Parse configuration
|
||||
*/
|
||||
static void read_config(Genode::Xml_node config_node)
|
||||
static void read_config(Genode::Xml_node node)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
try {
|
||||
char buf[16];
|
||||
config_node.attribute("animate").value(buf, sizeof(buf));
|
||||
|
||||
if (!strcmp("off", buf)) config_animate = false;
|
||||
else if (!strcmp("on", buf)) config_animate = 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) { }
|
||||
|
||||
config_fb_x = node.attribute_value("xpos", config_fb_x);
|
||||
config_fb_y = node.attribute_value("ypos", config_fb_y);
|
||||
config_fb_width = node.attribute_value("width", config_fb_width);
|
||||
config_fb_height = node.attribute_value("height", config_fb_height);
|
||||
config_title = node.attribute_value("title", config_title);
|
||||
config_animate = node.attribute_value("animate", true);
|
||||
config_decoration = node.attribute_value("decoration", true);
|
||||
config_resize_handle = node.attribute_value("resize_handle", true);
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +172,7 @@ class Liquid_fb::Main : public Scout::Event_handler
|
||||
Framebuffer_window<Pixel_rgb565>
|
||||
_fb_win { _graphics_backend, window_content(),
|
||||
_initial_position, _initial_size, _max_size,
|
||||
config_title, config_alpha,
|
||||
config_title.string(), config_alpha,
|
||||
config_resize_handle, config_decoration };
|
||||
|
||||
/* create background animator if configured */
|
||||
@ -260,7 +214,7 @@ class Liquid_fb::Main : public Scout::Event_handler
|
||||
|
||||
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_resize_handle(config_resize_handle);
|
||||
_fb_win.config_decoration(config_decoration);
|
||||
|
@ -85,7 +85,7 @@ class Window_content : public Scout::Element
|
||||
unsigned char *alpha;
|
||||
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,
|
||||
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::Allocator &_alloc;
|
||||
bool _config_alpha;
|
||||
@ -157,7 +157,7 @@ class Window_content : public Scout::Element
|
||||
|
||||
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,
|
||||
Input::Session_component &input_session,
|
||||
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,
|
||||
Input::Session_component &input_component,
|
||||
unsigned fb_w, unsigned fb_h, bool config_alpha)
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "elements.h"
|
||||
|
||||
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 &,
|
||||
unsigned fb_w, unsigned fb_h, bool config_alpha);
|
||||
extern void init_services(Genode::Env &, Input::Session_component &);
|
||||
|
Loading…
Reference in New Issue
Block a user