From 0c7450c5501b4588fbea531e908460747e7cabd9 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Tue, 30 May 2017 15:04:44 +0200 Subject: [PATCH] Removal of deprecated os/config.h (Ref #74) --- lib/mk/remote_rom_backend_nic_ip.mk | 4 +- run/fesrv.run | 17 ++--- run/jitterentropy_testu01.inc | 2 +- src/app/fesrv/main.cc | 88 ++++++++++++-------------- src/app/fesrv/target.mk | 2 +- src/lib/sqlite/genode_sqlite.cc | 7 +- src/lib/testu01/genode_gdef.cc | 8 ++- src/proxy/remote_rom/client/target.inc | 2 +- src/proxy/remote_rom/server/target.inc | 2 +- 9 files changed, 64 insertions(+), 68 deletions(-) diff --git a/lib/mk/remote_rom_backend_nic_ip.mk b/lib/mk/remote_rom_backend_nic_ip.mk index 5cbd77b..c1f8cf5 100644 --- a/lib/mk/remote_rom_backend_nic_ip.mk +++ b/lib/mk/remote_rom_backend_nic_ip.mk @@ -3,7 +3,7 @@ SRC_CC += backend/nic_ip/backend.cc -LIBS += base config net +LIBS += base net -# include less specific configuration +# include less specificuration include $(REP_DIR)/lib/mk/remote_rom_backend.inc diff --git a/run/fesrv.run b/run/fesrv.run index 2230a62..c8fc954 100644 --- a/run/fesrv.run +++ b/run/fesrv.run @@ -13,9 +13,9 @@ create_boot_directory install_config { - - + + @@ -29,22 +29,19 @@ install_config { - - - - + + + - - - -} + + } # # Boot image diff --git a/run/jitterentropy_testu01.inc b/run/jitterentropy_testu01.inc index 70ce9a1..70bb87a 100644 --- a/run/jitterentropy_testu01.inc +++ b/run/jitterentropy_testu01.inc @@ -25,7 +25,6 @@ set config { - @@ -36,6 +35,7 @@ set config { + diff --git a/src/app/fesrv/main.cc b/src/app/fesrv/main.cc index 36a8a4c..4df2974 100644 --- a/src/app/fesrv/main.cc +++ b/src/app/fesrv/main.cc @@ -38,8 +38,9 @@ #include "htif.h" -#include -#include +#include +#include +#include #include #include @@ -50,15 +51,15 @@ class Htif_zedboard_genode : public htif_t { public: - Htif_zedboard_genode( std::string image = "image.elf" ): - htif_t( std::vector( { image } ) ), - _io_mem_dataspace( DEV_PADDR, 2 * sizeof( uintptr_t ), true ), - dev_vaddr( _io_mem_dataspace.local_addr() ) - { - write_reg( 31, 0 ); // reset - } + Htif_zedboard_genode(Libc::Env & env, std::string image = "image.elf") + : htif_t( std::vector( { image } ) ), + _io_mem_dataspace(env, DEV_PADDR, 2 * sizeof( uintptr_t ), true ), + dev_vaddr( _io_mem_dataspace.local_addr() ) { + write_reg( 31, 0 ); /* reset */ } + protected: + ssize_t read( void *buf, size_t max_size ) { uint32_t *x = ( uint32_t * )buf; @@ -67,75 +68,68 @@ class Htif_zedboard_genode : public htif_t uintptr_t c = read_reg( 0 ); uint32_t count = 0; - if ( c > 0 ) - { - for ( count=0; count 0 ) { + for ( count=0; count= sizeof( *x ) ); - for ( uint32_t i = 0; i < size/sizeof( *x ); i++ ) - { - write_reg( 0, x[i] ); - } + for ( uint32_t i = 0; i < size/sizeof( *x ); i++ ) { + write_reg( 0, x[i] ); } return size; } - size_t chunk_max_size() { return 64; } - size_t chunk_align() { return 64; } - uint32_t mem_mb() { return 256; } - uint32_t num_cores() { return 1; } + size_t chunk_max_size() { return 64; } + size_t chunk_align() { return 64; } + uint32_t mem_mb() { return 256; } + uint32_t num_cores() { return 1; } private: + Genode::Attached_io_mem_dataspace _io_mem_dataspace; volatile uintptr_t *dev_vaddr; const static uintptr_t DEV_PADDR = 0x43C00000; }; -static const std::string image_name() + +static const std::string image_name(Libc::Env & env) { static const size_t LEN = 128; char buf[LEN]; Genode::memset( buf, 0, LEN ); - try - { - Genode::config()->xml_node().sub_node( "fesrv" ).attribute( "image" ).value( - buf, LEN - 1 ); - } - catch ( ... ) - { + try { + Genode::Attached_rom_dataspace config(env, "config"); + config.xml().sub_node( "fesrv" ).attribute( "image" ).value(buf, LEN - 1 ); + } catch ( ... ) { throw std::runtime_error( "elf-image not configured" ); } return std::string( buf ); } -int main() + +void Libc::Component::construct(Libc::Env & env) { - try - { - auto image = image_name(); - Htif_zedboard_genode htif( image ); - Genode::log( "Initialized Htif_zedboard with ", image.c_str() ); - htif.run(); - } - catch ( const std::runtime_error &e ) - { - Genode::error( "Caught runtime error: ", e.what() ); - } - catch ( ... ) - { - Genode::error( "Unknown error occured" ); - } + Libc::with_libc([&] () { + try { + std::string image = image_name(env); + Htif_zedboard_genode htif(env, image); + Genode::log( "Initialized Htif_zedboard with ", image.c_str() ); + htif.run(); + } catch ( const std::runtime_error &e ) { + Genode::error( "Caught runtime error: ", e.what() ); + } catch ( ... ) { + Genode::error( "Unknown error occured" ); + } + }); } diff --git a/src/app/fesrv/target.mk b/src/app/fesrv/target.mk index ba72acc..f2fd5c4 100644 --- a/src/app/fesrv/target.mk +++ b/src/app/fesrv/target.mk @@ -19,7 +19,7 @@ SRC_CC = main.cc \ term.cc TARGET = fesrv -LIBS = stdcxx posix +LIBS = stdcxx libc INC_DIR += $(FESRV_SRC) # Some defines to keep the fesrv compilation process happy diff --git a/src/lib/sqlite/genode_sqlite.cc b/src/lib/sqlite/genode_sqlite.cc index df31291..9b52ea7 100644 --- a/src/lib/sqlite/genode_sqlite.cc +++ b/src/lib/sqlite/genode_sqlite.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -525,15 +525,16 @@ int sqlite3_os_init(void) return SQLITE_ERROR; } + Genode::Attached_rom_dataspace config("config"); Vfs::Dir_file_system *genode_vfs = nullptr; try { - Xml_node node = Genode::config()->xml_node().sub_node("sqlite").sub_node("vfs"); + Xml_node node = config.xml().sub_node("sqlite").sub_node("vfs"); genode_vfs = new (Genode::env()->heap()) Vfs::Dir_file_system(node, Vfs::global_file_system_factory()); } catch (Genode::Xml_node::Nonexistent_sub_node) { try { - Xml_node node = Genode::config()->xml_node().sub_node("vfs"); + Xml_node node = config.xml().sub_node("vfs"); genode_vfs = new (Genode::env()->heap()) Vfs::Dir_file_system(node, Vfs::global_file_system_factory()); PWRN("additional VFS created for SQLite"); diff --git a/src/lib/testu01/genode_gdef.cc b/src/lib/testu01/genode_gdef.cc index 04b1c7d..880d46b 100644 --- a/src/lib/testu01/genode_gdef.cc +++ b/src/lib/testu01/genode_gdef.cc @@ -1,3 +1,5 @@ +#include + extern "C" { #include @@ -5,9 +7,11 @@ extern "C" { void gdef_GetHostName (char machine[], int n) { - strncpy(machine, "genode", n); + Genode::Attached_rom_dataspace config("config"); + try { config.xml().attribute("hostname").value(machine, n); } + catch (...) { Genode::strncpy(machine, "genode", n); } } void gdef_WriteHostName (void) { } -} \ No newline at end of file +} diff --git a/src/proxy/remote_rom/client/target.inc b/src/proxy/remote_rom/client/target.inc index eaf6f3d..2a9905a 100644 --- a/src/proxy/remote_rom/client/target.inc +++ b/src/proxy/remote_rom/client/target.inc @@ -1,7 +1,7 @@ SRC_CC = main.cc TARGET = remote_rom_client -LIBS += base config +LIBS += base INC_DIR += $(REP_DIR)/include/remote_rom diff --git a/src/proxy/remote_rom/server/target.inc b/src/proxy/remote_rom/server/target.inc index 36f30a8..0af27a5 100644 --- a/src/proxy/remote_rom/server/target.inc +++ b/src/proxy/remote_rom/server/target.inc @@ -1,7 +1,7 @@ SRC_CC = main.cc TARGET = remote_rom_server -LIBS += base config +LIBS += base INC_DIR += $(REP_DIR)/include/remote_rom