diff --git a/repos/base-fiasco/src/core/include/map_local.h b/repos/base-fiasco/src/core/include/map_local.h index 9a0c30317..8006eeaf1 100644 --- a/repos/base-fiasco/src/core/include/map_local.h +++ b/repos/base-fiasco/src/core/include/map_local.h @@ -63,8 +63,9 @@ namespace Genode { L4_IPC_NEVER, &ipc_result); if (L4_IPC_IS_ERROR(ipc_result)) { - PWRN("could not locally remap 0x%lx to 0x%lx, error code is %ld", - from_addr, to_addr, L4_IPC_ERROR(ipc_result)); + warning("could not locally remap ", Hex(from_addr), " " + "to ", Hex(to_addr), ", " + "error code is ", L4_IPC_ERROR(ipc_result)); return false; } } @@ -79,7 +80,7 @@ namespace Genode { */ inline void unmap_local(addr_t virt, size_t num_pages) { - PERR("unmap_local() called - not implemented yet"); + error("unmap_local() called - not implemented yet"); } } diff --git a/repos/base-fiasco/src/core/include/platform_pd.h b/repos/base-fiasco/src/core/include/platform_pd.h index a0f444887..51bf456a7 100644 --- a/repos/base-fiasco/src/core/include/platform_pd.h +++ b/repos/base-fiasco/src/core/include/platform_pd.h @@ -191,7 +191,7 @@ namespace Genode { * On L4/Fiasco, we don't use directed unmap but rely on the * in-kernel mapping database. See 'region_map_support.cc'. */ - void flush(addr_t, size_t) { PDBG("not implemented"); } + void flush(addr_t, size_t) { warning(__func__, " not implemented"); } }; } diff --git a/repos/base-fiasco/src/core/io_mem_session_support.cc b/repos/base-fiasco/src/core/io_mem_session_support.cc index 8f247a829..ffe6b6b5c 100644 --- a/repos/base-fiasco/src/core/io_mem_session_support.cc +++ b/repos/base-fiasco/src/core/io_mem_session_support.cc @@ -83,7 +83,8 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) L4_IPC_NEVER, &result, &tag); if (err || !l4_ipc_fpage_received(result)) { - PERR("%d %d", err, l4_ipc_fpage_received(result)); + error("map_local failed err=", err, " " + "(", l4_ipc_fpage_received(result), ")"); return 0; } diff --git a/repos/base-fiasco/src/core/irq_session_component.cc b/repos/base-fiasco/src/core/irq_session_component.cc index 89202e51d..0797c9bf8 100644 --- a/repos/base-fiasco/src/core/irq_session_component.cc +++ b/repos/base-fiasco/src/core/irq_session_component.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -52,7 +52,7 @@ bool Irq_object::_associate() L4_IPC_SHORT_MSG, &dw0, &dw1, L4_IPC_BOTH_TIMEOUT_0, &result); - if (err != L4_IPC_RETIMEOUT) PERR("IRQ association failed"); + if (err != L4_IPC_RETIMEOUT) error("IRQ association failed"); return (err == L4_IPC_RETIMEOUT); } @@ -74,7 +74,7 @@ void Irq_object::_wait_for_irq() L4_IPC_SHORT_MSG, &dw0, &dw1, L4_IPC_NEVER, &result); - if (L4_IPC_IS_ERROR(result)) PERR("Ipc error %lx", L4_IPC_ERROR(result)); + if (L4_IPC_IS_ERROR(result)) error("Ipc error ", L4_IPC_ERROR(result)); } while (L4_IPC_IS_ERROR(result)); } @@ -89,7 +89,7 @@ void Irq_object::start() void Irq_object::entry() { if (!_associate()) { - PERR("Could not associate with IRQ 0x%x", _irq); + error("Could not associate with IRQ ", _irq); return; } @@ -133,7 +133,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, throw Root::Unavailable(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { - PERR("Unavailable IRQ 0x%x requested", _irq_number); + error("Unavailable IRQ ", _irq_number, " requested"); throw Root::Unavailable(); } @@ -143,7 +143,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, Irq_session_component::~Irq_session_component() { - PERR("Not yet implemented."); + error("Not yet implemented."); } diff --git a/repos/base-fiasco/src/core/pager.cc b/repos/base-fiasco/src/core/pager.cc index 8aa7655f3..267d86614 100644 --- a/repos/base-fiasco/src/core/pager.cc +++ b/repos/base-fiasco/src/core/pager.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -45,7 +45,7 @@ void Ipc_pager::wait_for_fault() L4_IPC_NEVER, &result); if (L4_IPC_IS_ERROR(result)) - PERR("Ipc error %lx", L4_IPC_ERROR(result)); + error(__func__, ": IPC error ", Hex(L4_IPC_ERROR(result))); } while (L4_IPC_IS_ERROR(result)); } @@ -62,7 +62,7 @@ void Ipc_pager::reply_and_wait_for_fault() L4_IPC_SEND_TIMEOUT_0, &result); if (L4_IPC_IS_ERROR(result)) { - PERR("Ipc error %lx", L4_IPC_ERROR(result)); + error(__func__, ": IPC error ", Hex(L4_IPC_ERROR(result))); /* ignore all errors and wait for next proper message */ wait_for_fault(); diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 96c2636bd..77161896a 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -22,6 +22,7 @@ #include #include #include +#include /* core includes */ #include @@ -44,11 +45,6 @@ namespace Fiasco { using namespace Genode; -static const bool verbose = true; -static const bool verbose_core_pf = false; -static const bool verbose_region_alloc = false; - - /*********************************** ** Core address space management ** ***********************************/ @@ -107,21 +103,22 @@ static void _core_pager_loop() if (pfa < L4_PAGESIZE) { /* NULL pointer access */ - PERR("Possible null pointer %s in %x.%02x at %lx IP %lx", - rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1); + error("possible null pointer ", rw ? "WRITE" : "READ", " " + "in ", (int)t.id.task, ".", (int)t.id.lthread, " " + "at ", Hex(pfa), " IP ", dw1); /* do not unblock faulter */ send_reply = false; continue; } else if (!_core_address_ranges().valid_addr(pfa)) { /* page-fault address is not in RAM */ - PERR("%s access outside of RAM in %x.%02x at %lx IP %lx", - rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1); + error(rw ? "WRITE" : "READ", " access outside of RAM " + "in ", (int)t.id.task, ".", (int)t.id.lthread, " " + "at ", Hex(pfa), " IP ", dw1); /* do not unblock faulter */ send_reply = false; continue; - } else if (verbose_core_pf) - PDBG("pfa=%lx ip=%lx thread %x.%02x", pfa, dw1, (int)t.id.task, (int)t.id.lthread); + } /* my pf handler is sigma0 - just touch the appropriate page */ if (rw) @@ -205,24 +202,11 @@ struct Region }; -/** - * Log region - */ -static inline void print_region(Region r) -{ - printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start); -} - - /** * Add region to allocator */ static inline void add_region(Region r, Range_allocator &alloc) { - if (verbose_region_alloc) { - printf("%p add: ", &alloc); print_region(r); printf("\n"); - } - /* adjust region */ addr_t start = trunc_page(r.start); addr_t end = round_page(r.end); @@ -236,10 +220,6 @@ static inline void add_region(Region r, Range_allocator &alloc) */ static inline void remove_region(Region r, Range_allocator &alloc) { - if (verbose_region_alloc) { - printf("%p remove: ", &alloc); print_region(r); printf("\n"); - } - /* adjust region */ addr_t start = trunc_page(r.start); addr_t end = round_page(r.end); @@ -350,7 +330,7 @@ static Fiasco::l4_kernel_info_t *get_kip() bool amok = false; if (err) { - printf("IPC error %d\n", err); + raw("IPC error ", err, " while accessing the KIP"); amok = true; } if (!l4_ipc_fpage_received(r)) { @@ -367,16 +347,6 @@ static Fiasco::l4_kernel_info_t *get_kip() if (kip->magic != L4_KERNEL_INFO_MAGIC) panic("Sigma0 mapped something but not the KIP"); - if (verbose) { - printf("\n"); - printf("KIP @ %p\n", kip); - printf(" magic: %08x\n", kip->magic); - printf(" version: %08x\n", kip->version); - printf(" sigma0 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma0_esp, kip->sigma0_eip); - printf(" sigma1 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma1_esp, kip->sigma1_eip); - printf(" root "); printf(" esp: %08lx eip: %08lx\n", kip->root_esp, kip->root_eip); - } - return kip; } @@ -392,7 +362,7 @@ void Platform::_setup_basics() /* update multi-boot info pointer from KIP */ addr_t mb_info_addr = kip->user_ptr; - if (verbose) printf("MBI @ 0x%lx\n", mb_info_addr); + log("MBI @ ", Hex(mb_info_addr)); /* parse memory descriptors - look for virtual memory configuration */ /* XXX we support only one VM region (here and also inside RM) */ @@ -451,10 +421,9 @@ void Platform::_setup_rom() Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom); _rom_fs.insert(new_rom); - if (verbose) - printf(" mod[%d] [%p,%p) %s\n", i, - (void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(), - new_rom->name()); + log(" mod[", i, "] ", + Hex_range(new_rom->addr(), new_rom->size()), " ", + new_rom->name()); /* zero remainder of last ROM page */ size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; @@ -484,21 +453,21 @@ Platform::Platform() : if (initialized) panic("Platform constructed twice!"); initialized = true; + init_log(); + _setup_basics(); _setup_mem_alloc(); _setup_io_port_alloc(); _setup_irq_alloc(); _setup_rom(); - if (verbose) { - printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); - printf(":irq: "); _irq_alloc()->dump_addr_tree(); - printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); - } + log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + log(":region_alloc: "); _region_alloc()->dump_addr_tree(); + log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + log(":io_port: "); _io_port_alloc()->dump_addr_tree(); + log(":irq: "); _irq_alloc()->dump_addr_tree(); + log(":rom_fs: "); _rom_fs.print_fs(); + log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); Fiasco::l4_threadid_t myself = Fiasco::l4_myself(); diff --git a/repos/base-fiasco/src/core/platform_pd.cc b/repos/base-fiasco/src/core/platform_pd.cc index 783a7c5cb..9442674ce 100644 --- a/repos/base-fiasco/src/core/platform_pd.cc +++ b/repos/base-fiasco/src/core/platform_pd.cc @@ -34,9 +34,6 @@ using namespace Fiasco; using namespace Genode; -static const bool verbose = false; - - /************************** ** Static class members ** **************************/ @@ -189,7 +186,7 @@ int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread) void Platform_pd::_free_thread(int thread_id) { if (!_threads[thread_id]) - PWRN("double-free of thread %x.%x detected", _pd_id, thread_id); + warning("double-free of thread ", Hex(_pd_id), ".", Hex(thread_id), " detected"); _threads[thread_id] = 0; } @@ -207,7 +204,7 @@ bool Platform_pd::bind_thread(Platform_thread *thread) int t = _alloc_thread(thread_id, thread); if (t < 0) { - PERR("thread alloc failed"); + error("thread alloc failed"); return false; } thread_id = t; @@ -218,7 +215,6 @@ bool Platform_pd::bind_thread(Platform_thread *thread) /* finally inform thread about binding */ thread->bind(thread_id, l4_thread_id, this); - if (verbose) _debug_log_threads(); return true; } @@ -231,8 +227,6 @@ void Platform_pd::unbind_thread(Platform_thread *thread) thread->unbind(); _free_thread(thread_id); - - if (verbose) _debug_log_threads(); } @@ -248,7 +242,6 @@ Platform_pd::Platform_pd(Allocator * md_alloc, char const *, int ret = _alloc_pd(pd_id); if (ret < 0) { - _debug_log_pds(); panic("pd alloc failed"); } @@ -268,27 +261,3 @@ Platform_pd::~Platform_pd() _free_pd(); } - -/*********************** - ** Debugging support ** - ***********************/ - -void Platform_pd::_debug_log_threads() -{ - int i; - printf("[%02x] ", _pd_id); - for (i = 0; i < THREAD_MAX; ++i) { - printf("%c", !_threads[i] ? '.' : 'X'); - if (i == 63) printf("\n "); - } - printf("\n"); -} - - -void Platform_pd::_debug_log_pds() -{ - int i; - for (i = 0; i < PD_MAX; ++i) - printf("[%02x] %d %d %d\n", i, _pds()[i].reserved, _pds()[i].free, - _pds()[i].version); -} diff --git a/repos/base-fiasco/src/core/platform_thread.cc b/repos/base-fiasco/src/core/platform_thread.cc index e1eeed7a5..5b7d2e13a 100644 --- a/repos/base-fiasco/src/core/platform_thread.cc +++ b/repos/base-fiasco/src/core/platform_thread.cc @@ -15,7 +15,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -52,7 +52,8 @@ int Platform_thread::start(void *ip, void *sp) &old_eflags, &dummy, &dummy, 0, l4_utcb_get()); if (old_eflags == ~0UL) - PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + warning("old eflags == ~0 on ex_regs ", + Hex(thread.id.task), ".", Hex(thread.id.lthread)); fiasco_register_thread_name(thread, _name); return 0; @@ -61,13 +62,13 @@ int Platform_thread::start(void *ip, void *sp) void Platform_thread::pause() { - PDBG("not implemented"); + warning(__func__, " not implemented"); } void Platform_thread::resume() { - PDBG("not implemented"); + warning(__func__, " not implemented"); } @@ -99,7 +100,8 @@ void Platform_thread::unbind() &old_eflags, &dummy, &dummy, 0, l4_utcb_get()); if (old_eflags == ~0UL) - PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + warning("old eflags == ~0 on ex_regs ", + Hex(thread.id.task), ".", Hex(thread.id.lthread)); _thread_id = THREAD_INVALID; _l4_thread_id = L4_INVALID_ID; @@ -109,7 +111,7 @@ void Platform_thread::unbind() void Platform_thread::state(Thread_state s) { - PDBG("Not implemented"); + warning(__func__, " not implemented"); throw Cpu_thread::State_access_failed(); } @@ -129,7 +131,8 @@ Thread_state Platform_thread::state() &old_eflags, &ip, &sp, L4_THREAD_EX_REGS_NO_CANCEL, l4_utcb_get()); if (old_eflags == ~0UL) - PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread); + warning("old eflags == ~0 on ex_regs ", + Hex(thread.id.task), ".", Hex(thread.id.lthread)); /* fill thread state structure */ s.ip = ip; diff --git a/repos/base-fiasco/src/lib/base/ipc.cc b/repos/base-fiasco/src/lib/base/ipc.cc index 6d5719b85..a176055a2 100644 --- a/repos/base-fiasco/src/lib/base/ipc.cc +++ b/repos/base-fiasco/src/lib/base/ipc.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include #include #include @@ -176,7 +175,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, if (L4_IPC_ERROR(ipc_result) == L4_IPC_RECANCELED) throw Genode::Blocking_canceled(); - PERR("ipc_call error %lx", L4_IPC_ERROR(ipc_result)); + error("ipc_call error ", Hex(L4_IPC_ERROR(ipc_result))); throw Genode::Ipc_error(); } @@ -204,7 +203,7 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc, L4_IPC_SEND_TIMEOUT_0, &result); if (L4_IPC_IS_ERROR(result)) - PERR("ipc_send error %lx, ignored", L4_IPC_ERROR(result)); + error("ipc_send error ", Hex(L4_IPC_ERROR(result)), ", ignored"); } @@ -251,7 +250,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, * incoming message. */ if (L4_IPC_IS_ERROR(ipc_result)) { - PERR("ipc_reply_and_wait error %lx", L4_IPC_ERROR(ipc_result)); + error("ipc_reply_and_wait error ", Hex(L4_IPC_ERROR(ipc_result))); } else { need_to_wait = false; } @@ -265,7 +264,7 @@ Genode::Rpc_request Genode::ipc_reply_wait(Reply_capability const &last_caller, L4_IPC_NEVER, &ipc_result); if (L4_IPC_IS_ERROR(ipc_result)) { - PERR("ipc_wait error %lx", L4_IPC_ERROR(ipc_result)); + error("ipc_wait error ", Hex(L4_IPC_ERROR(ipc_result))); } else { need_to_wait = false; } diff --git a/repos/base-foc/src/core/include/map_local.h b/repos/base-foc/src/core/include/map_local.h index f742cc7cc..74e22bf39 100644 --- a/repos/base-foc/src/core/include/map_local.h +++ b/repos/base-foc/src/core/include/map_local.h @@ -107,12 +107,12 @@ namespace Genode { l4_msgtag_t tag = l4_msgtag(L4_PROTO_SIGMA0, 2, 0, 0); tag = l4_ipc_call(L4_BASE_PAGER_CAP, l4_utcb(), tag, L4_IPC_NEVER); if (l4_ipc_error(tag, l4_utcb())) { - PERR("Ipc error %ld", l4_ipc_error(tag, l4_utcb())); + error("Ipc error ", l4_ipc_error(tag, l4_utcb())); return false; } if (l4_msgtag_items(tag) < 1) { - PERR("Got no mapping!"); + error("got no mapping!"); return false; } diff --git a/repos/base-foc/src/core/include/platform_pd.h b/repos/base-foc/src/core/include/platform_pd.h index 2fbcce33a..9a2dd8003 100644 --- a/repos/base-foc/src/core/include/platform_pd.h +++ b/repos/base-foc/src/core/include/platform_pd.h @@ -112,7 +112,7 @@ namespace Genode { * On Fiasco.OC, we don't use directed unmap but rely on the * in-kernel mapping database. See 'region_map_support.cc'. */ - void flush(addr_t, size_t) { PDBG("not implemented"); } + void flush(addr_t, size_t) { warning(__func__, " not implemented"); } }; } diff --git a/repos/base-foc/src/core/io_mem_session_support.cc b/repos/base-foc/src/core/io_mem_session_support.cc index cc82bbf83..f7b5cbd3f 100644 --- a/repos/base-foc/src/core/io_mem_session_support.cc +++ b/repos/base-foc/src/core/io_mem_session_support.cc @@ -39,7 +39,7 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) return 0; if (!map_local_io(base, (addr_t)local_base, size >> get_page_size_log2())) { - PERR("map_local_io failed\n"); + error("map_local_io failed"); return 0; } diff --git a/repos/base-foc/src/core/ipc_pager.cc b/repos/base-foc/src/core/ipc_pager.cc index 3f2abc5fa..2b041bb0b 100644 --- a/repos/base-foc/src/core/ipc_pager.cc +++ b/repos/base-foc/src/core/ipc_pager.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -82,7 +82,7 @@ void Ipc_pager::wait_for_fault() _parse(label); return; } - PERR("Ipc error %d in pagefault from %lx", err, label & ~0x3); + error("Ipc error ", err, " in pagefault from ", Hex(label & ~0x3)); } while (true); } @@ -115,7 +115,7 @@ void Ipc_pager::reply_and_wait_for_fault() &label, L4_IPC_SEND_TIMEOUT_0); int err = l4_ipc_error(_tag, l4_utcb()); if (err) { - PERR("Ipc error %d in pagefault from %lx", err, label & ~0x3); + error("Ipc error ", err, " in pagefault from ", Hex(label & ~0x3)); wait_for_fault(); } else _parse(label); diff --git a/repos/base-foc/src/core/irq_session_component.cc b/repos/base-foc/src/core/irq_session_component.cc index b48e18b3d..f03dcd187 100644 --- a/repos/base-foc/src/core/irq_session_component.cc +++ b/repos/base-foc/src/core/irq_session_component.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -100,9 +100,8 @@ bool Genode::Irq_object::associate(unsigned irq, bool msi, _polarity = polarity; using namespace Fiasco; - if (l4_error(l4_factory_create_irq(L4_BASE_FACTORY_CAP, - _capability()))) { - PERR("l4_factory_create_irq failed!"); + if (l4_error(l4_factory_create_irq(L4_BASE_FACTORY_CAP, _capability()))) { + error("l4_factory_create_irq failed!"); return false; } @@ -111,7 +110,7 @@ bool Genode::Irq_object::associate(unsigned irq, bool msi, gsi |= L4_ICU_FLAG_MSI; if (l4_error(l4_icu_bind(L4_BASE_ICU_CAP, gsi, _capability()))) { - PERR("Binding IRQ %u to the ICU failed", _irq); + error("Binding IRQ ", _irq, " to the ICU failed"); return false; } @@ -121,13 +120,13 @@ bool Genode::Irq_object::associate(unsigned irq, bool msi, if (l4_error(l4_irq_attach(_capability(), reinterpret_cast(this), Interrupt_handler::handler_cap()))) { - PERR("Error attaching to IRQ %u", _irq); + error("cannot attach to IRQ ", _irq); return false; } if (_msi_addr && l4_error(l4_icu_msi_info(L4_BASE_ICU_CAP, gsi, &_msi_data))) { - PERR("Error getting MSI info"); + error("cannot get MSI info"); return false; } @@ -142,7 +141,7 @@ void Genode::Irq_object::ack_irq() int err; l4_msgtag_t tag = l4_irq_unmask(_capability()); if ((err = l4_ipc_error(tag, l4_utcb()))) - PERR("IRQ unmask: %d\n", err); + error("IRQ unmask: ", err); } @@ -167,10 +166,10 @@ Genode::Irq_object::~Irq_object() gsi |= L4_ICU_FLAG_MSI; if (l4_error(l4_irq_detach(_capability()))) - PERR("Error detaching IRQ"); + error("cannot detach IRQ"); if (l4_error(l4_icu_unbind(L4_BASE_ICU_CAP, gsi, _capability()))) - PERR("Error unbinding IRQ"); + error("cannot unbind IRQ"); cap_map()->remove(_cap); } @@ -191,13 +190,13 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, long msi = Arg_string::find_arg(args, "device_config_phys").long_value(0); if (msi) { if (msi_alloc.get(irq_args.irq_number(), 1)) { - PERR("Unavailable MSI %ld requested.", irq_args.irq_number()); + error("unavailable MSI ", irq_args.irq_number(), " requested"); throw Root::Unavailable(); } msi_alloc.set(irq_args.irq_number(), 1); } else { if (!irq_alloc || irq_alloc->alloc_addr(1, irq_args.irq_number()).error()) { - PERR("Unavailable IRQ %ld requested.", irq_args.irq_number()); + error("unavailable IRQ ", irq_args.irq_number(), " requested"); throw Root::Unavailable(); } } @@ -263,7 +262,7 @@ void Interrupt_handler::entry() while (true) { tag = l4_ipc_wait(l4_utcb(), &label, L4_IPC_NEVER); if ((err = l4_ipc_error(tag, l4_utcb()))) - PERR("IRQ receive: %d\n", err); + error("IRQ receive: ", err); else { Irq_object * irq_object = reinterpret_cast(label); irq_object->notify(); diff --git a/repos/base-foc/src/core/pager.cc b/repos/base-foc/src/core/pager.cc index eb6f521e5..b998bc5a4 100644 --- a/repos/base-foc/src/core/pager.cc +++ b/repos/base-foc/src/core/pager.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include -#include +#include #include /* core includes */ @@ -48,12 +48,12 @@ void Pager_entrypoint::entry() apply(_pager.badge(), [&] (Pager_object *obj) { /* the pager_object might be destroyed, while we got the message */ if (!obj) { - PWRN("No pager object found!"); + warning("no pager object found!"); return; } switch (_pager.msg_type()) { - + case Ipc_pager::PAGEFAULT: case Ipc_pager::EXCEPTION: { @@ -69,8 +69,9 @@ void Pager_entrypoint::entry() /* handle request */ if (obj->pager(_pager)) { /* could not resolv - leave thread in pagefault */ - PDBG("Could not resolve pf=%p ip=%p", - (void*)_pager.fault_addr(), (void*)_pager.fault_ip()); + warning("could not resolve " + "pf=", Hex(_pager.fault_addr()), " ", + "ip=", Hex(_pager.fault_ip())); } else { _pager.set_reply_dst(Native_thread(obj->badge())); reply_pending = true; @@ -131,7 +132,7 @@ void Pager_entrypoint::entry() } default: - PERR("Got unknown message type %x!", _pager.msg_type()); + error("got unknown message type ", Hex(_pager.msg_type())); } }); }; diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index 1dbac6c97..f9f470579 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -21,6 +21,7 @@ /* base-internal includes */ #include #include +#include /* core includes */ #include @@ -47,11 +48,6 @@ static l4_kernel_info_t *kip; using namespace Genode; -static const bool verbose = true; -static const bool verbose_core_pf = false; -static const bool verbose_region_alloc = false; - - /*********************************** ** Core address space management ** ***********************************/ @@ -90,7 +86,7 @@ static void _core_pager_loop() tag = l4_ipc_wait(utcb, &label, L4_IPC_NEVER); if (!tag.is_page_fault()) { - PWRN("Received something different than a pagefault, ignoring ..."); + warning("received something different than a pagefault, ignoring ..."); continue; } @@ -102,21 +98,20 @@ static void _core_pager_loop() if (pfa < (l4_umword_t)L4_PAGESIZE) { /* NULL pointer access */ - PERR("Possible null pointer %s at %lx IP %lx", - rw ? "WRITE" : "READ", pfa, ip); + error("Possible null pointer ", rw ? "WRITE" : "READ", " " + "at ", Hex(pfa), " IP ", Hex(ip)); /* do not unblock faulter */ send_reply = false; continue; } else if (!_core_address_ranges().valid_addr(pfa)) { /* page-fault address is not in RAM */ - PERR("%s access outside of RAM at %lx IP %lx", - rw ? "WRITE" : "READ", pfa, ip); + error(rw ? "WRITE" : "READ", " access outside of RAM " + "at ", Hex(pfa), " IP ", Hex(ip)); /* do not unblock faulter */ send_reply = false; continue; - } else if (verbose_core_pf) - PDBG("pfa=%lx ip=%lx", pfa, ip); + } /* my pf handler is sigma0 - just touch the appropriate page */ if (rw) @@ -162,7 +157,7 @@ Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0) l4_thread_control_exc_handler(thread().local.data()->kcap()); l4_msgtag_t tag = l4_thread_control_commit(L4_BASE_THREAD_CAP); if (l4_msgtag_has_error(tag)) - PWRN("l4_thread_control_commit failed!"); + warning("l4_thread_control_commit failed!"); } @@ -195,24 +190,11 @@ struct Region }; -/** - * Log region - */ -static inline void print_region(Region r) -{ - printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start); -} - - /** * Add region to allocator */ static inline void add_region(Region r, Range_allocator &alloc) { - if (verbose_region_alloc) { - printf("%p add: ", &alloc); print_region(r); printf("\n"); - } - /* adjust region */ addr_t start = trunc_page(r.start); addr_t end = round_page(r.end); @@ -226,10 +208,6 @@ static inline void add_region(Region r, Range_allocator &alloc) */ static inline void remove_region(Region r, Range_allocator &alloc) { - if (verbose_region_alloc) { - printf("%p remove: ", &alloc); print_region(r); printf("\n"); - } - /* adjust region */ addr_t start = trunc_page(r.start); addr_t end = round_page(r.end); @@ -366,15 +344,10 @@ void Platform::_setup_basics() if (kip->magic != L4_KERNEL_INFO_MAGIC) panic("Sigma0 mapped something but not the KIP"); - if (verbose) { - printf("\n"); - printf("KIP @ %p\n", kip); - printf(" magic: %08zx\n", (size_t)kip->magic); - printf(" version: %08zx\n", (size_t)kip->version); - printf(" sigma0 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma0_esp, kip->sigma0_eip); - printf(" sigma1 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma1_esp, kip->sigma1_eip); - printf(" root "); printf(" esp: %08lx eip: %08lx\n", kip->root_esp, kip->root_eip); - } + log(""); + log("KIP @ ", kip); + log(" magic: ", Hex(kip->magic)); + log(" version: ", Hex(kip->version)); /* add KIP as ROM module */ _kip_rom = Rom_module((addr_t)kip, L4_PAGESIZE, "l4v2_kip"); @@ -382,7 +355,7 @@ void Platform::_setup_basics() /* update multi-boot info pointer from KIP */ addr_t mb_info_addr = kip->user_ptr; - if (verbose) printf("MBI @ %lx\n", mb_info_addr); + log("MBI @ ", Hex(mb_info_addr)); /* parse memory descriptors - look for virtual memory configuration */ /* XXX we support only one VM region (here and also inside RM) */ @@ -447,11 +420,6 @@ void Platform::_setup_rom() /* map module */ touch_ro((const void*)new_rom->addr(), new_rom->size()); - if (verbose) - printf(" mod[%d] [%p,%p) %s\n", i, - (void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(), - new_rom->name()); - /* zero remainder of last ROM page */ size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE; if (count != L4_PAGESIZE) @@ -485,21 +453,21 @@ Platform::Platform() : if (initialized) panic("Platform constructed twice!"); initialized = true; + init_log(); + _setup_basics(); _setup_mem_alloc(); _setup_io_port_alloc(); _setup_irq_alloc(); _setup_rom(); - if (verbose) { - printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); - printf(":irq: "); _irq_alloc()->dump_addr_tree(); - printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); - } + log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + log(":region_alloc: "); _region_alloc()->dump_addr_tree(); + log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + log(":io_port: "); _io_port_alloc()->dump_addr_tree(); + log(":irq: "); _irq_alloc()->dump_addr_tree(); + log(":rom_fs: "); _rom_fs.print_fs(); + log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); Core_cap_index* pdi = reinterpret_cast(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_TASK_CAP)); @@ -546,7 +514,7 @@ Affinity::Space Platform::affinity_space() const l4_msgtag_t res = l4_scheduler_info(L4_BASE_SCHEDULER_CAP, &cpus_max, &cpus); if (l4_error(res)) { - PERR("could not detect number of CPUs - assuming 1 CPU"); + error("could not detect number of CPUs - assuming 1 CPU"); return 1; } diff --git a/repos/base-foc/src/core/platform_pd.cc b/repos/base-foc/src/core/platform_pd.cc index c80b80961..c675f0e6a 100644 --- a/repos/base-foc/src/core/platform_pd.cc +++ b/repos/base-foc/src/core/platform_pd.cc @@ -77,7 +77,7 @@ bool Platform_pd::bind_thread(Platform_thread *thread) return true; } - PERR("thread alloc failed"); + error("thread alloc failed"); return false; } @@ -124,7 +124,7 @@ Platform_pd::Platform_pd(Allocator *, char const *) l4_msgtag_t tag = l4_factory_create_task(L4_BASE_FACTORY_CAP, _task.local.data()->kcap(), utcb_area); if (l4_msgtag_has_error(tag)) - PERR("pd creation failed"); + error("pd creation failed"); } diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc index aea50d2b2..47e664a87 100644 --- a/repos/base-foc/src/core/platform_thread.cc +++ b/repos/base-foc/src/core/platform_thread.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* core includes */ @@ -241,7 +241,7 @@ void Platform_thread::_create_thread() l4_msgtag_t tag = l4_factory_create_thread(L4_BASE_FACTORY_CAP, _thread.local.data()->kcap()); if (l4_msgtag_has_error(tag)) - PERR("cannot create more thread kernel-objects!"); + error("cannot create more thread kernel-objects!"); /* create initial gate for thread */ _gate.local = thread_cap_factory().alloc(_thread.local); diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc index cce7ab30f..5ec9ed53a 100644 --- a/repos/base-foc/src/core/rpc_cap_factory.cc +++ b/repos/base-foc/src/core/rpc_cap_factory.cc @@ -71,7 +71,7 @@ void Cap_mapping::map(Fiasco::l4_cap_idx_t task) l4_obj_fpage(local.data()->kcap(), 0, L4_FPAGE_RWX), ((l4_cap_idx_t)remote) | L4_ITEM_MAP); if (l4_msgtag_has_error(tag)) - PERR("mapping cap failed"); + error("mapping cap failed"); } @@ -119,7 +119,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep) idx->kcap(), ref->pt()->thread().local.data()->kcap(), id); if (l4_msgtag_has_error(tag)) { - PERR("l4_factory_create_gate failed!"); + error("l4_factory_create_gate failed!"); cap_map()->remove(idx); platform_specific()->cap_id_alloc()->free(id); return cap; @@ -132,7 +132,7 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep) idx->pt(ref->pt()); cap = Native_capability(*idx); } catch (Cap_id_allocator::Out_of_ids) { - PERR("Out of capability ids"); + error("out of capability IDs"); } /* @@ -224,7 +224,7 @@ void Genode::Capability_map::remove(Genode::Cap_index* i) l4_obj_fpage(i->kcap(), 0, L4_FPAGE_RWX), L4_FP_ALL_SPACES | L4_FP_DELETE_OBJ); if (l4_msgtag_has_error(tag)) - PERR("destruction of ipc-gate %lx failed!", (unsigned long) i->kcap()); + error("destruction of ipc-gate ", i->kcap(), " failed!"); platform_specific()->cap_id_alloc()->free(i->id()); diff --git a/repos/base-foc/src/core/signal_source_component.cc b/repos/base-foc/src/core/signal_source_component.cc index 8ec92bd49..2c9b17c00 100644 --- a/repos/base-foc/src/core/signal_source_component.cc +++ b/repos/base-foc/src/core/signal_source_component.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -56,7 +56,7 @@ void Signal_source_component::submit(Signal_context_component *context, Signal_source::Signal Signal_source_component::wait_for_signal() { if (_signal_queue.empty()) { - PWRN("unexpected call of wait_for_signal"); + warning("unexpected call of wait_for_signal"); return Signal(0, 0); } @@ -79,7 +79,7 @@ Signal_source_component::Signal_source_component(Rpc_entrypoint *ep) l4_msgtag_t res = l4_factory_create_irq(L4_BASE_FACTORY_CAP, _blocking_semaphore.data()->kcap()); if (l4_error(res)) - PERR("Allocation of irq object failed!"); + error("Allocation of irq object failed!"); } diff --git a/repos/base-foc/src/core/spec/x86/platform.cc b/repos/base-foc/src/core/spec/x86/platform.cc index 6f0691d30..3694fc094 100644 --- a/repos/base-foc/src/core/spec/x86/platform.cc +++ b/repos/base-foc/src/core/spec/x86/platform.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include "platform.h" @@ -84,5 +84,5 @@ void Genode::Platform::setup_irq_mode(unsigned irq_number, unsigned trigger, * Set mode */ if (l4_error(l4_icu_set_mode(L4_BASE_ICU_CAP, irq_number, mode))) - PERR("Setting mode for IRQ%u failed", irq_number); + error("setting mode for IRQ ", irq_number, " failed"); } diff --git a/repos/base-foc/src/test/cap_integrity/main.cc b/repos/base-foc/src/test/cap_integrity/main.cc index 761a23ad3..868c8b739 100644 --- a/repos/base-foc/src/test/cap_integrity/main.cc +++ b/repos/base-foc/src/test/cap_integrity/main.cc @@ -15,6 +15,7 @@ /* Genode includes */ #include +#include #include #include @@ -26,7 +27,7 @@ using namespace Fiasco; int main(int argc, char **argv) { - printf("--- capability integrity test ---\n"); + log("--- capability integrity test ---"); enum { COUNT = 1000 }; @@ -48,6 +49,6 @@ int main(int argc, char **argv) } catch(...) { } } - printf("--- finished capability integrity test ---\n"); + log("--- finished capability integrity test ---"); return 0; } diff --git a/repos/base-hw/src/base/muen/sinfo.cc b/repos/base-hw/src/base/muen/sinfo.cc index 1d989b097..61c7feefe 100644 --- a/repos/base-hw/src/base/muen/sinfo.cc +++ b/repos/base-hw/src/base/muen/sinfo.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -24,16 +24,16 @@ static bool log_channel( void *data) { if (channel->has_event || channel->has_vector) { - PDBG("muen-sinfo: [%s with %s %03d] %s\n", - channel->writable ? "writer" : "reader", - channel->has_event ? "event " : "vector", - channel->has_event ? channel->event_number : channel->vector, - channel->name); + Genode::log("muen-sinfo: [", + channel->writable ? "writer" : "reader", " with ", + channel->has_event ? "event " : "vector", " ", + channel->has_event ? channel->event_number : channel->vector, + "] ", channel->name); } else { - PDBG("muen-sinfo: [%s with no %s ] %s\n", - channel->writable ? "writer" : "reader", - channel->writable ? "event " : "vector", - channel->name); + Genode::log("muen-sinfo: [", + channel->writable ? "writer" : "reader", " with no ", + channel->writable ? "event " : "vector", " ", + "] ", channel->name); } return true; @@ -41,14 +41,14 @@ static bool log_channel( /* Log memory region information */ -static bool log_memregion( - const struct Genode::Sinfo::Memregion_info * const region, - void *data) +static bool log_memregion(const struct Genode::Sinfo::Memregion_info * const region, + void *data) { - PDBG("muen-sinfo: [addr 0x%016llx size 0x%016llx %s%s] %s\n", - region->address, region->size, - region->writable ? "rw" : "ro", - region->executable ? "x" : "-", region->name); + Genode::log("muen-sinfo: [addr ", Genode::Hex(region->address), " " + "size ", Genode::Hex(region->size), " ", + region->writable ? "rw" : "ro", + region->executable ? "x" : "-", + "] ", region->name); return true; } @@ -72,7 +72,7 @@ Sinfo::Sinfo(const addr_t base_addr) sinfo = ((subject_info_type *)base_addr); if (!check_magic()) { - PERR("muen-sinfo: Subject information MAGIC mismatch\n"); + Genode::error("muen-sinfo: Subject information MAGIC mismatch"); return; } } @@ -207,19 +207,19 @@ uint64_t Sinfo::get_sched_end(void) void Sinfo::log_status() { if (!sinfo) { - PINF("Sinfo API not initialized"); + Genode::log("Sinfo API not initialized"); return; } if (!check_magic()) { - PINF("Sinfo MAGIC not found"); + Genode::log("Sinfo MAGIC not found"); return; } - PINF("muen-sinfo: Subject information exports %d memory region(s)\n", - sinfo->memregion_count); + Genode::log("muen-sinfo: Subject information exports ", + sinfo->memregion_count, " memory region(s)"); for_each_memregion(log_memregion, 0); - PINF("muen-sinfo: Subject information exports %d channel(s)\n", - sinfo->channel_info_count); + Genode::log("muen-sinfo: Subject information exports ", + sinfo->channel_info_count, " channel(s)"); for_each_channel(log_channel, 0); } diff --git a/repos/base-hw/src/core/core_region_map.cc b/repos/base-hw/src/core/core_region_map.cc index 62e8bdac8..dee1c9e00 100644 --- a/repos/base-hw/src/core/core_region_map.cc +++ b/repos/base-hw/src/core/core_region_map.cc @@ -38,12 +38,12 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask(); if (use_local_addr) { - PERR("Parameter 'use_local_addr' not supported within core"); + error("Parameter 'use_local_addr' not supported within core"); return nullptr; } if (offset) { - PERR("Parameter 'offset' not supported within core"); + error("Parameter 'offset' not supported within core"); return nullptr; } @@ -52,8 +52,8 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, if (!platform()->region_alloc()->alloc_aligned(page_rounded_size, &virt_addr, get_page_size_log2()).ok()) { - PERR("Could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return nullptr; } diff --git a/repos/base-hw/src/core/include/assert.h b/repos/base-hw/src/core/include/assert.h index cb6419784..25057842b 100644 --- a/repos/base-hw/src/core/include/assert.h +++ b/repos/base-hw/src/core/include/assert.h @@ -15,7 +15,7 @@ #define _CORE__INCLUDE__ASSERT_H_ /* Genode includes */ -#include +#include /** * Suppress assertions in release version @@ -43,9 +43,9 @@ do { \ if (DO_ASSERT) { \ if (!(expression)) { \ - PERR("Assertion failed: "#expression""); \ - PERR(" File: %s:%d", __FILE__, __LINE__); \ - PERR(" Function: %s", __PRETTY_FUNCTION__); \ + Genode::error("Assertion failed: "#expression""); \ + Genode::error(" File: ", __FILE__, ":", __LINE__); \ + Genode::error(" Function: ", __PRETTY_FUNCTION__); \ while (1) ; \ } \ } \ diff --git a/repos/base-hw/src/core/include/cpu_thread_allocator.h b/repos/base-hw/src/core/include/cpu_thread_allocator.h index c30eee1e3..4fae23b33 100644 --- a/repos/base-hw/src/core/include/cpu_thread_allocator.h +++ b/repos/base-hw/src/core/include/cpu_thread_allocator.h @@ -14,7 +14,7 @@ #ifndef _CORE__INCLUDE__CPU_THREAD_ALLOCATOR_H_ #define _CORE__INCLUDE__CPU_THREAD_ALLOCATOR_H_ -#include +#include #include namespace Genode @@ -49,14 +49,16 @@ namespace Genode void free(void *addr, size_t size) override { _alloc->free(addr, size); } - size_t consumed() const override { - PDBG("Unexpected call"); + size_t consumed() const override + { + warning(__func__, "unexpectedly called"); while (1) ; return 0; } - size_t overhead(size_t size) const override { - PDBG("Unexpected call"); + size_t overhead(size_t size) const override + { + warning(__func__, "unexpectedly called"); while (1) ; return 0; } diff --git a/repos/base-hw/src/core/include/signal_broker.h b/repos/base-hw/src/core/include/signal_broker.h index 4ee20657d..af8c161c8 100644 --- a/repos/base-hw/src/core/include/signal_broker.h +++ b/repos/base-hw/src/core/include/signal_broker.h @@ -81,7 +81,7 @@ class Genode::Signal_broker auto lambda = [&] (Signal_source_component *s) { if (!s) { - PERR("unknown signal source"); + error("unknown signal source"); return; } @@ -104,7 +104,7 @@ class Genode::Signal_broker { auto lambda = [&] (Signal_source_component *s) { if (!s) { - PERR("unknown signal source"); + error("unknown signal source"); throw Invalid_signal_source(); } @@ -124,7 +124,7 @@ class Genode::Signal_broker auto lambda = [&] (Signal_context_component *c) { if (!c) { - PERR("unknown signal context"); + error("unknown signal context"); return; } diff --git a/repos/base-hw/src/core/include/spec/riscv/translation_table.h b/repos/base-hw/src/core/include/spec/riscv/translation_table.h index 4d95c7ce2..d1c24d011 100644 --- a/repos/base-hw/src/core/include/spec/riscv/translation_table.h +++ b/repos/base-hw/src/core/include/spec/riscv/translation_table.h @@ -1,4 +1,4 @@ -/** +/* * \brief RISCV Sv39 page table format * \author Sebastian Sumpf * \date 2015-08-04 @@ -17,6 +17,7 @@ /* Genode includes */ #include #include +#include /* Core includes */ #include @@ -175,7 +176,7 @@ class Sv39::Level_x_translation_table /* sanity check vo bits 38 to 63 must be equal */ addr_t sanity = vo >> 38; if (sanity != 0 && sanity != 0x3ffffff) { - PERR("Invalid virtual address: %lx", vo); + Genode::error("invalid virtual address: ", vo); throw Invalid_range(); } @@ -302,7 +303,7 @@ class Sv39::Level_x_translation_table Level_x_translation_table() { if (!_aligned((addr_t)this, ALIGNM_LOG2)) { - PWRN("misaligned address"); + Genode::warning("misaligned address"); throw Misaligned(); } @@ -371,7 +372,7 @@ namespace Sv39 { { if ((vo & ~BLOCK_MASK) || (pa & ~BLOCK_MASK) || size < BLOCK_SIZE) { - PWRN("invalid range"); + Genode::warning("invalid range"); throw Invalid_range(); } diff --git a/repos/base-hw/src/core/include/spec/rpi/pic.h b/repos/base-hw/src/core/include/spec/rpi/pic.h index d86d458eb..354e8500d 100644 --- a/repos/base-hw/src/core/include/spec/rpi/pic.h +++ b/repos/base-hw/src/core/include/spec/rpi/pic.h @@ -15,6 +15,7 @@ #define _CORE__INCLUDE__SPEC__RPI__PIC_H_ /* Genode includes */ +#include #include /* core includes */ @@ -101,7 +102,7 @@ class Genode::Usb_dwc_otg : Mmio stat_cnt++; if (stat_cnt == 8000) { - PLOG("kicked: %d filtered: %d triggered: %d", kick_cnt, filter_cnt, trigger_cnt); + log("kicked: ", kick_cnt, " filtered: ", filter_cnt, " triggered: ", trigger_cnt); stat_cnt = 0; } diff --git a/repos/base-hw/src/core/include/spec/x86_64/muen/board.h b/repos/base-hw/src/core/include/spec/x86_64/muen/board.h index 406591874..1efb08902 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/muen/board.h +++ b/repos/base-hw/src/core/include/spec/x86_64/muen/board.h @@ -14,6 +14,8 @@ #ifndef _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_ #define _CORE__INCLUDE__SPEC__X86_64__MUEN__BOARD_H_ +#include + namespace Genode { struct Board @@ -31,7 +33,7 @@ namespace Genode TIMER_VECTOR_USER = 50, }; - void init() { } + void init() { Genode::init_log(); } }; } diff --git a/repos/base-hw/src/core/include/spec/x86_64/muen/timer.h b/repos/base-hw/src/core/include/spec/x86_64/muen/timer.h index 17064e431..bf38e967a 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/muen/timer.h +++ b/repos/base-hw/src/core/include/spec/x86_64/muen/timer.h @@ -15,7 +15,7 @@ #define _CORE__INCLUDE__SPEC__X86_64__MUEN__TIMER_H_ /* base includes */ -#include +#include #include /* core includes */ @@ -70,18 +70,19 @@ class Genode::Timer struct Sinfo::Memregion_info region; if (!sinfo()->get_memregion_info("timed_event", ®ion)) { - PERR("muen-timer: Unable to retrieve timed event region"); + error("muen-timer: Unable to retrieve timed event region"); throw Invalid_region(); } _event_page = (Subject_timed_event *)region.address; _event_page->event_nr = Board::TIMER_EVENT_KERNEL; - PINF("muen-timer: Page @0x%llx, frequency %llu kHz, event %u", - region.address, _tics_per_ms, _event_page->event_nr); + log("muen-timer: Page @", Hex(region.address), ", " + "frequency ", _tics_per_ms, " kHz, " + "event ", (unsigned)_event_page->event_nr); if (sinfo()->get_memregion_info("monitor_timed_event", ®ion)) { - PINF("muen-timer: Found guest timed event page @0x%llx" - " -> enabling preemption", region.address); + log("muen-timer: Found guest timed event page @", Hex(region.address), + " -> enabling preemption"); _guest_event_page = (Subject_timed_event *)region.address; _guest_event_page->event_nr = Board::TIMER_EVENT_PREEMPT; } diff --git a/repos/base-hw/src/core/include/vm_root.h b/repos/base-hw/src/core/include/vm_root.h index 09f0551a4..d7497b043 100644 --- a/repos/base-hw/src/core/include/vm_root.h +++ b/repos/base-hw/src/core/include/vm_root.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include /* core includes */ #include diff --git a/repos/base-hw/src/core/irq_session_component.cc b/repos/base-hw/src/core/irq_session_component.cc index 6a6ec421f..5ba0f2790 100644 --- a/repos/base-hw/src/core/irq_session_component.cc +++ b/repos/base-hw/src/core/irq_session_component.cc @@ -45,7 +45,7 @@ void Irq_session_component::ack_irq() void Irq_session_component::sigh(Signal_context_capability cap) { if (_sig_cap.valid()) { - PWRN("signal handler already registered for IRQ %u", _irq_number); + warning("signal handler already registered for IRQ ", _irq_number); return; } @@ -53,7 +53,7 @@ void Irq_session_component::sigh(Signal_context_capability cap) if (Kernel::new_irq((addr_t)&_kernel_object, _irq_number, Capability_space::capid(_sig_cap))) - PWRN("invalid signal handler for IRQ %u", _irq_number); + warning("invalid signal handler for IRQ ", _irq_number); } @@ -86,7 +86,7 @@ Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc, /* allocate interrupt */ if (_irq_alloc->alloc_addr(1, _irq_number).error()) { - PERR("unavailable interrupt %d requested", _irq_number); + error("unavailable interrupt ", _irq_number, " requested"); throw Root::Invalid_args(); } diff --git a/repos/base-hw/src/core/kernel/clock.cc b/repos/base-hw/src/core/kernel/clock.cc index f6ddcf841..fd048963f 100644 --- a/repos/base-hw/src/core/kernel/clock.cc +++ b/repos/base-hw/src/core/kernel/clock.cc @@ -79,7 +79,6 @@ time_t Clock::update_time() /* update time */ time_t const old_value = _last_timeout_duration; time_t const new_value = _timer->value(_cpu_id); -// PERR("%lu %lu", old_value, new_value); time_t const duration = old_value > new_value ? old_value - new_value : 1; _time += duration; return duration; diff --git a/repos/base-hw/src/core/kernel/cpu_scheduler.cc b/repos/base-hw/src/core/kernel/cpu_scheduler.cc index 3d27302ce..d918bb0f6 100644 --- a/repos/base-hw/src/core/kernel/cpu_scheduler.cc +++ b/repos/base-hw/src/core/kernel/cpu_scheduler.cc @@ -11,6 +11,9 @@ * under the terms of the GNU General Public License version 2. */ +/* Genode includes */ +#include + /* core includes */ #include #include @@ -189,7 +192,7 @@ void Cpu_scheduler::remove(Share * const s) * */ if (s == _head) { - PERR("Removing the head of the CPU scheduler isn't supported by now."); + Genode::error("Removing the head of the CPU scheduler isn't supported by now."); while (1) ; } if (s->_ready) { _fills.remove(s); } diff --git a/repos/base-hw/src/core/kernel/ipc_node.cc b/repos/base-hw/src/core/kernel/ipc_node.cc index 869c55957..45bad4fdc 100644 --- a/repos/base-hw/src/core/kernel/ipc_node.cc +++ b/repos/base-hw/src/core/kernel/ipc_node.cc @@ -176,7 +176,7 @@ void Ipc_node::send_request(Ipc_node * const callee, capid_t capid, bool help, unsigned rcv_caps) { if (_state != INACTIVE) { - PERR("IPC send request: bad state"); + Genode::error("IPC send request: bad state"); return; } Genode::Allocator &slab = pd()->platform_pd()->capability_slab(); @@ -202,8 +202,8 @@ Ipc_node * Ipc_node::helping_sink() { bool Ipc_node::await_request(unsigned rcv_caps) { - if (_state != INACTIVE) { - PERR("IPC await request: bad state"); + if (_state != INACTIVE) { + Genode::error("IPC await request: bad state"); return true; } Genode::Allocator &slab = pd()->platform_pd()->capability_slab(); diff --git a/repos/base-hw/src/core/kernel/pd.cc b/repos/base-hw/src/core/kernel/pd.cc index ae09dcfb1..fbeb7fa08 100644 --- a/repos/base-hw/src/core/kernel/pd.cc +++ b/repos/base-hw/src/core/kernel/pd.cc @@ -14,6 +14,7 @@ /* core includes */ #include +#include #include /* Genode includes */ @@ -62,7 +63,7 @@ void Mode_transition_control::map(Genode::Translation_table * tt, tt->insert_translation(Genode::trunc_page(VIRT_BASE), phys_base, SIZE, Genode::Page_flags::mode_transition(), alloc); } catch(...) { - PERR("Inserting exception vector in page table failed!"); } + Genode::error("inserting exception vector in page table failed!"); } } diff --git a/repos/base-hw/src/core/pager.cc b/repos/base-hw/src/core/pager.cc index b108be7b3..30b9eed70 100644 --- a/repos/base-hw/src/core/pager.cc +++ b/repos/base-hw/src/core/pager.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes*/ #include @@ -86,9 +86,10 @@ void Pager_object::unresolved_page_fault_occurred() { Platform_thread * const pt = (Platform_thread *)badge(); if (pt && pt->pd()) - PERR("%s -> %s: unresolved pagefault at ip=%lx sp=%lx fault address=%lx", - pt->pd()->label(), pt->label(), pt->kernel_object()->ip, - pt->kernel_object()->sp, pt->kernel_object()->fault_addr()); + error(pt->pd()->label(), " -> ", pt->label(), ": unresolved pagefault at " + "ip=", pt->kernel_object()->ip, " " + "sp=", pt->kernel_object()->sp, " " + "fault address=", pt->kernel_object()->fault_addr()); } Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index ce650d5fa..a06c6594f 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -200,7 +200,7 @@ Platform::Platform() void Core_parent::exit(int exit_value) { - log(__PRETTY_FUNCTION__, "not implemented"); + warning(__PRETTY_FUNCTION__, "not implemented"); while (1); } diff --git a/repos/base-hw/src/core/platform_pd.cc b/repos/base-hw/src/core/platform_pd.cc index c2c473d8c..90755d94e 100644 --- a/repos/base-hw/src/core/platform_pd.cc +++ b/repos/base-hw/src/core/platform_pd.cc @@ -58,7 +58,7 @@ bool Hw::Address_space::insert_translation(addr_t virt, addr_t phys, } } } catch(...) { - PERR("Invalid mapping %p -> %p (%zx)", (void*)phys, (void*)virt, size); + error("invalid mapping ", Hex(phys), " -> ", Hex(virt), " (", size, ")"); } return false; } @@ -74,7 +74,7 @@ void Hw::Address_space::flush(addr_t virt, size_t size) /* update translation caches */ Kernel::update_pd(_kernel_pd); } catch(...) { - PERR("tried to remove invalid region!"); + error("tried to remove invalid region!"); } } @@ -164,7 +164,7 @@ Platform_pd::Platform_pd(Allocator * md_alloc, char const *label) _label(label) { if (!_cap.valid()) { - PERR("failed to create kernel object"); + error("failed to create kernel object"); throw Root::Unavailable(); } } @@ -216,10 +216,9 @@ void Core_platform_pd::_map(addr_t start, addr_t end, bool io_mem) try { _table()->insert_translation(start, start, size, flags, _table_alloc()); } catch(Allocator::Out_of_memory) { - PERR("Translation table needs to much RAM"); + error("translation table needs to much RAM"); } catch(...) { - PERR("Invalid mapping %p -> %p (%zx)", (void*)start, - (void*)start, size); + error("invalid mapping ", Hex(start), " size=", size); } } diff --git a/repos/base-hw/src/core/platform_thread.cc b/repos/base-hw/src/core/platform_thread.cc index 78e5a99c1..92600c63e 100644 --- a/repos/base-hw/src/core/platform_thread.cc +++ b/repos/base-hw/src/core/platform_thread.cc @@ -69,7 +69,7 @@ Platform_thread::Platform_thread(const char * const label, /* create UTCB for a core thread */ void *utcb_phys; if (!platform()->ram_alloc()->alloc(sizeof(Native_utcb), &utcb_phys)) { - PERR("failed to allocate UTCB"); + error("failed to allocate UTCB"); throw Cpu_session::Out_of_metadata(); } map_local((addr_t)utcb_phys, (addr_t)_utcb_core_addr, @@ -94,7 +94,7 @@ Platform_thread::Platform_thread(size_t const quota, _utcb = core_env()->ram_session()->alloc(sizeof(Native_utcb), CACHED); } catch (...) { - PERR("failed to allocate UTCB"); + error("failed to allocate UTCB"); throw Cpu_session::Out_of_metadata(); } _utcb_core_addr = (Native_utcb *)core_env()->rm_session()->attach(_utcb); @@ -107,7 +107,7 @@ void Platform_thread::join_pd(Platform_pd * pd, bool const main_thread, { /* check if thread is already in another protection domain */ if (_pd && _pd != pd) { - PERR("thread already in another protection domain"); + error("thread already in another protection domain"); return; } @@ -139,7 +139,7 @@ int Platform_thread::start(void * const ip, void * const sp) /* lock the address space */ Locked_ptr locked_ptr(_address_space); if (!locked_ptr.valid()) { - PERR("invalid RM client"); + error("invalid RM client"); return -1; }; Page_flags const flags = Page_flags::apply_mapping(true, CACHED, false); @@ -147,7 +147,7 @@ int Platform_thread::start(void * const ip, void * const sp) Hw::Address_space * as = static_cast(&*locked_ptr); if (!as->insert_translation((addr_t)_utcb_pd_addr, dsc->phys_addr(), sizeof(Native_utcb), flags)) { - PERR("failed to attach UTCB"); + error("failed to attach UTCB"); return -1; } return 0; @@ -161,7 +161,7 @@ int Platform_thread::start(void * const ip, void * const sp) /* start executing new thread */ if (!_pd) { - PWRN("No protection domain associated!"); + error("no protection domain associated!"); return -1; } @@ -190,7 +190,7 @@ void Platform_thread::pager(Pager_object * const pager) if (route_thread_event(kernel_object(), Thread_event_id::FAULT, pager ? Capability_space::capid(pager->cap()) : cap_id_invalid())) - PERR("failed to set pager object for thread %s", label()); + error("failed to set pager object for thread ", label()); _pager = pager; } diff --git a/repos/base-hw/src/core/ram_session_support.cc b/repos/base-hw/src/core/ram_session_support.cc index 1d0336142..625af91a6 100644 --- a/repos/base-hw/src/core/ram_session_support.cc +++ b/repos/base-hw/src/core/ram_session_support.cc @@ -16,7 +16,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -35,15 +35,15 @@ void Ram_session_component::_clear_ds (Dataspace_component * ds) /* allocate range in core's virtual address space */ void *virt_addr; if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { - PERR("could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return; } /* map the dataspace's physical pages to corresponding virtual addresses */ size_t num_pages = page_rounded_size >> get_page_size_log2(); if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) { - PERR("core-local memory mapping failed"); + error("core-local memory mapping failed"); return; } @@ -59,7 +59,7 @@ void Ram_session_component::_clear_ds (Dataspace_component * ds) /* unmap dataspace from core */ if (!unmap_local((addr_t)virt_addr, num_pages)) - PERR("could not unmap core-local address range at %p", virt_addr); + error("could not unmap core-local address range at ", virt_addr); /* free core's virtual address space */ platform()->region_alloc()->free(virt_addr, page_rounded_size); diff --git a/repos/base-hw/src/core/spec/arm/kernel/thread.cc b/repos/base-hw/src/core/spec/arm/kernel/thread.cc index 25d09c203..a41451dfd 100644 --- a/repos/base-hw/src/core/spec/arm/kernel/thread.cc +++ b/repos/base-hw/src/core/spec/arm/kernel/thread.cc @@ -39,15 +39,15 @@ void Thread::exception(unsigned const cpu) return; case UNDEFINED_INSTRUCTION: if (_cpu->retry_undefined_instr(*this)) { return; } - PWRN("%s -> %s: undefined instruction at ip=%p", - pd_label(), label(), (void*)ip); + Genode::warning(pd_label(), " -> ", label(), ": " + "undefined instruction at ip=", Genode::Hex(ip)); _stop(); return; case RESET: return; default: - PWRN("%s -> %s: triggered an unknown exception %lu", - pd_label(), label(), (unsigned long)cpu_exception); + Genode::warning(pd_label(), " -> ", label(), ": " + "triggered an unknown exception ", cpu_exception); _stop(); return; } @@ -61,21 +61,24 @@ void Thread::_mmu_exception() _fault_pd = (addr_t)_pd->platform_pd(); _fault_signal = (addr_t)_fault.signal_context(); - /** - * core should never raise a page-fault, - * if this happens print out an error message with debug information + /* + * Core should never raise a page-fault. If this happens, print out an + * error message with debug information. */ if (_pd == Kernel::core_pd()) - PERR("Pagefault in core thread (%s): ip=%p fault=%p", - label(), (void*)ip, (void*)_fault_addr); + Genode::error("page fault in core thread (", label(), "): " + "ip=", Genode::Hex(ip), " fault=", Genode::Hex(_fault_addr)); _fault.submit(); return; } - PERR("%s -> %s: raised unhandled %s DFSR=0x%08x ISFR=0x%08x " - "DFAR=0x%08x ip=0x%08lx sp=0x%08lx", pd_label(), label(), - cpu_exception == DATA_ABORT ? "data abort" : "prefetch abort", - Cpu::Dfsr::read(), Cpu::Ifsr::read(), Cpu::Dfar::read(), ip, sp); + Genode::error(pd_label(), " -> ", label(), ": raised unhandled ", + cpu_exception == DATA_ABORT ? "data abort" : "prefetch abort", " " + "DFSR=", Genode::Hex(Cpu::Dfsr::read()), " " + "ISFR=", Genode::Hex(Cpu::Ifsr::read()), " " + "DFAR=", Genode::Hex(Cpu::Dfar::read()), " " + "ip=", Genode::Hex(ip), " " + "sp=", Genode::Hex(sp)); } diff --git a/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc b/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc index 55c50f1ed..e3998e188 100644 --- a/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc +++ b/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc @@ -11,6 +11,7 @@ * under the terms of the GNU General Public License version 2. */ +#include #include #include #include @@ -59,7 +60,7 @@ struct Kernel::Vm_irq : Kernel::Irq Cpu_job & job = cpu_pool()->executing_cpu()->scheduled_job(); Vm *vm = dynamic_cast(&job); if (!vm) - PERR("VM timer interrupt while VM is not runnning!"); + Genode::error("VM timer interrupt while VM is not runnning!"); else vm->inject_irq(_irq_nr); } diff --git a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc index 22b5013c5..7cac81dac 100644 --- a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc +++ b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc @@ -30,7 +30,7 @@ void Vm_session_component::exception_handler(Signal_context_capability handler) if (!create((void*)_ds.core_local_addr(), Capability_space::capid(handler), cma->phys_addr(_table))) - PWRN("Cannot instantiate vm kernel object, invalid signal context?"); + Genode::warning("Cannot instantiate vm kernel object, invalid signal context?"); } @@ -42,10 +42,10 @@ void Vm_session_component::_attach(addr_t phys_addr, addr_t vm_addr, size_t size _table->insert_translation(vm_addr, phys_addr, size, pflags, _tt_alloc); return; } catch(Allocator::Out_of_memory) { - PERR("Translation table needs to much RAM"); + Genode::error("Translation table needs to much RAM"); } catch(...) { - PERR("Invalid mapping %p -> %p (%zx)", (void*)phys_addr, - (void*)vm_addr, size); + Genode::error("Invalid mapping ", Genode::Hex(phys_addr), " -> ", + Genode::Hex(vm_addr), " (", size, ")"); } } @@ -86,7 +86,7 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint *ds_ep, /* get some aligned space for the translation table */ if (!cma->alloc_aligned(sizeof(Translation_table), (void**)&tt, Translation_table::ALIGNM_LOG2).ok()) { - PERR("failed to allocate kernel object"); + error("failed to allocate kernel object"); throw Root::Quota_exceeded(); } diff --git a/repos/base-hw/src/core/spec/arndale/platform_services.cc b/repos/base-hw/src/core/spec/arndale/platform_services.cc index 08e9a9dd8..32d358a94 100644 --- a/repos/base-hw/src/core/spec/arndale/platform_services.cc +++ b/repos/base-hw/src/core/spec/arndale/platform_services.cc @@ -13,6 +13,7 @@ /* Genode includes */ #include +#include /* Core includes */ #include diff --git a/repos/base-hw/src/core/spec/x86/kernel/cpu.cc b/repos/base-hw/src/core/spec/x86/kernel/cpu.cc index cc1e5cabd..e78e72314 100644 --- a/repos/base-hw/src/core/spec/x86/kernel/cpu.cc +++ b/repos/base-hw/src/core/spec/x86/kernel/cpu.cc @@ -12,6 +12,12 @@ * under the terms of the GNU General Public License version 2. */ +/* Genode includes */ +#include + +/* base-internal includes */ +#include /* init_log() */ + /* core includes */ #include #include @@ -35,13 +41,15 @@ void Kernel::Cpu::init(Pic &pic, Kernel::Pd &core_pd, Genode::Board&) fpu().init(); + Genode::init_log(); + /* - * Please do not remove the PINF(), because the serial constructor requires + * Please do not remove the log(), because the serial constructor requires * access to the Bios Data Area, which is available in the initial * translation table set, but not in the final tables used after * Cr3::write(). */ - PINF("Switch to core's final translation table"); + Genode::log("Switch to core's final translation table"); Cr3::write(Cr3::init((addr_t)core_pd.translation_table())); diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc b/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc index 07fa8e359..225f5a702 100644 --- a/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc +++ b/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc @@ -24,13 +24,13 @@ void Kernel::Thread::_mmu_exception() _fault_signal = (addr_t)_fault.signal_context(); _fault_addr = Cpu::Cr2::read(); - /** - * core should never raise a page-fault, - * if this happens print out an error message with debug information + /* + * Core should never raise a page-fault. If this happens, print out an + * error message with debug information. */ if (_pd == Kernel::core_pd()) - PERR("Pagefault in core thread (%s): ip=%p fault=%p", - label(), (void*)ip, (void*)_fault_addr); + Genode::error("page fault in core thread (", label(), "): " + "ip=", Genode::Hex(ip), " fault=", Genode::Hex(_fault_addr)); _fault.submit(); return; diff --git a/repos/base-hw/src/core/spec/x86_64/muen/platform_support.cc b/repos/base-hw/src/core/spec/x86_64/muen/platform_support.cc index 301be48b3..22796bdde 100644 --- a/repos/base-hw/src/core/spec/x86_64/muen/platform_support.cc +++ b/repos/base-hw/src/core/spec/x86_64/muen/platform_support.cc @@ -82,11 +82,11 @@ bool Platform::get_msi_params(const addr_t mmconf, addr_t &address, struct Sinfo::Dev_info dev_info; if (!sinfo()->get_dev_info(sid, &dev_info)) { - PERR("error retrieving Muen info for device with SID 0x%x", sid); + error("error retrieving Muen info for device with SID ", Hex(sid)); return false; } if (!dev_info.msi_capable) { - PERR("device 0x%x not configured for MSI", sid); + error("device ", Hex(sid), " not configured for MSI"); return false; } @@ -94,8 +94,8 @@ bool Platform::get_msi_params(const addr_t mmconf, addr_t &address, address = Msi_address::to_msi_addr(dev_info.irte_start); irq_number = dev_info.irq_start; - PDBG("enabling MSI for device with SID 0x%x: IRTE %d, IRQ %d", - sid, dev_info.irte_start, irq_number); + log("enabling MSI for device with SID ", Hex(sid), ": " + "IRTE ", dev_info.irte_start, ", IRQ ", irq_number); return true; } @@ -110,7 +110,7 @@ Native_region * Platform::_ram_regions(unsigned const i) if (!result.size) { struct Sinfo::Memregion_info region; if (!sinfo()->get_memregion_info("ram", ®ion)) { - PERR("Unable to retrieve base-hw ram region"); + error("Unable to retrieve base-hw ram region"); return 0; } diff --git a/repos/base-hw/src/core/thread_start.cc b/repos/base-hw/src/core/thread_start.cc index ade5500fe..20b8b5242 100644 --- a/repos/base-hw/src/core/thread_start.cc +++ b/repos/base-hw/src/core/thread_start.cc @@ -38,7 +38,7 @@ void Thread::start() { /* start thread with stack pointer at the top of stack */ if (native_thread().platform_thread->start((void *)&_thread_start, stack_top())) - PERR("failed to start thread"); + error("failed to start thread"); } diff --git a/repos/base-hw/src/lib/base/signal.cc b/repos/base-hw/src/lib/base/signal.cc index 6d058fb86..fc0d5c78d 100644 --- a/repos/base-hw/src/lib/base/signal.cc +++ b/repos/base-hw/src/lib/base/signal.cc @@ -40,7 +40,7 @@ namespace Genode { ** Signal context ** ********************/ -void Signal_context::submit(unsigned) { PERR("not implemented"); } +void Signal_context::submit(unsigned) { Genode::error("not implemented"); } /************************ @@ -67,7 +67,7 @@ Signal_receiver::Signal_receiver() _cap = env()->pd_session()->alloc_signal_source(); }, [&] () { - PINF("upgrading quota donation for PD session"); + log("upgrading quota donation for PD session"); env()->parent()->upgrade(env()->pd_session_cap(), "ram_quota=8K"); } ); @@ -105,7 +105,7 @@ Signal_context_capability Signal_receiver::manage(Signal_context * const c) return c->_cap; }, [&] () { - PINF("upgrading quota donation for PD session"); + log("upgrading quota donation for PD session"); env()->parent()->upgrade(env()->pd_session_cap(), "ram_quota=8K"); } ); @@ -118,7 +118,7 @@ void Signal_receiver::block_for_signal() { /* wait for a signal */ if (Kernel::await_signal(Capability_space::capid(_cap))) { - PERR("failed to receive signal"); + Genode::error("failed to receive signal"); return; } /* read signal data */ @@ -137,4 +137,4 @@ void Signal_receiver::block_for_signal() } -void Signal_receiver::local_submit(Signal::Data) { PERR("not implemented"); } +void Signal_receiver::local_submit(Signal::Data) { Genode::error("not implemented"); } diff --git a/repos/base-hw/src/lib/base/thread_start.cc b/repos/base-hw/src/lib/base/thread_start.cc index 554ff5f1c..cfc4b1adf 100644 --- a/repos/base-hw/src/lib/base/thread_start.cc +++ b/repos/base-hw/src/lib/base/thread_start.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ void Thread::_init_platform_thread(size_t weight, Type type) /* remap initial main-thread UTCB according to stack-area spec */ try { rm->attach_at(Hw::_main_thread_utcb_ds, utcb_new, utcb_size); } catch(...) { - PERR("failed to re-map UTCB"); + error("failed to re-map UTCB"); while (1) ; } /* adjust initial object state in case of a main thread */ @@ -92,7 +92,7 @@ void Thread::start() stack_virtual_size() - size - stack_area_virtual_base(); env_stack_area_region_map->attach_at(ds, dst, size); } catch (...) { - PERR("failed to attach userland stack"); + error("failed to attach userland stack"); sleep_forever(); } /* start thread with its initial IP and aligned SP */ diff --git a/repos/base-linux/src/core/include/platform_thread.h b/repos/base-linux/src/core/include/platform_thread.h index 9e2f6ec6a..7de061ee5 100644 --- a/repos/base-linux/src/core/include/platform_thread.h +++ b/repos/base-linux/src/core/include/platform_thread.h @@ -118,13 +118,13 @@ namespace Genode { Thread_state state() { - PDBG("Not implemented"); + warning("Not implemented"); throw Cpu_thread::State_access_failed(); } void state(Thread_state) { - PDBG("Not implemented"); + warning("Not implemented"); throw Cpu_thread::State_access_failed(); } diff --git a/repos/base-linux/src/core/native_pd_component.cc b/repos/base-linux/src/core/native_pd_component.cc index b46f0fd76..10da60425 100644 --- a/repos/base-linux/src/core/native_pd_component.cc +++ b/repos/base-linux/src/core/native_pd_component.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* core-local includes */ @@ -112,7 +112,7 @@ void Native_pd_component::_start(Dataspace_component &ds) int tmp_binary_fd = lx_open(filename, O_CREAT | O_EXCL | O_WRONLY, S_IRWXU); if (tmp_binary_fd < 0) { - PERR("Could not create file '%s'", filename); + error("Could not create file '", filename, "'"); return; /* XXX reflect error to client */ } @@ -205,6 +205,6 @@ void Native_pd_component::start(Capability binary) if (ds) _start(*ds); else - PERR("failed to lookup binary to start"); + error("failed to lookup binary to start"); }); }; diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc index 9ba8ae68d..d32695bfc 100644 --- a/repos/base-linux/src/core/platform.cc +++ b/repos/base-linux/src/core/platform.cc @@ -173,7 +173,7 @@ namespace Genode { * as well as in Genode processes. */ if (socket_pair.server_sd != -1 || socket_pair.client_sd != -1) - PERR("%s called for IPC server which should never happen", __func__); + error(__func__, " called for IPC server which should never happen"); } } diff --git a/repos/base-linux/src/core/platform_thread.cc b/repos/base-linux/src/core/platform_thread.cc index 77ce98bf0..bca3f133a 100644 --- a/repos/base-linux/src/core/platform_thread.cc +++ b/repos/base-linux/src/core/platform_thread.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include /* local includes */ #include "platform_thread.h" @@ -100,20 +100,19 @@ Platform_thread::~Platform_thread() void Platform_thread::cancel_blocking() { - PDBG("send cancel-blocking signal to %ld\n", _tid); lx_tgkill(_pid, _tid, LX_SIGUSR1); } void Platform_thread::pause() { - PDBG("not implemented"); + warning(__func__, "not implemented"); } void Platform_thread::resume() { - PDBG("not implemented"); + warning(__func__, "not implemented"); } diff --git a/repos/base-linux/src/include/base/internal/region_registry.h b/repos/base-linux/src/include/base/internal/region_registry.h index a1f48262a..56df325ca 100644 --- a/repos/base-linux/src/include/base/internal/region_registry.h +++ b/repos/base-linux/src/include/base/internal/region_registry.h @@ -15,7 +15,7 @@ #define _INCLUDE__BASE__INTERNAL__REGION_REGISTRY_ #include -#include +#include namespace Genode { class Region; @@ -97,8 +97,7 @@ class Genode::Region_registry if (!_map[i].used()) break; if (i == MAX_REGIONS) { - PERR("maximum number of %d regions reached", - MAX_REGIONS); + error("maximum number of ", (unsigned)MAX_REGIONS, " regions reached"); return -1; } diff --git a/repos/base-linux/src/include/base/internal/stack_area.h b/repos/base-linux/src/include/base/internal/stack_area.h index 76f7f4a32..69a9efd2a 100644 --- a/repos/base-linux/src/include/base/internal/stack_area.h +++ b/repos/base-linux/src/include/base/internal/stack_area.h @@ -52,7 +52,7 @@ static inline void flush_stack_area() int ret; if ((ret = lx_munmap(base, size)) < 0) { - PERR("%s: failed ret=%d", __func__, ret); + error(__func__, ": failed ret=", ret); throw Region_map::Region_conflict(); } } @@ -71,9 +71,7 @@ static inline Genode::addr_t reserve_stack_area() /* reserve at local address failed - unmap incorrect mapping */ if (addr_in != addr_out) { lx_munmap((void *)addr_out, size); - - PERR("%s: failed addr_in=%p addr_out=%p ret=%ld)", __func__, - addr_in, addr_out, (long)addr_out); + error(__func__, ": failed addr_in=", addr_in, " addr_out=", addr_out); throw Region_map::Region_conflict(); } diff --git a/repos/base-linux/src/lib/base/child_process.cc b/repos/base-linux/src/lib/base/child_process.cc index e3d374d60..773c778c7 100644 --- a/repos/base-linux/src/lib/base/child_process.cc +++ b/repos/base-linux/src/lib/base/child_process.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include #include /* base-internal includes */ @@ -79,7 +79,7 @@ Child::Process::Process(Dataspace_capability elf_ds, addr_t elf_addr; try { elf_addr = local_rm.attach(elf_ds); } catch (Region_map::Attach_failed) { - PERR("local attach of ELF executable failed"); throw; } + error("local attach of ELF executable failed"); throw; } /* setup ELF object and read program entry pointer */ Elf_binary elf(elf_addr); @@ -97,7 +97,7 @@ Child::Process::Process(Dataspace_capability elf_ds, if (dynamically_linked) { if (!ldso_ds.valid()) { - PERR("attempt to start dynamic executable without dynamic linker"); + error("attempt to start dynamic executable without dynamic linker"); throw Missing_dynamic_linker(); } diff --git a/repos/base-linux/src/lib/base/region_map_mmap.cc b/repos/base-linux/src/lib/base/region_map_mmap.cc index 11e83ddf4..6af7d6520 100644 --- a/repos/base-linux/src/lib/base/region_map_mmap.cc +++ b/repos/base-linux/src/lib/base/region_map_mmap.cc @@ -98,8 +98,8 @@ addr_t Region_map_mmap::_reserve_local(bool use_local_addr, if ((use_local_addr && addr_in != addr_out) || (((long)addr_out < 0) && ((long)addr_out > -4095))) { - PERR("_reserve_local: lx_mmap failed (addr_in=%p,addr_out=%p/%ld)", - addr_in, addr_out, (long)addr_out); + error("_reserve_local: lx_mmap failed " + "(addr_in=", addr_in, ",addr_out=", addr_out, "/", (long)addr_out, ")"); throw Region_map::Region_conflict(); } @@ -139,8 +139,9 @@ void *Region_map_mmap::_map_local(Dataspace_capability ds, if ((use_local_addr && addr_in != addr_out) || (((long)addr_out < 0) && ((long)addr_out > -4095))) { - PERR("_map_local: lx_mmap failed (addr_in=%p,addr_out=%p/%ld) overmap=%d", - addr_in, addr_out, (long)addr_out, overmap); + error("_map_local: lx_mmap failed" + "(addr_in=", addr_in, ", addr_out=", addr_out, "/", (long)addr_out, ") " + "overmap=", overmap); throw Region_map::Region_conflict(); } @@ -151,7 +152,7 @@ void *Region_map_mmap::_map_local(Dataspace_capability ds, void Region_map_mmap::_add_to_rmap(Region const ®ion) { if (_rmap.add_region(region) < 0) { - PERR("_add_to_rmap: could not add region to sub RM session"); + error("_add_to_rmap: could not add region to sub RM session"); throw Region_conflict(); } } @@ -167,12 +168,12 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, /* only support attach_at for sub RM sessions */ if (_sub_rm && !use_local_addr) { - PERR("Region_map_mmap::attach: attaching w/o local addr not supported\n"); + error("Region_map_mmap::attach: attaching w/o local addr not supported"); throw Out_of_metadata(); } if (offset < 0) { - PERR("Region_map_mmap::attach: negative offset not supported\n"); + error("Region_map_mmap::attach: negative offset not supported"); throw Region_conflict(); } @@ -204,7 +205,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, * Case 4 */ if (is_sub_rm_session(ds)) { - PERR("Region_map_mmap::attach: nesting sub RM sessions is not supported"); + error("Region_map_mmap::attach: nesting sub RM sessions is not supported"); throw Invalid_dataspace(); } @@ -213,7 +214,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, * sub RM session */ if (region_size + (addr_t)local_addr > _size) { - PERR("Region_map_mmap::attach: dataspace does not fit in sub RM session"); + error("Region_map_mmap::attach: dataspace does not fit in sub RM session"); throw Region_conflict(); } @@ -249,7 +250,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds, * Detect if sub RM session is already attached */ if (rm->_base) { - PERR("Region_map_mmap::attach: mapping a sub RM session twice is not supported"); + error("Region_map_mmap::attach: mapping a sub RM session twice is not supported"); throw Out_of_metadata(); } diff --git a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc index bc61b845d..3862cbb8d 100644 --- a/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc +++ b/repos/base-linux/src/lib/lx_hybrid/lx_hybrid.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include #include #include @@ -307,32 +306,32 @@ namespace Genode { void wait_for_construction() { - PERR("wait_for_construction() called for an adopted thread"); + error("wait_for_construction() called for an adopted thread"); } void constructed() { - PERR("constructed() called for an adopted thread"); + error("constructed() called for an adopted thread"); } void wait_for_start() { - PERR("wait_for_start() called for an adopted thread"); + error("wait_for_start() called for an adopted thread"); } void started() { - PERR("started() called for an adopted thread"); + error("started() called for an adopted thread"); } void wait_for_join() { - PERR("wait_for_join() called for an adopted thread"); + error("wait_for_join() called for an adopted thread"); } void joined() { - PERR("joined() called for an adopted thread"); + error("joined() called for an adopted thread"); } }; } @@ -464,8 +463,7 @@ Thread::Thread(size_t weight, const char *name, size_t stack_size, int const ret = pthread_create(&meta_data->pt, 0, thread_start, meta_data); if (ret) { - PERR("pthread_create failed (returned %d, errno=%d)", - ret, errno); + error("pthread_create failed (returned ", ret, ", errno=", errno, ")"); destroy(env()->heap(), meta_data); throw Out_of_stack_space(); } @@ -511,8 +509,8 @@ Thread::~Thread() if (needs_join) { int const ret = pthread_join(native_thread().meta_data->pt, 0); if (ret) - PWRN("pthread_join unexpectedly returned with %d (errno=%d)", - ret, errno); + warning("pthread_join unexpectedly returned " + "with ", ret, " (errno=", errno, ")"); } Thread_meta_data_created *meta_data = diff --git a/repos/base-linux/src/lib/syscall/linux_syscalls.h b/repos/base-linux/src/lib/syscall/linux_syscalls.h index bb1148a10..4962c60ef 100644 --- a/repos/base-linux/src/lib/syscall/linux_syscalls.h +++ b/repos/base-linux/src/lib/syscall/linux_syscalls.h @@ -57,7 +57,7 @@ extern "C" void wait_for_continue(void); char str[128]; \ Genode::snprintf(str, sizeof(str), \ ESC_ERR fmt ESC_END "\n", ##__VA_ARGS__); \ - Genode::raw((char const *)str); \ + Genode::raw(Genode::Cstring(str)); \ } while (0) diff --git a/repos/base-linux/src/test/lx_hybrid_errno/main.cc b/repos/base-linux/src/test/lx_hybrid_errno/main.cc index 9c55711a6..663ca7131 100644 --- a/repos/base-linux/src/test/lx_hybrid_errno/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_errno/main.cc @@ -7,7 +7,7 @@ /* Genode includes */ #include #include -#include +#include /* libc includes */ #include @@ -32,7 +32,7 @@ struct Thread : Genode::Thread_deprecated struct stat buf; int ret = stat("", &buf); - Genode::printf("thread: stat returned %d, errno=%d\n", ret, errno); + Genode::log("thread: stat returned ", ret, ", errno=", errno); /* * Let main thread procees @@ -56,13 +56,13 @@ struct Unexpected_errno_change { }; */ void Component::construct(Genode::Env &env) { - Genode::printf("--- thread-local errno test ---\n"); + Genode::log("--- thread-local errno test ---"); static Genode::Lock barrier(Genode::Lock::LOCKED); int const orig_errno = errno; - Genode::printf("main: before thread creation, errno=%d\n", orig_errno); + Genode::log("main: before thread creation, errno=", orig_errno); /* create thread, which modifies its thread-local errno value */ static Thread thread(barrier); @@ -70,14 +70,14 @@ void Component::construct(Genode::Env &env) /* block until the thread performed a 'stat' syscall */ barrier.lock(); - Genode::printf("main: after thread completed, errno=%d\n", errno); + Genode::log("main: after thread completed, errno=", errno); if (orig_errno != errno) { - PERR("unexpected change of main thread's errno value"); + Genode::error("unexpected change of main thread's errno value"); throw Unexpected_errno_change(); } - Genode::printf("--- finished thread-local errno test ---\n"); + Genode::log("--- finished thread-local errno test ---"); exit_status = 0; env.ep().schedule_suspend(exit_on_suspended, nullptr); } diff --git a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc index 2186c75b2..5928e83d7 100644 --- a/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc +++ b/repos/base-linux/src/test/lx_hybrid_pthread_ipc/main.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include /* libc includes */ #include @@ -31,7 +31,7 @@ static Genode::Lock *main_wait_lock() static void *pthread_entry(void *) { - PINF("first message"); + Genode::log("first message"); /* * Without the lazy initialization of 'Thread' objects for threads @@ -42,7 +42,7 @@ static void *pthread_entry(void *) * will appear in the LOG output. */ - PINF("second message"); + Genode::log("second message"); main_wait_lock()->unlock(); return 0; @@ -61,7 +61,7 @@ Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); } */ void Component::construct(Genode::Env &env) { - Genode::printf("--- pthread IPC test ---\n"); + Genode::log("--- pthread IPC test ---"); /* create thread w/o Genode's thread API */ pthread_t pth; @@ -70,7 +70,7 @@ void Component::construct(Genode::Env &env) /* wait until 'pthread_entry' finished */ main_wait_lock()->lock(); - Genode::printf("--- finished pthread IPC test ---\n"); + Genode::log("--- finished pthread IPC test ---"); exit_status = 0; env.ep().schedule_suspend(exit_on_suspended, nullptr); } diff --git a/repos/base-linux/src/test/lx_rmap/main.cc b/repos/base-linux/src/test/lx_rmap/main.cc index 5d68878a6..a6052e9ad 100644 --- a/repos/base-linux/src/test/lx_rmap/main.cc +++ b/repos/base-linux/src/test/lx_rmap/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -57,18 +57,18 @@ int main() size_t size(end - beg); - PLOG("blob region region [%016lx,%016lx) size=%zx", beg, end, size); + log("blob region region ", Hex_range(beg, size), " size=", size); /* RAM dataspace attachment overlapping binary */ try { Ram_dataspace_capability ds(env()->ram_session()->alloc(size)); - PLOG("before RAM dataspace attach"); + log("before RAM dataspace attach"); env()->rm_session()->attach_at(ds, beg); - PERR("after RAM dataspace attach -- ERROR"); + error("after RAM dataspace attach -- ERROR"); sleep_forever(); } catch (Region_map::Region_conflict) { - PLOG("OK caught Region_conflict exception"); + log("OK caught Region_conflict exception"); } /* empty managed dataspace overlapping binary */ @@ -77,12 +77,12 @@ int main() Region_map_client rm(rm_connection.create(size)); Dataspace_capability ds(rm.dataspace()); - PLOG("before sub-RM dataspace attach"); + log("before sub-RM dataspace attach"); env()->rm_session()->attach_at(ds, beg); - PERR("after sub-RM dataspace attach -- ERROR"); + error("after sub-RM dataspace attach -- ERROR"); sleep_forever(); } catch (Region_map::Region_conflict) { - PLOG("OK caught Region_conflict exception"); + log("OK caught Region_conflict exception"); } /* sparsely populated managed dataspace in free VM area */ @@ -94,14 +94,14 @@ int main() Dataspace_capability ds(rm.dataspace()); - PLOG("before populated sub-RM dataspace attach"); + log("before populated sub-RM dataspace attach"); char *addr = (char *)env()->rm_session()->attach(ds) + 0x1000; - PLOG("after populated sub-RM dataspace attach / before touch"); + log("after populated sub-RM dataspace attach / before touch"); char const val = *addr; *addr = 0x55; - PLOG("after touch (%x/%x)", val, *addr); + log("after touch (", val, "/", *addr, ")"); } catch (Region_map::Region_conflict) { - PERR("Caught Region_conflict exception -- ERROR"); + error("Caught Region_conflict exception -- ERROR"); sleep_forever(); } } diff --git a/repos/base-linux/src/test/region_map_mmap/main.cc b/repos/base-linux/src/test/region_map_mmap/main.cc index 2aeeca07e..a39ced5bf 100644 --- a/repos/base-linux/src/test/region_map_mmap/main.cc +++ b/repos/base-linux/src/test/region_map_mmap/main.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include @@ -23,31 +23,28 @@ static void test_linux_rmmap_bug() using namespace Genode; - PLOG("line: %d", __LINE__); + log("line: ", __LINE__); Ram_connection ram; #if 1 /* transfer quota */ - PLOG("line: %d", __LINE__); + log("line: ", __LINE__); ram.ref_account(env()->ram_session_cap()); env()->ram_session()->transfer_quota(ram.cap(), QUOTA); #endif - PLOG("line: %d", __LINE__); + log("line: ", __LINE__); for (unsigned i = 0; i < ROUNDS; ++i) { Ram_dataspace_capability ds(ram.alloc(CHUNK)); - PLOG("%d of %d pages allocated", (i + 1), ROUNDS); + log(i + 1, " of ", (unsigned)ROUNDS, " pages allocated"); } - PLOG("Done."); + log("Done."); } int main() { - Genode::printf("--- test-rm_session_mmap started ---\n"); - -// Timer::Connection timer; -// timer.msleep(1000); + Genode::log("--- test-rm_session_mmap started ---"); test_linux_rmmap_bug(); } diff --git a/repos/base-nova/include/nova/util.h b/repos/base-nova/include/nova/util.h index b2372efc7..ff3a286df 100644 --- a/repos/base-nova/include/nova/util.h +++ b/repos/base-nova/include/nova/util.h @@ -14,7 +14,7 @@ #ifndef _INCLUDE__NOVA__UTIL_H_ #define _INCLUDE__NOVA__UTIL_H_ -#include +#include #include __attribute__((always_inline)) @@ -51,7 +51,8 @@ inline void request_event_portal(Genode::Native_capability const &cap, utcb->crd_rcv = orig_crd; if (res) - PERR("request of event (%lu) capability selector failed (res=%u)", event, res); + Genode::error("request of event (", event, ") ", + "capability selector failed (res=", res, ")"); } @@ -111,6 +112,6 @@ inline void delegate_vcpu_portals(Genode::Native_capability const &cap, utcb->crd_rcv = orig_crd; if (res) - PERR("setting exception portals for vCPU failed %u", res); + Genode::error("setting exception portals for vCPU failed res=", res); } #endif /* _INCLUDE__NOVA__UTIL_H_ */ diff --git a/repos/base-nova/src/core/core_region_map.cc b/repos/base-nova/src/core/core_region_map.cc index 8cbc8f99d..a4e120e74 100644 --- a/repos/base-nova/src/core/core_region_map.cc +++ b/repos/base-nova/src/core/core_region_map.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -58,12 +58,12 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, throw Invalid_dataspace(); if (use_local_addr) { - PERR("Parameter 'use_local_addr' not supported within core"); + error("Parameter 'use_local_addr' not supported within core"); return nullptr; } if (offset) { - PERR("Parameter 'offset' not supported within core"); + error("Parameter 'offset' not supported within core"); return nullptr; } diff --git a/repos/base-nova/src/core/include/nova_util.h b/repos/base-nova/src/core/include/nova_util.h index f1390af57..6a386e06d 100644 --- a/repos/base-nova/src/core/include/nova_util.h +++ b/repos/base-nova/src/core/include/nova_util.h @@ -17,7 +17,7 @@ #define _CORE__INCLUDE__NOVA_UTIL_H_ /* Genode includes */ -#include +#include /* NOVA includes */ #include @@ -26,8 +26,6 @@ #include #include -enum { verbose_local_map = false }; - /** * Return boot CPU number. It is required if threads in core should be placed * on the same CPU as the main thread. @@ -82,11 +80,17 @@ static int map_local(Nova::Utcb *utcb, Nova::Crd src_crd, Nova::Crd dst_crd, Nova::uint8_t res = Nova::call(echo()->pt_sel()); if (res != Nova::NOVA_OK || utcb->msg_words() != 1 || !utcb->msg[0] || utcb->msg_items() != 1) { - PERR("Failure - map_local 0x%lx:%lu:%u->0x%lx:%lu:%u - call result=%x" - " utcb=%x:%x:%lx !!! utcb=%p kern=%u", - src_crd.addr(), src_crd.order(), src_crd.type(), - dst_crd.addr(), dst_crd.order(), dst_crd.type(), res, - utcb->msg_items(), utcb->msg_words(), utcb->msg[0], utcb, kern_pd); + + typedef Genode::Hex Hex; + error("map_local failed ", + Hex(src_crd.addr()), ":", Hex(src_crd.order()), ":", Hex(src_crd.type()), "->", + Hex(dst_crd.addr()), ":", Hex(dst_crd.order()), ":", Hex(dst_crd.type()), " - ", + "result=", Hex(res), " " + "msg=", Hex(utcb->msg_items()), ":", + Hex(utcb->msg_words()), ":", + Hex(utcb->msg[0]), " !!! " + "utcb=", utcb, " " + "kern=", kern_pd); return res > 0 ? res : -1; } /* clear receive window */ @@ -136,10 +140,6 @@ inline int map_local(Nova::Utcb *utcb, bool kern_pd = false, bool dma_mem = false, bool write_combined = false) { - if (verbose_local_map) - Genode::printf("::map_local: from %lx to %lx, %zd pages from kernel %u\n", - from_start, to_start, num_pages, kern_pd); - using namespace Nova; using namespace Genode; @@ -169,10 +169,6 @@ inline int map_local(Nova::Utcb *utcb, if ((to_end - to_curr) < (1UL << order)) order = log2(to_end - to_curr); - if (verbose_local_map) - Genode::printf("::map_local: order %zx %lx:%lx %lx:%lx\n", - order, from_curr, from_end, to_curr, to_end); - int const res = map_local(utcb, Mem_crd((from_curr >> 12), order - get_page_size_log2(), permission), Mem_crd((to_curr >> 12), order - get_page_size_log2(), permission), @@ -207,13 +203,10 @@ inline void unmap_local(Nova::Utcb *utcb, Genode::addr_t start, Genode::addr_t base = start >> get_page_size_log2(); if (start & (get_page_size() - 1)) { - PERR("unmap failed - unaligned address specified"); + error("unmap failed - unaligned address specified"); return; } - if (verbose_local_map) - PINF("Unmapping local: range 0x%lx+0x%zx", base, num_pages); - while (num_pages) { unsigned char const base_bit = lsb_bit(base); unsigned char const order_bit = min(log2(num_pages), 31U); @@ -221,10 +214,6 @@ inline void unmap_local(Nova::Utcb *utcb, Genode::addr_t start, Mem_crd const crd(base, order, rwx); - if (verbose_local_map) - PINF("Unmapping local: 0x%lx+0x%lx", crd.base(), - 1UL << crd.order()); - unmap_local(crd, self); num_pages -= 1UL << order; diff --git a/repos/base-nova/src/core/include/platform.h b/repos/base-nova/src/core/include/platform.h index f804af2aa..b1ca4ea0a 100644 --- a/repos/base-nova/src/core/include/platform.h +++ b/repos/base-nova/src/core/include/platform.h @@ -19,8 +19,6 @@ #include #include -#include - namespace Genode { class Platform : public Platform_generic diff --git a/repos/base-nova/src/core/include/util.h b/repos/base-nova/src/core/include/util.h index 8575de895..d56262925 100644 --- a/repos/base-nova/src/core/include/util.h +++ b/repos/base-nova/src/core/include/util.h @@ -52,12 +52,12 @@ namespace Genode { inline void backtrace() { using namespace Genode; - printf("\nbacktrace\n"); - printf(" %p\n", __builtin_return_address(0)); - printf(" %p\n", __builtin_return_address(1)); - printf(" %p\n", __builtin_return_address(2)); - printf(" %p\n", __builtin_return_address(3)); - printf(" %p\n", __builtin_return_address(4)); + log("\nbacktrace"); + log(" ", __builtin_return_address(0)); + log(" ", __builtin_return_address(1)); + log(" ", __builtin_return_address(2)); + log(" ", __builtin_return_address(3)); + log(" ", __builtin_return_address(4)); } diff --git a/repos/base-nova/src/core/irq_session_component.cc b/repos/base-nova/src/core/irq_session_component.cc index 992ac2876..b74a06713 100644 --- a/repos/base-nova/src/core/irq_session_component.cc +++ b/repos/base-nova/src/core/irq_session_component.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -36,7 +36,7 @@ static bool irq_ctrl(Genode::addr_t irq_sel, msi_addr, msi_data, sig_sel); if (res != Nova::NOVA_OK) - PERR("setting up MSI failed - error %u", res); + error("setting up MSI failed - error ", res); /* nova syscall interface specifies msi addr/data to be 32bit */ msi_addr = msi_addr & ~0U; @@ -61,7 +61,7 @@ static void deassociate(Genode::addr_t irq_sel) addr_t dummy1 = 0, dummy2 = 0; if (!irq_ctrl(irq_sel, dummy1, dummy2, irq_sel)) - PWRN("Irq could not be de-associated"); + warning("Irq could not be de-associated"); } @@ -129,7 +129,7 @@ void Irq_object::sigh(Signal_context_capability cap) void Irq_object::ack_irq() { if (Nova::NOVA_OK != Nova::sm_ctrl(irq_sel(), Nova::SEMAPHORE_DOWN)) - PERR("Unmasking irq of selector 0x%lx failed", irq_sel()); + error("Unmasking irq of selector ", irq_sel(), " failed"); } @@ -145,7 +145,7 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys) int ret = map_local((Nova::Utcb *)Thread::myself()->utcb(), src, dst, MAP_FROM_KERNEL_TO_CORE); if (ret) { - PERR("Getting IRQ from kernel failed - %u", irq); + error("getting IRQ from kernel failed - ", irq); throw Root::Unavailable(); } @@ -217,7 +217,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, } if (!irq_alloc || irq_alloc->alloc_addr(1, irq_number).error()) { - PERR("Unavailable IRQ 0x%lx requested", irq_number); + error("unavailable IRQ ", irq_number, " requested"); throw Root::Unavailable(); } diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc index 65508bb4d..685fa7308 100644 --- a/repos/base-nova/src/core/pager.cc +++ b/repos/base-nova/src/core/pager.cc @@ -71,6 +71,31 @@ static unsigned which_cpu(Pager_activation_base * pager) } +/** + * Utility for the formatted output of page-fault information + */ +struct Page_fault_info +{ + char const * const pd; + char const * const thread; + unsigned const cpu; + addr_t const ip, addr; + + Page_fault_info(char const *pd, char const *thread, unsigned cpu, + addr_t ip, addr_t addr) + : pd(pd), thread(thread), cpu(cpu), ip(ip), addr(addr) { } + + void print(Genode::Output &out) const + { + Genode::print(out, "pd='", pd, "' " + "thread='", thread, "' " + "cpu=", cpu, " " + "ip=", Hex(ip), " " + "address=", Hex(addr)); + } +}; + + void Pager_object::_page_fault_handler(addr_t pager_obj) { Ipc_pager ipc_pager; @@ -105,11 +130,13 @@ void Pager_object::_page_fault_handler(addr_t pager_obj) const char * client_thread = obj->client_thread(); const char * client_pd = obj->client_pd(); + Page_fault_info const fault_info(client_pd, client_thread, + which_cpu(pager_thread), + ipc_pager.fault_ip(), ipc_pager.fault_addr()); + /* region manager fault - to be handled */ if (ret == 1) { - PDBG("page fault, pd '%s', thread '%s', cpu %u, ip=%lx, fault " - "address=0x%lx", client_pd, client_thread, which_cpu(pager_thread), - ipc_pager.fault_ip(), ipc_pager.fault_addr()); + log("page fault, ", fault_info); utcb->set_msg_word(0); utcb->mtd = 0; @@ -121,10 +148,7 @@ void Pager_object::_page_fault_handler(addr_t pager_obj) /* unhandled case */ obj->_state.mark_dead(); - PWRN("unresolvable page fault, pd '%s', thread '%s', cpu %u, ip=%lx, " - "fault address=0x%lx ret=%u", client_pd, client_thread, - which_cpu(pager_thread), ipc_pager.fault_ip(), ipc_pager.fault_addr(), - ret); + warning("unresolvable page fault, ", fault_info, " ret=", ret); Native_capability pager_cap = obj->Object_pool::Entry::cap(); @@ -165,11 +189,13 @@ void Pager_object::exception(uint8_t exit_id) /* nobody handles this exception - so thread will be stopped finally */ _state.mark_dead(); - PWRN("unresolvable exception %u, pd '%s', thread '%s', cpu %u, " - "ip=0x%lx, %s", exit_id, client_pd(), client_thread(), - which_cpu(pager_thread), fault_ip, - res == 0xFF ? "no signal handler" : - (res == NOVA_OK ? "" : "recall failed")); + warning("unresolvable exception ", exit_id, ", " + "pd '", client_pd(), "', " + "thread '", client_thread(), "', " + "cpu ", which_cpu(pager_thread), ", " + "ip=", Hex(fault_ip), " ", + res == 0xFF ? "no signal handler" + : (res == NOVA_OK ? "" : "recall failed")); Nova::revoke(Obj_crd(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2)); @@ -291,7 +317,7 @@ void Pager_object::_invoke_handler(addr_t pager_obj) Obj_crd snd(cap.base(), 0); Obj_crd rcv(obj->_client_exc_vcpu + event * items_count + i, 0); if (map_local(utcb, snd, rcv)) - PWRN("could not remap vCPU portal 0x%x", i); + warning("could not remap vCPU portal ", Hex(i)); } } @@ -379,7 +405,7 @@ void Pager_object::wake_up() uint8_t res = sm_ctrl(sel_sm_block_pause(), SEMAPHORE_UP); if (res != NOVA_OK) - PWRN("canceling blocked client failed (thread sm)"); + warning("canceling blocked client failed (thread sm)"); } @@ -387,14 +413,14 @@ void Pager_object::client_cancel_blocking() { uint8_t res = sm_ctrl(exc_pt_sel_client() + SM_SEL_EC, SEMAPHORE_UP); if (res != NOVA_OK) - PWRN("canceling blocked client failed (thread sm)"); + warning("canceling blocked client failed (thread sm)"); if (!_state.has_signal_sm()) return; res = sm_ctrl(exc_pt_sel_client() + PT_SEL_STARTUP, SEMAPHORE_UP); if (res != NOVA_OK) - PWRN("canceling blocked client failed (signal sm)"); + warning("canceling blocked client failed (signal sm)"); } @@ -440,7 +466,7 @@ void Pager_object::cleanup_call() utcb->set_msg_word(0); utcb->mtd = 0; if (uint8_t res = call(sel_pt_cleanup())) - PERR("%8p - cleanup call to pager failed res=%d", utcb, res); + error(utcb, " - cleanup call to pager failed res=", res); } @@ -477,7 +503,7 @@ void Exception_handlers::register_handler(Pager_object *obj, Mtd mtd, { unsigned use_cpu = obj->location.xpos(); if (!kernel_hip()->is_cpu_enabled(use_cpu) || !pager_threads[use_cpu]) { - PWRN("invalid CPU parameter used in pager object"); + warning("invalid CPU parameter used in pager object"); throw Region_map::Invalid_thread(); } @@ -562,14 +588,14 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, /* ypos information not supported by now */ if (location.ypos()) { - PWRN("Unsupported location %ux%u", location.xpos(), location.ypos()); + warning("unsupported location ", location.xpos(), "x", location.ypos()); throw Region_map::Invalid_thread(); } /* place Pager_object on specified CPU by selecting proper pager thread */ unsigned use_cpu = location.xpos(); if (!kernel_hip()->is_cpu_enabled(use_cpu) || !pager_threads[use_cpu]) { - PWRN("invalid CPU parameter used in pager object"); + warning("invalid CPU parameter used in pager object"); throw Region_map::Invalid_thread(); } @@ -603,7 +629,7 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap, res = create_portal(sel_pt_cleanup(), pd_sel, ec_sel, Mtd(0), reinterpret_cast(_invoke_handler), this); if (res != Nova::NOVA_OK) { - PERR("could not create pager cleanup portal, error = %u\n", res); + error("could not create pager cleanup portal, error=", res); throw Region_map::Invalid_thread(); } @@ -661,10 +687,11 @@ uint8_t Pager_object::handle_oom(addr_t transfer_from, /* request current kernel quota usage of source pd */ Nova::pd_ctrl_debug(transfer_from, limit_source, usage_source); - PINF("oom - '%s':'%s' (%lu/%lu) - transfer %u pages from '%s':'%s' " - "(%lu/%lu)", dst_pd, dst_thread, - usage_before, limit_before, QUOTA_TRANSFER_PAGES, - src_pd, src_thread, usage_source, limit_source); + log("oom - '", dst_pd, "':'", dst_thread, "' " + "(", usage_before, "/", limit_before, ") - " + "transfer ", (long)QUOTA_TRANSFER_PAGES, " pages " + "from '", src_pd, "':'", src_thread, "' " + "(", usage_source, "/", limit_source, ")"); } uint8_t res = Nova::NOVA_PD_OOM; @@ -687,9 +714,10 @@ uint8_t Pager_object::handle_oom(addr_t transfer_from, } } - PWRN("kernel memory quota upgrade failed - trigger memory free up for " - "causing '%s':'%s' - donator is '%s':'%s', policy=%u", - dst_pd, dst_thread, src_pd, src_thread, policy); + warning("kernel memory quota upgrade failed - trigger memory free up for " + "causing '", dst_pd, "':'", dst_thread, "' - " + "donator is '", src_pd, "':'", src_thread, "', " + "policy=", (int)policy); /* if nothing helps try to revoke memory */ enum { REMOTE_REVOKE = true, PD_SELF = true }; @@ -760,14 +788,14 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src, assert |= utcb->msg_words(); if (assert) { - PERR("unknown OOM case - stop core pager thread"); + error("unknown OOM case - stop core pager thread"); utcb->set_msg_word(0); reply(myself->stack_top(), myself->native_thread().exc_pt_sel + Nova::SM_SEL_EC); } /* be strict in case of the -strict- STOP policy - stop causing thread */ if (policy == STOP) { - PERR("PD has insufficient kernel memory left - stop thread"); + error("PD has insufficient kernel memory left - stop thread"); utcb->set_msg_word(0); reply(myself->stack_top(), obj_dst->sel_sm_block_pause()); } @@ -780,7 +808,7 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src, switch (pager_src) { case SRC_PD_UNKNOWN: /* should not happen on Genode - we create and know every PD in core */ - PERR("Unknown PD has insufficient kernel memory left - stop thread"); + error("Unknown PD has insufficient kernel memory left - stop thread"); utcb->set_msg_word(0); reply(myself->stack_top(), myself->native_thread().exc_pt_sel + Nova::SM_SEL_EC); @@ -819,8 +847,9 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src, utcb->set_msg_word(0); if (res != Nova::NOVA_PD_OOM) - PERR("Upgrading kernel memory failed, policy %u, error %u " - "- stop thread finally", policy, res); + error("upgrading kernel memory failed, policy ", (int)policy, ", " + "error ", (int)res, " - stop thread finally"); + /* else: caller will get blocked until RCU period is over */ /* block caller in semaphore */ @@ -843,7 +872,7 @@ addr_t Pager_object::get_oom_portal() return pt_oom; } - PERR("creating portal for out of memory notification failed"); + error("creating portal for out of memory notification failed"); return 0; } @@ -889,10 +918,10 @@ void Pager_activation_base::entry() { } Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &cap_factory) : _cap_factory(cap_factory) { - /* sanity check space for pager threads */ + /* sanity check for pager threads */ if (kernel_hip()->cpu_max() > PAGER_CPUS) { - PERR("kernel supports more CPUs (%u) than Genode (%u)", - kernel_hip()->cpu_max(), PAGER_CPUS); + error("kernel supports more CPUs (", kernel_hip()->cpu_max(), ") " + "than Genode (", (unsigned)PAGER_CPUS, ")"); nova_die(); } @@ -916,7 +945,7 @@ Pager_capability Pager_entrypoint::manage(Pager_object *obj) /* let handle pager_object of pager thread on same CPU */ unsigned use_cpu = obj->location.xpos(); if (!kernel_hip()->is_cpu_enabled(use_cpu) || !pager_threads[use_cpu]) { - PWRN("invalid CPU parameter used in pager object"); + warning("invalid CPU parameter used in pager object"); return Pager_capability(); } Native_capability pager_thread_cap = diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index 98ccf9b4d..287b9d9b0 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -14,7 +14,6 @@ */ /* Genode includes */ -#include #include #include #include @@ -30,6 +29,7 @@ /* base-internal includes */ #include #include +#include /* NOVA includes */ #include @@ -124,13 +124,12 @@ static void page_fault_handler() (pf_type & Ipc_pager::ERR_W) ? Region_map::State::WRITE_FAULT : Region_map::State::READ_FAULT, 0); - printf("\nstack pointer 0x%lx, qualifiers 0x%lx %s%s%s%s%s\n", - pf_sp, pf_type, - pf_type & Ipc_pager::ERR_I ? "I" : "i", - pf_type & Ipc_pager::ERR_R ? "R" : "r", - pf_type & Ipc_pager::ERR_U ? "U" : "u", - pf_type & Ipc_pager::ERR_W ? "W" : "w", - pf_type & Ipc_pager::ERR_P ? "P" : "p"); + log("\nstack pointer ", Hex(pf_sp), ", qualifiers ", Hex(pf_type), " ", + pf_type & Ipc_pager::ERR_I ? "I" : "i", + pf_type & Ipc_pager::ERR_R ? "R" : "r", + pf_type & Ipc_pager::ERR_U ? "U" : "u", + pf_type & Ipc_pager::ERR_W ? "W" : "w", + pf_type & Ipc_pager::ERR_P ? "P" : "p"); if ((stack_area_virtual_base() <= pf_sp) && (pf_sp < stack_area_virtual_base() + @@ -144,8 +143,7 @@ static void page_fault_handler() Nova::Utcb * utcb_fault = reinterpret_cast(utcb_addr_f); unsigned last_items = utcb_fault->msg_items(); - printf("faulter utcb %p, last message item count %u\n", - utcb_fault, last_items); + log("faulter utcb ", utcb_fault, ", last message item count ", last_items); for (unsigned i = 0; i < last_items; i++) { Nova::Utcb::Item * item = utcb_fault->get_item(i); @@ -156,11 +154,13 @@ static void page_fault_handler() if (crd.is_null()) continue; - printf("%u - type=%x rights=0x%x region=0x%lx+0x%lx " - "hotspot %lx(%lx) - %s\n", i, crd.type(), crd.rights(), - crd.addr(), 1UL << (12 +crd.order()), - crd.hotspot(item->hotspot), item->hotspot, - item->is_del() ? "delegated" : "translated"); + log(i, " - " + "type=", Hex(crd.type()), " " + "rights=", Hex(crd.rights()), " " + "region=", Hex(crd.addr()), "+", Hex(1UL << (12 + crd.order())), " " + "hotspot=", Hex(crd.hotspot(item->hotspot)), + "(", Hex(item->hotspot), ")" + " - ", item->is_del() ? "delegated" : "translated"); } } @@ -187,11 +187,13 @@ static void page_fault_handler() }; int count = 1; - printf(" #%d %08lx %08lx\n", count++, pf_sp, pf_ip); + log(" #", count++, " ", Hex(pf_sp, Hex::PREFIX, Hex::PAD), " ", + Hex(pf_ip, Hex::PREFIX, Hex::PAD)); Core_img dump(pf_sp); while (dump.ip_valid()) { - printf(" #%d %p %08lx\n", count++, dump.ip(), *dump.ip()); + log(" #", count++, " ", Hex((addr_t)dump.ip(), Hex::PREFIX, Hex::PAD), + " ", Hex(*dump.ip(), Hex::PREFIX, Hex::PAD)); dump.next_ip(); } @@ -237,7 +239,7 @@ static void init_core_page_fault_handler() CORE_PAGER_UTCB_ADDR, core_pager_stack_top(), EXC_BASE, GLOBAL); if (ret) - PDBG("create_ec returned %u", ret); + log(__func__, ": create_ec returned ", ret); /* set up page-fault portal */ create_pt(PT_SEL_PAGE_FAULT, __core_pd_sel, ec_sel, @@ -308,6 +310,7 @@ Platform::Platform() : /* * Now that we can access the I/O ports for comport 0, printf works... */ + init_log(); /* * remap main utcb to default utcb address @@ -316,26 +319,26 @@ Platform::Platform() : */ if (map_local(__main_thread_utcb, (addr_t)__main_thread_utcb, (addr_t)main_thread_utcb(), 1, Rights(true, true, false))) { - PERR("could not remap utcb of main thread"); + error("could not remap utcb of main thread"); nova_die(); } /* sanity checks */ if (hip->sel_exc + 3 > NUM_INITIAL_PT_RESERVED) { - printf("configuration error\n"); + error("configuration error (NUM_INITIAL_PT_RESERVED)"); nova_die(); } /* map idle SCs */ unsigned const log2cpu = log2(hip->cpu_max()); if ((1U << log2cpu) != hip->cpu_max()) { - PERR("number of max CPUs is not of power of 2"); + error("number of max CPUs is not of power of 2"); nova_die(); } sc_idle_base = cap_map()->insert(log2cpu + 1); if (sc_idle_base & ((1UL << log2cpu) - 1)) { - PERR("unaligned sc_idle_base value %lx", sc_idle_base); + error("unaligned sc_idle_base value ", Hex(sc_idle_base)); nova_die(); } if(map_local(__main_thread_utcb, Obj_crd(0, log2cpu), @@ -353,7 +356,7 @@ Platform::Platform() : uint8_t res = Nova::sc_ctrl(sc_idle_base + i, n_time); if (res != Nova::NOVA_OK) { sc_init = false; - printf("%u %u %llu - failed\n", i, res, n_time); + error(i, " ", res, " ", n_time, " - failed"); } } if (!sc_init) @@ -371,13 +374,13 @@ Platform::Platform() : if (verbose_boot_info) { if (hip->has_feature_vmx()) - printf("Hypervisor features VMX\n"); + log("Hypervisor features VMX"); if (hip->has_feature_svm()) - printf("Hypervisor features SVM\n"); - printf("Hypervisor reports %ux%u CPU%c - boot CPU is %lu\n", - _cpus.width(), _cpus.height(), _cpus.total() > 1 ? 's' : ' ', boot_cpu()); + log("Hypervisor features SVM"); + log("Hypervisor reports ", _cpus.width(), "x", _cpus.height(), " " + "CPU", _cpus.total() > 1 ? "s" : " ", " - boot CPU is ", boot_cpu()); if (!cpuid_invariant_tsc()) - PWRN("CPU has no invariant TSC."); + warning("CPU has no invariant TSC."); } /* initialize core allocators */ @@ -385,7 +388,7 @@ Platform::Platform() : / hip->mem_desc_size; if (verbose_boot_info) - printf("Hypervisor info page contains %zd memory descriptors:\n", num_mem_desc); + log("Hypervisor info page contains ", num_mem_desc, " memory descriptors:"); addr_t mem_desc_base = ((addr_t)hip + hip->mem_desc_offset); @@ -429,9 +432,10 @@ Platform::Platform() : if (stack_area_virtual_base() <= check[i] && check[i] < stack_area_virtual_base() + stack_area_virtual_size()) { - PERR("overlapping area - [%lx, %lx) vs %lx", - stack_area_virtual_base(), stack_area_virtual_base() + - stack_area_virtual_size(), check[i]); + error("overlapping area - ", + Hex_range(stack_area_virtual_base(), + stack_area_virtual_size()), " vs ", + Hex(check[i])); nova_die(); } } @@ -447,9 +451,12 @@ Platform::Platform() : for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) { if (mem_desc->type != Hip::Mem_desc::AVAILABLE_MEMORY) continue; - if (verbose_boot_info) - printf("detected physical memory: 0x%16llx - size: 0x%llx\n", - mem_desc->addr, mem_desc->size); + if (verbose_boot_info) { + addr_t const base = mem_desc->addr; + size_t const size = mem_desc->size; + log("detected physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD), + " - size: ", Hex(size, Hex::PREFIX, Hex::PAD)); + } if (!mem_desc->size) continue; @@ -465,7 +472,8 @@ Platform::Platform() : size = trunc_page(mem_desc->addr + mem_desc->size) - base; if (verbose_boot_info) - printf("use physical memory: 0x%16lx - size: 0x%zx\n", base, size); + log("use physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD), + " - size: ", Hex(size, Hex::PREFIX, Hex::PAD)); _io_mem_alloc.remove_range(base, size); ram_alloc()->add_range(base, size); @@ -538,10 +546,11 @@ Platform::Platform() : (mem_d->addr >= mem_desc->addr + mem_desc->size)) continue; - PERR("region overlap [0x%8llx+0x%8llx] (%d) with " - "[0x%8llx+0x%8llx] (%d)", - mem_desc->addr, mem_desc->size, mem_desc->type, - mem_d->addr, mem_d->size, mem_d->type); + error("region overlap ", + Hex_range(mem_desc->addr, mem_desc->size), " " + "(", (int)mem_desc->type, ") with ", + Hex_range(mem_d->addr, mem_d->size), " " + "(", (int)mem_d->type, ")"); nova_die(); } } @@ -579,18 +588,14 @@ Platform::Platform() : addr_t core_local_addr = _map_pages(rom_mem_start >> get_page_size_log2(), pages_mapped); if (!core_local_addr) { - PERR("could not map multi boot module"); + error("could not map multi boot module"); nova_die(); } /* adjust core_local_addr of module if it was not page aligned */ core_local_addr += mem_desc->addr - rom_mem_start; - if (verbose_boot_info) - printf("map multi-boot module: physical 0x%8lx+0x%8llx" - " - ", (addr_t)mem_desc->addr, mem_desc->size); - - char * name; + char *name = nullptr; if (aux_in_rom_area) { aux = core_local_addr + (mem_desc->aux - mem_desc->addr); aux_len = strlen(reinterpret_cast(aux)) + 1; @@ -629,7 +634,7 @@ Platform::Platform() : prev_cmd_line_page = curr_cmd_line_page; if (!mapped_cmd_line) { - PERR("could not map command line"); + error("could not map command line"); nova_die(); } } @@ -646,7 +651,11 @@ Platform::Platform() : memset(reinterpret_cast(zero_out), 0, round_page(zero_out) - zero_out); - printf("%s\n", name); + if (verbose_boot_info) + log("map multi-boot module: physical ", + Hex((addr_t)mem_desc->addr, Hex::PREFIX, Hex::PAD), "+", + Hex((size_t)mem_desc->size, Hex::PREFIX, Hex::PAD), " - ", + Cstring(name)); /* revoke mapping of rom module - not needed */ unmap_local(__main_thread_utcb, trunc_page(core_local_addr), @@ -686,9 +695,9 @@ Platform::Platform() : _gsi_base_sel = (hip->mem_desc_offset - hip->cpu_desc_offset) / hip->cpu_desc_size; if (verbose_boot_info) { - printf(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); - printf(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); - printf(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); + log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + log(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); } /* add capability selector ranges to map */ @@ -706,13 +715,6 @@ Platform::Platform() : cap_map()->insert(range); -/* - if (verbose_boot_info) - printf("add cap range [0x%8lx:0x%8lx) - physical 0x%8lx -> 0x%8lx\n", - range->base(), - range->base() + range->elements(), phys_addr, core_local_addr); -*/ - index = range->base() + range->elements(); } diff --git a/repos/base-nova/src/core/platform_pd.cc b/repos/base-nova/src/core/platform_pd.cc index 6b7fe4ad4..5f6e960fa 100644 --- a/repos/base-nova/src/core/platform_pd.cc +++ b/repos/base-nova/src/core/platform_pd.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -35,7 +35,7 @@ bool Platform_pd::bind_thread(Platform_thread *thread) void Platform_pd::unbind_thread(Platform_thread *thread) { - PDBG("not implemented"); + warning(__func__, "not implemented"); } diff --git a/repos/base-nova/src/core/platform_thread.cc b/repos/base-nova/src/core/platform_thread.cc index 0981d5f93..5dc342b4a 100644 --- a/repos/base-nova/src/core/platform_thread.cc +++ b/repos/base-nova/src/core/platform_thread.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -39,7 +39,7 @@ using namespace Genode; void Platform_thread::affinity(Affinity::Location location) { - PERR("dynamic affinity change not supported on NOVA"); + error("dynamic affinity change not supported on NOVA"); } @@ -51,20 +51,20 @@ int Platform_thread::start(void *ip, void *sp) using namespace Nova; if (!_pager) { - PERR("pager undefined"); + error("pager undefined"); return -1; } if (!_pd || (main_thread() && !vcpu() && _pd->parent_pt_sel() == Native_thread::INVALID_INDEX)) { - PERR("protection domain undefined"); + error("protection domain undefined"); return -2; } addr_t const pt_oom = _pager->get_oom_portal(); if (!pt_oom || map_local((Utcb *)Thread::myself()->utcb(), Obj_crd(pt_oom, 0), Obj_crd(_sel_pt_oom(), 0))) { - PERR("setup of out-of-memory notification portal - failed"); + error("setup of out-of-memory notification portal - failed"); return -8; } @@ -73,7 +73,7 @@ int Platform_thread::start(void *ip, void *sp) addr_t const utcb = vcpu() ? 0 : round_page(initial_sp); if (_sel_exc_base == Native_thread::INVALID_INDEX) { - PERR("exception base not specified"); + error("exception base not specified"); return -3; } @@ -85,7 +85,7 @@ int Platform_thread::start(void *ip, void *sp) utcb, initial_sp, _sel_exc_base, !worker()); if (res == Nova::NOVA_PD_OOM && Nova::NOVA_OK != _pager->handle_oom()) { _pager->assign_pd(Native_thread::INVALID_INDEX); - PERR("creation of new thread failed %u", res); + error("creation of new thread failed ", res); return -4; } } while (res != Nova::NOVA_OK); @@ -103,7 +103,7 @@ int Platform_thread::start(void *ip, void *sp) } if (_sel_exc_base != Native_thread::INVALID_INDEX) { - PERR("thread already started"); + error("thread already started"); return -5; } @@ -139,7 +139,7 @@ int Platform_thread::start(void *ip, void *sp) uint8_t res = create_pd(pd_sel, pd_core_sel, initial_pts, KEEP_FREE_PAGES_NOT_AVAILABLE_FOR_UPGRADE, UPPER_LIMIT_PAGES); if (res != NOVA_OK) { - PERR("create_pd returned %d", res); + error("create_pd returned ", res); goto cleanup_pd; } @@ -148,7 +148,7 @@ int Platform_thread::start(void *ip, void *sp) res = create_ec(_sel_ec(), pd_sel, _location.xpos(), pd_utcb, 0, 0, THREAD_GLOBAL); if (res != NOVA_OK) { - PERR("create_ec returned %d", res); + error("create_ec returned ", res); goto cleanup_pd; } @@ -179,7 +179,7 @@ int Platform_thread::start(void *ip, void *sp) _pager->initial_esp(0); _pager->assign_pd(Native_thread::INVALID_INDEX); - PERR("create_sc returned %d", res); + error("create_sc returned ", res); goto cleanup_ec; } @@ -214,8 +214,7 @@ void Platform_thread::resume() uint8_t res; do { if (!_pd) { - PERR("protection domain undefined %s - resuming thread failed", - __PRETTY_FUNCTION__); + error("protection domain undefined - resuming thread failed"); return; } res = create_sc(_sel_sc(), _pd->pd_sel(), _sel_ec(), @@ -305,7 +304,7 @@ const char * Platform_thread::pd_name() const { Weak_ptr Platform_thread::address_space() { if (!_pd) { - PERR("protection domain undefined %s", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": protection domain undefined"); return Weak_ptr(); } return _pd->Address_space::weak_ptr(); @@ -325,7 +324,7 @@ unsigned long long Platform_thread::execution_time() const uint8_t res = Nova::sc_ctrl(_sel_sc(), time); if (res != Nova::NOVA_OK) - PDBG("sc_ctrl failed res=%x", res); + warning("sc_ctrl failed res=", res); return time; } @@ -341,12 +340,12 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio, _name(name) { if (_priority == 0) { - PWRN("priority of thread '%s' below minimum - boost to 1", _name.string()); + warning("priority of thread '", _name, "' below minimum - boost to 1"); _priority = 1; } if (_priority > Nova::Qpd::DEFAULT_PRIORITY) { - PWRN("priority of thread '%s' above maximum - limit to %u", - _name.string(), Nova::Qpd::DEFAULT_PRIORITY); + warning("priority of thread '", _name, "' above maximum - limit to ", + (unsigned)Nova::Qpd::DEFAULT_PRIORITY); _priority = Nova::Qpd::DEFAULT_PRIORITY; } } diff --git a/repos/base-nova/src/core/ram_session_support.cc b/repos/base-nova/src/core/ram_session_support.cc index b77d0ebf2..ef3b921a1 100644 --- a/repos/base-nova/src/core/ram_session_support.cc +++ b/repos/base-nova/src/core/ram_session_support.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include /* core includes */ diff --git a/repos/base-nova/src/core/rpc_cap_factory.cc b/repos/base-nova/src/core/rpc_cap_factory.cc index bd6cb4eee..015491c75 100644 --- a/repos/base-nova/src/core/rpc_cap_factory.cc +++ b/repos/base-nova/src/core/rpc_cap_factory.cc @@ -43,8 +43,12 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep, addr_t entry, add if (res == NOVA_OK) return Capability_space::import(pt_sel); - PERR("cap_session - cap=%lx:%lx addr=%lx mtd=%lx xpt=%lx res=%u", - ec_sel, ep.local_name(), entry, mtd, pt_sel, res); + error("cap alloc - " + "cap=", Hex(ec_sel), ":", Hex(ep.local_name()), " " + "entry=", Hex(entry), " " + "mtd=", Hex(mtd), " " + "xpt=", Hex(pt_sel), " " + "res=", res); _list.remove(pt_cap); destroy(&_slab, pt_cap); @@ -72,7 +76,7 @@ void Rpc_cap_factory::free(Native_capability cap) return; } } - PDBG("invalid cap object"); + warning("attempt to free invalid cap object"); } diff --git a/repos/base-nova/src/core/thread_start.cc b/repos/base-nova/src/core/thread_start.cc index 53bfd1b3c..3583b579e 100644 --- a/repos/base-nova/src/core/thread_start.cc +++ b/repos/base-nova/src/core/thread_start.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include -#include +#include /* base-internal includes */ #include @@ -61,7 +61,7 @@ void Thread::_init_platform_thread(size_t, Type type) addr_t rs_sel =native_thread().exc_pt_sel + SM_SEL_EC; uint8_t res = create_sm(rs_sel, pd_sel, 0); if (res != NOVA_OK) { - PERR("create_sm returned %u", res); + error("create_sm returned ", res); throw Cpu_session::Thread_creation_failed(); } } @@ -105,7 +105,7 @@ void Thread::start() uint8_t res = create_ec(native_thread().ec_sel, pd_sel, location.xpos(), utcb, sp, native_thread().exc_pt_sel, LOCAL_THREAD); if (res != NOVA_OK) { - PERR("create_ec returned %d cpu=%u", res, location.xpos()); + error("create_ec returned ", res, " cpu=", location.xpos()); throw Cpu_session::Thread_creation_failed(); } @@ -116,7 +116,7 @@ void Thread::start() if (map_local(reinterpret_cast(Thread::myself()->utcb()), Obj_crd(PT_SEL_PAGE_FAULT, 0), Obj_crd(native_thread().exc_pt_sel + PT_SEL_PAGE_FAULT, 0))) { - PERR("could not create page fault portal"); + error("could not create page fault portal"); throw Cpu_session::Thread_creation_failed(); } } diff --git a/repos/base-nova/src/include/base/internal/ipc.h b/repos/base-nova/src/include/base/internal/ipc.h index d152f49d2..c399686f5 100644 --- a/repos/base-nova/src/include/base/internal/ipc.h +++ b/repos/base-nova/src/include/base/internal/ipc.h @@ -48,8 +48,9 @@ static inline Nova::mword_t copy_utcb_to_msgbuf(Nova::Utcb &utcb, size_t num_data_words = num_msg_words - 1; if (num_data_words*sizeof(mword_t) > rcv_msg.capacity()) { - PERR("receive message buffer too small msg size=%zx, buf size=%zd", - num_data_words*sizeof(mword_t), rcv_msg.capacity()); + error("receive message buffer too small msg " + "size=", num_data_words*sizeof(mword_t), " " + "buf size=", rcv_msg.capacity()); num_data_words = rcv_msg.capacity()/sizeof(mword_t); } @@ -91,7 +92,7 @@ static inline bool copy_msgbuf_to_utcb(Nova::Utcb &utcb, enum { NUM_MSG_REGS = 256 }; if (num_msg_words > NUM_MSG_REGS) { - PERR("Message does not fit into UTCB message registers\n"); + error("message does not fit into UTCB message registers"); num_msg_words = NUM_MSG_REGS; } diff --git a/repos/base-nova/src/include/signal_source/client.h b/repos/base-nova/src/include/signal_source/client.h index 2a2662a6b..b1ddb028e 100644 --- a/repos/base-nova/src/include/signal_source/client.h +++ b/repos/base-nova/src/include/signal_source/client.h @@ -90,7 +90,7 @@ namespace Genode { /* block on semaphore until signal context was submitted */ if (uint8_t res = si_ctrl(_sem.local_name(), SEMAPHORE_DOWN, imprint, count)) - PWRN("signal reception failed - error %u", res); + warning("signal reception failed - error ", res); } while (imprint == 0); diff --git a/repos/base-nova/src/lib/base/cap_map.cc b/repos/base-nova/src/lib/base/cap_map.cc index b46a7da87..ff94fe20e 100644 --- a/repos/base-nova/src/lib/base/cap_map.cc +++ b/repos/base-nova/src/lib/base/cap_map.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* NOVA includes */ #include @@ -55,8 +55,7 @@ void Cap_range::inc(unsigned id) } if (failure) - PERR("cap reference counting error - reference overflow of cap=%lx", - _base + id); + error("cap reference counting error - reference overflow of cap=", _base + id); } @@ -82,8 +81,9 @@ void Cap_range::dec(unsigned const id_start, bool revoke, unsigned num_log_2) } if (failure) - PERR("cap reference counting error - one counter of cap range %lx+%x " - "has been already zero", _base + id_start, 1 << num_log_2); + error("cap reference counting error - one counter of cap ", + "range ", _base + id_start, "+", 1 << num_log_2, " " + "has been already zero"); } diff --git a/repos/base-nova/src/lib/base/capability.cc b/repos/base-nova/src/lib/base/capability.cc index ca776beb9..1abac4d61 100644 --- a/repos/base-nova/src/lib/base/capability.cc +++ b/repos/base-nova/src/lib/base/capability.cc @@ -11,8 +11,6 @@ * under the terms of the GNU General Public License version 2. */ -#include - /* base-internal includes */ #include diff --git a/repos/base-nova/src/lib/base/ipc.cc b/repos/base-nova/src/lib/base/ipc.cc index fa4894ca7..fc1a6efe4 100644 --- a/repos/base-nova/src/lib/base/ipc.cc +++ b/repos/base-nova/src/lib/base/ipc.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include /* base-internal includes */ #include @@ -51,7 +51,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst, /* the protocol value is unused as the badge is delivered by the kernel */ if (!copy_msgbuf_to_utcb(utcb, snd_msg, 0)) { - PERR("could not setup IPC"); + error("could not setup IPC"); throw Ipc_error(); } diff --git a/repos/base-nova/src/lib/base/rpc_entrypoint.cc b/repos/base-nova/src/lib/base/rpc_entrypoint.cc index 72e1a105e..4b2664d17 100644 --- a/repos/base-nova/src/lib/base/rpc_entrypoint.cc +++ b/repos/base-nova/src/lib/base/rpc_entrypoint.cc @@ -14,7 +14,6 @@ */ /* Genode includes */ -#include #include #include @@ -94,8 +93,7 @@ void Rpc_entrypoint::_dissolve(Rpc_object_base *obj) utcb->msg[0] = 0xdead; utcb->set_msg_word(1); if (uint8_t res = call(_cap.local_name())) - PERR("%8p - could not clean up entry point of thread 0x%p - res %u", - utcb, this->utcb(), res); + error(utcb, " - could not clean up entry point of thread ", this->utcb(), " - res ", res); } @@ -140,7 +138,7 @@ void Rpc_entrypoint::_activation_entry() /* in case of a portal cleanup call we are done here - just reply */ if (ep._cap.local_name() == (long)id_pt) { if (!rcv_window.prepare_rcv_window(utcb)) - PWRN("out of capability selectors for handling server requests"); + warning("out of capability selectors for handling server requests"); ep._rcv_buf.reset(); reply(utcb, exc, ep._snd_buf); @@ -153,8 +151,7 @@ void Rpc_entrypoint::_activation_entry() /* atomically lookup and lock referenced object */ auto lambda = [&] (Rpc_object_base *obj) { if (!obj) { - PERR("could not look up server object, return from call id_pt=%lx", - id_pt); + error("could not look up server object, return from call id_pt=", id_pt); return; } @@ -166,7 +163,7 @@ void Rpc_entrypoint::_activation_entry() ep.apply(id_pt, lambda); if (!rcv_window.prepare_rcv_window(*(Nova::Utcb *)ep.utcb())) - PWRN("out of capability selectors for handling server requests"); + warning("out of capability selectors for handling server requests"); ep._rcv_buf.reset(); reply(utcb, exc, ep._snd_buf); @@ -238,7 +235,7 @@ Rpc_entrypoint::~Rpc_entrypoint() typedef Object_pool Pool; Pool::remove_all([&] (Rpc_object_base *obj) { - PWRN("Object pool not empty in %s", __func__); + warning("object pool not empty in ", __func__); _dissolve(obj); }); diff --git a/repos/base-nova/src/lib/base/signal_submit.cc b/repos/base-nova/src/lib/base/signal_submit.cc index 3c2df933d..a8ab5287f 100644 --- a/repos/base-nova/src/lib/base/signal_submit.cc +++ b/repos/base-nova/src/lib/base/signal_submit.cc @@ -14,6 +14,7 @@ /* Genode includes */ #include +#include #include /* NOVA includes */ @@ -40,8 +41,7 @@ void Signal_transmitter::submit(unsigned cnt) if (res == NOVA_OK) return; - PDBG("submitting signal failed - error %u - context=0x%lx", res, - _context.local_name()); + warning("submitting signal failed - error ", res, " - context=", _context); _context = Signal_context_capability(); } diff --git a/repos/base-nova/src/lib/base/thread_start.cc b/repos/base-nova/src/lib/base/thread_start.cc index cee4bec8a..d1a948ec8 100644 --- a/repos/base-nova/src/lib/base/thread_start.cc +++ b/repos/base-nova/src/lib/base/thread_start.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -47,8 +47,8 @@ void Thread::_thread_start() Thread::myself()->entry(); } catch (...) { try { - PERR("Thread '%s' died because of an uncaught exception", - Thread::myself()->name().string()); + error("Thread '", Thread::myself()->name(), "' " + "died because of an uncaught exception"); } catch (...) { /* die in a noisy way */ nova_die(); diff --git a/repos/base-nova/src/test/platform/ipc.cc b/repos/base-nova/src/test/platform/ipc.cc index eb4967c6a..a1288280f 100644 --- a/repos/base-nova/src/test/platform/ipc.cc +++ b/repos/base-nova/src/test/platform/ipc.cc @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include /* test specific includes */ #include "server.h" diff --git a/repos/base-nova/src/test/platform/main.cc b/repos/base-nova/src/test/platform/main.cc index c6d6d2e41..854481ddf 100644 --- a/repos/base-nova/src/test/platform/main.cc +++ b/repos/base-nova/src/test/platform/main.cc @@ -13,7 +13,7 @@ */ #include -#include +#include #include #include @@ -53,7 +53,7 @@ void test_translate() local_name == (addr_t)Native_thread::INVALID_INDEX) { failed ++; - PERR("%s: ipc call failed %lx", __func__, rpc); + error(__func__, ": ipc call failed ", Hex(rpc)); ep.dissolve(&component); return; } @@ -66,21 +66,21 @@ void test_translate() local_name == (addr_t)Native_thread::INVALID_INDEX) { failed ++; - PERR("%s: ipc call failed %lx", __func__, rpc); + error(__func__, ": ipc call failed ", Hex(rpc)); ep.dissolve(&component); return; } Genode::Native_capability copy2 = Capability_space::import(local_name); - PINF("delegation session_cap->copy1->copy2 0x%lx->0x%lx->0x%lx", - session_cap.local_name(), copy1.local_name(), copy2.local_name()); + log("delegation session_cap->copy1->copy2 ", + session_cap, "->", copy1, "->", copy2); /* sanity checks translate which must work */ Genode::Native_capability got_cap = client.cap_cap(copy2.local_name()); if (got_cap.local_name() != copy1.local_name()) { failed ++; - PERR("%u:%s translate failed", __LINE__, __func__); + error(__LINE__, ":", __func__, " translate failed"); ep.dissolve(&component); return; } @@ -88,7 +88,7 @@ void test_translate() got_cap = client.cap_cap(copy1.local_name()); if (got_cap.local_name() != session_cap.local_name()) { failed ++; - PERR("%u:%s translate failed", __LINE__, __func__); + error(__LINE__, ":", __func__, " translate failed"); ep.dissolve(&component); return; } @@ -96,7 +96,7 @@ void test_translate() got_cap = client.cap_cap(session_cap.local_name()); if (got_cap.local_name() != session_cap.local_name()) { failed ++; - PERR("%u:%s translate failed", __LINE__, __func__); + error(__LINE__, ":", __func__, " translate failed"); ep.dissolve(&component); return; } @@ -114,7 +114,7 @@ void test_translate() Genode::uint8_t res = Nova::lookup(crd_ses); if (res != Nova::NOVA_OK || !crd_ses.is_null()) { failed ++; - PERR("%u - lookup call failed err=%x", __LINE__, res); + error(__LINE__, " - lookup call failed err=", Hex(res)); ep.dissolve(&component); return; } @@ -123,7 +123,7 @@ void test_translate() got_cap = client.cap_cap(copy2.local_name()); if (got_cap.local_name() != session_cap.local_name()) { failed ++; - PERR("%u:%s translate failed", __LINE__, __func__); + error(__LINE__, ":", __func__, " translate failed"); ep.dissolve(&component); return; } @@ -148,7 +148,7 @@ void test_revoke() local_name == (addr_t)Native_thread::INVALID_INDEX) { failed ++; - PERR("test_revoke ipc call failed %lx", rpc); + error("test_revoke ipc call failed ", Hex(rpc)); ep.dissolve(&component); return; } @@ -161,7 +161,7 @@ void test_revoke() local_name == (addr_t)Native_thread::INVALID_INDEX) { failed ++; - PERR("test_revoke ipc call failed %lx", rpc); + error("test_revoke ipc call failed ", Hex(rpc)); ep.dissolve(&component); return; } @@ -171,7 +171,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_dst.base() != local_name || crd_dst.type() != 3 || crd_dst.order() != 0) { failed ++; - PERR("%u - lookup call failed %x", __LINE__, res); + error(__LINE__, " - lookup call failed ", Hex(res)); ep.dissolve(&component); return; } @@ -181,7 +181,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_ses.base() != (addr_t)copy_session_cap.local_name() || crd_ses.type() != 3 || crd_ses.order() != 0) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_ses.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_ses.is_null()); ep.dissolve(&component); return; } @@ -190,7 +190,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_dst.base() != local_name || crd_dst.type() != 3 || crd_dst.order() != 0) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_dst.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_dst.is_null()); ep.dissolve(&component); return; } @@ -203,7 +203,7 @@ void test_revoke() res = Nova::lookup(crd_ses); if (res != Nova::NOVA_OK || !crd_ses.is_null()) { failed ++; - PERR("%u - lookup call failed err=%x", __LINE__, res); + error(__LINE__, " - lookup call failed err=", Hex(res)); ep.dissolve(&component); return; } @@ -212,7 +212,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_dst.base() != local_name || crd_dst.type() != 3 || crd_dst.order() != 0) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_dst.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_dst.is_null()); ep.dissolve(&component); return; } @@ -231,7 +231,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_ses.base() != (addr_t)copy_session_cap.local_name() || crd_ses.type() != 3 || crd_ses.order() != 0) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_ses.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_ses.is_null()); ep.dissolve(&component); return; } @@ -244,7 +244,7 @@ void test_revoke() if (res != Nova::NOVA_OK || crd_dst.base() != local_name || crd_dst.type() != 3 || crd_dst.order() != 0) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_dst.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_dst.is_null()); ep.dissolve(&component); return; } @@ -257,7 +257,7 @@ void test_revoke() res = Nova::lookup(crd_dst); if (res != Nova::NOVA_OK || !crd_dst.is_null()) { failed ++; - PERR("%u - lookup call failed err=%x is_null=%u", __LINE__, res, crd_dst.is_null()); + error(__LINE__, " - lookup call failed err=", Hex(res), " is_null=", crd_dst.is_null()); return; } } @@ -346,9 +346,9 @@ void test_pat() if (check_pat && diff_run * 100 / hip->tsc_freq) { failed ++; - PERR("map=%llx remap=%llx --> diff=%llx freq_tsc=%u %llu us", - map_run, remap_run, diff_run, hip->tsc_freq, - diff_run * 1000 / hip->tsc_freq); + error("map=", Hex(map_run), " remap=", Hex(remap_run), " --> " + "diff=", Hex(diff_run), " freq_tsc=", hip->tsc_freq, " ", + diff_run * 1000 / hip->tsc_freq, " us"); } Nova::revoke(Nova::Mem_crd(remap_addr >> PAGE_4K, DS_ORDER, all)); @@ -376,7 +376,7 @@ void test_server_oom() Genode::Native_capability got_cap = client.void_cap(); if (!got_cap.valid()) { - PERR("%u cap id %lx invalid", i, got_cap.local_name()); + error(i, " cap id ", Hex(got_cap.local_name()), " invalid"); failed ++; break; } @@ -386,7 +386,7 @@ void test_server_oom() idx.inc(); if (i % 5000 == 4999) - PINF("received %u. cap", i); + log("received ", i, ". cap"); } /* XXX this code does does no longer work since the removal of 'solely_map' */ @@ -399,13 +399,13 @@ void test_server_oom() send_cap.solely_map(); if (!client.cap_void(send_cap)) { - PERR("sending %4u. cap failed", i); + error("sending ", i, ". cap failed"); failed ++; break; } if (i % 5000 == 4999) - PINF("sent %u. cap", i); + log("sent ", i, ". cap"); } #endif @@ -423,7 +423,7 @@ class Greedy : public Thread_deprecated<4096> { void entry() { - PINF("starting"); + log("starting"); enum { SUB_RM_SIZE = 2UL * 1024 * 1024 * 1024 }; @@ -436,8 +436,8 @@ class Greedy : public Thread_deprecated<4096> { addr_t const page_fault_portal = native_thread().exc_pt_sel + 14; - PERR("cause mappings in range [0x%lx, 0x%lx) %p", mem, - mem + SUB_RM_SIZE - 1, &mem); + log("cause mappings in range ", + Hex_range(mem, SUB_RM_SIZE), " ", &mem); for (addr_t map_to = mem; map_to < mem + SUB_RM_SIZE; map_to += 4096) { @@ -450,7 +450,7 @@ class Greedy : public Thread_deprecated<4096> { /* trigger faked page fault */ Genode::uint8_t res = Nova::call(page_fault_portal); if (res != Nova::NOVA_OK) { - PINF("call result=%u", res); + log("call result=", res); failed++; return; } @@ -460,13 +460,13 @@ class Greedy : public Thread_deprecated<4096> { /* print status information in interval of 32M */ if (!(map_to & (32UL * 1024 * 1024 - 1))) { - printf("0x%lx\n", map_to); + log(Hex(map_to)); /* trigger some work to see quota in kernel decreasing */ // Nova::Rights rwx(true, true, true); // Nova::revoke(Nova::Mem_crd((map_to - 32 * 1024 * 1024) >> 12, 12, rwx)); } } - printf("still alive - done\n"); + log("still alive - done"); } }; @@ -483,16 +483,16 @@ void check(uint8_t res, const char *format, ...) va_end(list); if (res == Nova::NOVA_OK) { - PERR("res=%u %s - TEST FAILED", res, buf); + error("res=", res, " ", Cstring(buf), " - TEST FAILED"); failed++; } else - printf("res=%u %s\n", res, buf); + log("res=", res, " ", Cstring(buf)); } int main(int argc, char **argv) { - printf("testing base-nova platform\n"); + log("testing base-nova platform"); try { Genode::config()->xml_node().attribute("check_pat").value(&check_pat); @@ -564,7 +564,7 @@ int main(int argc, char **argv) core_pagefault_oom.join(); if (!failed) - printf("Test finished\n"); + log("Test finished"); return -failed; } diff --git a/repos/base-okl4/src/core/core_region_map.cc b/repos/base-okl4/src/core/core_region_map.cc index b36591044..c07fdec8d 100644 --- a/repos/base-okl4/src/core/core_region_map.cc +++ b/repos/base-okl4/src/core/core_region_map.cc @@ -37,20 +37,20 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, & get_page_mask(); if (use_local_addr) { - PERR("Parameter 'use_local_addr' not supported within core"); + error("parameter 'use_local_addr' not supported within core"); return nullptr; } if (offset) { - PERR("Parameter 'offset' not supported within core"); + error("parameter 'offset' not supported within core"); return nullptr; } /* allocate range in core's virtual address space */ void *virt_addr; if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { - PERR("Could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return nullptr; } diff --git a/repos/base-okl4/src/core/include/map_local.h b/repos/base-okl4/src/core/include/map_local.h index 495e416db..3cc4cea83 100644 --- a/repos/base-okl4/src/core/include/map_local.h +++ b/repos/base-okl4/src/core/include/map_local.h @@ -15,7 +15,7 @@ #define _CORE__INCLUDE__MAP_LOCAL_H_ /* Genode includes */ -#include +#include /* core includes */ #include @@ -36,8 +36,8 @@ namespace Genode { L4_FpageAddRightsTo(&fpage, L4_FullyAccessible); int ret = L4_UnmapFpage(L4_rootspace, fpage); if (ret != 1) - PERR("could not unmap page at %p from core (Error Code %ld)", - (void *)base, L4_ErrorCode()); + error("could not unmap page at ", Hex(base), " from core, " + "error=", L4_ErrorCode()); } /** @@ -61,7 +61,7 @@ namespace Genode { fpage.X.rwx = 7; if (L4_MapFpage(L4_rootspace, fpage, phys_desc) != 1) { - PERR("Core-local memory mapping failed, Error Code=%d\n", (int)L4_ErrorCode()); + error("core-local memory mapping failed, error=", L4_ErrorCode()); return false; } offset += get_page_size(); diff --git a/repos/base-okl4/src/core/include/util.h b/repos/base-okl4/src/core/include/util.h index 7fec16926..be6c30d9b 100644 --- a/repos/base-okl4/src/core/include/util.h +++ b/repos/base-okl4/src/core/include/util.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include #include /* base-internal includes */ @@ -50,7 +50,7 @@ namespace Genode { inline void panic(const char *s) { using namespace Okl4; - PDBG("Panic: %s", s); + error("Panic: ", s); ENTER_KDB("> panic <"); } @@ -58,7 +58,7 @@ namespace Genode { { using namespace Okl4; if (!val) { - PERR("Assertion failed: %s", s); + error("assertion failed: ", s); ENTER_KDB("Assertion failed"); } } @@ -117,10 +117,9 @@ namespace Genode { Region_map::State::Fault_type pf_type, unsigned long faulter_badge) { - printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, - faulter_badge); + log(pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", " (", + msg, " pf_addr=", Hex(pf_addr), " pf_ip=", Hex(pf_ip), " " + "from ", Hex(faulter_badge), ")"); } inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; } diff --git a/repos/base-okl4/src/core/irq_session_component.cc b/repos/base-okl4/src/core/irq_session_component.cc index 67299c4df..3c166d6d5 100644 --- a/repos/base-okl4/src/core/irq_session_component.cc +++ b/repos/base-okl4/src/core/irq_session_component.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -55,8 +55,8 @@ bool Irq_object::_associate() L4_LoadMR(0, _irq); int ret = L4_AllowInterruptControl(L4_rootspace); if (ret != 1) { - PERR("L4_AllowInterruptControl returned %d, error code=%ld\n", - ret, L4_ErrorCode()); + error("L4_AllowInterruptControl returned ", ret, ", error=", + L4_ErrorCode()); return false; } @@ -67,8 +67,8 @@ bool Irq_object::_associate() L4_LoadMR(0, _irq); ret = L4_RegisterInterrupt(thread_get_my_global_id(), IRQ_NOTIFY_BIT, 0, 0); if (ret != 1) { - PERR("L4_RegisterInterrupt returned %d, error code=%ld\n", - ret, L4_ErrorCode()); + error("L4_RegisterInterrupt returned ", ret, ", error=", + L4_ErrorCode()); return false; } @@ -98,7 +98,7 @@ void Irq_object::start() void Irq_object::entry() { if (!_associate()) - PERR("Could not associate with IRQ 0x%x", _irq); + error("could not associate with IRQ ", Hex(_irq)); /* thread is up and ready */ _sync_bootup.unlock(); @@ -148,7 +148,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, throw Root::Unavailable(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { - PERR("Unavailable IRQ 0x%x requested", _irq_number); + error("unavailable IRQ ", Hex(_irq_number), " requested"); throw Root::Unavailable(); } @@ -158,7 +158,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, Irq_session_component::~Irq_session_component() { - PDBG("Not yet implemented!"); + warning(__func__, " not yet implemented!"); } diff --git a/repos/base-okl4/src/core/pager.cc b/repos/base-okl4/src/core/pager.cc index defdfef66..f96319ee2 100644 --- a/repos/base-okl4/src/core/pager.cc +++ b/repos/base-okl4/src/core/pager.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -44,11 +44,11 @@ using namespace Okl4; static inline void print_page_fault(L4_Word_t type, L4_Word_t addr, L4_Word_t ip, unsigned long badge) { - printf("page (%s%s%s) fault at fault_addr=%lx, fault_ip=%lx, from=%lx\n", - type & L4_Readable ? "r" : "-", - type & L4_Writable ? "w" : "-", - type & L4_eXecutable ? "x" : "-", - addr, ip, badge); + log("page (", + type & L4_Readable ? "r" : "-", + type & L4_Writable ? "w" : "-", + type & L4_eXecutable ? "x" : "-", + ") fault at fault_addr=, ", Hex(addr), ", ip=", Hex(ip), ", from=", badge); } @@ -106,9 +106,9 @@ void Ipc_pager::wait_for_fault() L4_StoreMR(1, &_fault_ip); if (verbose_exception) - PERR("Exception (label 0x%x) occured in space %d at IP 0x%p", - (int)L4_Label(_faulter_tag), (int)L4_SenderSpace().raw, - (void *)_fault_ip); + error("exception (label ", Hex(L4_Label(_faulter_tag)), ") occured, " + "space=", Hex(L4_SenderSpace().raw), ", " + "ip=", Hex(_fault_ip)); } /* page fault */ @@ -133,8 +133,7 @@ void Ipc_pager::reply_and_wait_for_fault() _reply_mapping.phys_desc()); if (ret != 1) - PERR("L4_MapFpage returned %d, error_code=%d", - ret, (int)L4_ErrorCode()); + error("L4_MapFpage returned ", ret, ", error=", L4_ErrorCode()); /* reply to page-fault message to resume the faulting thread */ acknowledge_wakeup(); diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc index b4137f7e0..92c823ecf 100644 --- a/repos/base-okl4/src/core/platform.cc +++ b/repos/base-okl4/src/core/platform.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -21,6 +21,7 @@ #include #include #include +#include /* core includes */ #include @@ -38,8 +39,6 @@ namespace Okl4 { using namespace Genode; -static const bool verbose_boot_info = false; - enum { MAX_BOOT_MODULES = 64 }; enum { MAX_BOOT_MODULE_NAME_LEN = 32 }; static struct @@ -75,10 +74,6 @@ int Platform::bi_init_mem(Okl4::uintptr_t virt_base, Okl4::uintptr_t virt_end, Okl4::uintptr_t phys_base, Okl4::uintptr_t phys_end, const Okl4::bi_user_data_t *data) { - if (verbose_boot_info) - printf("init_mem: virt=[%08lx,%08lx), phys=[%08lx,%08lx)\n", - virt_base, virt_end, phys_base, phys_end); - Platform *p = (Platform *)data->user_data; p->_core_mem_alloc.phys_alloc()->add_range(phys_base, phys_end - phys_base + 1); p->_core_mem_alloc.virt_alloc()->add_range(virt_base, virt_end - virt_base + 1); @@ -89,10 +84,6 @@ int Platform::bi_init_mem(Okl4::uintptr_t virt_base, Okl4::uintptr_t virt_end, int Platform::bi_add_virt_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base, Okl4::uintptr_t end, const Okl4::bi_user_data_t *data) { - if (verbose_boot_info) - printf("add_virt_mem: pool=%d region=[0x%08lx,0x%08lx], %ld pages\n", - pool, base, end, (end - base + 1)/4096); - /* prevent first page from being added to core memory */ if (base < get_page_size() || end < get_page_size()) return 0; @@ -106,10 +97,6 @@ int Platform::bi_add_virt_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base, int Platform::bi_add_phys_mem(Okl4::bi_name_t pool, Okl4::uintptr_t base, Okl4::uintptr_t end, const Okl4::bi_user_data_t *data) { - if (verbose_boot_info) - printf("add_phys_mem: pool=%d region=[0x%08lx,0x%08lx], %ld pages\n", - pool, base, end, (end - base + 1)/4096); - if (pool == 2) { Platform *p = (Platform *)data->user_data; p->_core_mem_alloc.phys_alloc()->add_range(base, end - base + 1); @@ -122,10 +109,6 @@ int Platform::bi_export_object(Okl4::bi_name_t pd, Okl4::bi_name_t obj, Okl4::bi_export_type_t export_type, char *key, Okl4::size_t key_len, const Okl4::bi_user_data_t * data) { - if (verbose_boot_info) - printf("export_object: pd=%d obj=%d type=%d key=\"%s\"\n", - pd, obj, export_type, key); - /* * We walk the boot info only once and collect all memory section * objects. Each time we detect a memory section outside of roottask @@ -139,7 +122,7 @@ int Platform::bi_export_object(Okl4::bi_name_t pd, Okl4::bi_name_t obj, return 0; if (num_boot_module_objects >= MAX_BOOT_MODULES) { - PERR("Maximum number of boot modules exceeded"); + error("maximum number of boot modules exceeded"); return -1; } @@ -168,10 +151,6 @@ Okl4::bi_name_t Platform::bi_new_ms(Okl4::bi_name_t owner, Okl4::bi_name_t physpool, Okl4::bi_name_t virtpool, Okl4::bi_name_t zone, const Okl4::bi_user_data_t *data) { - if (verbose_boot_info) - printf("new_ms: owner=%d region=[%lx,%lx), flags=%lx, attr=%lx, physpool=%d, virtpool=%d, zone=%d\n", - owner, base, base + size - 1, flags, attr, physpool, virtpool, zone); - /* reset module index (see comment in 'bi_export_object') */ if (owner == 0) num_boot_module_memsects = 0; @@ -179,7 +158,7 @@ Okl4::bi_name_t Platform::bi_new_ms(Okl4::bi_name_t owner, if (virtpool != 3) return 0; if (num_boot_module_memsects >= MAX_BOOT_MODULES) { - PERR("Maximum number of boot modules exceeded"); + error("maximum number of boot modules exceeded"); return -1; } @@ -237,8 +216,6 @@ Platform::Platform() : * the location of the boot modules. */ - printf("parsing boot info at 0x%p...\n", (void *)boot_info_addr); - /* * Initialize callback function for parsing the boot-info * @@ -281,19 +258,14 @@ Platform::Platform() : _vm_start = 0x1000; _vm_size = 0xb0000000 - 0x1000; - /* - * When dumping 'ram_alloc', there are several small blocks in addition - * to the available free memory visible. These small blocks are used to - * hold the meta data for the ROM modules as initialized by '_setup_rom'. - */ - if (verbose_boot_info) { - printf(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); - printf(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); - printf(":irq: "); _irq_alloc()->dump_addr_tree(); - printf(":rom_fs: "); _rom_fs.print_fs(); - } + init_log(); + + log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + log(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + log(":io_port: "); _io_port_alloc()->dump_addr_tree(); + log(":irq: "); _irq_alloc()->dump_addr_tree(); + log(":rom_fs: "); _rom_fs.print_fs(); /* setup task object for core task */ _core_pd = new(core_mem_alloc()) Platform_pd(true); diff --git a/repos/base-okl4/src/core/platform_pd.cc b/repos/base-okl4/src/core/platform_pd.cc index 94831ceaf..113a741dd 100644 --- a/repos/base-okl4/src/core/platform_pd.cc +++ b/repos/base-okl4/src/core/platform_pd.cc @@ -29,9 +29,6 @@ namespace Okl4 { extern "C" { using namespace Genode; -static const bool verbose = false; - - /**************************** ** Private object members ** ****************************/ @@ -61,8 +58,7 @@ void Platform_pd::_create_pd(bool syscall) resources, &old_resources); if (ret != 1) - PERR("L4_SpaceControl(new) returned %d, error code=%d", - ret, (int)L4_ErrorCode()); + error("L4_SpaceControl(new) returned ", ret, ", error=", L4_ErrorCode()); } @@ -87,8 +83,7 @@ void Platform_pd::_destroy_pd() resources, &old_resources); if (ret != 1) - PERR("L4_SpaceControl(delete) returned %d, error code=%d", - ret, (int)L4_ErrorCode()); + error("L4_SpaceControl(delete) returned ", ret, ", error=", L4_ErrorCode()); } @@ -166,7 +161,8 @@ int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread) void Platform_pd::_free_thread(int thread_id) { if (!_threads[thread_id]) - PWRN("double-free of thread %x.%x detected", _pd_id, thread_id); + warning("double-free of thread ", + Hex(_pd_id), ".", Hex(thread_id), " detected"); _threads[thread_id] = 0; } @@ -186,7 +182,7 @@ bool Platform_pd::bind_thread(Platform_thread *thread) int t = _alloc_thread(thread_id, thread); if (t < 0) { - PERR("thread alloc failed"); + error("thread alloc failed"); return false; } thread_id = t; @@ -206,8 +202,6 @@ void Platform_pd::unbind_thread(Platform_thread *thread) thread->unbind(); _free_thread(thread_id); - - if (verbose) _debug_log_threads(); } @@ -232,23 +226,17 @@ void Platform_pd::space_pager(Platform_thread *thread) resources, &old_resources); if (ret != 1) - PERR("L4_SpaceControl(new space_pager...) returned %d, error code=%d", - ret, (int)L4_ErrorCode()); + error("L4_SpaceControl(new space_pager...) returned ", ret, ", error=", + L4_ErrorCode()); /* grant the pager mapping rights regarding this space */ if(!L4_AllowUserMapping(pager_space, 0x0, 0xff000000)) - PERR("Failed to delegate pt access to %lx, error %lx", - pager_space.raw, L4_ErrorCode()); + error("failed to delegate pt access to ", Hex(pager_space.raw), ", " + "error=", L4_ErrorCode()); } -void Platform_pd::_setup_address_space() -{ - PERR("not yet implemented"); -} - - -static const bool verbose_unmap = false; +void Platform_pd::_setup_address_space() { } static void unmap_log2_range(unsigned pd_id, addr_t base, size_t size_log2) @@ -259,8 +247,8 @@ static void unmap_log2_range(unsigned pd_id, addr_t base, size_t size_log2) L4_FpageAddRightsTo(&fpage, L4_FullyAccessible); int ret = L4_UnmapFpage(L4_SpaceId(pd_id), fpage); if (ret != 1) - PERR("could not unmap page at %p from space %x (Error Code %ld)", - (void *)base, pd_id, L4_ErrorCode()); + error("could not unmap page at ", Hex(base), " from space ", Hex(pd_id), ", " + "error=", L4_ErrorCode()); } @@ -271,9 +259,6 @@ void Platform_pd::flush(addr_t addr, size_t size) L4_Word_t remaining_size = size; L4_Word_t size_log2 = get_page_size_log2(); - if (verbose_unmap) - printf("PD %d: unmap [%lx,%lx)\n", _pd_id, addr, addr + size); - /* * Let unmap granularity ('size_log2') grow */ @@ -334,7 +319,7 @@ Platform_pd::Platform_pd(Allocator *, char const *label) _pd_id = _alloc_pd(); if (_pd_id > PD_MAX) - PERR("pd alloc failed"); + error("pd alloc failed"); _create_pd(true); } @@ -352,18 +337,3 @@ Platform_pd::~Platform_pd() _free_pd(); } - -/*********************** - ** Debugging support ** - ***********************/ - -void Platform_pd::_debug_log_threads() -{ - PWRN("_debug_log_threads disabled."); -} - - -void Platform_pd::_debug_log_pds() -{ - PWRN("_debug_log_pds disabled."); -} diff --git a/repos/base-okl4/src/core/platform_thread.cc b/repos/base-okl4/src/core/platform_thread.cc index a3168e01a..0802d5591 100644 --- a/repos/base-okl4/src/core/platform_thread.cc +++ b/repos/base-okl4/src/core/platform_thread.cc @@ -1,4 +1,3 @@ - /* * \brief OKL4 thread facility * \author Julian Stecklina @@ -15,7 +14,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -43,7 +42,7 @@ using namespace Okl4; int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) { if (!_platform_pd) { - PWRN("thread %d is not bound to a PD", _thread_id); + warning("thread ", _thread_id, " is not bound to a PD"); return -1; } @@ -89,8 +88,7 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) scheduler, pager, exception_handler, resources, (void *)utcb_location); if (ret != 1) { - PERR("L4_ThreadControl returned %d, error code=%d", - ret, (int)L4_ErrorCode()); + error("L4_ThreadControl returned ", ret, ", error=", ret, L4_ErrorCode()); return -1; } @@ -111,7 +109,7 @@ int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no) /* assign priority */ if (!L4_Set_Priority(new_thread_id, Cpu_session::scale_priority(DEFAULT_PRIORITY, _priority))) - PWRN("Could not set thread prioritry to default"); + warning("could not set thread prioritry to default"); set_l4_thread_id(new_thread_id); return 0; @@ -145,7 +143,7 @@ void Platform_thread::unbind() L4_nilthread, L4_nilthread, L4_nilthread, ~0, 0); if (res != 1) - PERR("Deleting thread 0x%08lx failed. Continuing...", _l4_thread_id.raw); + error("deleting thread ", Hex(_l4_thread_id.raw), " failed"); _thread_id = THREAD_INVALID; _l4_thread_id = L4_nilthread; diff --git a/repos/base-okl4/src/core/ram_session_support.cc b/repos/base-okl4/src/core/ram_session_support.cc index 96270e3c1..9f8a084d6 100644 --- a/repos/base-okl4/src/core/ram_session_support.cc +++ b/repos/base-okl4/src/core/ram_session_support.cc @@ -39,15 +39,15 @@ void Ram_session_component::_clear_ds (Dataspace_component *ds) /* allocate range in core's virtual address space */ void *virt_addr; if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { - PERR("could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return; } /* map the dataspace's physical pages to corresponding virtual addresses */ size_t num_pages = page_rounded_size >> get_page_size_log2(); if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) { - PERR("core-local memory mapping failed, Error Code=%d\n", (int)Okl4::L4_ErrorCode()); + error("core-local memory mapping failed, error=", Okl4::L4_ErrorCode()); return; } @@ -58,8 +58,8 @@ void Ram_session_component::_clear_ds (Dataspace_component *ds) /* unmap dataspace from core */ if (!unmap_local((addr_t)virt_addr, num_pages)) - PERR("could not unmap core-local address range at %p (Error Code %ld)", - virt_addr, Okl4::L4_ErrorCode()); + error("could not unmap core-local address range at ", virt_addr, ", " + "error=", Okl4::L4_ErrorCode()); /* free core's virtual address space */ platform()->region_alloc()->free(virt_addr, page_rounded_size); diff --git a/repos/base-okl4/src/core/spec/x86/platform_thread_x86.cc b/repos/base-okl4/src/core/spec/x86/platform_thread_x86.cc index fdcd6728b..0672ad100 100644 --- a/repos/base-okl4/src/core/spec/x86/platform_thread_x86.cc +++ b/repos/base-okl4/src/core/spec/x86/platform_thread_x86.cc @@ -58,7 +58,7 @@ Thread_state Platform_thread::state() void Platform_thread::state(Thread_state) { - PDBG("Not implemented"); + warning("Platform_thread::state not implemented"); throw Cpu_thread::State_access_failed(); } diff --git a/repos/base-okl4/src/lib/base/ipc.cc b/repos/base-okl4/src/lib/base/ipc.cc index ba192dd78..f91519e5e 100644 --- a/repos/base-okl4/src/lib/base/ipc.cc +++ b/repos/base-okl4/src/lib/base/ipc.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include #include #include @@ -93,8 +92,9 @@ static L4_Word_t extract_msg_from_utcb(L4_MsgTag_t rcv_tag, Msgbuf_base &rcv_msg unsigned const num_data_words = num_msg_words - data_start_idx; if (num_data_words*sizeof(L4_Word_t) > rcv_msg.capacity()) { - PERR("receive message buffer too small msg size=%zd, buf size=%zd", - num_data_words*sizeof(L4_Word_t), rcv_msg.capacity()); + error("receive message buffer too small," + "msg size=", num_data_words*sizeof(L4_Word_t), ", " + "buf size=", rcv_msg.capacity()); return Rpc_exception_code::INVALID_OBJECT; } @@ -197,7 +197,7 @@ void Genode::ipc_reply(Native_capability caller, Rpc_exception_code exc, L4_MsgTag_t rcv_tag = L4_Reply(Capability_space::ipc_cap_data(caller).dst); if (L4_IpcFailed(rcv_tag)) - PERR("ipc error in _reply - gets ignored"); + error("ipc error in ipc_reply - gets ignored"); } diff --git a/repos/base-pistachio/src/core/cpu_session_platform.cc b/repos/base-pistachio/src/core/cpu_session_platform.cc index d7e9b8d82..3c17975bb 100644 --- a/repos/base-pistachio/src/core/cpu_session_platform.cc +++ b/repos/base-pistachio/src/core/cpu_session_platform.cc @@ -15,12 +15,10 @@ #include using namespace Genode; -using namespace Pistachio; Dataspace_capability Cpu_thread_component::utcb() { - PERR("%s: Not implemented", __PRETTY_FUNCTION__); return Dataspace_capability(); } diff --git a/repos/base-pistachio/src/core/include/platform_pd.h b/repos/base-pistachio/src/core/include/platform_pd.h index 0a8e5a58f..1c13ff769 100644 --- a/repos/base-pistachio/src/core/include/platform_pd.h +++ b/repos/base-pistachio/src/core/include/platform_pd.h @@ -232,7 +232,7 @@ namespace Genode { * On Pistachio, we don't use directed unmap but rely on the * in-kernel mapping database. See 'region_map_support.cc'. */ - void flush(addr_t, size_t) { PDBG("not implemented"); } + void flush(addr_t, size_t) { warning(__func__, "not implemented"); } }; } diff --git a/repos/base-pistachio/src/core/include/print_l4_thread_id.h b/repos/base-pistachio/src/core/include/print_l4_thread_id.h index 67595acb0..64dd84620 100644 --- a/repos/base-pistachio/src/core/include/print_l4_thread_id.h +++ b/repos/base-pistachio/src/core/include/print_l4_thread_id.h @@ -1,7 +1,7 @@ /* - * \brief Pistachio-specific thread helper - * \author Julian Stecklina - * \date 2008-02-20 + * \brief Pistachio-specific helper for printing thread IDs + * \author Norman Feske + * \date 2016-08-15 */ /* @@ -14,31 +14,50 @@ #ifndef _CORE__INCLUDE__PRINT_L4_THREAD_ID_H_ #define _CORE__INCLUDE__PRINT_L4_THREAD_ID_H_ -#include +#include namespace Pistachio { #include +} - inline void print_l4_thread_id(L4_ThreadId_t t) +namespace Genode { struct Formatted_tid; } + + +struct Genode::Formatted_tid +{ + Pistachio::L4_ThreadId_t tid; + + explicit Formatted_tid(Pistachio::L4_ThreadId_t tid) : tid(tid) { } + + void print(Output &out) const { - if (L4_IsLocalId(t)) { - Genode::printf("THREAD (local) %02lx (raw %08lx)\n", - t.local.X.local_id, t.raw); + using namespace Pistachio; + using Genode::print; - } else if (L4_IsGlobalId(t)) { - Genode::printf("THREAD (global) %02lx (version %lx) (raw %08lx)\n", - t.global.X.thread_no, t.global.X.version, t.raw); + if (L4_IsLocalId(tid)) { + + unsigned char const local_id = tid.local.X.local_id; + print(out, "THREAD (local) ", + Hex(local_id, Hex::OMIT_PREFIX, Hex::PAD), " " + "(raw ", Hex(tid.raw, Hex::OMIT_PREFIX, Hex::PAD), ")"); + + } else if (L4_IsGlobalId(tid)) { + unsigned char const global_id = tid.global.X.thread_no; + print(out, "THREAD (global) ", + Hex(global_id, Hex::OMIT_PREFIX, Hex::PAD), " " + "(version ", Hex(tid.global.X.version, Hex::OMIT_PREFIX), ") ", + "(raw ", Hex(tid.raw, Hex::OMIT_PREFIX, Hex::PAD), ")"); } else { const char *name; - if (t == L4_nilthread) name = "nilthread"; - else if (t == L4_anythread) name = "anythread"; - else name = "???"; + if (tid == L4_nilthread) name = "nilthread"; + else if (tid == L4_anythread) name = "anythread"; + else name = "???"; - Genode::printf("THREAD (%s)\n", name); + print(out, "THREAD (", name, ")"); } } -} +}; #endif /* _CORE__INCLUDE__PRINT_L4_THREAD_ID_H_ */ diff --git a/repos/base-pistachio/src/core/include/util.h b/repos/base-pistachio/src/core/include/util.h index e65c46adc..f8588d24f 100644 --- a/repos/base-pistachio/src/core/include/util.h +++ b/repos/base-pistachio/src/core/include/util.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -25,6 +25,7 @@ /* core-local includes */ #include +#include /* Pistachio includes */ namespace Pistachio { @@ -41,7 +42,7 @@ namespace Genode { inline void panic(const char *s) { using namespace Pistachio; - PDBG("Panic: %s", s); + raw("Panic: ", s); L4_KDB_Enter("> panic <"); } @@ -49,7 +50,7 @@ namespace Genode { { using namespace Pistachio; if (!val) { - PERR("Assertion failed: %s", s); + error("Assertion failed: ", s); L4_KDB_Enter("Assertion failed."); } } @@ -112,10 +113,10 @@ namespace Genode { { Pistachio::L4_ThreadId_t tid; tid.raw = badge; - printf("%s (%s pf_addr=%p pf_ip=%p from %02lx (raw %08lx))\n", msg, - pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", - (void *)pf_addr, (void *)pf_ip, - Pistachio::L4_GlobalId(tid).global.X.thread_no, tid.raw); + log(msg, " (", + pf_type == Region_map::State::WRITE_FAULT ? "WRITE" : "READ", " " + "pf_addr=", Hex(pf_addr), " pf_ip=", Hex(pf_ip), " " + "from ", Formatted_tid(tid), ")"); } inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) { diff --git a/repos/base-pistachio/src/core/io_mem_session_support.cc b/repos/base-pistachio/src/core/io_mem_session_support.cc index 3361cbd6d..f79f0259e 100644 --- a/repos/base-pistachio/src/core/io_mem_session_support.cc +++ b/repos/base-pistachio/src/core/io_mem_session_support.cc @@ -27,8 +27,6 @@ namespace Pistachio { using namespace Genode; -static const bool verbose = false; - /* * TODO This should take a size parameter and check if the whole @@ -52,12 +50,7 @@ bool is_conventional_memory(addr_t base) } -void Io_mem_session_component::_unmap_local(addr_t base, size_t size) -{ - /* TODO .... */ - if (verbose) - PDBG("not yet implemented!"); -} +void Io_mem_session_component::_unmap_local(addr_t base, size_t size) { } static inline bool can_use_super_page(addr_t base, size_t size) { @@ -84,14 +77,11 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) /* find appropriate region for mapping */ void *result = 0; if (platform()->region_alloc()->alloc_aligned(size, &result, alignment).error()) - PERR("alloc_aligned failed!"); + error(__func__, ": alloc_aligned failed!"); local_base = (addr_t)result; } - if (verbose) - PDBG("base = 0x%08lx, size = 0x%08zx -> local = 0x%lx", base, size, local_base); - unsigned offset = 0; while (size) { @@ -99,21 +89,17 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size) if (can_use_super_page(base + offset, size)) page_size = get_super_page_size(); - L4_Fpage_t ret = - L4_Sigma0_GetPage_RcvWindow(get_sigma0(), - L4_Fpage(base + offset, page_size), - L4_Fpage(local_base + offset, page_size)); + L4_Sigma0_GetPage_RcvWindow(get_sigma0(), + L4_Fpage(base + offset, page_size), + L4_Fpage(local_base + offset, page_size)); if (_cacheable == WRITE_COMBINED) { int res = L4_Set_PageAttribute(L4_Fpage(local_base + offset, page_size), L4_WriteCombiningMemory); if (res != 1) - PERR("L4_Set_PageAttributes virt returned %d", res); + error(__func__, ": L4_Set_PageAttributes virt returned ", res); } - if (L4_IsNilFpage(ret) && verbose) - PDBG("Got nil fpage for 0x%08lx from sigma0 (ignoring)", base + offset); - offset += page_size; size -= page_size; } diff --git a/repos/base-pistachio/src/core/irq_session_component.cc b/repos/base-pistachio/src/core/irq_session_component.cc index 7ff23c4ef..1b5767e29 100644 --- a/repos/base-pistachio/src/core/irq_session_component.cc +++ b/repos/base-pistachio/src/core/irq_session_component.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -54,7 +54,7 @@ void Irq_object::_wait_for_irq() L4_MsgTag_t res = L4_Call(irq_thread); if (L4_IpcFailed(res)) - PERR("ipc error while waiting for interrupt."); + error("ipc error while waiting for interrupt"); } @@ -68,7 +68,7 @@ void Irq_object::start() void Irq_object::entry() { if (!_associate()) { - PERR("Could not associate with IRQ 0x%x", _irq); + error("could not associate with IRQ ", Hex(_irq)); return; } @@ -88,7 +88,7 @@ void Irq_object::entry() L4_MsgTag_t res = L4_Receive(irq_thread); if (L4_IpcFailed(res)) - PERR("ipc error while attaching to interrupt."); + error("ipc error while attaching to interrupt"); /* * Now, the IRQ is masked. To receive the next IRQ we have to send @@ -138,7 +138,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc, throw Root::Unavailable(); if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) { - PERR("Unavailable IRQ 0x%x requested", _irq_number); + error("unavailable IRQ ", Hex(_irq_number), " requested"); throw Root::Unavailable(); } @@ -151,7 +151,7 @@ Irq_session_component::~Irq_session_component() L4_Word_t res = L4_DeassociateInterrupt(irqno_to_threadid(_irq_number)); if (res != 1) - PERR("L4_DeassociateInterrupt failed"); + error("L4_DeassociateInterrupt failed"); } diff --git a/repos/base-pistachio/src/core/pager.cc b/repos/base-pistachio/src/core/pager.cc index ec0a810cb..ecda0e99c 100644 --- a/repos/base-pistachio/src/core/pager.cc +++ b/repos/base-pistachio/src/core/pager.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* base-internal includes */ @@ -72,11 +72,10 @@ void Ipc_pager::wait_for_fault() result = L4_Wait(&sender); failed = L4_IpcFailed(result); if (failed) - PERR("Page fault IPC error. (continuable)"); + error("page fault IPC error (continuable)"); if (L4_UntypedWords(result) != 2) { - PERR("Malformed page-fault ipc. (sender = 0x%08lx)", - sender.raw); + error("malformed page-fault ipc (sender=", sender, ")"); failed = true; } @@ -110,13 +109,13 @@ void Ipc_pager::reply_and_wait_for_fault() L4_MsgTag_t result = L4_ReplyWait(_last, &_last); if (L4_IpcFailed(result)) { - PERR("Page fault IPC error. (continuable)"); + error("page fault IPC error (continuable)"); wait_for_fault(); return; } if (L4_UntypedWords(result) != 2) { - PERR("Malformed page-fault ipc. (sender = 0x%08lx)", _last.raw); + error("malformed page-fault ipc. (sender=", _last, ")"); wait_for_fault(); return; } diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc index 23cab3cfb..9e4b258c4 100644 --- a/repos/base-pistachio/src/core/platform.cc +++ b/repos/base-pistachio/src/core/platform.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -22,6 +22,7 @@ #include #include #include +#include /* core includes */ #include @@ -81,7 +82,8 @@ static bool wait_for_page_fault(Pistachio::L4_ThreadId_t &from, enum { EXPECT = 2 }; if (L4_IpcFailed(res) || (L4_UntypedWords(res)) != EXPECT) { - PERR("got %ld words, expected %d", L4_UntypedWords(res), EXPECT); + error(__func__, ": got ", L4_UntypedWords(res), " words, " + "expected ", (int)EXPECT); return false; } L4_Store(res, &msg); @@ -112,7 +114,8 @@ static bool reply_and_wait_for_page_fault(Pistachio::L4_ThreadId_t to, enum { EXPECT = 2 }; if (L4_IpcFailed(res) || (L4_UntypedWords(res)) != EXPECT) { - PERR("got %ld words, expected %d", L4_UntypedWords(res), EXPECT); + error(__func__, ": got ", L4_UntypedWords(res), " words, " + "expected ", (int)EXPECT); return wait_for_page_fault(from, pf_addr, pf_ip, flags); } L4_Store(res, &msg); @@ -130,8 +133,6 @@ static bool reply_and_wait_for_page_fault(Pistachio::L4_ThreadId_t to, static void _core_pager_loop() { - if (verbose) PDBG("Core pager running."); - using namespace Pistachio; L4_ThreadId_t t; @@ -163,28 +164,26 @@ static void _core_pager_loop() continue; } - PDBG("Got page fault (pf_addr = %08lx, pf_ip = %08lx, flags = %08lx).", - pf_addr, pf_ip, flags); - print_l4_thread_id(L4_GlobalId(t)); + log(L4_GlobalId(t)); /* check for NULL pointer */ if (pf_addr < page_size) { - PERR("possible null pointer %s at address %lx at EIP %lx in", - write_fault(flags) ? "WRITE" : "READ/EXEC", pf_addr, pf_ip); - print_l4_thread_id(t); + error("possible null pointer ", + write_fault(flags) ? "WRITE" : "READ/EXEC", " at " + "address ", Hex(pf_addr), " at EIP ", Hex(pf_ip), " in ", t); + /* do not unblock faulter */ break; } else if (!_core_address_ranges().valid_addr(pf_addr)) { /* page-fault address is not in RAM */ - PERR("%s access outside of RAM at %lx IP %lx", - write_fault(flags) ? "WRITE" : "READ", pf_addr, pf_ip); - print_l4_thread_id(t); + error(write_fault(flags) ? "WRITE" : "READ", " access outside of RAM " + "at ", Hex(pf_addr), " IP ", Hex(pf_ip), " by ", t); + /* do not unblock faulter */ break; } else if (verbose_core_pf) { - PDBG("pfa=%lx ip=%lx in", pf_addr, pf_ip); - print_l4_thread_id(t); + log(__func__, ": pfa=", Hex(pf_addr), " ip=", Hex(pf_ip), " by ", t); } /* my pf handler is sigma0 - just touch the appropriate page */ @@ -263,31 +262,28 @@ struct Region { return (((base + size) > start) && (base < end)); } + + void print(Genode::Output &out) const + { + size_t const size = end - start; + Genode::print(out, Hex_range(start, size), " ", + "size: ", Hex(size, Hex::PREFIX, Hex::PAD)); + } }; -/** - * Log region - */ -static inline void print_region(Region r) -{ - printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start); -} - - /** * Add region to allocator */ static inline void add_region(Region r, Range_allocator &alloc) { if (r.start >= r.end) { - PERR("(start = 0x%08lx, end = 0x%08lx)\n", r.start, r.end); + error(__func__, ": bad range ", r); panic("add_region called with bogus parameters."); } - if (verbose_region_alloc) { - printf("%p add: ", &alloc); print_region(r); printf("\n"); - } + if (verbose_region_alloc) + log(&alloc, " add: ", r); /* adjust region */ addr_t start = trunc_page(r.start); @@ -305,9 +301,8 @@ static inline void remove_region(Region r, Range_allocator &alloc) if (r.start >= r.end) panic("remove_region called with bogus parameters."); - if (verbose_region_alloc) { - printf("%p remove: ", &alloc); print_region(r); printf("\n"); - } + if (verbose_region_alloc) + log(&alloc, " remove: ", r); /* adjust region */ addr_t start = trunc_page(r.start); @@ -358,12 +353,10 @@ static void dump_kip_memdesc(Pistachio::L4_KernelInterfacePage_t *kip) for (L4_Word_t i = 0; i < num_desc; i++) { L4_MemoryDesc_t *d = L4_MemoryDesc(kip, i); - printf("mem %ld: [0x%08lx, 0x%08lx) type=0x%lx (%s) %s\n", - i, - L4_Low(d), - L4_High(d)+1, - L4_Type(d), types[L4_Type(d) & 0xF], - L4_IsVirtual(d) ? "Virtual" : "Non-Virtual"); + log("mem ", i, ": ", + Hex_range(L4_Low(d), L4_High(d) - L4_Low(d) + 1), " " + "type=", Hex(L4_Type(d)), " (", types[L4_Type(d) & 0xf], ") ", + L4_IsVirtual(d) ? "Virtual" : "Non-Virtual"); } } @@ -417,7 +410,7 @@ void Platform::_setup_mem_alloc() /* mask out that size bit */ page_size_mask &= ~size; - printf("Trying to allocate %uK pages from sigma0.\n", size >> 10); + log("Trying to allocate ", size >> 10, "K pages from sigma0."); /* * Suck out sigma0. The spec says that we get only "conventional @@ -455,7 +448,7 @@ void Platform::_setup_mem_alloc() } } while (succ); - printf("Got %uK in %uK pieces.\n", bytes_got >> 10, size >> 10); + log("Got ", bytes_got >> 10, "K in ", size >> 10, "K pieces."); } } @@ -498,11 +491,11 @@ void Platform::_setup_basics() panic("we got something but not the KIP"); if (verbose) { - printf("\n"); - printf("KIP @ %p\n", kip); - printf(" magic: %08lx\n", kip->magic); - printf(" version: %08lx\n", kip->ApiVersion.raw); - printf(" BootInfo: %08lx\n", kip->BootInfo); + log(""); + log("KIP @ ", kip); + log(" magic: ", Hex(kip->magic, Hex::PREFIX, Hex::PAD)); + log(" version: ", Hex(kip->ApiVersion.raw, Hex::PREFIX, Hex::PAD)); + log(" BootInfo: ", Hex(kip->BootInfo, Hex::PREFIX, Hex::PAD)); } dump_kip_memdesc(kip); @@ -530,7 +523,7 @@ void Platform::_setup_basics() /* done magic */ - if (verbose) printf("MBI @ %p\n", mb_info_ptr); + if (verbose) log("MBI @ ", mb_info_ptr); /* get UTCB memory */ Platform_pd::touch_utcb_space(); @@ -553,7 +546,7 @@ void Platform::_setup_basics() if (!L4_IsVirtual(md)) continue; if (_vm_start != 0x0 || _vm_size != 0x0) { - PWRN("KIP has multiple virtual-memory descriptors. Taking only the first."); + warning("KIP has multiple virtual-memory descriptors. Taking only the first."); break; } @@ -564,8 +557,9 @@ void Platform::_setup_basics() _vm_start = max((L4_Word_t)0x1000, L4_MemoryDescLow(md)); _vm_size = L4_MemoryDescHigh(md) - _vm_start + 1; - printf("KIP reports virtual memory region at [%lx,%lx)\n", - L4_MemoryDescLow(md), L4_MemoryDescHigh(md)); + log("KIP reports virtual memory region at ", + Hex_range(L4_MemoryDescLow(md), + L4_MemoryDescHigh(md) - L4_MemoryDescLow(md))); } /* configure core's virtual memory, exclude KIP, stack area */ @@ -611,9 +605,7 @@ void Platform::_setup_rom() _rom_fs.insert(new_rom); if (verbose) - printf(" mod[%d] [%p,%p) %s\n", i, - (void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(), - new_rom->name()); + log(" mod[", i, "] ", *new_rom); /* zero remainder of last ROM page */ size_t count = page_size - rom.size() % page_size; @@ -651,6 +643,8 @@ Platform::Platform() : if (initialized) panic("Platform constructed twice!"); initialized = true; + init_log(); + _setup_basics(); _setup_preemption(); _setup_mem_alloc(); @@ -664,13 +658,13 @@ Platform::Platform() : * hold the meta data for the ROM modules as initialized by '_setup_rom'. */ if (verbose) { - printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); - printf(":irq: "); _irq_alloc()->dump_addr_tree(); - printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); + log(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + log(":region_alloc: "); _region_alloc()->dump_addr_tree(); + log(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + log(":io_port: "); _io_port_alloc()->dump_addr_tree(); + log(":irq: "); _irq_alloc()->dump_addr_tree(); + log(":rom_fs: "); _rom_fs.print_fs(); + log(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); } /* diff --git a/repos/base-pistachio/src/core/platform_pd.cc b/repos/base-pistachio/src/core/platform_pd.cc index 29541ce5c..f8901e19d 100644 --- a/repos/base-pistachio/src/core/platform_pd.cc +++ b/repos/base-pistachio/src/core/platform_pd.cc @@ -28,11 +28,6 @@ using namespace Pistachio; using namespace Genode; -static const bool verbose = false; - -#define PT_DBG(args...) if (verbose) { PDBG(args); } else { } - - /************************** ** Static class members ** **************************/ @@ -47,8 +42,6 @@ L4_Word_t Platform_pd::_core_utcb_ptr = 0; void Platform_pd::_create_pd(bool syscall) { if (syscall) { - PT_DBG("_create_pd (_l4_task_id = 0x%08lx)", - _l4_task_id.raw); /* create place-holder thread representing the PD */ L4_ThreadId_t l4t = make_l4_id(_pd_id, 0, _version); @@ -75,17 +68,13 @@ void Platform_pd::_destroy_pd() { using namespace Pistachio; - PT_DBG("_destroy_pd (_l4_task_id = 0x%08lx)", - _l4_task_id.raw); - - // Space Specifier == nilthread -> destroy + /* Space Specifier == nilthread -> destroy */ L4_Word_t res = L4_ThreadControl(_l4_task_id, L4_nilthread, L4_nilthread, L4_nilthread, (void *)-1); - if (res != 1) { - panic("Destroying protection domain failed."); - } + if (res != 1) + panic("destroying protection domain failed"); _l4_task_id = L4_nilthread; } @@ -182,7 +171,7 @@ int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread) void Platform_pd::_free_thread(int thread_id) { if (!_threads[thread_id]) - PWRN("double-free of thread %x.%x detected", _pd_id, thread_id); + warning("double-free of thread ", Hex(_pd_id), ".", Hex(thread_id), " detected"); _threads[thread_id] = 0; } @@ -202,7 +191,7 @@ bool Platform_pd::bind_thread(Platform_thread *thread) int t = _alloc_thread(thread_id, thread); if (t < 0) { - PERR("thread alloc failed"); + error("thread alloc failed"); return false; } thread_id = t; @@ -211,7 +200,6 @@ bool Platform_pd::bind_thread(Platform_thread *thread) /* finally inform thread about binding */ thread->bind(thread_id, l4_thread_id, this); - if (verbose) _debug_log_threads(); return true; } @@ -225,27 +213,19 @@ void Platform_pd::unbind_thread(Platform_thread *thread) _free_thread(thread_id); - if (verbose) _debug_log_threads(); } void Platform_pd::touch_utcb_space() { - L4_Word_t utcb_ptr; - L4_KernelInterfacePage_t *kip = get_kip(); L4_ThreadId_t mylocalid = L4_MyLocalId(); - utcb_ptr = *(L4_Word_t *) &mylocalid; + L4_Word_t utcb_ptr = *(L4_Word_t *) &mylocalid; utcb_ptr &= ~(L4_UtcbAreaSize (kip) - 1); /* store a pointer to core's utcb area */ _core_utcb_ptr = utcb_ptr; - PT_DBG("Core's UTCB area is at 0x%08lx (0x%08lx)", - utcb_ptr, L4_UtcbAreaSize(kip)); - PWRN("Core can have %lu threads.", - L4_UtcbAreaSize(kip) / L4_UtcbSize(kip)); - /* * We used to touch the UTCB space here, but that was probably not * neccessary. @@ -275,36 +255,20 @@ void Platform_pd::_setup_address_space() L4_KernelInterfacePage_t *kip = (L4_KernelInterfacePage_t *)get_kip(); L4_Fpage_t kip_space = L4_FpageLog2((L4_Word_t)kip, L4_KipAreaSizeLog2(kip)); - PT_DBG("kip_start = %08lx", L4_Address(kip_space)); - - /* utcb space follows the kip, but must be aligned */ - L4_Word_t kip_end = L4_Address(kip_space) + L4_KipAreaSize(kip); - PT_DBG("kip_end = %08lx", kip_end); L4_Word_t utcb_start = _core_utcb_ptr; -// L4_Word_t utcb_start = (L4_Word_t)(&_kip_utcb_area); - PT_DBG("utcb_start = %08lx", utcb_start); L4_Word_t utcb_size = L4_UtcbSize(kip) * THREAD_MAX; - PT_DBG("utcb_size = %08lx", utcb_size); - L4_Fpage_t utcb_space = L4_Fpage(utcb_start, - // L4_Fpage truncates this. - utcb_size + get_page_size() - 1 ); - - PT_DBG("Creating address space for %08lx.", ss.raw); + L4_Fpage_t utcb_space = L4_Fpage(utcb_start, utcb_size + get_page_size() - 1); L4_Word_t old_control; - int res; - - res = L4_SpaceControl(ss, 0, kip_space, utcb_space, L4_anythread, &old_control); + int res = L4_SpaceControl(ss, 0, kip_space, utcb_space, L4_anythread, &old_control); if (res != 1 ) { - PERR("Error while setting up address space: %lu", L4_ErrorCode()); + error("setting up address space failed, error ", L4_ErrorCode()); panic("L4_SpaceControl"); } - PT_DBG("Address space for %08lx created!", ss.raw); - _kip_ptr = L4_Address(kip_space); _utcb_ptr = L4_Address(utcb_space); } @@ -351,7 +315,8 @@ Platform_pd::Platform_pd(Allocator * md_alloc, char const *, _pd_id = _alloc_pd(pd_id); if (_pd_id < 0) { - PERR("pd alloc failed"); + error("pd alloc failed"); + return; } _create_pd(create); @@ -363,29 +328,9 @@ Platform_pd::~Platform_pd() /* invalidate weak pointers to this object */ Address_space::lock_for_destruction(); - PT_DBG("Destroying all threads of pd %p", this); - /* unbind all threads */ while (Platform_thread *t = _next_thread()) unbind_thread(t); - PT_DBG("Destroying pd %p", this); - _destroy_pd(); _free_pd(); } - - -/*********************** - ** Debugging support ** - ***********************/ - -void Platform_pd::_debug_log_threads() -{ - PWRN("_debug_log_threads disabled."); -} - - -void Platform_pd::_debug_log_pds() -{ - PWRN("_debug_log_pds disabled."); -} diff --git a/repos/base-pistachio/src/core/platform_thread.cc b/repos/base-pistachio/src/core/platform_thread.cc index 084c4d462..105ae0ecf 100644 --- a/repos/base-pistachio/src/core/platform_thread.cc +++ b/repos/base-pistachio/src/core/platform_thread.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* base-internal includes */ @@ -22,6 +22,7 @@ #include #include #include +#include /* Pistachio includes */ namespace Pistachio @@ -38,8 +39,6 @@ using namespace Pistachio; static const bool verbose = false; static const bool verbose2 = true; -#define PT_DBG(args...) if (verbose) { PDBG(args); } else { } - void Platform_thread::affinity(Affinity::Location location) { @@ -48,13 +47,13 @@ void Platform_thread::affinity(Affinity::Location location) unsigned const cpu_no = location.xpos(); if (cpu_no >= L4_NumProcessors(get_kip())) { - PERR("Invalid processor number."); + error("invalid processor number"); return; } if (_l4_thread_id != L4_nilthread) if (L4_Set_ProcessorNo(_l4_thread_id, cpu_no) == 0) - PERR("Error setting processor number."); + error("could not set processor number"); } @@ -74,31 +73,18 @@ int Platform_thread::start(void *ip, void *sp) /* XXX should always be the root task */ L4_ThreadId_t preempter = L4_Myself(); - PT_DBG("Trying to Platform_thread::start the thread '%s'.", _name); - - if (verbose2) - printf("thread '%s' has id 0x%08lx (task = 0x%x, thread = 0x%x)\n", - _name, thread.raw, _platform_pd->pd_id(), _thread_id); - if (_thread_id == THREAD_INVALID) { - PERR("Trying to start a thread with invalid ID."); + error("attempt to start a thread with invalid ID"); return -1; } L4_Word_t utcb_location = _platform_pd->_utcb_location(_thread_id); - PT_DBG("New thread's utcb at %08lx.", utcb_location); - PT_DBG("Attaching thread to address space 0x%08lx.", - _platform_pd->_l4_task_id.raw); - - PT_DBG("sp = %p, ip = %p", sp, ip); int ret = L4_ThreadControl(thread, _platform_pd->_l4_task_id, preempter, L4_Myself(), (void *)utcb_location); - PT_DBG("L4_ThreadControl() = %d", ret); if (ret != 1) { - PERR("Error code = 0x%08lx", L4_ErrorCode()); - PERR("L4_ThreadControl failed."); + error(__func__, ": L4_ThreadControl returned ", Hex(L4_ErrorCode())); return -2; } @@ -107,8 +93,8 @@ int Platform_thread::start(void *ip, void *sp) L4_nilthread, pager, (void *)-1); if (ret != 1) { - PERR("Error code = 0x%08lx", L4_ErrorCode()); - PERR("Setting pager failed."); + error(__func__, ": L4_ThreadControl returned ", Hex(L4_ErrorCode())); + error("setting pager failed"); return -3; } @@ -118,7 +104,7 @@ int Platform_thread::start(void *ip, void *sp) /* assign priority */ if (!L4_Set_Priority(thread, Cpu_session::scale_priority(DEFAULT_PRIORITY, _priority))) - PWRN("Could not set thread prioritry to default"); + warning("could not set thread prioritry to default"); /* send start message */ L4_Msg_t msg; @@ -130,25 +116,23 @@ int Platform_thread::start(void *ip, void *sp) L4_MsgTag_t tag = L4_Send(thread); if (L4_IpcFailed(tag)) { - PERR("Starting thread failed. (IPC error)"); + error("starting thread failed. (IPC error)"); return -4; } - PT_DBG("Done starting thread."); - return 0; } void Platform_thread::pause() { - PDBG("not implemented"); + warning(__func__, " not implemented"); } void Platform_thread::resume() { - PDBG("not implemented"); + warning(__func__, " not implemented"); } @@ -163,13 +147,11 @@ void Platform_thread::bind(int thread_id, L4_ThreadId_t l4_thread_id, void Platform_thread::unbind() { - PT_DBG("Killing thread 0x%08lx.", _l4_thread_id.raw); - L4_Word_t res = L4_ThreadControl(_l4_thread_id, L4_nilthread, L4_nilthread, L4_nilthread, (void *)-1); if (res != 1) - PERR("Deleting thread 0x%08lx failed. Continuing...", _l4_thread_id.raw); + error("deleting thread ", Formatted_tid(_l4_thread_id), " failed"); _thread_id = THREAD_INVALID; _l4_thread_id = L4_nilthread; @@ -179,7 +161,7 @@ void Platform_thread::unbind() void Platform_thread::state(Thread_state) { - PDBG("Not implemented"); + warning(__func__, " not implemented"); throw Cpu_thread::State_access_failed(); } diff --git a/repos/base-sel4/include/sel4/assert.h b/repos/base-sel4/include/sel4/assert.h index 696bb19bb..d44546d7a 100644 --- a/repos/base-sel4/include/sel4/assert.h +++ b/repos/base-sel4/include/sel4/assert.h @@ -15,11 +15,11 @@ #define _INCLUDE__SEL4__ASSERT_H_ /* Genode includes */ -#include +#include #define seL4_Assert(v) do { \ if (!(v)) { \ - PDBG("assertion failed: %s", #v); \ + Genode::error("assertion failed: ", #v); \ for (;;); \ } } while (0); diff --git a/repos/base-sel4/src/core/core_region_map.cc b/repos/base-sel4/src/core/core_region_map.cc index 6401add1c..5e3797612 100644 --- a/repos/base-sel4/src/core/core_region_map.cc +++ b/repos/base-sel4/src/core/core_region_map.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -38,20 +38,20 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size, size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask(); if (use_local_addr) { - PERR("Parameter 'use_local_addr' not supported within core"); + error(__func__, ": 'use_local_addr' not supported within core"); return nullptr; } if (offset) { - PERR("Parameter 'offset' not supported within core"); + error(__func__, ": 'offset' not supported within core"); return nullptr; } /* allocate range in core's virtual address space */ void *virt_addr; if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { - PERR("Could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return nullptr; } diff --git a/repos/base-sel4/src/core/include/initial_untyped_pool.h b/repos/base-sel4/src/core/include/initial_untyped_pool.h index 229a623de..51779d9cb 100644 --- a/repos/base-sel4/src/core/include/initial_untyped_pool.h +++ b/repos/base-sel4/src/core/include/initial_untyped_pool.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include /* core-local includes */ #include @@ -219,8 +219,8 @@ class Genode::Initial_untyped_pool num_objects); if (ret != 0) { - PERR("%s: seL4_Untyped_Retype (untyped) returned %d", - __FUNCTION__, ret); + error(__func__, ": seL4_Untyped_Retype (untyped) " + "returned ", ret); return; } } diff --git a/repos/base-sel4/src/core/include/kernel_object.h b/repos/base-sel4/src/core/include/kernel_object.h index b69daa755..54c96b97b 100644 --- a/repos/base-sel4/src/core/include/kernel_object.h +++ b/repos/base-sel4/src/core/include/kernel_object.h @@ -129,8 +129,8 @@ namespace Genode { num_objects); if (ret != 0) { - PERR("seL4_Untyped_RetypeAtOffset (%s) returned %d", - KOBJ::name(), ret); + error("seL4_Untyped_RetypeAtOffset (", KOBJ::name(), ") " + "returned ", ret); throw Retype_untyped_failed(); } @@ -183,8 +183,7 @@ namespace Genode { num_objects); if (ret != 0) { - PERR("seL4_Untyped_Retype (%s) returned %d", - KOBJ::name(), ret); + error("seL4_Untyped_Retype (", KOBJ::name(), ") returned ", ret); throw Retype_untyped_failed(); } } diff --git a/repos/base-sel4/src/core/include/page_table_registry.h b/repos/base-sel4/src/core/include/page_table_registry.h index 828ae252a..b6e51feaf 100644 --- a/repos/base-sel4/src/core/include/page_table_registry.h +++ b/repos/base-sel4/src/core/include/page_table_registry.h @@ -53,8 +53,6 @@ class Genode::Page_table_registry addr_t const addr; - static constexpr bool verbose = false; - private: List _entries; @@ -93,7 +91,7 @@ class Genode::Page_table_registry void insert_entry(Allocator &entry_alloc, addr_t addr, unsigned sel) { if (_entry_exists(addr)) { - PWRN("trying to insert page frame for 0x%lx twice", addr); + warning("trying to insert page frame for ", Hex(addr), " twice"); return; } @@ -110,10 +108,7 @@ class Genode::Page_table_registry Entry &entry = lookup(addr); _entries.remove(&entry); destroy(entry_alloc, &entry); - } catch (Lookup_failed) { - if (verbose) - PWRN("trying to remove non-existing page frame for 0x%lx", addr); - } + } catch (Lookup_failed) { } } void flush_all(Allocator &entry_alloc) @@ -156,7 +151,7 @@ class Genode::Page_table_registry *out_addr = nullptr; if (size > sizeof(Elem_space)) { - PERR("unexpected allocation size of %zd", size); + error("unexpected allocation size of ", size); return false; } @@ -205,12 +200,10 @@ class Genode::Page_table_registry if (_page_table_base(pt->addr) == _page_table_base(addr)) return *pt; } - PDBG("page-table lookup failed"); + warning(__func__, ": page-table lookup failed"); throw Lookup_failed(); } - static constexpr bool verbose = false; - public: /** @@ -240,7 +233,7 @@ class Genode::Page_table_registry /* XXX sel is unused */ if (_page_table_exists(addr)) { - PWRN("trying to insert page table for 0x%lx twice", addr); + warning("attempt to insert page table for ", Hex(addr), " twice"); return; } @@ -273,10 +266,7 @@ class Genode::Page_table_registry try { Page_table &page_table = _lookup(addr); page_table.remove_entry(_page_table_entry_alloc, addr); - } catch (...) { - if (verbose) - PDBG("no PT entry found for virtual address 0x%lx", addr); - } + } catch (...) { } } @@ -302,10 +292,7 @@ class Genode::Page_table_registry Page_table::Entry &entry = page_table.lookup(addr); fn(entry.sel); - } catch (...) { - if (verbose) - PDBG("no PT entry found for virtual address 0x%lx", addr); - } + } catch (...) { } } template diff --git a/repos/base-sel4/src/core/pager.cc b/repos/base-sel4/src/core/pager.cc index 67f87d43c..d9aea8e90 100644 --- a/repos/base-sel4/src/core/pager.cc +++ b/repos/base-sel4/src/core/pager.cc @@ -26,8 +26,6 @@ using namespace Genode; -static bool const verbose = false; - struct Fault_info { @@ -40,10 +38,7 @@ struct Fault_info ip(seL4_GetMR(0)), pf(seL4_GetMR(1)), write(seL4_Fault_isWriteFault(seL4_GetMR(3))) - { - if (verbose) - PINF("PF: ip=0x%lx, pf=0x%lx, write=%d", ip, pf, write); - } + { } }; diff --git a/repos/base-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc index c61d4d085..a38ebf160 100644 --- a/repos/base-sel4/src/core/platform.cc +++ b/repos/base-sel4/src/core/platform.cc @@ -184,10 +184,9 @@ void Platform::_init_allocators() if (verbose_boot_info) { log("core image:"); - log(" virtual address range [", - Hex(core_virt_beg, Hex::OMIT_PREFIX, Hex::PAD), ",", - Hex(core_virt_end, Hex::OMIT_PREFIX, Hex::PAD), ") size=", - Hex(core_size)); + log(" virtual address range ", + Hex_range(core_virt_beg, core_virt_end - core_virt_beg), " " + "size=", Hex(core_size)); } /* preserve sel4 boot info page in core's virtual address space */ @@ -391,7 +390,7 @@ void Platform::_init_rom_modules() _phys_cnode.copy(initial_cspace, Cnode_index(module_frame_sel + i), Cnode_index(dst_frame + i)); - PLOG("boot module '%s' (%zd bytes)", header->name, header->size); + log("boot module '", header->name, "' (", header->size, " bytes)"); /* * Register ROM module, the base address refers to location of the @@ -452,8 +451,7 @@ Platform::Platform() /* * Log statistics about allocator initialization */ - log("VM area at [", Hex(_vm_base, Hex::OMIT_PREFIX, Hex::PAD), ",", - Hex(_vm_base + _vm_size, Hex::OMIT_PREFIX, Hex::PAD), ")"); + log("VM area at ", Hex_range(_vm_base, _vm_size)); if (verbose_boot_info) { log(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); diff --git a/repos/base-sel4/src/core/platform_thread.cc b/repos/base-sel4/src/core/platform_thread.cc index 7b1f8aecf..b05ab7997 100644 --- a/repos/base-sel4/src/core/platform_thread.cc +++ b/repos/base-sel4/src/core/platform_thread.cc @@ -89,8 +89,8 @@ static void prepopulate_ipc_buffer(addr_t ipc_buffer_phys, Cap_sel ep_sel, /* allocate range in core's virtual address space */ void *virt_addr; if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) { - PERR("could not allocate virtual address range in core of size %zd\n", - page_rounded_size); + error("could not allocate virtual address range in core of size ", + page_rounded_size); return; } diff --git a/repos/base-sel4/src/core/stack_area.cc b/repos/base-sel4/src/core/stack_area.cc index bd4c45a85..b1598b00b 100644 --- a/repos/base-sel4/src/core/stack_area.cc +++ b/repos/base-sel4/src/core/stack_area.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include #include -#include +#include #include #include @@ -52,8 +52,6 @@ class Stack_area_region_map : public Region_map Ds_slab _ds_slab { platform()->core_mem_alloc() }; - enum { verbose = false }; - public: /** @@ -75,21 +73,17 @@ class Stack_area_region_map : public Region_map Dataspace_component *ds = new (&_ds_slab) Dataspace_component(size, 0, phys, CACHED, true, 0); if (!ds) { - PERR("dataspace for core stack does not exist"); + error(__func__, ": dataspace for core stack does not exist"); return (addr_t)0; } addr_t const core_local_addr = stack_area_virtual_base() + (addr_t)local_addr; - if (verbose) - PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx", - core_local_addr, ds->phys_addr(), ds->size()); - if (!map_local(ds->phys_addr(), core_local_addr, ds->size() >> get_page_size_log2())) { - PERR("could not map phys %lx at local %lx", - ds->phys_addr(), core_local_addr); + error(__func__, ": could not map phys ", Hex(ds->phys_addr()), " " + "at local ", Hex(core_local_addr)); return (addr_t)0; } @@ -134,7 +128,7 @@ class Stack_area_ram_session : public Ram_session return reinterpret_cap_cast(Native_capability()); } void free(Ram_dataspace_capability ds) { - PWRN("Not implemented!"); } + warning(__func__, " not implemented"); } int ref_account(Ram_session_capability ram_session) { return 0; } diff --git a/repos/base-sel4/src/core/thread_start.cc b/repos/base-sel4/src/core/thread_start.cc index ef2e50562..1c5de2a8d 100644 --- a/repos/base-sel4/src/core/thread_start.cc +++ b/repos/base-sel4/src/core/thread_start.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* base-internal includes */ @@ -41,8 +41,9 @@ void Thread::_init_platform_thread(size_t, Type type) thread_info.init(utcb_virt_addr); if (!map_local(thread_info.ipc_buffer_phys, utcb_virt_addr, 1)) { - PERR("could not map IPC buffer phys %lx at local %lx", - thread_info.ipc_buffer_phys, utcb_virt_addr); + error(__func__, ": could not map IPC buffer " + "phys=", Hex(thread_info.ipc_buffer_phys), " " + "local=%", Hex(utcb_virt_addr)); } native_thread().tcb_sel = thread_info.tcb_sel.value(); @@ -103,6 +104,6 @@ void Thread::start() void Thread::cancel_blocking() { - PWRN("not implemented"); + warning(__func__, " not implemented"); } diff --git a/repos/base-sel4/src/include/base/internal/assert.h b/repos/base-sel4/src/include/base/internal/assert.h index fe0700f17..674b03d49 100644 --- a/repos/base-sel4/src/include/base/internal/assert.h +++ b/repos/base-sel4/src/include/base/internal/assert.h @@ -27,7 +27,7 @@ do { if (!(e)) { \ char line_buf[32]; \ Genode::snprintf(line_buf, sizeof(line_buf), "%d", __LINE__); \ - kernel_debugger_outstring(ESC_ERR "Assertion failed: " #e ESC_END "\n"); \ + kernel_debugger_outstring("Assertion failed: " #e "\n"); \ kernel_debugger_outstring(__FILE__ ":"); \ kernel_debugger_outstring(line_buf); \ kernel_debugger_panic("\n"); \ diff --git a/repos/base/include/base/allocator_avl.h b/repos/base/include/base/allocator_avl.h index c31644ac3..3ce5c9dad 100644 --- a/repos/base/include/base/allocator_avl.h +++ b/repos/base/include/base/allocator_avl.h @@ -16,7 +16,6 @@ #include #include -#include #include #include diff --git a/repos/base/include/base/allocator_guard.h b/repos/base/include/base/allocator_guard.h index b236b889f..5bf524e64 100644 --- a/repos/base/include/base/allocator_guard.h +++ b/repos/base/include/base/allocator_guard.h @@ -15,7 +15,7 @@ #define _INCLUDE__BASE__ALLOCATOR_GUARD_H_ #include -#include +#include #include namespace Genode { class Allocator_guard; } @@ -71,11 +71,12 @@ class Genode::Allocator_guard : public Allocator bool alloc(size_t size, void **out_addr) override { if ((_amount - _consumed) < (size + _allocator->overhead(size))) { - PWRN("Quota exceeded! amount=%zu, size=%zu, consumed=%zu", - _amount, (size + _allocator->overhead(size)), _consumed); + warning("Quota exceeded! amount=", _amount, + ", size=", (size + _allocator->overhead(size)), + ", consumed=", _consumed); return false; } - bool b = _allocator->alloc(size, out_addr); + bool const b = _allocator->alloc(size, out_addr); if (b) _consumed += size + _allocator->overhead(size); return b; diff --git a/repos/base/include/base/child.h b/repos/base/include/base/child.h index c4c69dbc5..ba1399a05 100644 --- a/repos/base/include/base/child.h +++ b/repos/base/include/base/child.h @@ -101,7 +101,7 @@ struct Genode::Child_policy */ virtual void exit(int exit_value) { - PDBG("child \"%s\" exited with exit value %d", name(), exit_value); + log("child \"", name(), "\" exited with exit value ", exit_value); } /** diff --git a/repos/base/include/base/ipc.h b/repos/base/include/base/ipc.h index 0757b48c7..798933fb6 100644 --- a/repos/base/include/base/ipc.h +++ b/repos/base/include/base/ipc.h @@ -16,7 +16,7 @@ #include #include -#include +#include namespace Genode { @@ -97,7 +97,7 @@ class Genode::Ipc_unmarshaller : Noncopyable * condition triggers. */ if (_read_offset + size > _rcv_buf_size) { - PERR("message buffer overrun"); + error("message buffer overrun"); return; } diff --git a/repos/base/include/base/output.h b/repos/base/include/base/output.h index 1a8469fb0..9214321c0 100644 --- a/repos/base/include/base/output.h +++ b/repos/base/include/base/output.h @@ -61,6 +61,15 @@ namespace Genode { */ void print(Output &output, char const *); + /** + * Disallow printing non-const character buffers + * + * For 'char *' types, it is unclear whether the argument should be printed + * as a pointer or a string. The call must resolve this ambiguity by either + * casting the argument to 'void *' or wrapping it in a 'Cstring' object. + */ + void print(Output &, char *) = delete; + /** * Print pointer value */ @@ -137,36 +146,39 @@ namespace Genode { * wrapped into an 'Hex' object, thereby selecting the corresponding * overloaded 'print' function below. */ - struct Hex + class Hex { - enum Prefix { PREFIX, OMIT_PREFIX }; - enum Pad { PAD, NO_PAD }; + public: - unsigned long const value; - size_t const digits; - Prefix const prefix; - Pad const pad; + enum Prefix { PREFIX, OMIT_PREFIX }; + enum Pad { PAD, NO_PAD }; - /** - * Constructor - * - * \param prefix by default, the value is prepended with the prefix - * '0x'. The prefix can be suppressed by specifying - * 'OMIT_PREFIX' as argument. - * \param pad by default, leading zeros are stripped from the - * output. If set to 'PAD', the leading zeros will be - * printed. - */ - template - explicit Hex(T value, Prefix prefix = PREFIX, Pad pad = NO_PAD) - : value(value), digits(2*sizeof(T)), prefix(prefix), pad(pad) { } + private: + + unsigned long long const _value; + size_t const _digits; + Prefix const _prefix; + Pad const _pad; + + public: + + /** + * Constructor + * + * \param prefix by default, the value is prepended with the prefix + * '0x'. The prefix can be suppressed by specifying + * 'OMIT_PREFIX' as argument. + * \param pad by default, leading zeros are stripped from the + * output. If set to 'PAD', the leading zeros will be + * printed. + */ + template + explicit Hex(T value, Prefix prefix = PREFIX, Pad pad = NO_PAD) + : _value(value), _digits(2*sizeof(T)), _prefix(prefix), _pad(pad) { } + + void print(Output &output) const; }; - /** - * Print hexadecimal number - */ - void print(Output &output, Hex const &); - /** * Print range as hexadecimal format * diff --git a/repos/base/include/base/rpc_server.h b/repos/base/include/base/rpc_server.h index e827e58e1..1a29d94f4 100644 --- a/repos/base/include/base/rpc_server.h +++ b/repos/base/include/base/rpc_server.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -161,7 +161,7 @@ class Genode::Rpc_dispatcher : public RPC_INTERFACE Ipc_unmarshaller &, Msgbuf_base &, Meta::Overload_selector) { - PERR("invalid opcode %ld\n", opcode.value); + error("invalid opcode ", opcode.value); return Rpc_exception_code(Rpc_exception_code::INVALID_OPCODE); } diff --git a/repos/base/include/base/service.h b/repos/base/include/base/service.h index 91001eff5..0bc4ec2fc 100644 --- a/repos/base/include/base/service.h +++ b/repos/base/include/base/service.h @@ -15,7 +15,7 @@ #define _INCLUDE__BASE__SERVICE_H_ #include -#include +#include #include #include #include @@ -223,7 +223,7 @@ class Genode::Parent_service : public Service { try { return env()->parent()->session(name(), args, affinity); } catch (Parent::Unavailable) { - PWRN("parent has no service \"%s\"", name()); + warning("parent has no service \"", name(), "\""); throw Unavailable(); } catch (Parent::Quota_exceeded) { throw Quota_exceeded(); } @@ -395,14 +395,13 @@ class Genode::Service_registry * Lets sleep a night over it. */ if (!service) { - printf("%s: service %s not yet available - sleeping\n", - client_name, name); + log(client_name, ": service ", name, " not yet available - sleeping"); try { client->sleep(); - printf("%s: service %s got available\n", client_name, name); + log(client_name, ": service ", name, " got available"); } catch (Blocking_canceled) { - printf("%s: cancel waiting for service\n", client_name); + log(client_name, ": cancel waiting for service"); break; } } diff --git a/repos/base/include/base/session_label.h b/repos/base/include/base/session_label.h index 9256da78e..3972091f7 100644 --- a/repos/base/include/base/session_label.h +++ b/repos/base/include/base/session_label.h @@ -46,7 +46,7 @@ struct Genode::Session_label : String<160> if (!strcmp(_separator(), full + i, _separator_len())) return full + i + _separator_len(); - return Session_label(full); + return Session_label(Cstring(full)); } /** @@ -66,7 +66,7 @@ struct Genode::Session_label : String<160> break; /* construct new label with only the prefix part */ - return Session_label(full, prefix_len); + return Session_label(Cstring(full, prefix_len)); } }; @@ -81,7 +81,7 @@ namespace Genode { char buf[Session_label::capacity()]; Arg_string::find_arg(args, "label").string(buf, sizeof(buf), ""); - return Session_label(buf); + return Session_label(Cstring(buf)); } /** @@ -100,7 +100,7 @@ namespace Genode { char buf[Session_label::capacity()]; snprintf(buf, sizeof(buf), "%s -> %s", prefix.string(), label.string()); - return Session_label(buf); + return Session_label(Cstring(buf)); } } diff --git a/repos/base/include/base/weak_ptr.h b/repos/base/include/base/weak_ptr.h index fd09df361..30b6c3bd7 100644 --- a/repos/base/include/base/weak_ptr.h +++ b/repos/base/include/base/weak_ptr.h @@ -15,7 +15,7 @@ #define _INCLUDE__BASE__WEAK_PTR_H_ #include -#include +#include #include namespace Genode { @@ -140,8 +140,8 @@ class Genode::Weak_object_base ~Weak_object_base() { if (_list.first()) - PERR("Weak object %p not destructed properly " - "there are still dangling pointers to it", this); + error("Weak object ", this, " not destructed properly " + "there are still dangling pointers to it"); } void disassociate(Weak_ptr_base *ptr) diff --git a/repos/base/include/irq_session/irq_session.h b/repos/base/include/irq_session/irq_session.h index 21c2cd113..37d84183e 100644 --- a/repos/base/include/irq_session/irq_session.h +++ b/repos/base/include/irq_session/irq_session.h @@ -86,4 +86,26 @@ struct Genode::Irq_session : Session GENODE_RPC_INTERFACE(Rpc_ack_irq, Rpc_sigh, Rpc_info); }; + +namespace Genode { + + static inline void print(Output &out, Irq_session::Trigger value) + { + switch (value) { + case Irq_session::TRIGGER_UNCHANGED: print(out, "UNCHANGED"); break; + case Irq_session::TRIGGER_LEVEL: print(out, "LEVEL"); break; + case Irq_session::TRIGGER_EDGE: print(out, "EDGE"); break; + } + } + + static inline void print(Output &out, Irq_session::Polarity value) + { + switch (value) { + case Irq_session::POLARITY_UNCHANGED: print(out, "UNCHANGED"); break; + case Irq_session::POLARITY_HIGH: print(out, "HIGH"); break; + case Irq_session::POLARITY_LOW: print(out, "LOW"); break; + } + } +} + #endif /* _INCLUDE__IRQ_SESSION__IRQ_SESSION_H_ */ diff --git a/repos/base/include/root/component.h b/repos/base/include/root/component.h index 810344486..39c89cfd4 100644 --- a/repos/base/include/root/component.h +++ b/repos/base/include/root/component.h @@ -18,12 +18,11 @@ #define _INCLUDE__ROOT__COMPONENT_H_ #include +#include #include -#include #include -#include #include -#include +#include namespace Genode { @@ -228,8 +227,8 @@ class Genode::Root_component : public Rpc_object >, size_t needed = sizeof(SESSION_TYPE) + md_alloc()->overhead(sizeof(SESSION_TYPE)); if (needed > ram_quota) { - PERR("Insufficient ram quota, provided=%zu, required=%zu", - ram_quota, needed); + error("Insufficient ram quota, provided=", ram_quota, + ", required=", needed); throw Root::Quota_exceeded(); } diff --git a/repos/base/include/util/construct_at.h b/repos/base/include/util/construct_at.h index b0fb48f73..1cf5b0d47 100644 --- a/repos/base/include/util/construct_at.h +++ b/repos/base/include/util/construct_at.h @@ -15,7 +15,7 @@ #define _INCLUDE__UTIL__CONSTRUCT_AT_H_ #include -#include +#include namespace Genode { @@ -68,7 +68,7 @@ static inline T * Genode::construct_at(void *at, ARGS &&... args) */ void operator delete (void *) { - PERR("cxx: Placeable::operator delete (void *) not supported."); + error("cxx: Placeable::operator delete (void *) not supported."); } }; diff --git a/repos/base/include/util/fifo.h b/repos/base/include/util/fifo.h index 7cd227a61..cb60176fd 100644 --- a/repos/base/include/util/fifo.h +++ b/repos/base/include/util/fifo.h @@ -14,8 +14,6 @@ #ifndef _INCLUDE__UTIL__FIFO_H_ #define _INCLUDE__UTIL__FIFO_H_ -#include - namespace Genode { template class Fifo; diff --git a/repos/base/include/util/string.h b/repos/base/include/util/string.h index f8aa266ad..9d84c3b7a 100644 --- a/repos/base/include/util/string.h +++ b/repos/base/include/util/string.h @@ -23,6 +23,7 @@ namespace Genode { class Number_of_bytes; + class Cstring; template class String; } @@ -499,41 +500,150 @@ namespace Genode { } +/** + * Helper for the formatted output of a length-constrained character buffer + */ +class Genode::Cstring +{ + private: + + char const * const _str; + size_t const _len; + + static size_t _init_len(char const *str, size_t max_len) + { + /* + * In contrast to 'strlen' we stop searching for a terminating + * null once we reach 'max_len'. + */ + size_t res = 0; + for (; str && *str && res < max_len; str++, res++); + return res; + } + + public: + + /** + * Constructor + * + * \param str null-terminated character buffer + */ + Cstring(char const *str) : _str(str), _len(strlen(str)) { } + + /** + * Constructor + * + * \param str character buffer, not neccessarily null-terminated + * \param max_len maximum number of characters to consume + * + * The 'Cstring' contains all characters up to a terminating null in + * the 'str' buffer but not more that 'max_len' characters. + */ + Cstring(char const *str, size_t max_len) + : + _str(str), _len(_init_len(str, max_len)) + { } + + void print(Output &out) const { out.out_string(_str, _len); } +}; + + /** * Buffer that contains a null-terminated string * - * \param CAPACITY buffer size including the terminating zero + * \param CAPACITY buffer size including the terminating zero, + * must be higher than zero */ template class Genode::String { private: - char _buf[CAPACITY]; - size_t _length; + char _buf[CAPACITY]; + + /** + * Number of chars contained in '_buf' including the terminating null + */ + size_t _len; + + /** + * Output facility that targets a character buffer + */ + struct Local_output : Output + { + char * const _buf; + + size_t _num_chars = 0; + + /** + * Return true if '_buf' can fit at least one additional 'char'. + */ + bool _capacity_left() const { return CAPACITY - _num_chars - 1; } + + void _append(char c) { _buf[_num_chars++] = c; } + + Local_output(char *buf) : _buf(buf) { } + + size_t num_chars() const { return _num_chars; } + + void out_char(char c) override { if (_capacity_left()) _append(c); } + + void out_string(char const *str, size_t n) override + { + while (n-- > 0 && _capacity_left()) + _append(*str++); + } + }; + + template + void _init(T &&... args) + { + /* initialize string content */ + Local_output output(_buf); + Genode::print(output, args...); + + /* add terminating null */ + _buf[output.num_chars()] = 0; + _len = output.num_chars() + 1; + } public: constexpr static size_t size() { return CAPACITY; } - String() : _length(0) { } + String() : _len(0) { } - String(char const *str, size_t len = ~0UL - 1) - : - _length(min(len + 1, min(strlen(str) + 1, CAPACITY))) + /** + * Constructor + * + * If the textual representation of the supplied arguments exceeds + * 'CAPACITY', the resulting string gets truncated. The caller may + * check for this condition by evaluating the 'length' of the + * constructed 'String'. If 'length' equals 'CAPACITY', the string + * may fit perfectly into the buffer or may have been truncated. + * In general, it would be safe to assume the latter. + */ + template + String(T const &arg) { _init(arg); } + + /** + * Copy constructor + */ + template + String(String const &other) : _len(min(other._len, CAPACITY)) { - strncpy(_buf, str, _length); + Genode::strncpy(_buf, other._buf, _len); } /** * Return length of string, including the terminating null character */ - size_t length() const { return _length; } + size_t length() const { return _len; } static constexpr size_t capacity() { return CAPACITY; } bool valid() const { - return (_length <= CAPACITY) && (_length != 0) && (_buf[_length - 1] == '\0'); } + return (_len <= CAPACITY) && (_len != 0) && (_buf[_len - 1] == '\0'); } char const *string() const { return valid() ? _buf : ""; } diff --git a/repos/base/include/util/touch.h b/repos/base/include/util/touch.h index fdc5a45bb..831bc7a43 100644 --- a/repos/base/include/util/touch.h +++ b/repos/base/include/util/touch.h @@ -14,8 +14,6 @@ #ifndef _INCLUDE__UTIL__TOUCH_H_ #define _INCLUDE__UTIL__TOUCH_H_ -#include - namespace Genode { /** Touch one byte at address read only */ diff --git a/repos/base/include/util/volatile_object.h b/repos/base/include/util/volatile_object.h index e0018fd8f..16f2142a3 100644 --- a/repos/base/include/util/volatile_object.h +++ b/repos/base/include/util/volatile_object.h @@ -15,7 +15,6 @@ #define _INCLUDE__UTIL__VOLATILE_OBJECT_H_ #include -#include #include namespace Genode { @@ -61,11 +60,8 @@ class Genode::Volatile_object void _check_constructed() const { - if (!_constructed) { - PDBG("Deref_unconstructed_object"); - PDBG("bt: %p", __builtin_return_address(0)); + if (!_constructed) throw Deref_unconstructed_object(); - } } protected: diff --git a/repos/base/include/util/xml_node.h b/repos/base/include/util/xml_node.h index 2c39496ba..c8b619345 100644 --- a/repos/base/include/util/xml_node.h +++ b/repos/base/include/util/xml_node.h @@ -105,7 +105,7 @@ class Genode::Xml_attribute typedef String<64> Name; Name name() const { - return Name(_name.start(), _name.len()); } + return Name(Cstring(_name.start(), _name.len())); } /** * Return true if attribute has specified type @@ -171,7 +171,7 @@ class Genode::Xml_attribute { char buf[N]; value(buf, sizeof(buf)); - *out = String(buf); + *out = String(Cstring(buf)); } /** @@ -599,7 +599,7 @@ class Genode::Xml_node Type type() const { Token name = _start_tag.name(); - return Type(name.start(), name.len()); + return Type(Cstring(name.start(), name.len())); } /** @@ -705,7 +705,7 @@ class Genode::Xml_node char buf[STRING::capacity() + 1]; size_t const len = decoded_content(buf, sizeof(buf)); buf[min(len, STRING::capacity())] = 0; - return STRING(buf); + return STRING(Cstring(buf)); } /** diff --git a/repos/base/src/core/core_mem_alloc.cc b/repos/base/src/core/core_mem_alloc.cc index 1fbc5a15b..570f2352b 100644 --- a/repos/base/src/core/core_mem_alloc.cc +++ b/repos/base/src/core/core_mem_alloc.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include /* local includes */ @@ -21,8 +21,6 @@ using namespace Genode; -static const bool verbose_core_mem_alloc = false; - void * Mapped_avl_allocator::map_addr(void * addr) { @@ -46,8 +44,8 @@ Mapped_mem_allocator::alloc_aligned(size_t size, void **out_addr, int align, add Alloc_return ret1 = _phys_alloc->alloc_aligned(page_rounded_size, &phys_addr, align, from, to); if (!ret1.ok()) { - PERR("Could not allocate physical memory region of size %zu\n", - page_rounded_size); + error("Could not allocate physical memory region of size ", + page_rounded_size); return ret1; } @@ -55,7 +53,7 @@ Mapped_mem_allocator::alloc_aligned(size_t size, void **out_addr, int align, add Alloc_return ret2 = _virt_alloc->alloc_aligned(page_rounded_size, out_addr, align); if (!ret2.ok()) { - PERR("Could not allocate virtual address range in core of size %zu\n", + error("Could not allocate virtual address range in core of size ", page_rounded_size); /* revert physical allocation */ @@ -63,10 +61,6 @@ Mapped_mem_allocator::alloc_aligned(size_t size, void **out_addr, int align, add return ret2; } - if (verbose_core_mem_alloc) - printf("added core memory block of %zu bytes at virt=%p phys=%p\n", - page_rounded_size, *out_addr, phys_addr); - _phys_alloc->metadata(phys_addr, { *out_addr }); _virt_alloc->metadata(*out_addr, { phys_addr }); @@ -91,5 +85,5 @@ void Mapped_mem_allocator::free(void *addr, size_t size) void Mapped_mem_allocator::free(void *addr) { - PWRN("Not implemented!"); + warning(__func__, "not implemented!"); } diff --git a/repos/base/src/core/cpu_session_component.cc b/repos/base/src/core/cpu_session_component.cc index 5b2fa29ae..823d3159d 100644 --- a/repos/base/src/core/cpu_session_component.cc +++ b/repos/base/src/core/cpu_session_component.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -25,8 +25,6 @@ using namespace Genode; -static constexpr bool verbose = false; - Thread_capability Cpu_session_component::create_thread(Capability pd_cap, Name const &name, @@ -39,13 +37,11 @@ Thread_capability Cpu_session_component::create_thread(Capability pd Cpu_thread_component *thread = 0; if (weight.value == 0) { - PWRN("Thread %s: Bad weight 0, using %i instead.", - name.string(), Weight::DEFAULT_WEIGHT); + warning("Thread ", name, ": Bad weight 0, using default weight instead."); weight = Weight(); } if (weight.value > QUOTA_LIMIT) { - PWRN("Thread %s: Oversized weight %zu, using %i instead.", - name.string(), weight.value, QUOTA_LIMIT); + warning("Thread ", name, ": Oversized weight ", weight.value, ", using limit instead."); weight = Weight(QUOTA_LIMIT); } @@ -57,7 +53,7 @@ Thread_capability Cpu_session_component::create_thread(Capability pd */ auto create_thread_lambda = [&] (Pd_session_component *pd) { if (!pd) { - PERR("create_thread: invalid PD argument"); + error("create_thread: invalid PD argument"); throw Thread_creation_failed(); } Lock::Guard slab_lock_guard(_thread_alloc_lock); @@ -179,21 +175,20 @@ int Cpu_session_component::transfer_quota(Cpu_session_capability dst_cap, /* lookup targeted CPU session */ auto lambda = [&] (Cpu_session_component *dst) { if (!dst) { - PWRN("Transfer CPU quota, %s, targeted session not found", - _label.string()); + warning("Transfer CPU quota, ", _label, ", targeted session not found"); return -1; } /* check reference relationship */ if (dst->_ref != this && dst != _ref) { - PWRN("Transfer CPU quota, %s -> %s, no reference relation", - _label.string(), dst->_label.string()); + warning("Transfer CPU quota, ", _label, " -> ", dst->_label, ", " + "no reference relation"); return -2; } /* check quota availability */ size_t const quota = quota_lim_downscale(_quota, amount); if (quota > _quota) { - PWRN("Transfer CPU quota, %s -> %s, insufficient quota %zu, need %zu", - _label.string(), dst->_label.string(), _quota, quota); + warning("Transfer CPU quota, ", _label, " -> ", dst->_label, ", " + "insufficient quota ", _quota, ", need ", quota); return -3; } /* transfer quota */ @@ -212,20 +207,17 @@ int Cpu_session_component::ref_account(Cpu_session_capability ref_cap) * FIXME Add check for cycles along the tree of reference accounts */ if (_ref) { - PWRN("Set ref account, %s, set already", - _label.string()); + warning("set ref account, ", _label, ", set already"); return -2; } /* lookup and check targeted CPU-session */ auto lambda = [&] (Cpu_session_component *ref) { if (!ref) { - PWRN("Set ref account, %s, targeted session not found", - _label.string()); + warning("set ref account, ", _label, ", targeted session not found"); return -1; } if (ref == this) { - PWRN("Set ref account, %s, self reference not allowed", - _label.string()); + warning("set ref account, ", _label, ", self reference not allowed"); return -3; } /* establish ref-account relation from targeted CPU-session to us */ diff --git a/repos/base/src/core/cpu_session_support.cc b/repos/base/src/core/cpu_session_support.cc index 41debdeb6..be7585e9b 100644 --- a/repos/base/src/core/cpu_session_support.cc +++ b/repos/base/src/core/cpu_session_support.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -22,7 +22,7 @@ using namespace Genode; Dataspace_capability Cpu_thread_component::utcb() { - PERR("%s: Not implemented", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": not implemented"); return Dataspace_capability(); } diff --git a/repos/base/src/core/include/assertion.h b/repos/base/src/core/include/assertion.h index 159a454a7..291b90fae 100644 --- a/repos/base/src/core/include/assertion.h +++ b/repos/base/src/core/include/assertion.h @@ -15,10 +15,11 @@ #define _CORE__INCLUDE__ASSERTION_H_ /* Genode includes */ -#include +#include #define ASSERT_NEVER_CALLED \ - PERR("Unexpected call of '%s' (%s:%u)", __FUNCTION__, __FILE__, __LINE__); \ + Genode::error("Unexpected call of '", __FUNCTION__, "' " \ + "(", __FILE__, ":", __LINE__, ")"); \ for (;;); throw 0UL; #endif /* _CORE__INCLUDE__ASSERTION_H_ */ diff --git a/repos/base/src/core/include/core_env.h b/repos/base/src/core/include/core_env.h index 286278711..6fc7075ec 100644 --- a/repos/base/src/core/include/core_env.h +++ b/repos/base/src/core/include/core_env.h @@ -183,19 +183,19 @@ namespace Genode { Cpu_session *cpu_session() override { - PWRN("%s:%u not implemented", __FILE__, __LINE__); + warning(__func__, " not implemented"); return 0; } Cpu_session_capability cpu_session_cap() override { - PWRN("%s:%u not implemented", __FILE__, __LINE__); + warning(__func__, " not implemented"); return Cpu_session_capability(); } Pd_session_capability pd_session_cap() override { - PWRN("%s:%u not implemented", __FILE__, __LINE__); + warning(__func__, " not implemented"); return Pd_session_capability(); } diff --git a/repos/base/src/core/include/core_parent.h b/repos/base/src/core/include/core_parent.h index 33dfd9ec1..c0239a846 100644 --- a/repos/base/src/core/include/core_parent.h +++ b/repos/base/src/core/include/core_parent.h @@ -15,7 +15,6 @@ #ifndef _CORE__INCLUDE__CORE_PARENT_H_ #define _CORE__INCLUDE__CORE_PARENT_H_ -#include #include namespace Genode { struct Core_parent; } diff --git a/repos/base/src/core/include/core_pd_session.h b/repos/base/src/core/include/core_pd_session.h index a70719993..5044c0e95 100644 --- a/repos/base/src/core/include/core_pd_session.h +++ b/repos/base/src/core/include/core_pd_session.h @@ -85,7 +85,7 @@ class Genode::Core_pd_session_component : public Rpc_object { _signal_source_ep.apply(cap, [&] (Signal_context_component *context) { if (!context) { - PDBG("invalid signal-context capability"); + warning("invalid signal-context capability"); return; } diff --git a/repos/base/src/core/include/dataspace_component.h b/repos/base/src/core/include/dataspace_component.h index 1027a7ec1..c66d7673d 100644 --- a/repos/base/src/core/include/dataspace_component.h +++ b/repos/base/src/core/include/dataspace_component.h @@ -16,7 +16,6 @@ #define _CORE__INCLUDE__DATASPACE_COMPONENT_H_ /* Genode includes */ -#include #include #include #include diff --git a/repos/base/src/core/include/log_session_component.h b/repos/base/src/core/include/log_session_component.h index 3f6d0d64a..20eac1c9b 100644 --- a/repos/base/src/core/include/log_session_component.h +++ b/repos/base/src/core/include/log_session_component.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -47,7 +48,7 @@ namespace Genode { size_t write(String const &string_buf) { if (!(string_buf.valid_string())) { - PERR("corrupted string"); + error("corrupted string"); return 0; } @@ -77,14 +78,14 @@ namespace Genode { if (string[i] == '\n') { memcpy(buf, string + from_i, i - from_i); buf[i - from_i] = 0; - printf("[%s] %s\n", _label, buf); + log("[", Cstring(_label), "] ", Cstring(buf)); from_i = i + 1; } } /* if last character of string was not a line break, add one */ if (from_i < len) - printf("[%s] %s\n", _label, string + from_i); + log("[", Cstring(_label), "] ", Cstring(string + from_i)); return len; } diff --git a/repos/base/src/core/include/rm_session_component.h b/repos/base/src/core/include/rm_session_component.h index df16fe97a..b78a67221 100644 --- a/repos/base/src/core/include/rm_session_component.h +++ b/repos/base/src/core/include/rm_session_component.h @@ -92,7 +92,7 @@ class Genode::Rm_session_component : public Rpc_object _ep.apply(rm, [&] (Region_map_component *rmc) { if (!rmc) { - PWRN("could not look up region map to destruct"); + warning("could not look up region map to destruct"); return; } diff --git a/repos/base/src/core/include/rom_fs.h b/repos/base/src/core/include/rom_fs.h index dadba7222..8fca9890c 100644 --- a/repos/base/src/core/include/rom_fs.h +++ b/repos/base/src/core/include/rom_fs.h @@ -15,7 +15,7 @@ #define _CORE__INCLUDE__ROM_FS_H_ #include -#include +#include #include #include @@ -62,6 +62,11 @@ namespace Genode { /** Accessor functions */ addr_t addr() const { return _addr; } size_t size() const { return _size; } + + void print(Output &out) const + { + Genode::print(out, Hex_range(_addr, _size), " ", name()); + } }; class Rom_fs : public Avl_tree @@ -79,17 +84,17 @@ namespace Genode { if (!r) { Rom_module *first_module = (Rom_module *)first(); if (first_module) { - printf("Rom_fs %p dump:\n", this); + log("ROM modules:"); print_fs(first_module); } else { - printf("No modules in Rom_fs %p\n", this); + log("No modules in Rom_fs ", this); } } else { + + log(" ROM: ", Hex_range(r->addr(), r->size()), " ", + r->name()); + Rom_module *child; - - printf(" Rom: [%08lx,%08lx) %s\n", - r->addr(), r->addr() + r->size(), r->name()); - if ((child = (Rom_module *)r->child(Rom_module::LEFT))) print_fs(child); if ((child = (Rom_module *)r->child(Rom_module::RIGHT))) print_fs(child); } diff --git a/repos/base/src/core/include/signal_broker.h b/repos/base/src/core/include/signal_broker.h index d401bd830..cb0548f11 100644 --- a/repos/base/src/core/include/signal_broker.h +++ b/repos/base/src/core/include/signal_broker.h @@ -80,7 +80,7 @@ class Genode::Signal_broker _context_ep.apply(context_cap, [&] (Signal_context_component *c) { context = c; if (!context) { - PWRN("specified signal-context capability has wrong type"); + warning("specified signal-context capability has wrong type"); return; } @@ -98,7 +98,7 @@ class Genode::Signal_broker * suppress this warning in release mode (SPECS += * release). */ - PDBG("invalid signal-context capability"); + warning("invalid signal-context capability"); return; } diff --git a/repos/base/src/core/include/trace/control_area.h b/repos/base/src/core/include/trace/control_area.h index 4d6b048e4..2a19f24fa 100644 --- a/repos/base/src/core/include/trace/control_area.h +++ b/repos/base/src/core/include/trace/control_area.h @@ -79,7 +79,7 @@ class Genode::Trace::Control_area return true; } - PERR("trace-control allocaton failed"); + error("trace-control allocaton failed"); return false; } diff --git a/repos/base/src/core/io_mem_session_component.cc b/repos/base/src/core/io_mem_session_component.cc index 4a76776df..27b74dae1 100644 --- a/repos/base/src/core/io_mem_session_component.cc +++ b/repos/base/src/core/io_mem_session_component.cc @@ -22,9 +22,6 @@ using namespace Genode; -static const bool verbose = false; - - Io_mem_session_component::Dataspace_attr Io_mem_session_component::_prepare_io_mem(const char *args, Range_allocator *ram_alloc) @@ -46,18 +43,19 @@ Io_mem_session_component::_prepare_io_mem(const char *args, /* check for RAM collision */ int ret; if ((ret = ram_alloc->remove_range(base, size))) { - PERR("I/O memory [%lx,%lx) used by RAM allocator (%d)", base, base + size, ret); + error("I/O memory ", Hex_range(base, size), " " + "used by RAM allocator (", ret, ")"); return Dataspace_attr(); } /* allocate region */ switch (_io_mem_alloc->alloc_addr(req_size, req_base).value) { case Range_allocator::Alloc_return::RANGE_CONFLICT: - PERR("I/O memory [%lx,%lx) not available", req_base, req_base + req_size); + error("I/O memory ", Hex_range(req_base, req_size), " not available"); return Dataspace_attr(); case Range_allocator::Alloc_return::OUT_OF_METADATA: - PERR("I/O memory allocator ran out of meta data"); + error("I/O memory allocator ran out of meta data"); return Dataspace_attr(); case Range_allocator::Alloc_return::OK: break; @@ -66,11 +64,6 @@ Io_mem_session_component::_prepare_io_mem(const char *args, /* request local mapping */ addr_t local_addr = _map_local(base, size); - if (verbose) - PDBG("I/O mem [%lx,%lx) => [%lx,%lx)%s", - base, base + size, local_addr, local_addr + size, - (_cacheable == WRITE_COMBINED) ? " (write-combined)" : ""); - return Dataspace_attr(size, local_addr, base, _cacheable, req_base); } @@ -85,7 +78,7 @@ Io_mem_session_component::Io_mem_session_component(Range_allocator *io_mem_alloc _ds_ep(ds_ep) { if (!_ds.valid()) { - PERR("Local MMIO mapping failed!"); + error("Local MMIO mapping failed!"); _ds_cap = Io_mem_dataspace_capability(); throw Root::Invalid_args(); @@ -97,9 +90,6 @@ Io_mem_session_component::Io_mem_session_component(Range_allocator *io_mem_alloc Io_mem_session_component::~Io_mem_session_component() { - if (verbose) - PDBG("I/O mem free [%lx,%lx)", _ds.phys_addr(), _ds.phys_addr() + _ds.size()); - /* dissolve IO_MEM dataspace from service entry point */ _ds_ep->dissolve(&_ds); diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index 835358aa5..840ece989 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -94,7 +94,7 @@ Session_capability Core_parent::session(Parent::Service_name const &name, if (service) return service->session(args.string(), affinity); - PWRN("service_name=\"%s\" arg=\"%s\" not handled", name.string(), args.string()); + warning("service_name=\"", name.string(), "\" args=\"", args.string(), "\" not handled"); return Session_capability(); } @@ -233,8 +233,6 @@ int main() log("Genode ", Genode::version_string); - PDBG("--- create local services ---"); - static Trace::Policy_registry trace_policies; /* @@ -291,15 +289,13 @@ int main() /* make platform-specific services known to service pool */ platform_add_local_services(e, &sliced_heap, &local_services); - PDBG("--- start init ---"); - /* obtain ROM session with init binary */ Rom_session_capability init_rom_session_cap; try { static Rom_connection rom("init"); init_rom_session_cap = rom.cap(); } catch (...) { - PERR("ROM module \"init\" not present"); } + error("ROM module \"init\" not present"); } /* create ram session for init and transfer some of our own quota */ Ram_session_capability init_ram_session_cap @@ -320,7 +316,7 @@ int main() core's heap and not accounted by the component's meta data allocator */ Genode::size_t init_quota = platform()->ram_alloc()->avail() - 224*1024; env()->ram_session()->transfer_quota(init_ram_session_cap, init_quota); - PDBG("transferred %zu MB to init", init_quota / (1024*1024)); + log("", init_quota / (1024*1024), " MiB RAM assigned to init"); Pd_connection init_pd("init"); Core_child *init = new (env()->heap()) @@ -328,16 +324,12 @@ int main() init_pd, init_ram_session_cap, init_cpu.cap(), local_services); - PDBG("--- init created, waiting for exit condition ---"); platform()->wait_for_exit(); - PDBG("--- destroying init ---"); destroy(env()->heap(), init); rom_root.close(init_rom_session_cap); ram_root.close(init_ram_session_cap); - PDBG("--- core main says good bye ---"); - return 0; } diff --git a/repos/base/src/core/pager_object.cc b/repos/base/src/core/pager_object.cc index ce8678f87..6e082c181 100644 --- a/repos/base/src/core/pager_object.cc +++ b/repos/base/src/core/pager_object.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* core includes */ #include @@ -22,7 +22,7 @@ using namespace Genode; void Pager_object::wake_up() { - PWRN("user-level page fault handling is not supported on this platform"); + warning("user-level page fault handling is not supported on this platform"); } diff --git a/repos/base/src/core/pd_session_component.cc b/repos/base/src/core/pd_session_component.cc index f982027a8..217262926 100644 --- a/repos/base/src/core/pd_session_component.cc +++ b/repos/base/src/core/pd_session_component.cc @@ -12,9 +12,6 @@ * under the terms of the GNU General Public License version 2. */ -/* Genode includes */ -#include - /* core-local includes */ #include #include diff --git a/repos/base/src/core/ram_session_component.cc b/repos/base/src/core/ram_session_component.cc index 884c5bbff..70a5e27c7 100644 --- a/repos/base/src/core/ram_session_component.cc +++ b/repos/base/src/core/ram_session_component.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* core includes */ @@ -21,9 +21,6 @@ using namespace Genode; -static const bool verbose = false; - - addr_t Ram_session_component::phys_addr(Ram_dataspace_capability ds) { auto lambda = [] (Dataspace_component *dsc) { @@ -80,8 +77,8 @@ int Ram_session_component::_transfer_quota(Ram_session_component *dst, size_t am /* decrease quota limit of this session - check against used quota */ if (_quota_limit < amount + _payload) { - PWRN("Insufficient quota for transfer: %s", _label); - PWRN(" have %zu, need %zu", _quota_limit - _payload, amount); + warning("Insufficient quota for transfer: ", Cstring(_label)); + warning(" have ", _quota_limit - _payload, ", need ", amount); return -3; } @@ -131,19 +128,8 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attr * meta data of the dataspace to be created - therefore, we add * the slab block size here. */ - if (used_quota() + SBS + ds_size > _quota_limit) { - - if (verbose) { - PWRN("Quota exceeded: %s", _label); - PWRN(" memory for slab: %zu", _ds_slab.consumed()); - PWRN(" used quota: %zu", used_quota()); - PWRN(" ds_size: %zu", ds_size); - PWRN(" sizeof(Ram_session_component): %zu", sizeof(Ram_session_component)); - PWRN(" quota_limit: %zu", _quota_limit); - } - + if (used_quota() + SBS + ds_size > _quota_limit) throw Quota_exceeded(); - } /* * Allocate physical backing store @@ -170,7 +156,7 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attr * fragmentation could cause a failing allocation. */ if (!alloc_succeeded) { - PERR("We ran out of physical memory while allocating %zu bytes", ds_size); + error("out of physical memory while allocating ", ds_size, " bytes"); throw Quota_exceeded(); } @@ -184,7 +170,7 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attr ds = new (&_ds_slab) Dataspace_component(ds_size, (addr_t)ds_addr, cached, true, this); } catch (Allocator::Out_of_memory) { - PWRN("Could not allocate metadata"); + warning("Could not allocate metadata"); /* cleanup unneeded resources */ _ram_alloc->free(ds_addr); @@ -195,7 +181,7 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attr try { _export_ram_ds(ds); } catch (Out_of_metadata) { - PWRN("could not export RAM dataspace of size 0x%zx", ds->size()); + warning("could not export RAM dataspace of size ", ds->size()); /* cleanup unneeded resources */ destroy(&_ds_slab, ds); _ram_alloc->free(ds_addr); @@ -210,10 +196,6 @@ Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, Cache_attr */ _clear_ds(ds); - if (verbose) - PDBG("ds_size=%zu, used_quota=%zu quota_limit=%zu", - ds_size, used_quota(), _quota_limit); - Dataspace_capability result = _ds_ep->manage(ds); Lock::Guard lock_guard(_ref_members_lock); @@ -254,9 +236,6 @@ int Ram_session_component::ref_account(Ram_session_capability ram_session_cap) int Ram_session_component::transfer_quota(Ram_session_capability ram_session_cap, size_t amount) { - if (verbose) - PDBG("amount=%zu", amount); - auto lambda = [&] (Ram_session_component *dst) { return _transfer_quota(dst, amount); }; return _ram_session_ep->apply(ram_session_cap, lambda); @@ -294,7 +273,7 @@ Ram_session_component::~Ram_session_component() _free_ds(ds->cap())); if (_payload != 0) - PWRN("Remaining payload of %zu in ram session to destroy", _payload); + warning("Remaining payload of ", _payload, " in ram session to destroy"); if (!_ref_account) return; diff --git a/repos/base/src/core/region_map_component.cc b/repos/base/src/core/region_map_component.cc index 593320f14..fecf1e33c 100644 --- a/repos/base/src/core/region_map_component.cc +++ b/repos/base/src/core/region_map_component.cc @@ -7,14 +7,14 @@ */ /* - * Copyright (C) 2006-2013 Genode Labs GmbH + * Copyright (C) 2006-2016 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. */ /* Genode includes */ -#include +#include #include #include #include @@ -214,7 +214,7 @@ int Rm_client::pager(Ipc_pager &pager) src_fault_area.constrain(map_size_log2); dst_fault_area.constrain(map_size_log2); if (!src_fault_area.valid() || !dst_fault_area.valid()) - PERR("Invalid mapping"); + error("invalid mapping"); /* * Check if dataspace is compatible with page-fault type @@ -390,11 +390,6 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, /* inform dataspace about attachment */ dsc->attached_to(region); - if (verbose) - PDBG("attach ds %p (a=%lx,s=%zx,o=%lx) @ [%lx,%lx)", - (Dataspace_component *)dsc, dsc->phys_addr(), dsc->size(), - offset, (addr_t)r, (addr_t)r + size); - /* check if attach operation resolves any faulting region-manager clients */ for (Rm_faulter *faulter = _faulters.head(); faulter; ) { @@ -422,11 +417,6 @@ static void unmap_managed(Region_map_component *rm, Rm_region *region, int level managed; managed = managed->List::Element::next()) { - if (verbose) - PDBG("(%d: %p) a=%lx,s=%lx,off=%lx ra=%lx,s=%lx,off=%lx sub-session %p", - level, rm, managed->base(), (long)managed->size(), managed->offset(), - region->base(), (long)region->size(), region->offset(), managed->rm()); - if (managed->base() - managed->offset() >= region->base() - region->offset() && managed->base() - managed->offset() + managed->size() <= region->base() - region->offset() + region->size()) @@ -451,18 +441,13 @@ void Region_map_component::detach(Local_addr local_addr) Rm_region *region_ptr = _map.metadata(local_addr); if (!region_ptr) { - PWRN("detach: no attachment at %p", (void *)local_addr); + warning("detach: no attachment at ", (void *)local_addr); return; } Dataspace_component *dsc = region_ptr->dataspace(); if (!dsc) - PWRN("Rm_region of %p may be inconsistent!", this); - - if (verbose) - PDBG("detach ds %p (a=%lx,s=%zx,o=%lx) at [%lx,%lx)", - dsc, dsc->phys_addr(), dsc->size(), region_ptr->offset(), - region_ptr->base(), region_ptr->base() + region_ptr->size()); + warning("detach: region of ", this, " may be inconsistent!"); /* inform dataspace about detachment */ dsc->detached_from(region_ptr); @@ -522,7 +507,7 @@ void Region_map_component::detach(Local_addr local_addr) */ if (!platform()->supports_direct_unmap() && dsc->managed() && dsc->core_local_addr() == 0) { - PWRN("unmapping of managed dataspaces not yet supported"); + warning("unmapping of managed dataspaces not yet supported"); break; } @@ -628,8 +613,9 @@ Region_map::State Region_map_component::state() return faulter->fault_state(); } -static Dataspace_capability _type_deduction_helper(Dataspace_capability cap) { - return cap; } + +static Dataspace_capability +_type_deduction_helper(Dataspace_capability cap) { return cap; } Region_map_component::Region_map_component(Rpc_entrypoint &ep, diff --git a/repos/base/src/core/rom_session_component.cc b/repos/base/src/core/rom_session_component.cc index 37d1c40da..dd792e7cb 100644 --- a/repos/base/src/core/rom_session_component.cc +++ b/repos/base/src/core/rom_session_component.cc @@ -11,7 +11,6 @@ * under the terms of the GNU General Public License version 2. */ -#include #include #include #include diff --git a/repos/base/src/core/rpc_cap_factory_l4.cc b/repos/base/src/core/rpc_cap_factory_l4.cc index b040c8e16..9c6921904 100644 --- a/repos/base/src/core/rpc_cap_factory_l4.cc +++ b/repos/base/src/core/rpc_cap_factory_l4.cc @@ -29,7 +29,7 @@ Native_capability Rpc_cap_factory::_alloc(Rpc_cap_factory *owner, Native_capability ep) { if (!ep.valid()) { - PWRN("Invalid entrypoint capability"); + warning("Invalid entrypoint capability"); return Native_capability(); } diff --git a/repos/base/src/core/signal_source_component.cc b/repos/base/src/core/signal_source_component.cc index fe7530ec8..c445e4fc3 100644 --- a/repos/base/src/core/signal_source_component.cc +++ b/repos/base/src/core/signal_source_component.cc @@ -13,7 +13,6 @@ /* Genode includes */ #include -#include /* core includes */ #include diff --git a/repos/base/src/core/spec/x86/io_port_session_component.cc b/repos/base/src/core/spec/x86/io_port_session_component.cc index 3bf8d9ed4..d5d2bcb08 100644 --- a/repos/base/src/core/spec/x86/io_port_session_component.cc +++ b/repos/base/src/core/spec/x86/io_port_session_component.cc @@ -22,9 +22,6 @@ using namespace Genode; -static const bool verbose = false; - - /****************************** ** Constructor / destructor ** ******************************/ @@ -41,11 +38,11 @@ Io_port_session_component::Io_port_session_component(Range_allocator *io_port_al switch (io_port_alloc->alloc_addr(size, base).value) { case Range_allocator::Alloc_return::RANGE_CONFLICT: - PERR("I/O port [%x,%x) not available", base, base + size); + error("I/O port ", Hex_range(base, size), " not available"); throw Root::Invalid_args(); case Range_allocator::Alloc_return::OUT_OF_METADATA: - PERR("I/O port allocator ran out of meta data"); + error("I/O port allocator ran out of meta data"); /* * Do not throw 'Quota_exceeded' because the client cannot do @@ -56,9 +53,6 @@ Io_port_session_component::Io_port_session_component(Range_allocator *io_port_al case Range_allocator::Alloc_return::OK: break; } - if (verbose) - PDBG("I/O port: [%04x,%04x)", base, base + size); - /* store information */ _base = base; _size = size; @@ -67,8 +61,5 @@ Io_port_session_component::Io_port_session_component(Range_allocator *io_port_al Io_port_session_component::~Io_port_session_component() { - if (verbose) - PDBG("I/O port: [%04x,%04x)", _base, _base + _size); - _io_port_alloc->free(reinterpret_cast(_base)); } diff --git a/repos/base/src/core/stack_area.cc b/repos/base/src/core/stack_area.cc index fac1c840c..ef5b14e04 100644 --- a/repos/base/src/core/stack_area.cc +++ b/repos/base/src/core/stack_area.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include #include -#include +#include #include #include @@ -61,8 +61,6 @@ class Stack_area_region_map : public Region_map Ds_slab _ds_slab { platform()->core_mem_alloc() }; - enum { verbose = false }; - public: /** @@ -79,30 +77,23 @@ class Stack_area_region_map : public Region_map Range_allocator *ra = platform_specific()->ram_alloc(); if (ra->alloc_aligned(size, &phys_base, get_page_size_log2()).error()) { - PERR("could not allocate backing store for new stack"); + error("could not allocate backing store for new stack"); return (addr_t)0; } - if (verbose) - PDBG("phys_base = %p, size = 0x%zx", phys_base, size); - Dataspace_component *ds = new (&_ds_slab) Dataspace_component(size, 0, (addr_t)phys_base, CACHED, true, 0); if (!ds) { - PERR("dataspace for core stack does not exist"); + error("dataspace for core stack does not exist"); return (addr_t)0; } addr_t core_local_addr = stack_area_virtual_base() + (addr_t)local_addr; - if (verbose) - PDBG("core_local_addr = %lx, phys_addr = %lx, size = 0x%zx", - core_local_addr, ds->phys_addr(), ds->size()); - if (!map_local(ds->phys_addr(), core_local_addr, ds->size() >> get_page_size_log2())) { - PERR("could not map phys %lx at local %lx", - ds->phys_addr(), core_local_addr); + error("could not map phys ", Hex(ds->phys_addr()), + " at local ", Hex(core_local_addr)); return (addr_t)0; } diff --git a/repos/base/src/core/trace_session_component.cc b/repos/base/src/core/trace_session_component.cc index e0e25b7fb..a8ddd6028 100644 --- a/repos/base/src/core/trace_session_component.cc +++ b/repos/base/src/core/trace_session_component.cc @@ -34,7 +34,7 @@ size_t Session_component::subjects() } catch (Allocator::Out_of_memory) { - PWRN("TRACE session ran out of memory"); + warning("TRACE session ran out of memory"); throw Out_of_metadata(); } diff --git a/repos/base/src/include/base/internal/capability_space_tpl.h b/repos/base/src/include/base/internal/capability_space_tpl.h index 60087c770..0a50e49bf 100644 --- a/repos/base/src/include/base/internal/capability_space_tpl.h +++ b/repos/base/src/include/base/internal/capability_space_tpl.h @@ -176,7 +176,7 @@ class Genode::Capability_space_tpl Lock::Guard guard(_lock); if (data.inc_ref() == 255) - PERR("cap ref count overflow"); + error("cap ref count overflow"); } Rpc_obj_key rpc_obj_key(Data const &data) const diff --git a/repos/base/src/include/base/internal/expanding_cpu_session_client.h b/repos/base/src/include/base/internal/expanding_cpu_session_client.h index 57fb107cb..140c44e9a 100644 --- a/repos/base/src/include/base/internal/expanding_cpu_session_client.h +++ b/repos/base/src/include/base/internal/expanding_cpu_session_client.h @@ -16,7 +16,6 @@ /* Genode includes */ #include -#include #include /* base-internal includes */ diff --git a/repos/base/src/include/base/internal/expanding_parent_client.h b/repos/base/src/include/base/internal/expanding_parent_client.h index e3624dcdd..a2e7279fb 100644 --- a/repos/base/src/include/base/internal/expanding_parent_client.h +++ b/repos/base/src/include/base/internal/expanding_parent_client.h @@ -162,7 +162,7 @@ class Genode::Expanding_parent_client : public Parent_client { Lock::Guard guard(_lock); - PLOG("resource_request: %s", args.string()); + log("resource_request: ", args.string()); /* * Issue request but don't block if a custom signal handler is diff --git a/repos/base/src/include/base/internal/platform_env.h b/repos/base/src/include/base/internal/platform_env.h index d256f39b6..32173dcaf 100644 --- a/repos/base/src/include/base/internal/platform_env.h +++ b/repos/base/src/include/base/internal/platform_env.h @@ -21,7 +21,7 @@ #define _INCLUDE__BASE__INTERNAL__PLATFORM_ENV_H_ /* Genode includes */ -#include +#include #include #include @@ -118,9 +118,9 @@ class Genode::Platform_env : public Env_deprecated, void release() { - PDBG("used before freeing emergency=%zu", _resources.ram.used()); + log("used before freeing emergency=", _resources.ram.used()); _resources.ram.free(_emergency_ram_ds); - PDBG("used after freeing emergency=%zu", _resources.ram.used()); + log("used after freeing emergency=", _resources.ram.used()); } diff --git a/repos/base/src/include/base/internal/upgradeable_client.h b/repos/base/src/include/base/internal/upgradeable_client.h index 0f153b976..bc230e415 100644 --- a/repos/base/src/include/base/internal/upgradeable_client.h +++ b/repos/base/src/include/base/internal/upgradeable_client.h @@ -15,6 +15,7 @@ #define _INCLUDE__BASE__INTERNAL__UPGRADEABLE_CLIENT_H_ #include +#include namespace Genode { template struct Upgradeable_client; } @@ -33,8 +34,8 @@ struct Genode::Upgradeable_client : CLIENT void upgrade_ram(size_t quota) { - PINF("upgrading quota donation for Env::%s (%zu bytes)", - CLIENT::Rpc_interface::service_name(), quota); + log("upgrading quota donation for Env::", CLIENT::Rpc_interface::service_name(), + " (", quota, " bytes)"); char buf[128]; snprintf(buf, sizeof(buf), "ram_quota=%zu", quota); diff --git a/repos/base/src/lib/base/allocator_avl.cc b/repos/base/src/lib/base/allocator_avl.cc index b98d14eaa..57cbea76d 100644 --- a/repos/base/src/lib/base/allocator_avl.cc +++ b/repos/base/src/lib/base/allocator_avl.cc @@ -12,7 +12,7 @@ */ #include -#include +#include using namespace Genode; @@ -186,8 +186,9 @@ void Allocator_avl_base::_revert_allocations_and_ranges() } if (dangling_allocations) - PWRN("%zd dangling allocation%s at allocator destruction time", - dangling_allocations, (dangling_allocations > 1) ? "s" : ""); + warning(dangling_allocations, " dangling allocation", + (dangling_allocations > 1) ? "s" : "", + " at allocator destruction time"); /* remove ranges */ while (Block *block = _addr_tree.first()) @@ -353,8 +354,8 @@ void Allocator_avl_base::free(void *addr) size_t new_size = b->size(); if (new_addr != (addr_t)addr) - PERR("%s: given address (0x%p) is not the block start address (0x%lx)", - __PRETTY_FUNCTION__, addr, new_addr); + error(__PRETTY_FUNCTION__, ": given address (", addr, ") " + "is not the block start address (", (void *)new_addr, ")"); _destroy_block(b); diff --git a/repos/base/src/lib/base/avl_tree.cc b/repos/base/src/lib/base/avl_tree.cc index 5758ae186..2ea2025ed 100644 --- a/repos/base/src/lib/base/avl_tree.cc +++ b/repos/base/src/lib/base/avl_tree.cc @@ -12,7 +12,7 @@ */ #include -#include +#include using namespace Genode; @@ -89,7 +89,7 @@ void Avl_node_base::_rebalance_subtree(Avl_node_base *node, Policy &policy) void Avl_node_base::insert(Avl_node_base *node, Policy &policy) { if (node == this) { - PERR("Inserting element %p twice into avl tree!", node); + error("inserting element ", node, " twice into avl tree!"); return; } @@ -118,7 +118,7 @@ void Avl_node_base::remove(Policy &policy) Avl_node_base *l = _child[0]; if (!_parent) - PERR("Error: tried to remove AVL node that is not in an AVL tree"); + error("tried to remove AVL node that is not in an AVL tree"); if (l) { diff --git a/repos/base/src/lib/base/child.cc b/repos/base/src/lib/base/child.cc index 5d98acb41..7d366fff1 100644 --- a/repos/base/src/lib/base/child.cc +++ b/repos/base/src/lib/base/child.cc @@ -57,7 +57,7 @@ namespace { { if (_from.valid() && _to.valid() && Ram_session_client(_from).transfer_quota(_to, quantum)) { - PWRN("not enough quota for a donation of %zu bytes", quantum); + warning("not enough quota for a donation of ", quantum, " bytes"); throw Parent::Quota_exceeded(); } } @@ -202,7 +202,7 @@ void Child::_remove_session(Child::Session *s) /* return session quota to the ram session of the child */ if (_policy.ref_ram_session()->transfer_quota(_ram, s->donated_ram_quota())) - PERR("We ran out of our own quota"); + error("We ran out of our own quota"); destroy(heap(), s); } @@ -218,7 +218,7 @@ Service &Child::_parent_service() void Child::_close(Session* s) { if (!s) { - PWRN("no session structure found"); + warning("no session structure found"); return; } @@ -233,8 +233,7 @@ void Child::_close(Session* s) */ try { s->service()->close(s->cap()); } catch (Blocking_canceled) { - PDBG("Got Blocking_canceled exception during %s->close call\n", - s->ident()); } + warning("Got Blocking_canceled exception during ", s->ident(), "->close call"); } /* * If the session was provided by a child of us, @@ -249,7 +248,7 @@ void Child::_close(Session* s) Ram_session_client server_ram(s->service()->ram_session_cap()); if (server_ram.transfer_quota(_policy.ref_ram_cap(), s->donated_ram_quota())) { - PERR("Misbehaving server '%s'!", s->service()->name()); + error("Misbehaving server '", s->service()->name(), "'!"); } } @@ -378,12 +377,12 @@ void Child::upgrade(Session_capability to_session, Parent::Upgrade_args const &a targeted_service = session->service(); if (!targeted_service) { - PWRN("could not lookup service for session upgrade"); + warning("could not lookup service for session upgrade"); return; } if (!args.valid_string()) { - PWRN("no valid session-upgrade arguments"); + warning("no valid session-upgrade arguments"); return; } diff --git a/repos/base/src/lib/base/child_process.cc b/repos/base/src/lib/base/child_process.cc index 05254c38c..ff4c3c97c 100644 --- a/repos/base/src/lib/base/child_process.cc +++ b/repos/base/src/lib/base/child_process.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -39,7 +39,7 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds addr_t elf_addr; try { elf_addr = local_rm.attach(elf_ds); } catch (Region_map::Attach_failed) { - PERR("local attach of ELF executable failed"); throw; } + error("local attach of ELF executable failed"); throw; } /* setup ELF object and read program entry pointer */ Elf_binary elf(elf_addr); @@ -55,13 +55,13 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds local_rm.detach(elf_addr); if (!ldso_ds.valid()) { - PERR("attempt to start dynamic executable without dynamic linker"); + error("attempt to start dynamic executable without dynamic linker"); throw Missing_dynamic_linker(); } try { elf_addr = local_rm.attach(ldso_ds); } catch (Region_map::Attach_failed) { - PERR("local attach of dynamic linker failed"); throw; } + error("local attach of dynamic linker failed"); throw; } elf_ds = ldso_ds; elf = Elf_binary(elf_addr); @@ -102,13 +102,13 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds Dataspace_capability ds_cap; try { ds_cap = ram.alloc(size); } catch (Ram_session::Alloc_failed) { - PERR("allocation of read-write segment failed"); throw; }; + error("allocation of read-write segment failed"); throw; }; /* attach dataspace */ void *base; try { base = local_rm.attach(ds_cap); } catch (Region_map::Attach_failed) { - PERR("local attach of segment dataspace failed"); throw; } + error("local attach of segment dataspace failed"); throw; } void * const ptr = base; addr_t const laddr = elf_addr + seg.file_offset(); @@ -134,14 +134,14 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds off_t const offset = 0; try { remote_rm.attach_at(ds_cap, addr, size, offset); } catch (Region_map::Attach_failed) { - PERR("remote attach of read-write segment failed"); throw; } + error("remote attach of read-write segment failed"); throw; } } else { /* read-only segment */ if (seg.file_size() != seg.mem_size()) - PWRN("filesz and memsz for read-only segment differ"); + warning("filesz and memsz for read-only segment differ"); off_t const offset = seg.file_offset(); try { @@ -151,7 +151,7 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability elf_ds remote_rm.attach_at(elf_ds, addr, size, offset); } catch (Region_map::Attach_failed) { - PERR("remote attach of read-only segment failed"); throw; } + error("remote attach of read-only segment failed"); throw; } } } diff --git a/repos/base/src/lib/base/elf_binary.cc b/repos/base/src/lib/base/elf_binary.cc index 4d672267d..8953dff19 100644 --- a/repos/base/src/lib/base/elf_binary.cc +++ b/repos/base/src/lib/base/elf_binary.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* base-internal includes */ @@ -27,18 +27,18 @@ int Elf_binary::_ehdr_check_compat() Elf_Ehdr *ehdr = (Elf_Ehdr *)_start; if (memcmp(ehdr, ELFMAG, SELFMAG) != 0) { - PERR("binary is not an ELF"); + error("binary is not an ELF"); return -1; } if (ehdr->e_ident[EI_CLASS] != ELFCLASS) { - PERR("support for 32/64-bit objects only"); + error("support for 32/64-bit objects only"); return -1; } /* start executeables and shared objects with entry points only */ if (!(ehdr->e_type == ET_EXEC || (ehdr->e_type == ET_DYN && ehdr->e_entry))) { - PERR("program is no executable"); + error("program is no executable"); return -1; } @@ -55,7 +55,7 @@ int Elf_binary::_ph_table_check_compat() for (i = 0; i < num; i++) { if (ph_table[i].p_type == PT_LOAD) if (ph_table[i].p_align & (0x1000 - 1)) { - PWRN("unsupported alignment 0x%lx", (unsigned long) ph_table[i].p_align); + warning("unsupported alignment ", (unsigned long) ph_table[i].p_align); return -1; } if (ph_table[i].p_type == PT_DYNAMIC) diff --git a/repos/base/src/lib/base/entrypoint.cc b/repos/base/src/lib/base/entrypoint.cc index 675be7361..1a1ed6d48 100644 --- a/repos/base/src/lib/base/entrypoint.cc +++ b/repos/base/src/lib/base/entrypoint.cc @@ -69,7 +69,7 @@ void Entrypoint::_process_incoming_signals() */ retry( [&] () { _signal_proxy_cap.call(); }, - [] () { PWRN("blocking canceled during signal processing"); } + [] () { warning("blocking canceled during signal processing"); } ); } while (!_suspended_callback); @@ -176,7 +176,7 @@ Entrypoint::Entrypoint(Env &env) try { constructor_cap.call(); } catch (Genode::Blocking_canceled) { - PWRN("blocking canceled in entrypoint constructor"); + warning("blocking canceled in entrypoint constructor"); } _rpc_ep->dissolve(&constructor); diff --git a/repos/base/src/lib/base/heap.cc b/repos/base/src/lib/base/heap.cc index 18005c129..4a247121e 100644 --- a/repos/base/src/lib/base/heap.cc +++ b/repos/base/src/lib/base/heap.cc @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include @@ -86,10 +86,10 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me new_ds_cap = _ds_pool.ram_session->alloc(size); ds_addr = _ds_pool.region_map->attach(new_ds_cap); } catch (Ram_session::Alloc_failed) { - PWRN("could not allocate new dataspace of size %zu", size); + warning("could not allocate new dataspace of size ", size); return 0; } catch (Region_map::Attach_failed) { - PWRN("could not attach dataspace"); + warning("could not attach dataspace"); _ds_pool.ram_session->free(new_ds_cap); return 0; } @@ -98,7 +98,7 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me /* allocate the Dataspace structure */ if (_unsynchronized_alloc(sizeof(Heap::Dataspace), &ds_meta_data_addr) < 0) { - PWRN("could not allocate dataspace meta data"); + warning("could not allocate dataspace meta data"); return 0; } @@ -109,7 +109,7 @@ Heap::Dataspace *Heap::_allocate_dataspace(size_t size, bool enforce_separate_me /* allocate the Dataspace structure */ if (_alloc->alloc_aligned(sizeof(Heap::Dataspace), &ds_meta_data_addr, log2(sizeof(addr_t))).error()) { - PWRN("could not allocate dataspace meta data - this should never happen"); + warning("could not allocate dataspace meta data - this should never happen"); return 0; } @@ -152,7 +152,7 @@ bool Heap::_unsynchronized_alloc(size_t size, void **out_addr) Heap::Dataspace *ds = _allocate_dataspace(dataspace_size, true); if (!ds) { - PWRN("could not allocate dataspace"); + warning("could not allocate dataspace"); return false; } diff --git a/repos/base/src/lib/base/output.cc b/repos/base/src/lib/base/output.cc index c3fee71b0..be4f84ad5 100644 --- a/repos/base/src/lib/base/output.cc +++ b/repos/base/src/lib/base/output.cc @@ -85,14 +85,18 @@ void Genode::print(Output &output, double value) out_float(value, 10, 6, [&] (char c) { output.out_char(c); }); } -void Genode::print(Output &output, Hex const &value) +void Genode::Hex::print(Output &output) const { - if (value.prefix == Hex::PREFIX) + if (_prefix == Hex::PREFIX) output.out_string("0x"); - size_t const pad_len = (value.pad == Hex::PAD) ? value.digits : 0; + size_t const pad_len = (_pad == Hex::PAD) ? _digits : 0; - out_unsigned(value.value, 16, pad_len, - [&] (char c) { output.out_char(c); }); + /* mask possible sign-extension bits */ + unsigned long long mask = 0; + for (size_t i = 0; i < _digits; ++i) mask = (mask << 4) | 0xf; + + out_unsigned(_value & mask, 16, pad_len, + [&] (char c) { output.out_char(c); }); } diff --git a/repos/base/src/lib/base/rpc_dispatch_loop.cc b/repos/base/src/lib/base/rpc_dispatch_loop.cc index 5138c5d44..73f28d8fa 100644 --- a/repos/base/src/lib/base/rpc_dispatch_loop.cc +++ b/repos/base/src/lib/base/rpc_dispatch_loop.cc @@ -14,7 +14,6 @@ /* Genode includes */ #include #include -#include /* base-internal includes */ #include diff --git a/repos/base/src/lib/base/rpc_entrypoint.cc b/repos/base/src/lib/base/rpc_entrypoint.cc index ea82ea9c5..940f16e32 100644 --- a/repos/base/src/lib/base/rpc_entrypoint.cc +++ b/repos/base/src/lib/base/rpc_entrypoint.cc @@ -99,7 +99,7 @@ Rpc_entrypoint::~Rpc_entrypoint() dissolve(&_exit_handler); if (!empty()) - PWRN("Object pool not empty in %s", __func__); + warning("object pool not empty in ", __func__); /* * Now that we finished the 'dissolve' steps above (which need a working diff --git a/repos/base/src/lib/base/signal.cc b/repos/base/src/lib/base/signal.cc index b079a264a..4cc3d1669 100644 --- a/repos/base/src/lib/base/signal.cc +++ b/repos/base/src/lib/base/signal.cc @@ -189,12 +189,12 @@ Genode::Signal_context_registry *signal_context_registry() void Signal_context::submit(unsigned num) { if (!_receiver) { - PWRN("signal context with no receiver"); + warning("signal context with no receiver"); return; } if (!signal_context_registry()->test_and_lock(this)) { - PWRN("encountered dead signal context"); + warning("encountered dead signal context"); return; } @@ -239,7 +239,7 @@ Signal_context_capability Signal_receiver::manage(Signal_context *context) char buf[64]; snprintf(buf, sizeof(buf), "ram_quota=%zu", quota); - PINF("upgrading quota donation for PD session (%zu bytes)", quota); + log("upgrading quota donation for PD session (", quota, " bytes)"); env()->parent()->upgrade(env()->pd_session_cap(), buf); } @@ -284,12 +284,12 @@ void Signal_receiver::dispatch_signals(Signal_source *signal_source) Signal_context *context = (Signal_context *)(source_signal.imprint()); if (!context) { - PERR("received null signal imprint, stop signal handling"); + error("received null signal imprint, stop signal handling"); sleep_forever(); } if (!signal_context_registry()->test_and_lock(context)) { - PWRN("encountered dead signal context"); + warning("encountered dead signal context"); continue; } @@ -298,7 +298,7 @@ void Signal_receiver::dispatch_signals(Signal_source *signal_source) Signal::Data signal(context, source_signal.num()); context->_receiver->local_submit(signal); } else { - PWRN("signal context with no receiver"); + warning("signal context with no receiver"); } /* free context lock that was taken by 'test_and_lock' */ diff --git a/repos/base/src/lib/base/signal_common.cc b/repos/base/src/lib/base/signal_common.cc index 29ad1b9f6..2695af383 100644 --- a/repos/base/src/lib/base/signal_common.cc +++ b/repos/base/src/lib/base/signal_common.cc @@ -94,7 +94,7 @@ Signal_context::~Signal_context() * dissolving it from the signal receiver. */ if (_receiver) - PERR("Destructing undissolved signal context"); + error("Destructing undissolved signal context"); } @@ -152,7 +152,7 @@ Signal Signal_receiver::pending_signal() context->_curr_signal = Signal::Data(0, 0); if (result.num == 0) - PWRN("returning signal with num == 0"); + warning("returning signal with num == 0"); Trace::Signal_received trace_event(*context, result.num); diff --git a/repos/base/src/lib/base/slab.cc b/repos/base/src/lib/base/slab.cc index c0db8745a..c0e2062f5 100644 --- a/repos/base/src/lib/base/slab.cc +++ b/repos/base/src/lib/base/slab.cc @@ -221,7 +221,7 @@ Slab::Slab(size_t slab_size, size_t block_size, void *initial_sb, _curr_sb = _new_slab_block(); if (!_curr_sb) { - PERR("failed to obtain initial slab block"); + error("failed to obtain initial slab block"); throw Out_of_memory(); } @@ -259,7 +259,7 @@ Slab::Block *Slab::_new_slab_block() void Slab::_release_backing_store(Block *block) { if (block->avail() != _entries_per_block) - PWRN("freeing non-empty slab block"); + error("freeing non-empty slab block"); _total_avail -= block->avail(); _num_blocks--; diff --git a/repos/base/src/lib/base/sliced_heap.cc b/repos/base/src/lib/base/sliced_heap.cc index 9ad5b3f8f..2022948f8 100644 --- a/repos/base/src/lib/base/sliced_heap.cc +++ b/repos/base/src/lib/base/sliced_heap.cc @@ -13,7 +13,7 @@ #include #include -#include +#include using namespace Genode; @@ -50,11 +50,11 @@ bool Sliced_heap::alloc(size_t size, void **out_addr) ds_cap = _ram_session.alloc(size); block = _region_map.attach(ds_cap); } catch (Region_map::Attach_failed) { - PERR("Could not attach dataspace to local address space"); + error("Could not attach dataspace to local address space"); _ram_session.free(ds_cap); return false; } catch (Ram_session::Alloc_failed) { - PERR("Could not allocate dataspace with size %zu", size); + error("Could not allocate dataspace with size %zu", size); return false; } diff --git a/repos/base/src/lib/base/thread.cc b/repos/base/src/lib/base/thread.cc index 352e53052..cfa662761 100644 --- a/repos/base/src/lib/base/thread.cc +++ b/repos/base/src/lib/base/thread.cc @@ -255,8 +255,8 @@ Thread::Thread(Env &env, Name const &name, size_t stack_size) Thread::~Thread() { if (Thread::myself() == this) { - PERR("thread '%s' tried to self de-struct - sleeping forever.", - _stack->name().string()); + error("thread '", _stack->name().string(), "' " + "tried to self de-struct - sleeping forever."); sleep_forever(); } diff --git a/repos/base/src/lib/base/trace.cc b/repos/base/src/lib/base/trace.cc index bd21debbd..24459a398 100644 --- a/repos/base/src/lib/base/trace.cc +++ b/repos/base/src/lib/base/trace.cc @@ -78,7 +78,7 @@ bool Trace::Logger::_evaluate_control() Dataspace_capability policy_ds = Cpu_thread_client(thread_cap).trace_policy(); if (!policy_ds.valid()) { - PWRN("could not obtain trace policy"); + warning("could not obtain trace policy"); control->error(); enabled = false; return false; @@ -104,7 +104,7 @@ bool Trace::Logger::_evaluate_control() Dataspace_capability buffer_ds = Cpu_thread_client(thread_cap).trace_buffer(); if (!buffer_ds.valid()) { - PWRN("could not obtain trace buffer"); + warning("could not obtain trace buffer"); control->error(); enabled = false; return false; @@ -144,7 +144,7 @@ void Trace::Logger::init(Thread_capability thread, Cpu_session *cpu_session, Dataspace_capability ds = cpu->trace_control(); size_t size = Dataspace_client(ds).size(); if ((index + 1)*sizeof(Trace::Control) > size) { - PERR("thread control index is out of range"); + error("thread control index is out of range"); return; } diff --git a/repos/base/src/lib/cxx/exception.cc b/repos/base/src/lib/cxx/exception.cc index 9e79fca5b..0408c99cb 100644 --- a/repos/base/src/lib/cxx/exception.cc +++ b/repos/base/src/lib/cxx/exception.cc @@ -16,7 +16,8 @@ #include /* Genode includes */ -#include +#include +#include extern "C" char __eh_frame_start__[]; /* from linker script */ extern "C" void __register_frame (const void *begin); /* from libgcc_eh */ @@ -58,11 +59,13 @@ void terminate_handler() char *demangled_name = __cxa_demangle(t->name(), nullptr, nullptr, nullptr); if (demangled_name) { - PERR("Uncaught exception of type '%s'", demangled_name); + Genode::error("Uncaught exception of type " + "'", Genode::Cstring(demangled_name), "'"); free(demangled_name); - } else - PERR("Uncaught exception of type '%s' (use 'c++filt -t' to demangle)", - t->name()); + } else { + Genode::error("Uncaught exception of type '", t->name(), "' " + "(use 'c++filt -t' to demangle)"); + } } diff --git a/repos/base/src/lib/cxx/misc.cc b/repos/base/src/lib/cxx/misc.cc index daec9109f..b8a0376eb 100644 --- a/repos/base/src/lib/cxx/misc.cc +++ b/repos/base/src/lib/cxx/misc.cc @@ -93,7 +93,7 @@ void __register_frame(void *) { } */ extern "C" __attribute__((weak)) void raise() { - PDBG("raise called - not implemented\n"); + warning("cxx: raise called - not implemented"); } @@ -145,7 +145,6 @@ extern "C" int memcmp(const void *p0, const void *p1, size_t size) extern "C" __attribute__((weak)) void *memcpy(void *dst, void *src, size_t n) { -// PDBG("dst=%p, src=%p, n=%d", dst, src, n); return Genode::memcpy(dst, src, n); } @@ -153,7 +152,6 @@ void *memcpy(void *dst, void *src, size_t n) extern "C" __attribute__((weak)) void *memmove(void *dst, void *src, size_t n) { -// PDBG("dst=%p, src=%p, n=%d", dst, src, n); return Genode::memmove(dst, src, n); } @@ -161,7 +159,6 @@ void *memmove(void *dst, void *src, size_t n) extern "C" __attribute__((weak)) void *memset(void *s, int c, size_t n) { -// PDBG("s=%p, c=%d, n=%d", s, c, n); return Genode::memset(s, c, n); } diff --git a/repos/base/src/lib/cxx/new_delete.cc b/repos/base/src/lib/cxx/new_delete.cc index 2145c02b7..b86b27a0b 100644 --- a/repos/base/src/lib/cxx/new_delete.cc +++ b/repos/base/src/lib/cxx/new_delete.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -43,8 +43,8 @@ static void try_dealloc(void *ptr, Deallocator &dealloc) * the size argument. */ if (dealloc.need_size_for_free()) { - PERR("C++ runtime: delete called with allocator, which needs " - "'size' on free. Blocking before leaking memory..."); + Genode::error("C++ runtime: delete called with allocator, which needs " + "'size' on free. Blocking before leaking memory..."); sleep_forever(); } @@ -69,6 +69,6 @@ void operator delete (void *ptr, Deallocator &dealloc) { try_dealloc(ptr, deall */ __attribute__((weak)) void operator delete (void *) { - PERR("cxx: operator delete (void *) called - not implemented. " - "A working implementation is available in the 'stdcxx' library."); + Genode::error("cxx: operator delete (void *) called - not implemented. " + "A working implementation is available in the 'stdcxx' library."); } diff --git a/repos/base/src/lib/ldso/debug.cc b/repos/base/src/lib/ldso/debug.cc index 8a4e0ec09..021c5e288 100644 --- a/repos/base/src/lib/ldso/debug.cc +++ b/repos/base/src/lib/ldso/debug.cc @@ -33,8 +33,8 @@ void Linker::dump_link_map(Object *o) if (o->is_binary()) continue; - Genode::printf(" " EFMT " .. " EFMT ": %s\n", - o->link_map()->addr, o->link_map()->addr + o->size() - 1, - o->name()); + Genode::log(" ", Genode::Hex(o->link_map()->addr), + " .. ", Genode::Hex(o->link_map()->addr + o->size() - 1), + ": ", o->name()); } } diff --git a/repos/base/src/lib/ldso/dependency.cc b/repos/base/src/lib/ldso/dependency.cc index 502e712c4..191e7885c 100644 --- a/repos/base/src/lib/ldso/dependency.cc +++ b/repos/base/src/lib/ldso/dependency.cc @@ -34,7 +34,7 @@ Linker::Dependency::~Dependency() if (obj->unload()) { if (verbose_loading) - PDBG("Destroy: %s\n", obj->name()); + Genode::log("Destroy: ", obj->name()); destroy(Genode::env()->heap(), obj); } diff --git a/repos/base/src/lib/ldso/exception.cc b/repos/base/src/lib/ldso/exception.cc index 8cb88dc29..ea055b23d 100644 --- a/repos/base/src/lib/ldso/exception.cc +++ b/repos/base/src/lib/ldso/exception.cc @@ -47,7 +47,7 @@ extern "C" int dl_iterate_phdr(int (*callback) (Phdr_info *info, Genode::size_t info.phnum = e->file()->phdr.count; if (verbose_exception) - PDBG("%s reloc " EFMT, e->name(), e->reloc_base()); + Genode::log(e->name(), " reloc ", Genode::Hex(e->reloc_base())); if ((err = callback(&info, sizeof(Phdr_info), data))) break; diff --git a/repos/base/src/lib/ldso/file.cc b/repos/base/src/lib/ldso/file.cc index bb89af6d0..8f9ebce24 100644 --- a/repos/base/src/lib/ldso/file.cc +++ b/repos/base/src/lib/ldso/file.cc @@ -161,12 +161,12 @@ struct Linker::Elf_file : File bool check_compat(Elf::Ehdr const *ehdr) { if (memcmp(ehdr, ELFMAG, SELFMAG) != 0) { - PERR("LD: binary is not an ELF"); + Genode::error("LD: binary is not an ELF"); return false; } if (ehdr->e_ident[EI_CLASS] != ELFCLASS) { - PERR("LD: support for 32/64-bit objects only"); + Genode::error("LD: support for 32/64-bit objects only"); return false; } @@ -215,7 +215,7 @@ struct Linker::Elf_file : File continue; if (ph->p_align & (0x1000 - 1)) { - PERR("LD: Unsupported alignment %p", (void *)ph->p_align); + Genode::error("LD: Unsupported alignment ", (void *)ph->p_align); throw Incompatible(); } @@ -244,8 +244,9 @@ struct Linker::Elf_file : File reloc_base = (start == reloc_base) ? 0 : reloc_base; if (verbose_loading) - PDBG("reloc_base: " EFMT " start: " EFMT " end: " EFMT, - reloc_base, start, reloc_base + start + size); + Genode::log("LD: reloc_base: ", Genode::Hex(reloc_base), + " start: ", Genode::Hex(start), + " end: ", Genode::Hex(reloc_base + start + size)); for (unsigned i = 0; i < p.count; i++) { Elf::Phdr *ph = &p.phdr[i]; @@ -257,7 +258,7 @@ struct Linker::Elf_file : File load_segment_rw(*ph, i); else { - PERR("LD: Non-RW/RX segment"); + Genode::error("LD: Non-RW/RX segment"); throw Invalid_file(); } } @@ -321,7 +322,8 @@ struct Linker::Elf_file : File File const *Linker::load(char const *path, bool load) { if (verbose_loading) - PDBG("loading: %s (PHDRS only: %s)", path, load ? "no" : "yes"); + Genode::log("LD loading: ", path, " " + "(PHDRS only: ", load ? "no" : "yes", ")"); Elf_file *file = new (env()->heap()) Elf_file(Linker::file(path), load); return file; diff --git a/repos/base/src/lib/ldso/include/debug.h b/repos/base/src/lib/ldso/include/debug.h index 9b3b954e9..9e11b9879 100644 --- a/repos/base/src/lib/ldso/include/debug.h +++ b/repos/base/src/lib/ldso/include/debug.h @@ -14,7 +14,8 @@ #ifndef _INCLUDE__DEBUG_H_ #define _INCLUDE__DEBUG_H_ -#include +#include +#include #include constexpr bool verbose_link_map = false; @@ -127,8 +128,9 @@ struct Linker::Link_map return; for (Link_map *m = first; m; m = m->next) - PINF("MAP: addr: " EFMT " dynamic: %p %s m: %p p: %p n: %p", - m->addr, m->dynamic, m->path, m, m->prev, m->next); + Genode::log("MAP: addr: ", Genode::Hex(m->addr), + " dynamic: ", m->dynamic, " ", Genode::Cstring(m->path), + " m: ", m, " p: ", m->prev, " n: ", m->next); } }; diff --git a/repos/base/src/lib/ldso/include/dynamic.h b/repos/base/src/lib/ldso/include/dynamic.h index 354617105..1077211db 100644 --- a/repos/base/src/lib/ldso/include/dynamic.h +++ b/repos/base/src/lib/ldso/include/dynamic.h @@ -185,7 +185,7 @@ struct Linker::Dynamic Reloc_plt(obj, pltrel_type, pltrel, pltrel_size); break; default: - PERR("LD: Invalid PLT relocation %u", pltrel_type); + Genode::error("LD: Invalid PLT relocation ", (int)pltrel_type); throw Incompatible(); } } diff --git a/repos/base/src/lib/ldso/include/init.h b/repos/base/src/lib/ldso/include/init.h index 267ae0b64..2c180911a 100644 --- a/repos/base/src/lib/ldso/include/init.h +++ b/repos/base/src/lib/ldso/include/init.h @@ -68,7 +68,7 @@ struct Linker::Init : Genode::List /* relocate */ for (; obj; obj = obj->next_init()) { if (verbose_relocation) - PDBG("Relocate %s", obj->name()); + Genode::log("Relocate ", obj->name()); obj->relocate(); } @@ -94,7 +94,7 @@ struct Linker::Init : Genode::List if (obj->dynamic()->init_function) { if (verbose_relocation) - PDBG("%s init func %p", obj->name(), obj->dynamic()->init_function); + Genode::log(obj->name(), " init func ", obj->dynamic()->init_function); obj->dynamic()->init_function(); } diff --git a/repos/base/src/lib/ldso/include/linker.h b/repos/base/src/lib/ldso/include/linker.h index dd8ae6671..edd48ee62 100644 --- a/repos/base/src/lib/ldso/include/linker.h +++ b/repos/base/src/lib/ldso/include/linker.h @@ -34,7 +34,7 @@ constexpr bool verbose_exception = false; constexpr bool verbose_shared = false; constexpr bool verbose_loading = false; -extern Elf::Addr etext; +extern Elf::Addr etext; /** * Forward declartions and helpers diff --git a/repos/base/src/lib/ldso/include/relocation_generic.h b/repos/base/src/lib/ldso/include/relocation_generic.h index a4fa6d403..bf10d0fe8 100644 --- a/repos/base/src/lib/ldso/include/relocation_generic.h +++ b/repos/base/src/lib/ldso/include/relocation_generic.h @@ -48,7 +48,7 @@ struct Linker::Plt_got Plt_got(Dependency const *dep, Elf::Addr *pltgot) { if (verbose_relocation) - PDBG("OBJ: %s (%p)", dep->obj->name(), dep); + Genode::log("OBJ: ", dep->obj->name(), " (", dep, ")"); pltgot[1] = (Elf::Addr) dep; /* ELF object */ pltgot[2] = (Elf::Addr) &_jmp_slot; /* Linker entry */ @@ -66,7 +66,7 @@ struct Linker::Reloc_plt_generic Elf::Rel const *start, unsigned long size) { if (type != TYPE) { - PERR("LD: Unsupported PLT relocation type: %u", type); + Genode::error("LD: Unsupported PLT relocation type: ", (int)type); throw Incompatible(); } @@ -75,7 +75,7 @@ struct Linker::Reloc_plt_generic for (; rel < end; rel++) { if (rel->type() != JMPSLOT) { - PERR("LD: Unsupported PLT relocation %u", rel->type()); + Genode::error("LD: Unsupported PLT relocation ", (int)rel->type()); throw Incompatible(); } @@ -102,7 +102,8 @@ class Linker::Reloc_non_plt_generic void _copy(REL const *rel, Elf::Addr *addr) { if (!_dep->obj->is_binary()) { - PERR("LD: Copy relocation in DSO (%s at %p)", _dep->obj->name(), addr); + Genode::error("LD: copy relocation in DSO " + "(", _dep->obj->name(), " at ", addr, ")"); throw Incompatible(); } @@ -111,7 +112,7 @@ class Linker::Reloc_non_plt_generic /* search symbol in other objects, do not return undefined symbols */ if (!(sym = lookup_symbol(rel->sym(), _dep, &reloc_base, false, true))) { - PWRN("LD: Symbol not found"); + Genode::warning("LD: symbol not found"); return; } @@ -119,8 +120,9 @@ class Linker::Reloc_non_plt_generic Genode::memcpy(addr, (void *)src, sym->st_size); if (verbose_relocation) - PDBG("Copy relocation: " EFMT " -> %p (0x" EFMT " bytes) val: " EFMT "\n", - src, addr, sym->st_size, sym->st_value); + Genode::log("Copy relocation: ", Genode::Hex(src), + " -> ", addr, " (", Genode::Hex(sym->st_size), " bytes)" + " val: ", Genode::Hex(sym->st_value)); } public: @@ -143,7 +145,7 @@ class Linker::Reloc_jmpslot_generic Elf::Size const index) { if (type != TYPE) { - PERR("LD: Unsupported JMP relocation type: %u", type); + Genode::error("LD: unsupported JMP relocation type: ", (int)type); throw Incompatible(); } @@ -152,7 +154,7 @@ class Linker::Reloc_jmpslot_generic Elf::Addr reloc_base; if (!(sym = lookup_symbol(rel->sym(), dep, &reloc_base))) { - PWRN("LD: Symbol not found"); + Genode::warning("LD: symbol not found"); return; } @@ -162,8 +164,9 @@ class Linker::Reloc_jmpslot_generic if (verbose_relocation) { - PDBG("jmp: rbase " EFMT " s: %p sval: " EFMT, reloc_base, sym, sym->st_value); - PDBG("jmp_slot at %p -> " EFMT, _addr, *_addr); + Genode::log("jmp: rbase ", Genode::Hex(reloc_base), + " s: ", sym, " sval: ", Genode::Hex(sym->st_value)); + Genode::log("jmp_slot at ", _addr, " -> ", *_addr); } } diff --git a/repos/base/src/lib/ldso/main.cc b/repos/base/src/lib/ldso/main.cc index 8c799e22b..193a913d1 100644 --- a/repos/base/src/lib/ldso/main.cc +++ b/repos/base/src/lib/ldso/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ struct Linker::Elf_object : Object, Genode::Fifo::Element return; if (verbose_loading) - PDBG("destroy: %s", name()); + Genode::log("LD: destroy ELF object: ", name()); /* remove from link map */ Debug::state_change(Debug::DELETE, &map); @@ -288,13 +288,13 @@ Elf::Addr Ld::jmp_slot(Dependency const *dep, Elf::Size index) Genode::Lock::Guard guard(Elf_object::lock()); if (verbose_relocation) - PDBG("SLOT %p " EFMT, dep->obj, index); + Genode::log("LD: SLOT ", dep->obj, " ", Genode::Hex(index)); try { Reloc_jmpslot slot(dep, dep->obj->dynamic()->pltrel_type, dep->obj->dynamic()->pltrel, index); return slot.target_addr(); - } catch (...) { PERR("LD: Jump slot relocation failed. FATAL!"); } + } catch (...) { Genode::error("LD: jump slot relocation failed. FATAL!"); } return 0; } @@ -405,7 +405,7 @@ Object *Linker::load(char const *path, Dependency *dep, unsigned flags) for (Object *e = Elf_object::obj_list()->head(); e; e = e->next_obj()) { if (verbose_loading) - PDBG("LOAD: %s == %s", Linker::file(path), e->name()); + Genode::log("LOAD: ", Linker::file(path), " == ", e->name()); if (!Genode::strcmp(Linker::file(path), e->name())) { e->load(); @@ -432,7 +432,7 @@ Elf::Sym const *Linker::lookup_symbol(unsigned sym_index, Dependency const *dep, Elf::Sym const *symbol = e->symbol(sym_index); if (!symbol) { - PWRN("LD: Unkown symbol index %x", sym_index); + Genode::warning("LD: unknown symbol index ", Genode::Hex(sym_index)); return 0; } @@ -465,7 +465,9 @@ Elf::Sym const *Linker::lookup_symbol(char const *name, Dependency const *dep, if ((symbol = elf->lookup_symbol(name, hash)) && (symbol->st_value || undef)) { if (dep->root && verbose_lookup) - PINF("Lookup %s obj_src %s st %p info %x weak: %u", name, elf->name(), symbol, symbol->st_info, symbol->weak()); + Genode::log("LD: lookup ", name, " obj_src ", elf->name(), + " st ", symbol, " info ", Genode::Hex(symbol->st_info), + " weak: ", symbol->weak()); if (!undef && symbol->st_shndx == SHN_UNDEF) continue; @@ -487,13 +489,13 @@ Elf::Sym const *Linker::lookup_symbol(char const *name, Dependency const *dep, if (binary && dep != binary->dep.head()) { return lookup_symbol(name, binary->dep.head(), base, undef, other); } else { - PERR("Could not lookup symbol \"%s\"", name); + Genode::error("LD: could not lookup symbol \"", name, "\""); throw Not_found(); } } if (dep->root && verbose_lookup) - PDBG("Return %p", weak_symbol); + Genode::log("LD: return ", weak_symbol); if (!weak_symbol) throw Not_found(); @@ -563,17 +565,18 @@ void Component::construct(Genode::Env &env) try { binary = new(Genode::env()->heap()) Binary(); } catch (...) { - PERR("LD: Failed to load program"); - throw Failed_to_load_program(); + Genode::error("LD: failed to load program"); + throw Failed_to_load_program(); } /* print loaded object information */ try { if (verbose) { - PINF(" %lx .. %lx: stack area", - Genode::Thread::stack_area_virtual_base(), - Genode::Thread::stack_area_virtual_base() + - Genode::Thread::stack_area_virtual_size() - 1); + using namespace Genode; + log(" ", Hex(Thread::stack_area_virtual_base()), + " .. ", Hex(Thread::stack_area_virtual_base() + + Thread::stack_area_virtual_size() - 1), + ": stack area"); dump_link_map(Elf_object::obj_list()->head()); } } catch (...) { } diff --git a/repos/base/src/lib/ldso/shared_object.cc b/repos/base/src/lib/ldso/shared_object.cc index 4b275abc7..5dfaae7a1 100644 --- a/repos/base/src/lib/ldso/shared_object.cc +++ b/repos/base/src/lib/ldso/shared_object.cc @@ -55,7 +55,7 @@ Genode::Shared_object::Shared_object(char const *file, unsigned flags) using namespace Linker; if (verbose_shared) - PDBG("open '%s'", file ? file : "binary"); + Genode::log("LD: open '", file ? file : "binary", "'"); try { Genode::Lock::Guard guard(shared_object_lock()); @@ -80,7 +80,7 @@ void *Genode::Shared_object::_lookup(const char *name) const using namespace Linker; if (verbose_shared) - PDBG("lookup '%s'", name); + Genode::log("LD: shared object lookup '", name, "'"); try { Genode::Lock::Guard guard(Object::lock()); @@ -105,7 +105,7 @@ Genode::Shared_object::~Shared_object() using namespace Linker; if (verbose_shared) - PDBG("close"); + Genode::log("LD: close shared object"); Genode::Lock::Guard guard(shared_object_lock()); destroy(Genode::env()->heap(), to_root(_handle)); @@ -117,13 +117,14 @@ Genode::Address_info::Address_info(Genode::addr_t address) using namespace Genode; if (verbose_shared) - PDBG("request: %lx", address); + Genode::log("LD: address-info request: ", Genode::Hex(address)); Linker::Object *e = find_obj(address); e->info(address, *this); if (verbose_shared) - PDBG("Found: obj: %s sym: %s addr: %lx", path, name, addr); + Genode::log("LD: found address info: obj: ", path, " sym: ", name, + " addr: ", Genode::Hex(addr)); } diff --git a/repos/base/src/lib/ldso/spec/arm/relocation.h b/repos/base/src/lib/ldso/spec/arm/relocation.h index 26cbc54b2..8fac05c59 100644 --- a/repos/base/src/lib/ldso/spec/arm/relocation.h +++ b/repos/base/src/lib/ldso/spec/arm/relocation.h @@ -81,7 +81,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic Reloc_non_plt(Dependency const *dep, Elf::Rela const *, unsigned long) : Reloc_non_plt_generic(dep) { - PERR("LD: DT_RELA not supported"); + Genode::error("LD: DT_RELA not supported"); throw Incompatible(); } @@ -105,7 +105,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic case R_RELATIVE: _relative(addr); break; default: if (_dep->root) { - PWRN("LD: Unkown relocation %u", rel->type()); + Genode::warning("LD: Unkown relocation ", (int)rel->type()); throw Incompatible(); } break; diff --git a/repos/base/src/lib/ldso/spec/riscv/relocation.h b/repos/base/src/lib/ldso/spec/riscv/relocation.h index 435345ea4..1c40c4833 100644 --- a/repos/base/src/lib/ldso/spec/riscv/relocation.h +++ b/repos/base/src/lib/ldso/spec/riscv/relocation.h @@ -68,8 +68,9 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic *addr = reloc_base + sym->st_value + (addend ? rel->addend : 0); if (verbose_reloc(_dep)) - PDBG("GLOB DAT %p -> %llx r %llx v %llx", addr, *addr, reloc_base, - sym->st_value); + Genode::log("LD: GLOB DAT ", addr, " -> ", Genode::Hex(*addr), + " r ", Genode::Hex(reloc_base), + " v ", Genode::Hex(sym->st_value)); } public: @@ -83,7 +84,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic Elf::Addr *addr = (Elf::Addr *)(_dep->obj->reloc_base() + rel->offset); if (verbose_reloc(_dep)) - PDBG("reloc: %p type: %u", rel, rel->type()); + Genode::log("LD: reloc: ", rel, " type: ", (int)rel->type()); switch(rel->type()) { case R_JMPSLOT: _glob_dat_64(rel, addr, false); break; @@ -92,7 +93,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic default: if (!_dep->obj->is_linker()) { - PWRN("LD: Unkown relocation %u", rel->type()); + Genode::warning("LD: unkown relocation ", (int)rel->type()); throw Incompatible(); } break; @@ -103,7 +104,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic Reloc_non_plt(Dependency const *dep, Elf::Rel const *, unsigned long, bool) : Reloc_non_plt_generic(dep) { - PERR("LD: DT_REL not supported"); + Genode::error("LD: DT_REL not supported"); throw Incompatible(); } }; diff --git a/repos/base/src/lib/ldso/spec/x86_32/relocation.h b/repos/base/src/lib/ldso/spec/x86_32/relocation.h index 97d1d2e74..4dd51a354 100644 --- a/repos/base/src/lib/ldso/spec/x86_32/relocation.h +++ b/repos/base/src/lib/ldso/spec/x86_32/relocation.h @@ -61,7 +61,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic Reloc_non_plt(Dependency const *dep, Elf::Rela const *, unsigned long) : Reloc_non_plt_generic(dep) { - PERR("LD: DT_RELA not supported"); + Genode::error("LD: DT_RELA not supported"); throw Incompatible(); } @@ -85,7 +85,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic case R_RELATIVE: _relative(rel, addr); break; default: if (_dep->root) { - PWRN("LD: Unkown relocation %u", rel->type()); + Genode::warning("LD: Unkown relocation ", (int)rel->type()); throw Incompatible(); } break; diff --git a/repos/base/src/lib/ldso/spec/x86_64/relocation.h b/repos/base/src/lib/ldso/spec/x86_64/relocation.h index dc49fea9e..f72b4d142 100644 --- a/repos/base/src/lib/ldso/spec/x86_64/relocation.h +++ b/repos/base/src/lib/ldso/spec/x86_64/relocation.h @@ -62,8 +62,8 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic *addr = reloc_base + sym->st_value + (addend ? rel->addend : 0); if (verbose_reloc(_dep)) - PDBG("GLOB DAT %p -> %llx r %llx v %llx", addr, *addr, reloc_base, - sym->st_value); + Genode::log("GLOB DAT ", addr, " -> ", *addr, + " r ", reloc_base, " v ", sym->st_value); } public: @@ -84,7 +84,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic default: if (!_dep->obj->is_linker()) { - PWRN("LD: Unkown relocation %u", rel->type()); + Genode::warning("LD: Unkown relocation ", (int)rel->type()); throw Incompatible(); } break; @@ -95,7 +95,7 @@ class Linker::Reloc_non_plt : public Reloc_non_plt_generic Reloc_non_plt(Dependency const *dep, Elf::Rel const *, unsigned long, bool) : Reloc_non_plt_generic(dep) { - PERR("LD: DT_REL not supported"); + Genode::error("LD: DT_REL not supported"); throw Incompatible(); } }; diff --git a/repos/base/src/lib/ldso/startup/unwind_exidx.cc b/repos/base/src/lib/ldso/startup/unwind_exidx.cc index d90a465bf..caf6ebd8f 100644 --- a/repos/base/src/lib/ldso/startup/unwind_exidx.cc +++ b/repos/base/src/lib/ldso/startup/unwind_exidx.cc @@ -17,7 +17,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include /* * from gcc/config/arm/unwind-arm.h @@ -31,7 +31,7 @@ typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); extern "C" _Unwind_Ptr __attribute__((weak)) dl_unwind_find_exidx(_Unwind_Ptr pc, int *pcount); extern "C" _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int *pcount) { - PERR("Ops called"); + Genode::error("dl_unwind_find_exidx called"); return 0; } diff --git a/repos/base/src/lib/startup/_main.cc b/repos/base/src/lib/startup/_main.cc index 40f5f341d..e56256c94 100644 --- a/repos/base/src/lib/startup/_main.cc +++ b/repos/base/src/lib/startup/_main.cc @@ -22,7 +22,7 @@ /* Genode includes */ #include #include -#include +#include #include /* platform-specific local helper functions */ @@ -48,9 +48,9 @@ struct atexit_fn { void (*std_func)(void); void (*cxa_func)(void *); - } fn_ptr; /* function pointer */ - void *fn_arg; /* argument for CXA callback */ - void *fn_dso; /* shared module handle */ + } fn_ptr; /* function pointer */ + void *fn_arg; /* argument for CXA callback */ + void *fn_dso; /* shared module handle */ }; /* all members are initialized with 0 */ @@ -83,7 +83,7 @@ static int atexit_register(struct atexit_fn *fn) return 0; if (_atexit.index >= ATEXIT_SIZE) { - PERR("Cannot register exit handler - ATEXIT_SIZE reached"); + Genode::error("Cannot register exit handler - ATEXIT_SIZE reached"); return -1; } @@ -129,7 +129,7 @@ int genode___cxa_atexit(void (*func)(void*), void *arg, void *dso) fn.fn_arg = arg; fn.fn_dso = dso; - error = atexit_register(&fn); + error = atexit_register(&fn); return (error); } diff --git a/repos/base/src/lib/startup/init_main_thread.cc b/repos/base/src/lib/startup/init_main_thread.cc index afe99a9c1..502e1492e 100644 --- a/repos/base/src/lib/startup/init_main_thread.cc +++ b/repos/base/src/lib/startup/init_main_thread.cc @@ -16,7 +16,6 @@ /* Genode includes */ #include #include -#include #include /* base-internal includes */ diff --git a/repos/base/src/test/ada/startup.cc b/repos/base/src/test/ada/startup.cc index dba0c1a54..e5b6aa4c2 100644 --- a/repos/base/src/test/ada/startup.cc +++ b/repos/base/src/test/ada/startup.cc @@ -5,7 +5,7 @@ */ /* Genode includes */ -#include +#include /** * Declaration of the Ada main procedure @@ -17,7 +17,7 @@ extern "C" void _ada_main(void); */ extern "C" void __gnat_eh_personality() { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } /** diff --git a/repos/base/src/test/affinity/main.cc b/repos/base/src/test/affinity/main.cc index c6eb3428c..b0d8905dc 100644 --- a/repos/base/src/test/affinity/main.cc +++ b/repos/base/src/test/affinity/main.cc @@ -12,12 +12,21 @@ */ /* Genode includes */ -#include +#include #include #include #include +namespace Genode { + + static inline void print(Output &out, Affinity::Location location) + { + print(out, location.xpos(), ",", location.ypos()); + } +} + + enum { STACK_SIZE = sizeof(long)*1024, COUNT_VALUE = 10 * 1024 * 1024 }; struct Spinning_thread : Genode::Thread @@ -32,8 +41,7 @@ struct Spinning_thread : Genode::Thread { barrier.unlock(); - PINF("thread started on CPU %d,%d, spinning...", - _location.xpos(), _location.ypos()); + Genode::log("thread started on CPU ", _location, " spinning..."); unsigned round = 0; @@ -42,8 +50,8 @@ struct Spinning_thread : Genode::Thread /* show a life sign every now and then... */ if (cnt % COUNT_VALUE == 0) { - PINF("thread on CPU %d,%d keeps counting - round %u...\n", - _location.xpos(), _location.ypos(), round++); + Genode::log("thread on CPU ", _location, " keeps counting - " + "round ", round++, "..."); } } } @@ -73,11 +81,11 @@ Main::Main(Genode::Env &env) : env(env) { using namespace Genode; - printf("--- test-affinity started ---\n"); + log("--- test-affinity started ---"); Affinity::Space cpus = env.cpu().affinity_space(); - printf("Detected %ux%u CPU%s\n", - cpus.width(), cpus.height(), cpus.total() > 1 ? "s." : "."); + log("Detected ", cpus.width(), "x", cpus.height(), " " + "CPU", cpus.total() > 1 ? "s." : "."); /* get some memory for the thread objects */ Spinning_thread ** threads = new (heap) Spinning_thread*[cpus.total()]; @@ -92,10 +100,10 @@ Main::Main(Genode::Env &env) : env(env) for (unsigned i = 0; i < cpus.total(); i++) threads[i]->barrier.lock(); - printf("Threads started on a different CPU each.\n"); - printf("You may inspect them using the kernel debugger - if you have one.\n"); - printf("Main thread monitors client threads and prints the status of them.\n"); - printf("Legend : D - DEAD, A - ALIVE\n"); + log("Threads started on a different CPU each."); + log("You may inspect them using the kernel debugger - if you have one."); + log("Main thread monitors client threads and prints the status of them."); + log("Legend : D - DEAD, A - ALIVE"); volatile uint64_t cnt = 0; unsigned round = 0; @@ -116,7 +124,7 @@ Main::Main(Genode::Env &env) : env(env) snprintf(output, 4, "%2u ", i); output += 3; } - printf("%s\n", output_buffer); + log(Cstring(output_buffer)); output = output_buffer; snprintf(output, sizeof(text_round), text_round, round); @@ -128,7 +136,7 @@ Main::Main(Genode::Env &env) : env(env) output += 3; thread_cnt[i] = threads[i]->cnt; } - printf("%s\n", output_buffer); + log(Cstring(output_buffer)); round ++; } diff --git a/repos/base/src/test/fpu/main.cc b/repos/base/src/test/fpu/main.cc index 93da62ea4..a323a8b2a 100644 --- a/repos/base/src/test/fpu/main.cc +++ b/repos/base/src/test/fpu/main.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include using namespace Genode; @@ -67,7 +67,7 @@ class Fpu_user : public Thread_deprecated<0x2000> void entry() { - Genode::printf("FPU user started\n"); + Genode::log("FPU user started"); bool submitted = false; while (1) { enum { TRIALS = 1000 }; @@ -78,7 +78,7 @@ class Fpu_user : public Thread_deprecated<0x2000> _calc(a, c); _calc(b, c); if (a != b) { - PERR("calculation error"); + Genode::error("calculation error"); _st->submit(1); sleep_forever(); } @@ -108,7 +108,7 @@ int main() } /* wait for an ack of every FPU user */ for (unsigned i = 0; i < FPU_USERS;) { i += sr.wait_for_signal().num(); } - printf("test done\n"); + log("test done"); sleep_forever(); return 0; } diff --git a/repos/base/src/test/printf/main.cc b/repos/base/src/test/printf/main.cc index dc7a25733..8335989a4 100644 --- a/repos/base/src/test/printf/main.cc +++ b/repos/base/src/test/printf/main.cc @@ -16,13 +16,6 @@ #include #include -namespace Component { - - Genode::size_t stack_size() { return 4*1024*sizeof(long); } - - void construct(Genode::Env &env); -} - void Component::construct(Genode::Env &env) { @@ -32,6 +25,8 @@ void Component::construct(Genode::Env &env) log("empty hex range: ", Hex_range(0xabc0000, 0)); log("hex range to limit: ", Hex_range(0xf8, 8)); log("invalid hex range: ", Hex_range(0xf8, 0x10)); + log("negative hex char: ", Hex((char)-2LL, Hex::PREFIX, Hex::PAD)); + log("positive hex char: ", Hex((char) 2LL, Hex::PREFIX, Hex::PAD)); /* test that unsupported commands don't crash the printf parser */ printf("%#x %s\n", 0x38, "test 1"); diff --git a/repos/base/src/test/rm_fault/main.cc b/repos/base/src/test/rm_fault/main.cc index dfae84381..1e500d649 100644 --- a/repos/base/src/test/rm_fault/main.cc +++ b/repos/base/src/test/rm_fault/main.cc @@ -17,7 +17,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -31,6 +31,7 @@ using namespace Genode; + /*********** ** Child ** ***********/ @@ -40,19 +41,19 @@ enum { MANAGED_ADDR = 0x10000000 }; void read_at(addr_t addr) { - printf("perform read operation at 0x%p\n", (void *)addr); + log("perform read operation at ", Hex(addr)); int value = *(int *)addr; - printf("read value %x\n", value); + log("read value ", Hex(value)); } void modify(addr_t addr) { - printf("modify memory at 0x%p to %x\n", (void *)addr, ++(*(int *)addr)); + log("modify memory at ", Hex(addr), " to ", Hex(++(*(int *)addr))); } void main_child() { - printf("child role started\n"); + log("child role started"); /* perform illegal access */ read_at(MANAGED_ADDR); @@ -60,7 +61,7 @@ void main_child() while (true) modify(MANAGED_ADDR); - printf("--- child role of region-manager fault test finished ---\n"); + log("--- child role of region-manager fault test finished ---"); } @@ -136,7 +137,7 @@ class Test_child : public Child_policy void main_parent(Dataspace_capability elf_ds) { - printf("parent role started\n"); + log("parent role started"); /* create environment for new child */ static Pd_connection pd; @@ -165,28 +166,29 @@ void main_parent(Dataspace_capability elf_ds) for (int i = 0; i < 4; i++) { - printf("wait for region-manager fault\n"); + log("wait for region-manager fault"); fault_handler.wait_for_signal(); - printf("received region-manager fault signal, request fault state\n"); + log("received region-manager fault signal, request fault state"); Region_map::State state = address_space.state(); - printf("rm session state is %s, pf_addr=0x%p\n", - state.type == Region_map::State::READ_FAULT ? "READ_FAULT" : - state.type == Region_map::State::WRITE_FAULT ? "WRITE_FAULT" : - state.type == Region_map::State::EXEC_FAULT ? "EXEC_FAULT" : "READY", - (void *)state.addr); + char const *state_name = + state.type == Region_map::State::READ_FAULT ? "READ_FAULT" : + state.type == Region_map::State::WRITE_FAULT ? "WRITE_FAULT" : + state.type == Region_map::State::EXEC_FAULT ? "EXEC_FAULT" : "READY"; + + log("rm session state is ", state_name, ", pf_addr=", Hex(state.addr)); /* ignore spuriuous fault signal */ if (state.type == Region_map::State::READY) { - PINF("ignoring spurious fault signal"); + log("ignoring spurious fault signal"); continue; } addr_t child_virt_addr = state.addr & ~(4096 - 1); /* allocate dataspace to resolve the fault */ - printf("attach dataspace to the child at 0x%p\n", (void *)child_virt_addr); + log("attach dataspace to the child at ", Hex(child_virt_addr)); *local_addr = 0x1234; address_space.attach_at(ds, child_virt_addr); @@ -194,15 +196,15 @@ void main_parent(Dataspace_capability elf_ds) /* wait until our child modifies the dataspace content */ while (*local_addr == 0x1234); - printf("child modified dataspace content, new value is %x\n", *local_addr); + log("child modified dataspace content, new value is ", Hex(*local_addr)); - printf("revoke dataspace from child\n"); + log("revoke dataspace from child"); address_space.detach((void *)child_virt_addr); } fault_handler.dissolve(&signal_context); - printf("--- parent role of region-manager fault test finished ---\n"); + log("--- parent role of region-manager fault test finished ---"); } @@ -212,7 +214,7 @@ void main_parent(Dataspace_capability elf_ds) int main(int argc, char **argv) { - printf("--- region-manager fault test ---\n"); + log("--- region-manager fault test ---"); /* obtain own elf file from rom service */ try { diff --git a/repos/base/src/test/slab/main.cc b/repos/base/src/test/slab/main.cc index 1f2ba92e9..95d3051c6 100644 --- a/repos/base/src/test/slab/main.cc +++ b/repos/base/src/test/slab/main.cc @@ -14,13 +14,14 @@ #include #include -#include +#include #include #include using Genode::size_t; -using Genode::printf; +using Genode::log; +using Genode::error; struct Array_of_slab_elements @@ -50,7 +51,7 @@ struct Array_of_slab_elements { elem = (void **)Genode::env()->heap()->alloc(_elem_array_size()); - printf(" allocate %zu elements\n", num_elem); + log(" allocate ", num_elem, " elements"); for (size_t i = 0; i < num_elem; i++) if (!slab.alloc(slab_size, &elem[i])) throw Alloc_failed(); @@ -58,7 +59,7 @@ struct Array_of_slab_elements ~Array_of_slab_elements() { - printf(" free %zu elements\n", num_elem); + log(" free ", num_elem, " elements"); for (size_t i = 0; i < num_elem; i++) slab.free(elem[i], slab_size); @@ -69,7 +70,7 @@ struct Array_of_slab_elements int main(int argc, char **argv) { - printf("--- slab test ---\n"); + log("--- slab test ---"); static Timer::Connection timer; @@ -80,15 +81,16 @@ int main(int argc, char **argv) Genode::Slab slab(SLAB_SIZE, BLOCK_SIZE, nullptr, &alloc); for (unsigned i = 1; i <= 10; i++) { - printf("round %u (used quota: %zu, time: %ld ms)\n", - i, alloc.consumed(), timer.elapsed_ms()); + log("round ", i, " (" + "used quota: ", alloc.consumed(), " " + "time: ", timer.elapsed_ms(), " ms)"); Array_of_slab_elements array(slab, i*100000, SLAB_SIZE); - printf(" allocation completed (used quota: %zu", alloc.consumed()); + log(" allocation completed (used quota: ", alloc.consumed(), ")"); } - printf(" finished (used quota: %zu, time: %ld ms)\n", - alloc.consumed(), timer.elapsed_ms()); + log(" finished (used quota: ", alloc.consumed(), ", " + "time: ", timer.elapsed_ms(), " ms)"); /* * The slab keeps two empty blocks around. For the test, we also need to @@ -97,15 +99,15 @@ int main(int argc, char **argv) */ enum { HEAP_OVERHEAD = 36 }; if (alloc.consumed() > 2*(BLOCK_SIZE + HEAP_OVERHEAD)) { - PERR("slab failed to release empty slab blocks"); + error("slab failed to release empty slab blocks"); return -1; } } /* validate slab destruction */ - printf("destructed slab (used quota: %zu)\n", alloc.consumed()); + log("destructed slab (used quota: ", alloc.consumed(), ")"); if (alloc.consumed() > 0) { - PERR("slab failed to release all backing store"); + error("slab failed to release all backing store"); return -2; } diff --git a/repos/base/src/test/sub_rm/main.cc b/repos/base/src/test/sub_rm/main.cc index d65d75f15..a0261b4e9 100644 --- a/repos/base/src/test/sub_rm/main.cc +++ b/repos/base/src/test/sub_rm/main.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include #include @@ -26,7 +26,7 @@ using namespace Genode; static void fail(char const *message) { - PERR("FAIL: %s", message); + error("FAIL: ", message); class Test_failed{}; throw Test_failed(); } @@ -43,7 +43,7 @@ static char const *test_pattern_2() { static void fill_ds_with_test_pattern(char const *pattern, Dataspace_capability ds, size_t offset) { - printf("fill dataspace with information\n"); + log("fill dataspace with information"); char *content = env()->rm_session()->attach(ds); strncpy(content + offset, pattern, ~0); env()->rm_session()->detach(content); @@ -59,9 +59,9 @@ static void validate_pattern_at(char const *pattern, char const *ptr) int main(int, char **) { - printf("--- sub-rm test ---\n"); + log("--- sub-rm test ---"); - printf("create RM connection\n"); + log("create RM connection"); enum { SUB_RM_SIZE = 1024*1024 }; Rm_connection rm; @@ -77,22 +77,22 @@ int main(int, char **) fill_ds_with_test_pattern(test_pattern_2(), ds, 4096); if (!support_attach_sub_any) { - printf("attach RAM ds to any position at sub rm - this should fail\n"); + log("attach RAM ds to any position at sub rm - this should fail"); try { sub_rm.attach(ds, 0, 0, false, (addr_t)0); fail("sub rm attach_any unexpectedly did not fail"); } catch (Region_map::Out_of_metadata) { - printf("attach failed as expected\n"); } + log("attach failed as expected"); } } - printf("attach RAM ds to a fixed position at sub rm\n"); + log("attach RAM ds to a fixed position at sub rm"); enum { DS_SUB_OFFSET = 4096 }; if ((addr_t)sub_rm.attach_at(ds, DS_SUB_OFFSET, 0, 0) != DS_SUB_OFFSET) fail("attach_at return-value mismatch"); - printf("attach sub rm at local address space\n"); + log("attach sub rm at local address space"); /* * We use a fixed local address here because this makes the address space @@ -106,7 +106,7 @@ int main(int, char **) char *sub_rm_base = env()->rm_session()->attach_at(sub_rm.dataspace(), LOCAL_ATTACH_ADDR); - printf("validate pattern in sub rm\n"); + log("validate pattern in sub rm"); validate_pattern_at(test_pattern(), sub_rm_base + DS_SUB_OFFSET); /* @@ -114,12 +114,12 @@ int main(int, char **) * space. Now, test further populating the already attached sub rm session. */ - printf("attach RAM ds at another fixed position at sub rm\n"); + log("attach RAM ds at another fixed position at sub rm"); enum { DS_SUB_OFFSET_2 = 0x40000 }; if ((addr_t)sub_rm.attach_at(ds, DS_SUB_OFFSET_2, 0, 0) != DS_SUB_OFFSET_2) fail("attach_at return-value mismatch"); - printf("validate pattern in second mapping in sub rm\n"); + log("validate pattern in second mapping in sub rm"); validate_pattern_at(test_pattern(), sub_rm_base + DS_SUB_OFFSET_2); /* @@ -131,30 +131,30 @@ int main(int, char **) fail("undetected boundary conflict\n"); } catch (Region_map::Region_conflict) { - printf("attaching beyond sub RM boundary failed as expected\n"); } + log("attaching beyond sub RM boundary failed as expected"); } /* * Check for working region - conflict detection */ - printf("attaching RAM ds to a conflicting region\n"); + log("attaching RAM ds to a conflicting region"); try { sub_rm.attach_at(ds, DS_SUB_OFFSET + 4096, 0, 0); fail("region conflict went undetected\n"); } catch (Region_map::Region_conflict) { - printf("attaching conflicting region failed as expected\n"); } + log("attaching conflicting region failed as expected"); } if (attach_twice_forbidden) { /* * Try to double-attach the same sub RM session. This should fail */ - printf("attach sub rm again at local address space\n"); + log("attach sub rm again at local address space"); try { env()->rm_session()->attach(sub_rm.dataspace()); fail("double attachment of sub RM session went undetected\n"); } catch (Region_map::Out_of_metadata) { - printf("doubly attaching sub RM session failed as expected\n"); } + log("doubly attaching sub RM session failed as expected"); } } /* @@ -163,7 +163,7 @@ int main(int, char **) * of the region. The region size should be automatically reduced by one * page. */ - printf("attach RAM ds with offset\n"); + log("attach RAM ds with offset"); enum { DS_SUB_OFFSET_3 = 0x80000 }; sub_rm.attach_at(ds, DS_SUB_OFFSET_3, 0, 4096); validate_pattern_at(test_pattern_2(), sub_rm_base + DS_SUB_OFFSET_3); @@ -172,7 +172,7 @@ int main(int, char **) * Add the size parameter to the mix, attaching only a window of two pages * starting with the second page. */ - printf("attach RAM ds with offset and size\n"); + log("attach RAM ds with offset and size"); enum { DS_SUB_OFFSET_4 = 0xc0000 }; sub_rm.attach_at(ds, DS_SUB_OFFSET_4, 2*4096, 4096); validate_pattern_at(test_pattern_2(), sub_rm_base + DS_SUB_OFFSET_4); @@ -183,7 +183,7 @@ int main(int, char **) */ sub_rm.detach((void *)DS_SUB_OFFSET); - printf("--- end of sub-rm test ---\n"); + log("--- end of sub-rm test ---"); /* * Do not return from main function to allow the run script to inspect the diff --git a/repos/base/src/test/thread/main.cc b/repos/base/src/test/thread/main.cc index ae359faf8..b0f61a718 100644 --- a/repos/base/src/test/thread/main.cc +++ b/repos/base/src/test/thread/main.cc @@ -13,12 +13,12 @@ */ /* Genode includes */ -#include #include #include #include #include #include +#include #include #include #include @@ -237,10 +237,9 @@ struct Pause_helper : Thread * other threads of this task trying to print log messages will * block - looks like a deadlock. */ -// printf("stop me if you can\n"); loop ++; if (beep) { - PINF("beep"); + log("beep"); beep = false; loop ++; return; @@ -318,7 +317,7 @@ static void test_create_as_many_threads(Env &env) } } } catch (const char * ex) { - PINF("created %u threads before I got '%s'", i, ex); + log("created ", i, " threads before I got '", ex, "'"); for (unsigned j = i; j > 0; j--) { destroy(heap, threads[j - 1]); threads[j - 1] = nullptr; diff --git a/repos/base/src/test/weak_ptr/main.cc b/repos/base/src/test/weak_ptr/main.cc index 4d5821e77..5f29bce74 100644 --- a/repos/base/src/test/weak_ptr/main.cc +++ b/repos/base/src/test/weak_ptr/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -53,8 +53,8 @@ static void assert_weak_ptr_cnt(Genode::Weak_object_base const *obj, obj->debug_info(); if (expected_cnt != weak_ptr_cnt) { - PERR("unexpected count, expected %d, got %d", - expected_cnt, weak_ptr_cnt); + Genode::error("unexpected count, expected ", expected_cnt, ", " + "got ", weak_ptr_cnt); throw Fatal_error(); } } @@ -67,7 +67,7 @@ static void assert_weak_ptr_valid(Genode::Weak_ptr_base const &ptr, bool valid) if (weak_ptr_valid == valid) return; - PERR("weak pointer unexpectedly %s", valid ? "valid" : "invalid"); + Genode::error("weak pointer unexpectedly ", valid ? "valid" : "invalid"); throw Fatal_error(); } @@ -95,7 +95,7 @@ static void test_weak_pointer_tracking() { using namespace Genode; - PLOG("construct invalid weak pointer"); + log("construct invalid weak pointer"); { Weak_ptr ptr; assert_weak_ptr_valid(ptr, false); @@ -111,22 +111,22 @@ static void test_weak_pointer_tracking() assert_weak_ptr_cnt(obj, 2); - PLOG("test: assign weak pointer to itself"); + log("test: assign weak pointer to itself"); ptr_2 = ptr_2; assert_weak_ptr_cnt(obj, 2); assert_weak_ptr_valid(ptr_2, true); { - PLOG("test: assign weak pointer to another"); + log("test: assign weak pointer to another"); Weak_ptr ptr_3 = ptr_2; assert_weak_ptr_cnt(obj, 3); - PLOG("test: destruct weak pointer"); + log("test: destruct weak pointer"); /* 'ptr_3' gets destructed when leaving the scope */ } assert_weak_ptr_cnt(obj, 2); - PLOG("destruct object"); + log("destruct object"); destroy(env()->heap(), obj); /* @@ -150,9 +150,9 @@ struct Destruct_thread : Genode::Thread_deprecated<4096> void entry() { using namespace Genode; - PLOG("thread: going to destroy object"); + log("thread: going to destroy object"); destroy(env()->heap(), obj); - PLOG("thread: destruction completed, job done"); + log("thread: destruction completed, job done"); } Destruct_thread(O *obj) : Thread_deprecated("object_destructor"), obj(obj) { } @@ -164,8 +164,8 @@ static void assert_constructed(bool expect_constructed) if (object_constructed == expect_constructed) return; - PERR("object unexpectedly %sconstructed", - !object_constructed ? "not" : ""); + Genode::error("object unexpectedly ", + !object_constructed ? "not " : "", "constructed"); throw Fatal_error(); } @@ -222,31 +222,31 @@ static void test_acquisition_failure() { using namespace Genode; - PLOG("create object and weak pointer"); + log("create object and weak pointer"); Object *obj = new (env()->heap()) Object; Weak_ptr ptr = obj->weak_ptr(); - PLOG("try to acquire possession over the object"); + log("try to acquire possession over the object"); { Locked_ptr locked_ptr(ptr); if (!locked_ptr.valid()) { - PERR("locked pointer unexpectedly invalid"); + error("locked pointer unexpectedly invalid"); throw Fatal_error(); } /* release lock */ } - PLOG("destroy object"); + log("destroy object"); destroy(env()->heap(), obj); - PLOG("try again, this time we should get an invalid pointer"); + log("try again, this time we should get an invalid pointer"); { Locked_ptr locked_ptr(ptr); if (locked_ptr.valid()) { - PERR("locked pointer unexpectedly valid"); + error("locked pointer unexpectedly valid"); throw Fatal_error(); } } @@ -314,20 +314,20 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- test-weak_ptr started ---\n"); + log("--- test-weak_ptr started ---"); - printf("\n-- test tracking of weak pointers --\n"); + log("\n-- test tracking of weak pointers --"); test_weak_pointer_tracking(); - printf("\n-- test deferred destruction --\n"); + log("\n-- test deferred destruction --"); test_deferred_destruction(); - printf("\n-- test acquisition failure --\n"); + log("\n-- test acquisition failure --"); test_acquisition_failure(); - printf("\n-- test acquisition during destruction --\n"); + log("\n-- test acquisition during destruction --"); test_acquisition_during_destruction(); - printf("\n--- finished test-weak_ptr ---\n"); + log("\n--- finished test-weak_ptr ---"); return 0; } diff --git a/repos/dde_bsd/src/drivers/audio/main.cc b/repos/dde_bsd/src/drivers/audio/main.cc index f1e8a1183..356f401af 100644 --- a/repos/dde_bsd/src/drivers/audio/main.cc +++ b/repos/dde_bsd/src/drivers/audio/main.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/repos/dde_bsd/src/lib/audio/bus.cc b/repos/dde_bsd/src/lib/audio/bus.cc index c445e6d63..3f3f7d72e 100644 --- a/repos/dde_bsd/src/lib/audio/bus.cc +++ b/repos/dde_bsd/src/lib/audio/bus.cc @@ -319,7 +319,7 @@ struct Io_memory : public Bus_space int Bsd::probe_drivers(Genode::Env &env, Genode::Allocator &alloc) { - PINF("--- probe drivers ---"); + Genode::log("--- probe drivers ---"); static Pci_driver drv(env, alloc); return drv.probe(); } @@ -529,8 +529,8 @@ extern "C" int bus_dmamap_load(bus_dma_tag_t tag, bus_dmamap_t dmam, void *buf, extern "C" void bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t) { - Genode::log("not implemented, called from ", - __builtin_return_address(0)); + Genode::warning("not implemented, called from ", + __builtin_return_address(0)); } @@ -590,7 +590,7 @@ extern "C" void bus_dmamem_unmap(bus_dma_tag_t, caddr_t, size_t) { } extern "C" paddr_t bus_dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *, int, off_t, int, int) { - Genode::log("not implemented, called from ", - __builtin_return_address(0)); + Genode::warning("not implemented, called from ", + __builtin_return_address(0)); return 0; } diff --git a/repos/dde_bsd/src/lib/audio/dummies.cc b/repos/dde_bsd/src/lib/audio/dummies.cc index fd3b56f7c..dd804827b 100644 --- a/repos/dde_bsd/src/lib/audio/dummies.cc +++ b/repos/dde_bsd/src/lib/audio/dummies.cc @@ -25,14 +25,14 @@ enum { #define DUMMY(retval, name) \ DUMMY name(void) { \ if (SHOW_DUMMY) \ - Genode::log( #name " called (from ", __builtin_return_address(0), ") not implemented"); \ + Genode::warning( #name " called (from ", __builtin_return_address(0), ") not implemented"); \ return retval; \ } #define DUMMY_SKIP(retval, name) \ DUMMY name(void) { \ if (SHOW_SKIP) \ - Genode::log( #name " called (from ", __builtin_return_address(0), ") skipped"); \ + Genode::warning( #name " called (from ", __builtin_return_address(0), ") skipped"); \ return retval; \ } diff --git a/repos/dde_bsd/src/test/audio_in/main.cc b/repos/dde_bsd/src/test/audio_in/main.cc index a9916a926..db87889a3 100644 --- a/repos/dde_bsd/src/test/audio_in/main.cc +++ b/repos/dde_bsd/src/test/audio_in/main.cc @@ -16,7 +16,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -88,8 +88,8 @@ class Recording unsigned pos = _stream.pos(); unsigned tail = _stream.tail(); - PWRN("record overrun, pos: %u tail: %u overriden: %u", - pos, tail, tail - pos); + Genode::warning("record overrun, pos: ", pos, " tail: ", tail, " ", + "overriden: ", tail - pos); /* * Normally you would handle this case properly by saving all @@ -123,7 +123,7 @@ class Recording int main(int argc, char *argv[]) { - PDBG("--- Audio_in test ---\n"); + Genode::log("--- Audio_in test ---"); using namespace Genode; diff --git a/repos/dde_ipxe/src/drivers/nic/main.cc b/repos/dde_ipxe/src/drivers/nic/main.cc index 0b19b1d5b..94bab9ff3 100644 --- a/repos/dde_ipxe/src/drivers/nic/main.cc +++ b/repos/dde_ipxe/src/drivers/nic/main.cc @@ -15,7 +15,7 @@ /* Genode */ #include #include -#include +#include #include #include #include @@ -60,12 +60,12 @@ class Ipxe_session_component : public Nic::Session_component Packet_descriptor packet = _tx.sink()->get_packet(); if (!packet.size()) { - PWRN("Invalid tx packet"); + Genode::warning("Invalid tx packet"); return true; } if (dde_ipxe_nic_tx(1, _tx.sink()->packet_content(packet), packet.size())) - PWRN("Sending packet failed!"); + Genode::warning("Sending packet failed!"); _tx.sink()->acknowledge_packet(packet); return true; @@ -83,7 +83,7 @@ class Ipxe_session_component : public Nic::Session_component Genode::memcpy(_rx.source()->packet_content(p), packet, packet_len); _rx.source()->submit_packet(p); } catch (...) { - PDBG("failed to process received packet"); + Genode::warning(__func__, ": failed to process received packet"); } } @@ -106,14 +106,11 @@ class Ipxe_session_component : public Nic::Session_component { instance = this; - PINF("--- init callbacks"); dde_ipxe_nic_register_callbacks(_rx_callback, _link_callback); dde_ipxe_nic_get_mac_addr(1, _mac_addr.addr); - PINF("--- get MAC address %02x:%02x:%02x:%02x:%02x:%02x", - _mac_addr.addr[0] & 0xff, _mac_addr.addr[1] & 0xff, - _mac_addr.addr[2] & 0xff, _mac_addr.addr[3] & 0xff, - _mac_addr.addr[4] & 0xff, _mac_addr.addr[5] & 0xff); + + Genode::log("MAC address ", _mac_addr); } ~Ipxe_session_component() @@ -146,11 +143,11 @@ struct Main Main(Server::Entrypoint &ep) : ep(ep) { - PINF("--- iPXE NIC driver started ---\n"); + Genode::log("--- iPXE NIC driver started ---"); - PINF("--- init iPXE NIC"); + Genode::log("-- init iPXE NIC"); int cnt = dde_ipxe_nic_init(&ep); - PINF(" number of devices: %d", cnt); + Genode::log(" number of devices: ", cnt); Genode::env()->parent()->announce(ep.manage(root)); } diff --git a/repos/dde_ipxe/src/lib/dde_ipxe/dde.c b/repos/dde_ipxe/src/lib/dde_ipxe/dde.c index 1b5149da1..e93e4c334 100644 --- a/repos/dde_ipxe/src/lib/dde_ipxe/dde.c +++ b/repos/dde_ipxe/src/lib/dde_ipxe/dde.c @@ -21,12 +21,11 @@ #include #include #include + /* local includes */ #include #include "local.h" -#define PDBG(fmt, ...) dde_printf(fmt "\n", ##__VA_ARGS__) - /*************************** ** DMA memory allocation ** diff --git a/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc b/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc index f9e4848c1..37bbbf553 100644 --- a/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc +++ b/repos/dde_ipxe/src/lib/dde_ipxe/dde_support.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -234,7 +235,7 @@ struct Pci_driver return _region.mapped_base; } catch (...) { - PERR("failed to allocate dma memory"); + Genode::error("failed to allocate dma memory"); return 0; } } @@ -322,7 +323,7 @@ static Irq_handler *_irq_handler; extern "C" int dde_interrupt_attach(void(*handler)(void *), void *priv) { if (_irq_handler) { - PERR("Irq_handler already registered"); + Genode::error("Irq_handler already registered"); Genode::sleep_forever(); } @@ -366,8 +367,10 @@ extern "C" void *dde_dma_alloc(dde_size_t size, dde_size_t align, { void *ptr; if (allocator().alloc_aligned(size, &ptr, Genode::log2(align)).error()) { - PERR("memory allocation failed in alloc_memblock (size=%zu, align=%zx," - " offset=%zx)", (Genode::size_t)size, (Genode::size_t)align, (Genode::size_t)offset); + Genode::error("memory allocation failed in alloc_memblock (" + "size=", size, " " + "align=", Genode::Hex(align), " " + "offset=", Genode::Hex(offset), ")"); return 0; } return ptr; @@ -450,7 +453,7 @@ struct Slab_backend_alloc : public Genode::Allocator, using namespace Genode; if (_index == ELEMENTS) { - PERR("Slab-backend exhausted!"); + error("slab backend exhausted!"); return false; } @@ -492,7 +495,7 @@ struct Slab_backend_alloc : public Genode::Allocator, done = _alloc_block(); if (!done) { - PERR("Backend allocator exhausted\n"); + Genode::error("backend allocator exhausted"); return false; } @@ -641,7 +644,7 @@ static Io_memory *_io_mem; extern "C" int dde_request_iomem(dde_addr_t start, dde_addr_t *vaddr) { if (_io_mem) { - PERR("Io_memory already requested"); + Genode::error("Io_memory already requested"); Genode::sleep_forever(); } diff --git a/repos/dde_linux/src/drivers/framebuffer/intel/main.cc b/repos/dde_linux/src/drivers/framebuffer/intel/main.cc index 0ffa3e497..915592aa3 100644 --- a/repos/dde_linux/src/drivers/framebuffer/intel/main.cc +++ b/repos/dde_linux/src/drivers/framebuffer/intel/main.cc @@ -15,6 +15,7 @@ /* Genode includes */ #include #include +#include #include #include diff --git a/repos/dde_linux/src/include/lx_emul/impl/completion.h b/repos/dde_linux/src/include/lx_emul/impl/completion.h index 43438c1eb..bde9b37e8 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/completion.h +++ b/repos/dde_linux/src/include/lx_emul/impl/completion.h @@ -48,7 +48,8 @@ void __wake_up(wait_queue_head_t *wq, bool all) { Wait_list *list = static_cast(wq->list); if (!list) { - PWRN("wait_queue_head_t is empty, wq: %p called from: %p", wq, __builtin_return_address(0)); + Genode::warning("wait_queue_head_t is empty, wq: ", wq, " " + "called from: ", __builtin_return_address(0)); return; } @@ -72,7 +73,7 @@ void ___wait_event(wait_queue_head_t *wq) { Wait_list *list = static_cast(wq->list); if (!list) { - PWRN("__wait_event(): empty list in wq: %p", wq); + Genode::warning("__wait_event():dd empty list in wq: ", wq); init_waitqueue_head(wq); list = static_cast(wq->list); } diff --git a/repos/dde_linux/src/include/lx_emul/impl/gfp.h b/repos/dde_linux/src/include/lx_emul/impl/gfp.h index 6897636da..22f669f60 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/gfp.h +++ b/repos/dde_linux/src/include/lx_emul/impl/gfp.h @@ -28,7 +28,7 @@ struct page *alloc_pages(gfp_t gfp_mask, unsigned int order) page->paddr = Genode::Dataspace_client(ds_cap).phys_addr(); if (!page->addr) { - PERR("alloc_pages: %zu failed", size); + Genode::error("alloc_pages: ", size, " failed"); kfree(page); return 0; } diff --git a/repos/dde_linux/src/include/lx_emul/impl/mutex.h b/repos/dde_linux/src/include/lx_emul/impl/mutex.h index 8dc971e16..3255a610d 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/mutex.h +++ b/repos/dde_linux/src/include/lx_emul/impl/mutex.h @@ -72,11 +72,11 @@ void mutex_lock(struct mutex *m) void mutex_unlock(struct mutex *m) { if (m->state == MUTEX_UNLOCKED) { - PERR("Bug: multiple mutex unlock detected"); + Genode::error("bug: multiple mutex unlock detected"); Genode::sleep_forever(); } if (m->holder != Lx::scheduler().current()) { - PERR("Bug: mutex unlock by task not holding the mutex"); + Genode::error("bug: mutex unlock by task not holding the mutex"); Genode::sleep_forever(); } diff --git a/repos/dde_linux/src/include/lx_emul/impl/slab.h b/repos/dde_linux/src/include/lx_emul/impl/slab.h index b0ee870e3..9fbc92703 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/slab.h +++ b/repos/dde_linux/src/include/lx_emul/impl/slab.h @@ -18,9 +18,11 @@ void *kmalloc(size_t size, gfp_t flags) { if (flags & __GFP_DMA) - PWRN("GFP_DMA memory (below 16 MiB) requested (%p)", __builtin_return_address(0)); + Genode::warning("GFP_DMA memory (below 16 MiB) requested " + "(", __builtin_return_address(0), ")"); if (flags & __GFP_DMA32) - PWRN("GFP_DMA32 memory (below 4 GiB) requested (%p)", __builtin_return_address(0)); + Genode::warning("GFP_DMA32 memory (below 4 GiB) requested" + "(", __builtin_return_address(0), ")"); void *addr = nullptr; @@ -29,7 +31,7 @@ void *kmalloc(size_t size, gfp_t flags) : Lx::Malloc::mem().alloc(size); if ((Genode::addr_t)addr & 0x3) - PERR("unaligned kmalloc %lx", (Genode::addr_t)addr); + Genode::error("unaligned kmalloc ", (Genode::addr_t)addr); if (flags & __GFP_ZERO) Genode::memset(addr, 0, size); @@ -68,8 +70,8 @@ void kfree(void const *p) else if (Lx::Malloc::dma().inside((Genode::addr_t)p)) Lx::Malloc::dma().free(p); else - PERR("%s: unknown block at %p, called from %p", __func__, - p, __builtin_return_address(0)); + Genode::error(__func__, ": unknown block at ", p, ", " + "called from ", __builtin_return_address(0)); } @@ -82,7 +84,7 @@ static size_t _ksize(void *p) else if (Lx::Malloc::dma().inside((Genode::addr_t)p)) size = Lx::Malloc::dma().size(p); else - PERR("%s: unknown block at %p", __func__, p); + Genode::error(__func__, ": unknown block at ", p); return size; } diff --git a/repos/dde_linux/src/include/lx_emul/impl/wait.h b/repos/dde_linux/src/include/lx_emul/impl/wait.h index c02279036..c984c35db 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/wait.h +++ b/repos/dde_linux/src/include/lx_emul/impl/wait.h @@ -18,8 +18,8 @@ void prepare_to_wait(wait_queue_head_t *q, wait_queue_t *w, int state) { if (!q) { - PWRN("prepare_to_wait: wait_queue_head_t is 0, ignore, called from: %p", - __builtin_return_address(0)); + Genode::warning("prepare_to_wait: wait_queue_head_t is 0, ignore, " + "called from: ", __builtin_return_address(0)); return; } @@ -39,8 +39,8 @@ void prepare_to_wait_exclusive(wait_queue_head_t *q, wait_queue_t *w, int state) void finish_wait(wait_queue_head_t *q, wait_queue_t *w) { if (!q) { - PWRN("finish_wait: wait_queue_head_t is 0, ignore, called from: %p", - __builtin_return_address(0)); + Genode::warning("finish_wait: wait_queue_head_t is 0, ignore, ", + "called from: ", __builtin_return_address(0)); return; } diff --git a/repos/dde_linux/src/include/lx_emul/impl/work.h b/repos/dde_linux/src/include/lx_emul/impl/work.h index 6308d84e6..daab2204f 100644 --- a/repos/dde_linux/src/include/lx_emul/impl/work.h +++ b/repos/dde_linux/src/include/lx_emul/impl/work.h @@ -101,8 +101,8 @@ bool cancel_delayed_work_sync(struct delayed_work *dwork) bool pending = cancel_delayed_work(dwork); if (pending) { - PERR("WARN: delayed_work %p is executed directly in current '%s' routine", - dwork, Lx::scheduler().current()->name()); + Genode::error("WARN: delayed_work ", dwork, " is executed directly in " + "current '", Lx::scheduler().current()->name(), "' routine"); dwork->work.func(&dwork->work); } diff --git a/repos/dde_linux/src/include/lx_kit/internal/debug.h b/repos/dde_linux/src/include/lx_kit/internal/debug.h deleted file mode 100644 index a034a857e..000000000 --- a/repos/dde_linux/src/include/lx_kit/internal/debug.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * \brief Debug utilities - * \author Sebastian Sumpf - * \author Josef Soentgen - * \author Norman Feske - * \date 2014-10-10 - */ - -/* - * Copyright (C) 2014-2016 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _LX_KIT__INTERNAL__DEBUG_H_ -#define _LX_KIT__INTERNAL__DEBUG_H_ - -#ifndef PDBGV -#define PDBGV(...) do { if (verbose) PDBG(__VA_ARGS__); } while (0) -#endif - -#endif /* _LX_KIT__INTERNAL__DEBUG_H_ */ diff --git a/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h b/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h index 8549e55b6..e733dd33a 100644 --- a/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h +++ b/repos/dde_linux/src/include/lx_kit/internal/pci_dev.h @@ -25,7 +25,6 @@ #include /* Linux emulation environment includes */ -#include #include #include @@ -136,22 +135,12 @@ class Lx::Pci_dev : public pci_dev, public Lx_kit::List::Element if (res.type() == Device::Resource::MEMORY) flags |= IORESOURCE_MEM; this->resource[i].flags = flags; - PDBGV("this=%p base: %x size: %x type: %u", - this, res.base(), res.size(), res.type()); - /* request port I/O session */ if (res.type() == Device::Resource::IO) { uint8_t const virt_bar = _client.phys_bar_to_virt(i); _io_port.session(res.base(), res.size(), _client.io_port(virt_bar)); io = true; - PDBGV("I/O [%u-%u)", - res.base(), res.base() + res.size()); } - - /* request I/O memory (write combined) */ - if (res.type() == Device::Resource::MEMORY) - PDBGV("I/O memory [%x-%x)", res.base(), - res.base() + res.size()); } /* enable bus master and io bits */ diff --git a/repos/dde_linux/src/include/lx_kit/internal/task.h b/repos/dde_linux/src/include/lx_kit/internal/task.h index d4811b044..3a195e668 100644 --- a/repos/dde_linux/src/include/lx_kit/internal/task.h +++ b/repos/dde_linux/src/include/lx_kit/internal/task.h @@ -17,7 +17,7 @@ #define _LX_KIT__INTERNAL__TASK_H_ /* Genode includes */ -#include +#include #include #include @@ -89,7 +89,7 @@ class Lx::Task : public Lx_kit::List::Element case STATE_WAIT_BLOCKED: return false; } - PERR("state %d not handled by switch", _state); + Genode::error("state ", (int)_state, " not handled by switch"); Genode::sleep_forever(); } @@ -125,7 +125,7 @@ class Lx::Task : public Lx_kit::List::Element if (_wait_le_enqueued && _wait_list == list) return; if (_wait_le_enqueued) { - PERR("%p already queued in %p", this, _wait_list); + Genode::error(this, " already queued in ", _wait_list); Genode::sleep_forever(); } @@ -137,12 +137,12 @@ class Lx::Task : public Lx_kit::List::Element void wait_dequeue(List *list) { if (!_wait_le_enqueued) { - PERR("%p not queued", this); + Genode::error(this, " not queued"); Genode::sleep_forever(); } if (_wait_list != list) { - PERR("especially not in list %p", list); + Genode::error("especially not in list ", list); Genode::sleep_forever(); } @@ -218,7 +218,7 @@ class Lx::Task : public Lx_kit::List::Element } /* never reached */ - PERR("Unexpected return of Task"); + Genode::error("unexpected return of task"); Genode::sleep_forever(); } diff --git a/repos/dde_linux/src/include/lx_kit/pci_dev_registry.h b/repos/dde_linux/src/include/lx_kit/pci_dev_registry.h index 3cc0f5da3..66fe97e24 100644 --- a/repos/dde_linux/src/include/lx_kit/pci_dev_registry.h +++ b/repos/dde_linux/src/include/lx_kit/pci_dev_registry.h @@ -40,7 +40,6 @@ class Lx::Pci_dev_registry void insert(Pci_dev *pci_dev) { - PDBG("insert pci_dev %p", pci_dev); _devs.insert(pci_dev); } @@ -74,7 +73,8 @@ class Lx::Pci_dev_registry return Genode::Io_mem_session_client(io_mem_cap).dataspace(); } - PERR("Device using i/o memory of address %lx is unknown", phys); + Genode::error("device using I/O memory of address ", + Genode::Hex(phys), " is unknown"); return Genode::Io_mem_dataspace_capability(); } @@ -88,7 +88,7 @@ class Lx::Pci_dev_registry return value; } - PWRN("I/O port(%u) read failed", port); + Genode::warning("I/O port(", port, ") read failed"); return (T)~0; } @@ -100,7 +100,7 @@ class Lx::Pci_dev_registry if (d->io_port().out(port, value)) return; - PWRN("I/O port(%u) write failed", port); + Genode::warning("I/O port(", port, ") write failed"); } }; diff --git a/repos/dde_linux/src/lib/libc_lxip/init.cc b/repos/dde_linux/src/lib/libc_lxip/init.cc index 46762e0d6..b5da42b3a 100644 --- a/repos/dde_linux/src/lib/libc_lxip/init.cc +++ b/repos/dde_linux/src/lib/libc_lxip/init.cc @@ -13,7 +13,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -48,31 +48,33 @@ void __attribute__((constructor)) init_libc_lxip(void) (Genode::strlen(netmask_str) != 0) || (Genode::strlen(gateway_str) != 0)) { if (Genode::strlen(ip_addr_str) == 0) { - PERR("Missing \"ip_addr\" attribute. Ignoring network interface config."); + Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } else if (Genode::strlen(netmask_str) == 0) { - PERR("Missing \"netmask\" attribute. Ignoring network interface config."); + Genode::error("missing \"netmask\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } else if (Genode::strlen(gateway_str) == 0) { - PERR("Missing \"gateway\" attribute. Ignoring network interface config."); + Genode::error("missing \"gateway\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } } else throw -1; - PDBG("static network interface: ip_addr=%s netmask=%s gateway=%s ", - ip_addr_str, netmask_str, gateway_str); + Genode::log("static network interface: ", + "ip_addr=", Genode::Cstring(ip_addr_str), " " + "netmask=", Genode::Cstring(netmask_str), " " + "gateway=", Genode::Cstring(gateway_str)); Genode::snprintf(address_buf, sizeof(address_buf), "%s::%s:%s:::off", ip_addr_str, gateway_str, netmask_str); address_config = address_buf; } catch (...) { - PINF("Using DHCP for interface configuration."); + Genode::log("Using DHCP for interface configuration."); address_config = "dhcp"; } - PDBG("init_libc_lxip() address config=%s\n", address_config); + Genode::log("init_libc_lxip() address config=", address_config); create_lxip_plugin(address_config); } diff --git a/repos/dde_linux/src/lib/libc_lxip/plugin.cc b/repos/dde_linux/src/lib/libc_lxip/plugin.cc index af6fdf0eb..fa5e8ec83 100644 --- a/repos/dde_linux/src/lib/libc_lxip/plugin.cc +++ b/repos/dde_linux/src/lib/libc_lxip/plugin.cc @@ -20,7 +20,7 @@ /* Genode includes */ #include -#include +#include /* Libc plugin includes */ #include @@ -140,7 +140,7 @@ struct Plugin : Libc::Plugin Plugin::Plugin(char const *address_config) : socketcall(Lxip::init(address_config)) { - PDBG("using the lxip libc plugin"); + Genode::log("using the lxip libc plugin"); } @@ -260,7 +260,7 @@ int Plugin::fcntl(Libc::File_descriptor *sockfdo, int cmd, long val) default: - PERR("unsupported fcntl() request: %d", cmd); + Genode::error("unsupported fcntl() request: ", cmd); errno = ENOSYS; return -1; } @@ -308,8 +308,7 @@ int Plugin::getsockopt(Libc::File_descriptor *sockfdo, int level, int optname, void *optval, socklen_t *optlen) { if (level != SOL_SOCKET) { - PERR("%s: Unsupported level %d, we only support SOL_SOCKET for now", - __func__, level); + Genode::error(__func__, ": Unsupported level ", level, ", we only support SOL_SOCKET for now"); errno = EBADF; return -1; } @@ -342,7 +341,7 @@ int Plugin::ioctl(Libc::File_descriptor *sockfdo, int request, char *argp) default: - PERR("unsupported ioctl() request"); + Genode::error("unsupported ioctl() request"); errno = ENOSYS; return -1; } @@ -497,8 +496,7 @@ int Plugin::setsockopt(Libc::File_descriptor *sockfdo, int level, socklen_t optlen) { if (level != SOL_SOCKET) { - PERR("%s: Unsupported level %d, we only support SOL_SOCKET for now", - __func__, level); + Genode::error(__func__, ": Unsupported level ", level, ", we only support SOL_SOCKET for now"); errno = EBADF; return -1; } @@ -546,7 +544,7 @@ int Plugin::linux_family(const struct sockaddr *addr, socklen_t addrlen) default: - PERR("Unsupported socket BSD-protocol %u\n", addr->sa_family); + Genode::error("unsupported socket BSD protocol ", addr->sa_family); return 0; } @@ -569,7 +567,7 @@ int Plugin::bsd_family(struct sockaddr *addr) default: - PERR("Unsupported socket Linux-protocol %u\n", addr->sa_family); + Genode::error("unsupported socket Linux protocol ", addr->sa_family); return 0; } } @@ -580,19 +578,19 @@ int Plugin::translate_msg_flags(int bsd_flags) using namespace Lxip; int f = 0; - if (bsd_flags & MSG_OOB) f |= LINUX_MSG_OOB; - if (bsd_flags & MSG_PEEK) f |= LINUX_MSG_PEEK; - if (bsd_flags & MSG_DONTROUTE) f |= LINUX_MSG_DONTROUTE; - if (bsd_flags & MSG_EOR) f |= LINUX_MSG_EOR; - if (bsd_flags & MSG_TRUNC) f |= LINUX_MSG_TRUNC; - if (bsd_flags & MSG_CTRUNC) f |= LINUX_MSG_CTRUNC; - if (bsd_flags & MSG_WAITALL) f |= LINUX_MSG_WAITALL; - if (bsd_flags & MSG_NOTIFICATION) PWRN("MSG_NOTIFICATION ignored"); - if (bsd_flags & MSG_DONTWAIT) f |= LINUX_MSG_DONTWAIT; - if (bsd_flags & MSG_EOF) f |= LINUX_MSG_EOF; - if (bsd_flags & MSG_NBIO) PWRN("MSG_NBIO ignored"); - if (bsd_flags & MSG_NOSIGNAL) f |= LINUX_MSG_NOSIGNAL; - if (bsd_flags & MSG_COMPAT) f |= LINUX_MSG_COMPAT; + if (bsd_flags & MSG_OOB) f |= LINUX_MSG_OOB; + if (bsd_flags & MSG_PEEK) f |= LINUX_MSG_PEEK; + if (bsd_flags & MSG_DONTROUTE) f |= LINUX_MSG_DONTROUTE; + if (bsd_flags & MSG_EOR) f |= LINUX_MSG_EOR; + if (bsd_flags & MSG_TRUNC) f |= LINUX_MSG_TRUNC; + if (bsd_flags & MSG_CTRUNC) f |= LINUX_MSG_CTRUNC; + if (bsd_flags & MSG_WAITALL) f |= LINUX_MSG_WAITALL; + if (bsd_flags & MSG_NOTIFICATION) Genode::warning("MSG_NOTIFICATION ignored"); + if (bsd_flags & MSG_DONTWAIT) f |= LINUX_MSG_DONTWAIT; + if (bsd_flags & MSG_EOF) f |= LINUX_MSG_EOF; + if (bsd_flags & MSG_NBIO) Genode::warning("MSG_NBIO ignored"); + if (bsd_flags & MSG_NOSIGNAL) f |= LINUX_MSG_NOSIGNAL; + if (bsd_flags & MSG_COMPAT) f |= LINUX_MSG_COMPAT; return f; } @@ -642,7 +640,7 @@ int Plugin::translate_ops_linux(int optname) if (sockopts[i] == optname) return i; - PERR("Unsupported sockopt %d\n", optname); + Genode::error("unsupported sockopt ", optname); return -1; } diff --git a/repos/dde_linux/src/lib/libnl/lxcc_emul.cc b/repos/dde_linux/src/lib/libnl/lxcc_emul.cc index 67f6e018d..22a4d4fbe 100644 --- a/repos/dde_linux/src/lib/libnl/lxcc_emul.cc +++ b/repos/dde_linux/src/lib/libnl/lxcc_emul.cc @@ -12,7 +12,7 @@ */ /* Genode */ -#include +#include #include @@ -37,7 +37,7 @@ extern "C" char *getenv(const char *name) #if 0 #include -#include +#include #include #include #include @@ -143,7 +143,7 @@ long int strtol(const char *nptr, char **endptr, int base) { long res = 0; if (base != 0 && base != 10) { - PERR("strtol: base of %d is not supported", base); + Genode::error("strtol: base of ", base, " is not supported"); return 0; } Genode::ascii_to(nptr, res); diff --git a/repos/dde_linux/src/lib/libnl/socket.cc b/repos/dde_linux/src/lib/libnl/socket.cc index 21144b83e..1ee306ee9 100644 --- a/repos/dde_linux/src/lib/libnl/socket.cc +++ b/repos/dde_linux/src/lib/libnl/socket.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -52,7 +52,7 @@ extern "C" { static const bool trace = true; #define TRACE() \ do { if (trace) \ - PDBG("called from: %p", __builtin_return_address(0)); \ + Genode::log("called from: ", __builtin_return_address(0)); \ } while (0) @@ -168,7 +168,7 @@ ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags, { Socket *s = Socket_registry::find(sockfd); if (!s) { - PERR("sockfd %d not in registry", sockfd); + Genode::error("sockfd ", sockfd, " not in registry"); errno = EBADF; return -1; } @@ -203,8 +203,8 @@ ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags) } if (msg->msg_iovlen > Wifi::Msghdr::MAX_IOV_LEN) { - PERR("%s: %d exceeds maximum iov length (%d)", - __func__, msg->msg_iovlen, Wifi::Msghdr::MAX_IOV_LEN); + Genode::error(__func__, ": ", msg->msg_iovlen, " exceeds maximum iov " + "length (", (int)Wifi::Msghdr::MAX_IOV_LEN, ")"); errno = EINVAL; return -1; } @@ -257,18 +257,18 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) } if (msg->msg_iovlen > Wifi::Msghdr::MAX_IOV_LEN) { - PERR("%s: %d exceeds maximum iov length (%d)", - __func__, msg->msg_iovlen, Wifi::Msghdr::MAX_IOV_LEN); + Genode::error(__func__, ": ", msg->msg_iovlen, " exceeds maximum iov " + "length (", (int)Wifi::Msghdr::MAX_IOV_LEN, ")"); errno = EINVAL; return -1; } if (msg->msg_controllen != 0) { - PERR("%s: msg_control not supported", __func__); + Genode::error(__func__, ": msg_control not supported"); errno = EINVAL; return -1; } if (flags != 0) { - PERR("%s: flags not supported", __func__); + Genode::error(__func__, ": flags not supported"); errno = EOPNOTSUPP; return -1; } @@ -437,7 +437,7 @@ int fcntl(int fd, int cmd, ... /* arg */ ) return 0; } default: - PWRN("fcntl: unknown request: %d", cmd); + Genode::warning("fcntl: unknown request: ", cmd); break; } diff --git a/repos/dde_linux/src/lib/lxip/dummies.cc b/repos/dde_linux/src/lib/lxip/dummies.cc index ba14fe237..8ee95a69a 100644 --- a/repos/dde_linux/src/lib/lxip/dummies.cc +++ b/repos/dde_linux/src/lib/lxip/dummies.cc @@ -1,4 +1,4 @@ -/** +/* * \brief Dummy functions * \author Sebastian Sumpf * \date 2013-08-26 @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include @@ -28,40 +28,50 @@ enum { #define DUMMY(retval, name) \ DUMMY name(void) { \ - if (SHOW_DUMMY) \ - PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \ - return retval; \ -} + if (SHOW_DUMMY) \ + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "not implemented"); \ + return retval; \ + } #define DUMMY_SKIP(retval, name) \ DUMMY name(void) { \ if (SHOW_SKIP) \ - PLOG( #name " called (from %p) skipped", __builtin_return_address(0)); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "skipped"); \ + return retval; \ + } #define DUMMY_RET(retval, name) \ DUMMY name(void) { \ if (SHOW_RET) \ - PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "return ", retval); \ + return retval; \ + } #define DUMMY_SHOW(retval, name) \ DUMMY name(void) { \ if (SHOW_SHOW) \ - PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "return ", retval); \ + return retval; \ + } #define DUMMY_STOP(retval, name) \ DUMMY name(void) { \ do { \ - PWRN( #name " called (from %p) stopped", __builtin_return_address(0)); \ + Genode::warning(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "stopped"); \ Genode::sleep_forever(); \ } while (0); \ return retval; \ -} + } /* diff --git a/repos/dde_linux/src/lib/lxip/lxcc_emul.cc b/repos/dde_linux/src/lib/lxip/lxcc_emul.cc index e440da8f2..90fe02053 100644 --- a/repos/dde_linux/src/lib/lxip/lxcc_emul.cc +++ b/repos/dde_linux/src/lib/lxip/lxcc_emul.cc @@ -571,7 +571,7 @@ size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct io __wsum next = csum_and_copy_from_user(iov->iov_base, kdata, copy_len, 0, &err); if (err) { - PERR("%s: err: %d - sleeping", __func__, err); + Genode::error(__func__, ": err: ", err, " - sleeping"); Genode::sleep_forever(); } @@ -611,7 +611,7 @@ size_t csum_and_copy_to_iter(void *addr, size_t bytes, __wsum *csum, struct iov_ __wsum next = csum_and_copy_to_user(kdata, iov->iov_base, copy_len, 0, &err); if (err) { - PERR("%s: err: %d - sleeping", __func__, err); + Genode::error(__func__, ": err: ", err, " - sleeping"); Genode::sleep_forever(); } diff --git a/repos/dde_linux/src/lib/lxip/nic_handler.cc b/repos/dde_linux/src/lib/lxip/nic_handler.cc index eb503c1c8..6f5445cba 100644 --- a/repos/dde_linux/src/lib/lxip/nic_handler.cc +++ b/repos/dde_linux/src/lib/lxip/nic_handler.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -140,7 +140,7 @@ void net_mac(void* mac, unsigned long size) } str[MAC_LEN] = 0; - PINF("Received mac: %s", str); + Genode::log("Received mac: ", Cstring(str)); } diff --git a/repos/dde_linux/src/lib/lxip/socket_handler.cc b/repos/dde_linux/src/lib/lxip/socket_handler.cc index fcc0a6c67..56b50eade 100644 --- a/repos/dde_linux/src/lib/lxip/socket_handler.cc +++ b/repos/dde_linux/src/lib/lxip/socket_handler.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include #include /* local includes */ @@ -415,9 +415,6 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base, void dispatch(unsigned num) { - if (verbose) - PDBG("SOCKET dispatch %u", _call.opcode); - switch (_call.opcode) { case OP_ACCEPT : _do_accept(); break; @@ -438,7 +435,7 @@ class Net::Socketcall : public Genode::Signal_dispatcher_base, default: _handle.socket = 0; - PWRN("Unkown opcode: %u\n", _call.opcode); + Genode::warning("unkown opcode: ", (int)_call.opcode); } _unblock(); diff --git a/repos/dde_linux/src/lib/lxip/timer_handler.cc b/repos/dde_linux/src/lib/lxip/timer_handler.cc index e6a60a236..f3bc79eb9 100644 --- a/repos/dde_linux/src/lib/lxip/timer_handler.cc +++ b/repos/dde_linux/src/lib/lxip/timer_handler.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -233,7 +233,7 @@ class Lx::Timer { Context *ctx = _find_context(timer); if (!ctx) { - PERR("schedule unknown timer %p", timer); + Genode::error("schedule unknown timer ", timer); return -1; /* XXX better use 0 as rv? */ } diff --git a/repos/dde_linux/src/lib/usb/test.cc b/repos/dde_linux/src/lib/usb/test.cc index 650f6ba53..d78128adb 100644 --- a/repos/dde_linux/src/lib/usb/test.cc +++ b/repos/dde_linux/src/lib/usb/test.cc @@ -16,7 +16,7 @@ void tx_test() { char *data = (char *)skb->data; if (data[0x2a] == (char)0xaa && data[0x2b] == (char)0xbb) { - PDBG("Got server signal"); + Genode::log("Got server signal"); static char data[1066]; static char header[] = { 0x00, 0x1c, 0x25, 0x9e, 0x92, 0x4a, 0x2e, 0x60, 0x90, 0x0c, 0x4e, 0x01, 0x08, 0x00, 0x45, 0x00, diff --git a/repos/dde_linux/src/lib/wifi/dummies.cc b/repos/dde_linux/src/lib/wifi/dummies.cc index 39e598c2c..6184139b7 100644 --- a/repos/dde_linux/src/lib/wifi/dummies.cc +++ b/repos/dde_linux/src/lib/wifi/dummies.cc @@ -13,7 +13,6 @@ /* Genode includes */ #include -#include #include extern "C" { @@ -27,34 +26,41 @@ enum { #define DUMMY(retval, name) \ DUMMY name(void) { \ - if (SHOW_DUMMY) \ - PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \ - return retval; \ -} + if (SHOW_DUMMY) \ + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "not implemented"); \ + return retval; \ + } #define DUMMY_SKIP(retval, name) \ DUMMY name(void) { \ if (SHOW_SKIP) \ - Genode::log( #name " called (from ", __builtin_return_address(0), ") skipped"); \ - return retval; \ -} - -#define DUMMY_STOP(retval, name) \ - DUMMY name(void) { \ - do { \ - Genode::warning( #name " called (from ", __builtin_return_address(0), ") stopped"); \ - Genode::sleep_forever(); \ - } while (0); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "skipped"); \ + return retval; \ + } #define DUMMY_RET(retval, name) \ DUMMY name(void) { \ if (SHOW_RET) \ - Genode::warning( #name " called (from ", __builtin_return_address(0), ") return ", \ - retval); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "return ", retval); \ + return retval; \ + } + +#define DUMMY_STOP(retval, name) \ + DUMMY name(void) { \ + do { \ + Genode::warning(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "stopped"); \ + Genode::sleep_forever(); \ + } while (0); \ + return retval; \ + } /* return sucessful */ DUMMY_RET(0, netdev_kobject_init) diff --git a/repos/dde_linux/src/lib/wifi/lxcc_emul.cc b/repos/dde_linux/src/lib/wifi/lxcc_emul.cc index 08d1bf8d7..1d3766e76 100644 --- a/repos/dde_linux/src/lib/wifi/lxcc_emul.cc +++ b/repos/dde_linux/src/lib/wifi/lxcc_emul.cc @@ -296,9 +296,6 @@ size_t copy_from_iter(void *addr, size_t bytes, struct iov_iter *i) iov++; } - // PDBG("addr: %p bytes: %zu iov_base: %p iov_len: %zu len: %zu", - // addr, bytes, i->iov->iov_base, i->iov->iov_len, len); - return bytes; } @@ -326,9 +323,6 @@ size_t copy_to_iter(void *addr, size_t bytes, struct iov_iter *i) iov++; } - // PDBG("addr: %p bytes: %zu iov_base: %p iov_len: %zu len: %zu", - // addr, bytes, i->iov->iov_base, i->iov->iov_len, len); - return bytes; } diff --git a/repos/dde_linux/src/lib/wifi/nic.cc b/repos/dde_linux/src/lib/wifi/nic.cc index ed0e6b43f..73a4487d8 100644 --- a/repos/dde_linux/src/lib/wifi/nic.cc +++ b/repos/dde_linux/src/lib/wifi/nic.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/repos/dde_linux/src/lib/wpa_driver_nl80211/dummies.cc b/repos/dde_linux/src/lib/wpa_driver_nl80211/dummies.cc index 7d92d93ab..2103536da 100644 --- a/repos/dde_linux/src/lib/wpa_driver_nl80211/dummies.cc +++ b/repos/dde_linux/src/lib/wpa_driver_nl80211/dummies.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include extern "C" { typedef long DUMMY; @@ -24,24 +24,30 @@ enum { #define DUMMY(retval, name) \ DUMMY name(void) { \ - if (SHOW_DUMMY) \ - PDBG( #name " called (from %p) not implemented", __builtin_return_address(0)); \ - return retval; \ -} + if (SHOW_DUMMY) \ + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "not implemented"); \ + return retval; \ + } #define DUMMY_SKIP(retval, name) \ DUMMY name(void) { \ if (SHOW_SKIP) \ - PLOG( #name " called (from %p) skipped", __builtin_return_address(0)); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "skipped"); \ + return retval; \ + } #define DUMMY_RET(retval, name) \ DUMMY name(void) { \ if (SHOW_RET) \ - PWRN( #name " called (from %p) return %d", __builtin_return_address(0), retval); \ - return retval; \ -} + Genode::log(__func__, ": " #name " called " \ + "(from ", __builtin_return_address(0), ") " \ + "return ", retval); \ + return retval; \ + } DUMMY(0, getprotobyname) DUMMY(0, getprotobynumber) diff --git a/repos/dde_linux/src/lib/wpa_driver_nl80211/ioctl.cc b/repos/dde_linux/src/lib/wpa_driver_nl80211/ioctl.cc index 98f4d2b0a..35a61f16c 100644 --- a/repos/dde_linux/src/lib/wpa_driver_nl80211/ioctl.cc +++ b/repos/dde_linux/src/lib/wpa_driver_nl80211/ioctl.cc @@ -11,8 +11,11 @@ * under the terms of the GNU General Public License version 2. */ +/* compiler includes */ +#include + /* Genode includes */ -#include +#include /* libc includes */ #include @@ -40,7 +43,7 @@ int ioctl(int fd, unsigned long request, ...) switch (request) { case SIOCGIFADDR: - PERR("ioctl: request SIOCGIFADDR not implemented."); + Genode::error("ioctl: request SIOCGIFADDR not implemented."); return -1; case SIOCGIFINDEX: ifr->ifr_ifindex = 1; @@ -50,7 +53,7 @@ int ioctl(int fd, unsigned long request, ...) return 0; } - PWRN("ioctl: request %lu not handled by switch", request); + Genode::warning("ioctl: request ", request, " not handled by switch"); return -1; } diff --git a/repos/dde_linux/src/lib/wpa_supplicant/reporter.cc b/repos/dde_linux/src/lib/wpa_supplicant/reporter.cc index 6ce52e952..8d7262f43 100644 --- a/repos/dde_linux/src/lib/wpa_supplicant/reporter.cc +++ b/repos/dde_linux/src/lib/wpa_supplicant/reporter.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -52,7 +52,8 @@ extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s) struct wpa_ssid *wpa_ssid = wpa_s->current_ssid; /* FIXME ssid may contain any characters, even NUL */ - Genode::String ssid((char const*)wpa_ssid->ssid, wpa_ssid->ssid_len); + Genode::String + ssid(Genode::Cstring((char *)wpa_ssid->ssid, wpa_ssid->ssid_len)); char bssid_buf[MAC_STR_LEN]; mac2str(bssid_buf, wpa_s->bssid); @@ -63,7 +64,7 @@ extern "C" void wpa_report_connect_event(struct wpa_supplicant *wpa_s) xml.attribute("state", "connected"); }); }); - } catch (...) { PWRN("could not report connected state"); } + } catch (...) { Genode::warning("could not report connected state"); } } @@ -76,7 +77,8 @@ extern "C" void wpa_report_disconnect_event(struct wpa_supplicant *wpa_s) struct wpa_ssid *wpa_ssid = wpa_s->current_ssid; /* FIXME ssid may contain any characters, even NUL */ - Genode::String ssid((char const*)wpa_ssid->ssid, wpa_ssid->ssid_len); + Genode::String + ssid(Genode::Cstring((char *)wpa_ssid->ssid, wpa_ssid->ssid_len)); char bssid_buf[MAC_STR_LEN]; mac2str(bssid_buf, wpa_ssid->bssid); @@ -88,7 +90,7 @@ extern "C" void wpa_report_disconnect_event(struct wpa_supplicant *wpa_s) }); }); - } catch (...) { PWRN("could not report disconnected state"); } + } catch (...) { Genode::warning("could not report disconnected state"); } } @@ -124,7 +126,8 @@ extern "C" void wpa_report_scan_results(struct wpa_supplicant *wpa_s) char bssid_buf[MAC_STR_LEN]; mac2str(bssid_buf, bss->bssid); - Genode::String ssid((char const*)bss->ssid, bss->ssid_len); + Genode::String + ssid(Genode::Cstring((char *)bss->ssid, bss->ssid_len)); int quality = approximate_quality(bss); @@ -139,5 +142,5 @@ extern "C" void wpa_report_scan_results(struct wpa_supplicant *wpa_s) }); } }); - } catch (...) { PWRN("could not report scan results"); } + } catch (...) { Genode::warning("could not report scan results"); } } diff --git a/repos/dde_linux/src/lx_kit/malloc.cc b/repos/dde_linux/src/lx_kit/malloc.cc index 9dab438e8..c985f79bb 100644 --- a/repos/dde_linux/src/lx_kit/malloc.cc +++ b/repos/dde_linux/src/lx_kit/malloc.cc @@ -57,7 +57,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc, bool _alloc_block() { if (_index == ELEMENTS) { - PERR("Slab-backend exhausted!"); + Genode::error("slab backend exhausted!"); return false; } @@ -114,7 +114,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc, done = _alloc_block(); if (!done) { - PERR("Backend allocator exhausted\n"); + Genode::error("backend allocator exhausted"); return false; } @@ -154,7 +154,7 @@ class Lx_kit::Slab_backend_alloc : public Lx::Slab_backend_alloc, return _base + i * V_BLOCK_SIZE + phys - _ds_phys[i]; } - PWRN("virt_addr(0x%lx) - no translation", phys); + Genode::warning("virt_addr(", Genode::Hex(phys), ") - no translation"); return 0; } @@ -273,13 +273,14 @@ class Lx_kit::Malloc : public Lx::Malloc msb = SLAB_STOP_LOG2; if (msb > SLAB_STOP_LOG2) { - PERR("Slab too large %u reqested %zu cached %d", 1U << msb, size, _cached); + Genode::error("slab too large ", + 1UL << msb, "reqested ", size, " cached ", (int)_cached); return 0; } addr_t addr = _allocator[msb - SLAB_START_LOG2]->alloc(); if (!addr) { - PERR("Failed to get slab for %u", 1 << msb); + Genode::error("failed to get slab for ", 1 << msb); return 0; } @@ -320,7 +321,7 @@ class Lx_kit::Malloc : public Lx::Malloc { void *addr; if (!_back_allocator.alloc(size, &addr)) { - PERR("Large back end allocation failed (%zu bytes)", size); + Genode::error("large back end allocation failed (", size, " bytes)"); return nullptr; } diff --git a/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc b/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc index 480083219..44e5bbd4f 100644 --- a/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc +++ b/repos/dde_linux/src/lx_kit/mapped_io_mem_range.cc @@ -96,8 +96,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size, if (r->phys_range(phys_addr, size)) { void * const virt = (void *)(r->virt() + phys_addr - r->phys()); - PLOG("ioremap: return sub range phys 0x%lx (size %lx) to virt 0x%lx", - (long)phys_addr, (long)size, (long)virt); + log("ioremap: return sub range phys ", Hex(phys_addr), " " + "(size ", size, ") to virt ", virt); return virt; } } @@ -108,8 +108,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size, size, offset); if (!ds_cap.valid()) { - PERR("Failed to request I/O memory: [%lx,%lx)", phys_addr, - phys_addr + size); + error("failed to request I/O memory: ", + Hex_range(phys_addr, size)); return nullptr; } @@ -119,8 +119,8 @@ void *Lx::ioremap(addr_t phys_addr, unsigned long size, ranges.insert(io_mem); - PLOG("ioremap: mapped phys 0x%lx (size %lx) to virt 0x%lx", - (long)phys_addr, (long)size, (long)io_mem->virt()); + log("ioremap: mapped phys ", Hex(phys_addr), " (size ", size, ") " + "to virt ", Hex(io_mem->virt())); return (void *)io_mem->virt(); } diff --git a/repos/dde_linux/src/lx_kit/printf.cc b/repos/dde_linux/src/lx_kit/printf.cc index 531b6efc8..383b1c2d7 100644 --- a/repos/dde_linux/src/lx_kit/printf.cc +++ b/repos/dde_linux/src/lx_kit/printf.cc @@ -1,5 +1,5 @@ /* - * \brief Linux kit memory allocator + * \brief Linux kit printf backend * \author Sebastian Sumpf * \date 2016-04-20 */ @@ -11,10 +11,6 @@ * under the terms of the GNU General Public License version 2. */ -/* Genode includes */ -#include -#include - /* local includes */ #include @@ -26,7 +22,6 @@ namespace Lx { extern "C" int stdout_write(const char *s); -static const bool verbose_console = false; /** * Format string command representation @@ -347,7 +342,7 @@ class Lx::Console switch (cmd.type) { case Format_command::INT: - + if (cmd.length == Format_command::LONG_LONG) _out_signed(numeric_arg, cmd.base); else @@ -434,8 +429,6 @@ class Lx::Console void lx_printf(char const *fmt, ...) { - if (verbose_console) - PDBG("[%p] %s", __builtin_return_address(0), fmt); va_list va; va_start(va, fmt); Lx::Console::c().vprintf(fmt, va); diff --git a/repos/dde_linux/src/lx_kit/scheduler.cc b/repos/dde_linux/src/lx_kit/scheduler.cc index 155d29b9f..86fa5def6 100644 --- a/repos/dde_linux/src/lx_kit/scheduler.cc +++ b/repos/dde_linux/src/lx_kit/scheduler.cc @@ -16,13 +16,12 @@ /* Genode includes */ #include #include -#include +#include #include #include #include /* Linux emulation environment includes */ -#include #include #include @@ -84,7 +83,6 @@ class Lx_kit::Scheduler : public Lx::Scheduler void entry() { - PWRN("Scheduler::Logger is up"); _timer.msleep(1000 * _interval); while (true) { _scheduler.log_state("LOGGER"); @@ -108,7 +106,7 @@ class Lx_kit::Scheduler : public Lx::Scheduler Lx::Task *current() override { if (!_current) { - PERR("BUG: _current is zero!"); + Genode::error("BUG: _current is zero!"); Genode::sleep_forever(); } @@ -168,7 +166,7 @@ class Lx_kit::Scheduler : public Lx::Scheduler } if (!at_least_one) { - PWRN("schedule() called without runnable tasks"); + Genode::warning("schedule() called without runnable tasks"); log_state("SCHEDULE"); } @@ -181,9 +179,11 @@ class Lx_kit::Scheduler : public Lx::Scheduler unsigned i; Lx::Task *t; for (i = 0, t = _present_list.first(); t; t = t->next(), ++i) { - Genode::printf("%s [%u] prio: %u state: %s%u%s %s\n", - prefix, i, t->priority(), _state_color(t->state()), - t->state(), _ansi_esc_reset(), t->name()); + Genode::log(prefix, " [", i, "] " + "prio: ", (int)t->priority(), " " + "state: ", _state_color(t->state()), (int)t->state(), + _ansi_esc_reset(), " ", + t->name()); } } }; @@ -202,7 +202,8 @@ Lx::Task::Task(void (*func)(void*), void *arg, char const *name, scheduler.add(this); if (verbose) - PDBG("name: '%s' func: %p arg: %p prio: %u t: %p", name, func, arg, priority, this); + Genode::log("name: '", name, "' " "func: ", func, " " + "arg: ", arg, " prio: ", (int)priority, " t: ", this); } diff --git a/repos/dde_linux/src/lx_kit/timer.cc b/repos/dde_linux/src/lx_kit/timer.cc index 93db0dea8..7ac6058de 100644 --- a/repos/dde_linux/src/lx_kit/timer.cc +++ b/repos/dde_linux/src/lx_kit/timer.cc @@ -250,7 +250,7 @@ class Lx_kit::Timer : public Lx::Timer { Context *ctx = _find_context(timer); if (!ctx) { - PERR("schedule unknown timer %p", timer); + Genode::error("schedule unknown timer ", timer); return -1; /* XXX better use 0 as rv? */ } diff --git a/repos/dde_linux/src/lx_kit/work.cc b/repos/dde_linux/src/lx_kit/work.cc index e765fed8d..d1cfe160c 100644 --- a/repos/dde_linux/src/lx_kit/work.cc +++ b/repos/dde_linux/src/lx_kit/work.cc @@ -168,5 +168,5 @@ Lx::Work * Lx::Work::alloc_work_queue(Genode::Allocator *alloc, char const *name void Lx::Work::free_work_queue(Lx::Work *w) { - PERR("%s: IMPLEMENT ME", __func__); + Genode::error(__func__, ": IMPLEMENT ME"); } diff --git a/repos/dde_linux/src/server/usb_terminal/main.cc b/repos/dde_linux/src/server/usb_terminal/main.cc index 5e269635e..5f816231d 100644 --- a/repos/dde_linux/src/server/usb_terminal/main.cc +++ b/repos/dde_linux/src/server/usb_terminal/main.cc @@ -1,4 +1,4 @@ -/** +/* * \brief PL2303-USB-UART driver that exposes a terminal session * \author Sebastian Sumpf * \date 2014-12-17 @@ -11,6 +11,7 @@ * under the terms of the GNU General Public License version 2. */ +#include #include #include #include @@ -18,7 +19,6 @@ #include #include -constexpr bool verbose = false; namespace Terminal { class Main; @@ -111,7 +111,7 @@ struct Usb::Pl2303_driver : Completion for (int i = 0; i < p.transfer.actual_size; i++) ring_buffer.add(data[i]); } catch (Ring_buffer::Overflow) { - PWRN("Pl2303 buffer overflow"); + Genode::warning("Pl2303 buffer overflow"); } /* submit back to device (async) */ @@ -155,9 +155,9 @@ struct Usb::Pl2303_driver : Completion enum { BUF = 128 }; char buffer[BUF]; - PINF("PL2303 controller: ready"); - PINF("Manufacturer : %s", device.manufactorer_string.to_char(buffer, BUF)); - PINF("Product : %s", device.product_string.to_char(buffer, BUF)); + Genode::log("PL2303 controller: ready"); + Genode::log("Manufacturer : ", Cstring(device.manufactorer_string.to_char(buffer, BUF))); + Genode::log("Product : ", Cstring(device.product_string.to_char(buffer, BUF))); Interface &iface = device.interface(0); iface.claim(); @@ -183,17 +183,9 @@ struct Usb::Pl2303_driver : Completion /* set baud rate to 115200 */ pl2303_config *cfg = (pl2303_config *)iface.content(p); - if (verbose) - PDBG("GET_LINE %u %u %u %u\n", - cfg->baud, cfg->stop_bits, cfg->parity, cfg->data_bits); - pl2303_config cfg_new; *cfg = cfg_new; - if (verbose) - PDBG("SET_LINE %u %u %u %u\n", - cfg_new.baud, cfg_new.stop_bits, cfg_new.parity, cfg_new.data_bits); - iface.control_transfer(p, 0x21, 0x20, 0, 0, 100); iface.release(p); @@ -217,13 +209,8 @@ struct Usb::Pl2303_driver : Completion */ void state_change(unsigned) { - if (connection.plugged()) { - if (verbose) - PDBG("Device: Plugged"); + if (connection.plugged()) init(); - } - else if (verbose) - PDBG("Device: Unplugged"); } /** diff --git a/repos/dde_linux/src/test/lxip/http_srv/main.cc b/repos/dde_linux/src/test/lxip/http_srv/main.cc index a8fd52f29..e3ba420ed 100644 --- a/repos/dde_linux/src/test/lxip/http_srv/main.cc +++ b/repos/dde_linux/src/test/lxip/http_srv/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* libc includes */ #include @@ -35,7 +35,6 @@ static void serve(int fd) { /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = recv(fd, buf, 1024, 0); - // PLOG("Packet received!"); /* Ignore all receive errors */ if (buflen > 0) { @@ -49,8 +48,6 @@ static void serve(int fd) { buf[3] == ' ' && buf[4] == '/' ) { - // PLOG("Will send response"); - /* Send http header */ send(fd, http_html_hdr, sizeof(http_html_hdr), 0); @@ -65,35 +62,35 @@ int main() { int s; - PLOG("Create new socket ..."); + Genode::log("create new socket ..."); if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; in_addr.sin_family = AF_INET; in_addr.sin_port = htons(80); in_addr.sin_addr.s_addr = INADDR_ANY; if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if(listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { struct sockaddr addr; socklen_t len = sizeof(addr); int client = accept(s, &addr, &len); if(client < 0) { - PWRN("Invalid socket from accept!"); + Genode::warning("invalid socket from accept!"); continue; } serve(client); diff --git a/repos/dde_linux/src/test/lxip/udp_echo/main.cc b/repos/dde_linux/src/test/lxip/udp_echo/main.cc index ef90669ee..b9d2dde67 100644 --- a/repos/dde_linux/src/test/lxip/udp_echo/main.cc +++ b/repos/dde_linux/src/test/lxip/udp_echo/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* libc includes */ #include @@ -27,23 +27,23 @@ int main(void) { int s; - PLOG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; in_addr.sin_family = AF_INET; in_addr.sin_port = htons(1337); in_addr.sin_addr.s_addr = INADDR_ANY; if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { struct sockaddr_in addr; addr.sin_family = AF_INET; @@ -55,18 +55,18 @@ int main(void) ssize_t n = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&addr, &len); if (n == 0) { - PWRN("Invalid request!"); + Genode::warning("Invalid request!"); continue; } if (n < 0) { - PERR("Error %lld", n); + Genode::error("Error ", n); break; } - PLOG("Received %lld bytes", n); + Genode::log("Received ", n, " bytes"); n = sendto(s, buf, n, 0, (struct sockaddr*)&addr, len); - PLOG("Send %lld bytes back", n); + Genode::log("Send ", n, " bytes back"); } return 0; } diff --git a/repos/dde_rump/include/util/allocator_fap.h b/repos/dde_rump/include/util/allocator_fap.h index 0cae4be2b..77fff3b6a 100644 --- a/repos/dde_rump/include/util/allocator_fap.h +++ b/repos/dde_rump/include/util/allocator_fap.h @@ -77,7 +77,7 @@ namespace Allocator { return false; if (_index == ELEMENTS) { - PERR("Slab-backend exhausted!"); + error("slab backend exhausted!"); return false; } @@ -90,11 +90,11 @@ namespace Allocator { /* lookup phys. address */ _ds_phys[_index] = Genode::Dataspace_client(_ds_cap[_index]).phys_addr(); } catch (Genode::Ram_session::Quota_exceeded) { - PWRN("Backend allocator exhausted"); + warning("backend allocator exhausted"); _quota_exceeded = true; return false; } catch (Genode::Region_map::Attach_failed) { - PWRN("Backend VM region exhausted"); + warning("backend VM region exhausted"); _quota_exceeded = true; return false; } @@ -147,8 +147,8 @@ namespace Allocator { return 0; if (_range.alloc_aligned(size, &addr, align).error()) { - PERR("Backend allocator: Unable to allocate memory (size: %zu align: %d:)", - size, align); + error("backend allocator: Unable to allocate memory " + "(size: ", size, " align: ", align, ")"); return 0; } diff --git a/repos/dde_rump/include/util/hard_context.h b/repos/dde_rump/include/util/hard_context.h index be8e75d57..c680c3343 100644 --- a/repos/dde_rump/include/util/hard_context.h +++ b/repos/dde_rump/include/util/hard_context.h @@ -21,6 +21,7 @@ extern "C" { } #include +#include /************* @@ -66,7 +67,7 @@ class Hard_context_thread : public Hard_context, void entry() { _func(_arg); - PDBG("Returned from func"); + Genode::log(__func__, " returned from func"); } public: diff --git a/repos/dde_rump/run/rump_iso.run b/repos/dde_rump/run/rump_iso.run index 5166d353b..26ec0ca6b 100644 --- a/repos/dde_rump/run/rump_iso.run +++ b/repos/dde_rump/run/rump_iso.run @@ -98,7 +98,7 @@ build_boot_image $boot_modules append qemu_args "-nographic -m 64" -run_genode_until {child "test-iso" exited with exit value 0.*\n} 60 +run_genode_until {child .* exited with exit value 0.*\n} 60 # pay only attention to the output of init and its children grep_output {^\[init -> test-iso} diff --git a/repos/dde_rump/src/lib/rump/bootstrap.cc b/repos/dde_rump/src/lib/rump/bootstrap.cc index 87a21c431..1124f5e78 100644 --- a/repos/dde_rump/src/lib/rump/bootstrap.cc +++ b/repos/dde_rump/src/lib/rump/bootstrap.cc @@ -18,7 +18,7 @@ extern "C" { } #include -#include +#include #include #include @@ -55,18 +55,18 @@ struct Sym_tab : map(map), dynamic_base(map->dynamic) { if (!dynamic_base) { - PERR("%s: base is bogus %lx", map->path, map->addr); + Genode::error(map->path, ": base is bogus ", Genode::Hex(map->addr)); throw -1; } if (verbose) - PDBG("for %s at %lx\n", map->path, map->addr); + Genode::log("for ", map->path, " at ", Genode::Hex(map->addr)); find_tables(); if (!sym_base) { - PERR("%s: could not find symbol table (sym_base %p)", map->path, - sym_base); + Genode::error(map->path, ": could not find symbol table " + "(sym_base ", sym_base, ")"); throw -2; } @@ -136,8 +136,8 @@ struct Sym_tab { size_t sym_size = elf_dyn(i)->d_un.d_ptr; if (sym_size != sizeof(Elf_Sym)) - PWRN("Elf symbol size does not match binary %zx != elf %zx", - sym_size, sizeof(Elf_Sym)); + Genode::warning("Elf symbol size does not match binary ", + sym_size, " != ", sizeof(Elf_Sym)); } default: break; @@ -166,7 +166,8 @@ struct Sym_tab /* set absolute value */ sym_tab[out_cnt].st_value += map->addr; if (verbose) - PDBG("Read symbol %s val: %lx", name, sym_tab[out_cnt].st_value); + Genode::log("Read symbol ", name, " " + "val: ", Genode::Hex(sym_tab[out_cnt].st_value)); out_cnt++; } } @@ -188,7 +189,7 @@ static void _dl_init(Genode::Shared_object::Link_map const *map, using namespace Genode; Shared_object *obj; try { obj = new (Genode::env()->heap()) Shared_object(map->path); } - catch (...) { PERR ("Could not dlopen %s\n", map->path); return; } + catch (...) { error("Could not dlopen ", map->path); return; } struct modinfo **mi_start, **mi_end; struct rump_component **rc_start, **rc_end; @@ -196,14 +197,14 @@ static void _dl_init(Genode::Shared_object::Link_map const *map, mi_start = obj->lookup("__start_link_set_modules"); mi_end = obj->lookup("__stop_link_set_modules"); if (verbose) - PDBG("MI: start: %p end: %p", mi_start, mi_end); + log("MI: start: ", mi_start, " end: ", mi_end); if (mi_start && mi_end) mod_init(mi_start, (size_t)(mi_end-mi_start)); rc_start = obj->lookup("__start_link_set_rump_components"); rc_end = obj->lookup("__stop_link_set_rump_components"); if (verbose) - PDBG("RC: start: %p end: %p", rc_start, rc_end); + log("RC: start: ", rc_start, " end: ", rc_end); if (rc_start && rc_end) { for (; rc_start < rc_end; rc_start++) comp_init(*rc_start); @@ -233,7 +234,7 @@ void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload, _dl_init(curr_map, domodinit, compload); } } - PINF("BOOTSTRAP"); + log("BOOTSTRAP"); } @@ -245,7 +246,7 @@ void * rumpuser_dl_globalsym(const char *symname) catch (...) { } if (verbose) - PDBG("Lookup: %s addr %p", symname, addr); + Genode::log("Lookup: ", symname, " addr ", addr); return addr; } diff --git a/repos/dde_rump/src/lib/rump/dummies.cc b/repos/dde_rump/src/lib/rump/dummies.cc index 6abeb8367..77d1dc1e0 100644 --- a/repos/dde_rump/src/lib/rump/dummies.cc +++ b/repos/dde_rump/src/lib/rump/dummies.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include extern "C" { @@ -22,7 +22,8 @@ enum { #define DUMMY(retval, name) \ int name(void) { \ if (SHOW_DUMMY) \ - PDBG(#name " called (from %p) not implemented", __builtin_return_address(0)); \ + Genode::warning(#name " called (from ", __builtin_return_address(0), ") " \ + "not implemented"); \ return retval; \ } diff --git a/repos/dde_rump/src/lib/rump/hypercall.cc b/repos/dde_rump/src/lib/rump/hypercall.cc index c890304fd..12dfafc04 100644 --- a/repos/dde_rump/src/lib/rump/hypercall.cc +++ b/repos/dde_rump/src/lib/rump/hypercall.cc @@ -15,7 +15,7 @@ #include "sched.h" #include -#include +#include #include #include #include @@ -37,10 +37,10 @@ struct rumpuser_hyperup _rump_upcalls; int rumpuser_init(int version, const struct rumpuser_hyperup *hyp) { - PDBG("RUMP ver: %d", version); + Genode::log("RUMP ver: ", version); if (version != SUPPORTED_RUMP_VERSION) { - PERR("Unsupported rump-kernel version (%d) - supported is %d)", - version, SUPPORTED_RUMP_VERSION); + Genode::error("unsupported rump-kernel version (", version, ") - " + "supported is ", (int)SUPPORTED_RUMP_VERSION); return -1; } @@ -137,7 +137,7 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen) enum { RESERVE_MEM = 2U * 1024 * 1024 }; /* support one cpu */ - PDBG("%s", name); + Genode::log(name); if (!Genode::strcmp(name, "_RUMPUSER_NCPU")) { Genode::strncpy((char *)buf, "1", 2); return 0; @@ -155,7 +155,8 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen) size_t rump_ram = Genode::env()->ram_session()->avail(); if (rump_ram <= RESERVE_MEM) { - PERR("Insufficient quota need left: %zu < %u bytes", rump_ram, RESERVE_MEM); + Genode::error("insufficient quota left: ", + rump_ram, " < ", (long)RESERVE_MEM, " bytes"); return -1; } @@ -163,7 +164,7 @@ int rumpuser_getparam(const char *name, void *buf, size_t buflen) /* convert to string */ Genode::snprintf((char *)buf, buflen, "%zu", rump_ram); - PERR("Asserting rump kernel %zu KB of RAM", rump_ram / 1024); + Genode::log("asserting rump kernel ", rump_ram / 1024, " KB of RAM"); return 0; } @@ -188,7 +189,7 @@ void rumpuser_putchar(int ch) if (myself() != main_thread()) rumpkern_unsched(&nlocks, 0); - PLOG("rump: %s", buf); + Genode::log("rump: ", Genode::Cstring((char const *)buf)); if (myself() != main_thread()) rumpkern_sched(nlocks, 0); @@ -243,7 +244,7 @@ int rumpuser_malloc(size_t len, int alignment, void **memp) *memp = allocator()->alloc(len, align); if (verbose) - PWRN("ALLOC: p: %p, s: %zx, a: %d %d", *memp, len, align, alignment); + Genode::log("ALLOC: p: ", *memp, ", s: ", len, ", a: ", align, " ", alignment); return *memp ? 0 : -1; @@ -257,7 +258,7 @@ void rumpuser_free(void *mem, size_t len) allocator()->free(mem, len); if (verbose) - PWRN("FREE: p: %p, s: %zx", mem, len); + Genode::warning("FREE: p: ", mem, ", s: ", len); } @@ -318,7 +319,7 @@ void genode_exit(int) __attribute__((noreturn)); void rumpuser_exit(int status) { if (status == RUMPUSER_PANIC) - PERR("Rump panic"); + Genode::error("Rump panic"); genode_exit(status); } diff --git a/repos/dde_rump/src/lib/rump/io.cc b/repos/dde_rump/src/lib/rump/io.cc index 952b04260..d445b8756 100644 --- a/repos/dde_rump/src/lib/rump/io.cc +++ b/repos/dde_rump/src/lib/rump/io.cc @@ -14,6 +14,7 @@ #include "sched.h" #include #include +#include #include #include #include @@ -84,7 +85,7 @@ class Backend : public Hard_context_thread p = p->next(); } - PERR("Pending packet not found"); + Genode::error("pending packet not found"); return 0; } @@ -99,7 +100,7 @@ class Backend : public Hard_context_thread return &_p[idx]; } } - PWRN("Dequeue returned 0"); + Genode::warning("dequeue returned 0"); return 0; } @@ -132,7 +133,7 @@ class Backend : public Hard_context_thread int dummy; if (verbose) - PDBG("BIO done p: %p bio %p", p, p->donearg); + Genode::log("BIO done p: ", p, " bio ", p->donearg); rumpkern_sched(0, 0); if (p->biodone) @@ -221,7 +222,7 @@ class Backend : public Hard_context_thread _session.tx_channel()->sigh_ack_avail(_disp_ack); _session.tx_channel()->sigh_ready_to_submit(_disp_submit); _session.info(&_blk_cnt, &_blk_size, &_blk_ops); - PDBG("Backend blk_size %zu", _blk_size); + Genode::log("Backend blk_size ", _blk_size); Genode::memset(_p, 0, sizeof(_p)); start(); } @@ -248,7 +249,7 @@ class Backend : public Hard_context_thread return &_p[idx]; } } - PWRN("Alloc returned 0"); + Genode::warning("alloc returned 0"); return 0; } @@ -268,7 +269,7 @@ static Backend *backend() try { _b = new(Genode::env()->heap())Backend(); } catch (Genode::Parent::Service_denied) { - PERR("Opening block session denied!"); + Genode::error("opening block session denied!"); } rumpkern_sched(nlocks, 0); @@ -314,8 +315,13 @@ void rumpuser_bio(int fd, int op, void *data, size_t dlen, int64_t off, Packet *p = backend()->alloc(); if (verbose) - PDBG("fd: %d op: %d len: %zu off: %lx p %p bio %p sync %u", fd, op, dlen, (unsigned long)off, - p, donearg, !!(op & RUMPUSER_BIO_SYNC)); + Genode::log("fd: ", fd, " " + "op: ", op, " " + "len: ", dlen, " " + "off: ", Genode::Hex((unsigned long)off), " " + "p: ", p, " " + "bio ", donearg, " " + "sync: ", !!(op & RUMPUSER_BIO_SYNC)); p->opcode= op & RUMPUSER_BIO_WRITE ? Block::Packet_descriptor::WRITE : Block::Packet_descriptor::READ; diff --git a/repos/dde_rump/src/lib/rump/sync.cc b/repos/dde_rump/src/lib/rump/sync.cc index f11a2f110..445c0554c 100644 --- a/repos/dde_rump/src/lib/rump/sync.cc +++ b/repos/dde_rump/src/lib/rump/sync.cc @@ -67,7 +67,7 @@ struct rumpuser_mtx if (flags & RUMPUSER_MTX_KMUTEX) { if (owner != nullptr) - PERR("OWNER already set on KMUTEX enter"); + Genode::error("OWNER already set on KMUTEX enter"); owner = rumpuser_curlwp(); } @@ -94,7 +94,7 @@ struct rumpuser_mtx if (flags & RUMPUSER_MTX_KMUTEX) { if (owner == nullptr) - PERR("OWNER not set on KMUTEX exit"); + Genode::error("OWNER not set on KMUTEX exit"); owner = nullptr; } diff --git a/repos/dde_rump/src/server/rump_cgd/block_driver.h b/repos/dde_rump/src/server/rump_cgd/block_driver.h index 519b0ed05..703282e69 100644 --- a/repos/dde_rump/src/server/rump_cgd/block_driver.h +++ b/repos/dde_rump/src/server/rump_cgd/block_driver.h @@ -15,7 +15,7 @@ #define _BLOCK_DRIVER_H_ /* General includes */ -#include +#include #include #include #include @@ -44,7 +44,7 @@ class Driver : public Block::Driver try { _cgd_device = Cgd::init(Genode::env()->heap(), ep); } catch (...) { - PERR("could not initialize cgd device."); + Genode::error("could not initialize cgd device."); throw Genode::Root::Unavailable(); } @@ -67,7 +67,7 @@ class Driver : public Block::Driver bool _range_valid(Block::sector_t num, Genode::size_t count) { if (num + count > _blk_cnt) { - PERR("requested block %llu-%llu out of range!", num, num + count); + Genode::error("requested block ", num, "-", num + count, " out of range!"); return false; } diff --git a/repos/dde_rump/src/server/rump_cgd/cgd.cc b/repos/dde_rump/src/server/rump_cgd/cgd.cc index 928f00c7e..a83d3a8db 100644 --- a/repos/dde_rump/src/server/rump_cgd/cgd.cc +++ b/repos/dde_rump/src/server/rump_cgd/cgd.cc @@ -38,10 +38,6 @@ extern "C" { } -static const bool verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - /** * Miscellaneous methods used for converting the key string */ @@ -236,7 +232,7 @@ namespace Cgd { bool use_key = Genode::strcmp(method_val, "key") == 0 ? true : false; if (!use_key) { - PERR("no valid method specified."); + Genode::error("no valid method specified."); throw Genode::Exception(); } @@ -252,12 +248,12 @@ namespace Cgd { size_t enc_key_len = Genode::strlen(enc_key); if (enc_key_len != VALID_ENCODED_KEY_LEN) { - PERR("incorrect encoded key found."); + Genode::error("incorrect encoded key found."); throw Genode::Exception(); } if (!_decode_key_string(_params->key, enc_key, enc_key_len)) { - PERR("could not decode key string."); + Genode::error("could not decode key string."); throw Genode::Exception(); } @@ -266,7 +262,7 @@ namespace Cgd { /* let cgd(4) figure out the right blocksize */ _params->blocksize = -1; } else { - PERR("no node found."); + Genode::error("no node found."); throw Genode::Exception(); } } @@ -315,7 +311,7 @@ Cgd::Device::Device(int fd) rump_sys_ioctl(_fd, CGDIOCCLR, &ci); rump_sys_close(_fd); - PERR("could not read geometry of '%s'", CGD_RAW_DEVICE); + Genode::error("could not read geometry of '", CGD_RAW_DEVICE, "'"); throw Genode::Exception(); } @@ -399,13 +395,10 @@ Cgd::Device *Cgd::Device::configure(Genode::Allocator *alloc, Cgd::Params const { int fd = rump_sys_open(CGD_RAW_DEVICE, O_RDWR); if (fd == -1) { - PERR("could not open '%s'", CGD_RAW_DEVICE); + Genode::error("could not open '", CGD_RAW_DEVICE, "'"); throw Genode::Exception(); } - PDBGV("dev: '%s' alg: '%s' ivmethod: '%s' blocksize: %zu keylen: %zu", - dev, p->algorithm, p->ivmethod, p->blocksize, p->keylen); - /* perform configuration of cgd device */ cgd_ioctl ci; Genode::memset(&ci, 0, sizeof (ci)); @@ -421,7 +414,7 @@ Cgd::Device *Cgd::Device::configure(Genode::Allocator *alloc, Cgd::Params const if (err == -1) { rump_sys_close(fd); - PERR("could not configure '%s'", CGD_RAW_DEVICE); + Genode::error("could not configure '", CGD_RAW_DEVICE, "'"); throw Genode::Exception(); } @@ -438,7 +431,7 @@ Cgd::Device *Cgd::Device::configure(Genode::Allocator *alloc, Cgd::Params const rump_sys_ioctl(fd, CGDIOCCLR, &ci); rump_sys_close(fd); - PERR("could not get cgd information."); + Genode::error("could not get cgd information."); throw Genode::Exception(); } @@ -459,7 +452,7 @@ Cgd::Device *Cgd::init(Genode::Allocator *alloc, Server::Entrypoint &ep) /* register block device */ if (rump_pub_etfs_register(GENODE_DEVICE, GENODE_BLOCK_SESSION, RUMP_ETFS_BLK)) { - PERR("could not register '%s' within rumpkernel", GENODE_DEVICE); + Genode::error("could not register '", GENODE_DEVICE, "' within rumpkernel"); throw Genode::Exception(); } @@ -488,12 +481,12 @@ Cgd::Device *Cgd::init(Genode::Allocator *alloc, Server::Entrypoint &ep) break; } case Cgd::Config::ACTION_INVALID: - PERR("invalid action declared"); + Genode::error("invalid action declared"); throw Genode::Exception(); break; } - PINF("exporting '%s' as Block_session", cgd_dev->name()); + Genode::log("exporting '", cgd_dev->name(), "' as block session"); return cgd_dev; } diff --git a/repos/dde_rump/src/server/rump_cgd/random.cc b/repos/dde_rump/src/server/rump_cgd/random.cc index 6d0be95a2..891c1c453 100644 --- a/repos/dde_rump/src/server/rump_cgd/random.cc +++ b/repos/dde_rump/src/server/rump_cgd/random.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include extern "C" { @@ -47,7 +47,7 @@ struct Entropy { int err; if ((err = Jitter::jent_read_entropy(ec_stir, buf, len) < 0)) { - PERR("Failed to read entropy: %d", err); + Genode::error("failed to read entropy: ", err); return 0; } diff --git a/repos/dde_rump/src/server/rump_fs/directory.h b/repos/dde_rump/src/server/rump_fs/directory.h index 3216b5a96..88cc337d7 100644 --- a/repos/dde_rump/src/server/rump_fs/directory.h +++ b/repos/dde_rump/src/server/rump_fs/directory.h @@ -257,7 +257,7 @@ class File_system::Directory : public Node throw Lookup_failed(); if (ret == -1) - Genode::error("Error during unlink of ", node_path.base()); + Genode::error("error during unlink of ", node_path); } }; diff --git a/repos/dde_rump/src/server/rump_fs/main.cc b/repos/dde_rump/src/server/rump_fs/main.cc index 0bfcd2a6a..4a8fe3e84 100644 --- a/repos/dde_rump/src/server/rump_fs/main.cc +++ b/repos/dde_rump/src/server/rump_fs/main.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include "undef.h" diff --git a/repos/dde_rump/src/server/rump_fs/symlink.h b/repos/dde_rump/src/server/rump_fs/symlink.h index c9a4c2766..94ce9f064 100644 --- a/repos/dde_rump/src/server/rump_fs/symlink.h +++ b/repos/dde_rump/src/server/rump_fs/symlink.h @@ -54,7 +54,7 @@ class File_system::Symlink : public Node return 0; /* src may not be null-terminated */ - Genode::String target(src, len); + Genode::String target(Genode::Cstring(src, len)); int ret = rump_sys_symlink(target.string(), _path.base()); return ret == -1 ? 0 : ret; diff --git a/repos/dde_rump/src/test/blk_crypt/main.cc b/repos/dde_rump/src/test/blk_crypt/main.cc index 3c157eb65..1eeb9f26b 100644 --- a/repos/dde_rump/src/test/blk_crypt/main.cc +++ b/repos/dde_rump/src/test/blk_crypt/main.cc @@ -19,9 +19,9 @@ int main(int argc, char *argv[]) Block::Connection blk(&alloc); blk.info(&blk_cnt, &blk_sz, &blk_ops); - PINF("block device with block size %zd sector count %lld", - blk_sz, blk_cnt); - PLOG("read first block"); + Genode::log("block device with block size ", blk_sz, " sector count ", blk_cnt); + + Genode::log("read first block"); Block::Packet_descriptor p(blk.tx()->alloc_packet(blk_sz), Block::Packet_descriptor::READ, 0, 1); @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) p = blk.tx()->get_acked_packet(); if (!p.succeeded()) { - PERR("could not read first block"); + Genode::error("could not read first block"); blk.tx()->release_packet(p); return 1; } @@ -37,9 +37,8 @@ int main(int argc, char *argv[]) Genode::memcpy(buffer, blk.tx()->packet_content(p), blk_sz); /* XXX compare content */ - /* PERR("block content: '%s'", buffer); */ } catch(Genode::Parent::Service_denied) { - PERR("Opening block session was denied!"); + Genode::error("opening block session was denied"); return -1; } diff --git a/repos/demo/include/scout/platform.h b/repos/demo/include/scout/platform.h index 120d63e0d..d2bb1d73c 100644 --- a/repos/demo/include/scout/platform.h +++ b/repos/demo/include/scout/platform.h @@ -39,8 +39,8 @@ inline void *operator new(Genode::size_t size) using Genode::env; void *addr = env()->heap()->alloc(size); if (!addr) { - PERR("env()->heap() has consumed %zd", env()->heap()->consumed()); - PERR("env()->ram_session()->quota = %zd", env()->ram_session()->quota()); + Genode::error("env()->heap() has consumed ", env()->heap()->consumed()); + Genode::error("env()->ram_session()->quota = ", env()->ram_session()->quota()); throw Genode::Allocator::Out_of_memory(); } return addr; diff --git a/repos/demo/src/lib/launchpad/launchpad.cc b/repos/demo/src/lib/launchpad/launchpad.cc index 1a101109d..e8b588fc2 100644 --- a/repos/demo/src/lib/launchpad/launchpad.cc +++ b/repos/demo/src/lib/launchpad/launchpad.cc @@ -127,7 +127,7 @@ void Launchpad::process_config() enum { MAX_NAME_LEN = 128 }; char *filename = (char *)env()->heap()->alloc(MAX_NAME_LEN); if (!filename) { - printf("Error: Out of memory while processing configuration\n"); + Genode::error("out of memory while processing configuration"); return; } filename_attr.value(filename, MAX_NAME_LEN); @@ -171,13 +171,12 @@ void Launchpad::process_config() launcher_cnt++; } catch (...) { - printf("Warning: Launcher entry %d is malformed.\n", - launcher_cnt + 1); + Genode::warning("launcher entry ", launcher_cnt + 1, " is malformed"); } else { char buf[32]; node.type_name(buf, sizeof(buf)); - printf("Warning: Ignoring unsupported tag <%s>.\n", buf); + Genode::warning("ignoring unsupported tag <", Genode::Cstring(buf), ">"); } } } @@ -187,22 +186,22 @@ Launchpad_child *Launchpad::start_child(const char *filename, unsigned long ram_quota, Genode::Dataspace_capability config_ds) { - printf("starting %s with quota %lu\n", filename, ram_quota); + Genode::log("starting ", filename, " with quota ", ram_quota); /* find unique name for new child */ char unique_name[64]; _get_unique_child_name(filename, unique_name, sizeof(unique_name)); - printf("using unique child name \"%s\"\n", unique_name); + Genode::log("using unique child name \"", Cstring(unique_name), "\""); if (ram_quota > env()->ram_session()->avail()) { - PERR("Child's ram quota is higher than our available quota, using available quota"); + Genode::error("child's ram quota is higher than our available quota, using available quota"); ram_quota = env()->ram_session()->avail() - 256*1000; } size_t metadata_size = 4096*16 + sizeof(Launchpad_child); if (metadata_size > ram_quota) { - PERR("Too low ram_quota to hold child metadata"); + Genode::error("too low ram_quota to hold child metadata"); return 0; } @@ -217,13 +216,13 @@ Launchpad_child *Launchpad::start_child(const char *filename, * constructor of 'Rom_connection' throws a 'Parent::Service_denied' * exception. */ - Rom_connection rom(prefixed_label(Session_label(unique_name), + Rom_connection rom(prefixed_label(Session_label(Cstring(unique_name)), Session_label(filename)).string()); rom.on_destruction(Rom_connection::KEEP_OPEN); rom_cap = rom.cap(); file_cap = rom.dataspace(); } catch (...) { - printf("Error: Could not access file \"%s\" from ROM service.\n", filename); + Genode::error("could not access ROM module \"", filename, "\""); return 0; } @@ -239,22 +238,22 @@ Launchpad_child *Launchpad::start_child(const char *filename, if (!ram.cap().valid() || !cpu.cap().valid()) { if (ram.cap().valid()) { - PWRN("Failed to create CPU session"); + Genode::warning("failed to create CPU session"); env()->parent()->close(ram.cap()); } if (cpu.cap().valid()) { - PWRN("Failed to create RAM session"); + Genode::warning("failed to create RAM session"); env()->parent()->close(cpu.cap()); } env()->parent()->close(rom_cap); - PERR("Our quota is %zd", env()->ram_session()->quota()); + Genode::log("our quota is ", env()->ram_session()->quota()); return 0; } Pd_connection pd; pd.on_destruction(Pd_connection::KEEP_OPEN); if (!pd.cap().valid()) { - PWRN("Failed to create PD session"); + Genode::warning("failed to create PD session"); env()->parent()->close(ram.cap()); env()->parent()->close(cpu.cap()); env()->parent()->close(rom_cap); @@ -275,9 +274,9 @@ Launchpad_child *Launchpad::start_child(const char *filename, return c; } catch (Cpu_session::Thread_creation_failed) { - PWRN("Failed to create child - Cpu_session::Thread_creation_failed"); + Genode::warning("failed to create child - Cpu_session::Thread_creation_failed"); } catch (...) { - PWRN("Failed to create child - unknown reason"); + Genode::warning("failed to create child - unknown reason"); } env()->parent()->close(ram.cap()); @@ -325,7 +324,7 @@ class Child_destructor_thread : Thread_deprecated<2*4096> try { destroy(_curr_alloc, _curr_child); } catch (Blocking_canceled) { - PERR("Suspicious cancellation"); + Genode::error("suspicious cancellation"); } _ready = true; diff --git a/repos/demo/src/lib/mini_c/abort.cc b/repos/demo/src/lib/mini_c/abort.cc index 5ef3e8c65..84dc4dfe8 100644 --- a/repos/demo/src/lib/mini_c/abort.cc +++ b/repos/demo/src/lib/mini_c/abort.cc @@ -11,12 +11,12 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include extern "C" void *abort(void) { - PDBG("abort called"); + Genode::warning("abort called"); Genode::sleep_forever(); return 0; } diff --git a/repos/demo/src/lib/mini_c/strtol.cc b/repos/demo/src/lib/mini_c/strtol.cc index 41e4708e6..2b4d879dc 100644 --- a/repos/demo/src/lib/mini_c/strtol.cc +++ b/repos/demo/src/lib/mini_c/strtol.cc @@ -12,7 +12,7 @@ */ #include -#include +#include extern "C" long int strtol(const char *nptr, char **endptr, int base) @@ -22,7 +22,7 @@ extern "C" long int strtol(const char *nptr, char **endptr, int base) long result = 0; if (base != 0 && base != 10) { - PERR("strtol: base of %d not supported", base); + error("strtol: base of ", base, " not supported"); return 0; } diff --git a/repos/demo/src/server/nitlog/main.cc b/repos/demo/src/server/nitlog/main.cc index 290a26390..fcd930bdb 100644 --- a/repos/demo/src/server/nitlog/main.cc +++ b/repos/demo/src/server/nitlog/main.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -295,7 +296,7 @@ class Log_session_component : public Genode::Rpc_object Genode::size_t write(String const &log_text) { if (!log_text.valid_string()) { - PERR("corrupted string"); + Genode::error("corrupted string"); return 0; } @@ -315,7 +316,7 @@ class Log_root_component : public Genode::Root_component Log_session_component *_create_session(const char *args) { - PINF("create log session (%s)", args); + Genode::log("create log session args: ", args); char label_buf[Log_session_component::LABEL_LEN]; Genode::Arg label_arg = Genode::Arg_string::find_arg(args, "label"); @@ -386,7 +387,7 @@ int main(int argc, char **argv) using namespace Genode; /* make sure that we connect to LOG before providing this service by ourself */ - printf("--- nitlog ---\n"); + log("--- nitlog ---"); /* calculate size of log view in pixels */ int log_win_w = default_font.str_w(" ") * LOG_W + 2; diff --git a/repos/gems/include/gems/nitpicker_buffer.h b/repos/gems/include/gems/nitpicker_buffer.h index 27eec5ab4..36e058c96 100644 --- a/repos/gems/include/gems/nitpicker_buffer.h +++ b/repos/gems/include/gems/nitpicker_buffer.h @@ -57,7 +57,7 @@ struct Nitpicker_buffer nitpicker.buffer(mode, true); if (mode.format() != Framebuffer::Mode::RGB565) { - PWRN("Color mode %d not supported\n", (int)mode.format()); + Genode::warning("color mode ", mode, " not supported"); return Genode::Dataspace_capability(); } diff --git a/repos/gems/include/nano3d/scene.h b/repos/gems/include/nano3d/scene.h index f476a5285..467cba4c8 100644 --- a/repos/gems/include/nano3d/scene.h +++ b/repos/gems/include/nano3d/scene.h @@ -74,7 +74,7 @@ class Nano3d::Scene { Framebuffer::Mode::Format const format = nitpicker.mode().format(); if (format != Framebuffer::Mode::RGB565) { - PERR("framebuffer mode %d is not supported\n", format); + Genode::error("framebuffer mode ", (int)format, " is not supported"); throw Unsupported_color_depth(); } diff --git a/repos/gems/src/app/cpu_load_display/main.cc b/repos/gems/src/app/cpu_load_display/main.cc index 4b08f7891..742fb2ce2 100644 --- a/repos/gems/src/app/cpu_load_display/main.cc +++ b/repos/gems/src/app/cpu_load_display/main.cc @@ -138,7 +138,8 @@ class Cpu_load_display::Cpu : public Genode::List::Element } /* add new timeline */ - Timeline *t = new (Genode::env()->heap()) Timeline(subject_id, label); + Timeline *t = new (Genode::env()->heap()) + Timeline(subject_id, Genode::Cstring(label)); _timelines.insert(t); return t; } @@ -181,7 +182,6 @@ class Cpu_load_display::Cpu : public Genode::List::Element if (t->idle()) { - PDBG("discard timeline"); _timelines.remove(t); Genode::destroy(Genode::env()->heap(), t); } @@ -301,7 +301,7 @@ class Cpu_load_display::Scene : public Nano3d::Scene try { Xml_node subjects(_trace_subjects.local_addr()); _cpu_registry.import_trace_subjects(subjects, _now); - } catch (...) { PWRN("failed to import trace subjects"); } + } catch (...) { Genode::error("failed to import trace subjects"); } } Genode::Signal_dispatcher _trace_subjects_dispatcher; diff --git a/repos/gems/src/app/decorator/config.h b/repos/gems/src/app/decorator/config.h index ccef60671..29d568575 100644 --- a/repos/gems/src/app/decorator/config.h +++ b/repos/gems/src/app/decorator/config.h @@ -191,7 +191,7 @@ class Decorator::Config auto lambda = [&] (Xml_node node) { if (_num_window_controls >= MAX_WINDOW_CONTROLS) { - PWRN("number of configured window controls exceeds maximum"); + Genode::warning("number of configured window controls exceeds maximum"); return; } diff --git a/repos/gems/src/app/decorator/main.cc b/repos/gems/src/app/decorator/main.cc index 0bf077764..0210e332e 100644 --- a/repos/gems/src/app/decorator/main.cc +++ b/repos/gems/src/app/decorator/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -155,7 +155,7 @@ struct Decorator::Main : Window_factory_base return new (env()->heap()) Window(attribute(window_node, "id", 0UL), nitpicker, animator, config); } catch (Nitpicker::Session::Out_of_metadata) { - PINF("Handle Out_of_metadata of nitpicker session - upgrade by 8K"); + Genode::log("Handle Out_of_metadata of nitpicker session - upgrade by 8K"); Genode::env()->parent()->upgrade(nitpicker.cap(), "ram_quota=8192"); } } diff --git a/repos/gems/src/app/decorator/window.h b/repos/gems/src/app/decorator/window.h index 8df1bb7b6..d0a409feb 100644 --- a/repos/gems/src/app/decorator/window.h +++ b/repos/gems/src/app/decorator/window.h @@ -57,7 +57,7 @@ class Decorator::Window : public Window_base char buf[128]; Genode::snprintf(buf, sizeof(buf), "%d", id); - _nitpicker.enqueue(_handle, buf); + _nitpicker.enqueue(_handle, Genode::Cstring(buf)); } } diff --git a/repos/gems/src/app/floating_window_layouter/action.h b/repos/gems/src/app/floating_window_layouter/action.h index 127e508fa..903bcbca9 100644 --- a/repos/gems/src/app/floating_window_layouter/action.h +++ b/repos/gems/src/app/floating_window_layouter/action.h @@ -60,7 +60,7 @@ class Floating_window_layouter::Action if (string == "raise_window") return RAISE_WINDOW; if (string == "toggle_fullscreen") return TOGGLE_FULLSCREEN; - PWRN("cannot convert \"%s\" to action type", string.string()); + Genode::warning("cannot convert \"", string, "\" to action type"); return NONE; } diff --git a/repos/gems/src/app/floating_window_layouter/focus_history.h b/repos/gems/src/app/floating_window_layouter/focus_history.h index 905e450c7..7ac461428 100644 --- a/repos/gems/src/app/floating_window_layouter/focus_history.h +++ b/repos/gems/src/app/floating_window_layouter/focus_history.h @@ -58,7 +58,7 @@ class Floating_window_layouter::Focus_history { Entry * const entry = _lookup(window_id); if (!entry) { - PWRN("unexpected lookup failure for focus history entry"); + Genode::warning("unexpected lookup failure for focus history entry"); return; } diff --git a/repos/gems/src/app/floating_window_layouter/key_sequence_tracker.h b/repos/gems/src/app/floating_window_layouter/key_sequence_tracker.h index b6fe5143d..bb36144f6 100644 --- a/repos/gems/src/app/floating_window_layouter/key_sequence_tracker.h +++ b/repos/gems/src/app/floating_window_layouter/key_sequence_tracker.h @@ -75,7 +75,7 @@ class Floating_window_layouter::Key_sequence_tracker entries[pos++] = entry; if (pos == MAX_ENTRIES) { - PWRN("Too long key sequence, dropping information"); + Genode::warning("too long key sequence, dropping information"); pos = MAX_ENTRIES - 1; } } diff --git a/repos/gems/src/app/floating_window_layouter/main.cc b/repos/gems/src/app/floating_window_layouter/main.cc index 3ee484880..7186c29ea 100644 --- a/repos/gems/src/app/floating_window_layouter/main.cc +++ b/repos/gems/src/app/floating_window_layouter/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -481,7 +481,7 @@ void Floating_window_layouter::Main::handle_window_list_update(unsigned) try { import_window_list(window_list.xml()); } catch (...) { - PERR("Error while importing window list"); } + Genode::error("could not import window list"); } generate_window_layout_model(); } diff --git a/repos/gems/src/app/floating_window_layouter/user_state.h b/repos/gems/src/app/floating_window_layouter/user_state.h index 829340737..30328c13f 100644 --- a/repos/gems/src/app/floating_window_layouter/user_state.h +++ b/repos/gems/src/app/floating_window_layouter/user_state.h @@ -314,7 +314,7 @@ void Floating_window_layouter::User_state::_handle_event(Input::Event const &e, return; default: - PWRN("action %d unhanded", action.type()); + Genode::warning("action ", (int)action.type(), " unhanded"); } }); } diff --git a/repos/gems/src/app/launcher/fading_dialog.h b/repos/gems/src/app/launcher/fading_dialog.h index e6f0753fb..76967fb76 100644 --- a/repos/gems/src/app/launcher/fading_dialog.h +++ b/repos/gems/src/app/launcher/fading_dialog.h @@ -125,7 +125,7 @@ class Launcher::Fading_dialog : private Input_event_handler } } catch (...) { - PWRN("no menu hover model available"); + Genode::warning("no menu hover model available"); } } @@ -169,7 +169,7 @@ class Launcher::Fading_dialog : private Input_event_handler void upgrade(Genode::Session_capability, const char *args) override { - PDBG("upgrade called args: '%s'", args); + Genode::log("upgrade called args: '", args, "'"); } void close(Genode::Session_capability) override { } diff --git a/repos/gems/src/app/launcher/main.cc b/repos/gems/src/app/launcher/main.cc index 28906c933..c40321155 100644 --- a/repos/gems/src/app/launcher/main.cc +++ b/repos/gems/src/app/launcher/main.cc @@ -180,7 +180,7 @@ void Launcher::Main::_handle_focus_update(unsigned) _panel_dialog.focus_changed(label); } catch (...) { - PWRN("no focus model available"); + Genode::warning("no focus model available"); } } diff --git a/repos/gems/src/app/launcher/menu_dialog.h b/repos/gems/src/app/launcher/menu_dialog.h index b611ebd84..718b949fb 100644 --- a/repos/gems/src/app/launcher/menu_dialog.h +++ b/repos/gems/src/app/launcher/menu_dialog.h @@ -248,7 +248,7 @@ class Launcher::Menu_dialog : Input_event_handler, Dialog_generator, void update(Xml_node subsystems) { if (_elements.first()) { - PERR("subsequent updates are not supported"); + Genode::error("subsequent updates are not supported"); return; } diff --git a/repos/gems/src/app/launcher/panel_dialog.h b/repos/gems/src/app/launcher/panel_dialog.h index e984edff3..0e9d9ec94 100644 --- a/repos/gems/src/app/launcher/panel_dialog.h +++ b/repos/gems/src/app/launcher/panel_dialog.h @@ -183,9 +183,9 @@ class Launcher::Panel_dialog : Input_event_handler, Dialog_generator, dialog_changed(); } catch (Xml_node::Nonexistent_sub_node) { - PERR("no subsystem config found for \"%s\"", label.string()); + Genode::error("no subsystem config found for \"", label, "\""); } catch (Subsystem_manager::Invalid_config) { - PERR("invalid subsystem configuration for \"%s\"", label.string()); + Genode::error("invalid subsystem configuration for \"", label, "\""); } } diff --git a/repos/gems/src/app/launcher/subsystem_manager.h b/repos/gems/src/app/launcher/subsystem_manager.h index 2c1b6979f..765e9d158 100644 --- a/repos/gems/src/app/launcher/subsystem_manager.h +++ b/repos/gems/src/app/launcher/subsystem_manager.h @@ -157,7 +157,7 @@ class Launcher::Subsystem_manager return string_attribute(subsystem.sub_node("binary"), "name", Child::Binary_name("")); } catch (Xml_node::Nonexistent_sub_node) { - PERR("missing definition"); + Genode::error("missing definition"); throw Invalid_config(); } } @@ -178,7 +178,7 @@ class Launcher::Subsystem_manager } }); } catch (...) { - PERR("invalid RAM resource declaration"); + Genode::error("invalid RAM resource declaration"); throw Invalid_config(); } @@ -209,7 +209,7 @@ class Launcher::Subsystem_manager Ram_config const ram_config = _ram_config(subsystem); - PINF("starting child '%s'", label.string()); + Genode::log("starting child '", label.string(), "'"); try { Child *child = new (env()->heap()) @@ -229,7 +229,7 @@ class Launcher::Subsystem_manager child->start(); } catch (Rom_connection::Rom_connection_failed) { - PERR("binary \"%s\" is missing", binary_name.string()); + Genode::error("binary \"", binary_name, "\" is missing"); throw Invalid_config(); } } diff --git a/repos/gems/src/app/launcher/types.h b/repos/gems/src/app/launcher/types.h index a22f7c408..db447f1b0 100644 --- a/repos/gems/src/app/launcher/types.h +++ b/repos/gems/src/app/launcher/types.h @@ -32,7 +32,7 @@ namespace Launcher { */ char selector[Nitpicker::Session::Label::size()]; snprintf(selector, sizeof(selector), "%s ->", label.string()); - return Nitpicker::Session::Label(selector); + return Nitpicker::Session::Label(Cstring(selector)); } using Decorator::area_attribute; diff --git a/repos/gems/src/app/menu_view/main.cc b/repos/gems/src/app/menu_view/main.cc index dcce44a33..9265e0b35 100644 --- a/repos/gems/src/app/menu_view/main.cc +++ b/repos/gems/src/app/menu_view/main.cc @@ -151,7 +151,7 @@ void Menu_view::Main::handle_dialog_update(unsigned) root_widget.update(dialog_xml); root_widget.size(root_widget.min_size()); } catch (...) { - PERR("failed to construct widget tree"); + Genode::error("failed to construct widget tree"); } schedule_redraw = true; diff --git a/repos/gems/src/app/menu_view/widgets.h b/repos/gems/src/app/menu_view/widgets.h index cbb4b12ee..8c69a0877 100644 --- a/repos/gems/src/app/menu_view/widgets.h +++ b/repos/gems/src/app/menu_view/widgets.h @@ -139,7 +139,7 @@ class Menu_view::Widget : public List::Element char type[NAME_MAX_LEN]; node.type_name(type, sizeof(type)); - return Type_name(type); + return Type_name(Cstring(type)); } static bool _named_sub_node_exists(Xml_node node, Name const &name) @@ -242,7 +242,7 @@ class Menu_view::Widget : public List::Element node.for_each_sub_node([&] (Xml_node node) { if (!w) { - PERR("unexpected end of widget list during re-ordering"); + Genode::error("unexpected end of widget list during re-ordering"); return; } @@ -251,7 +251,7 @@ class Menu_view::Widget : public List::Element if (w->_name != name) { w = _lookup_child(name); if (!w) { - PERR("widget lookup unexpectedly failed during re-ordering"); + Genode::error("widget lookup unexpectedly failed during re-ordering"); return; } @@ -382,12 +382,12 @@ struct Menu_view::Root_widget : Widget char const *dialog_tag = "dialog"; if (!node.has_type(dialog_tag)) { - PERR("no valid tag found"); + Genode::error("no valid tag found"); return; } if (!node.num_sub_nodes()) { - PWRN("empty node"); + Genode::warning("empty node"); return; } @@ -836,7 +836,7 @@ Menu_view::Widget_factory::create(Xml_node node) char type[64]; type[0] = 0; node.type_name(type, sizeof(type)); - PERR("unknown widget type '%s'", type); + Genode::error("unknown widget type '", Cstring(type), "'"); return 0; } diff --git a/repos/gems/src/app/mixer_gui_qt/main.cpp b/repos/gems/src/app/mixer_gui_qt/main.cpp index 322da6041..8556f867d 100644 --- a/repos/gems/src/app/mixer_gui_qt/main.cpp +++ b/repos/gems/src/app/mixer_gui_qt/main.cpp @@ -5,7 +5,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) Report_thread *report_thread; try { report_thread = new Report_thread(); } catch (...) { - PERR("Could not create Report_thread"); + Genode::error("Could not create Report_thread"); return -1; } diff --git a/repos/gems/src/app/mixer_gui_qt/main_window.cpp b/repos/gems/src/app/mixer_gui_qt/main_window.cpp index 86c5559b8..10988f394 100644 --- a/repos/gems/src/app/mixer_gui_qt/main_window.cpp +++ b/repos/gems/src/app/mixer_gui_qt/main_window.cpp @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -318,7 +318,7 @@ static int write_config(char const *file, char const *data, size_t length) QFile mixer_file(file); if (!mixer_file.open(QIODevice::WriteOnly)) { - PERR("could not open '%s'", file); + Genode::error("could not open '", file, "'"); return -1; } @@ -367,16 +367,16 @@ void Main_window::_update_config() }); if (_verbose) - PLOG("label: '%s' volume: %d muted: %d", c->label().string(), - combined ? vol : w->volume(), - combined ? muted : w->muted()); + Genode::log("label: '", c->label(), "' " + "volume: ", combined ? vol : w->volume(), " " + "muted: ", combined ? muted : w->muted()); } } }); }); xml_used = xml.used(); - } catch (...) { PWRN("could generate 'mixer.config'"); } + } catch (...) { Genode::warning("could generate 'mixer.config'"); } write_config(config_file, xml_data, xml_used); } @@ -411,7 +411,7 @@ void Main_window::_update_clients(Genode::Xml_node &channels) _layout->addWidget(c); resize(sizeHint()); - } catch (Channel::Invalid_channel) { PWRN("invalid channel node"); } + } catch (Channel::Invalid_channel) { Genode::warning("invalid channel node"); } }); client_registry()->remove_invalid(); @@ -455,7 +455,7 @@ Main_window::Main_window() _default_out_volume = node.attribute_value("out_volume", 0); _default_volume = node.attribute_value("volume", 0); _default_muted = node.attribute_value("muted", 1); - } catch (...) { PWRN("no node found, fallback is 'muted=1'"); } + } catch (...) { Genode::warning("no node found, fallback is 'muted=1'"); } } diff --git a/repos/gems/src/app/themed_decorator/main.cc b/repos/gems/src/app/themed_decorator/main.cc index 5cd637b8c..0bdfbb30a 100644 --- a/repos/gems/src/app/themed_decorator/main.cc +++ b/repos/gems/src/app/themed_decorator/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -129,9 +129,7 @@ struct Decorator::Main : Window_factory_base pointer.construct("pointer"); pointer->sigh(pointer_dispatcher); } catch (Genode::Rom_connection::Rom_connection_failed) { - PINF("pointer information unavailable"); - - PDBG("constructed=%d", pointer.constructed()); + Genode::log("pointer information unavailable"); } nitpicker.framebuffer()->sync_sigh(nitpicker_sync_dispatcher); diff --git a/repos/gems/src/app/themed_decorator/window.h b/repos/gems/src/app/themed_decorator/window.h index 402d48e85..bd85f4439 100644 --- a/repos/gems/src/app/themed_decorator/window.h +++ b/repos/gems/src/app/themed_decorator/window.h @@ -161,7 +161,7 @@ class Decorator::Window : public Window_base, public Animator::Item char buf[128]; Genode::snprintf(buf, sizeof(buf), "%d", id); - _nitpicker.enqueue(_handle, buf); + _nitpicker.enqueue(_handle, Genode::Cstring(buf)); } } diff --git a/repos/gems/src/lib/file/file.cc b/repos/gems/src/lib/file/file.cc index ac07a3dcd..b3f17b9ad 100644 --- a/repos/gems/src/lib/file/file.cc +++ b/repos/gems/src/lib/file/file.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* gems includes */ #include @@ -42,7 +42,7 @@ File::File(char const *name, Genode::Allocator &alloc) { int const fd = open(name, O_RDONLY); if (read(fd, _data, _file_size) < 0) { - PERR("reading from file \"%s\" failed (error %d)", name, errno); + Genode::error("reading from file \"", name, "\" failed (error ", errno, ")"); throw Reading_failed(); } close(fd); diff --git a/repos/gems/src/server/file_terminal/main.cc b/repos/gems/src/server/file_terminal/main.cc index 1e66b8c4e..9d68ced71 100644 --- a/repos/gems/src/server/file_terminal/main.cc +++ b/repos/gems/src/server/file_terminal/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -30,11 +30,6 @@ #include -static bool const verbose = false; - -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - class Open_file { private: @@ -73,7 +68,6 @@ class Open_file Open_file(const char *filename) : _fd(-1) { - PDBGV("open '%s'", filename); _fd = ::open(filename, O_CREAT|O_RDWR); if (_fd == -1) ::perror("open"); @@ -122,7 +116,7 @@ class Open_file void fill_read_buffer_and_notify_client() { if (_read_buf_bytes_used) { - PWRN("read buffer already in use"); + Genode::warning("read buffer already in use"); return; } @@ -196,7 +190,7 @@ namespace Terminal { /* write data to descriptor */ if (::write(fd(), _io_buffer.local_addr(), num_bytes) < 0) - PERR("write error, dropping data"); + Genode::error("write error, dropping data"); } Genode::Dataspace_capability _dataspace() @@ -241,10 +235,10 @@ namespace Terminal { Session_component(io_buffer_size, filename); } catch (Genode::Xml_node::Nonexistent_attribute) { - PERR("Missing \"filename\" attribute in policy definition"); + Genode::error("missing \"filename\" attribute in policy definition"); throw Genode::Root::Unavailable(); } catch (Genode::Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("invalid session request, no matching policy"); throw Genode::Root::Unavailable(); } } @@ -267,7 +261,7 @@ int main() { using namespace Genode; - Genode::printf("--- file terminal started ---\n"); + Genode::log("--- file terminal started ---"); /** * The stack needs to be that large because certain functions diff --git a/repos/gems/src/server/http_blk/http.cc b/repos/gems/src/server/http_blk/http.cc index 90890873c..012af6f0f 100644 --- a/repos/gems/src/server/http_blk/http.cc +++ b/repos/gems/src/server/http_blk/http.cc @@ -57,7 +57,7 @@ void Http::cmd_head() int length = snprintf(_http_buf, HTTP_BUF, http_templ, "HEAD", _path, _host); if (write(_fd, _http_buf, length) != length) { - error("Write error"); + error("cmd_head: write error"); throw Http::Socket_error(); } } @@ -67,12 +67,12 @@ void Http::connect() { _fd = socket(AF_INET, SOCK_STREAM, 0); if (_fd < 0) { - error("No socket avaiable"); + error("connect: no socket avaiable"); throw Http::Socket_error(); } if (::connect(_fd, _info->ai_addr, sizeof(*(_info->ai_addr))) < 0) { - error("Connect failed"); + error("connect: connect failed"); throw Http::Socket_error(); } } @@ -85,7 +85,7 @@ void Http::resolve_uri() { struct addrinfo *info; if (getaddrinfo(_host, _port, 0, &info)) { - error("Error: Host ", (const char*)_host, " not found"); + error("host ", Cstring(_host), " not found"); throw Http::Uri_error(); } @@ -102,14 +102,12 @@ Genode::size_t Http::read_header() if (!read(_fd, &_http_buf[i], 1)) throw Http::Socket_closed(); - /* DEBUG: Genode::printf("%c", _http_buf[i]); */ - if (i >= 3 && _http_buf[i - 3] == '\r' && _http_buf[i - 2] == '\n' && _http_buf[i - 1] == '\r' && _http_buf[i - 0] == '\n') header = false; if (++i >= HTTP_BUF) { - error("Buffer overflow"); + error("read_header: buffer overflow"); throw Http::Socket_error(); } } @@ -172,7 +170,7 @@ void Http::do_read(void * buf, size_t size) int part; if ((part = read(_fd, (void *)((addr_t)buf + buf_fill), size - buf_fill)) <= 0) { - error("Error: Reading data (", errno, ")"); + error("could not read data (", errno, ")"); throw Http::Socket_error(); } @@ -270,7 +268,7 @@ void Http::cmd_get(size_t file_offset, size_t size, addr_t buffer) } if (_http_ret != HTTP_SUCC_PARTIAL) { - error("Error: Server returned ", _http_ret); + error("cmd_get: server returned ", _http_ret); throw Http::Server_error(); } diff --git a/repos/gems/src/server/tcp_terminal/main.cc b/repos/gems/src/server/tcp_terminal/main.cc index 19d9691c6..51903ddec 100644 --- a/repos/gems/src/server/tcp_terminal/main.cc +++ b/repos/gems/src/server/tcp_terminal/main.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -84,7 +84,7 @@ class Open_socket : public Genode::List::Element { int listen_sd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (listen_sd == -1) { - PERR("socket creation failed"); + Genode::error("socket creation failed"); return -1; } @@ -94,16 +94,16 @@ class Open_socket : public Genode::List::Element sockaddr.sin_addr.s_addr = INADDR_ANY; if (bind(listen_sd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) { - PERR("bind to port %d failed", tcp_port); + Genode::error("bind to port ", tcp_port, " failed"); return -1; } if (listen(listen_sd, 1)) { - PERR("listen failed"); + Genode::error("listen failed"); return -1; } - Genode::printf("listening on port %d...\n", tcp_port); + Genode::log("listening on port ", tcp_port, "..."); return listen_sd; } @@ -160,7 +160,7 @@ class Open_socket : public Genode::List::Element _sd = accept(_listen_sd, &addr, &len); if (_sd != -1) - Genode::printf("connection established\n"); + Genode::log("connection established"); /* * Inform client about the finished initialization of the terminal @@ -184,7 +184,7 @@ class Open_socket : public Genode::List::Element void fill_read_buffer_and_notify_client() { if (_read_buf_bytes_used) { - PWRN("read buffer already in use"); + Genode::warning("read buffer already in use"); return; } @@ -440,7 +440,7 @@ namespace Terminal { /* write data to socket, assuming that it won't block */ if (::write(sd(), _io_buffer.local_addr(), num_bytes) < 0) - PERR("write error, dropping data"); + Genode::error("write error, dropping data"); } Genode::Dataspace_capability _dataspace() @@ -512,7 +512,7 @@ int main() { using namespace Genode; - Genode::printf("--- TCP terminal started ---\n"); + Genode::log("--- TCP terminal started ---"); /* initialize entry point that serves the root interface */ enum { STACK_SIZE = 4*4096 }; diff --git a/repos/gems/src/server/terminal/main.cc b/repos/gems/src/server/terminal/main.cc index 4242f3d6f..94025eb4a 100644 --- a/repos/gems/src/server/terminal/main.cc +++ b/repos/gems/src/server/terminal/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -187,7 +187,7 @@ static void convert_char_array_to_pixels(Cell_array *cell_array, if (cell_array->line_dirty(line)) { if (verbose) - Genode::printf("convert line %d\n", line); + Genode::log("convert line ", line); unsigned x = 0; for (unsigned column = 0; column < cell_array->num_cols(); column++) { @@ -303,7 +303,7 @@ namespace Terminal { Genode::Dataspace_capability _init_fb() { if (_fb_mode.format() != Framebuffer::Mode::RGB565) { - PERR("Color mode %d not supported", _fb_mode.format()); + Genode::error("color mode ", _fb_mode, " not supported"); return Genode::Dataspace_capability(); } @@ -344,10 +344,10 @@ namespace Terminal { { using namespace Genode; - printf("new terminal session:\n"); - printf(" framebuffer has %dx%d pixels\n", _fb_mode.width(), _fb_mode.height()); - printf(" character size is %dx%d pixels\n", _char_width, _char_height); - printf(" terminal size is %dx%d characters\n", _columns, _lines); + log("new terminal session:"); + log(" framebuffer has mode ", _fb_mode); + log(" character size is ", _char_width, "x", _char_height, " pixels"); + log(" terminal size is ", _columns, "x", _lines, " characters"); framebuffer->refresh(0, 0, _fb_mode.width(), _fb_mode.height()); @@ -418,8 +418,6 @@ namespace Terminal { unsigned char *src = _io_buffer.local_addr(); for (unsigned i = 0; i < num_bytes; i++) { - if (verbose) - Genode::printf("%c (%d)\n", src[i], (int)src[i]); /* submit character to sequence decoder */ _decoder.insert(src[i]); @@ -464,7 +462,7 @@ namespace Terminal { Session_component *_create_session(const char *args) { - Genode::printf("create terminal session\n"); + Genode::log("create terminal session"); /* * XXX read I/O buffer size from args @@ -506,7 +504,7 @@ int main(int, char **) { using namespace Genode; - PDBG("--- terminal service started ---"); + log("--- terminal service started ---"); static Framebuffer::Connection framebuffer; static Input::Connection input; @@ -567,8 +565,8 @@ int main(int, char **) static Font font(font_data); static Font_family font_family(font); - printf("cell size is %dx%d\n", (int)font_family.cell_width(), - (int)font_family.cell_height()); + log("cell size is ", (int)font_family.cell_width(), + "x", (int)font_family.cell_height()); static Terminal::Flush_callback_registry flush_callback_registry; diff --git a/repos/gems/src/server/terminal_mux/ncurses.cc b/repos/gems/src/server/terminal_mux/ncurses.cc index 23541ab3f..7e304a2f5 100644 --- a/repos/gems/src/server/terminal_mux/ncurses.cc +++ b/repos/gems/src/server/terminal_mux/ncurses.cc @@ -5,7 +5,7 @@ */ /* Genode includes */ -#include +#include #include /* libc and ncurses includes */ @@ -111,7 +111,7 @@ Ncurses::Ncurses() char const *device_name = "/dev/terminal"; int fd = open(device_name, O_RDWR); if (fd < 0) { - PERR("Error: could not open %s", device_name); + Genode::error("could not open ", device_name); return; } dup2(fd, 0); diff --git a/repos/gems/src/server/wm/decorator_nitpicker.h b/repos/gems/src/server/wm/decorator_nitpicker.h index 32e2120a2..05016f04d 100644 --- a/repos/gems/src/server/wm/decorator_nitpicker.h +++ b/repos/gems/src/server/wm/decorator_nitpicker.h @@ -431,7 +431,7 @@ struct Wm::Decorator_nitpicker_session : Genode::Rpc_object, _execute_command(_command_buffer.get(i)); } catch (...) { - PWRN("unhandled exception while processing command from decorator"); + Genode::warning("unhandled exception while processing command from decorator"); } } _nitpicker_session.execute(); diff --git a/repos/gems/src/server/wm/main.cc b/repos/gems/src/server/wm/main.cc index 5a2bfc90d..f5aad2829 100644 --- a/repos/gems/src/server/wm/main.cc +++ b/repos/gems/src/server/wm/main.cc @@ -86,7 +86,7 @@ struct Wm::Main } } catch (...) { - PWRN("no focus model available"); + Genode::warning("no focus model available"); } } diff --git a/repos/gems/src/server/wm/nitpicker.h b/repos/gems/src/server/wm/nitpicker.h index 255dde0d1..0373f21b8 100644 --- a/repos/gems/src/server/wm/nitpicker.h +++ b/repos/gems/src/server/wm/nitpicker.h @@ -877,7 +877,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object, _view_handle_registry.free(handle); } catch (View_handle_registry::Lookup_failed) { - PWRN("view lookup failed while releasing view handle"); + Genode::warning("view lookup failed while releasing view handle"); return; } } @@ -893,7 +893,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object, try { _execute_command(_command_buffer.get(i)); } catch (View_handle_registry::Lookup_failed) { - PWRN("view lookup failed during command execution"); } + Genode::warning("view lookup failed during command execution"); } } /* propagate window-list changes to the layouter */ @@ -1186,7 +1186,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object +#include #include #include @@ -42,8 +42,6 @@ class Static_character_screen : public Terminal::Character_screen void output(Terminal::Character c) { -// Genode::printf("output '%c'\n", c.ascii()); - if (c.ascii() > 0x10) _char_array.set(_cursor_pos, c); _cursor_pos.x++; @@ -52,7 +50,6 @@ class Static_character_screen : public Terminal::Character_screen _cursor_pos.y++; } if (_cursor_pos.y >= _boundary.height) { -// _char_array.newline(); _cursor_pos.y = _boundary.height - 1; } } @@ -134,7 +131,6 @@ class Static_character_screen : public Terminal::Character_screen void hpa(int x) { - PDBG("hpa %d", x); } void hts() @@ -227,7 +223,6 @@ class Static_character_screen : public Terminal::Character_screen void vpa(int y) { - PDBG("vpa %d", y); } }; @@ -236,7 +231,7 @@ void Static_character_screen::dump() const { using namespace Terminal; - Genode::printf("--- screen dump follows ---\n"); + Genode::log("--- screen dump follows ---"); Boundary const boundary = _char_array.boundary(); for (int y = 0; y < boundary.height; y++) { @@ -253,10 +248,10 @@ void Static_character_screen::dump() const } line[boundary.width] = 0; - Genode::printf("%s\n", line); + Genode::log(Genode::Cstring(line)); } - Genode::printf("--- end of screen dump ---\n"); + Genode::log("--- end of screen dump ---"); } diff --git a/repos/hello_tutorial/src/hello/server/main.cc b/repos/hello_tutorial/src/hello/server/main.cc index 9b0ae0783..afa8858ec 100644 --- a/repos/hello_tutorial/src/hello/server/main.cc +++ b/repos/hello_tutorial/src/hello/server/main.cc @@ -14,6 +14,7 @@ #include #include +#include #include #include #include diff --git a/repos/libports/include/libc-plugin/fd_alloc.h b/repos/libports/include/libc-plugin/fd_alloc.h index 77bcb0660..50d8821e0 100644 --- a/repos/libports/include/libc-plugin/fd_alloc.h +++ b/repos/libports/include/libc-plugin/fd_alloc.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include /* libc includes */ @@ -53,8 +53,8 @@ namespace Libc { size_t const path_size = ::strlen(newpath) + 1; char *buf = (char*)malloc(path_size); if (!buf) { - PERR("could not allocate path buffer for libc_fd %d%s", - libc_fd, libc_fd == ANY_FD ? " (any)" : ""); + Genode::error("could not allocate path buffer for libc_fd ", + libc_fd, libc_fd == ANY_FD ? " (any)" : ""); return; } ::memcpy(buf, newpath, path_size); diff --git a/repos/libports/ports/qt5.hash b/repos/libports/ports/qt5.hash index 723d9d3e8..e9cd58aa9 100644 --- a/repos/libports/ports/qt5.hash +++ b/repos/libports/ports/qt5.hash @@ -1 +1 @@ -2db8119ea245fc40501d00968f364e0092a7f090 +8c8f232dcaa82e015b4f25f4fa99e7c7eeecc128 diff --git a/repos/libports/run/ldso.run b/repos/libports/run/ldso.run index fac963a2f..8e7f3ea0e 100644 --- a/repos/libports/run/ldso.run +++ b/repos/libports/run/ldso.run @@ -74,7 +74,7 @@ compare_output_to { [init -> test-ldso] lib_1_local_3 12345676 [init -> test-ldso] lib_1_pod_1 8070604d [init -> test-ldso] Libc::read: -[init -> test-ldso] no plugin found for read(0) +[init -> test-ldso] Error: no plugin found for read(0) [init -> test-ldso] Libc::abs(-10): 10 [init -> test-ldso] [init -> test-ldso] Catch exceptions in program diff --git a/repos/libports/src/app/acpica/ac.h b/repos/libports/src/app/acpica/ac.h index 554218b4a..36b88c650 100644 --- a/repos/libports/src/app/acpica/ac.h +++ b/repos/libports/src/app/acpica/ac.h @@ -35,17 +35,16 @@ class Ac : Acpica::Callback { nullptr, &onoff, ACPI_TYPE_INTEGER); if (ACPI_FAILURE(res)) { - PDBG("failed - res=0x%x _PSR", res); + Genode::log("failed - res=", Genode::Hex(res), " _PSR"); return; } _ac_state = onoff.object.Integer.Value; _ac_count++; - PINF("%s - ac (%u)", - _ac_state == 0 ? "offline " : - _ac_state == 1 ? "online " : "unknown ", - value); + Genode::log(_ac_state == 0 ? "offline " : + _ac_state == 1 ? "online " : "unknown ", + " - ac (", value, ")"); if (_report) _report->ac_event(); @@ -58,12 +57,12 @@ class Ac : Acpica::Callback { ACPI_STATUS res = AcpiInstallNotifyHandler (ac, ACPI_DEVICE_NOTIFY, handler, obj); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' res=", Genode::Hex(res)); delete obj; return AE_OK; } - PINF("detected - ac"); + Genode::log("detected - ac"); handler(ac, 0, obj); diff --git a/repos/libports/src/app/acpica/ec.h b/repos/libports/src/app/acpica/ec.h index 239137aac..4998b472e 100644 --- a/repos/libports/src/app/acpica/ec.h +++ b/repos/libports/src/app/acpica/ec.h @@ -60,21 +60,23 @@ class Ec : Acpica::Callback { ACPI_GPE_EVENT_INFO * ev = AcpiEvGetGpeEventInfo(ec->gpe_block, gpe); if (!ev || !ec->ec_cmdsta || !ec->ec_data) { - PERR("unknown GPE 0x%x", gpe); + Genode::error("unknown GPE ", Genode::Hex(gpe)); return AE_OK; /* GPE is disabled and must be enabled explicitly */ } if ((ACPI_GPE_DISPATCH_TYPE (ev->Flags) != ACPI_GPE_DISPATCH_HANDLER) || !ev->Dispatch.Handler) { - PERR("unknown dispatch type, GPE 0x%x, flags=0x%x type=0x%x", - gpe, ev->Flags, ACPI_GPE_DISPATCH_TYPE (ev->Flags)); + Genode::error("unknown dispatch type, " + "GPE ", Genode::Hex(gpe), ", " + "flags=", Genode::Hex(ev->Flags), " " + "type=", Genode::Hex(ACPI_GPE_DISPATCH_TYPE(ev->Flags))); return AE_OK; /* GPE is disabled and must be enabled explicitly */ } State::access_t state = ec->ec_cmdsta->inb(ec->ec_port_cmdsta); if (!State::Sci_evt::get(state)) { - PERR("unknown status 0x%x", state); + Genode::error("unknown status ", Genode::Hex(state)); return ACPI_REENABLE_GPE; /* gpe is acked and re-enabled */ } @@ -90,8 +92,8 @@ class Ec : Acpica::Callback { state = ec->ec_cmdsta->inb(ec->ec_port_cmdsta); if (!ec->_report) - PINF("ec event - status 0x%x data 0x%x round=%u", state, - data, ++cnt); + Genode::log("ec event - status ", Genode::Hex(state), " " + "data ", Genode::Hex(data), " round=", ++cnt); } while (State::Out_ful::get(state)); if (ec->_report) { @@ -123,20 +125,14 @@ class Ec : Acpica::Callback { return AE_OK; if (resource->Type != ACPI_RESOURCE_TYPE_IO) { - PWRN("unknown resource type %u", resource->Type); + Genode::warning("unknown resource type ", (int)resource->Type); return AE_OK; } -/* - PDBG("TYPE IO: IoDecode 0x%x, alignment 0x%x, AddressLen 0x%x " - "min 0x%x max 0x%x", - resource->Data.Io.IoDecode, resource->Data.Io.Alignment, - resource->Data.Io.AddressLength, resource->Data.Io.Minimum, - resource->Data.Io.Maximum); -*/ + /* first port is data, second is status/cmd */ if (resource->Data.Io.AddressLength != 1) - PERR("unsupported address length of %u", - resource->Data.Io.AddressLength); + Genode::error("unsupported address length of ", + resource->Data.Io.AddressLength); if (!ec->ec_data) { ec->ec_port_data = resource->Data.Io.Minimum; @@ -146,7 +142,7 @@ class Ec : Acpica::Callback { ec->ec_port_cmdsta = resource->Data.Io.Minimum; ec->ec_cmdsta = new (Genode::env()->heap()) Genode::Io_port_connection(ec->ec_port_cmdsta, 1); } else - PERR("unknown io_port"); + Genode::error("unknown io_port"); return AE_OK; } @@ -161,7 +157,7 @@ class Ec : Acpica::Callback { unsigned char *result = reinterpret_cast(value); if (bytes * 8 != bitwidth) { - PERR("unsupport bit width of %u", bitwidth); + Genode::error("unsupport bit width of ", bitwidth); return AE_BAD_PARAMETER; } @@ -223,7 +219,8 @@ class Ec : Acpica::Callback { ACPI_STATUS res = AcpiWalkResources(ec, ACPI_STRING("_CRS"), Ec::detect_io_ports, ec_obj); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' _CRS res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _CRS " + "res=", Genode::Hex(res)); return AE_OK; } @@ -231,7 +228,8 @@ class Ec : Acpica::Callback { handler_ec, nullptr, ec_obj); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' spacehandler res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' spacehandler " + "res=", Genode::Hex(res)); return AE_OK; } @@ -239,7 +237,8 @@ class Ec : Acpica::Callback { res = AcpiEvaluateObjectTyped(ec, ACPI_STRING("_GPE"), nullptr, &sta, ACPI_TYPE_INTEGER); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' _STA res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _STA " + "res=", Genode::Hex(res)); return AE_OK; } @@ -248,7 +247,8 @@ class Ec : Acpica::Callback { /* if ec_obj->gpe_block stays null - it's GPE0/GPE1 */ res = AcpiGetGpeDevice(gpe_to_enable, &ec_obj->gpe_block); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' get_device res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' get_device " + "res=", Genode::Hex(res)); return AE_OK; } @@ -256,17 +256,19 @@ class Ec : Acpica::Callback { ACPI_GPE_LEVEL_TRIGGERED, handler_gpe, ec_obj); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' install_device res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' install_device " + "res=", Genode::Hex(res)); return AE_OK; } res = AcpiEnableGpe (ec_obj->gpe_block, gpe_to_enable); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' enable_gpe res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' enable_gpe " + "res=", Genode::Hex(res)); return AE_OK; } - PINF("detected - ec"); + Genode::log("detected - ec"); if (ec_obj->_report) ec_obj->_report->add_notify(ec_obj); diff --git a/repos/libports/src/app/acpica/lid.h b/repos/libports/src/app/acpica/lid.h index 1f9c8037a..a09bde0e1 100644 --- a/repos/libports/src/app/acpica/lid.h +++ b/repos/libports/src/app/acpica/lid.h @@ -35,13 +35,13 @@ class Lid : Acpica::Callback { nullptr, &onoff, ACPI_TYPE_INTEGER); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' res=0x%x _PSR", __func__, res); + Genode::error("failed - '", __func__, "' " + "res=", Genode::Hex(res), " _PSR"); return; } - PINF("%s - lid (%u)", - onoff.object.Integer.Value ? "open " : "closed ", - value); + Genode::log(onoff.object.Integer.Value ? "open " : "closed ", + " - lid (", value, ")"); _lid_state = onoff.object.Integer.Value; _lid_count++; @@ -57,12 +57,13 @@ class Lid : Acpica::Callback { ACPI_STATUS res = AcpiInstallNotifyHandler (lid, ACPI_DEVICE_NOTIFY, handler, obj); if (ACPI_FAILURE(res)) { - PDBG("failed - %s res=0x%x LID adapter", __func__, res); + Genode::log("failed - ", __func__, " " + "res=", Genode::Hex(res), " LID adapter"); delete obj; return AE_OK; } - PINF("detected - lid"); + Genode::log("detected - lid"); handler(lid, 0, obj); diff --git a/repos/libports/src/app/acpica/os.cc b/repos/libports/src/app/acpica/os.cc index 9215bc857..a398a9af2 100644 --- a/repos/libports/src/app/acpica/os.cc +++ b/repos/libports/src/app/acpica/os.cc @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -53,56 +53,56 @@ static void init_acpica(Acpica::Reportstate *report) { ACPI_STATUS status = AcpiInitializeSubsystem(); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiInitializeSubsystem failed, status=", status); return; } status = AcpiInitializeTables(nullptr, 0, true); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiInitializeTables failed, status=", status); return; } status = AcpiLoadTables(); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiLoadTables failed, status=", status); return; } status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiEnableSubsystem failed, status=", status); return; } status = AcpiInitializeObjects(ACPI_NO_DEVICE_INIT); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiInitializeObjects (no devices) failed, status=", status); return; } /* Embedded controller */ status = AcpiGetDevices(ACPI_STRING("PNP0C09"), Ec::detect, report, nullptr); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiGetDevices failed, status=", status); return; } status = AcpiInitializeObjects(ACPI_FULL_INITIALIZATION); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiInitializeObjects (full init) failed, status=", status); return; } status = AcpiUpdateAllGpes(); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiUpdateAllGpes failed, status=", status); return; } status = AcpiEnableAllRuntimeGpes(); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiEnableAllRuntimeGpes failed, status=", status); return; } @@ -113,33 +113,33 @@ static void init_acpica(Acpica::Reportstate *report) { Fixed::handle_power_button, acpi_fixed); if (status != AE_OK) - PINF("failed - power button registration - error=%u", status); + Genode::log("failed - power button registration - error=", status); status = AcpiInstallFixedEventHandler(ACPI_EVENT_SLEEP_BUTTON, Fixed::handle_sleep_button, acpi_fixed); if (status != AE_OK) - PINF("failed - sleep button registration - error=%u", status); + Genode::log("failed - sleep button registration - error=", status); /* AC Adapters and Power Source Objects */ status = AcpiGetDevices(ACPI_STRING("ACPI0003"), Ac::detect, report, nullptr); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiGetDevices (ACPI0003) failed, status=", status); return; } /* Smart battery control devices */ status = AcpiGetDevices(ACPI_STRING("PNP0C0A"), Battery::detect, report, nullptr); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiGetDevices (PNP0C0A) failed, status=", status); return; } /* LID device */ status = AcpiGetDevices(ACPI_STRING("PNP0C0D"), Lid::detect, report, nullptr); if (status != AE_OK) { - PERR("%s:%u failed %u", __func__, __LINE__, status); + Genode::error("AcpiGetDevices (PNP0C0D) failed, status=", status); return; } } @@ -177,7 +177,8 @@ struct Acpica::Statechange if (_enable_poweroff && state == "poweroff") { ACPI_STATUS res0 = AcpiEnterSleepStatePrep(5); ACPI_STATUS res1 = AcpiEnterSleepState(5); - PERR("system poweroff failed - res=0x%x,0x%x", res0, res1); + Genode::error("system poweroff failed - " + "res=", Genode::Hex(res0), ",", Genode::Hex(res1)); return; } @@ -188,10 +189,11 @@ struct Acpica::Statechange } catch (...) { } Genode::uint64_t const space_addr = AcpiGbl_FADT.ResetRegister.Address; - PERR("system reset failed - err=%x, reset=%u, spaceid=0x%x, " - "addr=0x%llx", res, - !!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER), - AcpiGbl_FADT.ResetRegister.SpaceId, space_addr); + Genode::error("system reset failed - " + "err=", res, " " + "reset=", !!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER), " " + "spaceid=", Genode::Hex(AcpiGbl_FADT.ResetRegister.SpaceId), " " + "addr=", Genode::Hex(space_addr)); } } }; @@ -232,13 +234,13 @@ struct Acpica::Main { /* setup IRQ */ if (!irq_handler.handler) { - PWRN("no IRQ handling available"); + Genode::warning("no IRQ handling available"); return; } _sci_conn.construct(irq_handler.irq); - PINF("SCI IRQ: %u", irq_handler.irq); + Genode::log("SCI IRQ: ", irq_handler.irq); _sci_conn->sigh(_sci_irq); _sci_conn->ack_irq(); diff --git a/repos/libports/src/app/acpica/sb.h b/repos/libports/src/app/acpica/sb.h index 27fd9d3fb..b8a75590b 100644 --- a/repos/libports/src/app/acpica/sb.h +++ b/repos/libports/src/app/acpica/sb.h @@ -40,7 +40,8 @@ class Battery : Acpica::Callback { ACPI_STATUS res = AcpiInstallNotifyHandler (sb, ACPI_DEVICE_NOTIFY, handler, dev_obj); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' " + "res=", Genode::Hex(res)); delete dev_obj; return AE_OK; } @@ -48,7 +49,8 @@ class Battery : Acpica::Callback { Acpica::Buffer battery_name; AcpiGetName (sb, ACPI_SINGLE_NAME, &battery_name); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' battery name res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' battery name " + "res=", Genode::Hex(res)); return AE_OK; } @@ -56,7 +58,8 @@ class Battery : Acpica::Callback { res = AcpiEvaluateObjectTyped(sb, ACPI_STRING("_STA"), nullptr, &sta, ACPI_TYPE_INTEGER); if (ACPI_FAILURE(res)) { - PERR("failed - '%s' _STA res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _STA " + "res=", Genode::Hex(res)); return AE_OK; } @@ -67,7 +70,8 @@ class Battery : Acpica::Callback { ACPI_TYPE_PACKAGE); ACPI_OBJECT * obj = reinterpret_cast(battery.object); if (ACPI_FAILURE(res) || !obj) { - PERR("failed - '%s' _BIF res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _BIF " + "res=", Genode::Hex(res)); return AE_OK; } @@ -80,20 +84,23 @@ class Battery : Acpica::Callback { obj->Package.Elements[10].Type != ACPI_TYPE_STRING || obj->Package.Elements[9].Type != ACPI_TYPE_STRING) { - PINF("detected - battery '%s' - unknown state (0x%llx%s)", - battery_name.object, val, - val & ACPI_STA_BATTERY_PRESENT ? "" : "(not present)"); + Genode::log("detected - battery " + "'", Genode::Cstring(battery_name.object), "' - " + "unknown state (", Genode::Hex(val), + val & ACPI_STA_BATTERY_PRESENT ? "" : "(not present)", + ")"); return AE_OK; } - PINF("detected - battery '%s' type='%s' OEM='%s' state=0x%llx%s " - "model='%s' serial='%s'", - battery_name.object, - obj->Package.Elements[11].String.Pointer, - obj->Package.Elements[12].String.Pointer, - val, val & ACPI_STA_BATTERY_PRESENT ? "" : "(not present)", - obj->Package.Elements[10].String.Pointer, - obj->Package.Elements[9].String.Pointer); + using Genode::Cstring; + Genode::log("detected - battery " + "'", Cstring(battery_name.object), "' " + "type='", Cstring(obj->Package.Elements[11].String.Pointer), "' " + "OEM='", Cstring(obj->Package.Elements[12].String.Pointer), "' " + "state=", Genode::Hex(val), + val & ACPI_STA_BATTERY_PRESENT ? "" : "(not present)", " " + "model='", Cstring(obj->Package.Elements[10].String.Pointer), "' " + "serial='", Cstring(obj->Package.Elements[9].String.Pointer), "'"); return AE_OK; } @@ -113,7 +120,7 @@ class Battery : Acpica::Callback { ACPI_TYPE_PACKAGE); ACPI_OBJECT * obj = reinterpret_cast(battery.object); if (ACPI_FAILURE(res) || !obj || obj->Package.Count != 13) { - PERR("failed - '%s' _BIF res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _BIF res=", Genode::Hex(res)); return; } @@ -179,7 +186,7 @@ class Battery : Acpica::Callback { ACPI_OBJECT * obj = reinterpret_cast(dynamic.object); if (ACPI_FAILURE(res) || !obj || obj->Package.Count != 4) { - PERR("failed - '%s' _BST res=0x%x", __func__, res); + Genode::error("failed - '", __func__, "' _BST res=", Genode::Hex(res)); return; } diff --git a/repos/libports/src/app/mupdf/main.cc b/repos/libports/src/app/mupdf/main.cc index 77a7d5d25..7843f4a30 100644 --- a/repos/libports/src/app/mupdf/main.cc +++ b/repos/libports/src/app/mupdf/main.cc @@ -129,10 +129,8 @@ class Pdf_view mode(Framebuffer::Connection::mode()), base(Genode::env()->rm_session()->attach(dataspace())) { - PDBG("Framebuffer is %dx%d\n", mode.width(), mode.height()); - if (mode.format() != Framebuffer::Mode::RGB565) { - PERR("Color modes other than RGB565 are not supported. Exiting."); + Genode::error("Color modes other than RGB565 are not supported. Exiting."); throw Non_supported_framebuffer_mode(); } } @@ -160,14 +158,14 @@ class Pdf_view int fd = open(file_name, O_BINARY | O_RDONLY, 0666); if (fd < 0) { - PERR("Could not open input file \"%s\", Exiting.", file_name); + Genode::error("Could not open input file \"", file_name, "\", Exiting."); throw Invalid_input_file_name(); } pdfapp_open(&_pdfapp, (char *)file_name, fd, 0); if (_pdfapp.image->n != 4) { - PERR("Unexpected color depth, expected 4, got %d, Exiting.", - _pdfapp.image->n); + Genode::error("Unexpected color depth, expected 4, got ", + _pdfapp.image->n, ", Exiting."); throw Unexpected_document_color_depth(); } } @@ -214,7 +212,6 @@ extern "C" void _sigprocmask() void winrepaint(pdfapp_t *pdfapp) { - PDBG("called"); Pdf_view *pdf_view = (Pdf_view *)pdfapp->userdata; pdf_view->show(); } @@ -222,63 +219,63 @@ void winrepaint(pdfapp_t *pdfapp) void winrepaintsearch(pdfapp_t *) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } void wincursor(pdfapp_t *, int curs) { - PDBG("curs=%d - not implemented", curs); + Genode::warning(__func__, " curs=%d - not implemented", curs); } void winerror(pdfapp_t *, fz_error error) { - PDBG("error=%d", error); + Genode::error("winerror: error=", error); Genode::sleep_forever(); } void winwarn(pdfapp_t *, char *msg) { - PWRN("MuPDF: %s", msg); + Genode::warning("MuPDF: ", Genode::Cstring(msg)); } void winhelp(pdfapp_t *) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } char *winpassword(pdfapp_t *, char *) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); return NULL; } void winclose(pdfapp_t *app) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } void winreloadfile(pdfapp_t *) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } void wintitle(pdfapp_t *app, char *s) { - PDBG("s=\"%s\" - not implemented", s); + Genode::warning(__func__, " not implemented"); } void winresize(pdfapp_t *app, int w, int h) { - PDBG("not implemented, w=%d, h=%d", w, h); + Genode::warning(__func__, " not implemented"); } @@ -329,8 +326,6 @@ int main(int, char **) if (ev.type() == Input::Event::PRESS && key_cnt == 1) { - PDBG("key %d pressed", ev.code()); - int const ascii = keycode_to_ascii(ev.code()); if (ascii) pdf_view.handle_key(ascii); diff --git a/repos/libports/src/app/qt5/qt_avplay/main_window.h b/repos/libports/src/app/qt5/qt_avplay/main_window.h index 0b10b58cd..bc256fc2e 100644 --- a/repos/libports/src/app/qt5/qt_avplay/main_window.h +++ b/repos/libports/src/app/qt5/qt_avplay/main_window.h @@ -53,7 +53,7 @@ class Main_window : public Compound_widget Genode::config()->xml_node().sub_node("mediafile") .attribute("name").value(buf, sizeof(buf)); } catch(...) { - PWRN("no config node found, using \"mediafile\""); + Genode::warning("no config node found, using \"mediafile\""); } } } _mediafile_name; diff --git a/repos/libports/src/drivers/framebuffer/vesa/framebuffer.cc b/repos/libports/src/drivers/framebuffer/vesa/framebuffer.cc index d1d1404a8..96ebf4658 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/framebuffer.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/framebuffer.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -54,7 +54,7 @@ static uint16_t get_vesa_mode(mb_vbe_ctrl_t *ctrl_info, mb_vbe_mode_t *mode_info uint16_t ret = 0; if (verbose) - printf("Supported mode list\n"); + log("Supported mode list"); /* * The virtual address of the ctrl_info mapping may change on x86_cmd @@ -70,9 +70,10 @@ static uint16_t get_vesa_mode(mb_vbe_ctrl_t *ctrl_info, mb_vbe_mode_t *mode_info continue; if (verbose) - printf(" 0x%03x %ux%u@%u\n", *MODE_PTR(off), mode_info->x_resolution, - mode_info->y_resolution, - mode_info->bits_per_pixel); + log(" ", Hex((short)*MODE_PTR(off), Hex::PREFIX, Hex::PAD), " ", + (unsigned)mode_info->x_resolution, "x", + (unsigned)mode_info->y_resolution, "@", + (unsigned)mode_info->bits_per_pixel); if (choose_highest_resolution_mode) { if ((mode_info->bits_per_pixel == depth) && @@ -118,7 +119,7 @@ static uint16_t get_vesa_mode(mb_vbe_ctrl_t *ctrl_info, mb_vbe_mode_t *mode_info return ret; if (verbose) - PWRN("Searching in default vesa modes"); + warning("Searching in default vesa modes"); if (choose_highest_resolution_mode) { /* @@ -163,7 +164,7 @@ int Framebuffer_drv::map_io_mem(addr_t base, size_t size, bool write_combined, return -3; } - PDBG("fb mapped to %p", *out_addr); + log("fb mapped to ", *out_addr); if (out_io_ds) *out_io_ds = io_ds; @@ -191,13 +192,13 @@ int Framebuffer_drv::set_mode(unsigned long &width, unsigned long &height, /* retrieve controller information */ if (X86emu::x86emu_cmd(VBE_CONTROL_FUNC, 0, 0, VESA_CTRL_OFFS) != VBE_SUPPORTED) { - PWRN("VBE Bios not present"); + warning("VBE Bios not present"); return -1; } /* retrieve vesa mode hex value */ if (!(vesa_mode = get_vesa_mode(ctrl_info, mode_info, width, height, mode, verbose))) { - PWRN("graphics mode %lux%lu@%lu not found", width, height, mode); + warning("graphics mode ", width, "x", height, "@", mode, " not found"); /* print available modes */ get_vesa_mode(ctrl_info, mode_info, width, height, mode, true); return -2; @@ -209,12 +210,12 @@ int Framebuffer_drv::set_mode(unsigned long &width, unsigned long &height, /* determine VBE version and OEM string */ oem_string = X86emu::virt_addr(to_phys(ctrl_info->oem_string)); - printf("Found: VESA BIOS version %d.%d\nOEM: %s\n", - ctrl_info->version >> 8, ctrl_info->version & 0xFF, - ctrl_info->oem_string ? oem_string : "[unknown]"); + log("Found: VESA BIOS version ", + ctrl_info->version >> 8, ".", ctrl_info->version & 0xFF, "\n" + "OEM: ", Cstring(ctrl_info->oem_string ? oem_string : "[unknown]")); if (ctrl_info->version < 0x200) { - PWRN("VESA Bios version 2.0 or later required"); + warning("VESA Bios version 2.0 or later required"); return -3; } @@ -223,7 +224,7 @@ int Framebuffer_drv::set_mode(unsigned long &width, unsigned long &height, * FRAME BUFFER (0x80) bits */ if (X86emu::x86emu_cmd(VBE_INFO_FUNC, 0, vesa_mode, VESA_MODE_OFFS) != VBE_SUPPORTED || (mode_info->mode_attributes & 0x91) != 0x91) { - PWRN("graphics mode %lux%lu@%lu not supported", width, height, mode); + warning("graphics mode ", width, "x", height, "@", mode, " not supported"); /* print available modes */ get_vesa_mode(ctrl_info, mode_info, width, height, mode, true); return -4; @@ -231,7 +232,7 @@ int Framebuffer_drv::set_mode(unsigned long &width, unsigned long &height, /* set mode */ if ((X86emu::x86emu_cmd(VBE_MODE_FUNC, vesa_mode) & 0xFF00) != VBE_SUCCESS) { - PDBG("VBE SET error"); + error("VBE SET error"); return -5; } @@ -240,9 +241,8 @@ int Framebuffer_drv::set_mode(unsigned long &width, unsigned long &height, if (!io_mem_cap.valid()) { X86emu::x86emu_cmd(VBE_INFO_FUNC, 0, vesa_mode, VESA_MODE_OFFS); - printf("Found: physical frame buffer at 0x%08x size: 0x%08x\n", - mode_info->phys_base, - ctrl_info->total_memory << 16); + log("Found: physical frame buffer at ", Hex(mode_info->phys_base), " " + "size: ", ctrl_info->total_memory << 16); map_io_mem(mode_info->phys_base, ctrl_info->total_memory << 16, true, &fb, 0, &io_mem_cap); } diff --git a/repos/libports/src/drivers/framebuffer/vesa/hw_emul.cc b/repos/libports/src/drivers/framebuffer/vesa/hw_emul.cc index 05e90a354..59cd23319 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/hw_emul.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/hw_emul.cc @@ -18,7 +18,7 @@ */ #include -#include +#include #include "hw_emul.h" @@ -38,6 +38,29 @@ enum { PCI_DATA_REG = 0xcfc }; + +/** + * Helper for the formatted output of a (bus, device, function) triple + */ +struct Devfn +{ + unsigned short devfn; + + explicit Devfn(unsigned short devfn) : devfn(devfn) { } + + void print(Genode::Output &out) const + { + unsigned char const bus = devfn >> 8, + dev = (devfn >> 3) & 0x1f, + fn = devfn & 0x7; + + Genode::print(out, Hex(bus, Hex::OMIT_PREFIX, Hex::PAD), ":", + Hex(dev, Hex::OMIT_PREFIX, Hex::PAD), ".", + Hex(fn, Hex::OMIT_PREFIX)); + } +}; + + class Pci_card { private: @@ -73,7 +96,7 @@ class Pci_card } if (!device_cap.valid()) { - PERR("PCI VGA card not found. Sleeping..."); + Genode::error("PCI VGA card not found. Sleeping..."); sleep_forever(); } @@ -90,11 +113,11 @@ class Pci_card _devfn = bus << 8 | dev << 3 | fn; if (verbose) - PDBG("Found PCI VGA at %x:%x.%x", bus, dev, fn); + Genode::log("Found PCI VGA at ", Devfn(_devfn)); } - Platform::Device_client &device() { return _device; } - unsigned short devfn() const { return _devfn; } + Platform::Device_client &device() { return _device; } + unsigned short devfn() const { return _devfn; } }; @@ -124,15 +147,14 @@ static bool handle_pci_port_write(unsigned short port, T val) */ { if (sizeof(T) != 4) { - PWRN("writing with size %zx not supported", sizeof(T)); + warning("writing with size ", sizeof(T), " not supported", sizeof(T)); return true; } - unsigned devfn = (val >> 8) & 0xffff; + unsigned const devfn = (val >> 8) & 0xffff; if (devfn != pci_card()->devfn()) { if (verbose) - PWRN("accessing unknown PCI device %02x:%02x.%x", - devfn >> 8, (devfn >> 3) & 0x1f, devfn & 0x7); + warning("accessing unknown PCI device ", Devfn(devfn)); pci_cfg_addr_valid = false; return true; } @@ -145,7 +167,7 @@ static bool handle_pci_port_write(unsigned short port, T val) } case PCI_DATA_REG: - PWRN("writing data register not supported (value=0x%x)", (int)val); + warning("writing data register not supported (value=", Hex(val), ")"); return true; default: @@ -203,7 +225,7 @@ static bool handle_pci_port_read(unsigned short port, T *val) unsigned bar = (pci_cfg_addr - 0x10) / 4; Platform::Device::Resource res = pci_card()->device().resource(bar); if (res.type() == Platform::Device::Resource::INVALID) { - PWRN("requested PCI resource 0x%x invalid", bar); + warning("requested PCI resource ", bar, " invalid"); *val = 0; return true; } @@ -213,7 +235,7 @@ static bool handle_pci_port_read(unsigned short port, T *val) } default: - PWRN("unexpected configuration address 0x%x", pci_cfg_addr); + warning("unexpected configuration address ", Hex(pci_cfg_addr)); return true; } diff --git a/repos/libports/src/drivers/framebuffer/vesa/ifx86emu.cc b/repos/libports/src/drivers/framebuffer/vesa/ifx86emu.cc index 5d12bf0de..7727d5e37 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/ifx86emu.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/ifx86emu.cc @@ -12,6 +12,7 @@ * under the terms of the GNU General Public License version 2. */ +#include #include #include #include @@ -120,7 +121,7 @@ class Region : public Avl_node if (child(LEFT)) child(LEFT)->print_regions(); - printf(" [%08lx,%08lx)\n", _base, _base + _size); + log(" ", Hex_range(_base, _size)); if (child(RIGHT)) child(RIGHT)->print_regions(); @@ -181,7 +182,8 @@ class Region_database : public Avl_tree insert(region); return region; } catch (...) { - PERR("Access to I/O region [%08lx,%08lx) denied", beg, end); + Genode::error("access to I/O region ", + Hex_range(beg, end - beg), " denied"); return 0; } } @@ -202,17 +204,23 @@ class Port_region : public Region, public Io_port_connection { public: + void print(Genode::Output &out) const + { + unsigned const beg = base(), end = beg + size(); + Genode::print(out, Hex_range(beg, end - beg)); + } + Port_region(unsigned short port_base, size_t port_size) : Region(port_base, port_size), Io_port_connection(port_base, port_size) { if (verbose) - PLOG("add port [%04lx,%04lx)", base(), base() + size()); + Genode::log("add port ", *this); } ~Port_region() { if (verbose) - PLOG("del port [%04lx,%04lx)", base(), base() + size()); + Genode::log("del port ", *this); } }; @@ -253,17 +261,23 @@ class Mem_region : public Region public: + void print(Genode::Output &out) const + { + addr_t const beg = base(), end = beg + size(); + Genode::print(out, Hex_range(beg, end - beg)); + } + Mem_region(addr_t mem_base, size_t mem_size) : Region(mem_base, mem_size), _ds(mem_base, mem_size) { if (verbose) - PLOG("add mem [%08lx,%08lx) @ %p", base(), base() + size(), _ds.local_addr()); + Genode::log("add mem ", *this, " @ ", _ds.local_addr()); } ~Mem_region() { if (verbose) - PLOG("del mem [%08lx,%08lx)", base(), base() + size()); + Genode::log("del mem ", *this); } template @@ -289,7 +303,7 @@ static int map_code_area(void) /* map page0 */ if ((err = Framebuffer_drv::map_io_mem(0x0, PAGESIZE, false, &dummy))) { - PERR("Could not map page zero"); + Genode::error("could not map page zero"); return err; } x86_mem.bios_addr(dummy); @@ -300,7 +314,7 @@ static int map_code_area(void) dummy = ram_ds.local_addr(); x86_mem.data_addr(dummy); } catch (...) { - PERR("Could not allocate dataspace for code"); + Genode::error("could not allocate dataspace for code"); return -1; } @@ -322,22 +336,21 @@ static int map_code_area(void) template static T X86API read(X86emu::u32 addr) { - /* - * Access the last byte of the T value, before actually reading the value. - * - * If the value of the address is crossing the current region boundary, - * the region behind the boundary will be allocated. Both regions will be - * merged and can be attached to a different virtual address then when - * only accessing the first bytes of the value. - */ + /* + * Access the last byte of the T value, before actually reading the value. + * + * If the value of the address is crossing the current region boundary, + * the region behind the boundary will be allocated. Both regions will be + * merged and can be attached to a different virtual address then when + * only accessing the first bytes of the value. + */ T * ret = X86emu::virt_addr(addr + sizeof(T) - 1); ret = X86emu::virt_addr(addr); if (verbose_mem) { unsigned v = *ret; - PLOG(" io_mem: read [%p,%p) val 0x%ux", - reinterpret_cast(addr), - reinterpret_cast(addr + sizeof(T)), v); + Genode::log(" io_mem: read ", + Hex_range(addr, sizeof(T)), ", val=", Hex(v)); } return *ret; @@ -353,9 +366,8 @@ static void X86API write(X86emu::u32 addr, T val) if (verbose_mem) { unsigned v = val; - PLOG(" io_mem: write [%p,%p) val 0x%ux", - reinterpret_cast(addr), - reinterpret_cast(addr + sizeof(T)), v); + Genode::log(" io_mem: write ", + Hex_range(addr, sizeof(T)), ", val=", Hex(v)); } } @@ -396,8 +408,7 @@ static T X86API inx(X86emu::X86EMU_pioAddr addr) if (verbose_port) { unsigned v = ret; - PLOG("io_port: read [%04ux,%04zx) val 0x%ux", (unsigned short)addr, - addr + sizeof(T), v); + Genode::log("io_port: read ", *region, " value=", Hex(v)); } return ret; @@ -418,8 +429,7 @@ static void X86API outx(X86emu::X86EMU_pioAddr addr, T val) if (verbose_port) { unsigned v = val; - PLOG("io_port: write [%04ux,%04zx) val 0x%ux", (unsigned short)addr, - addr + sizeof(T), v); + Genode::log("io_port: write ", *region, " value=", Hex(v)); } switch (sizeof(T)) { @@ -473,7 +483,7 @@ TYPE * X86emu::virt_addr(ADDR_TYPE addr) return region->virt_addr(local_addr); else { - PWRN("Invalid address 0x%08lx", local_addr); + Genode::warning("invalid address ", Hex(local_addr)); local_addr = 0; } @@ -518,10 +528,10 @@ int X86emu::init(void) return -1; if (verbose) { - PDBG("--- x86 bios area is [0x%lx - 0x%lx) ---", - x86_mem.bios_addr(), x86_mem.bios_addr() + PAGESIZE); - PDBG("--- x86 data area is [0x%lx - 0x%lx) ---", - x86_mem.data_addr(), x86_mem.data_addr() + CODESIZE); + log("--- x86 bios area is ", + Hex_range(x86_mem.bios_addr(), PAGESIZE), " ---"); + log("--- x86 data area is ", + Hex_range(x86_mem.data_addr(), CODESIZE), " ---"); } X86emu::M.x86.debug = 0; @@ -533,10 +543,10 @@ int X86emu::init(void) void X86emu::print_regions() { - printf("I/O port regions:\n"); + log("I/O port regions:"); port_region_db.print_regions(); - printf("I/O memory regions:\n"); + log("I/O memory regions:"); mem_region_db.print_regions(); } diff --git a/repos/libports/src/drivers/framebuffer/vesa/main.cc b/repos/libports/src/drivers/framebuffer/vesa/main.cc index e9c8dbf7d..9090cb05b 100644 --- a/repos/libports/src/drivers/framebuffer/vesa/main.cc +++ b/repos/libports/src/drivers/framebuffer/vesa/main.cc @@ -126,17 +126,16 @@ namespace Framebuffer { if (!_buffered) return; if (scr_mode != 16) { - PWRN("buffered mode not supported for mode %d", (int)scr_mode); + Genode::warning("buffered mode not supported for mode ", (int)scr_mode); _buffered = false; } size_t buf_size = scr_width*scr_height*scr_mode/8; try { _bb_ds = Genode::env()->ram_session()->alloc(buf_size); } catch (...) { - PWRN("could not allocate back buffer, disabled buffered output"); + Genode::warning("could not allocate back buffer, disabled buffered output"); _buffered = false; } - PDBG("use buf size %zd", buf_size); if (_buffered && _bb_ds.valid()) { _bb_addr = Genode::env()->rm_session()->attach(_bb_ds); @@ -144,7 +143,7 @@ namespace Framebuffer { } if (_buffered) - PINF("using buffered output"); + Genode::log("using buffered output"); } /** @@ -207,12 +206,12 @@ namespace Framebuffer { bool buffered = config_attribute("buffered"); if (Framebuffer_drv::set_mode(scr_width, scr_height, scr_mode) != 0) { - PWRN("Could not set vesa mode %lux%lu@%lu", scr_width, scr_height, - scr_mode); + Genode::warning("Could not set vesa mode ", + scr_width, "x", scr_height, "@", scr_mode); throw Root::Invalid_args(); } - printf("Using video mode: %lu x %lu x %lu\n", scr_width, scr_height, scr_mode); + Genode::log("using video mode: ", scr_width, "x", scr_height, "@", scr_mode); return new (md_alloc()) Session_component(scr_width, scr_height, scr_mode, Framebuffer_drv::hw_framebuffer(), @@ -239,7 +238,7 @@ int main(int argc, char **argv) /* init driver back end */ if (Framebuffer_drv::init()) { - PERR("H/W driver init failed"); + Genode::error("H/W driver init failed"); return 3; } diff --git a/repos/libports/src/lib/acpica/iomem.cc b/repos/libports/src/lib/acpica/iomem.cc index e1f569e96..df984920b 100644 --- a/repos/libports/src/lib/acpica/iomem.cc +++ b/repos/libports/src/lib/acpica/iomem.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -25,7 +25,7 @@ extern "C" { #define FAIL(retval) \ { \ - PERR("%s:%u called - dead", __func__, __LINE__); \ + Genode::error(__func__, ":", __LINE__, " called - dead"); \ Genode::Lock lock; \ while (1) lock.lock(); \ return retval; \ diff --git a/repos/libports/src/lib/acpica/osl.cc b/repos/libports/src/lib/acpica/osl.cc index 15f5b6c6d..40a047496 100644 --- a/repos/libports/src/lib/acpica/osl.cc +++ b/repos/libports/src/lib/acpica/osl.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -25,7 +25,7 @@ extern "C" { #define FAIL(retval) \ { \ - PERR("%s:%u called - dead", __func__, __LINE__); \ + Genode::error(__func__, ":", __LINE__, " called - dead"); \ Genode::Lock lock; \ while (1) lock.lock(); \ return retval; \ @@ -46,7 +46,7 @@ void * AcpiOsAllocate (ACPI_SIZE size) { void AcpiOsFree (void *ptr) { if (Genode::env()->heap()->need_size_for_free()) - PWRN("%s called - warning - ptr=%p", __func__, ptr); + Genode::warning(__func__, " called - warning - ptr=", ptr); Genode::env()->heap()->free(ptr, 0); } @@ -70,7 +70,7 @@ void AcpiOsReleaseLock (ACPI_SPINLOCK h, ACPI_CPU_FLAGS flags) Genode::Lock *lock = reinterpret_cast(h); if (flags != AE_OK) - PWRN("warning - unknown flags in %s", __func__); + Genode::warning("warning - unknown flags in ", __func__); lock->unlock(); @@ -226,7 +226,7 @@ ACPI_STATUS AcpiOsExecute(ACPI_EXECUTE_TYPE type, ACPI_OSD_EXEC_CALLBACK func, deferred[i].context = context; return AE_OK; } - PERR("Queue full for deferred handlers"); + Genode::error("queue full for deferred handlers"); return AE_BAD_PARAMETER; } @@ -245,7 +245,7 @@ void AcpiOsWaitEventsComplete() void AcpiOsSleep (UINT64 sleep_ms) { - PDBG("%s %llu ms", __func__, sleep_ms); + Genode::log(__func__, " ", sleep_ms, " ms"); static Timer::Connection conn; conn.msleep(sleep_ms); diff --git a/repos/libports/src/lib/acpica/pci.cc b/repos/libports/src/lib/acpica/pci.cc index e370ffaa2..bff08e3d7 100644 --- a/repos/libports/src/lib/acpica/pci.cc +++ b/repos/libports/src/lib/acpica/pci.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -22,6 +22,26 @@ extern "C" { } +/** + * Utility for the formatted output of a (bus, device, function) triple + */ +struct Bdf +{ + unsigned char const bus, dev, fn; + + Bdf(unsigned char bus, unsigned char dev, unsigned char fn) + : bus(bus), dev(dev), fn(fn) { } + + void print(Genode::Output &out) const + { + using Genode::Hex; + Genode::print(out, Hex(bus, Hex::OMIT_PREFIX), ":", + Hex(dev, Hex::OMIT_PREFIX), ".", + Hex(fn, Hex::OMIT_PREFIX), " "); + } +}; + + static Platform::Client & platform() { static bool connected = false; @@ -44,15 +64,15 @@ static Platform::Client & platform() ACPI_STATUS AcpiOsInitialize (void) { /* acpi_drv uses IOMEM concurrently to us - wait until it is done */ - PINF("wait for platform drv"); + Genode::log("wait for platform drv"); try { platform(); } catch (...) { - PERR("did not get Platform connection"); + Genode::error("did not get Platform connection"); Genode::Lock lock(Genode::Lock::LOCKED); lock.lock(); } - PINF("wait for platform drv - done"); + Genode::log("wait for platform drv - done"); return AE_OK; } @@ -82,15 +102,17 @@ ACPI_STATUS AcpiOsReadPciConfiguration (ACPI_PCI_ID *pcidev, UINT32 reg, access_size = Platform::Device_client::Access_size::ACCESS_32BIT; break; default: - PERR("%s : unsupported access size %u", __func__, width); + Genode::error(__func__, " : unsupported access size ", width); platform().release_device(client); return AE_ERROR; }; *value = client.config_read(reg, access_size); - PINF("%s: %x:%x.%x reg=0x%x width=%u -> value=0x%llx", - __func__, bus, dev, fn, reg, width, *value); + Genode::log(__func__, ": ", Bdf(bus, dev, fn), + "reg=", Genode::Hex(reg), " " + "width=", width, " -> " + "value=", Genode::Hex(*value)); platform().release_device(client); return AE_OK; @@ -101,9 +123,10 @@ ACPI_STATUS AcpiOsReadPciConfiguration (ACPI_PCI_ID *pcidev, UINT32 reg, platform().release_device(client); } - PERR("%s unknown device - segment=%u bdf=%x:%x.%x reg=0x%x width=0x%x", - __func__, pcidev->Segment, pcidev->Bus, pcidev->Device, - pcidev->Function, reg, width); + Genode::error(__func__, " unknown device - segment=", pcidev->Segment, " " + "bdf=", Bdf(pcidev->Bus, pcidev->Device, pcidev->Function), " " + "reg=", Genode::Hex(reg), " " + "width=", Genode::Hex(width)); return AE_ERROR; } @@ -134,15 +157,17 @@ ACPI_STATUS AcpiOsWritePciConfiguration (ACPI_PCI_ID *pcidev, UINT32 reg, access_size = Platform::Device_client::Access_size::ACCESS_32BIT; break; default: - PERR("%s : unsupported access size %u", __func__, width); + Genode::error(__func__, " : unsupported access size ", width); platform().release_device(client); return AE_ERROR; }; client.config_write(reg, value, access_size); - PWRN("%s: %x:%x.%x reg=0x%x width=%u value=0x%llx", - __func__, bus, dev, fn, reg, width, value); + Genode::warning(__func__, ": ", Bdf(bus, dev, fn), " " + "reg=", Genode::Hex(reg), " " + "width=", width, " " + "value=", Genode::Hex(value)); platform().release_device(client); return AE_OK; @@ -153,9 +178,10 @@ ACPI_STATUS AcpiOsWritePciConfiguration (ACPI_PCI_ID *pcidev, UINT32 reg, platform().release_device(client); } - PERR("%s unknown device - segment=%u bdf=%x:%x.%x reg=0x%x width=0x%x", - __func__, pcidev->Segment, pcidev->Bus, pcidev->Device, - pcidev->Function, reg, width); + Genode::error(__func__, " unknown device - segment=", pcidev->Segment, " ", + "bdf=", Bdf(pcidev->Bus, pcidev->Device, pcidev->Function), " ", + "reg=", Genode::Hex(reg), " " + "width=", Genode::Hex(width)); return AE_ERROR; } diff --git a/repos/libports/src/lib/acpica/scan_root.cc b/repos/libports/src/lib/acpica/scan_root.cc index e13d93f86..fd7627f08 100644 --- a/repos/libports/src/lib/acpica/scan_root.cc +++ b/repos/libports/src/lib/acpica/scan_root.cc @@ -75,7 +75,7 @@ class Genode::Acpi_table if (local) return base + (local - io_mem.local_addr()); } catch (...) { - PWRN("failed to scan EBDA for RSDP root"); + Genode::warning("failed to scan EBDA for RSDP root"); } return 0; diff --git a/repos/libports/src/lib/egl/driver.cc b/repos/libports/src/lib/egl/driver.cc index aed2d3320..80c260cb4 100644 --- a/repos/libports/src/lib/egl/driver.cc +++ b/repos/libports/src/lib/egl/driver.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include /* for 'max' */ @@ -157,7 +157,7 @@ class Winsys : public pipe_winsys _update_buffer(struct pipe_winsys *ws, void *context_private) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } static void @@ -199,8 +199,11 @@ class Winsys : public pipe_winsys unsigned tex_usage, unsigned *stride) { - Genode::printf("Winsys::_surface_buffer_create: format=%d, stride=%d, usage=%d, tex_usage=%x)\n", - format, *stride, usage, tex_usage); + Genode::log("Winsys::_surface_buffer_create: " + "format=", (int)format, ", " + "stride=", *stride, ", " + "usage=", usage, ", " + "tex_usage=", Genode::Hex(tex_usage)); unsigned nblocksy = util_format_get_nblocksy(format, height); @@ -235,7 +238,7 @@ class Winsys : public pipe_winsys struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } static int @@ -243,7 +246,7 @@ class Winsys : public pipe_winsys struct pipe_fence_handle *fence, unsigned flag ) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } static int @@ -251,7 +254,7 @@ class Winsys : public pipe_winsys struct pipe_fence_handle *fence, unsigned flag ) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } public: @@ -322,7 +325,7 @@ class Surface : public native_surface static boolean _flush_frontbuffer(struct native_surface *nsurf) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } static boolean @@ -388,7 +391,7 @@ class Surface : public native_surface static void _wait(struct native_surface *nsurf) { - PDBG("not implemented"); + Genode::warning(__func__, " not implemented"); } public: @@ -471,7 +474,7 @@ class Display : public native_display const native_connector **conn_list = (const native_connector **)malloc(sizeof(native_connector **)); conn_list[0] = &conn; - printf("called, return 1 connector\n"); + Genode::log("called, return 1 connector"); if (num_connectors) *num_connectors = 1; if (num_crtcs) *num_crtcs = 1; @@ -572,7 +575,7 @@ class Display : public native_display } if (format != PIPE_FORMAT_NONE) { - printf("support depth and stencil buffer\n"); + Genode::log("support depth and stencil buffer"); config->depth_format = format; config->stencil_format = format; config->mode.depthBits = 24; @@ -586,7 +589,7 @@ class Display : public native_display config->scanout_bit = TRUE; - printf("returning 1 config at %p\n", config); + Genode::log("returning 1 config at ", config); *num_configs = NUM_CONFIGS; return configs; @@ -597,7 +600,7 @@ class Display : public native_display EGLNativePixmapType pix, const struct native_config *nconf) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } static struct native_surface * @@ -617,7 +620,7 @@ class Display : public native_display EGLNativePixmapType pix, const struct native_config *nconf) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } static struct native_surface * @@ -625,7 +628,7 @@ class Display : public native_display const struct native_config *nconf, uint width, uint height) { - PDBG("not implemented"); return 0; + Genode::warning(__func__, " not implemented"); return 0; } public: @@ -645,8 +648,8 @@ class Display : public native_display _mode.width = genode_framebuffer()->width(); _mode.height = genode_framebuffer()->height(); } catch (Genode::Parent::Service_denied) { - PWRN("EGL driver: could not create a Framebuffer session. " - "Screen surfaces cannot be used."); + Genode::warning("EGL driver: could not create a Framebuffer session. " + "Screen surfaces cannot be used."); _mode.width = 1; _mode.height = 1; } @@ -670,7 +673,7 @@ class Display : public native_display screen = softpipe_create_screen(&_winsys); } - PWRN("returned from init display->screen"); + Genode::warning("returned from init display->screen"); destroy = _destroy; get_param = _get_param; @@ -697,7 +700,7 @@ boolean Surface::_swap_buffers(struct native_surface *nsurf) timer.msleep(5); if (!texture) { - PERR("surface has no texture"); + Genode::error("surface has no texture"); return FALSE; } @@ -708,13 +711,13 @@ boolean Surface::_swap_buffers(struct native_surface *nsurf) this_surface->height()); if (!transfer) { - PERR("could not create transfer object"); + Genode::error("could not create transfer object"); return FALSE; } void *data = screen->transfer_map(screen, transfer); if (!data) { - PERR("transfer failed"); + Genode::error("transfer failed"); screen->tex_transfer_destroy(transfer); return FALSE; } @@ -766,7 +769,7 @@ extern "C" const char *native_get_name(void) extern "C" struct native_probe * native_create_probe(EGLNativeDisplayType dpy) { - PDBG("not yet implemented dpy=%d", dpy); + Genode::warning(__func__, " not yet implemented dpy=", dpy); return 0; } @@ -774,7 +777,7 @@ native_create_probe(EGLNativeDisplayType dpy) extern "C" enum native_probe_result native_get_probe_result(struct native_probe *nprobe) { - PDBG("not yet implemented"); + Genode::warning(__func__, " not yet implemented"); return NATIVE_PROBE_UNKNOWN; } @@ -801,12 +804,12 @@ native_create_display(EGLNativeDisplayType dpy, if (drm_api_create) api = drm_api_create(); else - PWRN("could not obtain symbol \"drm_api_create\" in driver \"%s\"", - driver_filename); + Genode::warning("could not obtain symbol \"drm_api_create\" in driver ", + "'", driver_filename, "'"); } if (!api) { - PWRN("falling back to softpipe driver"); + Genode::warning("falling back to softpipe driver"); /* * Performing clflush is not needed when using software rendering. diff --git a/repos/libports/src/lib/exfat/init.cc b/repos/libports/src/lib/exfat/init.cc index 345fc77b5..c8a11a0d9 100644 --- a/repos/libports/src/lib/exfat/init.cc +++ b/repos/libports/src/lib/exfat/init.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include @@ -32,17 +32,17 @@ struct exfat ef; bool Fuse::init_fs(void) { - PLOG("libc_fuse_exfat: try to mount /dev/blkdev..."); + Genode::log("libc_fuse_exfat: try to mount /dev/blkdev..."); int err = exfat_mount(&ef, "/dev/blkdev", ""); if (err) { - PERR("libc_fuse_exfat: could not mount /dev/blkdev"); + Genode::error("libc_fuse_exfat: could not mount /dev/blkdev"); return false; } fh = fuse_new(fc, NULL, &fuse_exfat_ops, sizeof (struct fuse_operations), NULL); if (fh == 0) { - PERR("libc_fuse_exfat: fuse_new() failed"); + Genode::error("libc_fuse_exfat: fuse_new() failed"); return false; } @@ -52,7 +52,7 @@ bool Fuse::init_fs(void) void Fuse::deinit_fs(void) { - PLOG("libc_fuse_exfat: umount /dev/blkdev..."); + Genode::log("libc_fuse_exfat: umount /dev/blkdev..."); exfat_unmount(&ef); } diff --git a/repos/libports/src/lib/ffat/diskio_block.cc b/repos/libports/src/lib/ffat/diskio_block.cc index daacf2718..4b57e1c0e 100644 --- a/repos/libports/src/lib/ffat/diskio_block.cc +++ b/repos/libports/src/lib/ffat/diskio_block.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* Ffat includes */ @@ -37,22 +37,22 @@ extern "C" DSTATUS disk_initialize (BYTE drv) static bool initialized = false; if (verbose) - PDBG("disk_initialize(drv=%u) called.", drv); + Genode::log("disk_initialize(drv=", drv, ") called."); if (drv != 0) { - PERR("Only one disk drive is supported at this time."); + Genode::error("only one disk drive is supported at this time."); return STA_NOINIT; } if (initialized) { - PERR("drv 0 has already been initialized."); + Genode::error("drv 0 has already been initialized."); return STA_NOINIT; } try { _block_connection = new (Genode::env()->heap()) Block::Connection(&_block_alloc); } catch(...) { - PERR("could not open block connection"); + Genode::error("could not open block connection"); return STA_NOINIT; } @@ -63,17 +63,17 @@ extern "C" DSTATUS disk_initialize (BYTE drv) /* check for read- and write-capability */ if (!ops.supported(Block::Packet_descriptor::READ)) { - PERR("Block device not readable!"); + Genode::error("block device not readable!"); destroy(env()->heap(), _block_connection); return STA_NOINIT; } if (!ops.supported(Block::Packet_descriptor::WRITE)) { - PINF("Block device not writeable!"); + Genode::warning("block device not writeable!"); } if (verbose) - PDBG("We have %llu blocks with a size of %zu bytes", - _blk_cnt, _blk_size); + Genode::log(__func__, ": We have ", _blk_cnt, " blocks with a " + "size of ", _blk_size, " bytes"); initialized = true; @@ -84,7 +84,7 @@ extern "C" DSTATUS disk_initialize (BYTE drv) extern "C" DSTATUS disk_status (BYTE drv) { if (drv != 0) { - PERR("Only one disk drive is supported at this time."); + Genode::error("only one disk drive is supported at this time."); return STA_NODISK; } @@ -95,11 +95,11 @@ extern "C" DSTATUS disk_status (BYTE drv) extern "C" DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) { if (verbose) - PDBG("disk_read(drv=%u, buff=%p, sector=%u, count=%u) called.", - drv, buff, (unsigned int)sector, count); + Genode::log(__func__, ": disk_read(drv=", drv, ", buff=", buff, ", " + "sector=", sector, ", count=", count, ") called."); if (drv != 0) { - PERR("Only one disk drive is supported at this time."); + Genode::error("only one disk drive is supported at this time."); return RES_ERROR; } @@ -111,20 +111,13 @@ extern "C" DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) /* check for success of operation */ if (!p.succeeded()) { - PERR("Could not read block(s)"); + Genode::error("could not read block(s)"); _source->release_packet(p); return RES_ERROR; } memcpy(buff, _source->packet_content(p), count * _blk_size); -#if 0 - PDBG("read() successful, contents of buff = \n"); - - for (unsigned int i = 0; i < count * _blk_size; i++) - PDBG("%8x: %2x %c", i, buff[i], buff[i] >= 32 ? buff[i] : '-'); -#endif - _source->release_packet(p); return RES_OK; } @@ -134,11 +127,11 @@ extern "C" DRESULT disk_read(BYTE drv, BYTE *buff, DWORD sector, BYTE count) extern "C" DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, BYTE count) { if (verbose) - PDBG("disk_write(drv=%u, buff=%p, sector=%u, count=%u) called.", - drv, buff, (unsigned int)sector, count); + Genode::log(__func__, ": disk_write(drv=", drv, ", buff=", buff, ", " + "sector=", sector, ", count=", count, ") called."); if (drv != 0) { - PERR("Only one disk drive is supported at this time."); + Genode::error("only one disk drive is supported at this time."); return RES_ERROR; } @@ -153,7 +146,7 @@ extern "C" DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, BYTE cou /* check for success of operation */ if (!p.succeeded()) { - PERR("Could not write block(s)"); + Genode::error("could not write block(s)"); _source->release_packet(p); return RES_ERROR; } @@ -166,15 +159,15 @@ extern "C" DRESULT disk_write(BYTE drv, const BYTE *buff, DWORD sector, BYTE cou extern "C" DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff) { - PWRN("disk_ioctl(drv=%u, ctrl=%u, buff=%p) called - not yet implemented.", - drv, ctrl, buff); + Genode::warning(__func__, "(drv=", drv, ", ctrl=", ctrl, ", buff=", buff, ") " + "called - not yet implemented."); return RES_OK; } extern "C" DWORD get_fattime(void) { - PWRN("get_fattime() called - not yet implemented."); + Genode::warning(__func__, "() called - not yet implemented."); return 0; } diff --git a/repos/libports/src/lib/fuse-ext2/init.cc b/repos/libports/src/lib/fuse-ext2/init.cc index 9604d20ab..1a5205553 100644 --- a/repos/libports/src/lib/fuse-ext2/init.cc +++ b/repos/libports/src/lib/fuse-ext2/init.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -44,17 +44,17 @@ char volname[] = "ext2_volume"; bool Fuse::init_fs(void) { - PLOG("libc_fuse_ext2: try to mount /dev/blkdev..."); + Genode::log("libc_fuse_ext2: try to mount /dev/blkdev..."); int err = ext2fs_open("/dev/blkdev", EXT2_FLAG_RW, 0, 0, unix_io_manager, &e2fs); if (err) { - PERR("libc_fuse_ext2: could not mount /dev/blkdev, error: %d", err); + Genode::error("libc_fuse_ext2: could not mount /dev/blkdev, error: ", err); return false; } errcode_t rc = ext2fs_read_bitmaps(e2fs); if (rc) { - PERR("libc_fuse_ext2: error while reading bitmaps"); + Genode::error("libc_fuse_ext2: error while reading bitmaps"); ext2fs_close(e2fs); return false; } @@ -74,7 +74,7 @@ bool Fuse::init_fs(void) fh = fuse_new(fc, NULL, &ext2fs_ops, sizeof (ext2fs_ops), &extfs_data); if (fh == 0) { - PERR("libc_fuse_ext2: fuse_new() failed"); + Genode::error("libc_fuse_ext2: fuse_new() failed"); return false; } @@ -84,7 +84,7 @@ bool Fuse::init_fs(void) void Fuse::deinit_fs(void) { - PLOG("libc_fuse_ext2: unmount /dev/blkdev..."); + Genode::log("libc_fuse_ext2: unmount /dev/blkdev..."); ext2fs_close(e2fs); free(fh); @@ -93,7 +93,7 @@ void Fuse::deinit_fs(void) void Fuse::sync_fs(void) { - PLOG("libc_fuse_ext2: sync file system..."); + Genode::log("libc_fuse_ext2: sync file system..."); ext2fs_flush(e2fs); } diff --git a/repos/libports/src/lib/fuse/fuse.cc b/repos/libports/src/lib/fuse/fuse.cc index fccf4b59a..747da1d4a 100644 --- a/repos/libports/src/lib/fuse/fuse.cc +++ b/repos/libports/src/lib/fuse/fuse.cc @@ -12,7 +12,7 @@ */ /* Genodes includes */ -#include +#include #include /* libc includes */ @@ -28,7 +28,7 @@ static struct fuse *_fuse; static struct fuse_context _ctx; #if 1 -#define TRACE PDBG("") +#define TRACE Genode::log("") #else #define TRACE #endif @@ -36,7 +36,7 @@ static struct fuse_context _ctx; struct fuse* Fuse::fuse() { if (_fuse == 0) { - PERR("libfuse: struct fuse is zero"); + Genode::error("libfuse: struct fuse is zero"); abort(); } @@ -52,7 +52,7 @@ extern "C" { void fuse_genode(const char *s) { - PLOG("%s: %s", __func__, s); + Genode::log(__func__, ": ", s); } #define FIX_UP_OPERATION1(f, name) \ @@ -82,7 +82,7 @@ static int fill_dir(void *dh, const char *name, const struct stat *sbuf, off_t o struct fuse_dirhandle *dir = (struct fuse_dirhandle*)dh; if ((dir->offset + sizeof (struct dirent)) > dir->size) { - PWRN("fill_dir buffer full"); + Genode::warning("fill_dir buffer full"); return 1; } @@ -139,7 +139,7 @@ struct fuse* fuse_new(struct fuse_chan *chan, struct fuse_args *args, _fuse = reinterpret_cast(malloc(sizeof (struct fuse))); if (_fuse == 0) { - PERR("could not create struct fuse"); + Genode::error("could not create struct fuse"); return 0; } diff --git a/repos/libports/src/lib/libc/dummies.cc b/repos/libports/src/lib/libc/dummies.cc index 4d01dd619..4981755cb 100644 --- a/repos/libports/src/lib/libc/dummies.cc +++ b/repos/libports/src/lib/libc/dummies.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -37,7 +37,7 @@ extern "C" { #define DUMMY(ret_type, ret_val, name, args) __attribute__((weak)) \ ret_type name args \ { \ - PDBG( #name " not implemented"); \ + Genode::warning(__func__, ": " #name " not implemented"); \ errno = ENOSYS; \ return ret_val; \ } @@ -128,7 +128,7 @@ DUMMY(pid_t , -1, _wait4, (pid_t, int *, int, struct rusage *)) void ksem_init(void) { - PDBG("ksem_init called, not yet implemented!"); + Genode::warning(__func__, " called, not yet implemented!"); while (1); } @@ -139,7 +139,8 @@ int __attribute__((weak)) madvise(void *addr, size_t length, int advice) /* ignore hint */ return 0; - PDBG("called, not implemented - %p+%zx advice=%d", addr, length, advice); + Genode::warning(__func__, " called, not implemented - ", addr, "+", + Genode::Hex(length), " advice=", advice); errno = ENOSYS; return -1; } diff --git a/repos/libports/src/lib/libc/dynamic_linker.cc b/repos/libports/src/lib/libc/dynamic_linker.cc index 48dc698c9..798d008c3 100644 --- a/repos/libports/src/lib/libc/dynamic_linker.cc +++ b/repos/libports/src/lib/libc/dynamic_linker.cc @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include @@ -39,7 +39,7 @@ void *dlopen(const char *name, int mode) /* error on unsupported mode values */ if (mode & ~supported) { snprintf(err_str, MAX_ERR, "Unsupported mode 0x%x\n", mode & ~supported); - PERR("dlopen: %s", err_str); + error("dlopen: ", Cstring(err_str)); return nullptr; } @@ -101,20 +101,20 @@ int dlclose(void *handle) int dlinfo(void *handle, int request, void *p) { - PERR("%s not implemented", __func__); + error(__func__, " not implemented"); return 0; } dlfunc_t dlfunc(void *handle, const char *name) { - PERR("%s not implemented", __func__); + error(__func__, " not implemented"); return 0; } void *dlvsym(void *handle, const char *name, const char *version) { - PERR("%s not implemented", __func__); + error(__func__, " not implemented"); return nullptr; } diff --git a/repos/libports/src/lib/libc/fd_alloc.cc b/repos/libports/src/lib/libc/fd_alloc.cc index 711f438eb..a89a7fbf1 100644 --- a/repos/libports/src/lib/libc/fd_alloc.cc +++ b/repos/libports/src/lib/libc/fd_alloc.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include #include -#include +#include /* libc plugin interface */ #include @@ -62,8 +62,8 @@ File_descriptor *File_descriptor_allocator::alloc(Plugin *plugin, alloc_ok = (Allocator_avl_base::alloc_addr(1, addr).ok()); if (!alloc_ok) { - PERR("could not allocate libc_fd %d%s", - libc_fd, libc_fd == ANY_FD ? " (any)" : ""); + error("could not allocate libc_fd ", libc_fd, + libc_fd == ANY_FD ? " (any)" : ""); return 0; } diff --git a/repos/libports/src/lib/libc/file_operations.cc b/repos/libports/src/lib/libc/file_operations.cc index 93f090650..67d0defb0 100644 --- a/repos/libports/src/lib/libc/file_operations.cc +++ b/repos/libports/src/lib/libc/file_operations.cc @@ -38,15 +38,6 @@ using namespace Libc; -#ifdef GENODE_RELEASE -#undef PERR -#define PERR(...) -#endif /* GENODE_RELEASE */ - -static bool const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - Libc::Mmap_registry *Libc::mmap_registry() { static Libc::Mmap_registry registry; @@ -91,27 +82,22 @@ class Symlink_resolve_error { }; static void resolve_symlinks(char const *path, Absolute_path &resolved_path) { - PDBGV("path = %s", path); - char path_element[PATH_MAX]; char symlink_target[PATH_MAX]; Absolute_path current_iteration_working_path; Absolute_path next_iteration_working_path(path, cwd().base()); - PDBGV("absolute_path = %s", next_iteration_working_path.base()); enum { FOLLOW_LIMIT = 10 }; int follow_count = 0; bool symlink_resolved_in_this_iteration; do { - PDBGV("new iteration"); if (follow_count++ == FOLLOW_LIMIT) { errno = ELOOP; throw Symlink_resolve_error(); } current_iteration_working_path = next_iteration_working_path; - PDBGV("current_iteration_working_path = %s", current_iteration_working_path.base()); next_iteration_working_path.import(""); symlink_resolved_in_this_iteration = false; @@ -125,7 +111,6 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path) } t.string(path_element, sizeof(path_element)); - PDBGV("path_element = %s", path_element); try { next_iteration_working_path.append_element(path_element); @@ -134,8 +119,6 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path) throw Symlink_resolve_error(); } - PDBGV("working_path_new = %s", next_iteration_working_path.base()); - /* * If a symlink has been resolved in this iteration, the remaining * path elements get added and a new iteration starts. @@ -145,11 +128,9 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path) int res; FNAME_FUNC_WRAPPER_GENERIC(res = , stat, next_iteration_working_path.base(), &stat_buf); if (res == -1) { - PDBGV("stat() failed for %s", next_iteration_working_path.base()); throw Symlink_resolve_error(); } if (S_ISLNK(stat_buf.st_mode)) { - PDBGV("found symlink: %s", next_iteration_working_path.base()); FNAME_FUNC_WRAPPER_GENERIC(res = , readlink, next_iteration_working_path.base(), symlink_target, sizeof(symlink_target) - 1); @@ -172,27 +153,22 @@ static void resolve_symlinks(char const *path, Absolute_path &resolved_path) throw Symlink_resolve_error(); } } - PDBGV("resolved symlink to: %s", next_iteration_working_path.base()); symlink_resolved_in_this_iteration = true; } } t = t.next(); } - PDBGV("token end"); } while (symlink_resolved_in_this_iteration); resolved_path = next_iteration_working_path; resolved_path.remove_trailing('/'); - PDBGV("resolved_path = %s", resolved_path.base()); } static void resolve_symlinks_except_last_element(char const *path, Absolute_path &resolved_path) { - PDBGV("path = %s", path); - Absolute_path absolute_path_without_last_element(path, cwd().base()); absolute_path_without_last_element.strip_last_element(); @@ -447,7 +423,7 @@ extern "C" void *mmap(void *addr, ::size_t length, int prot, int flags, /* lookup plugin responsible for file descriptor */ File_descriptor *fd = libc_fd_to_fd(libc_fd, "mmap"); if (!fd || !fd->plugin || !fd->plugin->supports_mmap()) { - PWRN("mmap not supported for file descriptor %d", libc_fd); + Genode::warning("mmap not supported for file descriptor ", libc_fd); errno = EBADF; return (void *)INVALID_FD; } @@ -461,7 +437,7 @@ extern "C" void *mmap(void *addr, ::size_t length, int prot, int flags, extern "C" int munmap(void *start, ::size_t length) { if (!mmap_registry()->registered(start)) { - PWRN("munmap: could not lookup plugin for address %p", start); + Genode::warning("munmap: could not lookup plugin for address ", start); errno = EINVAL; return -1; } @@ -486,8 +462,6 @@ extern "C" int munmap(void *start, ::size_t length) extern "C" int _open(const char *pathname, int flags, ::mode_t mode) { - PDBGV("pathname = %s", pathname); - Absolute_path resolved_path; Plugin *plugin; @@ -512,18 +486,16 @@ extern "C" int _open(const char *pathname, int flags, ::mode_t mode) } } - PDBGV("resolved path = %s", resolved_path.base()); - plugin = plugin_registry()->get_plugin_for_open(resolved_path.base(), flags); if (!plugin) { - PERR("no plugin found for open(\"%s\", %d)", pathname, flags); + Genode::error("no plugin found for open(\"", pathname, "\", ", flags, ")"); return -1; } new_fdo = plugin->open(resolved_path.base(), flags); if (!new_fdo) { - PERR("plugin()->open(\"%s\") failed", pathname); + Genode::error("plugin()->open(\"", pathname, "\") failed"); return -1; } new_fdo->path(resolved_path.base()); @@ -550,12 +522,12 @@ extern "C" int pipe(int pipefd[2]) plugin = plugin_registry()->get_plugin_for_pipe(); if (!plugin) { - PERR("no plugin found for pipe()"); + Genode::error("no plugin found for pipe()"); return -1; } if (plugin->pipe(pipefdo) == -1) { - PERR("plugin()->pipe() failed"); + Genode::error("plugin()->pipe() failed"); return -1; } @@ -615,7 +587,6 @@ extern "C" int rmdir(const char *path) extern "C" int stat(const char *path, struct stat *buf) { - PDBGV("path = %s", path); try { Absolute_path resolved_path; resolve_symlinks(path, resolved_path); @@ -668,6 +639,5 @@ extern "C" ssize_t write(int libc_fd, const void *buf, ::size_t count) { extern "C" int __getcwd(char *dst, ::size_t dst_size) { Genode::strncpy(dst, cwd().base(), dst_size); - PDBGV("cwd = %s", dst); return 0; } diff --git a/repos/libports/src/lib/libc/gai_strerror.cc b/repos/libports/src/lib/libc/gai_strerror.cc index 6f4973071..2b1fb1318 100644 --- a/repos/libports/src/lib/libc/gai_strerror.cc +++ b/repos/libports/src/lib/libc/gai_strerror.cc @@ -11,11 +11,11 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include extern "C" const char *gai_strerror(int errcode) { static const char *result = "gai_strerror called, not yet implemented!"; - PDBG("%s", result); + Genode::log(__func__, ": ", result); return result; } diff --git a/repos/libports/src/lib/libc/libc_file.h b/repos/libports/src/lib/libc/libc_file.h index d903b35e4..6bb76506f 100644 --- a/repos/libports/src/lib/libc/libc_file.h +++ b/repos/libports/src/lib/libc/libc_file.h @@ -15,7 +15,7 @@ #define _LIBC_FILE_H_ /* Genode includes */ -#include +#include /* Genode-specific libc interfaces */ #include @@ -34,7 +34,7 @@ static inline Libc::File_descriptor *libc_fd_to_fd(int libc_fd, const char *func Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->find_by_libc_fd(libc_fd); if (!fd) - PERR("no plugin found for %s(%d)", func_name, libc_fd); + Genode::error("no plugin found for ", func_name, "(", libc_fd, ")"); return fd; } @@ -62,7 +62,7 @@ static inline Libc::File_descriptor *libc_fd_to_fd(int libc_fd, const char *func { \ Plugin *plugin = plugin_registry()->get_plugin_for_##func_name(path, ##__VA_ARGS__); \ if (!plugin) { \ - PERR("no plugin found for %s(\"%s\")", #func_name, path); \ + Genode::error("no plugin found for ", #func_name, "(\"", Genode::Cstring(path), "\")");\ errno = ENOSYS; \ result_stm -1; \ } else \ diff --git a/repos/libports/src/lib/libc/libc_mmap_registry.h b/repos/libports/src/lib/libc/libc_mmap_registry.h index 7c2460b9c..0013ae8f3 100644 --- a/repos/libports/src/lib/libc/libc_mmap_registry.h +++ b/repos/libports/src/lib/libc/libc_mmap_registry.h @@ -10,7 +10,7 @@ /* Genode includes */ #include #include -#include +#include /* libc-internal includes */ #include @@ -78,7 +78,8 @@ class Libc::Mmap_registry Genode::Lock::Guard guard(_lock); if (_lookup_by_addr_unsynchronized(start)) { - PINF("mmap region at %p is already registered", start); + Genode::warning(__func__, ": mmap region at ", start, " " + "is already registered"); return; } @@ -107,7 +108,8 @@ class Libc::Mmap_registry Entry *e = _lookup_by_addr_unsynchronized(start); if (!e) { - PWRN("lookup for address %p in in mmap registry failed", start); + Genode::warning("lookup for address ", start, " " + "in in mmap registry failed"); return; } diff --git a/repos/libports/src/lib/libc/malloc.cc b/repos/libports/src/lib/libc/malloc.cc index f8fc1cd62..923ba1a87 100644 --- a/repos/libports/src/lib/libc/malloc.cc +++ b/repos/libports/src/lib/libc/malloc.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -102,7 +102,7 @@ class Malloc : public Genode::Allocator } } - ~Malloc() { PDBG("CALLED"); } + ~Malloc() { Genode::warning(__func__, " unexpectedly called"); } /** * Allocator interface diff --git a/repos/libports/src/lib/libc/plugin.cc b/repos/libports/src/lib/libc/plugin.cc index 6df33b78f..05e96f30c 100644 --- a/repos/libports/src/lib/libc/plugin.cc +++ b/repos/libports/src/lib/libc/plugin.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* libc plugin interface */ #include @@ -148,7 +148,7 @@ bool Plugin::supports_mmap() #define DUMMY(ret_type, ret_val, name, args) \ ret_type Plugin::name args \ { \ - PERR( #name " not implemented"); \ + Genode::error(__func__, ": " #name " not implemented"); \ return ret_val; \ } diff --git a/repos/libports/src/lib/libc/select.cc b/repos/libports/src/lib/libc/select.cc index af2c30ac2..3fc5c587b 100644 --- a/repos/libports/src/lib/libc/select.cc +++ b/repos/libports/src/lib/libc/select.cc @@ -14,7 +14,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -103,7 +103,7 @@ static int selscan(int nfds, fd_set *in_readfds, fd_set *in_writefds, } nready += plugin_nready; } else if (plugin_nready < 0) { - PERR("plugin->select() returned error value %d", plugin_nready); + Genode::error("plugin->select() returned error value ", plugin_nready); } } } diff --git a/repos/libports/src/lib/libc/socket_operations.cc b/repos/libports/src/lib/libc/socket_operations.cc index a29d3b4ca..586e7c922 100644 --- a/repos/libports/src/lib/libc/socket_operations.cc +++ b/repos/libports/src/lib/libc/socket_operations.cc @@ -29,15 +29,6 @@ using namespace Libc; -#ifdef GENODE_RELEASE -#undef PERR -#define PERR(...) -#endif /* GENODE_RELEASE */ - -static bool const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - extern "C" int _accept(int libc_fd, struct sockaddr *addr, socklen_t *addrlen) { return accept(libc_fd, addr, addrlen); @@ -83,7 +74,7 @@ extern "C" void freeaddrinfo(struct addrinfo *res) plugin = plugin_registry()->get_plugin_for_freeaddrinfo(res); if (!plugin) { - PERR("no plugin found for freeaddrinfo()"); + Genode::error("no plugin found for freeaddrinfo()"); return; } @@ -100,7 +91,7 @@ extern "C" int getaddrinfo(const char *node, const char *service, plugin = plugin_registry()->get_plugin_for_getaddrinfo(node, service, hints, res); if (!plugin) { - PERR("no plugin found for getaddrinfo()"); + Genode::error("no plugin found for getaddrinfo()"); return -1; } @@ -210,13 +201,13 @@ extern "C" int socket(int domain, int type, int protocol) plugin = plugin_registry()->get_plugin_for_socket(domain, type, protocol); if (!plugin) { - PERR("no plugin found for socket()"); + Genode::error("no plugin found for socket()"); return -1; } new_fdo = plugin->socket(domain, type, protocol); if (!new_fdo) { - PERR("plugin()->socket() failed"); + Genode::error("plugin()->socket() failed"); return -1; } diff --git a/repos/libports/src/lib/libc/sysctl.cc b/repos/libports/src/lib/libc/sysctl.cc index 216fd5037..f02c03720 100644 --- a/repos/libports/src/lib/libc/sysctl.cc +++ b/repos/libports/src/lib/libc/sysctl.cc @@ -44,7 +44,7 @@ extern "C" long sysconf(int name) case _SC_PHYS_PAGES: return Genode::env()->ram_session()->quota() / PAGESIZE; default: - PWRN("%s(%d) not implemented", __func__, name); + Genode::warning(__func__, "(", name, ") not implemented"); return Libc::Errno(EINVAL); } } @@ -54,7 +54,7 @@ extern "C" long sysconf(int name) extern "C" int sysctlbyname(char const *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - PWRN("%s(%s,...) not implemented", __func__, name); + Genode::warning(__func__, "(", name, ",...) not implemented"); return Libc::Errno(ENOENT); } @@ -203,7 +203,7 @@ extern "C" int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, } default: - PWRN("unhandled sysctl data type for %s", sysctl_path.base()); + Genode::warning("unhandled sysctl data type for ", sysctl_path); return Libc::Errno(EINVAL); } } @@ -250,7 +250,8 @@ extern "C" int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, } } - PWRN("sysctl: no builtin or override value found for %s.%s", - ctl_names[index_a].ctl_name, ctl->ctl_name); + Genode::warning("sysctl: no builtin or override value found for ", + Genode::Cstring(ctl_names[index_a].ctl_name), ".", + Genode::Cstring(ctl->ctl_name)); return Libc::Errno(ENOENT); } diff --git a/repos/libports/src/lib/libc/task.cc b/repos/libports/src/lib/libc/task.cc index 5a8e420e7..53fd5928d 100644 --- a/repos/libports/src/lib/libc/task.cc +++ b/repos/libports/src/lib/libc/task.cc @@ -23,12 +23,18 @@ #include -#define P(fmt,...) \ - do { \ - int dummy; \ - Genode::printf(ESC_INF "[%lx] %s:%u " fmt ESC_END "\n", \ - (unsigned long)&dummy >> 20, \ - __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); \ +/* escape sequences for highlighting debug message prefixes */ +#define LIBC_ESC_START "\033[32m" +#define LIBC_ESC_END "\033[0m" + +#define P(...) \ + do { \ + int dummy; \ + using namespace Genode; \ + Hex ctx((addr_t)&dummy >> 20, Hex::OMIT_PREFIX); \ + log(LIBC_ESC_START "[", ctx, "] ", \ + __PRETTY_FUNCTION__, ":", __LINE__, \ + LIBC_ESC_END " ", ##__VA_ARGS__); \ } while (0) @@ -95,7 +101,7 @@ class Libc::Task : public Genode::Rpc_object Task(Genode::Env &env) : _env(env) { } - ~Task() { PERR("%s should not be executed!", __PRETTY_FUNCTION__); } + ~Task() { Genode::error(__PRETTY_FUNCTION__, " should not be executed!"); } void run() { diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index 82218f4b3..718b4594e 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -165,7 +165,7 @@ class Libc::Vfs_plugin : public Libc::Plugin try { return vfs_config(); } catch (...) { - PINF("no VFS configured"); + Genode::warning("no VFS configured"); return Genode::Xml_node(""); } } @@ -178,8 +178,8 @@ class Libc::Vfs_plugin : public Libc::Plugin Libc::File_descriptor *fd = open(path, flags, libc_fd); if (fd->libc_fd != libc_fd) { - PERR("could not allocate fd %d for %s, got fd %d", - libc_fd, path, fd->libc_fd); + Genode::error("could not allocate fd ", libc_fd, " " + "for ", path, ", got fd ", fd->libc_fd); close(fd); return; } @@ -454,7 +454,7 @@ ssize_t Libc::Vfs_plugin::getdirentries(Libc::File_descriptor *fd, char *buf, ::size_t nbytes, ::off_t *basep) { if (nbytes < sizeof(struct dirent)) { - PERR("getdirentries: buffer too small"); + Genode::error("getdirentries: buffer too small"); return -1; } @@ -591,7 +591,7 @@ int Libc::Vfs_plugin::ioctl(Libc::File_descriptor *fd, int request, char *argp) } default: - PWRN("unsupported ioctl (request=0x%x)", request); + Genode::warning("unsupported ioctl (request=", Genode::Hex(request), ")"); break; } @@ -703,7 +703,7 @@ int Libc::Vfs_plugin::fcntl(Libc::File_descriptor *fd, int cmd, long arg) * duplicate. */ if (dup2(fd, new_fd) == -1) { - PERR("Plugin::fcntl: dup2 unexpectedly failed"); + Genode::error("Plugin::fcntl: dup2 unexpectedly failed"); errno = EINVAL; return -1; } @@ -718,7 +718,7 @@ int Libc::Vfs_plugin::fcntl(Libc::File_descriptor *fd, int cmd, long arg) break; } - PERR("fcntl(): command %d not supported - vfs", cmd); + Genode::error("fcntl(): command ", cmd, " not supported - vfs"); errno = EINVAL; return -1; } @@ -819,13 +819,13 @@ void *Libc::Vfs_plugin::mmap(void *addr_in, ::size_t length, int prot, int flags Libc::File_descriptor *fd, ::off_t offset) { if (prot != PROT_READ) { - PERR("mmap for prot=%x not supported", prot); + Genode::error("mmap for prot=", Genode::Hex(prot), " not supported"); errno = EACCES; return (void *)-1; } if (addr_in != 0) { - PERR("mmap for predefined address not supported"); + Genode::error("mmap for predefined address not supported"); errno = EINVAL; return (void *)-1; } @@ -842,7 +842,7 @@ void *Libc::Vfs_plugin::mmap(void *addr_in, ::size_t length, int prot, int flags } if (::pread(fd->libc_fd, addr, length, offset) < 0) { - PERR("mmap could not obtain file content"); + Genode::error("mmap could not obtain file content"); ::munmap(addr, length); errno = EACCES; return (void *)-1; diff --git a/repos/libports/src/lib/libc_ffat/plugin.cc b/repos/libports/src/lib/libc_ffat/plugin.cc index 31b724297..276ef0c96 100644 --- a/repos/libports/src/lib/libc_ffat/plugin.cc +++ b/repos/libports/src/lib/libc_ffat/plugin.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* libc includes */ @@ -59,8 +59,6 @@ class Plugin_context : public Libc::Plugin_context Plugin_context(const char *filename) : _fd_flags(0), _status_flags(0) { - if (verbose) - PDBG("new context at %p", this); _filename = (char*)malloc(::strlen(filename) + 1); ::strcpy(_filename, filename); } @@ -176,10 +174,10 @@ class Plugin : public Libc::Plugin { /* mount the file system */ if (verbose) - PDBG("Mounting device %u ...\n\n", 0); + Genode::log(__func__, ": mounting device ..."); if (f_mount(0, &_fatfs) != Ffat::FR_OK) { - PERR("Mount failed\n"); + Genode::error("mount failed"); } } @@ -196,42 +194,42 @@ class Plugin : public Libc::Plugin bool supports_mkdir(const char *path, mode_t) override { if (verbose) - PDBG("path = %s", path); + Genode::log(__func__, ": path=", path); return true; } bool supports_open(const char *pathname, int flags) override { if (verbose) - PDBG("pathname = %s", pathname); + Genode::log(__func__, ": pathname=", pathname); return true; } bool supports_rename(const char *oldpath, const char *newpath) override { if (verbose) - PDBG("oldpath = %s, newpath = %s", oldpath, newpath); + Genode::log(__func__, ": oldpath=", oldpath, ", newpath=", newpath); return true; } bool supports_rmdir(const char *path) override { if (verbose) - PDBG("path = %s", path); + Genode::log(__func__, ": path=", path); return true; } bool supports_stat(const char *path) override { if (verbose) - PDBG("path = %s", path); + Genode::log(__func__, ": path=", path); return true; } bool supports_unlink(const char *path) override { if (verbose) - PDBG("path = %s", path); + Genode::log(__func__, ": path=", path); return true; } @@ -274,7 +272,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_close() returned an unexpected error code"); + Genode::error("f_close() returned an unexpected error code"); return -1; } } @@ -285,7 +283,7 @@ class Plugin : public Libc::Plugin case F_GETFD: return context(fd)->fd_flags(); case F_SETFD: context(fd)->fd_flags(arg); return 0; case F_GETFL: return context(fd)->status_flags(); - default: PERR("fcntl(): command %d not supported", cmd); return -1; + default: Genode::error("fcntl(): command ", cmd, " not supported", cmd); return -1; } } @@ -298,7 +296,7 @@ class Plugin : public Libc::Plugin { /* libc's opendir() fails if _fstatfs() returns -1, so we return 0 here */ if (verbose) - PDBG("_fstatfs() called - not yet implemented"); + Genode::warning("_fstatfs() called - not yet implemented"); return 0; } @@ -319,7 +317,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_sync() returned an unexpected error code"); + Genode::error("f_sync() returned an unexpected error code"); return -1; } } @@ -346,7 +344,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_truncate() returned an unexpected error code"); + Genode::error("f_truncate() returned an unexpected error code"); return -1; } } @@ -357,7 +355,7 @@ class Plugin : public Libc::Plugin using namespace Ffat; if (nbytes < sizeof(struct dirent)) { - PERR("buf too small"); + Genode::error(__func__, ": buf too small"); errno = ENOMEM; return -1; } @@ -381,13 +379,13 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_readdir() returned an unexpected error code"); + Genode::error("f_readdir() returned an unexpected error code"); return -1; } if (ffat_file_info.fname[0] == 0) { /* no (more) entries */ if (verbose) - PDBG("no more dir entries"); + Genode::log(__func__, ": no more dir entries"); /* TODO: reset the f_readdir() index? */ return 0; } @@ -408,7 +406,7 @@ class Plugin : public Libc::Plugin dirent->d_namlen = ::strlen(dirent->d_name); if (verbose) - PDBG("found dir entry %s", dirent->d_name); + Genode::log("found dir entry ", Genode::Cstring(dirent->d_name)); *basep += sizeof(struct dirent); return sizeof(struct dirent); @@ -447,7 +445,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_lseek() returned an unexpected error code"); + Genode::error("f_lseek() returned an unexpected error code"); return -1; } } @@ -482,7 +480,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_mkdir() returned an unexpected error code"); + Genode::error("f_mkdir() returned an unexpected error code"); return -1; } } @@ -492,7 +490,7 @@ class Plugin : public Libc::Plugin using namespace Ffat; if (verbose) - PDBG("pathname = %s", pathname); + Genode::log(__func__, ": pathname=", pathname); FIL ffat_file; BYTE ffat_flags = 0; @@ -532,7 +530,7 @@ class Plugin : public Libc::Plugin Ffat::DIR ffat_dir; FRESULT f_opendir_res = f_opendir(&ffat_dir, pathname); if (verbose) - PDBG("opendir res=%d", f_opendir_res); + Genode::log(__func__, ": opendir res=", (int)f_opendir_res); switch(f_opendir_res) { case FR_OK: { Plugin_context *context = new (Genode::env()->heap()) @@ -541,7 +539,7 @@ class Plugin : public Libc::Plugin Libc::File_descriptor *f = Libc::file_descriptor_allocator()->alloc(this, context); if (verbose) - PDBG("new fd=%d", f->libc_fd); + Genode::log(__func__, ": new fd=", f->libc_fd); return f; } @@ -559,7 +557,7 @@ class Plugin : public Libc::Plugin return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_opendir() returned an unexpected error code"); + Genode::error("f_opendir() returned an unexpected error code"); return 0; } } @@ -584,7 +582,7 @@ class Plugin : public Libc::Plugin return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_open() returned an unexpected error code"); + Genode::error("f_open() returned an unexpected error code"); return 0; } } @@ -620,7 +618,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_rename() returned an unexpected error code"); + Genode::error("f_rename() returned an unexpected error code"); return -1; } } @@ -646,7 +644,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_read() returned an unexpected error code"); + Genode::error("f_read() returned an unexpected error code"); return -1; } } @@ -688,7 +686,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_stat() returned an unexpected error code"); + Genode::error("f_stat() returned an unexpected error code"); return -1; } @@ -698,12 +696,12 @@ class Plugin : public Libc::Plugin if ((file_info.fattrib & AM_DIR) == AM_DIR) { buf->st_mode |= S_IFDIR; if (verbose) - PDBG("type: directory"); + Genode::log(__func__, ": type: directory"); } else { buf->st_mode |= S_IFREG; if (verbose) - PDBG("type: regular file with a size of %u bytes", - (unsigned int)buf->st_size); + Genode::log(__func__, ": type: regular file with a " + "size of ", buf->st_size, " bytes"); } /* TODO: handle more attributes */ @@ -716,13 +714,13 @@ class Plugin : public Libc::Plugin tm.tm_sec = (file_info.ftime & 0b0000000000011111) * 2; if (verbose) - PDBG("last modified: %04u-%02u-%02u %02u:%02u:%02u", - 1900 + tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + Genode::log("last modified: ", + 1900 + tm.tm_year, "-", tm.tm_mon, "-", tm.tm_mday, " ", + tm.tm_hour, ":", tm.tm_min, ":", tm.tm_sec); buf->st_mtime = mktime(&tm); if (buf->st_mtime == -1) - PERR("mktime() returned -1, the file modification time reported by stat() will be incorrect"); + Genode::error("mktime() returned -1, the file modification time reported by stat() will be incorrect"); return 0; } @@ -755,7 +753,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_unlink() returned an unexpected error code"); + Genode::error("f_unlink() returned an unexpected error code"); return -1; } } @@ -786,7 +784,7 @@ class Plugin : public Libc::Plugin return -1; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_write() returned an unexpected error code"); + Genode::error("f_write() returned an unexpected error code"); return -1; } } @@ -804,6 +802,5 @@ class Plugin : public Libc::Plugin void __attribute__((constructor)) init_libc_ffat(void) { - PDBG("using the libc_ffat plugin"); static Plugin plugin; } diff --git a/repos/libports/src/lib/libc_fuse/plugin.cc b/repos/libports/src/lib/libc_fuse/plugin.cc index 4042dcdd4..49aef45ab 100644 --- a/repos/libports/src/lib/libc_fuse/plugin.cc +++ b/repos/libports/src/lib/libc_fuse/plugin.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include #include #include @@ -36,9 +36,6 @@ using namespace Genode; void *operator new (size_t, void *ptr) { return ptr; } -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) -static bool const verbose = false; - /* a little helper to prevent code duplication */ static inline int check_result(int res) { @@ -59,31 +56,20 @@ static inline int check_result(int res) ** override libc defaults ** ****************************/ -/* -extern "C" int access(const char *pathname, int mode) -{ - PDBGV("pathname: %s", pathname); - return check_result(Fuse::fuse()->op.access(pathname, mode)); -} -*/ - extern "C" int chmod(const char *path, mode_t mode) { - PDBGV("path: %s", path); return check_result(Fuse::fuse()->op.chmod(path, mode)); } extern "C" int chown(const char *path, uid_t uid, gid_t gid) { - PDBGV("path: %s", path); return check_result(Fuse::fuse()->op.chown(path, uid, gid)); } extern "C" int link(const char *oldpath, const char *newpath) { - PDBGV("oldpath: %s", oldpath); return check_result(Fuse::fuse()->op.link(oldpath, newpath)); } @@ -132,7 +118,7 @@ namespace { Plugin() : Libc::Plugin(PLUGIN_PRIORITY) { if (!Fuse::init_fs()) { - PERR("FUSE fs initialization failed"); + error("FUSE fs initialization failed"); return; } } @@ -145,7 +131,6 @@ namespace { bool supports_mkdir(const char *path, mode_t mode) { - PDBGV("path: %s", path); if (Fuse::initialized() == 0) return false; @@ -154,8 +139,6 @@ namespace { bool supports_open(const char *pathname, int flags) { - PDBGV("pathname: %s", pathname); - if (Genode::strcmp(pathname, "/dev/blkdev") == 0) return false; @@ -167,7 +150,6 @@ namespace { bool supports_readlink(const char *path, char *buf, ::size_t bufsiz) { - PDBGV("path: %s", path); if (Fuse::initialized() == 0) return false; @@ -176,7 +158,6 @@ namespace { bool supports_rmdir(const char *path) { - PDBGV("path: %s", path); if (Fuse::fuse() == 0) return false; return true; @@ -184,7 +165,6 @@ namespace { bool supports_stat(const char *path) { - PDBGV("path: %s", path); if (Fuse::initialized() == 0) return false; @@ -193,7 +173,6 @@ namespace { bool supports_symlink(const char *oldpath, const char *newpath) { - PDBGV("path: %s", oldpath); if (Fuse::fuse() == 0) return false; return true; @@ -201,7 +180,6 @@ namespace { bool supports_unlink(const char *path) { - PDBGV("path: %s", path); if (Fuse::fuse() == 0) return false; return true; @@ -212,8 +190,6 @@ namespace { { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); - Fuse::fuse()->op.release(ctx->path.string(), &ctx->file_info); destroy(env()->heap(), ctx); @@ -235,7 +211,7 @@ namespace { ctx->fd_flags = arg; return 0; default: - PDBG("cmd %d not supported", cmd); + warning(__func__, ": cmd ", cmd, " not supported"); return -1; } @@ -246,8 +222,6 @@ namespace { { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); - Genode::memset(buf, 0, sizeof (struct stat)); int res = Fuse::fuse()->op.getattr(ctx->path.string(), buf); @@ -263,8 +237,6 @@ namespace { { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); - struct statvfs vfs; int res = Fuse::fuse()->op.statfs(ctx->path.string(), &vfs); @@ -292,8 +264,6 @@ namespace { { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); - int res = Fuse::fuse()->op.ftruncate(ctx->path.string(), length, &ctx->file_info); if (res != 0) { @@ -308,10 +278,9 @@ namespace { ::off_t *basep) { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); if (nbytes < sizeof (struct dirent)) { - PERR("buf too small"); + error(__func__, ": buf too small"); errno = ENOMEM; return -1; } @@ -372,7 +341,6 @@ namespace { ::off_t lseek(Libc::File_descriptor *fd, ::off_t offset, int whence) { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); switch (whence) { case SEEK_SET: @@ -400,7 +368,6 @@ namespace { int mkdir(const char *pathname, mode_t mode) { - PDBGV("pathname: %s", pathname); int res = Fuse::fuse()->op.mkdir(pathname, mode); return check_result(res); @@ -409,7 +376,6 @@ namespace { Libc::File_descriptor *open(const char *pathname, int flags) { /* XXX evaluate flags */ - PDBGV("pathname: %s", pathname); Plugin_context *context = new (Genode::env()->heap()) Plugin_context(pathname, flags); @@ -431,7 +397,7 @@ namespace { case 0: break; default: - PERR("could not create '%s'", pathname); + error(__func__, ": could not create '", pathname, "'"); destroy(env()->heap(), context); return 0; } @@ -468,7 +434,6 @@ namespace { ssize_t read(Libc::File_descriptor *fd, void *buf, ::size_t count) { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); int res = Fuse::fuse()->op.read(ctx->path.string(), reinterpret_cast(buf), @@ -484,8 +449,6 @@ namespace { ssize_t readlink(const char *path, char *buf, ::size_t bufsiz) { - PDBGV("path: %s", path); - int res = Fuse::fuse()->op.readlink(path, buf, bufsiz); if (res < 0) { errno = -res; @@ -502,7 +465,6 @@ namespace { int rename(const char *oldpath, const char *newpath) { - PDBGV("oldpath: %s newpath: %s", oldpath, newpath); int res = Fuse::fuse()->op.rename(oldpath, newpath); return check_result(res); @@ -510,7 +472,6 @@ namespace { int rmdir(const char *path) { - PDBGV("path: %s", path); int res = Fuse::fuse()->op.rmdir(path); return check_result(res); @@ -518,7 +479,6 @@ namespace { int stat(const char *path, struct stat *buf) { - PDBGV("path: %s", path); Genode::memset(buf, 0, sizeof (buf)); int res = Fuse::fuse()->op.getattr(path, buf); @@ -528,7 +488,6 @@ namespace { int symlink(const char *oldpath, const char *newpath) { - PDBGV("oldpath: %s newpath: %s", oldpath, newpath); int res = Fuse::fuse()->op.symlink(oldpath, newpath); return check_result(res); @@ -536,7 +495,6 @@ namespace { int unlink(const char *path) { - PDBGV("path: %s", path); int res = Fuse::fuse()->op.unlink(path); return check_result(res); @@ -546,7 +504,6 @@ namespace { { Plugin_context *ctx = context(fd); - PDBGV("path: %s", ctx->path.string()); int res = Fuse::fuse()->op.write(ctx->path.string(), reinterpret_cast(buf), count, ctx->offset, &ctx->file_info); @@ -574,6 +531,5 @@ void __attribute__((constructor)) init_libc_fuse(void) extern void init_libc_vfs(void); init_libc_vfs(); - PDBGV("using the libc_fuse plugin"); static Plugin plugin; } diff --git a/repos/libports/src/lib/libc_lwip/init.cc b/repos/libports/src/lib/libc_lwip/init.cc index 154b9a4bd..613308a93 100644 --- a/repos/libports/src/lib/libc_lwip/init.cc +++ b/repos/libports/src/lib/libc_lwip/init.cc @@ -12,12 +12,9 @@ * under the terms of the GNU General Public License version 2. */ -#include - extern void create_lwip_plugin(); void __attribute__((constructor)) init_libc_lwip(void) { - PDBG("init_libc_lwip()\n"); create_lwip_plugin(); } diff --git a/repos/libports/src/lib/libc_lwip/plugin.cc b/repos/libports/src/lib/libc_lwip/plugin.cc index b02a20e44..72dfce01f 100644 --- a/repos/libports/src/lib/libc_lwip/plugin.cc +++ b/repos/libports/src/lib/libc_lwip/plugin.cc @@ -13,7 +13,7 @@ */ #include -#include +#include #define LWIP_COMPAT_SOCKETS 0 @@ -221,7 +221,7 @@ struct Plugin : Libc::Plugin Plugin::Plugin() { - PDBG("using the lwIP libc plugin\n"); + Genode::log("using the lwIP libc plugin"); lwip_tcpip_init(); } @@ -285,7 +285,7 @@ Libc::File_descriptor *Plugin::accept(Libc::File_descriptor *sockfdo, Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context); if (!fd) - PERR("could not allocate file descriptor"); + Genode::error("could not allocate file descriptor"); return fd; } @@ -338,7 +338,7 @@ int Plugin::fcntl(Libc::File_descriptor *sockfdo, int cmd, long val) result = lwip_fcntl(s, cmd, (val & O_NONBLOCK) ? lwip_O_NONBLOCK : 0); break; default: - PERR("libc_lwip: unsupported fcntl() request: %d", cmd); + Genode::error("libc_lwip: unsupported fcntl() request: ", cmd); break; } @@ -398,7 +398,7 @@ int Plugin::ioctl(Libc::File_descriptor *sockfdo, int request, char *argp) return lwip_ioctl(get_lwip_fd(sockfdo), lwip_FIONREAD, argp);; break; default: - PERR("unsupported ioctl() request"); + Genode::error("unsupported ioctl() request"); errno = ENOSYS; return -1; } @@ -566,7 +566,7 @@ Libc::File_descriptor *Plugin::socket(int domain, int type, int protocol) int lwip_fd = lwip_socket(domain, type, protocol); if (lwip_fd == -1) { - PERR("lwip_socket() failed"); + Genode::error("lwip_socket() failed"); return 0; } diff --git a/repos/libports/src/lib/libc_lwip_loopback/init.cc b/repos/libports/src/lib/libc_lwip_loopback/init.cc index 442c4e498..3b184657b 100644 --- a/repos/libports/src/lib/libc_lwip_loopback/init.cc +++ b/repos/libports/src/lib/libc_lwip_loopback/init.cc @@ -12,7 +12,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include @@ -20,7 +20,7 @@ extern void create_lwip_plugin(); void __attribute__((constructor)) init_loopback(void) { - PDBG("init_loopback()\n"); + Genode::log(__func__); /* make sure the libc_lwip plugin has been created */ create_lwip_plugin(); diff --git a/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc b/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc index 67932c27d..20be6d00e 100644 --- a/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc +++ b/repos/libports/src/lib/libc_lwip_nic_dhcp/init.cc @@ -12,7 +12,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -35,7 +35,7 @@ void __attribute__((constructor)) init_nic_dhcp(void) { enum { BUF_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE * 128 }; - PDBG("init_nic_dhcp()\n"); + Genode::log(__func__); bool provide_etc_resolv_conf = true; @@ -79,21 +79,22 @@ void __attribute__((constructor)) init_nic_dhcp(void) (strlen(netmask_str) != 0) || (strlen(gateway_str) != 0)) { if (strlen(ip_addr_str) == 0) { - PERR("Missing \"ip_addr\" attribute. Ignoring network interface config."); + Genode::error("missing \"ip_addr\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } else if (strlen(netmask_str) == 0) { - PERR("Missing \"netmask\" attribute. Ignoring network interface config."); + Genode::error("missing \"netmask\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } else if (strlen(gateway_str) == 0) { - PERR("Missing \"gateway\" attribute. Ignoring network interface config."); + Genode::error("missing \"gateway\" attribute. Ignoring network interface config."); throw Genode::Xml_node::Nonexistent_attribute(); } } else throw -1; - PDBG("static network interface: ip_addr=%s netmask=%s gateway=%s ", - ip_addr_str, netmask_str, gateway_str - ); + Genode::log("static network interface: " + "ip_addr=", Genode::Cstring(ip_addr_str), " " + "netmask=", Genode::Cstring(netmask_str), " " + "gateway=", Genode::Cstring(gateway_str)); genode_uint32_t ip, nm, gw; @@ -102,7 +103,7 @@ void __attribute__((constructor)) init_nic_dhcp(void) gw = inet_addr(gateway_str); if (ip == INADDR_NONE || nm == INADDR_NONE || gw == INADDR_NONE) { - PERR("Invalid network interface config."); + Genode::error("invalid network interface config"); throw -1; } else { ip_addr = ip; @@ -111,7 +112,7 @@ void __attribute__((constructor)) init_nic_dhcp(void) } } catch (...) { - PINF("Using DHCP for interface configuration."); + Genode::log("Using DHCP for interface configuration."); } /* make sure the libc_lwip plugin has been created */ diff --git a/repos/libports/src/lib/libc_lwip_nic_dhcp/plugin.cc b/repos/libports/src/lib/libc_lwip_nic_dhcp/plugin.cc index e14400254..3fdec8b4f 100644 --- a/repos/libports/src/lib/libc_lwip_nic_dhcp/plugin.cc +++ b/repos/libports/src/lib/libc_lwip_nic_dhcp/plugin.cc @@ -220,7 +220,7 @@ namespace { { switch (cmd) { case F_GETFL: return context(fd)->status_flags(); - default: PERR("fcntl(): command %d not supported", cmd); return -1; + default: Genode::error("fcntl(): command ", cmd, " not supported", cmd); return -1; } } }; diff --git a/repos/libports/src/lib/libc_pipe/plugin.cc b/repos/libports/src/lib/libc_pipe/plugin.cc index d04b82d11..0be3cc5c4 100644 --- a/repos/libports/src/lib/libc_pipe/plugin.cc +++ b/repos/libports/src/lib/libc_pipe/plugin.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -176,7 +176,7 @@ namespace Libc_pipe { Plugin::Plugin() { - Genode::printf("using the pipe libc plugin\n"); + Genode::log("using the pipe libc plugin"); } @@ -255,15 +255,16 @@ namespace Libc_pipe { /* unsupported flags present */ - PERR("%s: command F_SETFL arg %ld not fully supported", - __PRETTY_FUNCTION__, arg); + Genode::error(__PRETTY_FUNCTION__, ": " + "command F_SETFL arg ", arg, " not fully supported"); return -1; } default: - PERR("%s: command %d arg %ld not supported", __PRETTY_FUNCTION__, cmd, arg); + Genode::error(__PRETTY_FUNCTION__, "s: command ", cmd, " " + "arg ", arg, " not supported"); return -1; } @@ -286,7 +287,7 @@ namespace Libc_pipe { ssize_t Plugin::read(Libc::File_descriptor *fdo, void *buf, ::size_t count) { if (!read_end(fdo)) { - PERR("Cannot read from write end of pipe."); + Genode::error("cannot read from write end of pipe"); errno = EBADF; return -1; } @@ -367,7 +368,7 @@ namespace Libc_pipe { ::size_t count) { if (!write_end(fdo)) { - PERR("Cannot write into read end of pipe."); + Genode::error("cannot write into read end of pipe"); errno = EBADF; return -1; } diff --git a/repos/libports/src/lib/libc_terminal/plugin.cc b/repos/libports/src/lib/libc_terminal/plugin.cc index be5af6e5e..494a71e59 100644 --- a/repos/libports/src/lib/libc_terminal/plugin.cc +++ b/repos/libports/src/lib/libc_terminal/plugin.cc @@ -24,7 +24,7 @@ /* Genode includes */ #include #include -#include +#include #include #include @@ -309,8 +309,8 @@ namespace { } } default: - PERR("fcntl(): command %d args %ld not supported - terminal", - cmd, arg); + Genode::warning("fcntl(): command ", cmd, " args ", arg, " " + "not supported - terminal"); return -1; } } diff --git a/repos/libports/src/lib/libdrm/ioctl.cc b/repos/libports/src/lib/libdrm/ioctl.cc index f06dd26e7..8ab954afe 100644 --- a/repos/libports/src/lib/libdrm/ioctl.cc +++ b/repos/libports/src/lib/libdrm/ioctl.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include /* libc includes */ #include @@ -96,12 +96,12 @@ const char *command_name(long request) static void dump_ioctl(long request) { - PDBG("ioctl(request=%lx, %s, len=%ld, cmd=%s)", request, - (request & 0xe0000000) == IOC_OUT ? "out" : - (request & 0xe0000000) == IOC_IN ? "in" : - (request & 0xe0000000) == IOC_INOUT ? "inout" : "void", - IOCPARM_LEN(request), - command_name(request)); + Genode::log("ioctl(request=", Genode::Hex(request), ", ", + (request & 0xe0000000) == IOC_OUT ? "out" : + (request & 0xe0000000) == IOC_IN ? "in" : + (request & 0xe0000000) == IOC_INOUT ? "inout" : "void", ", " + "len=", IOCPARM_LEN(request), ", " + "cmd=", command_name(request), ")"); } @@ -129,7 +129,7 @@ namespace { Libc::Plugin(PLUGIN_PRIORITY), _driver(driver), _client(0) { if (!_driver) { - PERR("could not initialize GPU driver"); + Genode::error("could not initialize GPU driver"); return; } _client = _driver->create_client(); @@ -199,8 +199,13 @@ namespace { void *mmap(void *addr, ::size_t length, int prot, int flags, Libc::File_descriptor *fd, ::off_t offset) { - PDBG("\naddr=%p, length=%zd, prot=%x, flags=%x, offset=0x%lx", - addr, length, prot, flags, (long)offset); + using namespace Genode; + log(__func__, ": " + "addr=", addr, ", " + "length=", length, ", " + "prot=", Hex(prot), ", " + "flags=", Hex(flags), ", " + "offset=", Hex(offset)); return (void *)offset; } diff --git a/repos/libports/src/lib/lwip/platform/nic.cc b/repos/libports/src/lib/lwip/platform/nic.cc index 1a0219c71..168de9e8c 100644 --- a/repos/libports/src/lib/lwip/platform/nic.cc +++ b/repos/libports/src/lib/lwip/platform/nic.cc @@ -28,7 +28,7 @@ extern "C" { /* Genode includes */ #include -#include +#include #include #include @@ -254,7 +254,7 @@ extern "C" { if (netif->input(p, netif) != ERR_OK) { if (verbose) - PERR("genode_netif_input: input error"); + Genode::error("genode_netif_input: input error"); pbuf_free(p); p = 0; } diff --git a/repos/libports/src/lib/lwip/platform/sys_arch.cc b/repos/libports/src/lib/lwip/platform/sys_arch.cc index 9cef5d54f..53650856b 100644 --- a/repos/libports/src/lib/lwip/platform/sys_arch.cc +++ b/repos/libports/src/lib/lwip/platform/sys_arch.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -109,11 +109,11 @@ extern "C" { static ip_addr_t ip_addr = { 0 }; if (ip_addr.addr != netif->ip_addr.addr) { - PINF("got IP address %d.%d.%d.%d", - ip4_addr1(&(netif->ip_addr)), - ip4_addr2(&(netif->ip_addr)), - ip4_addr3(&(netif->ip_addr)), - ip4_addr4(&(netif->ip_addr))); + Genode::log("got IP address ", + ip4_addr1(&(netif->ip_addr)), ".", + ip4_addr2(&(netif->ip_addr)), ".", + ip4_addr3(&(netif->ip_addr)), ".", + ip4_addr4(&(netif->ip_addr))); ip_addr.addr = netif->ip_addr.addr; } } @@ -203,7 +203,7 @@ extern "C" { netifapi_netif_set_up(&netif); } } catch (Nic_not_availble) { - PWRN("NIC not available, loopback is used as default"); + Genode::warning("NIC not available, loopback is used as default"); return 2; } return 0; @@ -237,10 +237,10 @@ extern "C" { sem->ptr = _sem; return ERR_OK; } catch (Genode::Allocator::Out_of_memory) { - PWRN("Out of memory"); + Genode::warning(__func__, ": out of memory"); return ERR_MEM; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); /* we just use a arbitrary value that is * not defined in err.h */ return -32; @@ -261,7 +261,7 @@ extern "C" { if (_sem) destroy(Genode::env()->heap(), _sem); } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); } } @@ -276,12 +276,11 @@ extern "C" { Genode::Timed_semaphore *_sem = reinterpret_cast(sem->ptr); if (!_sem) { - //PERR("Invalid semaphore pointer at: %lx", *sem->ptr); return; } _sem->up(); } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); } } @@ -333,7 +332,6 @@ extern "C" { try { Timed_semaphore *_sem = reinterpret_cast(sem->ptr); if (!_sem) { - //PERR("Invalid semaphore pointer at: %lx", *sem->ptr); return EINVAL; } @@ -348,7 +346,7 @@ extern "C" { } catch (Timeout_exception) { return SYS_ARCH_TIMEOUT; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); return -1; } } @@ -401,10 +399,10 @@ extern "C" { mbox->ptr = _mbox; return ERR_OK; } catch (Genode::Allocator::Out_of_memory) { - PWRN("Out of memory"); + Genode::warning(__func__, ": out of memory"); return ERR_MEM; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); return -32; } } @@ -422,7 +420,7 @@ extern "C" { if (_mbox) destroy(Genode::env()->heap(), _mbox); } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); } } @@ -473,16 +471,15 @@ extern "C" { try { Mailbox* _mbox = reinterpret_cast(mbox->ptr); if (!_mbox) { - //PERR("Invalid mailbox pointer at %lx", *mbox->ptr); return; } _mbox->add(msg); return; } catch (Mailbox::Overflow) { if (verbose) - PWRN("Overflow exception!"); + Genode::warning(__func__, ": overflow exception!"); } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); } } } @@ -499,16 +496,15 @@ extern "C" { try { Mailbox* _mbox = reinterpret_cast(mbox->ptr); if (!_mbox) { - //PERR("Invalid mailbox pointer at %lx", *mbox->ptr); return EINVAL; } _mbox->add(msg); return ERR_OK; } catch (Mailbox::Overflow) { if (verbose) - PWRN("Overflow exception!"); + Genode::warning(__func__, ": overflow exception!"); } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); } return ERR_MEM; } @@ -542,7 +538,7 @@ extern "C" { } catch (Genode::Nonblocking_exception) { ret = SYS_MBOX_EMPTY; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); ret = SYS_ARCH_TIMEOUT; } @@ -591,10 +587,10 @@ extern "C" { _th->start(); return (sys_thread_t) _th; } catch (Genode::Allocator::Out_of_memory) { - PWRN("Out of memory"); + Genode::warning(__func__, ": out of memory"); return 0; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown Exception occured!"); return ERR_MEM; } } @@ -644,7 +640,7 @@ extern "C" { return &tt->timeouts; } catch (...) { - PERR("Unknown Exception occured!"); + Genode::error(__func__, ": unknown exception occured!"); return 0; } } @@ -659,6 +655,6 @@ extern "C" { extern "C" void lwip_sleep_forever() { int dummy = 1; - PDBG("thread %u", (unsigned)(((Genode::addr_t)&dummy)>>20)&0xff); + Genode::log(__func__, ": thread ", (unsigned)(((Genode::addr_t)&dummy)>>20)&0xff); Genode::sleep_forever(); } diff --git a/repos/libports/src/lib/ntfs-3g/init.cc b/repos/libports/src/lib/ntfs-3g/init.cc index 7be0c94ec..220226dbc 100644 --- a/repos/libports/src/lib/ntfs-3g/init.cc +++ b/repos/libports/src/lib/ntfs-3g/init.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -48,7 +48,7 @@ bool Fuse::init_fs(void) *ctx = reinterpret_cast(malloc(sizeof (ntfs_fuse_context_t))); if (!*ctx) { - PERR("out-of-memory"); + Genode::error("out of memory"); return false; } @@ -69,17 +69,17 @@ bool Fuse::init_fs(void) }; */ - PLOG("libc_fuse_ntfs-3g: try to mount /dev/blkdev..."); + Genode::log("libc_fuse_ntfs-3g: try to mount /dev/blkdev..."); int err = ntfs_open("/dev/blkdev"); if (err) { - PERR("libc_fuse_ntfs-3g: could not mount /dev/blkdev"); + Genode::error("libc_fuse_ntfs-3g: could not mount /dev/blkdev"); return false; } fh = fuse_new(fc, NULL, &ntfs_3g_ops, sizeof (ntfs_3g_ops), NULL); if (fh == 0) { - PERR("libc_fuse_exfat: fuse_new() failed"); + Genode::error("libc_fuse_exfat: fuse_new() failed"); ntfs_close(); return false; } @@ -92,7 +92,7 @@ bool Fuse::init_fs(void) void Fuse::deinit_fs(void) { - PLOG("libc_fuse_ntfs-3g: unmount /dev/blkdev..."); + Genode::log("libc_fuse_ntfs-3g: unmount /dev/blkdev..."); ntfs_close(); free(*ntfs_fuse_ctx()); @@ -101,7 +101,7 @@ void Fuse::deinit_fs(void) void Fuse::sync_fs(void) { - PLOG("libc_fuse_ntfs-3g: sync file system..."); + Genode::log("libc_fuse_ntfs-3g: sync file system..."); ntfs_device_sync((*ntfs_fuse_ctx())->vol->dev); } diff --git a/repos/libports/src/lib/pthread/semaphore.cc b/repos/libports/src/lib/pthread/semaphore.cc index a215d0575..3a6715168 100644 --- a/repos/libports/src/lib/pthread/semaphore.cc +++ b/repos/libports/src/lib/pthread/semaphore.cc @@ -13,7 +13,7 @@ */ #include -#include +#include #include using namespace Genode; @@ -32,7 +32,7 @@ extern "C" { int sem_close(sem_t *) { - PDBG("not implemented"); + warning(__func__, " not implemented"); return -1; } @@ -60,7 +60,7 @@ extern "C" { sem_t *sem_open(const char *, int, ...) { - PDBG("not implemented"); + warning(__func__, " not implemented"); return 0; } @@ -74,21 +74,21 @@ extern "C" { int sem_timedwait(sem_t * __restrict, const struct timespec * __restrict) { - PDBG("not implemented"); + warning(__func__, " not implemented"); return -1; } int sem_trywait(sem_t *) { - PDBG("not implemented"); + warning(__func__, " not implemented"); return -1; } int sem_unlink(const char *) { - PDBG("not implemented"); + warning(__func__, " not implemented"); return -1; } diff --git a/repos/libports/src/lib/pthread/thread.cc b/repos/libports/src/lib/pthread/thread.cc index d11672287..f918894e9 100644 --- a/repos/libports/src/lib/pthread/thread.cc +++ b/repos/libports/src/lib/pthread/thread.cc @@ -13,7 +13,7 @@ */ #include -#include +#include #include #include #include @@ -140,8 +140,8 @@ extern "C" { */ if (!_pthread_main_np()) { - PERR("pthread_self() called from alien thread named '%s'", - myself->name().string()); + error("pthread_self() called from alien thread named ", + "'", myself->name().string(), "'"); return nullptr; } @@ -167,7 +167,7 @@ extern "C" { size_t *stacksize) { /* FIXME */ - PWRN("pthread_attr_getstack() called, might not work correctly"); + warning("pthread_attr_getstack() called, might not work correctly"); if (!attr || !*attr || !stackaddr || !stacksize) return EINVAL; @@ -433,7 +433,7 @@ extern "C" { if (!attr || !*attr) return EINVAL; - PDBG("not implemented yet"); + warning(__func__, " not implemented yet"); return 0; } @@ -445,7 +445,7 @@ extern "C" { if (!attr || !*attr) return EINVAL; - PDBG("not implemented yet"); + warning(__func__, " not implemented yet"); return 0; } diff --git a/repos/libports/src/lib/qemu-usb/host.cc b/repos/libports/src/lib/qemu-usb/host.cc index 6255b6b73..1a34114bd 100644 --- a/repos/libports/src/lib/qemu-usb/host.cc +++ b/repos/libports/src/lib/qemu-usb/host.cc @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include @@ -63,7 +63,8 @@ struct Completion : Usb::Completion if (actual_size < 0) actual_size = 0; if (verbose_host) - PDBG("packet.type: %u actual_size: 0x%x", packet.type, actual_size); + log(__func__, ": packet.type: ", (int)packet.type, " " + "actual_size: ", Hex(actual_size)); p->actual_length = 0; @@ -151,7 +152,7 @@ struct Usb_host_device : List::Element } } - if (!result) PERR("Device already claimed"); + if (!result) error("device already claimed"); return result; } @@ -338,7 +339,7 @@ struct Usb_host_device : List::Element ** Qemu interface ** ********************/ -#define TRACE_AND_STOP do { PDBG("not implemented"); } while(false) +#define TRACE_AND_STOP do { warning(__func__, " not implemented"); } while(false) #define USB_HOST_DEVICE(obj) \ OBJECT_CHECK(USBHostDevice, (obj), TYPE_USB_HOST_DEVICE) @@ -374,7 +375,7 @@ static void usb_host_realize(USBDevice *udev, Error **errp) dev->usb_raw.config_descriptor(&ddescr, &cdescr); if (verbose_host) - PDBG("set udev->speed to %d", Usb_host_device::to_qemu_speed(ddescr.speed)); + log("set udev->speed to %d", Usb_host_device::to_qemu_speed(ddescr.speed)); udev->speed = Usb_host_device::to_qemu_speed(ddescr.speed); udev->speedmask = (1 << udev->speed); @@ -428,7 +429,7 @@ static void usb_host_handle_data(USBDevice *udev, USBPacket *p) } break; default: - PERR("not supported data request"); + error("not supported data request"); break; } @@ -462,7 +463,8 @@ static void usb_host_handle_control(USBDevice *udev, USBPacket *p, Usb_host_device *dev = (Usb_host_device *)d->data; if (verbose_host) - PDBG("r: %x v: %x i: %x length: %d", request, value, index, length); + log("r: ", Hex(request), " v: ", Hex(value), " " + "i: ", Hex(index), " length: ", length); switch (request) { case DeviceOutRequest | USB_REQ_SET_ADDRESS: @@ -479,13 +481,13 @@ static void usb_host_handle_control(USBDevice *udev, USBPacket *p, if (udev->speed == USB_SPEED_SUPER && !(udev->port->speedmask & USB_SPEED_MASK_SUPER) && request == 0x8006 && value == 0x100 && index == 0) { - PERR("r->usb3ep0quirk = true"); + error("r->usb3ep0quirk = true"); } Usb::Packet_descriptor packet; try { packet = dev->alloc_packet(length); - } catch (...) { PERR("Packet allocation failed"); return; } + } catch (...) { error("Packet allocation failed"); return; } packet.type = Usb::Packet_descriptor::CTRL; packet.control.request_type = request >> 8; @@ -567,6 +569,28 @@ struct Usb_devices : List return nullptr; } + /** + * Helper for the formatted output of device info + */ + struct Formatted_dev_info + { + uint32_t const vendor, product; + uint16_t const bus, dev; + + Formatted_dev_info(uint16_t bus, uint16_t dev, uint32_t vendor, uint32_t product) + : + vendor(vendor), product(product), bus(bus), dev(dev) + { } + + void print(Genode::Output &out) const + { + Genode::print(out, Hex(bus, Hex::OMIT_PREFIX, Hex::PAD), ":", + Hex(dev, Hex::OMIT_PREFIX, Hex::PAD), " (", + "vendor=", Hex(vendor, Hex::OMIT_PREFIX), ", ", + "product=", Hex(product, Hex::OMIT_PREFIX), ")"); + } + }; + void _devices_update(unsigned) { Lock::Guard g(_lock); @@ -578,7 +602,7 @@ struct Usb_devices : List return; if (verbose_devices) - PINF("%s", _devices_rom.local_addr()); + log(_devices_rom.local_addr()); Xml_node devices_node(_devices_rom.local_addr(), _devices_rom.size()); devices_node.for_each_sub_node("device", [&] (Xml_node const &node) { @@ -588,11 +612,13 @@ struct Usb_devices : List unsigned bus = node.attribute_value("bus", 0); unsigned dev = node.attribute_value("dev", 0); + Formatted_dev_info const formatted_dev_info(bus, dev, vendor, product); + Genode::String<128> label; try { node.attribute("label").value(&label); } catch (Genode::Xml_attribute::Nonexistent_attribute) { - PERR("No label found for device %03x:%03x", bus, dev); + error("no label found for device ", formatted_dev_info); return; } @@ -605,12 +631,10 @@ struct Usb_devices : List insert(new_device); - PINF("Attach USB device %03x:%03x (%x:%x)", - bus, dev, vendor, product); + log("Attach USB device ", formatted_dev_info); } catch (...) { - PERR("Could not attach USB device %03x:%03x (%x:%x)", - bus, dev, vendor, product); + error("could not attach USB device ", formatted_dev_info); } }); } diff --git a/repos/libports/src/lib/qemu-usb/qemu_emul.cc b/repos/libports/src/lib/qemu-usb/qemu_emul.cc index 68549eab3..77a17edaa 100644 --- a/repos/libports/src/lib/qemu-usb/qemu_emul.cc +++ b/repos/libports/src/lib/qemu-usb/qemu_emul.cc @@ -15,6 +15,7 @@ /* Genode includes */ #include #include +#include #include /* local includes */ @@ -241,7 +242,8 @@ struct Object_pool return &w; } - PERR("object for pointer not found called from: %p", __builtin_return_address(0)); + Genode::error("object for pointer not found called from: ", + __builtin_return_address(0)); throw -1; } @@ -319,7 +321,7 @@ USBHostDevice *create_usbdevice(void *data) { Wrapper *obj = Object_pool::p()->create_object(); if (!obj) { - PERR("could not create new object"); + Genode::error("could not create new object"); return nullptr; } @@ -360,10 +362,10 @@ void remove_usbdevice(USBHostDevice *device) DeviceState *usb_device_state = cast_DeviceState(device); if (usb_device_class == nullptr) - PERR("usb_device_class null"); + Genode::error("usb_device_class null"); if (usb_device_state == nullptr) - PERR("usb_device_class null"); + Genode::error("usb_device_class null"); Error *e = nullptr; usb_device_class->unrealize(usb_device_state, &e); @@ -457,7 +459,7 @@ QEMUTimer* timer_new_ns(QEMUClockType, void (*cb)(void*), void *opaque) { QEMUTimer *t = (QEMUTimer*)malloc(sizeof(QEMUTimer)); if (t == nullptr) { - PERR("could not create QEMUTimer"); + Genode::error("could not create QEMUTimer"); return nullptr; } @@ -484,6 +486,8 @@ struct Controller : public Qemu::Controller uint64_t _mmio_size; + typedef Genode::Hex Hex; + Controller() { Genode::memset(mmio_regions, 0, sizeof(mmio_regions)); @@ -511,7 +515,8 @@ struct Controller : public Qemu::Controller return mmio; } - PERR("could not find MMIO region for offset: %lx", offset); + Genode::error("could not find MMIO region for offset: ", + Genode::Hex(offset)); throw -1; } @@ -547,7 +552,8 @@ struct Controller : public Qemu::Controller *((uint32_t*)buf) = v; if (verbose_mmio) - PDBG("mmio: %lx offset: %lx reg: %lx v: %llx", mmio.id, offset, reg, v); + Genode::log(__func__, ": ", Hex(mmio.id), " offset: ", Hex(offset), " " + "reg: ", Hex(reg), " v: ", Hex(v)); return 0; } @@ -572,7 +578,8 @@ struct Controller : public Qemu::Controller mmio.ops->write(ptr, reg, v, size); if (verbose_mmio) - PDBG("mmio: %lx offset: %lx reg: %lx v: %llx", mmio.id, offset, reg, v); + Genode::log(__func__, ": ", Hex(mmio.id), " offset: ", Hex(offset), " " + "reg: ", Hex(reg), " v: ", Hex(v)); return 0; } @@ -637,7 +644,7 @@ int dma_memory_read(AddressSpace*, dma_addr_t addr, void *buf, dma_addr_t size) void pci_set_irq(PCIDevice*, int level) { if (verbose_irq) - PDBG("IRQ level: %d", level); + Genode::log(__func__, ": IRQ level: ", level); _pci_device->raise_interrupt(level); } @@ -690,12 +697,13 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len) if (qiov->alloc_hint <= niov) { if (verbose_iov) - PDBG("alloc_hint %d <= niov: %d", qiov->alloc_hint, niov); + Genode::log(__func__, ": alloc_hint ", qiov->alloc_hint, + " <= niov: ", niov); qiov->alloc_hint += 64; iovec *new_iov = (iovec*) malloc(sizeof(iovec) * qiov->alloc_hint); if (new_iov == nullptr) { - PERR("Could not reallocate iov"); + Genode::error("could not reallocate iov"); throw -1; } @@ -709,8 +717,8 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len) } if (verbose_iov) - PDBG("niov: %u iov_base: %p base: %p len: %zu", - niov, &qiov->iov[niov].iov_base, base, len); + Genode::log(__func__, ": niov: ", niov, " iov_base: ", + &qiov->iov[niov].iov_base, " base: ", base, " len: ", len); qiov->iov[niov].iov_base = base; qiov->iov[niov].iov_len = len; @@ -738,12 +746,12 @@ void qemu_iovec_reset(QEMUIOVector *qiov) void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) { if (verbose_iov) - PDBG("iov: %p alloc_hint: %d", qiov->iov, alloc_hint); + Genode::log(__func__, " iov: ", qiov->iov, " alloc_hint: ", alloc_hint); iovec *iov = qiov->iov; if (iov != nullptr) { if (alloc_hint > qiov->alloc_hint) - PERR("iov already initialized: %p and alloc_hint smaller", iov); + Genode::error("iov already initialized: ", iov, " and alloc_hint smaller"); qemu_iovec_reset(qiov); return; @@ -755,7 +763,7 @@ void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) qiov->iov = (iovec*) malloc(sizeof(iovec) * alloc_hint); if (qiov->iov == nullptr) { - PERR("Could not allocate iov"); + Genode::error("could not allocate iov"); throw -1; } @@ -833,7 +841,8 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl) dma_addr_t xlen = len; mem = _pci_device->map_dma(base, xlen); if (verbose_iov) - PDBG("mem: 0x%p base: 0x%p len: 0x%lx", mem, (void*)base, len); + Genode::log("mem: ", mem, " base: ", (void *)base, " len: ", + Genode::Hex(len)); if (!mem) { goto err; @@ -849,7 +858,7 @@ int usb_packet_map(USBPacket *p, QEMUSGList *sgl) return 0; err: - PERR("could not map dma"); + Genode::error("could not map dma"); usb_packet_unmap(p, sgl); return -1; } @@ -874,7 +883,7 @@ void error_setg(Error **errp, const char *fmt, ...) *errp = (Error*) malloc(sizeof(Error)); if (*errp == nullptr) { - PERR("Could not allocate Error"); + Genode::error("could not allocate Error"); return; } diff --git a/repos/libports/src/lib/qt5/patches/qt5_qml.patch b/repos/libports/src/lib/qt5/patches/qt5_qml.patch index 06cd7038d..dc6c91773 100644 --- a/repos/libports/src/lib/qt5/patches/qt5_qml.patch +++ b/repos/libports/src/lib/qt5/patches/qt5_qml.patch @@ -8,9 +8,9 @@ From: Christian Prochaska qtdeclarative/src/qml/qml/qqmlimport.cpp | 9 qtdeclarative/src/qml/qml/v8/qv8qobjectwrapper.cpp | 4 qtdeclarative/src/qml/types/qqmldelegatemodel_p.h | 2 - qtjsbackend/src/3rdparty/v8/src/platform-genode.cc | 706 ++++++++++++++++++++ + qtjsbackend/src/3rdparty/v8/src/platform-genode.cc | 686 ++++++++++++++++++++ qtjsbackend/src/v8/v8.pri | 2 - 6 files changed, 722 insertions(+), 3 deletions(-) + 6 files changed, 702 insertions(+), 3 deletions(-) create mode 100644 qtjsbackend/src/3rdparty/v8/src/platform-genode.cc diff --git a/qtdeclarative/src/qml/qml/qqmlaccessors_p.h b/qtdeclarative/src/qml/qml/qqmlaccessors_p.h @@ -90,10 +90,10 @@ index 5702c59..3d616b5 100644 QT_BEGIN_NAMESPACE diff --git a/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc b/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc new file mode 100644 -index 0000000..de6f632 +index 0000000..25bdfc7 --- /dev/null +++ b/qtjsbackend/src/3rdparty/v8/src/platform-genode.cc -@@ -0,0 +1,706 @@ +@@ -0,0 +1,686 @@ +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are @@ -126,7 +126,7 @@ index 0000000..de6f632 +// Minimal include to get access to abort, fprintf and friends for bootstrapping +// messages. + -+#include ++#include +#include +#include +#include @@ -148,12 +148,10 @@ index 0000000..de6f632 +namespace v8 { +namespace internal { + -+static const bool verbose = false; -+ +static const pthread_t kNoThread = (pthread_t) 0; + +#undef UNIMPLEMENTED -+#define UNIMPLEMENTED(...) PDBG("UNIMPLEMENTED") ++#define UNIMPLEMENTED(...) Genode::warning(__PRETTY_FUNCTION__, ": UNIMPLEMENTED") + + +double ceiling(double x) { @@ -350,11 +348,9 @@ index 0000000..de6f632 + try { + Genode::env()->rm_session()->attach_at(_ds_cap, _base_addr); + return; -+ } catch (Genode::Region_map::Region_conflict) { -+ if (verbose) -+ PDBG("could not attach at address 0x%lx", _base_addr); -+ } ++ } catch (Genode::Region_map::Region_conflict) { } + } ++ Genode::error(__PRETTY_FUNCTION__, ": could not attach region"); + throw Region_map::Region_conflict(); + } + } @@ -378,9 +374,6 @@ index 0000000..de6f632 + + Attached_region_map *find_by_addr(Genode::addr_t addr) + { -+ if (verbose) -+ PDBG("addr = 0x%lx, _base_addr = 0x%lx, _end_addr = 0x%lx", -+ addr, _base_addr, _base_addr + _size); + if ((addr >= _base_addr) && (addr < _base_addr + _size)) + return this; + @@ -411,12 +404,10 @@ index 0000000..de6f632 + try { + rm = new Attached_region_map(size, alignment); + } catch (Attached_region_map::Region_conflict) { -+ PDBG("could not reserve region"); ++ Genode::error(__PRETTY_FUNCTION__, ": could not reserve region"); + return 0; + } + vm_registry().insert(rm); -+ if (verbose) -+ PDBG("base_addr = 0x%p", rm->base_addr()); + return rm->base_addr(); +} + @@ -426,16 +417,12 @@ index 0000000..de6f632 + + +VirtualMemory::VirtualMemory(size_t size) { -+ if (verbose) -+ PDBG("size = 0x%zx", size); + address_ = ReserveRegion(size); + size_ = size; +} + + +VirtualMemory::VirtualMemory(size_t size, size_t alignment) { -+ if (verbose) -+ PDBG("size = 0x%zx, alignment = 0x%zx", size, alignment); + address_ = reserve_region(size, alignment); + size_ = size; +} @@ -484,13 +471,10 @@ index 0000000..de6f632 + + +bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { -+ if (verbose) -+ PDBG("base = 0x%p, size = 0x%zx", base, size); + Attached_region_map *rm = vm_registry().first(); + rm = rm->find_by_addr((Genode::addr_t)base); + if (!rm) { -+ if (verbose) -+ PDBG("could not find RM connection"); ++ Genode::error(__PRETTY_FUNCTION__, ": could not find RM connection"); + return false; + } + @@ -509,8 +493,6 @@ index 0000000..de6f632 + +bool VirtualMemory::UncommitRegion(void* base, size_t size) { + UNIMPLEMENTED(); -+ if (verbose) -+ PDBG("base = 0x%p, size = 0x%zx", base, size); + return false; +} + @@ -528,8 +510,6 @@ index 0000000..de6f632 + * be detached before detaching the sub RM session. + */ + -+ if (verbose) -+ PDBG("base = 0x%p, size = 0x%zx", base, size); + Attached_rm_connection *rm = vm_registry().first(); + /* XXX: also pass the size for checking? */ + rm = rm->find_by_addr((Genode::addr_t)base); diff --git a/repos/libports/src/lib/qt5/patches/qt5_qtbase_genode.patch b/repos/libports/src/lib/qt5/patches/qt5_qtbase_genode.patch index 0410032ad..f35d6f695 100644 --- a/repos/libports/src/lib/qt5/patches/qt5_qtbase_genode.patch +++ b/repos/libports/src/lib/qt5/patches/qt5_qtbase_genode.patch @@ -41,7 +41,7 @@ index 1cedd3a..646be07 100644 // Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG // environment variables. diff --git a/qtbase/src/corelib/global/qlogging.cpp b/qtbase/src/corelib/global/qlogging.cpp -index c8293be..c7e9422 100644 +index c8293be..02b7e40 100644 --- a/qtbase/src/corelib/global/qlogging.cpp +++ b/qtbase/src/corelib/global/qlogging.cpp @@ -61,6 +61,10 @@ @@ -49,7 +49,7 @@ index c8293be..c7e9422 100644 #endif +#ifdef Q_OS_GENODE -+#include ++#include +#endif + #include @@ -60,7 +60,7 @@ index c8293be..c7e9422 100644 #if defined(QT_USE_SLOG2) slog2_default_handler(type, logMessage.toLocal8Bit().constData()); +#elif defined(Q_OS_GENODE) -+ PDBG("%s", logMessage.toLocal8Bit().constData()); ++ Genode::log(logMessage.toLocal8Bit().constData()); #elif defined(Q_OS_ANDROID) static bool logToAndroid = qEnvironmentVariableIsEmpty("QT_ANDROID_PLAIN_LOG"); if (logToAndroid) { @@ -273,7 +273,7 @@ index 100e014..00263a0 100644 #endif } diff --git a/qtbase/src/corelib/kernel/qeventdispatcher_unix.cpp b/qtbase/src/corelib/kernel/qeventdispatcher_unix.cpp -index 69363bc..0a7aa7d 100644 +index 69363bc..be1a7cf 100644 --- a/qtbase/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/qtbase/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -74,6 +74,11 @@ @@ -282,7 +282,7 @@ index 69363bc..0a7aa7d 100644 +#ifdef Q_OS_GENODE +#include -+#define perror PERR ++#define perror Genode::error +#endif /* Q_OS_GENODE */ + QT_BEGIN_NAMESPACE diff --git a/repos/libports/src/lib/qt5/patches/qt5_qtscript.patch b/repos/libports/src/lib/qt5/patches/qt5_qtscript.patch index efce5bacb..52c2780df 100644 --- a/repos/libports/src/lib/qt5/patches/qt5_qtscript.patch +++ b/repos/libports/src/lib/qt5/patches/qt5_qtscript.patch @@ -6,10 +6,10 @@ From: Christian Prochaska --- qtbase/src/corelib/global/qglobal.h | 6 +++++- qtbase/src/corelib/kernel/qvariant_p.h | 3 +++ - .../JavaScriptCore/runtime/Collector.cpp | 21 ++++++++++++++++++++ - .../javascriptcore/JavaScriptCore/wtf/Assertions.h | 11 ++++++++++ + .../JavaScriptCore/runtime/Collector.cpp | 20 ++++++++++++++++++++ + .../javascriptcore/JavaScriptCore/wtf/Assertions.h | 11 +++++++++++ .../javascriptcore/JavaScriptCore/wtf/Platform.h | 5 +++++ - 5 files changed, 45 insertions(+), 1 deletion(-) + 5 files changed, 44 insertions(+), 1 deletion(-) diff --git a/qtbase/src/corelib/global/qglobal.h b/qtbase/src/corelib/global/qglobal.h index 79e32fe..324c168 100644 @@ -50,16 +50,15 @@ index 4ec049e..e5e8dc4 100644 m_x->is_shared = false; m_x->is_null = !m_copy; diff --git a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp -index d5adbd7..d9dd773 100644 +index d5adbd7..d2a5ad9 100644 --- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp +++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp -@@ -64,6 +64,13 @@ +@@ -64,6 +64,12 @@ #include +#elif OS(GENODE) + -+#include +#include +#include +#include @@ -67,7 +66,7 @@ index d5adbd7..d9dd773 100644 #elif OS(UNIX) #include -@@ -209,6 +216,15 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() +@@ -209,6 +215,15 @@ NEVER_INLINE CollectorBlock* Heap::allocateBlock() void* address = _aligned_malloc(BLOCK_SIZE, BLOCK_SIZE); #endif memset(address, 0, BLOCK_SIZE); @@ -83,7 +82,7 @@ index d5adbd7..d9dd773 100644 #elif HAVE(POSIX_MEMALIGN) void* address; posix_memalign(&address, BLOCK_SIZE, BLOCK_SIZE); -@@ -299,6 +315,9 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block) +@@ -299,6 +314,9 @@ NEVER_INLINE void Heap::freeBlockPtr(CollectorBlock* block) #else _aligned_free(block); #endif @@ -93,7 +92,7 @@ index d5adbd7..d9dd773 100644 #elif HAVE(POSIX_MEMALIGN) free(block); #else -@@ -649,6 +668,8 @@ static inline void* currentThreadStackBase() +@@ -649,6 +667,8 @@ static inline void* currentThreadStackBase() thread_info threadInfo; get_thread_info(find_thread(NULL), &threadInfo); return threadInfo.stack_end; @@ -103,7 +102,7 @@ index d5adbd7..d9dd773 100644 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); MutexLocker locker(mutex); diff --git a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h -index 352a74b..6a1aea3 100644 +index 352a74b..20ef8b4 100644 --- a/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h +++ b/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h @@ -44,6 +44,10 @@ @@ -111,7 +110,7 @@ index 352a74b..6a1aea3 100644 #include "Platform.h" +#if OS(GENODE) -+#include ++#include +#endif + #if COMPILER(MSVC) @@ -123,8 +122,8 @@ index 352a74b..6a1aea3 100644 } while(false) +#elif OS(GENODE) +#define CRASH() ( \ -+ PERR("QtScript CRASH in '%s'", WTF_PRETTY_FUNCTION), \ -+ PERR(" in %s:%d", __FILE__, __LINE__), \ ++ Genode::error("QtScript CRASH in '", WTF_PRETTY_FUNCTION, "'"), \ ++ Genode::error(" in ", __FILE__, ":", __LINE__), \ + *(int *)(uintptr_t)0xbbadbeef = 0, \ + ((void(*)())0)() /* More reliable, but doesn't say BBADBEEF */ \ +) diff --git a/repos/libports/src/lib/qt5/patches/qt5_qtwebkit.patch b/repos/libports/src/lib/qt5/patches/qt5_qtwebkit.patch index 405f94154..4db0c905f 100644 --- a/repos/libports/src/lib/qt5/patches/qt5_qtwebkit.patch +++ b/repos/libports/src/lib/qt5/patches/qt5_qtwebkit.patch @@ -6,16 +6,16 @@ From: Christian Prochaska --- .../Source/JavaScriptCore/dfg/DFGOperations.cpp | 1 + .../JavaScriptCore/jit/ExecutableAllocator.h | 8 ++++++++ - qtwebkit/Source/WTF/wtf/Assertions.h | 11 ++++++++++ + qtwebkit/Source/WTF/wtf/Assertions.h | 11 +++++++++++ qtwebkit/Source/WTF/wtf/FastMalloc.cpp | 2 +- qtwebkit/Source/WTF/wtf/InlineASM.h | 4 ++-- - qtwebkit/Source/WTF/wtf/OSAllocatorPosix.cpp | 13 ++++++++++++ + qtwebkit/Source/WTF/wtf/OSAllocatorPosix.cpp | 13 +++++++++++++ qtwebkit/Source/WTF/wtf/OSRandomSource.cpp | 8 ++++++++ - qtwebkit/Source/WTF/wtf/Platform.h | 19 +++++++++++++++--- - qtwebkit/Source/WTF/wtf/StackBounds.cpp | 13 ++++++++++++ - qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp | 21 ++++++++++++++++++++ + qtwebkit/Source/WTF/wtf/Platform.h | 19 ++++++++++++++++--- + qtwebkit/Source/WTF/wtf/StackBounds.cpp | 13 +++++++++++++ + qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp | 20 ++++++++++++++++++++ .../platform/graphics/qt/MediaPlayerPrivateQt.cpp | 3 +++ - 11 files changed, 97 insertions(+), 6 deletions(-) + 11 files changed, 96 insertions(+), 6 deletions(-) diff --git a/qtwebkit/Source/JavaScriptCore/dfg/DFGOperations.cpp b/qtwebkit/Source/JavaScriptCore/dfg/DFGOperations.cpp index bb9ccc3..077cbed 100644 @@ -50,7 +50,7 @@ index 85779e6..231ba3b 100644 static const size_t fixedExecutableMemoryPoolSize = 32 * 1024 * 1024; #endif diff --git a/qtwebkit/Source/WTF/wtf/Assertions.h b/qtwebkit/Source/WTF/wtf/Assertions.h -index 7e079ab..cac10fc 100644 +index 7e079ab..2a54393 100644 --- a/qtwebkit/Source/WTF/wtf/Assertions.h +++ b/qtwebkit/Source/WTF/wtf/Assertions.h @@ -50,6 +50,10 @@ @@ -58,7 +58,7 @@ index 7e079ab..cac10fc 100644 #endif +#if OS(GENODE) -+#include ++#include +#endif + #ifdef NDEBUG @@ -70,8 +70,8 @@ index 7e079ab..cac10fc 100644 __builtin_trap()) +#elif OS(GENODE) +#define CRASH() ( \ -+ PERR("WebKit CRASH in '%s'", WTF_PRETTY_FUNCTION), \ -+ PERR(" in %s:%d", __FILE__, __LINE__), \ ++ Genode::error("WebKit CRASH in '", WTF_PRETTY_FUNCTION, "'"), \ ++ Genode::error(" in ", __FILE__, ":", __LINE__), \ + *(int *)(uintptr_t)0xbbadbeef = 0, \ + ((void(*)())0)() /* More reliable, but doesn't say BBADBEEF */ \ +) @@ -152,7 +152,7 @@ index a2f6a79..be8fff9 100644 } // namespace WTF diff --git a/qtwebkit/Source/WTF/wtf/OSRandomSource.cpp b/qtwebkit/Source/WTF/wtf/OSRandomSource.cpp -index 0c1416a..5a10b3d 100644 +index 0c1416a..921ea54 100644 --- a/qtwebkit/Source/WTF/wtf/OSRandomSource.cpp +++ b/qtwebkit/Source/WTF/wtf/OSRandomSource.cpp @@ -29,6 +29,10 @@ @@ -160,7 +160,7 @@ index 0c1416a..5a10b3d 100644 #include +#if OS(GENODE) -+#include ++#include +#endif /* OS(GENODE) */ + #if OS(UNIX) @@ -171,7 +171,7 @@ index 0c1416a..5a10b3d 100644 void cryptographicallyRandomValuesFromOS(unsigned char* buffer, size_t length) { +#if OS(GENODE) -+ PWRN("cryptographicallyRandomValuesFromOS(): no strong source of randomness available"); ++ Genode::warning("cryptographicallyRandomValuesFromOS(): no strong source of randomness available"); + return; +#endif /* OS(GENODE) */ #if OS(UNIX) @@ -267,15 +267,14 @@ index a272ce3..65a5a1f 100644 void StackBounds::initialize() diff --git a/qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp b/qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp -index f547085..07fc9b0 100644 +index f547085..3263f04 100644 --- a/qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp +++ b/qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp -@@ -49,6 +49,12 @@ +@@ -49,6 +49,11 @@ #include #endif +#if OS(GENODE) -+#include +#include +#include +#endif @@ -283,7 +282,7 @@ index f547085..07fc9b0 100644 #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON #endif -@@ -367,6 +373,21 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, size_t alignment) { +@@ -367,6 +372,21 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, size_t alignment) { } #endif diff --git a/repos/libports/src/lib/qt5/qpluginwidget/qpluginwidget.cpp b/repos/libports/src/lib/qt5/qpluginwidget/qpluginwidget.cpp index 5c04ea319..2d158a062 100644 --- a/repos/libports/src/lib/qt5/qpluginwidget/qpluginwidget.cpp +++ b/repos/libports/src/lib/qt5/qpluginwidget/qpluginwidget.cpp @@ -107,12 +107,12 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf uint32_t file_size = *(uint32_t*)(file_buf.constData() + file_buf.size() - sizeof(uint32_t)); - PDBG("file_size_uncompressed = %u", file_size); + Genode::log(__func__, ": file_size_uncompressed=", file_size); size_t ram_quota = Arg_string::find_arg(_args.constData(), "ram_quota").ulong_value(0) + file_size; if ((long)env()->ram_session()->avail() - (long)ram_quota < QPluginWidget::RAM_QUOTA) { - PERR("quota exceeded"); + Genode::error("quota exceeded"); _plugin_loading_state = QUOTA_EXCEEDED_ERROR; return; } @@ -135,7 +135,7 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf /* enable gzip format detection */ if (inflateInit2(&zs, 16 + MAX_WBITS) != Z_OK) { - PERR("inflateInit2() failed"); + Genode::error("inflateInit2() failed"); _plugin_loading_state = INFLATE_ERROR; inflateEnd(&zs); @@ -145,7 +145,7 @@ void PluginStarter::_start_plugin(QString &file_name, QByteArray const &file_buf /* uncompress */ if (inflate(&zs, Z_SYNC_FLUSH) != Z_STREAM_END) { - PERR("inflate() failed"); + Genode::error("inflate() failed"); _plugin_loading_state = INFLATE_ERROR; inflateEnd(&zs); diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qgenodeclipboard.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qgenodeclipboard.cpp index c3e29d78d..0c4991c90 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qgenodeclipboard.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qgenodeclipboard.cpp @@ -76,7 +76,7 @@ QMimeData *QGenodeClipboard::mimeData(QClipboard::Mode mode) if (!_clipboard_ds->valid()) { if (verbose) - PERR("invalid clipboard dataspace"); + Genode::error("invalid clipboard dataspace"); return 0; } @@ -86,7 +86,7 @@ QMimeData *QGenodeClipboard::mimeData(QClipboard::Mode mode) Genode::Xml_node node(xml_data); if (!node.has_type("clipboard")) { - PERR("invalid clipboard xml syntax"); + Genode::error("invalid clipboard xml syntax"); return 0; } @@ -95,7 +95,7 @@ QMimeData *QGenodeClipboard::mimeData(QClipboard::Mode mode) _decoded_clipboard_content = (char*)malloc(node.content_size()); if (!_decoded_clipboard_content) { - PERR("could not allocate buffer for decoded clipboard content"); + Genode::error("could not allocate buffer for decoded clipboard content"); return 0; } @@ -104,7 +104,7 @@ QMimeData *QGenodeClipboard::mimeData(QClipboard::Mode mode) node.content_size()))); } catch (Genode::Xml_node::Invalid_syntax) { - PERR("invalid clipboard xml syntax"); + Genode::error("invalid clipboard xml syntax"); return 0; } @@ -127,7 +127,7 @@ void QGenodeClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) Genode::Reporter::Xml_generator xml(*_clipboard_reporter, [&] () { xml.append_sanitized(utf8text.constData(), utf8text.size()); }); } catch (...) { - PERR("could not write clipboard data"); + Genode::error("could not write clipboard data"); } } diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp index 52b460d90..638698060 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerglcontext.cpp @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* EGL includes */ #define EGL_EGLEXT_PROTOTYPES @@ -36,7 +36,7 @@ QNitpickerGLContext::QNitpickerGLContext(QOpenGLContext *context) : QPlatformOpenGLContext() { if (qnglc_verbose) - PDBG("called"); + Genode::log(__func__, "called"); if (!eglBindAPI(EGL_OPENGL_API)) qFatal("eglBindAPI() failed"); @@ -51,7 +51,7 @@ QNitpickerGLContext::QNitpickerGLContext(QOpenGLContext *context) qFatal("eglInitialize() failed"); if (qnglc_verbose) - PDBG("eglInitialize() returned major: %d, minor: %d", major, minor); + Genode::log("eglInitialize() returned major: ", major, ", minor: ", minor); _egl_config = q_configFromGLFormat(_egl_display, context->format(), false, EGL_PBUFFER_BIT); if (_egl_config == 0) @@ -68,7 +68,7 @@ QNitpickerGLContext::QNitpickerGLContext(QOpenGLContext *context) bool QNitpickerGLContext::makeCurrent(QPlatformSurface *surface) { if (qnglc_verbose) - PDBG("called"); + Genode::log(__func__, " called"); doneCurrent(); @@ -79,7 +79,7 @@ bool QNitpickerGLContext::makeCurrent(QPlatformSurface *surface) w->framebuffer() }; if (qnglc_verbose) - PDBG("w->framebuffer() = %p", w->framebuffer()); + Genode::log(__func__, ": w->framebuffer()=", w->framebuffer()); if (w->egl_surface() != EGL_NO_SURFACE) if (!eglDestroySurface(_egl_display, w->egl_surface())) @@ -103,7 +103,7 @@ bool QNitpickerGLContext::makeCurrent(QPlatformSurface *surface) void QNitpickerGLContext::doneCurrent() { if (qnglc_verbose) - PDBG("called"); + Genode::log(__func__, " called"); if (!eglMakeCurrent(_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) qFatal("eglMakeCurrent() failed"); @@ -113,7 +113,7 @@ void QNitpickerGLContext::doneCurrent() void QNitpickerGLContext::swapBuffers(QPlatformSurface *surface) { if (qnglc_verbose) - PDBG("called"); + Genode::log(__func__, " called"); QNitpickerPlatformWindow *w = static_cast(surface); @@ -127,7 +127,8 @@ void QNitpickerGLContext::swapBuffers(QPlatformSurface *surface) void (*QNitpickerGLContext::getProcAddress(const QByteArray &procName)) () { if (qnglc_verbose) - PDBG("procName = %s, pointer = %p", procName.constData(), eglGetProcAddress(procName.constData())); + Genode::log("procName=", procName.constData(), " , " + "pointer=", eglGetProcAddress(procName.constData())); return static_cast(eglGetProcAddress(procName.constData())); } diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerplatformwindow.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerplatformwindow.cpp index f202dfcfe..cc8faca9c 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerplatformwindow.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerplatformwindow.cpp @@ -95,9 +95,6 @@ void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev) case Input::Event::PRESS: - if (qnpw_verbose) - PDBG("PRESS"); - /* make this window the focused window */ requestActivateWindow(); @@ -122,9 +119,6 @@ void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev) case Input::Event::RELEASE: - if (qnpw_verbose) - PDBG("RELEASE"); - switch (ev->code()) { case Input::BTN_LEFT: _mouse_button_state &= ~Qt::LeftButton; @@ -146,9 +140,6 @@ void QNitpickerPlatformWindow::_process_mouse_event(Input::Event *ev) case Input::Event::WHEEL: - if (qnpw_verbose) - PDBG("WHEEL"); - QWindowSystemInterface::handleWheelEvent(window(), local_position, local_position, diff --git a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerwindowsurface.cpp b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerwindowsurface.cpp index 6c3277cb8..20ef63a77 100644 --- a/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerwindowsurface.cpp +++ b/repos/libports/src/lib/qt5/qtbase/src/plugins/platforms/nitpicker/qnitpickerwindowsurface.cpp @@ -53,9 +53,6 @@ QPaintDevice *QNitpickerWindowSurface::paintDevice() if (_framebuffer_changed) { - if (verbose) - PDBG("framebuffer changed"); - _framebuffer_changed = false; /* * It can happen that 'resize()' was not called yet, so the size needs diff --git a/repos/libports/src/lib/readline/genode.cc b/repos/libports/src/lib/readline/genode.cc index 1090c6f0d..380c4922e 100644 --- a/repos/libports/src/lib/readline/genode.cc +++ b/repos/libports/src/lib/readline/genode.cc @@ -13,7 +13,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include using namespace Genode; @@ -31,7 +31,7 @@ char *UP = 0; extern "C" int tgetnum(char *s); int tgetnum(char *s) { - PDBG("tgetnum called with s=\"%s\"", s); + Genode::log(__func__, ": tgetnum called with s=\"", Genode::Cstring(s), "\""); enum { SCREEN_WIDTH = 80, SCREEN_HEIGHT = 25 }; if (!strcmp(s, "co")) return SCREEN_WIDTH; @@ -43,7 +43,7 @@ int tgetnum(char *s) extern "C" char *tgetstr(char *id, char **area); char *tgetstr(char *id, char **area) { - PDBG("not yet implemented"); + Genode::log(__func__, " not yet implemented"); return 0; } @@ -51,7 +51,7 @@ char *tgetstr(char *id, char **area) extern "C" int tputs(const char *str, int affcnt, int (*putc)(int)); int tputs(const char *str, int affcnt, int (*putc)(int)) { - PDBG("not yet implemented"); + Genode::log(__func__, " not yet implemented"); return -1; } @@ -59,7 +59,7 @@ int tputs(const char *str, int affcnt, int (*putc)(int)) extern "C" int tgetent(char *bp, const char *name); int tgetent(char *bp, const char *name) { - PDBG("not yet implemented"); + Genode::log(__func__, " not yet implemented"); return -1; } @@ -67,7 +67,7 @@ int tgetent(char *bp, const char *name) extern "C" char *tgoto(const char *cap, int col, int row); char *tgoto(const char *cap, int col, int row) { - PDBG("not yet implemented"); + Genode::log(__func__, " not yet implemented"); return 0; } @@ -75,7 +75,7 @@ char *tgoto(const char *cap, int col, int row) extern "C" int tgetflag(char *id); int tgetflag(char *id) { - PDBG("not yet implemented"); + Genode::log(__func__, " not yet implemented"); return -1; } diff --git a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc index 9efb5b4d7..efd725bfc 100644 --- a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc +++ b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -29,6 +29,8 @@ using Genode::env; using Genode::Allocator_avl; using Genode::Signal_context; using Genode::Signal_receiver; +using Genode::log; +using Genode::Hex; static const char *channel_names[] = { "front left", "front right" }; static float volume = 1.0; @@ -151,7 +153,7 @@ static SDL_AudioDevice *GENODEAUD_CreateDevice(int devindex) false, channel == 0 ? true : false); _this->hidden->audio[channel]->start(); } catch(Genode::Parent::Service_denied) { - PERR("Could not connect to 'Audio_out' service."); + Genode::error("could not connect to 'Audio_out' service"); while(--channel > 0) destroy(env()->heap(), _this->hidden->audio[channel]); @@ -255,10 +257,10 @@ static void GENODEAUD_CloseAudio(_THIS) static int GENODEAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) { - PDBG("requested freq = %d", spec->freq); - PDBG("requested format = 0x%x", spec->format); - PDBG("requested samples = %u", spec->samples); - PDBG("requested size = %u", spec->size); + log("requested freq=", spec->freq); + log(" format=", Hex(spec->format)); + log(" samples=", spec->samples); + log(" size=", spec->size); spec->channels = AUDIO_CHANNELS; spec->format = AUDIO_S16LSB; diff --git a/repos/libports/src/lib/sdl/video/SDL_genode_fb_events.cc b/repos/libports/src/lib/sdl/video/SDL_genode_fb_events.cc index aa7c0ce0d..dc7549817 100644 --- a/repos/libports/src/lib/sdl/video/SDL_genode_fb_events.cc +++ b/repos/libports/src/lib/sdl/video/SDL_genode_fb_events.cc @@ -28,7 +28,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include #include #include @@ -97,7 +97,7 @@ extern "C" { &ksym)); break; case Input::Event::WHEEL: - PWRN("Mouse wheel, not implemented yet!"); + Genode::warning("mouse wheel, not implemented yet"); break; default: break; @@ -112,7 +112,7 @@ extern "C" { input = new(Genode::env()->heap()) Connection(); if(!input->cap().valid()) { - PERR("No input driver available!"); + Genode::error("no input driver available!"); return; } diff --git a/repos/libports/src/lib/sdl/video/SDL_genode_fb_video.cc b/repos/libports/src/lib/sdl/video/SDL_genode_fb_video.cc index d25e226cc..ba422995f 100644 --- a/repos/libports/src/lib/sdl/video/SDL_genode_fb_video.cc +++ b/repos/libports/src/lib/sdl/video/SDL_genode_fb_video.cc @@ -28,7 +28,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ -#include +#include #include #include @@ -60,7 +60,7 @@ extern "C" { framebuffer = new(Genode::env()->heap()) Framebuffer::Connection(); if (!framebuffer->cap().valid()) { - PERR("Couldn't get framebuffer session!"); + Genode::error("couldn't obtain framebuffer session"); return 0; } return 1; @@ -72,7 +72,7 @@ extern "C" { */ static void Genode_Fb_DeleteDevice(SDL_VideoDevice *device) { - PDBG("Free framebuffer session object"); + Genode::log("free framebuffer session object"); if(framebuffer != 0) Genode::destroy(Genode::env()->heap(), framebuffer); framebuffer = 0; @@ -149,7 +149,7 @@ extern "C" { { if(framebuffer == 0) { - PERR("Framebuffer isn't initialized!"); + Genode::error("framebuffer isn't initialized"); return -1; } @@ -157,14 +157,15 @@ extern "C" { scr_mode = framebuffer->mode(); t->info.current_w = scr_mode.width(); t->info.current_h = scr_mode.height(); - PDBG("Framebuffer has width=%d and height=%d", - t->info.current_w, t->info.current_h); + Genode::log("Framebuffer has " + "width=", t->info.current_w, " " + "height=", t->info.current_h); /* set mode specific values */ switch(scr_mode.format()) { case Framebuffer::Mode::RGB565: - PDBG("We use pixelformat rgb565."); + Genode::log("We use pixelformat rgb565."); vformat->BitsPerPixel = 16; vformat->BytesPerPixel = scr_mode.bytes_per_pixel(); vformat->Rmask = 0x0000f800; @@ -184,7 +185,7 @@ extern "C" { /* Map the buffer */ Genode::Dataspace_capability fb_ds_cap = framebuffer->dataspace(); if (!fb_ds_cap.valid()) { - PERR("Could not request dataspace for frame buffer"); + Genode::error("could not request dataspace for frame buffer"); return -1; } t->hidden->buffer = Genode::env()->rm_session()->attach(fb_ds_cap); @@ -221,18 +222,18 @@ extern "C" { int width, int height, int bpp, Uint32 flags) { - PDBG("Set video mode to: width=%d height=%d bpp=%d", - width, height, bpp); + Genode::log("Set video mode to: " + "width=", width, " " "height=", height, " " "bpp=", bpp); if ( ! t->hidden->buffer ) { - PERR("No buffer for requested mode"); + Genode::error("no buffer for requested mode"); return(0); } SDL_memset(t->hidden->buffer, 0, width * height * (bpp / 8)); /* Allocate the new pixel format for the screen */ if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) { - PERR("Couldn't allocate new pixel format for requested mode"); + Genode::error("couldn't allocate new pixel format for requested mode"); return(0); } @@ -252,7 +253,7 @@ extern "C" { static int Genode_Fb_AllocHWSurface(SDL_VideoDevice *t, SDL_Surface *surface) { - PDBG("Not supported yet ..."); + Genode::log(__func__, " not supported yet ..."); return -1; } @@ -260,7 +261,7 @@ extern "C" { static void Genode_Fb_FreeHWSurface(SDL_VideoDevice *t, SDL_Surface *surface) { - PDBG("Not supported yet ..."); + Genode::log(__func__, " not supported yet ..."); } @@ -270,7 +271,7 @@ extern "C" { static int Genode_Fb_LockHWSurface(SDL_VideoDevice *t, SDL_Surface *surface) { - PDBG("Not supported yet ..."); + Genode::log(__func__, " not supported yet ..."); return 0; } @@ -278,7 +279,7 @@ extern "C" { static void Genode_Fb_UnlockHWSurface(SDL_VideoDevice *t, SDL_Surface *surface) { - PDBG("Not supported yet ..."); + Genode::log(__func__, " not supported yet ..."); } @@ -303,7 +304,7 @@ extern "C" { int Genode_Fb_SetColors(SDL_VideoDevice *t, int firstcolor, int ncolors, SDL_Color *colors) { - PWRN("Not implemented yet"); + Genode::warning(__func__, " not implemented yet"); return 1; } @@ -314,7 +315,7 @@ extern "C" { */ void Genode_Fb_VideoQuit(SDL_VideoDevice *t) { - PDBG("Quit video device ..."); + Genode::log("Quit video device ..."); if (t->screen->pixels != 0) { SDL_free(t->screen->pixels); diff --git a/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h b/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h index d831fbf50..4f285a11b 100644 --- a/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h +++ b/repos/libports/src/lib/vfs/jitterentropy/vfs_jitterentropy.h @@ -34,14 +34,14 @@ class Jitterentropy_file_system : public Vfs::Single_file_system { int err = jent_entropy_init(); if (err) { - PERR("jitterentropy library could not be initialized!"); + Genode::error("jitterentropy library could not be initialized!"); return false; } /* use the default behaviour as specified in jitterentropy(3) */ _ec_stir = jent_entropy_collector_alloc(0, 0); if (!_ec_stir) { - PERR("jitterentropy could not allocate entropy collector!"); + Genode::error("jitterentropy could not allocate entropy collector!"); return false; } diff --git a/repos/libports/src/server/acpi_input/main.cc b/repos/libports/src/server/acpi_input/main.cc index 8ba159831..9dfa3d1c3 100644 --- a/repos/libports/src/server/acpi_input/main.cc +++ b/repos/libports/src/server/acpi_input/main.cc @@ -15,6 +15,7 @@ /* base includes */ #include #include +#include #include /* os includes */ @@ -234,7 +235,8 @@ struct Transform::Main { else throw 5; } catch (...) { - String<64> invalid_node(map_node.addr(), map_node.size()); + String<64> invalid_node(Genode::Cstring(map_node.addr(), + map_node.size())); Genode::error("map item : '", invalid_node.string(), "'"); /* we want a well formated configuration ! - die */ class Invalid_config {} exception; diff --git a/repos/libports/src/server/ffat_fs/directory.h b/repos/libports/src/server/ffat_fs/directory.h index 4d8a2c5d8..7d7730fd9 100644 --- a/repos/libports/src/server/ffat_fs/directory.h +++ b/repos/libports/src/server/ffat_fs/directory.h @@ -38,18 +38,13 @@ namespace File_system { size_t read(char *dst, size_t len, seek_off_t seek_offset) { - bool verbose = false; - - if (verbose) - PDBG("len = %zu, seek_offset = %llu", len, seek_offset); - if (len < sizeof(Directory_entry)) { - PERR("read buffer too small for directory entry"); + error("read buffer too small for directory entry"); return 0; } if (seek_offset % sizeof(Directory_entry)) { - PERR("seek offset not alighed to sizeof(Directory_entry)"); + error("seek offset not alighed to sizeof(Directory_entry)"); return 0; } @@ -77,20 +72,20 @@ namespace File_system { case FR_OK: break; case FR_INVALID_OBJECT: - PERR("f_readdir() failed with error code FR_INVALID_OBJECT"); + error("f_readdir() failed with error code FR_INVALID_OBJECT"); return 0; case FR_DISK_ERR: - PERR("f_readdir() failed with error code FR_DISK_ERR"); + error("f_readdir() failed with error code FR_DISK_ERR"); return 0; case FR_INT_ERR: - PERR("f_readdir() failed with error code FR_INT_ERR"); + error("f_readdir() failed with error code FR_INT_ERR"); return 0; case FR_NOT_READY: - PERR("f_readdir() failed with error code FR_NOT_READY"); + error("f_readdir() failed with error code FR_NOT_READY"); return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_readdir() returned an unexpected error code"); + error("f_readdir() returned an unexpected error code"); return 0; } @@ -101,9 +96,6 @@ namespace File_system { if (e->name[0] == 0) /* use short file name */ strncpy(e->name, ffat_file_info.fname, sizeof(e->name)); - if (verbose) - PDBG("found dir entry: %s", e->name); - if ((ffat_file_info.fattrib & AM_DIR) == AM_DIR) e->type = Directory_entry::TYPE_DIRECTORY; else diff --git a/repos/libports/src/server/ffat_fs/file.h b/repos/libports/src/server/ffat_fs/file.h index 8f4faffec..aa8a4eb78 100644 --- a/repos/libports/src/server/ffat_fs/file.h +++ b/repos/libports/src/server/ffat_fs/file.h @@ -33,13 +33,8 @@ namespace File_system { size_t read(char *dst, size_t len, seek_off_t seek_offset) { - bool verbose = false; - using namespace Ffat; - if (verbose) - PDBG("len = %zu, seek_offset = %llu", len, seek_offset); - UINT result; if (seek_offset == (seek_off_t)(~0)) @@ -51,20 +46,20 @@ namespace File_system { case FR_OK: break; case FR_INVALID_OBJECT: - PERR("f_lseek() failed with error code FR_INVALID_OBJECT"); + Genode::error("f_lseek() failed with error code FR_INVALID_OBJECT"); return 0; case FR_DISK_ERR: - PERR("f_lseek() failed with error code FR_DISK_ERR"); + Genode::error("f_lseek() failed with error code FR_DISK_ERR"); return 0; case FR_INT_ERR: - PERR("f_lseek() failed with error code FR_INT_ERR"); + Genode::error("f_lseek() failed with error code FR_INT_ERR"); return 0; case FR_NOT_READY: - PERR("f_lseek() failed with error code FR_NOT_READY"); + Genode::error("f_lseek() failed with error code FR_NOT_READY"); return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_lseek() returned an unexpected error code"); + Genode::error("f_lseek() returned an unexpected error code"); return 0; } @@ -72,38 +67,31 @@ namespace File_system { switch(res) { case FR_OK: - if (verbose) - PDBG("result = %d", result); return result; case FR_DENIED: - PDBG("f_read() failed with error code FR_DENIED"); + Genode::warning("f_read() failed with error code FR_DENIED"); return 0; case FR_INVALID_OBJECT: - PERR("f_read() failed with error code FR_INVALID_OBJECT"); + Genode::error("f_read() failed with error code FR_INVALID_OBJECT"); return 0; case FR_DISK_ERR: - PERR("f_read() failed with error code FR_DISK_ERR"); + Genode::error("f_read() failed with error code FR_DISK_ERR"); return 0; case FR_INT_ERR: - PERR("f_read() failed with error code FR_INT_ERR"); + Genode::error("f_read() failed with error code FR_INT_ERR"); return 0; case FR_NOT_READY: - PERR("f_read() failed with error code FR_NOT_READY"); + Genode::error("f_read() failed with error code FR_NOT_READY"); return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_read() returned an unexpected error code"); + Genode::error("f_read() returned an unexpected error code"); return 0; } } size_t write(char const *src, size_t len, seek_off_t seek_offset) { - bool verbose = false; - - if (verbose) - PDBG("len = %zu, seek_offset = %llu", len, seek_offset); - using namespace Ffat; UINT result; @@ -117,20 +105,20 @@ namespace File_system { case FR_OK: break; case FR_INVALID_OBJECT: - PERR("f_lseek() failed with error code FR_INVALID_OBJECT"); + Genode::error("f_lseek() failed with error code FR_INVALID_OBJECT"); return 0; case FR_DISK_ERR: - PERR("f_lseek() failed with error code FR_DISK_ERR"); + Genode::error("f_lseek() failed with error code FR_DISK_ERR"); return 0; case FR_INT_ERR: - PERR("f_lseek() failed with error code FR_INT_ERR"); + Genode::error("f_lseek() failed with error code FR_INT_ERR"); return 0; case FR_NOT_READY: - PERR("f_lseek() failed with error code FR_NOT_READY"); + Genode::error("f_lseek() failed with error code FR_NOT_READY"); return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_lseek() returned an unexpected error code"); + Genode::error("f_lseek() returned an unexpected error code"); return 0; } @@ -138,27 +126,25 @@ namespace File_system { switch(res) { case FR_OK: - if (verbose) - PDBG("result = %d", result); return result; case FR_DENIED: - PERR("f_write() failed with error code FR_DENIED"); + Genode::error("f_write() failed with error code FR_DENIED"); return 0; case FR_INVALID_OBJECT: - PERR("f_write() failed with error code FR_INVALID_OBJECT"); + Genode::error("f_write() failed with error code FR_INVALID_OBJECT"); return 0; case FR_DISK_ERR: - PERR("f_write() failed with error code FR_DISK_ERR"); + Genode::error("f_write() failed with error code FR_DISK_ERR"); return 0; case FR_INT_ERR: - PERR("f_write() failed with error code FR_INT_ERR"); + Genode::error("f_write() failed with error code FR_INT_ERR"); return 0; case FR_NOT_READY: - PERR("f_write() failed with error code FR_NOT_READY"); + Genode::error("f_write() failed with error code FR_NOT_READY"); return 0; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_write() returned an unexpected error code"); + Genode::error("f_write() returned an unexpected error code"); return 0; } } diff --git a/repos/libports/src/server/ffat_fs/main.cc b/repos/libports/src/server/ffat_fs/main.cc index 349ce6e17..7da8252c2 100644 --- a/repos/libports/src/server/ffat_fs/main.cc +++ b/repos/libports/src/server/ffat_fs/main.cc @@ -20,6 +20,8 @@ #include #include #include +#include +#include /* local includes */ #include @@ -45,10 +47,6 @@ static Lock _ffat_lock; typedef Lock_guard Ffat_lock_guard; -static bool const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - /************************* ** File-system service ** *************************/ @@ -94,12 +92,10 @@ namespace File_system { switch (packet.operation()) { case Packet_descriptor::READ: - PDBGV("READ"); res_length = node.read((char *)content, length, offset); break; case Packet_descriptor::WRITE: - PDBGV("WRITE"); res_length = node.write((char const *)content, length, offset); break; } @@ -119,7 +115,7 @@ namespace File_system { Node *node = _handle_registry.lookup(packet.handle()); _process_packet_op(packet, *node); } - catch (Invalid_handle) { PERR("Invalid_handle"); } + catch (Invalid_handle) { error("Invalid_handle"); } /* * The 'acknowledge_packet' function cannot block because we @@ -161,7 +157,7 @@ namespace File_system { static void _assert_valid_path(char const *path) { if (!valid_path(path)) { - PWRN("malformed path '%s'", path); + warning("malformed path '", path, "'"); throw Lookup_failed(); } } @@ -206,12 +202,6 @@ namespace File_system { File_handle file(Dir_handle dir_handle, Name const &name, Mode mode, bool create) { - PDBGV("_root = %s, dir_name = %s, name = %s, create = %d", - _root.name(), - _handle_registry.lookup(dir_handle)->name(), - name.string(), - create); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (!valid_filename(name.string())) @@ -265,23 +255,23 @@ namespace File_system { case FR_WRITE_PROTECTED: throw Permission_denied(); case FR_NOT_READY: - PERR("f_open() failed with error code FR_NOT_READY"); + error("f_open() failed with error code FR_NOT_READY"); throw Lookup_failed(); case FR_DISK_ERR: - PERR("f_open() failed with error code FR_DISK_ERR"); + error("f_open() failed with error code FR_DISK_ERR"); throw Lookup_failed(); case FR_INT_ERR: - PERR("f_open() failed with error code FR_INT_ERR"); + error("f_open() failed with error code FR_INT_ERR"); throw Lookup_failed(); case FR_NOT_ENABLED: - PERR("f_open() failed with error code FR_NOT_ENABLED"); + error("f_open() failed with error code FR_NOT_ENABLED"); throw Lookup_failed(); case FR_NO_FILESYSTEM: - PERR("f_open() failed with error code FR_NO_FILESYSTEM"); + error("f_open() failed with error code FR_NO_FILESYSTEM"); throw Lookup_failed(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_open() returned an unexpected error code"); + error("f_open() returned an unexpected error code"); throw Lookup_failed(); } } @@ -294,9 +284,6 @@ namespace File_system { Dir_handle dir(Path const &path, bool create) { - PDBGV("_root = %s, path = %s, create = %d", - _root.name(), path.string(), create); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (create && !_writable) @@ -333,13 +320,10 @@ namespace File_system { case FR_OK: break; case FR_NO_PATH: - PDBGV("f_mkdir() failed with error code FR_NO_PATH"); throw Lookup_failed(); case FR_INVALID_NAME: - PDBGV("f_mkdir() failed with error code FR_INVALID_NAME"); throw Name_too_long(); case FR_INVALID_DRIVE: - PDBGV("f_mkdir() failed with error code FR_INVALID_DRIVE"); throw Name_too_long(); case FR_DENIED: case FR_WRITE_PROTECTED: @@ -347,27 +331,26 @@ namespace File_system { case FR_EXIST: throw Node_already_exists(); case FR_NOT_READY: - PERR("f_mkdir() failed with error code FR_NOT_READY"); + error("f_mkdir() failed with error code FR_NOT_READY"); throw Lookup_failed(); case FR_DISK_ERR: - PERR("f_mkdir() failed with error code FR_DISK_ERR"); + error("f_mkdir() failed with error code FR_DISK_ERR"); throw Lookup_failed(); case FR_INT_ERR: - PERR("f_mkdir() failed with error code FR_INT_ERR"); + error("f_mkdir() failed with error code FR_INT_ERR"); throw Lookup_failed(); case FR_NOT_ENABLED: - PERR("f_mkdir() failed with error code FR_NOT_ENABLED"); + error("f_mkdir() failed with error code FR_NOT_ENABLED"); throw Lookup_failed(); case FR_NO_FILESYSTEM: - PERR("f_mkdir() failed with error code FR_NO_FILESYSTEM"); + error("f_mkdir() failed with error code FR_NO_FILESYSTEM"); throw Lookup_failed(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_mkdir() returned an unexpected error code"); + error("f_mkdir() returned an unexpected error code"); throw Lookup_failed(); } } catch (Exception e) { - PDBGV("exception occured while trying to create directory"); destroy(env()->heap(), dir_node); throw e; } @@ -382,32 +365,29 @@ namespace File_system { dir_node->ffat_dir(ffat_dir); return _handle_registry.alloc(dir_node); case FR_NO_PATH: - PDBGV("f_opendir() failed with error code FR_NO_PATH"); throw Lookup_failed(); case FR_INVALID_NAME: - PDBGV("f_opendir() failed with error code FR_INVALID_NAME"); throw Name_too_long(); case FR_INVALID_DRIVE: - PDBGV("f_opendir() failed with error code FR_INVALID_DRIVE"); throw Name_too_long(); case FR_NOT_READY: - PERR("f_opendir() failed with error code FR_NOT_READY"); + error("f_opendir() failed with error code FR_NOT_READY"); throw Lookup_failed(); case FR_DISK_ERR: - PERR("f_opendir() failed with error code FR_DISK_ERR"); + error("f_opendir() failed with error code FR_DISK_ERR"); throw Lookup_failed(); case FR_INT_ERR: - PERR("f_opendir() failed with error code FR_INT_ERR"); + error("f_opendir() failed with error code FR_INT_ERR"); throw Lookup_failed(); case FR_NOT_ENABLED: - PERR("f_opendir() failed with error code FR_NOT_ENABLED"); + error("f_opendir() failed with error code FR_NOT_ENABLED"); throw Lookup_failed(); case FR_NO_FILESYSTEM: - PERR("f_opendir() failed with error code FR_NO_FILESYSTEM"); + error("f_opendir() failed with error code FR_NO_FILESYSTEM"); throw Lookup_failed(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_opendir() returned an unexpected error code"); + error("f_opendir() returned an unexpected error code"); throw Lookup_failed(); } } catch (Exception e) { @@ -418,8 +398,6 @@ namespace File_system { Node_handle node(Path const &path) { - PDBGV("path = %s", path.string()); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (!valid_path(path.string())) @@ -459,23 +437,23 @@ namespace File_system { case FR_INVALID_DRIVE: throw Lookup_failed(); case FR_DISK_ERR: - PERR("f_stat() failed with error code FR_DISK_ERR"); + error("f_stat() failed with error code FR_DISK_ERR"); throw Lookup_failed(); case FR_INT_ERR: - PERR("f_stat() failed with error code FR_INT_ERR"); + error("f_stat() failed with error code FR_INT_ERR"); throw Lookup_failed(); case FR_NOT_READY: - PERR("f_stat() failed with error code FR_NOT_READY"); + error("f_stat() failed with error code FR_NOT_READY"); throw Lookup_failed(); case FR_NOT_ENABLED: - PERR("f_stat() failed with error code FR_NOT_ENABLED"); + error("f_stat() failed with error code FR_NOT_ENABLED"); throw Lookup_failed(); case FR_NO_FILESYSTEM: - PERR("f_stat() failed with error code FR_NO_FILESYSTEM"); + error("f_stat() failed with error code FR_NO_FILESYSTEM"); throw Lookup_failed(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_stat() returned an unexpected error code"); + error("f_stat() returned an unexpected error code"); throw Lookup_failed(); } } catch (Exception e) { @@ -496,12 +474,10 @@ namespace File_system { try { node = _handle_registry.lookup(handle); } catch(Invalid_handle) { - PERR("close() called with invalid handle"); + error("close() called with invalid handle"); return; } - PDBGV("name = %s", node->name()); - /* free the handle */ _handle_registry.free(handle); @@ -518,20 +494,20 @@ namespace File_system { case FR_OK: return; case FR_INVALID_OBJECT: - PERR("f_close() failed with error code FR_INVALID_OBJECT"); + error("f_close() failed with error code FR_INVALID_OBJECT"); return; case FR_DISK_ERR: - PERR("f_close() failed with error code FR_DISK_ERR"); + error("f_close() failed with error code FR_DISK_ERR"); return; case FR_INT_ERR: - PERR("f_close() failed with error code FR_INT_ERR"); + error("f_close() failed with error code FR_INT_ERR"); return; case FR_NOT_READY: - PERR("f_close() failed with error code FR_NOT_READY"); + error("f_close() failed with error code FR_NOT_READY"); return; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_close() returned an unexpected error code"); + error("f_close() returned an unexpected error code"); return; } } @@ -548,8 +524,6 @@ namespace File_system { Node *node = _handle_registry.lookup(node_handle); - PDBGV("name = %s", node->name()); - using namespace Ffat; /* f_stat() does not work for the '/' directory */ @@ -566,49 +540,46 @@ namespace File_system { case FR_OK: break; case FR_NO_FILE: - PERR("f_stat() failed with error code FR_NO_FILE"); + error("f_stat() failed with error code FR_NO_FILE"); return status; case FR_NO_PATH: - PERR("f_stat() failed with error code FR_NO_PATH"); + error("f_stat() failed with error code FR_NO_PATH"); return status; case FR_INVALID_NAME: - PERR("f_stat() failed with error code FR_INVALID_NAME"); + error("f_stat() failed with error code FR_INVALID_NAME"); return status; case FR_INVALID_DRIVE: - PERR("f_stat() failed with error code FR_INVALID_DRIVE"); + error("f_stat() failed with error code FR_INVALID_DRIVE"); return status; case FR_DISK_ERR: - PERR("f_stat() failed with error code FR_DISK_ERR"); + error("f_stat() failed with error code FR_DISK_ERR"); return status; case FR_INT_ERR: - PERR("f_stat() failed with error code FR_INT_ERR"); + error("f_stat() failed with error code FR_INT_ERR"); return status; case FR_NOT_READY: - PERR("f_stat() failed with error code FR_NOT_READY"); + error("f_stat() failed with error code FR_NOT_READY"); return status; case FR_NOT_ENABLED: - PERR("f_stat() failed with error code FR_NOT_ENABLED"); + error("f_stat() failed with error code FR_NOT_ENABLED"); return status; case FR_NO_FILESYSTEM: - PERR("f_stat() failed with error code FR_NO_FILESYSTEM"); + error("f_stat() failed with error code FR_NO_FILESYSTEM"); return status; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_stat() returned an unexpected error code"); + error("f_stat() returned an unexpected error code"); return status; } if ((ffat_file_info.fattrib & AM_DIR) == AM_DIR) { - PDBGV("MODE_DIRECTORY"); status.mode = File_system::Status::MODE_DIRECTORY; } else { - PDBGV("MODE_FILE"); status.mode = File_system::Status::MODE_FILE; status.size = ffat_file_info.fsize; } } else { - PDBGV("MODE_DIRECTORY"); status.mode = File_system::Status::MODE_DIRECTORY; } @@ -645,8 +616,6 @@ namespace File_system { void unlink(Dir_handle dir_handle, Name const &name) { - PDBGV("name = %s", name.string()); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (!valid_filename(name.string())) @@ -682,31 +651,29 @@ namespace File_system { case FR_WRITE_PROTECTED: throw Permission_denied(); case FR_DISK_ERR: - PERR("f_unlink() failed with error code FR_DISK_ERR"); + error("f_unlink() failed with error code FR_DISK_ERR"); return; case FR_INT_ERR: - PERR("f_unlink() failed with error code FR_INT_ERR"); + error("f_unlink() failed with error code FR_INT_ERR"); return; case FR_NOT_READY: - PERR("f_unlink() failed with error code FR_NOT_READY"); + error("f_unlink() failed with error code FR_NOT_READY"); return; case FR_NOT_ENABLED: - PERR("f_unlink() failed with error code FR_NOT_ENABLED"); + error("f_unlink() failed with error code FR_NOT_ENABLED"); return; case FR_NO_FILESYSTEM: - PERR("f_unlink() failed with error code FR_NO_FILESYSTEM"); + error("f_unlink() failed with error code FR_NO_FILESYSTEM"); return; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_unlink() returned an unexpected error code"); + error("f_unlink() returned an unexpected error code"); return; } } void truncate(File_handle file_handle, file_size_t size) { - PDBGV("truncate()"); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (!_writable) @@ -724,25 +691,25 @@ namespace File_system { case FR_OK: /* according to the FatFs documentation this can happen */ if (f_tell(file->ffat_fil()) != size) { - PERR("f_lseek() could not seek to offset %llu", size); + error("f_lseek() could not seek to offset ", size); return; } break; case FR_DISK_ERR: - PERR("f_lseek() failed with error code FR_DISK_ERR"); + error("f_lseek() failed with error code FR_DISK_ERR"); return; case FR_INT_ERR: - PERR("f_lseek() failed with error code FR_INT_ERR"); + error("f_lseek() failed with error code FR_INT_ERR"); return; case FR_NOT_READY: - PERR("f_lseek() failed with error code FR_NOT_READY"); + error("f_lseek() failed with error code FR_NOT_READY"); return; case FR_INVALID_OBJECT: - PERR("f_lseek() failed with error code FR_INVALID_OBJECT"); + error("f_lseek() failed with error code FR_INVALID_OBJECT"); throw Invalid_handle(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_lseek() returned an unexpected error code"); + error("f_lseek() returned an unexpected error code"); return; } @@ -752,23 +719,23 @@ namespace File_system { case FR_OK: return; case FR_INVALID_OBJECT: - PERR("f_truncate() failed with error code FR_INVALID_OBJECT"); + error("f_truncate() failed with error code FR_INVALID_OBJECT"); throw Invalid_handle(); case FR_DISK_ERR: - PERR("f_truncate() failed with error code FR_DISK_ERR"); + error("f_truncate() failed with error code FR_DISK_ERR"); return; case FR_INT_ERR: - PERR("f_truncate() failed with error code FR_INT_ERR"); + error("f_truncate() failed with error code FR_INT_ERR"); return; case FR_NOT_READY: - PERR("f_truncate() failed with error code FR_NOT_READY"); + error("f_truncate() failed with error code FR_NOT_READY"); return; case FR_TIMEOUT: - PERR("f_truncate() failed with error code FR_TIMEOUT"); + error("f_truncate() failed with error code FR_TIMEOUT"); return; default: /* not supposed to occur according to the libffat documentation */ - PERR("f_truncate() returned an unexpected error code"); + error("f_truncate() returned an unexpected error code"); return; } } @@ -776,8 +743,6 @@ namespace File_system { void move(Dir_handle from_dir_handle, Name const &from_name, Dir_handle to_dir_handle, Name const &to_name) { - PDBGV("from_name = %s, to_name = %s", from_name.string(), to_name.string()); - Ffat_lock_guard ffat_lock_guard(_ffat_lock); if (!_writable) @@ -803,9 +768,6 @@ namespace File_system { throw Invalid_name(); } - PDBGV("from_path = %s", absolute_from_path.base()); - PDBGV("to_path = %s", absolute_to_path.base()); - using namespace Ffat; FRESULT res = f_rename(absolute_from_path.base(), absolute_to_path.base()); @@ -820,36 +782,36 @@ namespace File_system { case FR_INVALID_DRIVE: throw Invalid_name(); case FR_EXIST: - PERR("f_rename() failed with error code FR_EXIST"); + error("f_rename() failed with error code FR_EXIST"); throw Invalid_name(); case FR_DENIED: case FR_WRITE_PROTECTED: throw Permission_denied(); case FR_DISK_ERR: - PERR("f_rename() failed with error code FR_DISK_ERR"); + error("f_rename() failed with error code FR_DISK_ERR"); throw Lookup_failed(); case FR_INT_ERR: - PERR("f_rename() failed with error code FR_INT_ERR"); + error("f_rename() failed with error code FR_INT_ERR"); throw Lookup_failed(); case FR_NOT_READY: - PERR("f_rename() failed with error code FR_NOT_READY"); + error("f_rename() failed with error code FR_NOT_READY"); throw Lookup_failed(); case FR_NOT_ENABLED: - PERR("f_rename() failed with error code FR_NOT_ENABLED"); + error("f_rename() failed with error code FR_NOT_ENABLED"); throw Lookup_failed(); case FR_NO_FILESYSTEM: - PERR("f_rename() failed with error code FR_NO_FILESYSTEM"); + error("f_rename() failed with error code FR_NO_FILESYSTEM"); throw Lookup_failed(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_rename() returned an unexpected error code"); + error("f_rename() returned an unexpected error code"); throw Lookup_failed(); } } void sigh(Node_handle, Genode::Signal_context_capability) { - PWRN("File_system::Session::sigh not supported"); + error("File_system::Session::sigh not supported"); } }; @@ -913,33 +875,33 @@ namespace File_system { case FR_INVALID_DRIVE: throw Lookup_failed(); case FR_NOT_READY: - PERR("f_chdir() failed with error code FR_NOT_READY"); + error("f_chdir() failed with error code FR_NOT_READY"); throw Root::Unavailable(); case FR_DISK_ERR: - PERR("f_chdir() failed with error code FR_DISK_ERR"); + error("f_chdir() failed with error code FR_DISK_ERR"); throw Root::Unavailable(); case FR_INT_ERR: - PERR("f_chdir() failed with error code FR_INT_ERR"); + error("f_chdir() failed with error code FR_INT_ERR"); throw Root::Unavailable(); case FR_NOT_ENABLED: - PERR("f_chdir() failed with error code FR_NOT_ENABLED"); + error("f_chdir() failed with error code FR_NOT_ENABLED"); throw Root::Unavailable(); case FR_NO_FILESYSTEM: - PERR("f_chdir() failed with error code FR_NO_FILESYSTEM"); + error("f_chdir() failed with error code FR_NO_FILESYSTEM"); throw Root::Unavailable(); default: /* not supposed to occur according to the libffat documentation */ - PERR("f_chdir() returned an unexpected error code"); + error("f_chdir() returned an unexpected error code"); throw Root::Unavailable(); } session_root_dir = new (env()->heap()) Directory(root); } } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"root\" attribute in policy definition"); + error("missing \"root\" attribute in policy definition"); throw Root::Unavailable(); } catch (Lookup_failed) { - PERR("Session root directory \"%s\" does not exist", root); + error("session root directory \"", Cstring(root), "\" does not exist"); throw Root::Unavailable(); } @@ -949,7 +911,7 @@ namespace File_system { writeable = policy.attribute_value("writeable", false); } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + error("Invalid session request, no matching policy"); throw Root::Unavailable(); } @@ -959,7 +921,7 @@ namespace File_system { Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) { - PERR("%s requested a session with a zero length transmission buffer", label.string()); + error(label, " requested a session with a zero length transmission buffer"); throw Root::Invalid_args(); } @@ -969,8 +931,8 @@ namespace File_system { */ size_t session_size = sizeof(Session_component) + tx_buf_size; if (max((size_t)4096, session_size) > ram_quota) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, session_size); + error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", session_size); throw Root::Quota_exceeded(); } return new (md_alloc()) @@ -1006,10 +968,8 @@ int main(int, char **) static Ffat::FATFS _fatfs; /* mount the file system */ - PDBGV("Mounting device %u ...\n\n", 0); - if (f_mount(0, &_fatfs) != Ffat::FR_OK) { - PERR("Mount failed\n"); + error("mount failed"); return -1; } diff --git a/repos/libports/src/server/ffat_fs/node.h b/repos/libports/src/server/ffat_fs/node.h index 227af42f6..e9a71a9d4 100644 --- a/repos/libports/src/server/ffat_fs/node.h +++ b/repos/libports/src/server/ffat_fs/node.h @@ -9,6 +9,7 @@ /* Genode includes */ #include +#include #include /* ffat includes */ @@ -40,13 +41,13 @@ namespace File_system { virtual size_t read(char *dst, size_t len, seek_off_t) { - PERR("read() called on generic Node object"); + Genode::error("read() called on generic Node object"); return 0; } virtual size_t write(char const *src, size_t len, seek_off_t) { - PERR("write() called on generic Node object"); + Genode::error("write() called on generic Node object"); return 0; } }; diff --git a/repos/libports/src/server/fuse_fs/directory.h b/repos/libports/src/server/fuse_fs/directory.h index 6b79f7677..35c01b6f4 100644 --- a/repos/libports/src/server/fuse_fs/directory.h +++ b/repos/libports/src/server/fuse_fs/directory.h @@ -73,7 +73,7 @@ class File_system::Directory : public Node switch (res) { case 0: break; default: - PERR("could not create '%s'", path); + Genode::error("could not create '", path, "'"); throw Lookup_failed(); } @@ -85,24 +85,24 @@ class File_system::Directory : public Node int err = -res; switch (err) { case EACCES: - PERR("op.mkdir() permission denied"); + Genode::error("op.mkdir() permission denied"); throw Permission_denied(); case EEXIST: throw Node_already_exists(); case EIO: - PERR("op.mkdir() I/O error occurred"); + Genode::error("op.mkdir() I/O error occurred"); throw Lookup_failed(); case ENOENT: throw Lookup_failed(); case ENOTDIR: throw Lookup_failed(); case ENOSPC: - PERR("op.mkdir() error while expanding directory"); + Genode::error("op.mkdir() error while expanding directory"); throw Lookup_failed(); case EROFS: throw Permission_denied(); default: - PERR("op.mkdir() returned unexpected error code: %d", res); + Genode::error("op.mkdir() returned unexpected error code: ", res); throw Lookup_failed(); } } @@ -195,12 +195,12 @@ class File_system::Directory : public Node size_t read(char *dst, size_t len, seek_off_t seek_offset) { if (len < sizeof(Directory_entry)) { - PERR("read buffer too small for directory entry"); + Genode::error("read buffer too small for directory entry"); return 0; } if (seek_offset % sizeof(Directory_entry)) { - PERR("seek offset not aligned to sizeof(Directory_entry)"); + Genode::error("seek offset not aligned to sizeof(Directory_entry)"); return 0; } diff --git a/repos/libports/src/server/fuse_fs/file.h b/repos/libports/src/server/fuse_fs/file.h index b8aea3a5c..afb7f589e 100644 --- a/repos/libports/src/server/fuse_fs/file.h +++ b/repos/libports/src/server/fuse_fs/file.h @@ -51,7 +51,7 @@ class File_system::File : public Node case 0: break; default: - PERR("could not create '%s'", path); + Genode::error("could not create '", path, "'"); throw Lookup_failed(); } diff --git a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc index 26deaea0a..47330f7d6 100644 --- a/repos/libports/src/server/fuse_fs/fuse_fs_main.cc +++ b/repos/libports/src/server/fuse_fs/fuse_fs_main.cc @@ -12,6 +12,7 @@ */ /* Genode includes */ +#include #include #include #include @@ -28,9 +29,6 @@ #include #include -static bool const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - namespace File_system { struct Main; @@ -107,7 +105,7 @@ class File_system::Session_component : public Session_rpc_object _process_packet_op(packet, *node); } - catch (Invalid_handle) { PERR("Invalid_handle"); } + catch (Invalid_handle) { Genode::error("Invalid_handle"); } /* * The 'acknowledge_packet' function cannot block because we @@ -149,7 +147,7 @@ class File_system::Session_component : public Session_rpc_object static void _assert_valid_path(char const *path) { if (!path || path[0] != '/') { - PWRN("malformed path '%s'", path); + Genode::warning("malformed path '", path, "'"); throw Lookup_failed(); } } @@ -201,9 +199,6 @@ class File_system::Session_component : public Session_rpc_object Directory *dir = _handle_registry.lookup_and_lock(dir_handle); Node_lock_guard dir_guard(dir); - PDBGV("dir: '%s' name: '%s' %s", dir->name(), name.string(), - create ? "create" : ""); - if (create && !_writeable) throw Permission_denied(); @@ -216,7 +211,7 @@ class File_system::Session_component : public Session_rpc_object Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create) { if (! Fuse::support_symlinks()) { - PERR("FUSE file system does not support symlinks"); + Genode::error("FUSE file system does not support symlinks"); return Symlink_handle(); } @@ -226,8 +221,6 @@ class File_system::Session_component : public Session_rpc_object Directory *dir = _handle_registry.lookup_and_lock(dir_handle); Node_lock_guard dir_guard(dir); - PDBGV("dir: '%s' name: '%s'", dir->name(), name.string()); - if (create && !_writeable) throw Permission_denied(); @@ -243,8 +236,6 @@ class File_system::Session_component : public Session_rpc_object _assert_valid_path(path_str); - PDBGV("path: '%s'", path_str); - if (create && !_writeable) throw Permission_denied(); @@ -267,7 +258,6 @@ class File_system::Session_component : public Session_rpc_object * FIXME this leads to '/' as parent and 'the rest' as name, * which fortunatly is in this case not a problem. */ - PDBGV("path_str: '%s'", path_str); Node *node = _root.node(path_str + 1); Node_lock_guard guard(node); @@ -286,12 +276,10 @@ class File_system::Session_component : public Session_rpc_object */ node->unlock(); } catch (Invalid_handle) { - PERR("close() called with invalid handle"); + Genode::error("close() called with invalid handle"); return; } - PDBGV("node: %p name: '%s'", node, node->name()); - _handle_registry.free(handle); destroy(&_md_alloc, node); } @@ -318,7 +306,7 @@ class File_system::Session_component : public Session_rpc_object void control(Node_handle, Control) { - PERR("%s not implemented", __func__); + Genode::error(__func__, " not implemented"); } void unlink(Dir_handle dir_handle, Name const &name) @@ -329,8 +317,6 @@ class File_system::Session_component : public Session_rpc_object Directory *dir = _handle_registry.lookup_and_lock(dir_handle); Node_lock_guard dir_guard(dir); - PDBGV("dir: '%s' name: '%s'", dir->name(), name.string()); - Absolute_path absolute_path(_root.name()); try { @@ -345,7 +331,7 @@ class File_system::Session_component : public Session_rpc_object int res = Fuse::fuse()->op.unlink(absolute_path.base()); if (res != 0) { - PERR("fuse()->op.unlink() returned unexpected error code: %d", res); + Genode::error("fuse()->op.unlink() returned unexpected error code: ", res); return; } } @@ -382,9 +368,6 @@ class File_system::Session_component : public Session_rpc_object Node_lock_guard from_dir_guard(from_dir); Node_lock_guard to_dir_guard(to_dir); - PDBGV("from_dir: '%s' from_name: '%s', to_dir: '%s' to_name: '%s'", - from_dir->name(), from_name.string(), to_dir->name(), to_name.string()); - Absolute_path absolute_from_path(_root.name()); Absolute_path absolute_to_path(_root.name()); @@ -399,15 +382,12 @@ class File_system::Session_component : public Session_rpc_object throw Invalid_name(); } - PDBGV("from_path = %s", absolute_from_path.base()); - PDBGV("to_path = %s", absolute_to_path.base()); - /* XXX remove direct use of FUSE operations */ int res = Fuse::fuse()->op.rename(absolute_to_path.base(), absolute_from_path.base()); if (res != 0) { - PERR("fuse()->op.rename() returned unexpected error code: %d", res); + Genode::error("fuse()->op.rename() returned unexpected error code: ", res); return; } } @@ -467,10 +447,11 @@ class File_system::Root : public Root_component root_dir = root; } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"root\" attribute in policy definition"); + Genode::error("missing \"root\" attribute in policy definition"); throw Root::Unavailable(); } catch (Lookup_failed) { - PERR("Session root directory \"%s\" does not exist", root); + Genode::error("session root directory \"", + Genode::Cstring(root), "\" does not exist"); throw Root::Unavailable(); } @@ -479,10 +460,10 @@ class File_system::Root : public Root_component */ writeable = policy.attribute_value("writeable", false); if (writeable) - PWRN("WARNING: write support in fuse_fs is considered experimental, data-loss may occur."); + Genode::warning("write support in fuse_fs is considered experimental, data-loss may occur."); } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("Invalid session request, no matching policy"); throw Root::Unavailable(); } @@ -492,7 +473,7 @@ class File_system::Root : public Root_component Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) { - PERR("%s requested a session with a zero length transmission buffer", label.string()); + Genode::error(label, " requested a session with a zero length transmission buffer"); throw Root::Invalid_args(); } @@ -502,8 +483,8 @@ class File_system::Root : public Root_component */ size_t session_size = sizeof(Session_component) + tx_buf_size; if (max((size_t)4096, session_size) > ram_quota) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, " , " + "need ", session_size); throw Root::Quota_exceeded(); } return new (md_alloc()) @@ -542,7 +523,7 @@ struct File_system::Main Main(Server::Entrypoint &ep) : ep(ep) { if (!Fuse::init_fs()) { - PERR("FUSE fs initialization failed"); + Genode::error("FUSE fs initialization failed"); return; } diff --git a/repos/libports/src/test/lwip/http_clnt/main.cc b/repos/libports/src/test/lwip/http_clnt/main.cc index 0deb3ea4e..9a6c2faa8 100644 --- a/repos/libports/src/test/lwip/http_clnt/main.cc +++ b/repos/libports/src/test/lwip/http_clnt/main.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -48,7 +48,7 @@ int main() if( lwip_nic_init(0, 0, 0, BUF_SIZE, BUF_SIZE)) { - PERR("We got no IP address!"); + Genode::error("got no IP address!"); return 0; } @@ -56,30 +56,30 @@ int main() _timer.msleep(2000); - PDBG("Create new socket ..."); + Genode::log("Create new socket ..."); int s = lwip_socket(AF_INET, SOCK_STREAM, 0 ); if (s < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); continue; } - PDBG("Connect to server ..."); + Genode::log("Connect to server ..."); struct sockaddr_in addr; addr.sin_port = htons(80); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr(serv_addr); if((lwip_connect(s, (struct sockaddr *)&addr, sizeof(addr))) < 0) { - PERR("Could not connect!"); + Genode::error("could not connect!"); lwip_close(s); continue; } - PDBG("Send request..."); + Genode::log("Send request..."); unsigned long bytes = lwip_send(s, (char*)http_get_request, Genode::strlen(http_get_request), 0); if ( bytes < 0 ) { - PERR("Couldn't send request ..."); + Genode::error("couldn't send request ..."); lwip_close(s); continue; } @@ -91,8 +91,8 @@ int main() buflen = lwip_recv(s, buf, 1024, 0); if(buflen > 0) { buf[buflen] = 0; - PDBG("Packet received!"); - PDBG("Packet content:\n%s", buf); + Genode::log("Packet received!"); + Genode::log("Packet content:\n", Genode::Cstring(buf)); } else break; } diff --git a/repos/libports/src/test/lwip/http_srv/main.cc b/repos/libports/src/test/lwip/http_srv/main.cc index 8865eeb54..86d344ea2 100644 --- a/repos/libports/src/test/lwip/http_srv/main.cc +++ b/repos/libports/src/test/lwip/http_srv/main.cc @@ -18,7 +18,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -51,7 +51,7 @@ void http_server_serve(int conn) { /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = lwip_recv(conn, buf, 1024, 0); - PLOG("Packet received!"); + Genode::log("Packet received!"); /* Ignore all receive errors */ if (buflen > 0) { @@ -65,7 +65,7 @@ void http_server_serve(int conn) { buf[3] == ' ' && buf[4] == '/' ) { - PLOG("Will send response"); + Genode::log("Will send response"); /* Send http header */ lwip_send(conn, http_html_hdr, Genode::strlen(http_html_hdr), 0); @@ -87,39 +87,39 @@ int main() /* Initialize network stack and do DHCP */ if (lwip_nic_init(0, 0, 0, BUF_SIZE, BUF_SIZE)) { - PERR("We got no IP address!"); + Genode::error("got no IP address!"); return -1; } - PLOG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = lwip_socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; - in_addr.sin_family = AF_INET; - in_addr.sin_port = htons(80); - in_addr.sin_addr.s_addr = INADDR_ANY; + in_addr.sin_family = AF_INET; + in_addr.sin_port = htons(80); + in_addr.sin_addr.s_addr = INADDR_ANY; if(lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if(lwip_listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { struct sockaddr addr; socklen_t len = sizeof(addr); int client = lwip_accept(s, &addr, &len); if(client < 0) { - PWRN("Invalid socket from accept!"); + Genode::warning("invalid socket from accept!"); continue; } http_server_serve(client); diff --git a/repos/libports/src/test/lwip/http_srv_static/main.cc b/repos/libports/src/test/lwip/http_srv_static/main.cc index 3dd778171..8a634d783 100644 --- a/repos/libports/src/test/lwip/http_srv_static/main.cc +++ b/repos/libports/src/test/lwip/http_srv_static/main.cc @@ -18,7 +18,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -44,14 +44,15 @@ const static char http_index_html[] = * * \param conn socket connected to the client */ -void http_server_serve(int conn) { +void http_server_serve(int conn) +{ char buf[1024]; ssize_t buflen; /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = lwip_recv(conn, buf, 1024, 0); - PLOG("Packet received!"); + Genode::log("Packet received!"); /* Ignore all receive errors */ if (buflen > 0) { @@ -65,7 +66,7 @@ void http_server_serve(int conn) { buf[3] == ' ' && buf[4] == '/' ) { - PLOG("Will send response"); + Genode::log("Will send response"); /* Send http header */ lwip_send(conn, http_html_hdr, Genode::strlen(http_html_hdr), 0); @@ -88,39 +89,39 @@ int main() /* Initialize network stack */ if (lwip_nic_init(inet_addr("10.0.2.55"), inet_addr("255.255.255.0"), inet_addr("10.0.2.1"), BUF_SIZE, BUF_SIZE)) { - PERR("We got no IP address!"); + Genode::error("got no IP address!"); return -1; } - PLOG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = lwip_socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; in_addr.sin_family = AF_INET; in_addr.sin_port = htons(80); in_addr.sin_addr.s_addr = INADDR_ANY; if(lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if(lwip_listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { struct sockaddr addr; socklen_t len = sizeof(addr); int client = lwip_accept(s, &addr, &len); if(client < 0) { - PWRN("Invalid socket from accept!"); + Genode::warning("invalid socket from accept!"); continue; } http_server_serve(client); diff --git a/repos/libports/src/test/lwip/http_srv_tracing/main.cc b/repos/libports/src/test/lwip/http_srv_tracing/main.cc index 9aec6ef6e..e14cb3404 100644 --- a/repos/libports/src/test/lwip/http_srv_tracing/main.cc +++ b/repos/libports/src/test/lwip/http_srv_tracing/main.cc @@ -18,7 +18,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -62,7 +62,6 @@ void http_server_serve(int conn) { /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = lwip_recv(conn, buf, 1024, 0); - //PLOG("Packet received!"); /* Ignore all receive errors */ if (buflen > 0) { @@ -76,8 +75,6 @@ void http_server_serve(int conn) { buf[3] == ' ' && buf[4] == '/' ) { - //PLOG("Will send response"); - /* Send http header */ //Fiasco::fiasco_tbuf_log_3val(">> lwip_send", Genode::strlen(http_html_hdr), 0, 0); lwip_send(conn, http_html_hdr, Genode::strlen(http_html_hdr), 0); @@ -107,43 +104,42 @@ int main() /* Initialize network stack and do DHCP */ if (lwip_nic_init(0, 0, 0, BUF_SIZE, BUF_SIZE)) { - PERR("We got no IP address!"); + Genode::error("got no IP address!"); return -1; } - PLOG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = lwip_socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; - in_addr.sin_family = AF_INET; - in_addr.sin_port = htons(80); - in_addr.sin_addr.s_addr = INADDR_ANY; + in_addr.sin_family = AF_INET; + in_addr.sin_port = htons(80); + in_addr.sin_addr.s_addr = INADDR_ANY; if(lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if(lwip_listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { struct sockaddr addr; socklen_t len = sizeof(addr); int client = lwip_accept(s, &addr, &len); if(client < 0) { - PWRN("Invalid socket from accept!"); + Genode::warning("invalid socket from accept!"); continue; } http_server_serve(client); - // PLOG("Sent response, closing connection"); lwip_close(client); } diff --git a/repos/libports/src/test/lwip/http_srv_tracing_nonblocking/main.cc b/repos/libports/src/test/lwip/http_srv_tracing_nonblocking/main.cc index c16991bcc..35d36b8de 100644 --- a/repos/libports/src/test/lwip/http_srv_tracing_nonblocking/main.cc +++ b/repos/libports/src/test/lwip/http_srv_tracing_nonblocking/main.cc @@ -18,7 +18,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -66,7 +66,7 @@ void http_server_serve(int conn) { /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = lwip_recv(conn, buf, 1024, 0); - PLOG("Packet received!"); + Genode::log("Packet received!"); /* Ignore all receive errors */ if (buflen > 0) { @@ -80,7 +80,7 @@ void http_server_serve(int conn) { buf[3] == ' ' && buf[4] == '/' ) { - PLOG("Will send response"); + Genode::log("Will send response"); /* Send http header */ lwip_send(conn, http_html_hdr, Genode::strlen(http_html_hdr), 0); @@ -103,17 +103,17 @@ int main() /* Initialize network stack and do DHCP */ if (lwip_nic_init(0, 0, 0, BUF_SIZE, BUF_SIZE)) { - PERR("We got no IP address!"); + Genode::error("got no IP address!"); return -1; } - PLOG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = lwip_socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PLOG("Now, I will bind to port 80 ..."); + Genode::log("Now, I will bind to port 80 ..."); struct sockaddr_in in_addr; in_addr.sin_family = AF_INET; in_addr.sin_port = htons(80); @@ -121,19 +121,19 @@ int main() memset(&(in_addr.sin_zero), '\0', 8); if (lwip_bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PLOG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if (lwip_listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } - PLOG("Make socket non-blocking ..."); + Genode::log("Make socket non-blocking ..."); if (lwip_fcntl(s, F_SETFL, O_NONBLOCK)) { - PERR("fcntl() failed!"); + Genode::error("fcntl() failed!"); return -1; } @@ -146,7 +146,7 @@ int main() c_num = 0; - PLOG("Start the server loop ..."); + Genode::log("Start the server loop ..."); while(true) { /* clear fds */ FD_ZERO(&rs); @@ -166,7 +166,6 @@ int main() } } - //PLOG("before select, c_num: %d", c_num); int ready = lwip_select(c_num + 1, &rs, &ws, &es, &timeout); if (ready > 0) { @@ -183,17 +182,14 @@ int main() if (errno == EWOULDBLOCK) break; - //PWRN("Invalid socket from accept!"); continue; } if (lwip_fcntl(*fd, F_SETFL, O_NONBLOCK)) { - //PERR("fcntl() failed"); lwip_close(*fd); continue; } c_num++; - //PLOG("add client %d", c_num); } } @@ -203,13 +199,10 @@ int main() if (*fd != -1) { if (FD_ISSET(*fd, &rs)) { http_server_serve(*fd); - //PLOG("Send response, closing connection"); lwip_close(*fd); c_num--; *fd = -1; - - //PLOG("after close, c_num: %d", c_num); } if (num > 0) diff --git a/repos/libports/src/test/lwip/loopback/main.cc b/repos/libports/src/test/lwip/loopback/main.cc index 0271c1b9a..4518be6a7 100644 --- a/repos/libports/src/test/lwip/loopback/main.cc +++ b/repos/libports/src/test/lwip/loopback/main.cc @@ -19,7 +19,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -50,29 +50,29 @@ class Client : public Genode::Thread_deprecated<4096> /* client loop */ while(true) { - PDBG("Create new socket ..."); + Genode::log("Create new socket ..."); int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (s < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); continue; } - PDBG("Connect to server ..."); + Genode::log("Connect to server ..."); struct sockaddr_in addr; addr.sin_port = htons(80); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); if((connect(s, (struct sockaddr *)&addr, sizeof(addr))) < 0) { - PERR("Could not connect!"); + Genode::error("could not connect!"); close(s); continue; } - PDBG("Send request..."); + Genode::log("Send request..."); unsigned long bytes = send(s, (char*)http_get_request, Genode::strlen(http_get_request), 0); if ( bytes < 0 ) { - PERR("Couldn't send request ..."); + Genode::error("couldn't send request ..."); close(s); continue; } @@ -84,8 +84,8 @@ class Client : public Genode::Thread_deprecated<4096> buflen = recv(s, buf, 1024, 0); if(buflen > 0) { buf[buflen] = 0; - PDBG("Packet received!"); - PDBG("Packet content:\n%s", buf); + Genode::log("Packet received!"); + Genode::log("Packet content:\n", Genode::Cstring(buf)); } else break; } @@ -115,7 +115,7 @@ void http_server_serve(int conn) { /* Read the data from the port, blocking if nothing yet there. We assume the request (the part we care about) is in one packet */ buflen = recv(conn, buf, 1024, 0); - PDBG("Request received!"); + Genode::log("Request received!"); /* Ignore receive errors */ if (buflen > 0) { @@ -146,25 +146,25 @@ void http_server_serve(int conn) { int server() { int s; - PDBG("Create new socket ..."); + Genode::log("Create new socket ..."); if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - PERR("No socket available!"); + Genode::error("no socket available!"); return -1; } - PDBG("Now, I will bind ..."); + Genode::log("Now, I will bind ..."); struct sockaddr_in in_addr; in_addr.sin_family = AF_INET; in_addr.sin_port = htons(80); in_addr.sin_addr.s_addr = INADDR_ANY; if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) { - PERR("bind failed!"); + Genode::error("bind failed!"); return -1; } - PDBG("Now, I will listen ..."); + Genode::log("Now, I will listen ..."); if(listen(s, 5)) { - PERR("listen failed!"); + Genode::error("listen failed!"); return -1; } @@ -174,13 +174,13 @@ int server() { * Unblock client thread, wait for requests and handle them, * after that close the connection. */ - PDBG("Start the loop ..."); + Genode::log("Start the loop ..."); while(true) { struct sockaddr addr; socklen_t len = sizeof(addr); int client = accept(s, &addr, &len); if(client < 0) { - PWRN("Invalid socket from accept!"); + Genode::warning("invalid socket from accept!"); continue; } http_server_serve(client); diff --git a/repos/libports/src/test/lwip/pingpong/pingpong.cc b/repos/libports/src/test/lwip/pingpong/pingpong.cc index 8c5abd39a..12115b2d5 100644 --- a/repos/libports/src/test/lwip/pingpong/pingpong.cc +++ b/repos/libports/src/test/lwip/pingpong/pingpong.cc @@ -22,8 +22,6 @@ forgepacket(Packet *p, uint32_t id) { p->h.id = id; p->d[p->h.dsize - 1] = (id % 128); - - //PLOG("payload for %u = %u", id, (id % 128)); } int @@ -35,8 +33,6 @@ checkpacket(size_t n, Packet *p) return -1; } - //PLOG("header: %u, data: %u", n - p->h.dsize, n - sizeof (Packetheader)); - /* check packet type */ if (p->h.type != Tping) { printf("ERROR: wrong packet type!\n"); diff --git a/repos/libports/src/test/lwip/pingpong/server/main.cc b/repos/libports/src/test/lwip/pingpong/server/main.cc index 006aebbdf..55fa5cc3f 100644 --- a/repos/libports/src/test/lwip/pingpong/server/main.cc +++ b/repos/libports/src/test/lwip/pingpong/server/main.cc @@ -152,17 +152,6 @@ main(int argc, char *argv[]) verbose = 0; -#if 0 - Genode::Xml_node argv_node = Genode::config()->xml_node().sub_node("argv"); - try { - argv_node.attribute("listenip" ).value(listenip, sizeof(listenip)); - argv_node.attribute("verbose").value( &verbose ); - } catch(...) { - PERR("listenip was not specified!"); - return 1; - } -#endif - recvping(listenip); return 0; diff --git a/repos/libports/src/test/moon/main.cc b/repos/libports/src/test/moon/main.cc index 226ff6cc0..c33faba8e 100644 --- a/repos/libports/src/test/moon/main.cc +++ b/repos/libports/src/test/moon/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* Lua includes */ @@ -74,13 +74,13 @@ static int l_log(lua_State *lua) for (int i = 1; i <= n; ++i) { if (lua_isstring(lua, i)) - PLOG("%s", lua_tostring(lua, i)); + Genode::log(lua_tostring(lua, i)); else if (lua_isnil(lua, i)) - PLOG("%s", "nil"); + Genode::log("nil"); else if (lua_isboolean(lua, i)) - PLOG("%s", lua_toboolean(lua, i) ? "true" : "false"); + Genode::log(lua_toboolean(lua, i) ? "true" : "false"); else - PLOG("%s: %p", luaL_typename(lua, i), lua_topointer(lua, i)); + Genode::log(luaL_typename(lua, i), ": ", lua_topointer(lua, i)); } return 0; @@ -127,7 +127,7 @@ int main() luaL_register(lua, "Genode", l_genode); if (luaL_dostring(lua, exec_string) != 0) - PLOG("%s\n", lua_tostring(lua, -1)); + Genode::log(lua_tostring(lua, -1)); lua_close(lua); } diff --git a/repos/libports/src/test/python/main.cc b/repos/libports/src/test/python/main.cc index b44441a92..013413eff 100644 --- a/repos/libports/src/test/python/main.cc +++ b/repos/libports/src/test/python/main.cc @@ -15,7 +15,7 @@ #include /* Genode includes */ -#include +#include #include /* libc includes */ @@ -37,9 +37,9 @@ static bool process_config(char **file) return true; } catch (Xml_node::Nonexistent_sub_node) { - PERR("No 'config/script' sub node in config found"); } + Genode::error("no 'config/script' sub node in config found"); } catch (Xml_node::Nonexistent_attribute) { - PERR("No 'name' attribute in 'script' node found"); } + Genode::error("no 'name' attribute in 'script' node found"); } return false; } @@ -54,11 +54,11 @@ int main() char *name; if (!process_config(&name)) { - PERR("No script found"); + Genode::error("no script found"); return 1; } - PDBG("Found script: %s", name); + Genode::log("Found script: ", Genode::Cstring(name)); fp._file = open(name, 0, 0); fp._read = __sread; fp._cookie = &fp; @@ -70,7 +70,7 @@ int main() Py_InteractiveFlag = 0; Py_Initialize(); - PDBG("Starting python ..."); + Genode::log("Starting python ..."); PyRun_SimpleFile(&fp, name); return 0; diff --git a/repos/os/include/audio_in_session/client.h b/repos/os/include/audio_in_session/client.h index 1367d76b4..1198c6953 100644 --- a/repos/os/include/audio_in_session/client.h +++ b/repos/os/include/audio_in_session/client.h @@ -107,8 +107,8 @@ class Audio_in::Session_client : public Genode::Rpc_client void wait_for_progress() { if (!_progress.cap.valid()) { - PWRN("Progress signal is not installed, will not block " - "(enable in 'Audio_in::Connection')"); + Genode::warning("Progress signal is not installed, will not block " + "(enable in 'Audio_in::Connection')"); return; } diff --git a/repos/os/include/audio_out_session/client.h b/repos/os/include/audio_out_session/client.h index 90bcea069..95c92511e 100644 --- a/repos/os/include/audio_out_session/client.h +++ b/repos/os/include/audio_out_session/client.h @@ -110,8 +110,8 @@ class Audio_out::Session_client : public Genode::Rpc_client void wait_for_progress() { if (!_progress.cap.valid()) { - PWRN("Progress signal is not installed, will not block " - "(enable in 'Audio_out::Connection')"); + Genode::warning("Progress signal is not installed, will not block " + "(enable in 'Audio_out::Connection')"); return; } @@ -127,8 +127,8 @@ class Audio_out::Session_client : public Genode::Rpc_client void wait_for_alloc() { if (!_alloc.cap.valid()) { - PWRN("Alloc signal is not installed, will not block " - "(enable in 'Audio_out::Connection')"); + Genode::warning("Alloc signal is not installed, will not block " + "(enable in 'Audio_out::Connection')"); return; } diff --git a/repos/os/include/block/component.h b/repos/os/include/block/component.h index e1efdbce9..79335d940 100644 --- a/repos/os/include/block/component.h +++ b/repos/os/include/block/component.h @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include @@ -81,7 +83,7 @@ class Block::Session_component : public Block::Session_component_base, inline void _ack_packet(Packet_descriptor &packet) { if (!tx_sink()->ready_to_ack()) - error("Not ready to ack!"); + error("not ready to ack!"); tx_sink()->acknowledge_packet(packet); _p_in_fly--; @@ -175,7 +177,7 @@ class Block::Session_component : public Block::Session_component_base, */ Session_component(Driver_factory &driver_factory, Genode::Entrypoint &ep, - size_t buf_size) + size_t buf_size) : Session_component_base(driver_factory, buf_size), Driver_session(_rq_ds, ep.rpc_ep()), _rq_phys(Dataspace_client(_rq_ds).phys_addr()), @@ -293,10 +295,12 @@ class Block::Root : public Genode::Root_component -#include +#include /* local includes */ #include @@ -239,7 +239,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node) } } catch (Xml_node::Nonexistent_sub_node) { - PERR("could not look up window %ld in XML model", window->id()); } + Genode::error("could not look up window ", window->id(), " in XML model"); } } /* @@ -281,7 +281,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node) for_each_sub_node(root_node, "window", [&] (Xml_node window_node) { if (!window) { - PERR("unexpected end of window list during re-ordering"); + Genode::error("unexpected end of window list during re-ordering"); return; } @@ -290,7 +290,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node) if (window->id() != id) { window = _lookup_by_id(id); if (!window) { - PERR("window lookup unexpectedly failed during re-ordering"); + Genode::error("window lookup unexpectedly failed during re-ordering"); return; } diff --git a/repos/os/include/decorator/xml_utils.h b/repos/os/include/decorator/xml_utils.h index 16ec7b6fe..cb17704f6 100644 --- a/repos/os/include/decorator/xml_utils.h +++ b/repos/os/include/decorator/xml_utils.h @@ -71,7 +71,7 @@ Decorator::string_attribute(Xml_node const &node, char const *attr, char buf[CAPACITY]; node.attribute(attr).value(buf, sizeof(buf)); - return Genode::String(buf); + return Genode::String(Genode::Cstring(buf)); } diff --git a/repos/os/include/file_system/node_handle_registry.h b/repos/os/include/file_system/node_handle_registry.h index d24cd5c92..88715c695 100644 --- a/repos/os/include/file_system/node_handle_registry.h +++ b/repos/os/include/file_system/node_handle_registry.h @@ -173,10 +173,8 @@ namespace File_system { { Genode::Lock::Guard guard(_lock); - if (!_in_range(h1.value) || !_in_range(h2.value)) { - PDBG("refer_to_same_node -> Invalid_handle"); + if (!_in_range(h1.value) || !_in_range(h2.value)) throw Invalid_handle(); - } return _nodes[h1.value] == _nodes[h2.value]; } @@ -192,10 +190,8 @@ namespace File_system { throw Invalid_handle(); Node_base *node = dynamic_cast(_nodes[handle.value]); - if (!node) { - PDBG("Invalid_handle"); + if (!node) throw Invalid_handle(); - } node->lock(); Node_lock_guard node_lock_guard(node); diff --git a/repos/os/include/file_system_session/connection.h b/repos/os/include/file_system_session/connection.h index a309e6487..457226d0a 100644 --- a/repos/os/include/file_system_session/connection.h +++ b/repos/os/include/file_system_session/connection.h @@ -112,7 +112,6 @@ struct File_system::Connection : File_system::Connection_base */ void upgrade_ram() { - PWRN("upgrading File_system session"); Genode::env()->parent()->upgrade(cap(), "ram=8K"); } diff --git a/repos/os/include/framebuffer_session/framebuffer_session.h b/repos/os/include/framebuffer_session/framebuffer_session.h index 3bba53a2f..aebf30930 100644 --- a/repos/os/include/framebuffer_session/framebuffer_session.h +++ b/repos/os/include/framebuffer_session/framebuffer_session.h @@ -14,6 +14,7 @@ #ifndef _INCLUDE__FRAMEBUFFER_SESSION__FRAMEBUFFER_SESSION_H_ #define _INCLUDE__FRAMEBUFFER_SESSION__FRAMEBUFFER_SESSION_H_ +#include #include #include #include @@ -64,6 +65,15 @@ struct Framebuffer::Mode */ Genode::size_t bytes_per_pixel() const { return bytes_per_pixel(_format); } + + void print(Genode::Output &out) const + { + Genode::print(out, _width, "x", _height, "@"); + switch (_format) { + case RGB565: Genode::print(out, "RGB565"); break; + default: Genode::print(out, "INVALID"); break; + } + } }; diff --git a/repos/os/include/gpio/config.h b/repos/os/include/gpio/config.h index a07cf11b2..34182a2ce 100644 --- a/repos/os/include/gpio/config.h +++ b/repos/os/include/gpio/config.h @@ -62,18 +62,20 @@ void Gpio::process_config(Gpio::Driver &driver) driver.direction(num, true); } else throw Invalid_mode(); - PINF("gpio %d mode %s value=%d", num, mode, value); + Genode::log("gpio ", num, " " + "mode ", Genode::Cstring(mode), " " + "value=", value); } catch(Genode::Xml_node::Nonexistent_attribute) { - PWRN("Missing attribute. Ignore node."); + Genode::warning("missing attribute. Ignore node."); } catch(Gpio::Invalid_gpio_number) { - PWRN("Invalid GPIO number %d. Ignore node", num); + Genode::warning("invalid GPIO number ", num, ", ignore node"); } if (gpio_node.last("gpio")) break; } } catch (Genode::Xml_node::Nonexistent_sub_node) { - PWRN("No GPIO config"); + Genode::warning("no GPIO config"); } } diff --git a/repos/os/include/init/child.h b/repos/os/include/init/child.h index 12109653d..e456d0f31 100644 --- a/repos/os/include/init/child.h +++ b/repos/os/include/init/child.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -47,8 +47,8 @@ namespace Init { static void warn_insuff_quota(Genode::size_t const avail) { if (!config_verbose) { return; } - Genode::printf("Warning: Specified quota exceeds available quota.\n"); - Genode::printf(" Proceeding with a quota of %zu.\n", avail); + Genode::log("Warning: Specified quota exceeds available quota."); + Genode::log(" Proceeding with a quota of ", avail, "."); } inline long read_priority(Genode::Xml_node start_node, long prio_levels) @@ -70,8 +70,8 @@ namespace Init { long new_prio = prio_levels ? prio_levels-1 : 0; char name[Genode::Service::MAX_NAME_LEN]; start_node.attribute("name").value(name, sizeof(name)); - PWRN("%s: invalid priority, upgrading from %ld to %ld", - name, -priority, -new_prio); + Genode::warning(Genode::Cstring(name), ": invalid priority, upgrading " + "from ", -priority, " to ", -new_prio); return new_prio; } @@ -152,7 +152,7 @@ namespace Init { if (Genode::strcmp(" -> ", label, 4) == 0) return label + 4; - PWRN("cannot skip label prefix while processing "); + Genode::warning("cannot skip label prefix while processing "); return label; } @@ -391,12 +391,13 @@ class Init::Child : Genode::Child_policy try { start_node.attribute("name").value(unique, sizeof(unique)); } catch (Genode::Xml_node::Nonexistent_attribute) { - PWRN("Missing 'name' attribute in '' entry.\n"); + Genode::warning("missing 'name' attribute in '' entry"); throw; } /* check for a name confict with the other children */ if (!registry.unique(unique)) { - PERR("Child name \"%s\" is not unique", unique); + Genode::error("child name \"", Genode::Cstring(unique), "\" " + "is not unique"); throw Child_name_is_not_unique(); } @@ -582,13 +583,14 @@ class Init::Child : Genode::Child_policy using namespace Genode; if (_resources.ram_quota == 0) - PWRN("no valid RAM resource for child \"%s\"", _name.unique); + Genode::warning("no valid RAM resource for child " + "\"", Genode::Cstring(_name.unique), "\""); if (config_verbose) { - Genode::printf("child \"%s\"\n", _name.unique); - Genode::printf(" RAM quota: %zu\n", _resources.ram_quota); - Genode::printf(" ELF binary: %s\n", _name.file); - Genode::printf(" priority: %ld\n", _resources.priority); + Genode::log("child \"", Genode::Cstring(_name.unique), "\""); + Genode::log(" RAM quota: ", _resources.ram_quota); + Genode::log(" ELF binary: ", Cstring(_name.file)); + Genode::log(" priority: ", _resources.priority); } /* @@ -603,7 +605,7 @@ class Init::Child : Genode::Child_policy service_node.attribute("name").value(name, sizeof(name)); if (config_verbose) - Genode::printf(" provides service %s\n", name); + Genode::log(" provides service ", Genode::Cstring(name)); child_services.insert(new (_child.heap()) Routed_service(name, &_server)); @@ -642,6 +644,8 @@ class Init::Child : Genode::Child_policy const char *args) { Genode::Service *service = 0; + using Genode::error; + using Genode::warning; /* check for config file request */ if ((service = _config_policy.resolve_session_request(service_name, args))) @@ -677,7 +681,8 @@ class Init::Child : Genode::Child_policy return service; if (!service_wildcard) { - PWRN("%s: service lookup for \"%s\" at parent failed", name(), service_name); + warning(name(), ": service lookup for " + "\"", service_name, "\" at parent failed"); return 0; } } @@ -689,7 +694,8 @@ class Init::Child : Genode::Child_policy Genode::Server *server = _name_registry.lookup_server(server_name); if (!server) { - PWRN("%s: invalid route to non-existing server \"%s\"", name(), server_name); + warning(name(), ": invalid route to non-existing " + "server \"", Genode::Cstring(server_name), "\""); return 0; } @@ -698,14 +704,16 @@ class Init::Child : Genode::Child_policy return service; if (!service_wildcard) { - PWRN("%s: lookup to child service \"%s\" failed", name(), service_name); + Genode::warning(name(), ": lookup to child " + "service \"", service_name, "\" failed"); return 0; } } if (target.has_type("any-child")) { if (_child_services.is_ambiguous(service_name)) { - PERR("%s: ambiguous routes to service \"%s\"", name(), service_name); + error(name(), ": ambiguous routes to " + "service \"", service_name, "\""); return 0; } service = _child_services.find(service_name); @@ -713,7 +721,8 @@ class Init::Child : Genode::Child_policy return service; if (!service_wildcard) { - PWRN("%s: lookup for service \"%s\" failed", name(), service_name); + warning(name(), ": lookup for service " + "\"", service_name, "\" failed"); return 0; } } @@ -723,7 +732,7 @@ class Init::Child : Genode::Child_policy } } } catch (...) { - PWRN("%s: no route to service \"%s\"", name(), service_name); + warning(name(), ": no route to service \"", service_name, "\""); } return service; } @@ -769,13 +778,12 @@ class Init::Child : Genode::Child_policy Genode::Server *server) { if (config_verbose) - Genode::printf("child \"%s\" announces service \"%s\"\n", - name(), service_name); + Genode::log("child \"", name(), "\" announces service \"", service_name, "\""); Genode::Service *s = _child_services.find(service_name, &_server); Routed_service *rs = dynamic_cast(s); if (!s || !rs) { - PERR("%s: illegal announcement of service \"%s\"", name(), service_name); + Genode::error(name(), ": illegal announcement of service \"", service_name, "\""); return false; } @@ -785,15 +793,14 @@ class Init::Child : Genode::Child_policy void resource_request(Genode::Parent::Resource_args const &args) { - Genode::printf("child \"%s\" requests resources: %s\n", - name(), args.string()); + Genode::log("child \"", name(), "\" requests resources: ", args.string()); Genode::size_t const requested_ram_quota = Genode::Arg_string::find_arg(args.string(), "ram_quota") .ulong_value(0); if (avail_slack_ram_quota() < requested_ram_quota) { - PWRN("Cannot respond to resource request - out of memory"); + Genode::warning("cannot respond to resource request - out of memory"); return; } diff --git a/repos/os/include/init/child_policy.h b/repos/os/include/init/child_policy.h index ad5d662fe..d89920c20 100644 --- a/repos/os/include/init/child_policy.h +++ b/repos/os/include/init/child_policy.h @@ -133,7 +133,7 @@ class Init::Child_policy_handle_cpu_priorities long discarded_prio_lsb_bits_mask = (1 << _prio_levels_log2) - 1; if (priority & discarded_prio_lsb_bits_mask) { - PWRN("priority band too small, losing least-significant priority bits"); + warning("priority band too small, losing least-significant priority bits"); } priority >>= _prio_levels_log2; @@ -281,7 +281,7 @@ class Init::Child_policy_redirect_rom_file Session_label const to(_to); Session_label const prefixed_to = - prefixed_label(prefix.valid() ? prefix : nullptr, to); + prefixed_label(prefix.valid() ? prefix : Session_label(), to); Arg_string::set_arg_string(args, args_len, "label", prefixed_to.string()); } diff --git a/repos/os/include/input/component.h b/repos/os/include/input/component.h index 7ec583e2e..cdfa04674 100644 --- a/repos/os/include/input/component.h +++ b/repos/os/include/input/component.h @@ -49,7 +49,7 @@ class Input::Session_component : public Genode::Rpc_object try { _event_queue.add(event); } catch (Input::Event_queue::Overflow) { - PWRN("input overflow - resetting queue"); + Genode::warning("input overflow - resetting queue"); _event_queue.reset(); } } diff --git a/repos/os/include/nic/root.h b/repos/os/include/nic/root.h index 9993ee06b..5da19219c 100644 --- a/repos/os/include/nic/root.h +++ b/repos/os/include/nic/root.h @@ -52,8 +52,8 @@ class Nic::Root : public Genode::Root_component ram_quota - session_size) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, tx_buf_size + rx_buf_size + session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); } diff --git a/repos/os/include/nic_session/nic_session.h b/repos/os/include/nic_session/nic_session.h index a91e0905d..93e573c73 100644 --- a/repos/os/include/nic_session/nic_session.h +++ b/repos/os/include/nic_session/nic_session.h @@ -15,6 +15,7 @@ #define _INCLUDE__NIC_SESSION__NIC_SESSION_H_ #include +#include #include #include #include @@ -33,7 +34,20 @@ namespace Nic { } -struct Nic::Mac_address { char addr[6]; }; +struct Nic::Mac_address +{ + enum { NUM_ELEM = 6 }; + + char addr[NUM_ELEM]; + + void print(Genode::Output &out) const + { + using Genode::Hex; + for (unsigned i = 0; i < NUM_ELEM; i++) + Genode::print(out, i > 0 ? ":" : "", + Hex(addr[i], Hex::OMIT_PREFIX, Hex::PAD)); + } +}; /* diff --git a/repos/os/include/os/child_policy_dynamic_rom.h b/repos/os/include/os/child_policy_dynamic_rom.h index 1e6ebc2d0..9ce5ee2b6 100644 --- a/repos/os/include/os/child_policy_dynamic_rom.h +++ b/repos/os/include/os/child_policy_dynamic_rom.h @@ -98,7 +98,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, Lock::Guard guard(_lock); if (!_ram) { - PERR("Error: No backing store for loading ROM data"); + Genode::error("no backing store for loading ROM data"); return; } @@ -123,7 +123,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, Lock::Guard guard(_lock); if (!_fg.size() && !_bg_has_pending_data) { - PERR("Error: no data loaded"); + Genode::error("no data loaded"); return Rom_dataspace_capability(); } diff --git a/repos/os/include/os/slave.h b/repos/os/include/os/slave.h index 77c437f2a..90e4ed1dd 100644 --- a/repos/os/include/os/slave.h +++ b/repos/os/include/os/slave.h @@ -131,8 +131,7 @@ class Genode::Slave_policy : public Genode::Child_policy return service; if (!_service_permitted(service_name)) { - PERR("%s: illegal session request of service \"%s\"", - name(), service_name); + error(name(), ": illegal session request of service \"", service_name, "\""); return 0; } diff --git a/repos/os/include/ram_fs/directory.h b/repos/os/include/ram_fs/directory.h index 402692be5..fc2c3923b 100644 --- a/repos/os/include/ram_fs/directory.h +++ b/repos/os/include/ram_fs/directory.h @@ -188,14 +188,14 @@ class File_system::Directory : public Node size_t read(char *dst, size_t len, seek_off_t seek_offset) { if (len < sizeof(Directory_entry)) { - PERR("read buffer too small for directory entry"); + Genode::error("read buffer too small for directory entry"); return 0; } seek_off_t index = seek_offset / sizeof(Directory_entry); if (seek_offset % sizeof(Directory_entry)) { - PERR("seek offset not alighed to sizeof(Directory_entry)"); + Genode::error("seek offset not alighed to sizeof(Directory_entry)"); return 0; } diff --git a/repos/os/include/ram_fs/file.h b/repos/os/include/ram_fs/file.h index 87af09c9d..60fa8460c 100644 --- a/repos/os/include/ram_fs/file.h +++ b/repos/os/include/ram_fs/file.h @@ -86,7 +86,7 @@ class File_system::File : public Node if (seek_offset + len >= Chunk_level_0::SIZE) { len = (Chunk_level_0::SIZE-1) - seek_offset; - PERR("%s: size limit %d reached", name(), Chunk_level_0::SIZE); + Genode::error(name(), ": size limit ", (long)Chunk_level_0::SIZE, " reached"); } _chunk.write(src, len, (size_t)seek_offset); diff --git a/repos/os/include/report_rom/report_service.h b/repos/os/include/report_rom/report_service.h index 6a2861afd..375ca1bcd 100644 --- a/repos/os/include/report_rom/report_service.h +++ b/repos/os/include/report_rom/report_service.h @@ -55,7 +55,8 @@ struct Report::Session_component : Genode::Rpc_object, Rom::Writer static void _log_lines(char const *string, size_t len) { Genode::print_lines<200>(string, len, - [&] (char const *line) { Genode::log(" ", line); }); + [&] (char const *line) + { Genode::log(" ", line); }); } public: @@ -87,7 +88,7 @@ struct Report::Session_component : Genode::Rpc_object, Rom::Writer length = Genode::min(length, _ds.size()); if (_verbose) { - Genode::log("report '", _module.name().string(), "'"); + Genode::log("report '", _module.name(), "'"); _log_lines(_ds.local_addr(), length); } diff --git a/repos/os/include/spec/x86/platform_device/platform_device.h b/repos/os/include/spec/x86/platform_device/platform_device.h index d9da043c4..b87d3afa4 100644 --- a/repos/os/include/spec/x86/platform_device/platform_device.h +++ b/repos/os/include/spec/x86/platform_device/platform_device.h @@ -74,7 +74,7 @@ struct Platform::Device : Platform::Abstract_device /** * Return base address of resource */ - unsigned base() + unsigned base() const { /* * Mask out the resource-description bits of the base @@ -87,12 +87,12 @@ struct Platform::Device : Platform::Abstract_device /** * Return resource size in bytes */ - unsigned size() { return _size; } + unsigned size() const { return _size; } /** * Return true if resource is prefetchable memory */ - bool prefetchable() + bool prefetchable() const { return type() == MEMORY && (_bar & (1 << 3)); } @@ -100,7 +100,7 @@ struct Platform::Device : Platform::Abstract_device /** * Return resource type */ - Type type() + Type type() const { if (_bar == 0) return INVALID; diff --git a/repos/os/include/terminal/char_cell_array_character_screen.h b/repos/os/include/terminal/char_cell_array_character_screen.h index 9db6b638c..ae350ad87 100644 --- a/repos/os/include/terminal/char_cell_array_character_screen.h +++ b/repos/os/include/terminal/char_cell_array_character_screen.h @@ -218,10 +218,7 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _cursor_visibility = CURSOR_VERY_VISIBLE; } - void cpr() - { - PDBG("not implemented"); - } + void cpr() { Genode::warning(__func__, " not implemented"); } void csr(int start, int end) { @@ -267,8 +264,8 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _cursor_pos = Terminal::Position(x, y); } - void cuu1() { PWRN("not implemented"); } - void dch(int) { PDBG("not implemented"); } + void cuu1() { Genode::warning(__func__, " not implemented"); } + void dch(int) { Genode::warning(__func__, " not implemented"); } void dl(int num_lines) { @@ -301,7 +298,7 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _char_cell_array.set_cell(x, _cursor_pos.y, Char_cell()); } - void el1() { PDBG("not implemented"); } + void el1() { Genode::warning(__func__, " not implemented"); } void home() { @@ -318,8 +315,8 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _cursor_pos.x = Genode::min(_boundary.width - 1, _cursor_pos.x); } - void hts() { PDBG("not implemented"); } - void ich(int) { PDBG("not implemented"); } + void hts() { Genode::warning(__func__, " not implemented"); } + void ich(int) { Genode::warning(__func__, " not implemented"); } void il(int value) { @@ -336,18 +333,18 @@ class Char_cell_array_character_screen : public Terminal::Character_screen _char_cell_array.cursor(_cursor_pos, true); } - void oc() { PDBG("not implemented"); } + void oc() { Genode::warning(__func__, " not implemented"); } void op() { _color_index = DEFAULT_COLOR_INDEX | (DEFAULT_COLOR_INDEX_BG << 3); } - void rc() { PDBG("not implemented"); } - void ri() { PDBG("not implemented"); } - void ris() { PDBG("not implemented"); } - void rmam() { PDBG("not implemented"); } - void rmir() { PDBG("not implemented"); } + void rc() { Genode::warning(__func__, " not implemented"); } + void ri() { Genode::warning(__func__, " not implemented"); } + void ris() { Genode::warning(__func__, " not implemented"); } + void rmam() { Genode::warning(__func__, " not implemented"); } + void rmir() { Genode::warning(__func__, " not implemented"); } void setab(int value) { @@ -377,14 +374,14 @@ class Char_cell_array_character_screen : public Terminal::Character_screen sgr(0); } - void sc() { PDBG("not implemented"); } - void smam() { PDBG("not implemented"); } - void smir() { PDBG("not implemented"); } - void tbc() { PDBG("not implemented"); } - void u6(int, int) { PDBG("not implemented"); } - void u7() { PDBG("not implemented"); } - void u8() { PDBG("not implemented"); } - void u9() { PDBG("not implemented"); } + void sc() { Genode::warning(__func__, " not implemented"); } + void smam() { Genode::warning(__func__, " not implemented"); } + void smir() { Genode::warning(__func__, " not implemented"); } + void tbc() { Genode::warning(__func__, " not implemented"); } + void u6(int, int) { Genode::warning(__func__, " not implemented"); } + void u7() { Genode::warning(__func__, " not implemented"); } + void u8() { Genode::warning(__func__, " not implemented"); } + void u9() { Genode::warning(__func__, " not implemented"); } void vpa(int y) { diff --git a/repos/os/include/terminal/decoder.h b/repos/os/include/terminal/decoder.h index c9ba3faa7..c6955d3c7 100644 --- a/repos/os/include/terminal/decoder.h +++ b/repos/os/include/terminal/decoder.h @@ -96,15 +96,15 @@ class Terminal::Decoder void _dump() const { - Genode::printf("--- escape stack follows ---\n"); + Genode::log("--- escape stack follows ---"); for (int i = 0; i < _index; i++) { int type = _entries[i].type; int value = _entries[i].value; - Genode::printf("%s %d (0x%x '%c')\n", - type == Entry::INVALID ? " INVALID" : - type == Entry::NUMBER ? " NUMBER " - : " CODE ", - value, value, value); + Genode::log(type == Entry::INVALID ? " INVALID" : + type == Entry::NUMBER ? " NUMBER " + : " CODE ", + " ", value, " ", + "(", Genode::Hex(value), ")"); } } @@ -117,7 +117,7 @@ class Terminal::Decoder void push(Entry const &entry) { if (_index == MAX_ENTRIES - 1) { - Genode::printf("Error: escape stack overflow\n"); + Genode::error("escape stack overflow"); _dump(); reset(); return; @@ -392,7 +392,7 @@ class Terminal::Decoder * Currently returning true w/o actually handling the * sequence */ - PDBG("Sequence '[%d;%d;%d%c' is not implemented", p1, p2, p3, command); + Genode::warning("Sequence '[", p1, ";", p2, ";", p3, "m' is not implemented"); return true; default: return false; } diff --git a/repos/os/include/usb/packet_handler.h b/repos/os/include/usb/packet_handler.h index 40bd70035..917d97a51 100644 --- a/repos/os/include/usb/packet_handler.h +++ b/repos/os/include/usb/packet_handler.h @@ -1,4 +1,4 @@ -/** +/* * \brief Packet stream helper * \author Sebastian Sumpf * \date 2014-12-08 @@ -83,8 +83,9 @@ class Usb::Packet_handler { /* is size larger than packet stream */ if (size > _connection.source()->bulk_buffer_size()) { - PERR("Packet allocation of (%zu bytes) too large, buffer has %zu bytes", - size, _connection.source()->bulk_buffer_size()); + Genode::error("packet allocation of (", size, " bytes) too large, " + "buffer has ", _connection.source()->bulk_buffer_size(), + " bytes"); throw Usb::Session::Tx::Source::Packet_alloc_failed(); } diff --git a/repos/os/include/usb/usb.h b/repos/os/include/usb/usb.h index 938df43a9..11be15b58 100644 --- a/repos/os/include/usb/usb.h +++ b/repos/os/include/usb/usb.h @@ -18,8 +18,7 @@ #include #include #include - -#include +#include namespace Usb { @@ -105,8 +104,11 @@ class Usb::Endpoint : public Endpoint_descriptor void dump() { if (verbose_descr) - PLOG("\tEndpoint: len: %x type: %x address: %x attributes: %x", - length, type, address, attributes); + Genode::log("\tEndpoint: " + "len: ", Genode::Hex(length), " " + "type: ", Genode::Hex(type), " " + "address: ", Genode::Hex(address), " " + "attributes: ", Genode::Hex(attributes)); } }; @@ -159,10 +161,16 @@ class Usb::Alternate_interface : public Interface_descriptor, if (!verbose_descr) return; - PWRN("Interface: len: %x: type: %x number: %x alt_setting: %x", - length, type, number, alt_settings); - PWRN(" num_endpoints: %x class: %x subclass: %x: protocol: %x", - num_endpoints, iclass, isubclass, iprotocol); + Genode::warning("Interface: " + "len: ", Genode::Hex(length), " " + "type: ", Genode::Hex(type), " " + "number: ", Genode::Hex(number), " " + "alt_settings: ", Genode::Hex(alt_settings)); + Genode::warning(" " + "num_endpoints: ", Genode::Hex(num_endpoints), " " + "class: ", Genode::Hex(iclass), " ", + "subclass: ", Genode::Hex(isubclass), " " + "protocol: ", Genode::Hex(iprotocol)); } }; @@ -383,7 +391,7 @@ class Usb::Config : public Config_descriptor, for (unsigned j = 0; j < alt_settings; j++) { _connection.interface_descriptor(i, j, &descr); if (descr.number != i) - PERR("Interface number != index"); + error("Interface number != index"); _interfaces[descr.number]->_add(new(_md_alloc) Alternate_interface(descr, md)); } @@ -410,8 +418,12 @@ class Usb::Config : public Config_descriptor, void dump() { if (verbose_descr) - PINF("Config: len: %x type %x total_len: %x num_intf: %x config_value: %x", - length, type, total_length, num_interfaces, config_value); + log("Config: " + "len: ", Genode::Hex(length), " " + "type: ", Genode::Hex(type), " " + "total_length: ", Genode::Hex(total_length), " " + "num_intf: ", Genode::Hex(num_interfaces), " " + "config_value: ", Genode::Hex(config_value)); } }; @@ -520,12 +532,12 @@ class Usb::Device : public Meta_data void set_configuration(uint8_t num) { if (!config) { - PERR("No current configuration found"); + Genode::error("No current configuration found"); return; } if (!num || num > device_descr.num_configs) { - PERR("Valid configuration values: 1 ... %u", device_descr.num_configs); + Genode::error("Valid configuration values: 1 ... ", device_descr.num_configs); return; } @@ -552,11 +564,19 @@ class Usb::Device : public Meta_data if (!verbose_descr) return; - PINF("Device: len: %x type: %x class: %x sub-class: %x proto: %x max_packet: %x", - device_descr.length, device_descr.type, device_descr.dclass, device_descr.dsubclass, - device_descr.dprotocol, device_descr.max_packet_size); - PINF(" vendor: %x product: %x configs: %x", - device_descr.vendor_id, device_descr.product_id, device_descr.num_configs); + using Genode::Hex; + + Genode::log("Device: " + "len: ", Hex(device_descr.length), " " + "type: " , Hex(device_descr.type), " " + "class: ", Hex(device_descr.dclass), " " + "sub-class: ", Hex(device_descr.dsubclass), " " + "proto: ", Hex(device_descr.dprotocol), " " + "max_packet: ", Hex(device_descr.max_packet_size)); + Genode::log(" " + "vendor: ", Hex(device_descr.vendor_id), " " + "product: ", Hex(device_descr.product_id), " " + "configs: ", Hex(device_descr.num_configs)); } }; diff --git a/repos/os/include/util/geometry.h b/repos/os/include/util/geometry.h index 88caead4c..876f6f7d0 100644 --- a/repos/os/include/util/geometry.h +++ b/repos/os/include/util/geometry.h @@ -16,6 +16,7 @@ #include #include +#include namespace Genode { template class Point; @@ -61,6 +62,12 @@ class Genode::Point * Operator for testing equality of two points */ bool operator == (Point const &p) const { return p.x() == _x && p.y() == _y; } + + void print(Output &out) const + { + Genode::print(out, _x >= 0 ? "+" : "-", abs(_x), + _y >= 0 ? "+" : "-", abs(_y)); + } }; @@ -95,6 +102,8 @@ class Genode::Area * Operator for testing equality of two areas */ bool operator == (Area const &a) const { return a.w() == _w && a.h() == _h; } + + void print(Output &out) const { Genode::print(out, _w, "x", _h); } }; @@ -195,6 +204,15 @@ class Genode::Rect Point center(Area
area) const { return Point(((CT)w() - (CT)area.w())/2, ((CT)h() - (CT)area.h())/2) + p1(); } + + /** + * Print rectangle coordinates + * + * The output has the form 'width' x 'height' +/- 'p1.x' +/- 'p1.y'. + * For example, a rectange of size 15x16 as position (-13, 14) is + * printed as "15x16-13+14" + */ + void print(Output &out) const { Genode::print(out, area(), p1()); } }; #endif /* _INCLUDE__UTIL__GEOMETRY_H_ */ diff --git a/repos/os/include/vfs/block_file_system.h b/repos/os/include/vfs/block_file_system.h index 34ffdf92b..339ca4e60 100644 --- a/repos/os/include/vfs/block_file_system.h +++ b/repos/os/include/vfs/block_file_system.h @@ -84,7 +84,7 @@ class Vfs::Block_file_system : public Single_file_system p = _tx_source->get_acked_packet(); if (!p.succeeded()) { - PERR("Could not read block(s)"); + Genode::error("Could not read block(s)"); _tx_source->release_packet(p); return 0; } @@ -149,7 +149,7 @@ class Vfs::Block_file_system : public Single_file_system file_size count, file_size &out_count) override { if (!_writeable) { - PERR("block device is not writeable"); + Genode::error("block device is not writeable"); return WRITE_ERR_INVALID; } @@ -184,8 +184,7 @@ class Vfs::Block_file_system : public Single_file_system nbytes = _block_io(blk_nr, (void*)(buf + written), bytes_left, true, true); if (nbytes == 0) { - PERR("error while write block:%llu from block device", - blk_nr); + Genode::error("error while write block:", blk_nr, " from block device"); return WRITE_ERR_INVALID; } @@ -214,8 +213,7 @@ class Vfs::Block_file_system : public Single_file_system nbytes = _block_io(blk_nr, _block_buffer, _block_size, true); if ((unsigned)nbytes != _block_size) { - PERR("error while writing block:%llu from Block_device", - blk_nr); + Genode::error("error while writing block:", blk_nr, " to Block_device"); return WRITE_ERR_INVALID; } @@ -233,7 +231,7 @@ class Vfs::Block_file_system : public Single_file_system file_size &out_count) override { if (!_readable) { - PERR("block device is not readable"); + Genode::error("block device is not readable"); return READ_ERR_INVALID; } @@ -267,8 +265,7 @@ class Vfs::Block_file_system : public Single_file_system nbytes = _block_io(blk_nr, dst + read, bytes_left, false, true); if (nbytes == 0) { - PERR("error while reading block:%llu from block device", - blk_nr); + Genode::error("error while reading block:", blk_nr, " from block device"); return READ_ERR_INVALID; } @@ -281,8 +278,7 @@ class Vfs::Block_file_system : public Single_file_system nbytes = _block_io(blk_nr, _block_buffer, _block_size, false); if ((unsigned)nbytes != _block_size) { - PERR("error while reading block:%llu from block device", - blk_nr); + Genode::error("error while reading block:", blk_nr, " from block device"); return READ_ERR_INVALID; } @@ -314,7 +310,7 @@ class Vfs::Block_file_system : public Single_file_system default: - PDBG("invalid ioctl request %d", opcode); + Genode::warning("invalid ioctl request ", (int)opcode); break; } diff --git a/repos/os/include/vfs/dir_file_system.h b/repos/os/include/vfs/dir_file_system.h index 57cda509a..12796c274 100644 --- a/repos/os/include/vfs/dir_file_system.h +++ b/repos/os/include/vfs/dir_file_system.h @@ -235,14 +235,14 @@ class Vfs::Dir_file_system : public File_system continue; } - PERR("failed to create <%s> VFS node", sub_node.type().string()); + Genode::error("failed to create <", sub_node.type(), "> VFS node"); try { String<64> value; for (unsigned i = 0; i < 16; ++i) { Xml_attribute attr = sub_node.attribute(i); attr.value(&value); - PERR("\t%s=\"%s\"", attr.name().string(), value.string()); + Genode::error("\t", attr.name(), "=\"", value, "\""); } } catch (Xml_node::Nonexistent_attribute) { } } diff --git a/repos/os/include/vfs/fs_file_system.h b/repos/os/include/vfs/fs_file_system.h index 7addbe72f..938c641fd 100644 --- a/repos/os/include/vfs/fs_file_system.h +++ b/repos/os/include/vfs/fs_file_system.h @@ -23,8 +23,6 @@ namespace Vfs { class Fs_file_system; } class Vfs::Fs_file_system : public File_system { - enum { verbose = false }; - private: /* @@ -537,10 +535,6 @@ class Vfs::Fs_file_system : public File_system bool const create = vfs_mode & OPEN_MODE_CREATE; - if (create) - if (verbose) - PDBG("creation of file %s requested", file_name.base() + 1); - try { ::File_system::Dir_handle dir = _fs.dir(dir_path.base(), false); Fs_handle_guard dir_guard(_fs, dir); diff --git a/repos/os/include/vfs/tar_file_system.h b/repos/os/include/vfs/tar_file_system.h index ef551946f..271b6fc7b 100644 --- a/repos/os/include/vfs/tar_file_system.h +++ b/repos/os/include/vfs/tar_file_system.h @@ -23,8 +23,6 @@ namespace Vfs { class Tar_file_system; } class Vfs::Tar_file_system : public File_system { - enum { verbose = false }; - struct Rom_name { enum { ROM_NAME_MAX_LEN = 64 }; @@ -133,9 +131,6 @@ class Vfs::Tar_file_system : public File_system { Absolute_path lookup_path(name); - if (verbose) - PDBG("lookup_path = %s", lookup_path.base()); - Node *parent_node = this; Node *child_node; @@ -152,15 +147,8 @@ class Vfs::Tar_file_system : public File_system t.string(path_element, sizeof(path_element)); - if (verbose) - PDBG("path_element = %s", path_element); - for (child_node = parent_node->first(); child_node; child_node = child_node->next()) { - if (verbose) - PDBG("comparing with node %s", child_node->name); if (strcmp(child_node->name, path_element) == 0) { - if (verbose) - PDBG("found matching child node"); parent_node = child_node; break; } @@ -214,9 +202,6 @@ class Vfs::Tar_file_system : public File_system { Absolute_path current_path(record->name()); - if (verbose) - PDBG("current_path = %s", current_path.base()); - char path_element[MAX_PATH_LEN]; Path_element_token t(current_path.base()); @@ -242,9 +227,6 @@ class Vfs::Tar_file_system : public File_system if (child_node) { - if (verbose) - PDBG("found node for %s", path_element); - if (remaining_path.has_single_element()) { /* Found a node for the record to be inserted. * This is usually a directory node without @@ -254,9 +236,6 @@ class Vfs::Tar_file_system : public File_system } else { if (remaining_path.has_single_element()) { - if (verbose) - PDBG("creating node for %s", path_element); - /* * TODO: find 'path_element' in 'record->name' * and use the location in the record as name @@ -268,9 +247,6 @@ class Vfs::Tar_file_system : public File_system child_node = new (env()->heap()) Node(name, record); } else { - if (verbose) - PDBG("creating node without record for %s", path_element); - /* create a directory node without record */ Genode::size_t name_size = strlen(path_element) + 1; char *name = (char*)env()->heap()->alloc(name_size); @@ -376,8 +352,8 @@ class Vfs::Tar_file_system : public File_system _root_node("", 0), _cached_num_dirent(_root_node) { - PINF("tar archive '%s' local at %p, size is %llu", - _rom_name.name, _tar_base, _tar_size); + Genode::log("tar archive '", Genode::Cstring(_rom_name.name), "' " + "local at ", (void *)_tar_base, ", size is ", _tar_size); _for_each_tar_record_do(Add_node_action(_root_node)); } @@ -395,8 +371,8 @@ class Vfs::Tar_file_system : public File_system Record const *record = node->record; if (record->type() != Record::TYPE_FILE) { - PERR("TAR record \"%s\" has unsupported type %d", - path, record->type()); + Genode::error("TAR record \"", path, "\" has " + "unsupported type ", record->type()); return Dataspace_capability(); } @@ -410,7 +386,7 @@ class Vfs::Tar_file_system : public File_system return ds_cap; } - catch (...) { PDBG("Could not create new dataspace"); } + catch (...) { Genode::warning(__func__, " could not create new dataspace"); } return Dataspace_capability(); } @@ -422,9 +398,6 @@ class Vfs::Tar_file_system : public File_system Stat_result stat(char const *path, Stat &out) override { - if (verbose) - PDBG("path = %s", path); - out = Stat(); Node const *node = dereference(path); @@ -432,9 +405,6 @@ class Vfs::Tar_file_system : public File_system return STAT_ERR_NO_ENTRY; if (!node->record) { - if (verbose) - PDBG("found a virtual directoty node"); - out.mode = STAT_MODE_DIRECTORY; return STAT_OK; } @@ -448,9 +418,7 @@ class Vfs::Tar_file_system : public File_system case Record::TYPE_SYMLINK: mode |= STAT_MODE_SYMLINK; break; case Record::TYPE_DIR: mode |= STAT_MODE_DIRECTORY; break; - default: - if (verbose) - PDBG("unhandled record type %d", record->type()); + default: break; } out.mode = mode; @@ -496,7 +464,8 @@ class Vfs::Tar_file_system : public File_system out.type = DIRENT_TYPE_DIRECTORY; break; default: - PERR("unhandled record type %d for %s", record->type(), node->name); + Genode::error("unhandled record type ", record->type(), " " + "for ", node->name); } } else { /* If no record exists, assume it is a directory */ @@ -615,7 +584,6 @@ class Vfs::Tar_file_system : public File_system Write_result write(Vfs_handle *, char const *, file_size, file_size &) override { - PDBG("called\n"); return WRITE_ERR_INVALID; } @@ -641,7 +609,6 @@ class Vfs::Tar_file_system : public File_system Ftruncate_result ftruncate(Vfs_handle *handle, file_size) override { - PDBG("called\n"); return FTRUNCATE_ERR_NO_PERM; } }; diff --git a/repos/os/run/report_rom.run b/repos/os/run/report_rom.run index 61fff6a14..ecc5e7060 100644 --- a/repos/os/run/report_rom.run +++ b/repos/os/run/report_rom.run @@ -58,13 +58,11 @@ compare_output_to { [init -> test-report_rom] Reporter: brightness 10 [init -> test-report_rom] ROM client: request brightness report [init -> test-report_rom] -> - [init -> test-report_rom] [init -> test-report_rom] Reporter: updated brightness to 77 [init -> test-report_rom] ROM client: wait for update notification [init -> test-report_rom] ROM client: got signal [init -> test-report_rom] ROM client: request updated brightness report [init -> test-report_rom] -> - [init -> test-report_rom] [init -> test-report_rom] Reporter: close report session [init -> test-report_rom] ROM client: ROM is available despite report was closed - OK [init -> test-report_rom] Reporter: start reporting (while the ROM client still listens) diff --git a/repos/os/run/resource_yield.run b/repos/os/run/resource_yield.run index f1671db52..a30a4ed8a 100644 --- a/repos/os/run/resource_yield.run +++ b/repos/os/run/resource_yield.run @@ -33,4 +33,4 @@ build_boot_image "core init timer test-resource_yield" append qemu_args "-nographic -m 96" -run_genode_until {--- test-resource_yield finished ---\s*\n} 50 +run_genode_until {--- test-resource_yield finished ---.*\n} 50 diff --git a/repos/os/src/app/cli_monitor/main.cc b/repos/os/src/app/cli_monitor/main.cc index 29801025e..c4f2536e5 100644 --- a/repos/os/src/app/cli_monitor/main.cc +++ b/repos/os/src/app/cli_monitor/main.cc @@ -89,7 +89,7 @@ static Subsystem_config_registry &subsystem_config_registry() } catch (Genode::Xml_node::Nonexistent_sub_node) { - PERR("missing '' configuration"); + Genode::error("missing '' configuration"); throw; } } diff --git a/repos/os/src/app/cli_monitor/spec/foc/arndale/extension.cc b/repos/os/src/app/cli_monitor/spec/foc/arndale/extension.cc index e3ff91dc9..5e42c858d 100644 --- a/repos/os/src/app/cli_monitor/spec/foc/arndale/extension.cc +++ b/repos/os/src/app/cli_monitor/spec/foc/arndale/extension.cc @@ -51,7 +51,7 @@ void init_extension(Command_registry &commands) static Regulator::Connection reg(Regulator::CLK_CPU); static Cpufreq_command cpufreq_command(reg); commands.insert(&cpufreq_command); - } catch (...) { PDBG("No regulator session available!"); }; + } catch (...) { Genode::warning("no regulator session available!"); }; static Kdebug_command kdebug_command; commands.insert(&kdebug_command); diff --git a/repos/os/src/app/cli_monitor/subsystem_config_registry.h b/repos/os/src/app/cli_monitor/subsystem_config_registry.h index 83bd5ccfa..e250eb038 100644 --- a/repos/os/src/app/cli_monitor/subsystem_config_registry.h +++ b/repos/os/src/app/cli_monitor/subsystem_config_registry.h @@ -73,6 +73,8 @@ class Subsystem_config_registry template void for_config(char const *name, FN const &fn) { + using Genode::error; + /* * Load subsystem configuration */ @@ -92,7 +94,7 @@ class Subsystem_config_registry Vfs::Vfs_handle::Guard handle_guard(handle); if (open_result != Vfs::Directory_service::OPEN_OK) { - PERR("could not open '%s', err=%d", path.base(), open_result); + error("could not open '", path, "', err=", (int)open_result); throw Nonexistent_subsystem_config(); } @@ -101,7 +103,7 @@ class Subsystem_config_registry handle->fs().read(handle, _config_buf, sizeof(_config_buf), out_count); if (read_result != Vfs::File_io_service::READ_OK) { - PERR("could not read '%s', err=%d", path.base(), read_result); + error("could not read '", path, "', err=", (int)read_result); throw Nonexistent_subsystem_config(); } @@ -110,11 +112,11 @@ class Subsystem_config_registry fn(subsystem_node); } catch (Genode::Xml_node::Invalid_syntax) { - PERR("subsystem configuration has invalid syntax"); + error("subsystem configuration has invalid syntax"); throw Nonexistent_subsystem_config(); } catch (Genode::Xml_node::Nonexistent_sub_node) { - PERR("invalid subsystem configuration"); + error("invalid subsystem configuration"); throw Nonexistent_subsystem_config(); } } @@ -125,6 +127,8 @@ class Subsystem_config_registry template void for_each_config(FN const &fn) { + using Genode::error; + /* iterate over the directory entries */ for (unsigned i = 0;; i++) { @@ -134,7 +138,7 @@ class Subsystem_config_registry _fs.dirent(_subsystems_path(), i, dirent); if (dirent_result != Vfs::Directory_service::DIRENT_OK) { - PERR("could not access directory '%s'", _subsystems_path()); + error("could not access directory '", _subsystems_path(), "'"); return; } diff --git a/repos/os/src/app/rom_logger/main.cc b/repos/os/src/app/rom_logger/main.cc index 604ecd953..98a91b025 100644 --- a/repos/os/src/app/rom_logger/main.cc +++ b/repos/os/src/app/rom_logger/main.cc @@ -69,7 +69,7 @@ void Rom_logger::Main::_handle_update(unsigned) rom_name = config()->xml_node().attribute_value("rom", rom_name); } catch (...) { - PWRN("could not determine ROM name from config"); + Genode::warning("could not determine ROM name from config"); return; } @@ -89,12 +89,12 @@ void Rom_logger::Main::_handle_update(unsigned) _rom_ds->update(); if (_rom_ds->valid()) { - PLOG("ROM '%s':", _rom_name.string()); + log("ROM '", _rom_name, "':"); Genode::print_lines<200>(_rom_ds->local_addr(), _rom_ds->size(), - [&] (char const *line) { PLOG(" %s", line); }); + [&] (char const *line) { Genode::log(" ", line); }); } else { - PLOG("ROM '%s' is invalid", _rom_name.string()); + Genode::log("ROM '", _rom_name, "' is invalid"); } } } diff --git a/repos/os/src/app/rom_to_file/main.cc b/repos/os/src/app/rom_to_file/main.cc index 57bf12287..5ae9b3147 100644 --- a/repos/os/src/app/rom_to_file/main.cc +++ b/repos/os/src/app/rom_to_file/main.cc @@ -89,7 +89,7 @@ void Rom_to_file::Main::_handle_update(unsigned) rom_name = config()->xml_node().attribute_value("rom", rom_name); } catch (...) { - PWRN("could not determine ROM name from config"); + warning("could not determine ROM name from config"); return; } @@ -127,31 +127,31 @@ void Rom_to_file::Main::_handle_update(unsigned) size_t written = write(_fs, handle, _rom_ds->local_addr(), len, 0); if (written < len) { - PWRN("%zu of %zu bytes have been written", written, len); + warning(written, " of ", len, " bytes have been written"); } _fs.close(handle); } catch (Permission_denied) { - PERR("%s%s: permission denied", dir_path, file_name); + error(Cstring(dir_path), file_name, ": permission denied"); } catch (No_space) { - PERR("file system out of space"); + error("file system out of space"); } catch (Out_of_metadata) { - PERR("server ran out of memory"); + error("server ran out of memory"); } catch (Invalid_name) { - PERR("%s%s: invalid path", dir_path, file_name); + error(Cstring(dir_path), file_name, ": invalid path"); } catch (Name_too_long) { - PERR("%s%s: name too long", dir_path, file_name); + error(Cstring(dir_path), file_name, ": name too long"); } catch (...) { - PERR("cannot open file %s%s", dir_path, file_name); + error("cannot open file ", Cstring(dir_path), file_name); throw; } } else { - PLOG("ROM '%s' is invalid", _rom_name.string()); + log("ROM '", _rom_name, "' is invalid"); } } } diff --git a/repos/os/src/app/status_bar/main.cc b/repos/os/src/app/status_bar/main.cc index 9b6d6869f..da5639b4f 100644 --- a/repos/os/src/app/status_bar/main.cc +++ b/repos/os/src/app/status_bar/main.cc @@ -40,7 +40,7 @@ static Genode::String read_string_attribute(Genode::Xml_node node, char const try { char buf[N]; node.attribute(attr).value(buf, sizeof(buf)); - return Genode::String(buf); + return Genode::String(Genode::Cstring(buf)); } catch (...) { return default_value; } @@ -131,7 +131,7 @@ void Status_bar_buffer::draw(Domain_name const &domain_name, Color color) { if (mode.format() != Framebuffer::Mode::RGB565) { - PERR("pixel format not supported"); + Genode::error("pixel format not supported"); return; } @@ -245,7 +245,7 @@ void Main::handle_focus(unsigned) color = node.attribute_value("color", Color(0, 0, 0)); } catch (...) { - PWRN("could not parse focus report"); } + Genode::warning("could not parse focus report"); } draw_status_bar(); } diff --git a/repos/os/src/app/trace_subject_reporter/main.cc b/repos/os/src/app/trace_subject_reporter/main.cc index eb27ff184..a8c593391 100644 --- a/repos/os/src/app/trace_subject_reporter/main.cc +++ b/repos/os/src/app/trace_subject_reporter/main.cc @@ -204,8 +204,9 @@ void Server::Main::handle_config(unsigned) report_affinity = config_report_attribute_enabled("affinity"); report_activity = config_report_attribute_enabled("activity"); - PINF("period_ms=%ld, report_activity=%d, report_affinity=%d", - period_ms, report_activity, report_affinity); + log("period_ms=", period_ms, ", " + "report_activity=", report_activity, ", " + "report_affinity=", report_affinity); timer.trigger_periodic(1000*period_ms); } diff --git a/repos/os/src/app/usb_report_filter/main.cc b/repos/os/src/app/usb_report_filter/main.cc index f9df0791a..54f98b77b 100644 --- a/repos/os/src/app/usb_report_filter/main.cc +++ b/repos/os/src/app/usb_report_filter/main.cc @@ -31,6 +31,9 @@ namespace Usb_filter { using Genode::Xml_generator; using Genode::Attached_rom_dataspace; using Genode::snprintf; + using Genode::error; + using Genode::log; + using Genode::warning; struct Device_registry; struct Main; @@ -155,7 +158,7 @@ class Usb_filter::Device_registry File_system::Dir_handle root_dir = _fs.dir("/", false); _file = _fs.file(root_dir, config_file, File_system::READ_WRITE, false); } catch (...) { - PERR("Could not open '%s'", config_file); + error("could not open '", config_file, "'"); return; } @@ -163,7 +166,7 @@ class Usb_filter::Device_registry size_t n = File_system::read(_fs, _file, old_file, sizeof(old_file)); if (n == 0) { - PERR("Could not read '%s'", config_file); + error("could not read '", config_file, "'"); return; } @@ -188,7 +191,7 @@ class Usb_filter::Device_registry }); if (!drv_config.has_sub_node("raw")) - PINF("enable raw support in usb_drv"); + log("enable raw support in usb_drv"); xml.node("raw", [&] { xml.node("report", [&] { @@ -211,11 +214,11 @@ class Usb_filter::Device_registry new_file[xml.used()] = 0; if (verbose) - PLOG("new usb_drv configuration:\n%s", new_file); + log("new usb_drv configuration:\n", Cstring(new_file)); n = File_system::write(_fs, _file, new_file, xml.used()); if (n == 0) - PERR("Could not write '%s'", config_file); + error("could not write '", config_file, "'"); _fs.close(_file); } @@ -230,7 +233,7 @@ class Usb_filter::Device_registry if (!_devices_rom.valid()) return; if (verbose) - PLOG("device report:\n%s", _devices_rom.local_addr()); + log("device report:\n", _devices_rom.local_addr()); Xml_node usb_devices(_devices_rom.local_addr(), _devices_rom.size()); @@ -240,7 +243,7 @@ class Usb_filter::Device_registry bool _check_config(Xml_node &drv_config) { if (!drv_config.has_sub_node("raw")) { - PERR("Could not access node"); + error("could not access node"); return false; } @@ -256,8 +259,9 @@ class Usb_filter::Device_registry }); if (verbose && !result) - PWRN("No matching policy was created for device %d-%d (%x:%x)", - entry.bus, entry.dev, entry.vendor, entry.product); + warning("No matching policy was created for " + "device ", entry.bus, "-", entry.dev, " " + "(", entry.vendor, ":", entry.product, ")"); }; _for_each_entry(check_policy); @@ -397,7 +401,7 @@ class Usb_filter::Device_registry try { config.sub_node("client").attribute("label").value(&_client_label); } catch (...) { - PERR("Could not update client label"); + error("could not update client label"); } } }; diff --git a/repos/os/src/drivers/acpi/acpi.cc b/repos/os/src/drivers/acpi/acpi.cc index 3c59118fd..22ee5e386 100644 --- a/repos/os/src/drivers/acpi/acpi.cc +++ b/repos/os/src/drivers/acpi/acpi.cc @@ -381,7 +381,8 @@ class Table_wrapper Apic_override *o = static_cast(apic); - PINF("MADT IRQ %u -> GSI %u flags: %x", o->irq, o->gsi, o->flags); + Genode::log("MADT IRQ ", o->irq, " -> GSI ", (unsigned)o->gsi, " " + "flags: ", (unsigned)o->flags); Irq_override::list()->insert(new (&alloc) Irq_override(o->irq, o->gsi, o->flags)); @@ -392,8 +393,10 @@ class Table_wrapper { Mcfg_struct *mcfg = _table->mcfg_struct(); for (; mcfg < _table->mcfg_end(); mcfg = mcfg->next()) { - PINF("MCFG BASE 0x%llx seg %02x bus %02x-%02x", mcfg->base, - mcfg->pci_seg, mcfg->pci_bus_start, mcfg->pci_bus_end); + Genode::log("MCFG BASE ", Genode::Hex(mcfg->base), " " + "seg ", Genode::Hex(mcfg->pci_seg), " " + "bus ", Genode::Hex(mcfg->pci_bus_start), "-", + Genode::Hex(mcfg->pci_bus_end)); /* bus_count * up to 32 devices * 8 function per device * 4k */ uint32_t bus_count = mcfg->pci_bus_end - mcfg->pci_bus_start + 1; @@ -408,12 +411,12 @@ class Table_wrapper void parse_dmar(Genode::Allocator &alloc) const { Dmar_struct_header *head = _table->dmar_header(); - PLOG("%u bit DMA physical addressable%s\n", head->width + 1, - head->flags & Dmar_struct_header::INTR_REMAP_MASK ? - " , IRQ remapping supported" : ""); + Genode::log(head->width + 1, " bit DMA physical addressable", + head->flags & Dmar_struct_header::INTR_REMAP_MASK ? + " , IRQ remapping supported" : ""); head->apply([&] (Dmar_common const &dmar) { - PLOG("DMA remapping structure type=%u", dmar.read()); + Genode::log("DMA remapping structure type=", dmar.read()); }); Dmar_entry::list()->insert(new (&alloc) Dmar_entry(head->clone(alloc))); @@ -435,10 +438,12 @@ class Table_wrapper memcpy(_name, _table->signature, 4); if (verbose) - PDBG("Table mapped '%s' at %p (from %lx) size %x", _name, _table, _base, _table->size); + Genode::log("table mapped '", Genode::Cstring(_name), "' at ", _table, " " + "(from ", Genode::Hex(_base), ") " + "size ", Genode::Hex(_table->size)); if (checksum((uint8_t *)_table, _table->size)) { - PERR("Checksum mismatch for %s", _name); + Genode::error("checksum mismatch for ", Genode::Cstring(_name)); throw -1; } } @@ -473,8 +478,19 @@ class Pci_routing : public List::Element uint32_t gsi() const { return _gsi; } uint32_t device() const { return _adr >> 16; } + void print(Genode::Output &out) const + { + Genode::print(out, "adr: ", Genode::Hex(_adr), " " + "pin: ", Genode::Hex(_pin), " " + "gsi: ", Genode::Hex(_gsi)); + } + /* debug */ - void dump() { if (verbose) PDBG("Pci: adr %x pin %x gsi: %u", _adr, _pin, _gsi); } + void dump() + { + if (verbose) + Genode::log("Pci: ", *this); + } }; @@ -667,7 +683,7 @@ class Element : public List::Element for (uint32_t p = 0; name[p] == PARENT_PREFIX; p++, parent_len -= NAME_LEN) ; if (_name_len + parent_len > sizeof(_name)) { - PERR("name is not large enough"); + Genode::error("name is not large enough"); throw -1; } @@ -804,7 +820,7 @@ class Element : public List::Element name[name_len] = 0; if (verbose) - PDBG("Indirect %s", name); + Genode::log("indirect ", Genode::Cstring(name)); for (uint32_t skip = 0; skip <= dev->_name_len / NAME_LEN; skip++) { Element *e = dev->_compare(name, skip * NAME_LEN); @@ -929,8 +945,9 @@ class Element : public List::Element char n[_name_len + 1]; memcpy(n, _name, _name_len); n[_name_len] = 0; - PDBG("Found package %x size %u name_len %u name: %s", - _data[0], _size, _name_len, n); + Genode::log("Found package ", Genode::Hex(_data[0]), " " + "size: ", _size, " name_len: ", _name_len, " " + "name: ", Genode::Cstring(n)); } public: @@ -988,7 +1005,7 @@ class Element : public List::Element } if (verbose) - PDBG("Freeing up memory of elements - %lu bytes", freed_up); + Genode::log("Freeing up memory of elements - ", freed_up, " bytes"); } /** @@ -1055,7 +1072,7 @@ class Element : public List::Element if (prt) { if (verbose) - PDBG("Scanning device %x", e->_bdf); + Genode::log("Scanning device ", Genode::Hex(e->_bdf)); prt->_direct_prt(alloc, e); prt->_indirect_prt(alloc, e); @@ -1079,8 +1096,10 @@ class Element : public List::Element Pci_routing *r = e->pci_list().first(); for (; r; r = r->next()) { if (r->match_bdf(device_bdf) && r->pin() == pin) { - if (verbose) PDBG("Found GSI: %u device : %x pin %u", - r->gsi(), device_bdf, pin); + if (verbose) + Genode::log("Found GSI: ", r->gsi(), " " + "device : ", Genode::Hex(device_bdf), " ", + "pin ", pin); return r->gsi(); } } @@ -1175,23 +1194,23 @@ class Acpi_table if (table.is_searched()) { if (verbose) - PDBG("Found %s", table.name()); + Genode::log("Found ", table.name()); Element::parse(alloc, table.table()); } if (table.is_madt()) { - PDBG("Found MADT"); + Genode::log("Found MADT"); table.parse_madt(alloc); } if (table.is_mcfg()) { - PDBG("Found MCFG"); + Genode::log("Found MCFG"); table.parse_mcfg(alloc); } if (table.is_dmar()) { - PDBG("Found DMAR"); + Genode::log("Found DMAR"); table.parse_dmar(alloc); } @@ -1201,7 +1220,7 @@ class Acpi_table Table_wrapper table(dsdt); if (table.is_searched()) { if (verbose) - PDBG("Found dsdt %s", table.name()); + Genode::log("Found dsdt ", table.name()); Element::parse(alloc, table.table()); } @@ -1236,7 +1255,7 @@ class Acpi_table if (!rsdp) { if (verbose) - PDBG("No rsdp structure found"); + Genode::log("No rsdp structure found"); return; } @@ -1244,8 +1263,10 @@ class Acpi_table uint8_t oem[7]; memcpy(oem, rsdp->oemid, 6); oem[6] = 0; - PDBG("ACPI revision %u of OEM '%s', rsdt:0x%x xsdt:0x%llx", - rsdp->revision, oem, rsdp->rsdt, rsdp->xsdt); + Genode::log("ACPI revision ", rsdp->revision, " of " + "OEM '", oem, "', " + "rsdt:", Genode::Hex(rsdp->rsdt), " " + "xsdt:", Genode::Hex(rsdp->xsdt)); } addr_t const rsdt = rsdp->rsdt; diff --git a/repos/os/src/drivers/acpi/memory.h b/repos/os/src/drivers/acpi/memory.h index 11ddead10..08cc804fb 100644 --- a/repos/os/src/drivers/acpi/memory.h +++ b/repos/os/src/drivers/acpi/memory.h @@ -67,8 +67,9 @@ class Acpi::Memory /* sanity check that physical address is in range we support */ if ((phys & _align_mask(ACPI_REGION_SIZE_LOG2)) != high) { - PERR("acpi table out of range - 0x%lx not in [0x%lx,0x%lx)", - phys, high, high + (1UL << ACPI_REGION_SIZE_LOG2) - 1); + addr_t const end = high + (1UL << ACPI_REGION_SIZE_LOG2) - 1; + error("acpi table out of range - ", Hex(phys), " " + "not in ", Hex_range(high, end - high)); throw -1; } diff --git a/repos/os/src/drivers/ahci/ahci.cc b/repos/os/src/drivers/ahci/ahci.cc index 76d852307..95a461abd 100644 --- a/repos/os/src/drivers/ahci/ahci.cc +++ b/repos/os/src/drivers/ahci/ahci.cc @@ -104,16 +104,21 @@ struct Ahci void info() { - PINF("\tversion: %x.%04x", hba.read(), - hba.read()); - PINF("\tcommand slots: %u", hba.command_slots()); - PINF("\tnative command queuing: %s", hba.ncq() ? "yes" : "no"); - PINF("\t64 bit support: %s", hba.supports_64bit() ? "yes" : "no"); + using Genode::log; + + log("version: " + "major=", Genode::Hex(hba.read()), " " + "minor=", Genode::Hex(hba.read())); + log("command slots: ", hba.command_slots()); + log("native command queuing: ", hba.ncq() ? "yes" : "no"); + log("64-bit support: ", hba.supports_64bit() ? "yes" : "no"); } void scan_ports(Genode::Region_map &rm) { - PINF("\tnumber of ports: %u pi: %x", hba.port_count(), hba.read()); + Genode::log("number of ports: ", hba.port_count(), " " + "pi: ", Genode::Hex(hba.read())); + unsigned available = hba.read(); for (unsigned i = 0; i < hba.port_count(); i++) { @@ -126,7 +131,7 @@ struct Ahci /* check for ATA/ATAPI devices */ unsigned sig = port.read(); if (!atapi(sig) && !ata(sig)) { - PINF("\t\t#%u: off", i); + Genode::log("\t\t#", i, ": off"); continue; } @@ -134,9 +139,9 @@ struct Ahci bool enabled = false; try { enabled = port.enable(); } - catch (Port::Not_ready) { PERR("Could not enable port %u", i); } + catch (Port::Not_ready) { Genode::error("could not enable port ", i); } - PINF("\t\t#%u: %s", i, atapi(sig) ? "ATAPI" : "ATA"); + Genode::log("\t\t#", i, ": ", atapi(sig) ? "ATAPI" : "ATA"); if (!enabled) continue; @@ -156,7 +161,7 @@ struct Ahci break; default: - PWRN("Device signature %x unsupported", sig); + Genode::warning("device signature ", Genode::Hex(sig), " unsupported"); } } }; diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index 1edf0385d..3505bca70 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -426,7 +427,7 @@ struct Port : Genode::Mmio { stop(); if (!wait_for(0, Hba::delayer(), 500, 1000)) - PERR("failed to stop command list processing"); + Genode::error("failed to stop command list processing"); } virtual ~Port() @@ -574,12 +575,12 @@ struct Port : Genode::Mmio return; if (!wait_for(0, hba.delayer(), 500, 1000)) { - PERR("HBA busy unable to start command processing."); + Genode::error("HBA busy unable to start command processing."); return; } if (!wait_for(0, hba.delayer(), 500, 1000)) { - PERR("HBA in DRQ unable to start command processing."); + Genode::error("HBA in DRQ unable to start command processing."); return; } @@ -675,14 +676,14 @@ struct Port : Genode::Mmio void reset() { if (read()) - PWRN("CMD.ST bit set during device reset --> unknown behavior"); + Genode::warning("CMD.ST bit set during device reset --> unknown behavior"); write(1); hba.delayer().usleep(1000); write(0); if (!wait_for(Ssts::Dec::ESTABLISHED, hba.delayer())) - PWRN("Port reset failed"); + Genode::warning("Port reset failed"); } /** @@ -813,13 +814,13 @@ struct Port_driver : Port, Block::Driver { /* max. PRDT size is 4MB */ if (count * block_size() > 4 * 1024 * 1024) { - PERR("error: maximum supported packet size is 4MB"); + Genode::error("error: maximum supported packet size is 4MB"); throw Io_error(); } /* sanity check */ if (block_number + count > block_count()) { - PERR("error: requested blocks are outside of device"); + Genode::error("error: requested blocks are outside of device"); throw Io_error(); } } diff --git a/repos/os/src/drivers/ahci/ata_driver.h b/repos/os/src/drivers/ahci/ata_driver.h index eeee45daf..8316fd880 100644 --- a/repos/os/src/drivers/ahci/ata_driver.h +++ b/repos/os/src/drivers/ahci/ata_driver.h @@ -58,20 +58,21 @@ struct Identity : Genode::Mmio void info() { - PLOG("\t\tqueue depth: %u ncq: %u", - read() + 1, - read()); - PLOG("\t\tnumer of sectors: %llu", read()); - PLOG("\t\tmultiple logical blocks per physical: %s", - read() ? "yes" : "no"); - PLOG("\t\tlogical blocks per physical: %u", - 1U << read()); - PLOG("\t\tlogical block size is above 512 byte: %s", - read() ? "yes" : "no"); - PLOG("\t\twords (16bit) per logical block: %u", - read()); - PLOG("\t\toffset of first logical block within physical: %u", - read()); + using Genode::log; + + log(" queue depth: ", read() + 1, " " + "ncq: ", read()); + log(" numer of sectors: ", read()); + log(" multiple logical blocks per physical: ", + read() ? "yes" : "no"); + log(" logical blocks per physical: ", + 1U << read()); + log(" logical block size is above 512 byte: ", + read() ? "yes" : "no"); + log(" words (16bit) per logical block: ", + read()); + log(" offset of first logical block within physical: ", + read()); } }; @@ -240,8 +241,11 @@ struct Ata_driver : Port_driver (end >= pending_start && end <= pending_end) || (pending_start >= block_number && pending_start <= end) || (pending_end >= block_number && pending_end <= end)) { - PWRN("Overlap: pending %llu + %zu, request: %llu + %zu", pending[slot].block_number(), - pending[slot].block_count(), block_number, count); + + Genode::warning("overlap: " + "pending ", pending[slot].block_number(), + " + ", pending[slot].block_count(), ", " + "request: ", block_number, " + ", count); throw Block::Driver::Request_congestion(); } } @@ -282,9 +286,6 @@ struct Ata_driver : Port_driver { Is::access_t status = Port::read(); - if (verbose) - PDBG("irq: %x state: %u", status, state); - switch (state) { case IDENTIFY: @@ -297,8 +298,8 @@ struct Ata_driver : Port_driver model.construct(*info); if (verbose) { - PLOG("\t\tmodel number: %s", model->buf); - PLOG("\t\tserial number: %s", serial->buf); + Genode::log(" model number: ", Genode::Cstring(model->buf)); + Genode::log(" serial number: ", Genode::Cstring(serial->buf)); info->info(); } diff --git a/repos/os/src/drivers/ahci/atapi_driver.h b/repos/os/src/drivers/ahci/atapi_driver.h index f2e8e2a7c..f792a9164 100644 --- a/repos/os/src/drivers/ahci/atapi_driver.h +++ b/repos/os/src/drivers/ahci/atapi_driver.h @@ -1,4 +1,4 @@ -/** +/* * \brief AHCI-port driver for ATAPI devices * \author Sebastian Sumpf * \date 2015-04-29 @@ -56,7 +56,7 @@ struct Atapi_driver : Port_driver state = STATUS; if (sense_tries++ >= 3) { - PERR("Could not power up device"); + Genode::error("could not power up device"); state_change(); return; } @@ -104,9 +104,14 @@ struct Atapi_driver : Port_driver Is::access_t status = Port::read(); if (verbose) { - PDBG("irq: is: %x ci: %x state: %u", status, Port::read(), state); + Genode::log("irq: " + "is: ", Genode::Hex(status), " " + "ci: ", Genode::Hex(Port::read()), " " + "state: ", (int)state); Device_fis f(fis_base); - PDBG("d2h: status: %x error: %x", f.read(), f.read()); + Genode::log("d2h: " + "status: ", f.read(), " " + "error: ", Genode::Hex(f.read())); } ack_irq(); @@ -184,7 +189,7 @@ struct Atapi_driver : Port_driver pending = packet; if (verbose) - PDBG("Add packet read %llu count %zu -> %u", block_number, count, 0); + Genode::log("add packet read ", block_number, " count ", count, " -> 0"); /* setup fis */ Command_table table(command_table_addr(0), phys, count * block_size()); diff --git a/repos/os/src/drivers/ahci/main.cc b/repos/os/src/drivers/ahci/main.cc index ca60e1bcd..557d30719 100644 --- a/repos/os/src/drivers/ahci/main.cc +++ b/repos/os/src/drivers/ahci/main.cc @@ -14,6 +14,7 @@ /* Genode includes */ #include #include +#include #include #include #include @@ -125,7 +126,7 @@ class Block::Root_multiple_clients : public Root_component< ::Session_component> if (num < 0) { error("rejecting session request, no matching policy for '", label, "'", model_buf[0] == 0 ? "" - : " (model=", (char const *)model_buf, " serial=", (char const *)sn_buf, ")"); + : " (model=", Cstring(model_buf), " serial=", Cstring(sn_buf), ")"); throw Root::Invalid_args(); } diff --git a/repos/os/src/drivers/ahci/spec/exynos5/platform.cc b/repos/os/src/drivers/ahci/spec/exynos5/platform.cc index 0e8314c63..79e4eddbd 100644 --- a/repos/os/src/drivers/ahci/spec/exynos5/platform.cc +++ b/repos/os/src/drivers/ahci/spec/exynos5/platform.cc @@ -1,4 +1,4 @@ -/** +/* * \brief Driver for Exynos-5250 soc * \author Martin Stein * \author Sebastian Sumpf @@ -92,7 +92,7 @@ struct I2c_interface : Attached_mmio if (read() && !read()) return 1; delayer.usleep(TX_DELAY_US); } - PERR("I2C ack not received"); + Genode::error("I2C ack not received"); return 0; } @@ -102,7 +102,7 @@ struct I2c_interface : Attached_mmio bool arbitration_error() { if (read()) { - PERR("I2C arbitration failed"); + Genode::error("I2C arbitration failed"); return 1; } return 0; @@ -121,7 +121,7 @@ struct I2c_interface : Attached_mmio { /* initiate message transfer */ if (!wait_for(0, delayer)) { - PERR("I2C busy"); + Genode::error("I2C busy"); return -1; } Stat::access_t stat = read(); @@ -148,7 +148,7 @@ struct I2c_interface : Attached_mmio write(0); /* FIXME fixup */ if (arbitration_error()) return -1; if (!wait_for(0, delayer)) { - PERR("I2C end transfer failed"); + Genode::error("I2C end transfer failed"); return -1; } return 0; @@ -189,7 +189,7 @@ struct I2c_sataphy : I2c_interface /* send messaage */ if (send(msg, MSG_SIZE)) return -1; - if (verbose) printf("SATA PHY 40-pin interface enabled\n"); + if (verbose) Genode::log("SATA PHY 40-pin interface enabled"); return 0; } @@ -302,11 +302,11 @@ struct Sata_phy_ctrl : Attached_mmio * in more depth. */ if (!wait_for(1, delayer)) { - PERR("PLL lock failed"); + Genode::error("PLL lock failed"); return -1; } if (verbose) - printf("SATA PHY initialized\n"); + Genode::log("SATA PHY initialized"); return 0; } @@ -341,7 +341,7 @@ struct Exynos5_hba : Platform::Hba /* reset */ hba.write< ::Hba::Ghc::Hr>(1); if (!hba.wait_for< ::Hba::Ghc::Hr>(0, ::Hba::delayer(), 1000, 1000)) { - PERR("HBA reset failed"); + Genode::error("HBA reset failed"); throw Root::Unavailable(); } diff --git a/repos/os/src/drivers/ahci/spec/x86/platform.cc b/repos/os/src/drivers/ahci/spec/x86/platform.cc index 587b509fb..45d34dd4a 100644 --- a/repos/os/src/drivers/ahci/spec/x86/platform.cc +++ b/repos/os/src/drivers/ahci/spec/x86/platform.cc @@ -1,4 +1,4 @@ -/** +/* * \brief Driver for PCI-bus platforms * \author Sebastian Sumpf * \date 2015-04-29 @@ -49,24 +49,22 @@ struct X86_hba : Platform::Hba [&] () { env.parent().upgrade(pci.cap(), "ram_quota=4096"); }); if (!pci_device_cap.valid()) { - PERR("No AHCI controller found"); + Genode::error("no AHCI controller found"); throw -1; } /* construct pci client */ pci_device.construct(pci_device_cap); - PINF("AHCI found (vendor: %04x device: %04x class:" - " %08x)\n", pci_device->vendor_id(), - pci_device->device_id(), pci_device->class_code()); + Genode::log("AHCI found (" + "vendor: ", pci_device->vendor_id(), " " + "device: ", pci_device->device_id(), " " + "class: ", pci_device->class_code(), ")"); /* read base address of controller */ Platform::Device::Resource resource = pci_device->resource(AHCI_BASE_ID); res_base = resource.base(); res_size = resource.size(); - if (verbose) - PDBG("base: %lx size: %zx", res_base, res_size); - /* enable bus master */ uint16_t cmd = pci_device->config_read(PCI_CMD, Platform::Device::ACCESS_16BIT); cmd |= 0x4; @@ -92,7 +90,7 @@ struct X86_hba : Platform::Hba if (msi & MSI_ENABLED) { _config_write(cap + 2, msi ^ MSI_CAP, Platform::Device::ACCESS_8BIT); - PINF("Disabled MSIs %x", msi); + Genode::log("disabled MSI ", msi); } } } diff --git a/repos/os/src/drivers/audio/spec/linux/main.cc b/repos/os/src/drivers/audio/spec/linux/main.cc index 8772613a8..8d06219d9 100644 --- a/repos/os/src/drivers/audio/spec/linux/main.cc +++ b/repos/os/src/drivers/audio/spec/linux/main.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -282,7 +283,7 @@ struct Audio_out::Main int err = audio_drv_init(dev); if (err) { if (err == -1) { - Genode::error("could not open ALSA device ", dev); + Genode::error("could not open ALSA device ", Genode::Cstring(dev)); } else { Genode::error("could not initialize driver error ", err); } diff --git a/repos/os/src/drivers/framebuffer/spec/exynos/driver.cc b/repos/os/src/drivers/framebuffer/spec/exynos/driver.cc index a0d4d8239..8404d4817 100644 --- a/repos/os/src/drivers/framebuffer/spec/exynos/driver.cc +++ b/repos/os/src/drivers/framebuffer/spec/exynos/driver.cc @@ -136,7 +136,7 @@ class I2c_interface : public Attached_mmio write(0); write(0); if (read()) { - PWRN("I2C got stuck after transfer, forcely terminate"); + warning("I2C got stuck after transfer, forcely terminate"); write(0); } } @@ -157,7 +157,7 @@ class I2c_interface : public Attached_mmio Start_msg::Addr::set(start, slave); Start_msg::Rx::set(start, !tx); if (!wait_for(0, *delayer())) { - PERR("I2C to busy to do transfer"); + error("I2C to busy to do transfer"); return -1; } /* enable signal receipt */ @@ -192,7 +192,7 @@ class I2c_interface : public Attached_mmio if (read() && !read()) return 1; delayer()->usleep(TX_DELAY_US); } - PERR("I2C ack not received"); + error("I2C ack not received"); return 0; } @@ -202,7 +202,7 @@ class I2c_interface : public Attached_mmio bool _arbitration_error() { if (read()) { - PERR("I2C arbitration failed"); + error("I2C arbitration failed"); return 1; } return 0; @@ -293,7 +293,7 @@ class I2c_interface : public Attached_mmio { /* check receive buffer and initialize message transfer */ if (!buf_size) { - PERR("zero-sized receive buffer"); + error("zero-sized receive buffer"); return -1; } if (_start_m_transfer(slave, 0)) return -1; @@ -483,7 +483,7 @@ class Video_mixer : public Attached_mmio write(4); break; default: - PERR("framebuffer format not supported"); + error("framebuffer format not supported"); return -1; } /* window measurements */ @@ -536,7 +536,7 @@ class Video_mixer : public Attached_mmio Cfg::Hd_mode::set(cfg, 1); break; default: - PERR("framebuffer height not supported"); + error("framebuffer height not supported"); return -1; } Cfg::Scan_mode::set(cfg, 1); /* progressive */ @@ -623,7 +623,7 @@ class I2c_hdmi : public I2c_interface cfg_size = sizeof(cfg_148_5)/sizeof(cfg_148_5[0]); break; default: - PERR("pixel clock not supported"); + error("pixel clock not supported"); return -1; } if (m_transmit(HDMI_PHY_SLAVE, cfg, cfg_size)) { return -1; } @@ -988,7 +988,7 @@ class Hdmi : public Attached_mmio aspect_ratio = _16_9; cea_video_mode = 16; } else { - PERR("resolution not supported"); + error("resolution not supported"); return -1; } /* set-up HDMI PHY */ @@ -1044,7 +1044,7 @@ class Hdmi : public Attached_mmio write(PIC_RATIO_16_9 | AVI_RATIO_SAME_AS_PIC); break; default: - PERR("aspect ratio not supported"); + error("aspect ratio not supported"); return -1; } write(cea_video_mode); @@ -1089,12 +1089,12 @@ class Hdmi : public Attached_mmio _setup_mode_16(); break; default: - PERR("mode not supported"); + error("mode not supported"); return -1; } /* wait for PHY PLLs to get steady */ if (!wait_for(1, *delayer(), 10)) { - PERR("HDMI PHY not ready"); + error("HDMI PHY not ready"); return -1; } /* turn on core and timing generator */ @@ -1128,7 +1128,7 @@ int Framebuffer::Driver::init_drv(size_t width, size_t height, Format format, if (_init_hdmi(fb_phys)) { return -1; } return 0; default: - PERR("output not supported"); + error("output not supported"); return -1; } } diff --git a/repos/os/src/drivers/framebuffer/spec/exynos/driver.h b/repos/os/src/drivers/framebuffer/spec/exynos/driver.h index a8698e63a..bce6efe85 100644 --- a/repos/os/src/drivers/framebuffer/spec/exynos/driver.h +++ b/repos/os/src/drivers/framebuffer/spec/exynos/driver.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include #include namespace Framebuffer @@ -78,7 +78,7 @@ class Framebuffer::Driver case FORMAT_RGB565: return 2; default: - PERR("unknown pixel format"); + error("unknown pixel format"); return 0; } } diff --git a/repos/os/src/drivers/framebuffer/spec/exynos/main.cc b/repos/os/src/drivers/framebuffer/spec/exynos/main.cc index bceaf8002..797e7fe69 100644 --- a/repos/os/src/drivers/framebuffer/spec/exynos/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/exynos/main.cc @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ class Framebuffer::Session_component _phys_base(Dataspace_client(_ds).phys_addr()) { if (driver.init_drv(width, height, _format, output, _phys_base)) { - PERR("Could not initialize display"); + error("could not initialize display"); struct Could_not_initialize_display : Exception { }; throw Could_not_initialize_display(); } @@ -137,7 +137,7 @@ struct Main } } catch (...) { - PDBG("using default configuration: HDMI@%dx%d", width, height); + log("using default configuration: HDMI@", width, "x", height); } /* let entrypoint serve the framebuffer session and root interfaces */ diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/driver.h b/repos/os/src/drivers/framebuffer/spec/imx53/driver.h index b58eecdb4..c43396230 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/driver.h +++ b/repos/os/src/drivers/framebuffer/spec/imx53/driver.h @@ -97,7 +97,7 @@ class Framebuffer::Driver _pwm.enable_display(); break; default: - PERR("Unknown board revision!"); + error("unknown board revision!"); return false; } return true; diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/main.cc b/repos/os/src/drivers/framebuffer/spec/imx53/main.cc index 27455e55c..a6fb1cb33 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/imx53/main.cc @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -80,7 +80,7 @@ class Framebuffer::Session_component : _ipu(driver.ipu()) { if (!driver.init(Dataspace_client(_fb_ds).phys_addr())) { - PERR("Could not initialize display"); + error("could not initialize display"); struct Could_not_initialize_display : Exception { }; throw Could_not_initialize_display(); } @@ -120,7 +120,7 @@ static bool config_attribute(const char *attr_name) int main(int, char **) { - Genode::printf("Starting i.MX53 framebuffer driver\n"); + Genode::log("--- i.MX53 framebuffer driver ---"); using namespace Framebuffer; diff --git a/repos/os/src/drivers/framebuffer/spec/omap4/driver.h b/repos/os/src/drivers/framebuffer/spec/omap4/driver.h index d4e00b479..89ed44ba6 100644 --- a/repos/os/src/drivers/framebuffer/spec/omap4/driver.h +++ b/repos/os/src/drivers/framebuffer/spec/omap4/driver.h @@ -153,17 +153,17 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base) _hdmi.write(0); if (!_hdmi.issue_pwr_pll_command(Hdmi::Pwr_ctrl::ALL_OFF, _delayer)) { - PERR("Powering off HDMI timed out\n"); + error("powering off HDMI timed out"); return false; } if (!_hdmi.issue_pwr_pll_command(Hdmi::Pwr_ctrl::BOTH_ON_ALL_CLKS, _delayer)) { - PERR("Powering on HDMI timed out\n"); + error("powering on HDMI timed out"); return false; } if (!_hdmi.reset_pll(_delayer)) { - PERR("Resetting HDMI PLL timed out\n"); + error("resetting HDMI PLL timed out"); return false; } @@ -182,12 +182,12 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base) _hdmi.write(0x35555); if (!_hdmi.pll_go(_delayer)) { - PERR("HDMI PLL GO timed out"); + error("HDMI PLL GO timed out"); return false; } if (!_hdmi.issue_pwr_phy_command(Hdmi::Pwr_ctrl::LDOON, _delayer)) { - PERR("HDMI Phy power on timed out"); + error("HDMI Phy power on timed out"); return false; } @@ -195,7 +195,7 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base) _hdmi.write(0xf0000000); if (!_hdmi.issue_pwr_phy_command(Hdmi::Pwr_ctrl::TXON, _delayer)) { - PERR("HDMI Txphy power on timed out"); + error("HDMI Txphy power on timed out"); return false; } @@ -246,7 +246,7 @@ bool Framebuffer::Driver::_init_hdmi(Framebuffer::addr_t phys_base) _dispc.write(1); if (!_dispc.wait_for(Dispc::Control1::Go_tv::HW_UPDATE_DONE, _delayer)) { - PERR("Go_tv timed out"); + error("Go_tv timed out"); return false; } @@ -272,7 +272,7 @@ bool Framebuffer::Driver::init(size_t width, size_t height, ret = _init_hdmi(phys_base); break; default: - PERR("Unknown output %d specified", output); + error("unknown output ", (int)output, " specified"); } return ret; } diff --git a/repos/os/src/drivers/framebuffer/spec/omap4/main.cc b/repos/os/src/drivers/framebuffer/spec/omap4/main.cc index 809e2bab3..a889ea842 100644 --- a/repos/os/src/drivers/framebuffer/spec/omap4/main.cc +++ b/repos/os/src/drivers/framebuffer/spec/omap4/main.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -101,7 +101,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object -static int verbose = 0; - namespace Gpio { class Odroid_x2_driver; } @@ -50,9 +48,7 @@ class Gpio::Odroid_x2_driver : public Driver handle_irq(); } - void handle_irq(){ - PDBG("IRQ\n"); - } + void handle_irq() { } Gpio::Reg *_gpio_reg(int gpio_pin) { @@ -67,7 +63,7 @@ class Gpio::Odroid_x2_driver : public Driver case 40 ... 46: return &_reg4; default: - PERR("no Gpio_bank for pin %d available", gpio_pin); + Genode::error("no Gpio_bank for pin ", gpio_pin, " available"); return 0; } } @@ -105,15 +101,6 @@ class Gpio::Odroid_x2_driver : public Driver Genode::off_t offset = _bank_offset[pos_gpio]; int gpio = gpio_pin - sum_gpio; - if ( verbose) { - PDBG("gpio=%d", gpio); - PDBG("gpio_pin=%d", gpio_pin); - PDBG("gpio_input=%d", input ? 0: 0x1); - PDBG("gpio_pos=%d", pos_gpio); - PDBG("gpio_sum=%d", sum_gpio); - PDBG("gpio_off_set=%d", (int)offset); - } - Reg* reg = _gpio_reg(gpio_pin); reg->set_direction(gpio, input, offset); } @@ -125,14 +112,6 @@ class Gpio::Odroid_x2_driver : public Driver Genode::off_t offset = _bank_offset[pos_gpio]; int gpio = gpio_pin - sum_gpio; - if ( verbose) { - PDBG("gpio=%d", gpio); - PDBG("gpio_pin=%d", gpio_pin); - PDBG("gpio_level=%d", level ? 0: 0x1); - PDBG("gpio_pos=%d", pos_gpio); - PDBG("gpio_sum=%d", sum_gpio); - PDBG("gpio_off_set=%d", (int)offset); - } Reg* reg = _gpio_reg(gpio_pin); reg->write_pin(gpio, level, offset); } @@ -143,13 +122,6 @@ class Gpio::Odroid_x2_driver : public Driver int sum_gpio = gpio_bank_index(gpio_pin, false); Genode::off_t offset = _bank_offset[pos_gpio]; int gpio = gpio_pin - sum_gpio; - if ( verbose) { - PDBG("gpio=%d", gpio); - PDBG("gpio_pin=%d", gpio_pin); - PDBG("gpio_pos=%d", pos_gpio); - PDBG("gpio_sum=%d", sum_gpio); - PDBG("gpio_off_set=%d", (int)offset); - } Reg* reg = _gpio_reg(gpio_pin); return reg->read_pin(gpio, offset) ; @@ -157,15 +129,13 @@ class Gpio::Odroid_x2_driver : public Driver } void debounce_enable(unsigned gpio, bool enable) { - PWRN("Not supported!"); } + Genode::warning("debounce_enable not supported!"); } void debounce_time(unsigned gpio, unsigned long us) { - PWRN("Not supported!"); } + Genode::warning("debounce_time not supported!"); } void falling_detect(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); - int pos_gpio = gpio_bank_index(gpio_pin, true); int sum_gpio = gpio_bank_index(gpio_pin, false); Genode::off_t offset = _irq_offset[pos_gpio]; @@ -177,8 +147,6 @@ class Gpio::Odroid_x2_driver : public Driver void rising_detect(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); - int pos_gpio = gpio_bank_index(gpio_pin, true); int sum_gpio = gpio_bank_index(gpio_pin, false); Genode::off_t offset = _irq_offset[pos_gpio]; @@ -191,7 +159,6 @@ class Gpio::Odroid_x2_driver : public Driver void high_detect(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); int pos_gpio = gpio_bank_index(gpio_pin, true); int sum_gpio = gpio_bank_index(gpio_pin, false); Genode::off_t offset = _irq_offset[pos_gpio]; @@ -204,8 +171,6 @@ class Gpio::Odroid_x2_driver : public Driver void low_detect(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); - int pos_gpio = gpio_bank_index(gpio_pin, true); int sum_gpio = gpio_bank_index(gpio_pin, false); Genode::off_t offset = _irq_offset[pos_gpio]; @@ -218,28 +183,23 @@ class Gpio::Odroid_x2_driver : public Driver void irq_enable(unsigned gpio_pin, bool enable) { - if (verbose) PDBG("gpio=%d enable=%d", gpio_pin, enable); _irq_enabled[gpio_pin] = enable; } void ack_irq(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); - _irq.ack_irq(); } void register_signal(unsigned gpio_pin, Genode::Signal_context_capability cap) { - if (verbose) PDBG("gpio=%d", gpio_pin); _sig_cap[gpio_pin] = cap; } void unregister_signal(unsigned gpio_pin) { - if (verbose) PDBG("gpio=%d", gpio_pin); Genode::Signal_context_capability cap; _sig_cap[gpio_pin] = cap; diff --git a/repos/os/src/drivers/gpio/spec/exynos4/main.cc b/repos/os/src/drivers/gpio/spec/exynos4/main.cc index c0a23f92f..194a59608 100644 --- a/repos/os/src/drivers/gpio/spec/exynos4/main.cc +++ b/repos/os/src/drivers/gpio/spec/exynos4/main.cc @@ -14,7 +14,8 @@ */ /* Genode includes */ -#include +#include +#include #include #include #include @@ -40,7 +41,7 @@ struct Main { using namespace Genode; - printf("--- Odroid_x2 gpio driver ---\n"); + log("--- Odroid_x2 gpio driver ---"); Gpio::process_config(driver); diff --git a/repos/os/src/drivers/gpio/spec/imx53/driver.h b/repos/os/src/drivers/gpio/spec/imx53/driver.h index 3177576fa..61fa94847 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/driver.h +++ b/repos/os/src/drivers/gpio/spec/imx53/driver.h @@ -27,8 +27,6 @@ /* local includes */ #include "gpio.h" -static int verbose = 0; - class Imx53_driver : public Gpio::Driver { @@ -154,7 +152,7 @@ class Imx53_driver : public Gpio::Driver return &_gpio_bank_6; } - PERR("no Gpio_bank for pin %d available", gpio); + Genode::error("no Gpio_bank for pin ", gpio, " available"); return 0; } @@ -199,8 +197,6 @@ class Imx53_driver : public Gpio::Driver void direction(unsigned gpio, bool input) { - if (verbose) PDBG("gpio=%d input=%d", gpio, input); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(input ? 0 : 1, _gpio_index(gpio)); @@ -208,8 +204,6 @@ class Imx53_driver : public Gpio::Driver void write(unsigned gpio, bool level) { - if (verbose) PDBG("gpio=%d level=%d", gpio, level); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(level ? 1 : 0, @@ -218,26 +212,22 @@ class Imx53_driver : public Gpio::Driver bool read(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); return gpio_reg->read(_gpio_index(gpio)); } void debounce_enable(unsigned gpio, bool enable) { - PWRN("Not supported!"); + Genode::warning("debounce enable not supported"); } void debounce_time(unsigned gpio, unsigned long us) { - PWRN("Not supported!"); + Genode::warning("debounce time not supported"); } void falling_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(Gpio_reg::Int_conf::FAL_EDGE, _gpio_index(gpio)); @@ -245,8 +235,6 @@ class Imx53_driver : public Gpio::Driver void rising_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(Gpio_reg::Int_conf::RIS_EDGE, _gpio_index(gpio)); @@ -254,8 +242,6 @@ class Imx53_driver : public Gpio::Driver void high_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(Gpio_reg::Int_conf::HIGH_LEVEL, _gpio_index(gpio)); @@ -263,8 +249,6 @@ class Imx53_driver : public Gpio::Driver void low_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(Gpio_reg::Int_conf::LOW_LEVEL, _gpio_index(gpio)); @@ -272,29 +256,21 @@ class Imx53_driver : public Gpio::Driver void irq_enable(unsigned gpio, bool enable) { - if (verbose) PDBG("gpio=%d enable=%d", gpio, enable); - _gpio_bank(gpio)->irq(_gpio_index(gpio), enable); } void ack_irq(unsigned gpio) { - if (verbose) PDBG("gpio=%d ack_irq", gpio); - _gpio_bank(gpio)->ack_irq(_gpio_index(gpio)); } void register_signal(unsigned gpio, Genode::Signal_context_capability cap) { - if (verbose) PDBG("gpio=%d", gpio); - _gpio_bank(gpio)->sigh(_gpio_index(gpio), cap); } void unregister_signal(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Genode::Signal_context_capability cap; _gpio_bank(gpio)->sigh(_gpio_index(gpio), cap); } diff --git a/repos/os/src/drivers/gpio/spec/imx53/main.cc b/repos/os/src/drivers/gpio/spec/imx53/main.cc index 45af0733f..ef781ba16 100644 --- a/repos/os/src/drivers/gpio/spec/imx53/main.cc +++ b/repos/os/src/drivers/gpio/spec/imx53/main.cc @@ -15,9 +15,9 @@ */ /* Genode includes */ -#include +#include +#include #include -#include #include #include #include @@ -42,7 +42,7 @@ struct Main { using namespace Genode; - printf("--- i.MX53 gpio driver ---\n"); + log("--- i.MX53 gpio driver ---"); Gpio::process_config(driver); diff --git a/repos/os/src/drivers/gpio/spec/omap4/driver.h b/repos/os/src/drivers/gpio/spec/omap4/driver.h index 4305d7b00..43bde9269 100644 --- a/repos/os/src/drivers/gpio/spec/omap4/driver.h +++ b/repos/os/src/drivers/gpio/spec/omap4/driver.h @@ -25,8 +25,6 @@ /* local includes */ #include "gpio.h" -static int verbose = 0; - class Omap4_driver : public Gpio::Driver { @@ -102,7 +100,7 @@ class Omap4_driver : public Gpio::Driver _irq_enabled[pin] = enable; } - void ack_irq(int pin) { PDBG("not implemented"); } + void ack_irq(int pin) { Genode::warning(__func__, " not implemented"); } void sigh(int pin, Genode::Signal_context_capability cap) { _sig_cap[pin] = cap; } @@ -134,7 +132,7 @@ class Omap4_driver : public Gpio::Driver return &_gpio_bank_5; } - PERR("no Gpio_bank for pin %d available", gpio); + Genode::error("no Gpio_bank for pin ", gpio, " available"); return 0; } @@ -155,14 +153,7 @@ class Omap4_driver : public Gpio::Driver Genode::Board_base::GPIO5_IRQ), _gpio_bank_5(_ep, Genode::Board_base::GPIO6_MMIO_BASE, Genode::Board_base::GPIO6_MMIO_SIZE, Genode::Board_base::GPIO6_IRQ) - { - for (int i = 0; i < MAX_BANKS; ++i) { - if (verbose) - PDBG("GPIO%d ctrl=%08x", - i+1, _gpio_bank(i << PIN_SHIFT)->regs()->read()); - } - } - + { } public: @@ -175,16 +166,12 @@ class Omap4_driver : public Gpio::Driver void direction(unsigned gpio, bool input) { - if (verbose) PDBG("gpio=%d input=%d", gpio, input); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(input ? 1 : 0, _gpio_index(gpio)); } void write(unsigned gpio, bool level) { - if (verbose) PDBG("gpio=%d level=%d", gpio, level); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); if (level) @@ -195,16 +182,12 @@ class Omap4_driver : public Gpio::Driver bool read(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); return gpio_reg->read(_gpio_index(gpio)); } void debounce_enable(unsigned gpio, bool enable) { - if (verbose) PDBG("gpio=%d enable=%d", gpio, enable); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write(enable ? 1 : 0, _gpio_index(gpio)); @@ -212,8 +195,6 @@ class Omap4_driver : public Gpio::Driver void debounce_time(unsigned gpio, unsigned long us) { - if (verbose) PDBG("gpio=%d us=%ld", gpio, us); - unsigned char debounce; if (us < 32) @@ -229,8 +210,6 @@ class Omap4_driver : public Gpio::Driver void falling_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write (0, _gpio_index(gpio)); gpio_reg->write (0, _gpio_index(gpio)); @@ -240,8 +219,6 @@ class Omap4_driver : public Gpio::Driver void rising_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write (0, _gpio_index(gpio)); gpio_reg->write (0, _gpio_index(gpio)); @@ -251,8 +228,6 @@ class Omap4_driver : public Gpio::Driver void high_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write (0, _gpio_index(gpio)); gpio_reg->write (1, _gpio_index(gpio)); @@ -262,8 +237,6 @@ class Omap4_driver : public Gpio::Driver void low_detect(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Gpio_reg *gpio_reg = _gpio_bank(gpio)->regs(); gpio_reg->write (1, _gpio_index(gpio)); gpio_reg->write (0, _gpio_index(gpio)); @@ -273,29 +246,21 @@ class Omap4_driver : public Gpio::Driver void irq_enable(unsigned gpio, bool enable) { - if (verbose) PDBG("gpio=%d enable=%d", gpio, enable); - _gpio_bank(gpio)->irq(_gpio_index(gpio), enable); } void ack_irq(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - _gpio_bank(gpio)->ack_irq(_gpio_index(gpio)); } void register_signal(unsigned gpio, Genode::Signal_context_capability cap) { - if (verbose) PDBG("gpio=%d", gpio); - _gpio_bank(gpio)->sigh(_gpio_index(gpio), cap); } void unregister_signal(unsigned gpio) { - if (verbose) PDBG("gpio=%d", gpio); - Genode::Signal_context_capability cap; _gpio_bank(gpio)->sigh(_gpio_index(gpio), cap); } diff --git a/repos/os/src/drivers/gpio/spec/omap4/main.cc b/repos/os/src/drivers/gpio/spec/omap4/main.cc index 1b4bf6c98..ba247c1aa 100644 --- a/repos/os/src/drivers/gpio/spec/omap4/main.cc +++ b/repos/os/src/drivers/gpio/spec/omap4/main.cc @@ -14,7 +14,8 @@ */ /* Genode includes */ -#include +#include +#include #include #include #include @@ -41,7 +42,7 @@ struct Main { using namespace Genode; - printf("--- omap4 gpio driver ---\n"); + log("--- omap4 gpio driver ---"); Gpio::process_config(driver); diff --git a/repos/os/src/drivers/gpio/spec/rpi/driver.h b/repos/os/src/drivers/gpio/spec/rpi/driver.h index 533e752ce..12be4599a 100644 --- a/repos/os/src/drivers/gpio/spec/rpi/driver.h +++ b/repos/os/src/drivers/gpio/spec/rpi/driver.h @@ -18,7 +18,7 @@ #define _DRIVERS__GPIO__SPEC__RPI__DRIVER_H_ /* Genode includes */ -#include +#include #include #include #include @@ -67,7 +67,7 @@ class Gpio::Rpi_driver : public Driver } void _invalid_gpio(unsigned gpio) { - PERR("invalid GPIO pin number %u", gpio); } + Genode::error("invalid GPIO pin number ", gpio); } public: @@ -75,7 +75,8 @@ class Gpio::Rpi_driver : public Driver void set_func(unsigned gpio, Reg::Function function) { - if (verbose) PDBG("gpio=%d function=%d", gpio, function); + if (verbose) + Genode::log("set_func: gpio=", gpio, " function=", (int)function); _reg.set_gpio_function(gpio, function); } @@ -92,7 +93,10 @@ class Gpio::Rpi_driver : public Driver void direction(unsigned gpio, bool input) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d input=%d", gpio, input); + + if (verbose) + Genode::log("direction: gpio=", gpio, " input=", input); + Reg::Function f = input ? Reg::FSEL_INPUT : Reg::FSEL_OUTPUT; _reg.set_gpio_function(gpio, f); } @@ -100,10 +104,12 @@ class Gpio::Rpi_driver : public Driver void write(unsigned gpio, bool level) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d level=%d", gpio, level); + + if (verbose) + Genode::log("write: gpio=", gpio, " level=", level); if (_reg.get_gpio_function(gpio)!=Reg::FSEL_OUTPUT) - PWRN("GPIO pin (%d) is not configured for output.", gpio); + warning("GPIO pin ", gpio, " is not configured for output"); if (level) _reg.set_gpio_level(gpio); @@ -115,18 +121,22 @@ class Gpio::Rpi_driver : public Driver { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return 0; } if(_reg.get_gpio_function(gpio) != Reg::FSEL_INPUT) - PWRN("GPIO pin (%d) is not configured for input.", gpio); + warning("GPIO pin ", gpio, " is not configured for input"); return _reg.get_gpio_level(gpio); } - void debounce_enable(unsigned, bool) { PWRN("Not supported!"); } - void debounce_time(unsigned, unsigned long) { PWRN("Not supported!"); } + void debounce_enable(unsigned, bool) { + Genode::warning("debounce_enable not supported!"); } + + void debounce_time(unsigned, unsigned long) { + Genode::warning("debounce_time not supported!"); } void falling_detect(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + + if (verbose) Genode::log("falling_detect: gpio=", gpio); if(_async) _reg.set_gpio_async_falling_detect(gpio); @@ -137,7 +147,8 @@ class Gpio::Rpi_driver : public Driver void rising_detect(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + + if (verbose) Genode::log("rising_detect: gpio=", gpio); if(_async) _reg.set_gpio_async_rising_detect(gpio); @@ -148,7 +159,7 @@ class Gpio::Rpi_driver : public Driver void high_detect(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + if (verbose) Genode::log("high_detect: gpio=", gpio); _reg.set_gpio_high_detect(gpio); } @@ -156,7 +167,7 @@ class Gpio::Rpi_driver : public Driver void low_detect(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + if (verbose) Genode::log("low_detect: gpio=", gpio); _reg.set_gpio_low_detect(gpio); } @@ -164,7 +175,7 @@ class Gpio::Rpi_driver : public Driver void irq_enable(unsigned gpio, bool enable) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d enable=%d", gpio, enable); + if (verbose) Genode::log("irq_enable: gpio=", gpio, " enable=", enable); _irq_enabled[gpio] = enable; } @@ -172,7 +183,7 @@ class Gpio::Rpi_driver : public Driver void ack_irq(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + if (verbose) Genode::log("ack_irq: gpio=", gpio); _reg.clear_event(gpio); _irq.ack_irq(); @@ -182,7 +193,7 @@ class Gpio::Rpi_driver : public Driver Genode::Signal_context_capability cap) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + if (verbose) Genode::log("register_signal: gpio=", gpio); _sig_cap[gpio] = cap; } @@ -190,7 +201,7 @@ class Gpio::Rpi_driver : public Driver void unregister_signal(unsigned gpio) { if (!gpio_valid(gpio)) { _invalid_gpio(gpio); return; } - if (verbose) PDBG("gpio=%d", gpio); + if (verbose) Genode::log("unregister_signal: gpio=", gpio); Genode::Signal_context_capability cap; _sig_cap[gpio] = cap; diff --git a/repos/os/src/drivers/gpio/spec/rpi/main.cc b/repos/os/src/drivers/gpio/spec/rpi/main.cc index 29956ee17..1fc751d68 100644 --- a/repos/os/src/drivers/gpio/spec/rpi/main.cc +++ b/repos/os/src/drivers/gpio/spec/rpi/main.cc @@ -14,7 +14,8 @@ */ /* Genode includes */ -#include +#include +#include #include #include #include @@ -39,7 +40,7 @@ struct Main root(&ep.rpc_ep(), &sliced_heap, driver) { using namespace Genode; - printf("--- RaspberryPI gpio driver ---\n"); + log("--- Raspberry Pi GPIO driver ---"); /* * Check configuration for async events detect @@ -76,14 +77,14 @@ struct Main case 3: driver.set_func(num, Gpio::Reg::FSEL_ALT3); break; case 4: driver.set_func(num, Gpio::Reg::FSEL_ALT4); break; case 5: driver.set_func(num, Gpio::Reg::FSEL_ALT5); break; - default: PWRN("Wrong pin function. Ignore node."); + default: warning("wrong pin function, ignore node"); } } catch(Xml_node::Nonexistent_attribute) { - PWRN("Missing attribute. Ignore node."); + warning("missing attribute, ignore node"); } if (gpio_node.last("gpio")) break; } - } catch (Xml_node::Nonexistent_sub_node) { PWRN("No GPIO config"); } + } catch (Xml_node::Nonexistent_sub_node) { warning("no GPIO config"); } /* * Announce service diff --git a/repos/os/src/drivers/input/dummy/main.cc b/repos/os/src/drivers/input/dummy/main.cc index 4e7b07294..a1c5d498d 100644 --- a/repos/os/src/drivers/input/dummy/main.cc +++ b/repos/os/src/drivers/input/dummy/main.cc @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include using namespace Genode; @@ -83,7 +83,7 @@ struct Main /* create dataspace for event buffer that is shared with the client */ try { ev_ds_cap = env()->ram_session()->alloc(MAX_EVENTS*sizeof(Input::Event)); } catch (Ram_session::Alloc_failed) { - PERR("Could not allocate dataspace for event buffer"); + Genode::error("could not allocate dataspace for event buffer"); throw Genode::Exception(); } diff --git a/repos/os/src/drivers/input/spec/ps2/ps2_keyboard.h b/repos/os/src/drivers/input/spec/ps2/ps2_keyboard.h index 5cb9c08f5..b40673083 100644 --- a/repos/os/src/drivers/input/spec/ps2/ps2_keyboard.h +++ b/repos/os/src/drivers/input/spec/ps2/ps2_keyboard.h @@ -14,7 +14,7 @@ #ifndef _DRIVERS__INPUT__SPEC__PS2__PS2_KEYBOARD_H_ #define _DRIVERS__INPUT__SPEC__PS2__PS2_KEYBOARD_H_ -#include +#include #include #include @@ -124,7 +124,7 @@ class Ps2_keyboard : public Input_driver void process(unsigned char v, bool verbose_scan_codes) { if (verbose_scan_codes) - PLOG("process %02x scan code set 1", v); + Genode::log("process ", Genode::Hex(v), " scan code set 1"); switch (_state) { @@ -257,7 +257,7 @@ class Ps2_keyboard : public Input_driver void process(unsigned char v, bool verbose_scan_codes) { if (verbose_scan_codes) - PLOG("process %02x scan code set 2", v); + Genode::log("process ", Genode::Hex(v), " scan code set 2"); enum { EXTENDED_KEY_PREFIX = 0xe0, @@ -378,10 +378,10 @@ class Ps2_keyboard : public Input_driver /* prepare state machine for processing the first packet */ _state_machine->reset(); - Genode::printf("Using keyboard with scan code set %s.\n", - _state_machine == &_scan_code_set_1_state_machine - ? _xlate_mode ? "1 (xlate)" : "1" - : "2"); + Genode::log("Using keyboard with scan code set ", + _state_machine == &_scan_code_set_1_state_machine + ? _xlate_mode ? "1 (xlate)" : "1" + : "2"); } void reset() @@ -399,12 +399,12 @@ class Ps2_keyboard : public Input_driver /* try to enable scan-code set 2 */ _kbd.write(0xf0); if (_kbd.read() != ACK) { - PWRN("Scan code setting not supported"); + Genode::warning("scan code setting not supported"); return; } _kbd.write(SCAN_CODE_SET_2); if (_kbd.read() != ACK) { - PWRN("Scan code 2 not supported"); + Genode::warning("scan code 2 not supported"); return; } @@ -443,11 +443,11 @@ class Ps2_keyboard : public Input_driver _key_state[key_code] = _state_machine->press(); if (_verbose) - PLOG("post %s, key_code = %d\n", - press ? "PRESS" : "RELEASE", key_code); + Genode::log("post ", press ? "PRESS" : "RELEASE", ", " + "key_code = ", key_code); if (_ev_queue.avail_capacity() == 0) { - PWRN("event queue overflow - dropping events"); + Genode::warning("event queue overflow - dropping events"); _ev_queue.reset(); } diff --git a/repos/os/src/drivers/input/spec/ps2/x86/i8042.h b/repos/os/src/drivers/input/spec/ps2/x86/i8042.h index 155912093..518d28bbd 100644 --- a/repos/os/src/drivers/input/spec/ps2/x86/i8042.h +++ b/repos/os/src/drivers/input/spec/ps2/x86/i8042.h @@ -133,7 +133,7 @@ class I8042 * functions). */ if (attempts == 0) { - PERR("Failed to read from port"); + Genode::error("failed to read from port"); return 0; } @@ -209,7 +209,7 @@ class I8042 attempts--; if (attempts == 0) { - PERR("No data available"); + Genode::error("no data available"); return RET_INVALID; } @@ -279,19 +279,19 @@ class I8042 /* run self tests */ _command(CMD_TEST); if ((ret = _wait_data()) != RET_TEST_OK) { - Genode::printf("i8042: self test failed (%x)\n", ret); + Genode::log("i8042: self test failed (", Genode::Hex(ret), ")"); return; } _command(CMD_KBD_TEST); if ((ret = _wait_data()) != RET_KBD_TEST_OK) { - Genode::printf("i8042: kbd test failed (%x)\n", ret); + Genode::log("i8042: kbd test failed (", Genode::Hex(ret), ")"); return; } _command(CMD_AUX_TEST); if ((ret = _wait_data()) != RET_AUX_TEST_OK) { - Genode::printf("i8042: aux test failed (%x)\n", ret); + Genode::log("I8042: aux test failed (", Genode::Hex(ret), ")"); return; } diff --git a/repos/os/src/drivers/nic/gem/main.cc b/repos/os/src/drivers/nic/gem/main.cc index f099f8489..6aa16cf3a 100644 --- a/repos/os/src/drivers/nic/gem/main.cc +++ b/repos/os/src/drivers/nic/gem/main.cc @@ -45,13 +45,7 @@ class Gem_session_component try { Genode::Xml_node nic_config = Genode::config()->xml_node().sub_node("nic"); nic_config.attribute("mac").value(&mac_addr); - PINF("Using configured MAC address \"%02x:%02x:%02x:%02x:%02x:%02x\"", - mac_addr.addr[0], - mac_addr.addr[1], - mac_addr.addr[2], - mac_addr.addr[3], - mac_addr.addr[4], - mac_addr.addr[5] ); + Genode::log("Using configured MAC address ", mac_addr); } catch (...) { /* fall back to fake MAC address (unicast, locally managed) */ mac_addr.addr[0] = 0x02; diff --git a/repos/os/src/drivers/nic/gem/marvell_phy.h b/repos/os/src/drivers/nic/gem/marvell_phy.h index 202214a5a..e0b30f1b6 100644 --- a/repos/os/src/drivers/nic/gem/marvell_phy.h +++ b/repos/os/src/drivers/nic/gem/marvell_phy.h @@ -255,15 +255,15 @@ namespace Genode Bmsr::Full_10::get(phyreg) && Bmsr::Anegcapable::get(phyreg)) { /* Found a valid PHY address */ - PDBG("Default phy address %d is valid\n", _phyaddr); + log("default phy address ", (int)_phyaddr, " is valid"); return; } else { - PDBG("PHY address is not setup correctly %d\n", _phyaddr); + log("PHY address is not setup correctly ", (int)_phyaddr); _phyaddr = -1; } } - PDBG("detecting phy address\n"); + log("detecting phy address"); if (_phyaddr == -1) { /* detect the PHY address */ for (int i = 31; i >= 0; i--) { @@ -273,12 +273,12 @@ namespace Genode Bmsr::Full_10::get(phyreg) && Bmsr::Anegcapable::get(phyreg)) { /* Found a valid PHY address */ - PDBG("Found valid phy address, %d\n", i); + log("found valid phy address, ", i); return; } } } - PDBG("PHY is not detected\n"); + warning("PHY is not detected"); _phyaddr = -1; } @@ -336,7 +336,7 @@ namespace Genode return result; if (result == 0) { - PDBG("Config not changed"); + log("config not changed"); /* Advertisment hasn't changed, but maybe aneg was never on to * begin with? Or maybe phy was isolated? */ uint16_t ctl = phy_read(); @@ -344,7 +344,7 @@ namespace Genode if (!Bmcr::Anenable::get(ctl) || Bmcr::Isolate::get(ctl)) result = 1; /* do restart aneg */ } else { - PDBG("Config changed"); + log("config changed"); } /* Only restart aneg if we are advertising something different @@ -431,7 +431,7 @@ namespace Genode } if (phy_read()) { - PWRN("PHY reset timed out\n"); + warning("PHY reset timed out"); throw Phy_timeout_after_reset(); } @@ -470,13 +470,13 @@ namespace Genode if ( Bmsr::Anegcapable::get(mii_reg) && !Bmsr::Anegcomplete::get(mii_reg) ) { int i = 0; - Genode::printf("Waiting for PHY auto negotiation to complete"); + Genode::log("waiting for PHY auto negotiation to complete"); while (!Bmsr::Anegcomplete::get(mii_reg)) { /* * Timeout reached ? */ if (i > PHY_AUTONEGOTIATE_TIMEOUT) { - PWRN(" TIMEOUT !\n"); + warning(" TIMEOUT !"); _link_up = false; return 0; } @@ -487,7 +487,7 @@ namespace Genode mii_reg = phy_read(); } - Genode::printf(" done\n"); + Genode::log(" done"); _link_up = true; } else { /* Read the link a second time to clear the latched state */ @@ -514,11 +514,11 @@ namespace Genode !Phy_stat::Spddone::get(stat)) { int i = 0; - PDBG("Waiting for PHY realtime link"); + log("waiting for PHY realtime link"); while (!phy_read()) { /* Timeout reached ? */ if (i > PHY_AUTONEGOTIATE_TIMEOUT) { - PWRN(" TIMEOUT !"); + warning(" TIMEOUT !"); _link_up = false; break; } @@ -527,7 +527,7 @@ namespace Genode Genode::printf("."); _timer.msleep(1); } - PINF(" done"); + log(" done"); _timer.msleep(500); } else { if (Phy_stat::Link::get(stat)) @@ -562,7 +562,7 @@ namespace Genode phy_detection(); uint32_t phy_id = get_phy_id(); - PDBG("The found phy has the id %08x", phy_id); + log("the found phy has the id ", Hex(phy_id)); phy_reset(); m88e1310_config(); diff --git a/repos/os/src/drivers/nic/gem/rx_buffer_descriptor.h b/repos/os/src/drivers/nic/gem/rx_buffer_descriptor.h index 4758b2d5c..590aeffa1 100644 --- a/repos/os/src/drivers/nic/gem/rx_buffer_descriptor.h +++ b/repos/os/src/drivers/nic/gem/rx_buffer_descriptor.h @@ -93,7 +93,7 @@ class Rx_buffer_descriptor : public Buffer_descriptor const Status::access_t status = _current_descriptor().status; if (!Status::Start_of_frame::get(status) || !Status::End_of_frame::get(status)) { - PWRN("Package splitted over more than one descriptor. Package ignored!"); + warning("Package splitted over more than one descriptor. Package ignored!"); _set_package_processed(); return 0; @@ -101,7 +101,7 @@ class Rx_buffer_descriptor : public Buffer_descriptor const size_t length = Status::Length::get(status); if (length > max_length) { - PWRN("Buffer for received package to small. Package ignored!"); + warning("Buffer for received package to small. Package ignored!"); _set_package_processed(); return 0; @@ -120,11 +120,11 @@ class Rx_buffer_descriptor : public Buffer_descriptor { static unsigned int old_data[0x1F]; - PDBG("Rx buffer:"); + log("Rx buffer:"); const unsigned int* const cur_data = local_addr(); for (unsigned i=0; i %08x", i*4, old_data[i], cur_data[i]); + log(i*4, ": ", Hex(old_data[i]), " -> ", Hex(cur_data[i])); } } memcpy(old_data, cur_data, sizeof(old_data)); diff --git a/repos/os/src/drivers/nic/spec/lan9118/lan9118.h b/repos/os/src/drivers/nic/spec/lan9118/lan9118.h index c6b0188c9..22c6575ca 100644 --- a/repos/os/src/drivers/nic/spec/lan9118/lan9118.h +++ b/repos/os/src/drivers/nic/spec/lan9118/lan9118.h @@ -14,7 +14,7 @@ #ifndef _DRIVERS__NIC__SPEC__LAN9118__LAN9118_H_ #define _DRIVERS__NIC__SPEC__LAN9118__LAN9118_H_ -#include +#include #include #include #include @@ -120,7 +120,7 @@ class Lan9118 : public Nic::Session_component, _timer.msleep(10); } - PERR("timeout while waiting for completeness of MAC CSR access"); + Genode::error("timeout while waiting for completeness of MAC CSR access"); } /** @@ -200,7 +200,7 @@ class Lan9118 : public Nic::Session_component, Genode::Packet_descriptor packet = _tx.sink()->get_packet(); if (!packet.size()) { - PWRN("Invalid tx packet"); + Genode::warning("Invalid tx packet"); return true; } @@ -208,7 +208,8 @@ class Lan9118 : public Nic::Session_component, enum { MAX_PACKET_SIZE_LOG2 = 11 }; Genode::size_t const max_size = (1 << MAX_PACKET_SIZE_LOG2) - 1; if (packet.size() > max_size) { - PERR("packet size %zd too large, limit is %zd", packet.size(), max_size); + Genode::error("packet size ", packet.size(), " too large, " + "limit is ", max_size); return true; } @@ -224,7 +225,7 @@ class Lan9118 : public Nic::Session_component, /* check space left in tx data fifo */ Genode::size_t const fifo_avail = _reg_read(TX_FIFO_INF) & 0xffff; if (fifo_avail < count*4 + sizeof(cmd_a) + sizeof(cmd_b)) { - PERR("tx fifo overrun, ignore packet"); + Genode::error("tx fifo overrun, ignore packet"); _tx.sink()->acknowledge_packet(packet); return false; } @@ -275,23 +276,25 @@ class Lan9118 : public Nic::Session_component, unsigned long const id_rev = _reg_read(ID_REV), byte_order = _reg_read(BYTE_TEST); - PINF("id/rev: 0x%lx", id_rev); - PINF("byte order: 0x%lx", byte_order); + using namespace Genode; + + log("id/rev: ", Hex(id_rev)); + log("byte order: ", Hex(byte_order)); enum { EXPECTED_BYTE_ORDER = 0x87654321 }; if (byte_order != EXPECTED_BYTE_ORDER) { - PERR("invalid byte order, expected 0x%x", EXPECTED_BYTE_ORDER); + error("invalid byte order, expected ", Hex(EXPECTED_BYTE_ORDER)); throw Device_not_supported(); } enum { EXPECTED_ID = 0x01180000 }; if ((id_rev & 0xffff0000) != EXPECTED_ID) { - PERR("device ID not supported, expected 0x%x", EXPECTED_ID); + error("device ID not supported, expected ", Hex(EXPECTED_ID)); throw Device_not_supported(); } if (!_soft_reset()) { - PERR("soft reset timed out"); + error("soft reset timed out"); throw Device_not_supported(); } @@ -306,9 +309,7 @@ class Lan9118 : public Nic::Session_component, _mac_addr.addr[1] = (mac_addr_lo >> 8) & 0xff; _mac_addr.addr[0] = (mac_addr_lo >> 0) & 0xff; - PINF("MAC address: %02x:%02x:%02x:%02x:%02x:%02x", - _mac_addr.addr[5], _mac_addr.addr[4], _mac_addr.addr[3], - _mac_addr.addr[2], _mac_addr.addr[1], _mac_addr.addr[0]); + log("MAC address: ", _mac_addr); /* configure MAC */ enum { MAC_CR_TXEN = (1 << 3), @@ -343,7 +344,8 @@ class Lan9118 : public Nic::Session_component, */ ~Lan9118() { - PINF("disable NIC"); + Genode::log("disable NIC"); + /* disable transmitter */ _reg_write(TX_CFG, 0); diff --git a/repos/os/src/drivers/nic/spec/lan9118/main.cc b/repos/os/src/drivers/nic/spec/lan9118/main.cc index 2a5c428ed..0e653d05b 100644 --- a/repos/os/src/drivers/nic/spec/lan9118/main.cc +++ b/repos/os/src/drivers/nic/spec/lan9118/main.cc @@ -56,8 +56,8 @@ class Root : public Genode::Root_component */ if (tx_buf_size + rx_buf_size < tx_buf_size || tx_buf_size + rx_buf_size > ram_quota - session_size) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, tx_buf_size + rx_buf_size + session_size); + error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); } @@ -84,7 +84,7 @@ struct Server::Main Main(Entrypoint &ep) : ep(ep) { - printf("--- LAN9118 NIC driver started ---\n"); + log("--- LAN9118 NIC driver started ---"); Genode::env()->parent()->announce(ep.manage(nic_root)); } }; diff --git a/repos/os/src/drivers/nic/spec/linux/main.cc b/repos/os/src/drivers/nic/spec/linux/main.cc index 3dd7cb3c4..13a801f1d 100644 --- a/repos/os/src/drivers/nic/spec/linux/main.cc +++ b/repos/os/src/drivers/nic/spec/linux/main.cc @@ -25,6 +25,7 @@ /* Genode */ #include +#include #include #include #include @@ -81,14 +82,14 @@ class Linux_session_component : public Nic::Session_component int fd = open("/dev/net/tun", O_RDWR); if (fd < 0) { - PERR("could not open /dev/net/tun: no virtual network emulation"); + Genode::error("could not open /dev/net/tun: no virtual network emulation"); /* this error is fatal */ throw Genode::Exception(); } /* set fd to non-blocking */ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { - PERR("could not set /dev/net/tun to non-blocking"); + Genode::error("could not set /dev/net/tun to non-blocking"); throw Genode::Exception(); } @@ -99,16 +100,16 @@ class Linux_session_component : public Nic::Session_component try { Genode::Xml_node nic_node = Genode::config()->xml_node().sub_node("nic"); nic_node.attribute("tap").value(ifr.ifr_name, sizeof(ifr.ifr_name)); - PINF("Using tap device \"%s\"", ifr.ifr_name); + Genode::log("using tap device \"", Genode::Cstring(ifr.ifr_name), "\""); } catch (...) { /* use tap0 if no config has been provided */ Genode::strncpy(ifr.ifr_name, "tap0", sizeof(ifr.ifr_name)); - PINF("No config provided, using tap0"); + Genode::log("no config provided, using tap0"); } ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { - PERR("could not configure /dev/net/tun: no virtual network emulation"); + Genode::error("could not configure /dev/net/tun: no virtual network emulation"); close(fd); /* this error is fatal */ throw Genode::Exception(); @@ -129,7 +130,7 @@ class Linux_session_component : public Nic::Session_component Packet_descriptor packet = _tx.sink()->get_packet(); if (!packet.size()) { - PWRN("Invalid tx packet"); + warning("invalid tx packet"); return true; } @@ -142,7 +143,7 @@ class Linux_session_component : public Nic::Session_component if (ret < 0 && errno == EAGAIN) continue; - if (ret < 0) PERR("write: errno=%d", errno); + if (ret < 0) Genode::error("write: errno=", errno); } while (ret < 0); _tx.sink()->acknowledge_packet(packet); @@ -201,13 +202,7 @@ class Linux_session_component : public Nic::Session_component try { Genode::Xml_node nic_config = Genode::config()->xml_node().sub_node("nic"); nic_config.attribute("mac").value(&_mac_addr); - PINF("Using configured MAC address \"%02x:%02x:%02x:%02x:%02x:%02x\"", - _mac_addr.addr[0], - _mac_addr.addr[1], - _mac_addr.addr[2], - _mac_addr.addr[3], - _mac_addr.addr[4], - _mac_addr.addr[5]); + Genode::log("Using configured MAC address ", _mac_addr); } catch (...) { /* fall back to fake MAC address (unicast, locally managed) */ _mac_addr.addr[0] = 0x02; diff --git a/repos/os/src/drivers/platform/spec/arndale/main.cc b/repos/os/src/drivers/platform/spec/arndale/main.cc index 3b5bc5570..2c47ab765 100644 --- a/repos/os/src/drivers/platform/spec/arndale/main.cc +++ b/repos/os/src/drivers/platform/spec/arndale/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -54,7 +54,7 @@ int main(int, char **) { using namespace Genode; - PINF("--- Arndale platform driver ---\n"); + log("--- Arndale platform driver ---"); static Cap_connection cap; static Rpc_entrypoint ep(&cap, 4096, "arndale_plat_ep"); diff --git a/repos/os/src/drivers/platform/spec/imx53/main.cc b/repos/os/src/drivers/platform/spec/imx53/main.cc index c520b0da4..8ed031682 100644 --- a/repos/os/src/drivers/platform/spec/imx53/main.cc +++ b/repos/os/src/drivers/platform/spec/imx53/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -75,7 +75,7 @@ class Platform::Session_component : public Genode::Rpc_object _iomux.pwm_enable(); break; default: - PWRN("Invalid device"); + Genode::warning("invalid device"); }; } @@ -86,7 +86,7 @@ class Platform::Session_component : public Genode::Rpc_object _ccm.ipu_clk_disable(); break; default: - PWRN("Invalid device"); + Genode::warning("invalid device"); }; } @@ -94,7 +94,7 @@ class Platform::Session_component : public Genode::Rpc_object { switch (dev) { default: - PWRN("Invalid device"); + Genode::warning("invalid device"); }; } @@ -135,7 +135,7 @@ int main(int, char **) { using namespace Genode; - PINF("--- i.MX53 platform driver ---\n"); + Genode::log("--- i.MX53 platform driver ---"); static Cap_connection cap; static Rpc_entrypoint ep(&cap, 4096, "imx53_plat_ep"); diff --git a/repos/os/src/drivers/platform/spec/odroid_x2/cmu.h b/repos/os/src/drivers/platform/spec/odroid_x2/cmu.h index 3178a9b85..604d5ff4b 100644 --- a/repos/os/src/drivers/platform/spec/odroid_x2/cmu.h +++ b/repos/os/src/drivers/platform/spec/odroid_x2/cmu.h @@ -20,7 +20,7 @@ #include #include #include -#include +#include using namespace Regulator; @@ -182,7 +182,8 @@ class Cmu : public Regulator::Driver, void _cpu_clk_freq(unsigned long level) { - PINF("Changing CPU frequency to %lu",level); + using namespace Genode; + log("Changing CPU frequency to ",level); unsigned freq; switch (level) { case CPU_FREQ_200: @@ -207,9 +208,9 @@ class Cmu : public Regulator::Driver, freq = 6; break; default: - PWRN("Unsupported CPU frequency level %ld", level); - PWRN("Supported values are 200, 400, 600, 800, 1000, 1200, 14000 MHz"); - PWRN("and 1, 1.2, 1.4, 1.6, 1.7 GHz"); + warning("Unsupported CPU frequency level ", level); + warning("Supported values are 200, 400, 600, 800, 1000, 1200, 14000 MHz"); + warning("and 1, 1.2, 1.4, 1.6, 1.7 GHz"); return; }; @@ -252,7 +253,7 @@ class Cmu : public Regulator::Driver, != Clk_mux_stat_cpu::Core_sel::MOUT_APLL) ; _cpu_freq = static_cast(level); - PINF("End of Changing CPU frequency to %lu",level); + Genode::log("changed CPU frequency to ",level); } @@ -288,7 +289,7 @@ class Cmu : public Regulator::Driver, _hdmi_enable(); break; default: - PWRN("Unsupported for %s", names[id].name); + Genode::warning("enabling regulator unsupported for ", names[id].name); } } @@ -301,7 +302,7 @@ class Cmu : public Regulator::Driver, return write(0); } default: - PWRN("Unsupported for %s", names[id].name); + Genode::warning("disabling regulator unsupported for ", names[id].name); } } @@ -339,7 +340,7 @@ class Cmu : public Regulator::Driver, _cpu_clk_freq(level); break; default: - PWRN("Unsupported for %s", names[id].name); + Genode::warning("level setting unsupported for ", names[id].name); } } @@ -349,7 +350,7 @@ class Cmu : public Regulator::Driver, case CLK_CPU: return _cpu_freq; default: - PWRN("Unsupported for %s", names[id].name); + Genode::warning("level requesting unsupported for ", names[id].name); } return 0; } @@ -368,7 +369,7 @@ class Cmu : public Regulator::Driver, case CLK_USB20: return read(); default: - PWRN("Unsupported for %s", names[id].name); + Genode::warning("state request unsupported for ", names[id].name); } return true; } diff --git a/repos/os/src/drivers/platform/spec/odroid_x2/main.cc b/repos/os/src/drivers/platform/spec/odroid_x2/main.cc index 9d34a1bc2..1b561ba82 100644 --- a/repos/os/src/drivers/platform/spec/odroid_x2/main.cc +++ b/repos/os/src/drivers/platform/spec/odroid_x2/main.cc @@ -13,7 +13,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -53,7 +53,7 @@ int main(int, char **) { using namespace Genode; - PINF("--- Odroid-x2 platform driver ---"); + log("--- Odroid-x2 platform driver ---"); static Cap_connection cap; static Rpc_entrypoint ep(&cap, 4096, "odroid_x2_plat_ep"); @@ -61,7 +61,7 @@ int main(int, char **) static Regulator::Root reg_root(&ep, env()->heap(), driver_factory); env()->parent()->announce(ep.manage(®_root)); - PINF("--- Odroid-x2 platform driver. Done ---"); + log("--- Odroid-x2 platform driver. Done ---"); sleep_forever(); return 0; } diff --git a/repos/os/src/drivers/platform/spec/rpi/main.cc b/repos/os/src/drivers/platform/spec/rpi/main.cc index 425ae3093..d222ae39a 100644 --- a/repos/os/src/drivers/platform/spec/rpi/main.cc +++ b/repos/os/src/drivers/platform/spec/rpi/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -106,7 +106,7 @@ int main(int, char **) { using namespace Platform; - PINF("--- Raspberry Pi platform driver ---\n"); + Genode::log("--- Raspberry Pi platform driver ---"); static Cap_connection cap; static Rpc_entrypoint ep(&cap, 4096, "rpi_plat_ep"); diff --git a/repos/os/src/drivers/platform/spec/rpi/mbox.h b/repos/os/src/drivers/platform/spec/rpi/mbox.h index 9246e331a..883290f75 100644 --- a/repos/os/src/drivers/platform/spec/rpi/mbox.h +++ b/repos/os/src/drivers/platform/spec/rpi/mbox.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -95,7 +95,7 @@ class Mbox : Genode::Attached_mmio read(); if (!wait_for(0, _delayer, 500, 1)) { - PERR("Mbox: timeout waiting for ready-to-write"); + Genode::error("Mbox: timeout waiting for ready-to-write"); return; } @@ -106,7 +106,7 @@ class Mbox : Genode::Attached_mmio write(value); if (!wait_for(0, _delayer, 500, 1)) { - PERR("Mbox: timeout waiting for response"); + Genode::error("Mbox: timeout waiting for response"); return; } diff --git a/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc b/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc index 22b961afc..744b409c2 100644 --- a/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc +++ b/repos/os/src/drivers/platform/spec/x86/device_pd/main.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include @@ -117,7 +117,8 @@ void Platform::Device_pd_component::attach_dma_mem(Genode::Dataspace_capability if (page != ~0UL) address_space().detach(page); - PERR("attachment of DMA memory @ %lx+%zx failed", phys, size); + Genode::error("attachment of DMA memory @ ", + Genode::Hex(phys), "+", Genode::Hex(size), " failed"); return; } @@ -126,8 +127,9 @@ void Platform::Device_pd_component::attach_dma_mem(Genode::Dataspace_capability if (map_eager(flex.addr, flex.log2_order)) continue; - PERR("attachment of DMA memory @ %lx+%zx failed at %lx", phys, size, - flex.addr); + Genode::error("attachment of DMA memory @ ", + Genode::Hex(phys), "+", Genode::Hex(size), " failed at ", + flex.addr); return; } } @@ -145,16 +147,30 @@ void Platform::Device_pd_component::assign_pci(Genode::Io_mem_dataspace_capabili /* trigger mapping of whole memory area */ if (!map_eager(page, 12)) - PERR("assignment of PCI device failed - %lx", page); + Genode::error("assignment of PCI device failed - ", Genode::Hex(page)); + + /* utility to print rid value */ + struct Rid + { + Genode::uint16_t const v; + explicit Rid(Genode::uint16_t rid) : v(rid) { } + void print(Genode::Output &out) const + { + using Genode::print; + using Genode::Hex; + print(out, Hex(v >> 8, Hex::Prefix::OMIT_PREFIX), ":", + Hex((v >> 3) & 3, Hex::Prefix::OMIT_PREFIX), ".", + Hex(v & 0x7, Hex::Prefix::OMIT_PREFIX)); + } + }; /* try to assign pci device to this protection domain */ if (!env()->pd_session()->assign_pci(page, rid)) - PERR("assignment of PCI device %x:%x.%x failed phys=%lx virt=%lx", - rid >> 8, (rid >> 3) & 0x1f, rid & 0x7, - ds_client.phys_addr(), page); + Genode::error("assignment of PCI device ", Rid(rid), " failed ", + "phys=", Genode::Hex(ds_client.phys_addr()), " " + "virt=", Genode::Hex(page)); else - PINF("assignment of %x:%x.%x succeeded", - rid >> 8, (rid >> 3) & 0x1f, rid & 0x7); + Genode::log("assignment of ", rid, " succeeded"); /* we don't need the mapping anymore */ address_space().detach(page); diff --git a/repos/os/src/drivers/platform/spec/x86/irq.cc b/repos/os/src/drivers/platform/spec/x86/irq.cc index 1332c200c..89498f88f 100644 --- a/repos/os/src/drivers/platform/spec/x86/irq.cc +++ b/repos/os/src/drivers/platform/spec/x86/irq.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* Platform driver include */ @@ -129,8 +129,8 @@ class Platform::Irq_thread : public Genode::Thread_deprecated<4096> Sdb *dispatcher = dynamic_cast(sig.context()); if (!dispatcher) { - PERR("dispatcher missing for signal %p, %u", - sig.context(), sig.num()); + Genode::error("dispatcher missing for signal ", + sig.context(), " ", sig.num()); continue; } dispatcher->dispatch(sig.num()); @@ -221,7 +221,7 @@ void Platform::Irq_session_component::ack_irq() /* shared irq handling */ Irq_component *irq_obj = Proxy::get_irq_proxy(_gsi); if (!irq_obj) { - PERR("Expected to find IRQ proxy for IRQ %02x", _gsi); + Genode::error("expected to find IRQ proxy for IRQ ", Genode::Hex(_gsi)); return; } @@ -269,10 +269,11 @@ Platform::Irq_session_component::Irq_session_component(unsigned irq, _gsi = Platform::Irq_override::irq_override(_gsi, trigger, polarity); if (_gsi != irq || trigger != Genode::Irq_session::TRIGGER_UNCHANGED || - polarity != Genode::Irq_session::POLARITY_UNCHANGED) - PINF("IRQ override %u->%u trigger mode=%s polarity=%s", irq, _gsi, - trigger == Genode::Irq_session::TRIGGER_LEVEL ? "LEVEL" : trigger == Genode::Irq_session::TRIGGER_EDGE ? "EDGE" : "UNCHANGED", - polarity == Genode::Irq_session::POLARITY_HIGH ? "HIGH" : polarity == Genode::Irq_session::POLARITY_LOW ? "LOW" : "UNCHANGED"); + polarity != POLARITY_UNCHANGED) { + + Genode::log("IRQ override ", irq, "->", _gsi, ", " + "trigger mode: ", trigger, ", ", "polarity: ", polarity); + } try { /* check if shared IRQ object was used before */ @@ -281,7 +282,7 @@ Platform::Irq_session_component::Irq_session_component(unsigned irq, return; } catch (Genode::Parent::Service_denied) { } - PERR("unavailable IRQ 0x%x requested", _gsi); + Genode::error("unavailable IRQ ", Genode::Hex(_gsi), " requested"); } @@ -318,7 +319,7 @@ void Platform::Irq_session_component::sigh(Genode::Signal_context_capability sig /* shared irq handling */ Irq_component *irq_obj = Proxy::get_irq_proxy(_gsi); if (!irq_obj) { - PERR("signal handler got not registered - irq object unavailable"); + Genode::error("signal handler got not registered - irq object unavailable"); return; } diff --git a/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc b/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc index a14ef8172..817ce4c18 100644 --- a/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc +++ b/repos/os/src/drivers/platform/spec/x86/nonpci_devices.cc @@ -24,9 +24,9 @@ class Nonpci::Ps2 : public Platform::Device_component IRQ_KEYBOARD = 1, IRQ_MOUSE = 12, - ACCESS_WIDTH = 1, - REG_DATA = 0x60, - REG_STATUS = 0x64, + ACCESS_WIDTH = 1, + REG_DATA = 0x60, + REG_STATUS = 0x64, }; Platform::Irq_session_component _irq_mouse; @@ -52,10 +52,10 @@ class Nonpci::Ps2 : public Platform::Device_component { switch (virt_irq) { case 0: - PINF("PS2 uses IRQ, vector 0x%x", IRQ_KEYBOARD); + Genode::log("PS2 uses IRQ, vector ", Genode::Hex(IRQ_KEYBOARD)); return Device_component::irq(virt_irq); case 1: - PINF("PS2 uses IRQ, vector 0x%x", IRQ_MOUSE); + Genode::log("PS2 uses IRQ, vector ", Genode::Hex(IRQ_MOUSE)); return _irq_mouse.cap(); default: return Genode::Irq_session_capability(); @@ -132,13 +132,13 @@ Platform::Device_capability Platform::Session_component::device(String const &na break; if (devices_i >= sizeof(devices) / sizeof(devices[0])) { - PERR("unknown '%s' device name", device_name); + Genode::error("unknown '", device_name, " device name"); return Device_capability(); } if (!permit_device(devices[devices_i])) { - PERR("Denied access to device '%s' for session '%s'", device_name, - _label.string()); + Genode::error("denied access to device '", device_name, "' for " + "session '", _label, "'"); return Device_capability(); } diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device.cc b/repos/os/src/drivers/platform/spec/x86/pci_device.cc index 589f626d4..4508229c3 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device.cc +++ b/repos/os/src/drivers/platform/spec/x86/pci_device.cc @@ -93,10 +93,11 @@ void Platform::Device_component::config_write(unsigned char address, if (!_device_config.reg_in_use(&_config_access, address, size)) break; - PERR("%x:%x:%x write access to address=%x value=0x%x" - " size=0x%x denied - it is used by the platform driver.", - _device_config.bus_number(), _device_config.device_number(), - _device_config.function_number(), address, value, size); + Genode::error(_device_config, " write access to " + "address=", Genode::Hex(address), " " + "value=", Genode::Hex(value), " " + "size=", Genode::Hex(size), " " + "denied - it is used by the platform driver."); return; case PCI_CMD_REG: /* COMMAND register - first byte */ if (size == Access_size::ACCESS_16BIT) @@ -106,11 +107,11 @@ void Platform::Device_component::config_write(unsigned char address, if (size == Access_size::ACCESS_8BIT) break; default: - PWRN("%x:%x:%x write access to address=%x value=0x%x " - " size=0x%x got dropped", _device_config.bus_number(), - _device_config.device_number(), - _device_config.function_number(), - address, value, size); + Genode::warning(_device_config, " write access to " + "address=", Genode::Hex(address), " " + "value=", Genode::Hex(value), " " + "size=", Genode::Hex(size), " " + "got dropped"); return; } @@ -121,7 +122,7 @@ void Platform::Device_component::config_write(unsigned char address, } catch (Platform::Session::Out_of_metadata) { throw Quota_exceeded(); } catch (...) { - PERR("assignment to device failed"); + Genode::error("assignment to device failed"); } } @@ -200,21 +201,18 @@ Genode::Irq_session_capability Platform::Device_component::irq(Genode::uint8_t i } if (_irq_session->msi()) - PINF("%x:%x.%x uses MSI %s, vector 0x%lx, address 0x%lx%s", - _device_config.bus_number(), - _device_config.device_number(), - _device_config.function_number(), - msi_64 ? "64bit" : "32bit", - _irq_session->msi_data(), _irq_session->msi_address(), - msi_mask ? ", maskable" : ", non-maskable"); + Genode::log(_device_config, " uses ", + "MSI ", (msi_64 ? "64bit" : "32bit"), ", " + "vector ", Genode::Hex(_irq_session->msi_data()), ", " + "address ", Genode::Hex(_irq_session->msi_address()), ", ", + (msi_mask ? "maskable" : "non-maskable")); else - PINF("%x:%x.%x uses IRQ, vector 0x%x%s%s", - _device_config.bus_number(), - _device_config.device_number(), - _device_config.function_number(), _irq_line, - msi_cap ? (msi_64 ? ", MSI 64bit capable" : - ", MSI 32bit capable") : "", - msi_mask ? ", maskable" : ", non-maskable"); + Genode::log(_device_config, " uses IRQ, vector ", + Genode::Hex(_irq_line), + (msi_cap ? (msi_64 ? ", MSI 64bit capable" + : ", MSI 32bit capable") + : ""), + (msi_mask ? ", maskable" : ", non-maskable")); return _irq_session->cap(); } diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device_component.h b/repos/os/src/drivers/platform/spec/x86/pci_device_component.h index ace2ede57..706762904 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_device_component.h @@ -133,10 +133,8 @@ class Platform::Device_component : public Genode::Rpc_object, _device_config.function_number(), pin); if (irq_r) { - PINF("%x:%x.%x adjust IRQ as reported by ACPI: %u -> %u", - _device_config.bus_number(), - _device_config.device_number(), - _device_config.function_number(), irq, irq_r); + Genode::log(_device_config, " adjust IRQ as reported by ACPI: ", + irq, " -> ", irq_r); _irq_line = irq = irq_r; } diff --git a/repos/os/src/drivers/platform/spec/x86/pci_device_config.h b/repos/os/src/drivers/platform/spec/x86/pci_device_config.h index 09b6c46c8..d71d5d5fc 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_device_config.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_device_config.h @@ -11,8 +11,10 @@ * under the terms of the GNU General Public License version 2. */ -#pragma once +#ifndef _X86__PCI_DEVICE_CONFIG_H_ +#define _X86__PCI_DEVICE_CONFIG_H_ +#include #include #include "pci_config_access.h" @@ -143,6 +145,15 @@ namespace Platform { int device_number() { return _device; } int function_number() { return _function; } + void print(Genode::Output &out) const + { + using Genode::print; + using Genode::Hex; + print(out, Hex(_bus, Hex::Prefix::OMIT_PREFIX), + ":", Hex(_device, Hex::Prefix::OMIT_PREFIX), + ".", Hex(_function, Hex::Prefix::OMIT_PREFIX)); + } + Genode::uint16_t bdf () { return (_bus << 8) | (_device << 3) | (_function & 0x7); } @@ -232,3 +243,5 @@ namespace Platform { } }; } + +#endif /* _X86__PCI_DEVICE_CONFIG_H_ */ diff --git a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h index 179d70d3b..146bef6d3 100644 --- a/repos/os/src/drivers/platform/spec/x86/pci_session_component.h +++ b/repos/os/src/drivers/platform/spec/x86/pci_session_component.h @@ -193,7 +193,7 @@ namespace Platform { throw Out_of_metadata(); if (Genode::env()->ram_session()->transfer_quota(ram_ref_cap, DEVICE_PD_RAM_QUOTA)) { - PERR("Transferring quota for device pd failed"); + Genode::error("Transferring quota for device pd failed"); md_alloc.upgrade(DEVICE_PD_RAM_QUOTA); throw Platform::Session::Fatal(); } @@ -207,8 +207,8 @@ namespace Platform { Session_capability session = Genode::Root_client(policy->root()).session("", Affinity()); child = Device_pd_client(Genode::reinterpret_cap_cast(session)); } catch (Genode::Rom_connection::Rom_connection_failed) { - PWRN("PCI device protection domain for IOMMU support " - "is not available"); + Genode::warning("PCI device protection domain for IOMMU support " + "is not available"); if (policy) { destroy(md_alloc, policy); @@ -220,7 +220,7 @@ namespace Platform { md_alloc.upgrade(DEVICE_PD_RAM_QUOTA); throw Out_of_metadata(); } catch(...) { - PERR("unknown exception"); + Genode::error("unknown exception"); md_alloc.upgrade(DEVICE_PD_RAM_QUOTA); throw Platform::Session::Fatal(); } @@ -518,11 +518,12 @@ namespace Platform { if (!find_dev_in_policy(policy_device, DOUBLET)) return; - PERR("'%s' - device '%s' is part of more than one policy", - _label.string(), policy_device); + Genode::error("'", _label, "' - device " + "'", Genode::Cstring(policy_device), "' " + "is part of more than one policy"); } catch (Genode::Xml_node::Nonexistent_attribute) { - PERR("'%s' - device node misses a 'name' attribute", - _label.string()); + Genode::error("'", _label, "' - device node " + "misses a 'name' attribute"); } throw Genode::Root::Unavailable(); }); @@ -546,8 +547,8 @@ namespace Platform { class_sub_prog = class_subclass_prog(alias_class); if (class_sub_prog >= INVALID_CLASS) { - PERR("'%s' - invalid 'class' attribute '%s'", - _label.string(), alias_class); + Genode::error("'", _label, "' - invalid 'class' ", + "attribute '", Genode::Cstring(alias_class), "'"); throw Genode::Root::Unavailable(); } } catch (Xml_attribute::Nonexistent_attribute) { } @@ -557,8 +558,7 @@ namespace Platform { /* sanity check that 'class' is the only attribute */ try { node.attribute(1); - PERR("'%s' - attributes beside 'class' detected", - _label.string()); + Genode::error("'", _label, "' - attributes beside 'class' detected"); throw Genode::Root::Unavailable(); } catch (Xml_attribute::Nonexistent_attribute) { } @@ -569,8 +569,8 @@ namespace Platform { /* no 'class' attribute - now check for valid bdf triple */ try { node.attribute(3); - PERR("'%s' - invalid number of pci node attributes", - _label.string()); + Genode::error("'", _label, "' - " + "invalid number of pci node attributes"); throw Genode::Root::Unavailable(); } catch (Xml_attribute::Nonexistent_attribute) { } @@ -590,12 +590,14 @@ namespace Platform { if (!find_dev_in_policy(bus, device, function, DOUBLET)) return; - PERR("'%s' - device '%2x:%2x.%x' is part of more than " - "one policy", _label.string(), bus, device, - function); + Genode::error("'", _label, "' - device '", + Genode::Hex(bus), ":", + Genode::Hex(device), ".", function, "' " + "is part of more than one policy"); + } catch (Xml_attribute::Nonexistent_attribute) { - PERR("'%s' - invalid pci node attributes for bdf", - _label.string()); + Genode::error("'", _label, "' - " + "invalid pci node attributes for bdf"); } throw Genode::Root::Unavailable(); }); @@ -723,9 +725,11 @@ namespace Platform { if (bdf_in_use.get(Device_config::MAX_BUSES * bus + Device_config::MAX_DEVICES * device + function, 1)) - PERR("Device %2x:%2x.%u is used by more than one " - "driver - session '%s'.", bus, device, function, - _label.string()); + Genode::error("Device ", + Genode::Hex(bus), ":", + Genode::Hex(device), ".", function, " " + "is used by more than one driver - " + "session '", _label, "'."); else bdf_in_use.set(Device_config::MAX_BUSES * bus + Device_config::MAX_DEVICES * device + @@ -800,7 +804,7 @@ namespace Platform { _device_pd->child.attach_dma_mem(rmrr_cap); } } catch (...) { - PERR("assignment to device pd or of RMRR region failed"); + Genode::error("assignment to device pd or of RMRR region failed"); } } @@ -1073,8 +1077,8 @@ class Platform::Root : public Genode::Root_component return new (md_alloc()) Session_component(ep(), md_alloc(), args, _device_pd_ep); } catch (Genode::Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy for '%s'", - Genode::label_from_args(args).string()); + Genode::error("Invalid session request, no matching policy for ", + "'", Genode::label_from_args(args).string(), "'"); throw Genode::Root::Unavailable(); } } @@ -1110,7 +1114,7 @@ class Platform::Root : public Genode::Root_component try { _parse_report_rom(acpi_rom); } catch (...) { - PERR("PCI config space data could not be parsed."); + Genode::error("PCI config space data could not be parsed."); } } } @@ -1131,7 +1135,7 @@ class Platform::Root : public Genode::Root_component const bool feature_reset = Fadt::Features::Reset::get(fadt.features); if (!feature_reset) { - PWRN("system reset failed - feature not supported"); + Genode::warning("system reset failed - feature not supported"); return; } @@ -1146,7 +1150,7 @@ class Platform::Root : public Genode::Root_component access_size = Device::ACCESS_32BIT; break; case Fadt::Gas::Access_size::QWORD: - PERR("system reset failed - unsupported access size"); + Genode::error("system reset failed - unsupported access size"); return; default: break; @@ -1155,6 +1159,6 @@ class Platform::Root : public Genode::Root_component config_access.system_reset(fadt.reset_addr, fadt.reset_value, access_size); /* if we are getting here - the reset failed */ - PINF("system reset failed"); + Genode::warning("system reset failed"); } }; diff --git a/repos/os/src/drivers/rtc/spec/x86/main.cc b/repos/os/src/drivers/rtc/spec/x86/main.cc index 1793187f8..c29df5fc9 100644 --- a/repos/os/src/drivers/rtc/spec/x86/main.cc +++ b/repos/os/src/drivers/rtc/spec/x86/main.cc @@ -13,6 +13,7 @@ /* Genode */ #include +#include #include #include #include diff --git a/repos/os/src/drivers/sd_card/sd_card.h b/repos/os/src/drivers/sd_card/sd_card.h index d0ddac497..1e59eb362 100644 --- a/repos/os/src/drivers/sd_card/sd_card.h +++ b/repos/os/src/drivers/sd_card/sd_card.h @@ -58,11 +58,15 @@ namespace Sd_card { struct Busy : Bitfield<31, 1> { }; }; - struct Cid { - uint32_t raw_0; - uint32_t raw_1; - uint32_t raw_2; - uint32_t raw_3; + struct Cid + { + uint32_t raw_0, raw_1, raw_2, raw_3; + + void print(Output &out) const + { + Genode::print(out, Hex(raw_3), " ", Hex(raw_2), " ", + Hex(raw_1), " ", Hex(raw_0)); + } }; struct Csd0 : Register<32> @@ -138,6 +142,18 @@ namespace Sd_card { : index(op), arg(0), rsp_type(rsp_type), transfer(transfer) { } + + void print(Output &out) const + { + using Genode::print; + print(out, "index=", index, ", arg=", arg, ", rsp_type="); + switch (rsp_type) { + case RESPONSE_NONE: print(out, "NONE"); break; + case RESPONSE_136_BIT: print(out, "136_BIT"); break; + case RESPONSE_48_BIT: print(out, "48_BIT"); break; + case RESPONSE_48_BIT_WITH_BUSY: print(out, "48_BIT_WITH_BUSY"); break; + } + } }; template @@ -435,7 +451,7 @@ namespace Sd_card { { /* send CMD55 prefix */ if (!_issue_command(Acmd_prefix(prefix_rca))) { - PERR("prefix command timed out"); + error("prefix command timed out"); return false; } @@ -482,7 +498,7 @@ namespace Sd_card { return ((Csd2::V2_device_size_hi::get(csd.csd2) << 16) | Csd1::V2_device_size_lo::get(csd.csd1)) + 1; - PERR("Could not detect SD-card capacity"); + error("Could not detect SD-card capacity"); throw Detection_failed(); } @@ -496,31 +512,30 @@ namespace Sd_card { Card_info _detect() { if (!issue_command(All_send_cid())) { - PWRN("All_send_cid command failed"); + warning("All_send_cid command failed"); throw Detection_failed(); } Cid const cid = _read_cid(); - PLOG("CID: 0x%08x 0x%08x 0x%08x 0x%08x", - cid.raw_3, cid.raw_2, cid.raw_1, cid.raw_0); + log("CID: ", cid); if (!issue_command(Send_relative_addr())) { - PERR("Send_relative_addr timed out"); + error("Send_relative_addr timed out"); throw Detection_failed(); } unsigned const rca = _read_rca(); - PLOG("RCA: 0x%04x", rca); + log("RCA: ", Hex(rca)); if (!issue_command(Send_csd(rca))) { - PERR("Send_csd failed"); + error("Send_csd failed"); throw Detection_failed(); } Csd const csd = _read_csd(); if (!issue_command(Select_card(rca))) { - PERR("Select_card failed"); + error("Select_card failed"); throw Detection_failed(); } @@ -531,42 +546,42 @@ namespace Sd_card { Card_info _detect_mmc() { if (!issue_command(All_send_cid())) { - PWRN("All_send_cid command failed"); + warning("All_send_cid command failed"); throw Detection_failed(); } unsigned const rca = 1; if (!issue_command(Send_relative_addr(rca))) { - PERR("Send_relative_addr timed out"); + error("Send_relative_addr timed out"); throw Detection_failed(); } if (!issue_command(Send_csd(rca))) { - PERR("Send_csd failed"); + error("Send_csd failed"); throw Detection_failed(); } Csd const csd = _read_csd(); if (Csd3::Version::get(csd.csd3) != Csd3::Version::EXT_CSD) { - PERR("Csd version is not extented CSD"); + error("Csd version is not extented CSD"); throw Detection_failed(); } if (Csd3::Mmc_spec_vers::get(csd.csd3) < 4) { - PERR("Csd specific version is less than 4"); + error("Csd specific version is less than 4"); throw Detection_failed(); } if (!issue_command(Select_card(rca))) { - PERR("Select_card failed"); + error("Select_card failed"); throw Detection_failed(); } size_t device_size; if(!(device_size = _read_ext_csd())) { - PERR("Could not read extented CSD"); + error("Could not read extented CSD"); throw Detection_failed(); } diff --git a/repos/os/src/drivers/sd_card/spec/exynos5/driver.h b/repos/os/src/drivers/sd_card/spec/exynos5/driver.h index 28e84ed62..47fbd7cb0 100644 --- a/repos/os/src/drivers/sd_card/spec/exynos5/driver.h +++ b/repos/os/src/drivers/sd_card/spec/exynos5/driver.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -77,8 +77,8 @@ class Block::Exynos5_driver : public Block::Driver { Sd_card::Card_info const card_info = _controller.card_info(); - PLOG("SD/MMC card detected"); - PLOG("capacity: %zd MiB", card_info.capacity_mb()); + Genode::log("SD/MMC card detected"); + Genode::log("capacity: ", card_info.capacity_mb(), " MiB"); } diff --git a/repos/os/src/drivers/sd_card/spec/exynos5/dwmmc.h b/repos/os/src/drivers/sd_card/spec/exynos5/dwmmc.h index 32162a199..3acb7bbd1 100644 --- a/repos/os/src/drivers/sd_card/spec/exynos5/dwmmc.h +++ b/repos/os/src/drivers/sd_card/spec/exynos5/dwmmc.h @@ -199,7 +199,7 @@ struct Dwmmc : Genode::Mmio write(0x7); if (!wait_for(0, delayer, 100, 1000)) { - PERR("Could not reset host contoller"); + Genode::error("Could not reset host contoller"); return false; } @@ -211,7 +211,7 @@ struct Dwmmc : Genode::Mmio write(0x2); if (!wait_for(0, delayer, 100, 1000)) - PERR("Could not reset fifo"); + Genode::error("Could not reset fifo"); } void disable_irq() @@ -241,7 +241,7 @@ struct Dwmmc : Genode::Mmio write(cmd); if (!wait_for(0, delayer)) { - PERR("Update clock registers failed"); + Genode::error("Update clock registers failed"); return false; } @@ -304,7 +304,14 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller return block_count < MAX_BLOCKS ? 0 : block_count - MAX_BLOCKS; } - void dump() { PDBG("this: %p f: %x bytes: %u, addr: %x next: %x", this, flags, bytes, addr, next); } + void dump() + { + Genode::log("this: ", this, " " + "flags: ", Genode::Hex(flags), " " + "bytes: ", bytes, " " + "addr: ", Genode::Hex(addr), " " + "next:", Genode::Hex(next)); + } }; /* @@ -349,20 +356,20 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller bus_width(BUS_WIDTH_1); if (!issue_command(Go_idle_state())) { - PWRN("Go_idle_state command failed"); + Genode::warning("Go_idle_state command failed"); throw Detection_failed(); } _delayer.usleep(2000); if (!issue_command(Send_if_cond())) { - PWRN("Send_if_cond command failed"); + Genode::warning("Send_if_cond command failed"); throw Detection_failed(); } /* if this succeeds it is an SD card */ if ((read() & 0xff) == 0xaa) - PINF("Found SD card"); + Genode::log("Found SD card"); /* * We need to issue the same Mmc_send_op_cond command multiple @@ -376,7 +383,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller unsigned arg = 0; for (; i > 0; --i) { if (!issue_command(Mmc_send_op_cond(arg, true))) { - PWRN("Sd_send_op_cond command failed"); + Genode::warning("Sd_send_op_cond command failed"); throw Detection_failed(); } @@ -390,7 +397,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller } if (i == 0) { - PERR("Send_op_cond timed out, could no power-on SD/MMC card"); + Genode::error("Send_op_cond timed out, could no power-on SD/MMC card"); throw Detection_failed(); } @@ -399,14 +406,14 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller /* switch frequency to high speed */ enum { EXT_CSD_HS_TIMING = 185 }; if (!issue_command(Mmc_switch(EXT_CSD_HS_TIMING, 1))) { - PERR("Error setting high speed frequency"); + Genode::error("Error setting high speed frequency"); throw Detection_failed(); } enum { EXT_CSD_BUS_WIDTH = 183 }; /* set card to 8 bit */ if (!issue_command(Mmc_switch(EXT_CSD_BUS_WIDTH, 2))) { - PERR("Error setting card bus width"); + Genode::error("Error setting card bus width"); throw Detection_failed(); } @@ -414,7 +421,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller /* set to eight bit transfer Bit */ if (!setup_bus(CLK_DIV_52Mhz, _delayer)) { - PERR("Error setting bus to high speed"); + Genode::error("Error setting bus to high speed"); throw Detection_failed(); } @@ -433,7 +440,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller size_t const max_idmac_block_count = IDMAC_DESC_MAX_ENTRIES * 8; if (block_count > max_idmac_block_count) { - PERR("Block request too large"); + Genode::error("Block request too large"); return false; } @@ -488,17 +495,17 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller } if (read()) { - PERR("Response error"); + Genode::error("Response error"); return false; } if (read()) { - PERR("Data read timeout"); + Genode::error("Data read timeout"); return false; } if (read()) { - PERR("CRC error"); + Genode::error("CRC error"); return false; } } @@ -528,11 +535,11 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller bool _issue_command(Sd_card::Command_base const &command) { if (verbose) - PLOG("-> index=0x%08x, arg=0x%08x, rsp_type=%d", - command.index, command.arg, command.rsp_type); + Genode::log("-> ", command); if (!wait_for(0, _delayer, 10000, 100)) { - PERR("wait for State::Data_busy timed out %x", read()); + Genode::error("wait for State::Data_busy timed out ", + Genode::Hex(read())); return false; } @@ -571,21 +578,20 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller write(cmd); if (!wait_for(1, _delayer, 10000, 100)) { - PERR("Command failed Rintst: %x Mintst: %x Status: %x", read(), read(), read()); + Genode::error("command failed " + "Rintst: ", read(), " " + "Mintst: ", read(), " " + "Status: ", read()); if (read()) - PWRN("timeout"); + Genode::warning("timeout"); if (read()) - PWRN("Repsonse error"); + Genode::warning("repsonse error"); return false; } - if (verbose) - PDBG("IRQ: Rintsts %x transfer %s", read(), - command.transfer == Sd_card::TRANSFER_NONE ? "none" : "data"); - /* acknowledge interrupt */ write(1); @@ -628,7 +634,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller throw Detection_failed(); if (!wait_for(1, _delayer)) { - PERR("Error retrieving extented CSD"); + Genode::error("cannot retrieve extented CSD"); throw Detection_failed(); } /* clear IRQ */ @@ -639,7 +645,7 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller /* read revision */ if (csd.read() < 2) { - PERR("Extented CSD revision is < 2"); + Genode::error("extented CSD revision is < 2"); throw Detection_failed(); } @@ -662,14 +668,15 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller return false; if (!_issue_command(Sd_card::Read_multiple_block(block_number))) { - PERR("Read_multiple_block failed, Status: 0x%08x", read()); + Genode::error("Read_multiple_block failed, Status: ", + Genode::Hex(read())); return false; } bool complete = _wait_for_transfer_complete(); if (!_issue_command(Sd_card::Stop_transmission())) { - PERR("Unable to stop transmission"); + Genode::error("unable to stop transmission"); return false; } @@ -683,14 +690,15 @@ struct Exynos5_msh_controller : private Dwmmc, Sd_card::Host_controller return false; if (!_issue_command(Sd_card::Write_multiple_block(block_number))) { - PERR("Read_multiple_block failed, Status: 0x%08x", read()); + Genode::error("Read_multiple_block failed, Status: ", + Genode::Hex(read())); return false; } bool complete = _wait_for_transfer_complete(); if (!_issue_command(Sd_card::Stop_transmission())) { - PERR("Unable to stop transmission"); + Genode::error("unable to stop transmission"); return false; } diff --git a/repos/os/src/drivers/sd_card/spec/imx53/adma2.cc b/repos/os/src/drivers/sd_card/spec/imx53/adma2.cc index 0146c0fa5..815ef700d 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/adma2.cc +++ b/repos/os/src/drivers/sd_card/spec/imx53/adma2.cc @@ -33,7 +33,7 @@ int Table::setup_request(size_t const size, addr_t const buffer_phys) /* sanity check */ static size_t constexpr max_size = _max_desc * Desc::Length::max; if (size > max_size) { - PERR("Block request too large"); + Genode::error("block request too large"); return -1; } /* install new descriptors till they cover all requested bytes */ diff --git a/repos/os/src/drivers/sd_card/spec/imx53/bench/main.cc b/repos/os/src/drivers/sd_card/spec/imx53/bench/main.cc index 602c6d67c..96bd1c9c4 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/bench/main.cc +++ b/repos/os/src/drivers/sd_card/spec/imx53/bench/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ static void run_benchmark(Block::Driver &driver, { using namespace Genode; - PLOG("request_size=%zd bytes", request_size); + log("request_size=", request_size, " bytes"); size_t const time_before_ms = timer.elapsed_ms(); @@ -81,9 +81,9 @@ static void run_benchmark(Block::Driver &driver, size_t const buffer_size_kb = buffer_size / 1024; size_t const throughput_kb_per_sec = (1000*buffer_size_kb) / duration_ms; - PLOG(" duration: %zd ms", duration_ms); - PLOG(" amount: %zd KiB", buffer_size_kb); - PLOG(" throughput: %zd KiB/sec", throughput_kb_per_sec); + log(" duration: ", duration_ms, " ms"); + log(" amount: ", buffer_size_kb, " KiB"); + log(" throughput: ", throughput_kb_per_sec, " KiB/sec"); } @@ -93,7 +93,7 @@ struct Main { using namespace Genode; - printf("--- i.MX53 SD card benchmark ---\n"); + log("--- i.MX53 SD card benchmark ---"); bool const use_dma = true; @@ -116,7 +116,7 @@ struct Main * Benchmark reading from SD card */ - printf("\n-- reading from SD card --\n"); + log("\n-- reading from SD card --"); struct Read : Operation { @@ -144,7 +144,7 @@ struct Main * its original content. */ - printf("\n-- writing to SD card --\n"); + log("\n-- writing to SD card --"); struct Write : Operation { @@ -163,7 +163,7 @@ struct Main run_benchmark(driver, timer, buffer_virt, buffer_phys, buffer_size, request_sizes[i], write_operation); - printf("\n--- i.MX53 SD card benchmark finished ---\n"); + log("\n--- i.MX53 SD card benchmark finished ---"); } }; diff --git a/repos/os/src/drivers/sd_card/spec/imx53/driver.h b/repos/os/src/drivers/sd_card/spec/imx53/driver.h index 8b62cb43d..4b89993a9 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/driver.h +++ b/repos/os/src/drivers/sd_card/spec/imx53/driver.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -60,8 +60,8 @@ class Block::Imx53_driver : public Block::Driver { Sd_card::Card_info const card_info = _controller.card_info(); - PLOG("SD card detected"); - PLOG("capacity: %zd MiB", card_info.capacity_mb()); + log("SD card detected"); + log("capacity: ", card_info.capacity_mb(), " MiB"); } diff --git a/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.cc b/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.cc index d19bbafb9..b11f04234 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.cc +++ b/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.cc @@ -30,7 +30,7 @@ int Esdhcv2_controller::_wait_for_card_ready_mbw() unsigned constexpr attempts_delay_us = 100000; while (1) { if (!attempts) { - PERR("Reading card status after multiblock write failed"); + error("Reading card status after multiblock write failed"); return -1; } /* assemble argument register value */ @@ -58,7 +58,7 @@ int Esdhcv2_controller::_wait_for_card_ready_mbw() /* check for errors */ R1_response_0::access_t const resp = read(); if (R1_response_0::Error::get(resp)) { - PERR("Reading card status after multiblock write failed"); + error("Reading card status after multiblock write failed"); return -1; } /* if card is in a ready state, return success, retry otherwise */ @@ -114,7 +114,7 @@ int Esdhcv2_controller::_wait_for_cmd_complete_mb(bool const r) */ if (irq != irq_goal) { if (!wait_for(irq_goal, _delayer)) { - PERR("Completion host signal timed out"); + error("Completion host signal timed out"); return -1; } } @@ -147,7 +147,7 @@ int Esdhcv2_controller::_wait_for_cmd_complete() /* wait for "Command Completion" signal and acknowledge it */ _wait_for_irq(); if (read() != Irqstat::Cc::reg_mask()) { - PERR("Received unexpected host signal"); + error("received unexpected host signal"); return -1; } write(Irqstat::Cc::reg_mask()); @@ -233,14 +233,14 @@ unsigned Esdhcv2_controller::_read_rca() bool Esdhcv2_controller::read_blocks(size_t, size_t, char *) { - PERR("Block transfer without DMA not supported by now"); + error("block transfer without DMA not supported by now"); return false; } bool Esdhcv2_controller::write_blocks(size_t, size_t, char const *) { - PERR("Block transfer without DMA not supported by now"); + error("block transfer without DMA not supported by now"); return false; } @@ -291,7 +291,7 @@ int Esdhcv2_controller::_wait_for_cmd_allowed() * "Data Line Active" and "Data Inhibit" may also be active. */ if (!wait_for(Prsstat_lhw::cmd_allowed(), _delayer)) { - PERR("Wait till issuing a new command is allowed timed out"); + error("wait till issuing a new command is allowed timed out"); return -1; } return 0; @@ -446,7 +446,7 @@ Card_info Esdhcv2_controller::_init() void Esdhcv2_controller::_detect_err(char const * const err) { - PERR("%s", err); + error(err); throw Detection_failed(); } @@ -471,7 +471,7 @@ int Esdhcv2_controller::_reset(Delayer & delayer) /* wait for reset completion */ if (!wait_for(0, delayer)) { - PERR("Reset timed out"); + error("Reset timed out"); return -1; } return 0; diff --git a/repos/os/src/drivers/sd_card/spec/omap4/bench/main.cc b/repos/os/src/drivers/sd_card/spec/omap4/bench/main.cc index ce8fb60e8..156c61f74 100644 --- a/repos/os/src/drivers/sd_card/spec/omap4/bench/main.cc +++ b/repos/os/src/drivers/sd_card/spec/omap4/bench/main.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -45,7 +45,7 @@ static void run_benchmark(Block::Driver &driver, { using namespace Genode; - PLOG("request_size=%zd bytes", request_size); + log("request_size=", request_size, " bytes"); size_t const time_before_ms = timer.elapsed_ms(); @@ -72,8 +72,8 @@ static void run_benchmark(Block::Driver &driver, size_t const buffer_size_kb = buffer_size / 1024; size_t const throughput_kb_per_sec = (1000*buffer_size_kb) / duration_ms; - PLOG(" -> duration: %zd ms", duration_ms); - PLOG(" throughput: %zd KiB/sec", throughput_kb_per_sec); + log(" -> duration: ", duration_ms, " ms"); + log(" throughput: ", throughput_kb_per_sec, " KiB/sec"); } @@ -83,7 +83,7 @@ struct Main { using namespace Genode; - printf("--- OMAP4 SD card benchmark ---\n"); + log("--- OMAP4 SD card benchmark ---"); bool const use_dma = false; @@ -106,12 +106,12 @@ struct Main * Benchmark reading from SD card */ - printf("\n-- reading from SD card --\n"); + log("\n-- reading from SD card --"); struct Read : Operation { void operator () (Block::Driver &driver, - addr_t number, size_t count, addr_t phys, char *virt) + addr_t number, size_t count, addr_t phys, char *virt) { Block::Packet_descriptor p; if (driver.dma_enabled()) @@ -123,7 +123,7 @@ struct Main for (unsigned i = 0; request_sizes[i]; i++) run_benchmark(driver, timer, buffer_virt, buffer_phys, buffer_size, - request_sizes[i], read_operation); + request_sizes[i], read_operation); /* * Benchmark writing to SD card @@ -133,12 +133,12 @@ struct Main * its original content. */ - printf("\n-- writing to SD card --\n"); + log("\n-- writing to SD card --"); struct Write : Operation { void operator () (Block::Driver &driver, - addr_t number, size_t count, addr_t phys, char *virt) + addr_t number, size_t count, addr_t phys, char *virt) { Block::Packet_descriptor p; if (driver.dma_enabled()) @@ -150,9 +150,9 @@ struct Main for (unsigned i = 0; request_sizes[i]; i++) run_benchmark(driver, timer, buffer_virt, buffer_phys, buffer_size, - request_sizes[i], write_operation); + request_sizes[i], write_operation); - printf("\n--- OMAP4 SD card benchmark finished ---\n"); + log("\n--- OMAP4 SD card benchmark finished ---"); } }; diff --git a/repos/os/src/drivers/sd_card/spec/omap4/driver.h b/repos/os/src/drivers/sd_card/spec/omap4/driver.h index b8367a7a9..37cebc87f 100644 --- a/repos/os/src/drivers/sd_card/spec/omap4/driver.h +++ b/repos/os/src/drivers/sd_card/spec/omap4/driver.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -67,8 +67,8 @@ class Block::Omap4_driver : public Block::Driver { Sd_card::Card_info const card_info = _controller.card_info(); - PLOG("SD card detected"); - PLOG("capacity: %zd MiB", card_info.capacity_mb()); + Genode::log("SD card detected"); + Genode::log("capacity: ", card_info.capacity_mb(), " MiB"); } diff --git a/repos/os/src/drivers/sd_card/spec/omap4/mmchs.h b/repos/os/src/drivers/sd_card/spec/omap4/mmchs.h index 75f177f86..c65a72925 100644 --- a/repos/os/src/drivers/sd_card/spec/omap4/mmchs.h +++ b/repos/os/src/drivers/sd_card/spec/omap4/mmchs.h @@ -347,12 +347,12 @@ struct Mmchs : Genode::Mmio * the timing here. */ if (!wait_for(1, delayer, 1000, 0)) { - PERR("reset of cmd line timed out (src != 1)"); + Genode::error("reset of cmd line timed out (src != 1)"); return false; } if (!wait_for(0, delayer, 1000, 0)) { - PERR("reset of cmd line timed out (src != 0)"); + Genode::error("reset of cmd line timed out (src != 0)"); return false; } @@ -365,7 +365,7 @@ struct Mmchs : Genode::Mmio write(1); if (!wait_for(1, delayer, 1000, 0)) { - PERR("soft reset all timed out (src != 1)"); + Genode::error("soft reset all timed out (src != 1)"); return false; } @@ -401,7 +401,7 @@ struct Mmchs : Genode::Mmio write(Hctl::Sdbp::POWER_ON); if (!wait_for(1, delayer)) { - PERR("setting Hctl::Sdbp timed out"); + Genode::error("setting Hctl::Sdbp timed out"); return false; } return true; @@ -427,7 +427,7 @@ struct Mmchs : Genode::Mmio /* wait for clock to become stable */ if (!wait_for(1, delayer)) { - PERR("clock enable timed out"); + Genode::error("clock enable timed out"); return false; } @@ -467,7 +467,7 @@ struct Mmchs : Genode::Mmio write(0); if (!wait_for(1, delayer, 1000*1000, 0)) { - PERR("init stream timed out"); + Genode::error("init stream timed out"); return false; } @@ -514,7 +514,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller set_bus_power(VOLTAGE_3_0); if (!sd_bus_power_on(_delayer)) { - PERR("sd_bus_power failed"); + Genode::error("sd_bus_power failed"); } disable_irq(); @@ -525,12 +525,12 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller stop_clock(); if (!set_and_enable_clock(CLOCK_DIV_240, _delayer)) { - PERR("set_clock failed"); + Genode::error("set_clock failed"); throw Detection_failed(); } if (!init_stream(_delayer)) { - PERR("sending the initialization stream failed"); + Genode::error("sending the initialization stream failed"); throw Detection_failed(); } @@ -539,19 +539,19 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller _delayer.usleep(1000); if (!issue_command(Go_idle_state())) { - PWRN("Go_idle_state command failed"); + Genode::error("Go_idle_state command failed"); throw Detection_failed(); } _delayer.usleep(2000); if (!issue_command(Send_if_cond())) { - PWRN("Send_if_cond command failed"); + Genode::error("Send_if_cond command failed"); throw Detection_failed(); } if (read() != 0x1aa) { - PERR("unexpected response of Send_if_cond command"); + Genode::error("unexpected response of Send_if_cond command"); throw Detection_failed(); } @@ -566,7 +566,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller int i = 1000; for (; i > 0; --i) { if (!issue_command(Sd_send_op_cond(0x18000, true))) { - PWRN("Sd_send_op_cond command failed"); + Genode::warning("Sd_send_op_cond command failed"); throw Detection_failed(); } @@ -577,7 +577,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller } if (i == 0) { - PERR("Sd_send_op_cond timed out, could no power-on SD card"); + Genode::error("Sd_send_op_cond timed out, could no power-on SD card"); throw Detection_failed(); } @@ -588,7 +588,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller */ if (!issue_command(Set_bus_width(Set_bus_width::Arg::Bus_width::FOUR_BITS), card_info.rca())) { - PWRN("Set_bus_width(FOUR_BITS) command failed"); + Genode::warning("Set_bus_width(FOUR_BITS) command failed"); throw Detection_failed(); } @@ -598,7 +598,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller stop_clock(); if (!set_and_enable_clock(CLOCK_DIV_0, _delayer)) { - PERR("set_clock failed"); + Genode::error("set_clock failed"); throw Detection_failed(); } @@ -640,7 +640,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller * supported by the controller. */ if (block_count*BLOCK_SIZE > max_adma_request_size*ADMA_DESC_MAX_ENTRIES) { - PERR("Block request too large"); + Genode::error("Block request too large"); return false; } @@ -694,7 +694,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller { if (!wait_for(1, _delayer, 1000*1000, 0) && !wait_for(1, _delayer)) { - PERR("Stat::Tc timed out"); + Genode::error("Stat::Tc timed out"); return false; } @@ -707,7 +707,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller { if (!wait_for(1, _delayer, 1000*1000, 0) && !wait_for(1, _delayer)) { - PERR("Pstate::Bre timed out"); + Genode::error("Pstate::Bre timed out"); return false; } return true; @@ -717,7 +717,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller { if (!wait_for(1, _delayer, 1000*1000, 0) && !wait_for(1, _delayer)) { - PERR("Pstate::Bwe timed out"); + Genode::error("Pstate::Bwe timed out"); return false; } return true; @@ -745,17 +745,18 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller write(1); if (read() != 0) - PWRN("unexpected state (Stat: 0x%x Blen: 0x%x Nblk: %d)", - read(), read(), read()); + Genode::warning("unexpected state (" + "Stat: ", Genode::Hex(read()), " " + "Blen: ", Genode::Hex(read()), " " + "Nblk: ", read()); return true; } - PWRN("unexpected interrupt, Stat: 0x%08x", read()); + Genode::warning("unexpected interrupt, Stat: ", Genode::Hex(read())); } } - public: enum { IRQ_NUMBER = Genode::Board_base::HSMMC_IRQ }; @@ -790,11 +791,10 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller bool _issue_command(Sd_card::Command_base const &command) { if (verbose) - PLOG("-> index=0x%08x, arg=0x%08x, rsp_type=%d", - command.index, command.arg, command.rsp_type); + Genode::log("-> ", command); if (!wait_for(0, _delayer)) { - PERR("wait for Pstate::Cmdi timed out"); + Genode::error("wait for Pstate::Cmdi timed out"); return false; } @@ -841,9 +841,9 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller for (unsigned long i = 0; i < 1000*1000; i++) { Stat::access_t const stat = read(); if (Stat::Erri::get(stat)) { - PWRN("SD command error"); + Genode::warning("SD command error"); if (Stat::Cto::get(stat)) - PWRN("timeout"); + Genode::warning("timeout"); reset_cmd_line(_delayer); write(~0); @@ -858,7 +858,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller } if (verbose) - PLOG("<- %s", result ? "succeeded" : "timed out"); + Genode::log("<- ", result ? "succeeded" : "timed out"); /* clear status of command-completed bit */ write(1); @@ -910,7 +910,8 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller write(block_count); if (!issue_command(Read_multiple_block(block_number))) { - PERR("Read_multiple_block failed, Stat: 0x%08x", read()); + Genode::error("Read_multiple_block failed, Stat: ", + Genode::Hex(read())); return false; } @@ -940,7 +941,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller write(block_count); if (!issue_command(Write_multiple_block(block_number))) { - PERR("Write_multiple_block failed"); + Genode::error("Write_multiple_block failed"); return false; } @@ -973,7 +974,8 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller _setup_adma_descriptor_table(block_count, out_buffer_phys); if (!issue_command(Read_multiple_block(block_number))) { - PERR("Read_multiple_block failed, Stat: 0x%08x", read()); + Genode::error("Read_multiple_block failed, Stat: ", + Genode::Hex(read())); return false; } @@ -996,7 +998,7 @@ struct Omap4_hsmmc_controller : private Mmchs, public Sd_card::Host_controller _setup_adma_descriptor_table(block_count, buffer_phys); if (!issue_command(Write_multiple_block(block_number))) { - PERR("Write_multiple_block failed"); + Genode::error("Write_multiple_block failed"); return false; } diff --git a/repos/os/src/drivers/sd_card/spec/pl180/pl180.h b/repos/os/src/drivers/sd_card/spec/pl180/pl180.h index ecc42e5f1..357f53221 100644 --- a/repos/os/src/drivers/sd_card/spec/pl180/pl180.h +++ b/repos/os/src/drivers/sd_card/spec/pl180/pl180.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -115,35 +115,6 @@ class Pl180 : public Host_driver, public Genode::Irq_handler void _clear_status() { _write_reg(Clear, ~0); } - void _log_status() const - { - unsigned s = _read_reg(Status); - - PLOG("pl180 status:\n%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", - (s & CmdCrcFail) ? " CmdCrcFail\n" : "", - (s & DataCrcFail) ? " DataCrcFail\n" : "", - (s & CmdTimeOut) ? " CmdTimeOut\n" : "", - (s & DataTimeOut) ? " DataTimeOut\n" : "", - (s & TxUnderrun) ? " TxUnderrun\n" : "", - (s & RxUnderrun) ? " RxUnderrun\n" : "", - (s & CmdRespEnd) ? " CmdRespEnd\n" : "", - (s & CmdSent) ? " CmdSent\n" : "", - (s & DataEnd) ? " DataEnd\n" : "", - (s & StartBitErr) ? " StartBitErr\n" : "", - (s & DataBlockEnd) ? " DataBlockEnd\n" : "", - (s & CmdActive) ? " CmdActive\n" : "", - (s & TxActive) ? " TxActive\n" : "", - (s & RxActive) ? " RxActive\n" : "", - (s & TxFifoHalfEmpty) ? " TxFifoHalfEmpty\n" : "", - (s & RxFifoHalfFull) ? " RxFifoHalfFull\n" : "", - (s & TxFifoFull) ? " TxFifoFull\n" : "", - (s & RxFifoFull) ? " RxFifoFull\n" : "", - (s & TxFifoEmpty) ? " TxFifoEmpty\n" : "", - (s & RxFifoEmpty) ? " RxFifoEmpty\n" : "", - (s & TxDataAvlbl) ? " TxDataAvlbl\n" : "", - (s & RxDataAvlbl) ? " RxDataAvlbl\n" : ""); - } - public: Pl180(Genode::addr_t mmio_base, Genode::size_t mmio_size) @@ -168,8 +139,6 @@ class Pl180 : public Host_driver, public Genode::Irq_handler { Genode::Lock::Guard g(_mutex); - PINF("%s: %02x", __func__, irq_number); - _log_status(); _clear_status(); } diff --git a/repos/os/src/drivers/sd_card/spec/rpi/driver.h b/repos/os/src/drivers/sd_card/spec/rpi/driver.h index f65277dd9..90bbfe27a 100644 --- a/repos/os/src/drivers/sd_card/spec/rpi/driver.h +++ b/repos/os/src/drivers/sd_card/spec/rpi/driver.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -62,8 +62,8 @@ class Block::Sdhci_driver : public Block::Driver { Sd_card::Card_info const card_info = _controller.card_info(); - PLOG("SD card detected"); - PLOG("capacity: %zd MiB", card_info.capacity_mb()); + Genode::log("SD card detected"); + Genode::log("capacity: ", card_info.capacity_mb(), " MiB"); } diff --git a/repos/os/src/drivers/sd_card/spec/rpi/sdhci.h b/repos/os/src/drivers/sd_card/spec/rpi/sdhci.h index 64a4e86f2..0978e50ac 100644 --- a/repos/os/src/drivers/sd_card/spec/rpi/sdhci.h +++ b/repos/os/src/drivers/sd_card/spec/rpi/sdhci.h @@ -171,7 +171,7 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller write(v); if (!wait_for(1, _delayer)) { - PERR("could not set internal clock"); + Genode::error("could not set internal clock"); throw Detection_failed(); } @@ -196,13 +196,12 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller } if (!wait_for(0, _delayer)) { - PERR("host-controller soft reset timed out"); + Genode::error("host-controller soft reset timed out"); throw Detection_failed(); } - PLOG("SDHCI version: %u (specification %u.0)", - read(), read()+1); - + Genode::log("SDHCI version: ", read(), " " + "(specification ", read() + 1, ".0)"); /* * Raspberry Pi (BCM2835) does not need to @@ -229,19 +228,19 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller _set_and_enable_clock(240); if (!issue_command(Go_idle_state())) { - PWRN("Go_idle_state command failed"); + Genode::warning("Go_idle_state command failed"); throw Detection_failed(); } _delayer.usleep(2000); if (!issue_command(Send_if_cond())) { - PWRN("Send_if_cond command failed"); + Genode::warning("Send_if_cond command failed"); throw Detection_failed(); } if (read() != 0x1aa) { - PERR("unexpected response of Send_if_cond command"); + Genode::error("unexpected response of Send_if_cond command"); throw Detection_failed(); } @@ -256,7 +255,7 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller int i = 1000; for (; i > 0; --i) { if (!issue_command(Sd_send_op_cond(0x18000, true))) { - PWRN("Sd_send_op_cond command failed"); + Genode::warning("Sd_send_op_cond command failed"); throw Detection_failed(); } @@ -267,7 +266,7 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller } if (i == 0) { - PERR("Sd_send_op_cond timed out, could no power-on SD card"); + Genode::error("Sd_send_op_cond timed out, could no power-on SD card"); throw Detection_failed(); } @@ -278,7 +277,7 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller */ if (!issue_command(Set_bus_width(Set_bus_width::Arg::Bus_width::FOUR_BITS), card_info.rca())) { - PWRN("Set_bus_width(FOUR_BITS) command failed"); + Genode::warning("Set_bus_width(FOUR_BITS) command failed"); throw Detection_failed(); } @@ -353,11 +352,10 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller bool _issue_command(Sd_card::Command_base const &command) { if (verbose) - PLOG("-> index=0x%08x, arg=0x%08x, rsp_type=%d", - command.index, command.arg, command.rsp_type); + Genode::log("-> ", command); if (!_poll_and_wait_for(0)) { - PERR("controller inhibits issueing commands"); + Genode::error("controller inhibits issueing commands"); return false; } @@ -397,7 +395,7 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller write(cmd); if (!_poll_and_wait_for(1)) { - PERR("command timed out"); + Genode::error("command timed out"); return false; } @@ -459,7 +457,8 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller _set_block_count(block_count); if (!issue_command(Read_multiple_block(_block_to_command_address(block_number)))) { - PERR("Read_multiple_block failed, Status: 0x%08x", read()); + Genode::error("Read_multiple_block failed, Status: ", + Genode::Hex(read())); return false; } @@ -482,8 +481,8 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller } if (!_poll_and_wait_for(1)) { - PERR("completion of read request failed (interrupt status %08x)", - read()); + Genode::error("completion of read request failed (interrupt " + "status ", Genode::Hex(read()), ")"); return false; } @@ -505,7 +504,8 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller _set_block_count(block_count); if (!issue_command(Write_multiple_block(_block_to_command_address(block_number)))) { - PERR("Write_multiple_block failed, Status: 0x%08x", read()); + Genode::error("Write_multiple_block failed, Status: ", + Genode::Hex(read())); return false; } @@ -522,8 +522,8 @@ struct Sdhci_controller : private Sdhci, public Sd_card::Host_controller } if (!_poll_and_wait_for(1)) { - PERR("completion of write request failed (interrupt status %08x)", - read()); + Genode::error("completion of write request failed (interrupt " + "status ", read(), ")"); return false; } diff --git a/repos/os/src/drivers/timer/spec/hw/platform_timer.h b/repos/os/src/drivers/timer/spec/hw/platform_timer.h index 24957d38f..1c8b15dab 100644 --- a/repos/os/src/drivers/timer/spec/hw/platform_timer.h +++ b/repos/os/src/drivers/timer/spec/hw/platform_timer.h @@ -58,9 +58,9 @@ class Platform_timer _curr_time_us(0), _last_timeout_us(0), _max_timeout_us(Kernel::timeout_max_us()) { - PINF("Maximum timeout %lu us", _max_timeout_us); + Genode::log("maximum timeout ", _max_timeout_us, " us"); if (max_timeout() < min_timeout()) { - PERR("Minimum timeout greater then maximum timeout"); + Genode::error("minimum timeout greater then maximum timeout"); throw Genode::Exception(); } } diff --git a/repos/os/src/drivers/uart/spec/exynos5/main.cc b/repos/os/src/drivers/uart/spec/exynos5/main.cc index faf15d198..4e0a9267b 100644 --- a/repos/os/src/drivers/uart/spec/exynos5/main.cc +++ b/repos/os/src/drivers/uart/spec/exynos5/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -29,7 +29,7 @@ int main(int argc, char **argv) { using namespace Genode; - PINF("--- Exynos5 UART driver started ---\n"); + log("--- Exynos5 UART driver started ---"); /** * Factory used by 'Terminal::Root' at session creation/destruction time @@ -55,7 +55,7 @@ int main(int argc, char **argv) if (baudrate == 0) { - PDBG("Baudrate is not defined. Use default 115200"); + warning("Baudrate is not defined. Use default 115200"); baudrate = BAUD_115200; } diff --git a/repos/os/src/drivers/uart/spec/i8250/main.cc b/repos/os/src/drivers/uart/spec/i8250/main.cc index 7f87873b0..e5064a3ba 100644 --- a/repos/os/src/drivers/uart/spec/i8250/main.cc +++ b/repos/os/src/drivers/uart/spec/i8250/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -25,7 +25,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- i8250 UART driver started ---\n"); + log("--- i8250 UART driver started ---"); /** * Factory used by 'Uart::Root' at session creation/destruction time @@ -75,7 +75,7 @@ int main(int argc, char **argv) enum { BAUD = 115200 }; if (baudrate == 0) { - PINF("Baudrate is not defined. Use default 115200"); + warning("Baudrate is not defined. Use default 115200"); baudrate = BAUD; } diff --git a/repos/os/src/drivers/uart/spec/omap4/main.cc b/repos/os/src/drivers/uart/spec/omap4/main.cc index c53c579b7..27829a33b 100644 --- a/repos/os/src/drivers/uart/spec/omap4/main.cc +++ b/repos/os/src/drivers/uart/spec/omap4/main.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -30,7 +30,7 @@ int main(int argc, char **argv) { using namespace Genode; - PDBG("--- OMAP4 UART driver started ---\n"); + log("--- OMAP4 UART driver started ---"); /** * Factory used by 'Terminal::Root' at session creation/destruction time @@ -56,7 +56,7 @@ int main(int argc, char **argv) if (baudrate == 0) { - PDBG("Baudrate is not defined. Use default 115200"); + warning("Baudrate is not defined. Use default 115200"); baudrate = BAUD_115200; } diff --git a/repos/os/src/drivers/uart/spec/pl011/main.cc b/repos/os/src/drivers/uart/spec/pl011/main.cc index af0d9bd0b..e162f9672 100644 --- a/repos/os/src/drivers/uart/spec/pl011/main.cc +++ b/repos/os/src/drivers/uart/spec/pl011/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -27,7 +27,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- PL011 UART driver started ---\n"); + log("--- PL011 UART driver started ---"); /** * Factory used by 'Uart::Root' at session creation/destruction time @@ -48,7 +48,8 @@ int main(int argc, char **argv) Uart::Driver *create(unsigned index, unsigned /* baudrate */, Uart::Char_avail_callback &callback) { - PINF("Setting baudrate is not supported yet. Use default 115200."); + warning("Setting baudrate is not supported yet. Use default 115200."); + /* * We assume the underlying kernel uses UART0 and, therefore, start at * index 1 for the user-level driver. diff --git a/repos/os/src/drivers/uart/uart_component.h b/repos/os/src/drivers/uart/uart_component.h index 56e246608..93f772841 100644 --- a/repos/os/src/drivers/uart/uart_component.h +++ b/repos/os/src/drivers/uart/uart_component.h @@ -117,7 +117,7 @@ namespace Uart { && _read_number(height) == ';' && _read_number(width) == 'R') { - PINF("detected terminal size %dx%d", width, height); + Genode::log("detected terminal size ", width, "x", height); return Size(width, height); } @@ -238,10 +238,10 @@ namespace Uart { Session_component(_driver_factory, index, baudrate, detect_size); } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"uart\" attribute in policy definition"); + Genode::error("Missing \"uart\" attribute in policy definition"); throw Root::Unavailable(); } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("Invalid session request, no matching policy"); throw Root::Unavailable(); } } diff --git a/repos/os/src/drivers/uart/uart_driver.h b/repos/os/src/drivers/uart/uart_driver.h index 74e6732fa..d194ea979 100644 --- a/repos/os/src/drivers/uart/uart_driver.h +++ b/repos/os/src/drivers/uart/uart_driver.h @@ -46,7 +46,7 @@ namespace Uart { */ virtual void baud_rate(int /*bits_per_second*/) { - PINF("Setting baudrate is not supported yet. Use default 115200."); + Genode::warning("Setting baudrate is not supported yet. Use default 115200."); } }; diff --git a/repos/os/src/drivers/usb_block/cbw_csw.h b/repos/os/src/drivers/usb_block/cbw_csw.h index 45a4e32c9..705e5de9a 100644 --- a/repos/os/src/drivers/usb_block/cbw_csw.h +++ b/repos/os/src/drivers/usb_block/cbw_csw.h @@ -58,12 +58,12 @@ struct Usb::Cbw : Genode::Mmio void dump() { - PLOG("Sig: 0x%04x", read()); - PLOG("Tag: %u", read()); - PLOG("Dtl: %u", read()); - PLOG("Flg: 0x%x", read()); - PLOG("Lun: %u", read()); - PLOG("Cbl: %u", read()); + Genode::log("Sig: ", Genode::Hex(read())); + Genode::log("Tag: ", read()); + Genode::log("Dtl: ", read()); + Genode::log("Flg: ", Genode::Hex(read())); + Genode::log("Lun: ", read()); + Genode::log("Cbl: ", read()); } }; @@ -80,7 +80,7 @@ struct Test_unit_ready : Usb::Cbw, void dump() { - PLOG("--- Dump TEST_UNIT_READY command --"); + Genode::log("--- Dump TEST_UNIT_READY command --"); Cbw::dump(); Scsi::Cmd_6::dump(); } @@ -98,7 +98,7 @@ struct Request_sense : Usb::Cbw, Scsi::Request_sense void dump() { - PLOG("--- Dump REQUEST_SENSE command --"); + Genode::log("--- Dump REQUEST_SENSE command --"); Cbw::dump(); Scsi::Cmd_6::dump(); } @@ -116,7 +116,7 @@ struct Inquiry : Usb::Cbw, Scsi::Inquiry void dump() { - PLOG("--- Dump INQUIRY command --"); + Genode::log("--- Dump INQUIRY command --"); Cbw::dump(); Scsi::Cmd_6::dump(); } @@ -134,7 +134,7 @@ struct Read_capacity_10 : Usb::Cbw, Scsi::Read_capacity_10 void dump() { - PLOG("--- Dump READ_CAPACITY_10 command --"); + Genode::log("--- Dump READ_CAPACITY_10 command --"); Cbw::dump(); Scsi::Cmd_10::dump(); } @@ -153,7 +153,7 @@ struct Read_10 : Usb::Cbw, Scsi::Read_10 void dump() { - PLOG("--- Dump READ_10 command --"); + Genode::log("--- Dump READ_10 command --"); Cbw::dump(); Scsi::Cmd_10::dump(); } @@ -172,7 +172,7 @@ struct Write_10 : Usb::Cbw, Scsi::Write_10 void dump() { - PLOG("--- Dump WRITE_10 command --"); + Genode::log("--- Dump WRITE_10 command --"); Cbw::dump(); Scsi::Cmd_10::dump(); } @@ -190,7 +190,7 @@ struct Read_capacity_16 : Usb::Cbw, Scsi::Read_capacity_16 void dump() { - PLOG("--- Dump READ_CAPACITY_16 command --"); + Genode::log("--- Dump READ_CAPACITY_16 command --"); Cbw::dump(); Scsi::Cmd_16::dump(); } @@ -209,7 +209,7 @@ struct Read_16 : Usb::Cbw, Scsi::Read_16 void dump() { - PLOG("--- Dump READ_16 command --"); + Genode::log("--- Dump READ_16 command --"); Cbw::dump(); Scsi::Cmd_16::dump(); } @@ -228,7 +228,7 @@ struct Write_16 : Usb::Cbw, Scsi::Write_16 void dump() { - PLOG("--- Dump WRITE_16 command --"); + Genode::log("--- Dump WRITE_16 command --"); Cbw::dump(); Scsi::Cmd_16::dump(); } diff --git a/repos/os/src/drivers/usb_block/main.cc b/repos/os/src/drivers/usb_block/main.cc index c5b952c6e..3ca2b6c70 100644 --- a/repos/os/src/drivers/usb_block/main.cc +++ b/repos/os/src/drivers/usb_block/main.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -72,7 +73,7 @@ struct Usb::Block_driver : Usb::Completion, void handle_state_change() { if (!usb.plugged()) { - PDBG("Device unplugged"); + Genode::log("Device unplugged"); device_plugged = false; return; } @@ -82,7 +83,7 @@ struct Usb::Block_driver : Usb::Completion, return; } - PDBG("Device plugged"); + Genode::log("Device plugged"); if (!initialize()) { return; @@ -590,7 +591,7 @@ struct Usb::Block_driver : Usb::Completion, Genode::error("complete error: packet not succeded"); if (req.pending) { Genode::error("request pending: tag: ", active_tag, " read: ", - (int)req.read, " buffer: ", req.buffer, " lba: ", + (int)req.read, " buffer: ", (void *)req.buffer, " lba: ", req.lba, " size: ", req.size); ack_pending_request(false); } @@ -662,7 +663,7 @@ struct Usb::Block_driver : Usb::Completion, uint8_t const status = csw.sts(); if (status != Csw::PASSED) { Genode::error("CSW failed: ", Hex(status, Hex::PREFIX, Hex::PAD), - " read: ", (int)req.read, " buffer: ", req.buffer, + " read: ", (int)req.read, " buffer: ", (void *)req.buffer, " lba: ", req.lba, " size: ", req.size); break; } diff --git a/repos/os/src/drivers/usb_block/scsi.h b/repos/os/src/drivers/usb_block/scsi.h index 12b26dcab..ea2a7dfb9 100644 --- a/repos/os/src/drivers/usb_block/scsi.h +++ b/repos/os/src/drivers/usb_block/scsi.h @@ -126,13 +126,13 @@ struct Scsi::Inquiry_response : Genode::Mmio void dump() { - PLOG("--- Dump INQUIRY data ---"); - PLOG("Dt: 0x%02x", read
()); - PLOG("Rm::Rmb: %u ", read()); - PLOG("Ver: 0x%02x", read()); - PLOG("Rdf: 0x%02x", read()); - PLOG("Al: %u", read()); - PLOG("Flg: 0x%02x", read()); + Genode::log("--- Dump INQUIRY data ---"); + Genode::log("Dt: ", Genode::Hex(read
())); + Genode::log("Rm::Rmb: ", read()); + Genode::log("Ver: ", Genode::Hex(read())); + Genode::log("Rdf: ", Genode::Hex(read())); + Genode::log("Al: ", read()); + Genode::log("Flg: ", Genode::Hex(read())); } }; @@ -162,12 +162,12 @@ struct Scsi::Request_sense_response : Genode::Mmio void dump() { - PLOG("--- Dump REQUEST_SENSE data ---"); - PLOG("Rc::V: %u", read()); - PLOG("Rc::Ec: 0x%02x", read()); - PLOG("Flg::Sk: 0x%02x", read()); - PLOG("Asc: 0x%02x", read()); - PLOG("Asq: 0x%02x", read()); + Genode::log("--- Dump REQUEST_SENSE data ---"); + Genode::log("Rc::V: ", read()); + Genode::log("Rc::Ec: ", Genode::Hex(read())); + Genode::log("Flg::Sk: ", Genode::Hex(read())); + Genode::log("Asc: ", Genode::Hex(read())); + Genode::log("Asq: ", Genode::Hex(read())); } }; @@ -186,9 +186,9 @@ struct Scsi::Capacity_response_10 : Genode::Mmio void dump() { - PLOG("--- Dump READ_CAPACITY_10 data ---"); - PLOG("Bc: 0x%04x", block_count()); - PLOG("Bs: 0x%04x", block_size()); + Genode::log("--- Dump READ_CAPACITY_10 data ---"); + Genode::log("Bc: ", Genode::Hex(block_count())); + Genode::log("Bs: ", Genode::Hex(block_size())); } }; @@ -207,9 +207,9 @@ struct Scsi::Capacity_response_16 : Genode::Mmio void dump() { - PLOG("--- Dump READ_CAPACITY_16 data ---"); - PLOG("Bc: 0x%08llx", block_count()); - PLOG("Bs: 0x%04x", block_size()); + Genode::log("--- Dump READ_CAPACITY_16 data ---"); + Genode::log("Bc: ", Genode::Hex(block_count())); + Genode::log("Bs: ", Genode::Hex(block_size())); } }; @@ -230,10 +230,10 @@ struct Scsi::Cmd_6 : Genode::Mmio void dump() { - PLOG("Op: 0x%02x", read()); - PLOG("Lba: 0x%02x", be16(read())); - PLOG("Len: %u", read()); - PLOG("Ctl: 0x%02x", read()); + Genode::log("Op: ", Genode::Hex(read())); + Genode::log("Lba: ", Genode::Hex(be16(read()))); + Genode::log("Len: ", read()); + Genode::log("Ctl: ", Genode::Hex(read())); } }; @@ -294,11 +294,11 @@ struct Scsi::Start_stop : Genode::Mmio void dump() { - PLOG("Op: 0x%02x", read()); - PLOG("I::Immed: %u", read()); - PLOG("Flg::Pwc: 0x%02x", read()); - PLOG("Flg::Loej: %u", read()); - PLOG("Flg::St: %u", read()); + Genode::log("Op: ", Genode::Hex(read())); + Genode::log("I::Immed: ", read()); + Genode::log("Flg::Pwc: ", Genode::Hex(read())); + Genode::log("Flg::Loej: ", read()); + Genode::log("Flg::St: ", read()); } }; @@ -319,10 +319,10 @@ struct Scsi::Cmd_10 : Genode::Mmio void dump() { - PLOG("Op: 0x%0x", read()); - PLOG("Lba: 0x%0x", be32(read())); - PLOG("Len: %u", be16(read())); - PLOG("Ctl: 0x%0x", read()); + Genode::log("Op: ", Genode::Hex(read())); + Genode::log("Lba: ", Genode::Hex(be32(read()))); + Genode::log("Len: ", be16(read())); + Genode::log("Ctl: ", Genode::Hex(read())); } }; @@ -380,10 +380,10 @@ struct Scsi::Cmd_16 : Genode::Mmio void dump() { - PLOG("Op: 0x%0x", read()); - PLOG("Lba: 0x%0llx", be64(read())); - PLOG("Len: %u", be32(read())); - PLOG("Ctl: 0x%0x", read()); + Genode::log("Op: ", Genode::Hex(read())); + Genode::log("Lba: ", Genode::Hex(be64(read()))); + Genode::log("Len: ", be32(read())); + Genode::log("Ctl: ", Genode::Hex(read())); } }; diff --git a/repos/os/src/init/main.cc b/repos/os/src/init/main.cc index e2105a86b..596c0f3fd 100644 --- a/repos/os/src/init/main.cc +++ b/repos/os/src/init/main.cc @@ -36,7 +36,7 @@ inline long read_prio_levels() catch (...) { } if (prio_levels && (prio_levels != (1 << log2(prio_levels)))) { - printf("Warning: Priolevels is not power of two, priorities are disabled\n"); + warning("prio levels is not power of two, priorities are disabled"); return 0; } return prio_levels; @@ -70,7 +70,7 @@ inline void determine_parent_services(Genode::Service_registry *services) using namespace Genode; if (Init::config_verbose) - printf("parent provides\n"); + log("parent provides"); Xml_node node = config()->xml_node().sub_node("parent-provides").sub_node("service"); for (; ; node = node.next("service")) { @@ -81,7 +81,7 @@ inline void determine_parent_services(Genode::Service_registry *services) Parent_service *s = new (env()->heap()) Parent_service(service_name); services->insert(s); if (Init::config_verbose) - printf(" service \"%s\"\n", service_name); + log(" service \"", Cstring(service_name), "\""); if (node.last("service")) break; } @@ -191,7 +191,7 @@ class Init::Child_registry : public Name_registry, Child_list void insert_alias(Alias *alias) { if (!unique(alias->name.string())) { - PERR("Alias name %s is not unique", alias->name.string()); + error("alias name ", alias->name, " is not unique"); throw Alias_name_is_not_unique(); } _aliases.insert(alias); @@ -330,9 +330,9 @@ int main(int, char **) children.insert_alias(new (env()->heap()) Alias(alias_node)); } catch (Alias::Name_is_missing) { - PWRN("Missing 'name' attribute in '' entry\n"); } + warning("missing 'name' attribute in '' entry"); } catch (Alias::Child_is_missing) { - PWRN("Missing 'child' attribute in '' entry\n"); } + warning("missing 'child' attribute in '' entry"); } }); @@ -360,9 +360,9 @@ int main(int, char **) children.start(); } catch (Xml_node::Nonexistent_sub_node) { - PERR("No children to start"); } + error("no children to start"); } catch (Xml_node::Invalid_syntax) { - PERR("No children to start"); } + error("no children to start"); } catch (Init::Child::Child_name_is_not_unique) { } catch (Init::Child_registry::Alias_name_is_not_unique) { } @@ -379,7 +379,7 @@ int main(int, char **) if (signal.context() == &sig_ctx_config) break; - PWRN("unexpected signal received - drop it"); + warning("unexpected signal received - drop it"); } /* kill all currently running children */ diff --git a/repos/os/src/lib/alarm/alarm.cc b/repos/os/src/lib/alarm/alarm.cc index ef4c7364c..7af7714a6 100644 --- a/repos/os/src/lib/alarm/alarm.cc +++ b/repos/os/src/lib/alarm/alarm.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include using namespace Genode; @@ -20,7 +20,7 @@ using namespace Genode; void Alarm_scheduler::_unsynchronized_enqueue(Alarm *alarm) { if (alarm->_active) { - PERR("trying to insert the same alarm twice!"); + error("trying to insert the same alarm twice!"); return; } diff --git a/repos/os/src/lib/config/config.cc b/repos/os/src/lib/config/config.cc index 5ac1a2535..dfca1a492 100644 --- a/repos/os/src/lib/config/config.cc +++ b/repos/os/src/lib/config/config.cc @@ -50,7 +50,7 @@ void Config::reload() _config_xml = _config_xml_node(_config_ds); } catch (Genode::Xml_node::Invalid_syntax) { - PERR("Config file has invalid syntax"); + Genode::error("Config file has invalid syntax"); _config_xml = fallback_config_xml(); } } @@ -88,11 +88,11 @@ Config *Genode::config() static Config config_inst; return &config_inst; } catch (Genode::Rom_connection::Rom_connection_failed) { - PERR("Could not obtain config file"); + Genode::error("Could not obtain config file"); } catch (Genode::Xml_node::Invalid_syntax) { - PERR("Config file has invalid syntax"); + Genode::error("Config file has invalid syntax"); } catch(...) { - PERR("Config dataspace is invalid"); + Genode::error("Config dataspace is invalid"); } } /* do not try again to construct 'config_inst' */ diff --git a/repos/os/src/lib/config_args/config_args.cc b/repos/os/src/lib/config_args/config_args.cc index 916e9c042..3188fe22a 100644 --- a/repos/os/src/lib/config_args/config_args.cc +++ b/repos/os/src/lib/config_args/config_args.cc @@ -12,6 +12,7 @@ */ #include +#include using namespace Genode; @@ -40,7 +41,7 @@ void init_config_args(void) catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_attribute) { - PERR(" node has no 'value' attribute, ignoring further nodes"); + error(" node has no 'value' attribute, ignoring further nodes"); } if (argc == 0) diff --git a/repos/os/src/lib/net/stat.cc b/repos/os/src/lib/net/stat.cc index 4e3e2e3f7..655fd210b 100644 --- a/repos/os/src/lib/net/stat.cc +++ b/repos/os/src/lib/net/stat.cc @@ -58,17 +58,6 @@ void Measurement::data(Net::Ethernet_frame * eth, Genode::size_t size) _stat.count ++; _stat.size += size; - if (false) { - for (unsigned i=0; i < 5; i++) - Genode::printf("%2x:", eth->src().addr[i]); - Genode::printf("%2x -> ", eth->src().addr[5]); - for (unsigned i=0; i < 5; i++) - Genode::printf("%2x:", eth->dst().addr[i]); - Genode::printf("%2x ", eth->dst().addr[5]); - Genode::printf("rx %lu:%llu, drop %lu:%llu\n", _stat.count, _stat.size, - _drop.count, _drop.size); - } - if (status != IS_MAGIC) return; @@ -86,14 +75,12 @@ void Measurement::data(Net::Ethernet_frame * eth, Genode::size_t size) if (time_elapsed_ms) kbits_raw = (_stat.size + _drop.size) / time_elapsed_ms * 8; - printf("%lu kBit/s (raw %lu kBit/s), runtime %lu ms\n", - kbits_test, kbits_raw, time_elapsed_ms); - printf("%lu kiBytes (+ %lu kiBytes dropped)\n", - (unsigned long)(_stat.size / 1024), - (unsigned long)(_drop.size / 1024)); - printf("%lu packets (+ %lu packets dropped)\n", - _stat.count, _drop.count); - printf("\n"); + log(kbits_test, " kBit/s (raw ", kbits_raw, " kBit/s), " + "runtime ", time_elapsed_ms, " ms"); + log((unsigned long)(_stat.size / 1024), " kiBytes (+ ", + (unsigned long)(_drop.size / 1024), " kiBytes dropped)"); + log(_stat.count, " packets (+ ", _drop.count, " packets dropped)"); + log(""); _stat.size = _stat.count = _drop.size = _drop.count = 0; diff --git a/repos/os/src/server/blk_cache/driver.h b/repos/os/src/server/blk_cache/driver.h index 544ebd896..08dc5205d 100644 --- a/repos/os/src/server/blk_cache/driver.h +++ b/repos/os/src/server/blk_cache/driver.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "chunk.h" @@ -165,10 +166,10 @@ class Driver : public Block::Driver write(r->cli.block_number(), r->cli.block_count(), r->buffer, r->cli); } catch(Block::Driver::Request_congestion) { - Genode::warning("cli (", r->cli.block_number(), - " ", r->cli.block_count(), - ") srv (", r->srv.block_number(), - " ", r->srv.block_count(), ")"); + Genode::warning("cli (", r->cli.block_number(), " ", + r->cli.block_count(), ") " + "srv (", r->srv.block_number(), " ", + r->srv.block_count(), ")"); } } @@ -215,7 +216,7 @@ class Driver : public Block::Driver */ void _request(Block::sector_t block_number, Genode::size_t block_count, - char * const buffer, + char * const buffer, Block::Packet_descriptor &packet) { Block::Packet_descriptor p_to_dev; diff --git a/repos/os/src/server/clipboard/main.cc b/repos/os/src/server/clipboard/main.cc index afe2ddccc..82990923d 100644 --- a/repos/os/src/server/clipboard/main.cc +++ b/repos/os/src/server/clipboard/main.cc @@ -193,8 +193,8 @@ struct Clipboard::Main : Rom::Module::Read_policy, Rom::Module::Write_policy if (_focused_domain.valid() && _domain(writer) == _focused_domain) return true; - PWRN("unexpected attempt by '%s' to write to '%s'", - writer.label().string(), module.name().string()); + warning("unexpected attempt by '", writer.label(), "' " + "to write to '", module.name(), "'"); return false; } diff --git a/repos/os/src/server/fs_log/main.cc b/repos/os/src/server/fs_log/main.cc index e92d933c8..7cfba57f5 100644 --- a/repos/os/src/server/fs_log/main.cc +++ b/repos/os/src/server/fs_log/main.cc @@ -12,13 +12,14 @@ */ /* Genode includes */ +#include #include #include #include #include #include #include -#include +#include /* Local includes */ #include "log_file.h" @@ -86,7 +87,7 @@ class Fs_log::Root_component : && policy.has_attribute("label_prefix")) { if (!dir_path[1]) { - PERR("cannot merge an empty policy label"); + Genode::error("cannot merge an empty policy label"); throw Root::Unavailable(); } @@ -151,7 +152,6 @@ class Fs_log::Root_component : offset = _fs.status(handle).size; } catch (File_system::Lookup_failed) { - PDBG("create"); handle = _fs.file(dir_handle, file_name, File_system::WRITE_ONLY, true); } @@ -162,22 +162,22 @@ class Fs_log::Root_component : _log_files.insert(file); } catch (Permission_denied) { - PERR("%s: permission denied", Path(file_name, dir_path).base()); + error(Path(file_name, dir_path), ": permission denied"); } catch (No_space) { - PERR("file system out of space"); + error("file system out of space"); } catch (Out_of_metadata) { - PERR("file system server out of metadata"); + error("file system server out of metadata"); } catch (Invalid_name) { - PERR("%s: invalid path", Path(file_name, dir_path).base()); + error(Path(file_name, dir_path), ": invalid path"); } catch (Name_too_long) { - PERR("%s: name too long", Path(file_name, dir_path).base()); + error(Path(file_name, dir_path), ": name too long"); } catch (...) { - PERR("cannot open log file %s", Path(file_name, dir_path).base()); + error("cannot open log file ", Path(file_name, dir_path)); throw; } diff --git a/repos/os/src/server/fs_log/session.h b/repos/os/src/server/fs_log/session.h index 665dbea31..823bd8439 100644 --- a/repos/os/src/server/fs_log/session.h +++ b/repos/os/src/server/fs_log/session.h @@ -67,7 +67,7 @@ class Fs_log::Unlabeled_session_component : public Session_component size_t write(Log_session::String const &msg) { if (!msg.valid_string()) { - PERR("corrupted string"); + Genode::error("corrupted string"); return 0; } @@ -104,7 +104,7 @@ class Fs_log::Labeled_session_component : public Session_component size_t write(Log_session::String const &msg) { if (!msg.valid_string()) { - PERR("corrupted string"); + Genode::error("corrupted string"); return 0; } diff --git a/repos/os/src/server/fs_rom/main.cc b/repos/os/src/server/fs_rom/main.cc index f0882b881..8128ee71f 100755 --- a/repos/os/src/server/fs_rom/main.cc +++ b/repos/os/src/server/fs_rom/main.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/repos/os/src/server/iso9660/backing_store.h b/repos/os/src/server/iso9660/backing_store.h index d30b43233..a25e37b1f 100644 --- a/repos/os/src/server/iso9660/backing_store.h +++ b/repos/os/src/server/iso9660/backing_store.h @@ -35,7 +35,7 @@ class Backing_store { virtual void detach_block(UMD umd) { - PWRN("this should never be called"); + Genode::warning(__func__, " this should never be called"); } }; @@ -187,7 +187,6 @@ class Backing_store /* skip blocks that are currently in the process of being assigned */ while (_curr_block()->user() == &_not_yet_assigned) { - PDBG("skipping not-yet assigned block"); _advance_curr_block(); } diff --git a/repos/os/src/server/iso9660/iso9660.cc b/repos/os/src/server/iso9660/iso9660.cc index ea576d74b..116e13199 100644 --- a/repos/os/src/server/iso9660/iso9660.cc +++ b/repos/os/src/server/iso9660/iso9660.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include #include -#include +#include #include #include #include @@ -63,12 +63,12 @@ namespace Iso { _p = _source->get_acked_packet(); if (!_p.succeeded()) { - PERR("Could not read block %lu", blk_nr); + Genode::error("Could not read block ", blk_nr); throw Io_error(); } } catch (Block::Session::Tx::Source::Packet_alloc_failed) { - PERR("Packet overrun!"); + Genode::error("packet overrun!"); _p = _source->get_acked_packet(); throw Io_error(); } @@ -331,9 +331,6 @@ namespace Iso { Sector sec(blk_nr, 1); Volume_descriptor *vol = sec.addr(); - if (verbose) - PDBG("Volume: type %u", vol->type()); - if (vol->primary()) return vol->copy_root_record(); @@ -353,8 +350,6 @@ namespace Iso { if (!root) throw Non_data_disc(); - if (verbose) - PDBG("Good root"); return root; } @@ -371,9 +366,6 @@ namespace Iso { unsigned long blk_count; unsigned long blk_nr = info->blk_nr() + (file_offset / Sector::blk_size()); - if (verbose) - PDBG("Read blk %lu count %lu, file_offset: %08lx length %u", blk_nr, total_blk_count, file_offset, length); - while ((blk_count = min(Sector::MAX_SECTORS, total_blk_count))) { Sector sec(blk_nr, blk_count); @@ -440,7 +432,7 @@ namespace Iso { Directory_record *tmp = sec.addr()->locate(level); if (!tmp && i == Sector::to_blk(dir->data_length()) - 1) { - PERR("File not found: %s", path); + Genode::error("file not found: ", Genode::Cstring(path)); throw File_not_found(); } @@ -449,9 +441,6 @@ namespace Iso { dir = tmp; current_blk_nr = dir->blk_nr(); - if (verbose) - PDBG("Found %s", level); - if (!dir->directory()) { blk_nr = current_blk_nr; data_length = dir->data_length(); @@ -466,13 +455,10 @@ namespace Iso { /* Warning: Don't access 'dir' after this point, since the sector is gone */ if (!blk_nr && !data_length) { - PERR("File not found: %s", path); + Genode::error("file not found: ", Genode::Cstring(path)); throw File_not_found(); } - if (verbose) - PDBG("Path: %s Block nr: %u Length: %u", path, blk_nr, data_length); - return new(env()->heap()) File_info(blk_nr, data_length); } diff --git a/repos/os/src/server/iso9660/main.cc b/repos/os/src/server/iso9660/main.cc index 847585001..e3bc4ab11 100644 --- a/repos/os/src/server/iso9660/main.cc +++ b/repos/os/src/server/iso9660/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -106,12 +106,12 @@ namespace Iso { Rom_component(char *path) { if ((_file = File::scan_cache(path))) { - PINF("cache hit for file %s", path); + Genode::log("cache hit for file ", Genode::Cstring(path)); return; } _file = new(env()->heap()) File(path); - PINF("request for file %s", path); + Genode::log("request for file ", Genode::Cstring(path)); File::cache()->insert(_file); } @@ -140,7 +140,7 @@ namespace Iso { strncpy(_path, label.last_element().string(), sizeof(_path)); if (verbose) - PDBG("Request for file %s lrn %zu", _path, strlen(_path)); + Genode::log("Request for file ", Cstring(_path), " len ", strlen(_path)); try { return new (md_alloc()) Rom_component(_path); diff --git a/repos/os/src/server/loader/child.h b/repos/os/src/server/loader/child.h index d1cde55dd..42d3ef469 100644 --- a/repos/os/src/server/loader/child.h +++ b/repos/os/src/server/loader/child.h @@ -98,7 +98,7 @@ namespace Loader { snprintf(args, sizeof(args), "ram_quota=4K, label=\"%s\"", name); return static_cap_cast(_local_rom_service.session(args, Affinity())); } catch (Genode::Parent::Service_denied) { - PERR("Lookup for ROM module \"%s\" failed", name); + Genode::error("Lookup for ROM module \"", name, "\" failed"); throw; } } diff --git a/repos/os/src/server/loader/nitpicker.h b/repos/os/src/server/loader/nitpicker.h index ebbb5f85d..80ac11d87 100644 --- a/repos/os/src/server/loader/nitpicker.h +++ b/repos/os/src/server/loader/nitpicker.h @@ -121,13 +121,13 @@ class Nitpicker::Session_component : public Genode::Rpc_object case Command::OP_TO_BACK: { - PDBG("OP_TO_BACK not implemented"); + Genode::warning("OP_TO_BACK not implemented"); return; } case Command::OP_BACKGROUND: { - PDBG("OP_BACKGROUND not implemented"); + Genode::warning("OP_BACKGROUND not implemented"); return; } diff --git a/repos/os/src/server/loader/rom.h b/repos/os/src/server/loader/rom.h index b33e66362..b6cdde8e2 100644 --- a/repos/os/src/server/loader/rom.h +++ b/repos/os/src/server/loader/rom.h @@ -73,7 +73,7 @@ namespace Genode { Rom_dataspace_capability fg_dataspace() { if (!_fg.size() && !_bg_has_pending_data) { - PERR("Error: no data loaded"); + Genode::error("no data loaded"); return Rom_dataspace_capability(); } diff --git a/repos/os/src/server/log_report/main.cc b/repos/os/src/server/log_report/main.cc index 15b32d3b9..59c61f45e 100644 --- a/repos/os/src/server/log_report/main.cc +++ b/repos/os/src/server/log_report/main.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/repos/os/src/server/log_terminal/main.cc b/repos/os/src/server/log_terminal/main.cc index ceaf8f8eb..6d4e5da7f 100644 --- a/repos/os/src/server/log_terminal/main.cc +++ b/repos/os/src/server/log_terminal/main.cc @@ -12,6 +12,7 @@ */ /* Genode includes */ +#include #include #include #include @@ -50,7 +51,7 @@ class Buffered_output _buf[_index] = 0; /* flush buffered characters to LOG */ - Genode::printf(_buf); + Genode::log(Genode::Cstring(_buf)); /* reset */ _index = 0; @@ -67,9 +68,10 @@ class Buffered_output for (unsigned i = 0; i < consume_bytes; i++) { char const c = src[i]; - _buf[_index++] = c; if (c == '\n') _flush(); + else + _buf[_index++] = c; } if (_remaining_capacity() == 0) diff --git a/repos/os/src/server/lx_fs/directory.h b/repos/os/src/server/lx_fs/directory.h index e95c5ee73..c9c2bf7a7 100644 --- a/repos/os/src/server/lx_fs/directory.h +++ b/repos/os/src/server/lx_fs/directory.h @@ -133,12 +133,12 @@ class File_system::Directory : public Node size_t read(char *dst, size_t len, seek_off_t seek_offset) { if (len < sizeof(Directory_entry)) { - PERR("read buffer too small for directory entry"); + Genode::error("read buffer too small for directory entry"); return 0; } if (seek_offset % sizeof(Directory_entry)) { - PERR("seek offset not aligned to sizeof(Directory_entry)"); + Genode::error("seek offset not aligned to sizeof(Directory_entry)"); return 0; } diff --git a/repos/os/src/server/lx_fs/main.cc b/repos/os/src/server/lx_fs/main.cc index 786c77c2b..b4c1b5f61 100644 --- a/repos/os/src/server/lx_fs/main.cc +++ b/repos/os/src/server/lx_fs/main.cc @@ -12,6 +12,7 @@ */ /* Genode includes */ +#include #include #include #include @@ -96,7 +97,7 @@ class File_system::Session_component : public Session_rpc_object _process_packet_op(packet, *node); } - catch (Invalid_handle) { PERR("Invalid_handle"); } + catch (Invalid_handle) { Genode::error("Invalid_handle"); } /* * The 'acknowledge_packet' function cannot block because we @@ -138,7 +139,7 @@ class File_system::Session_component : public Session_rpc_object static void _assert_valid_path(char const *path) { if (!path || path[0] != '/') { - PWRN("malformed path '%s'", path); + Genode::warning("malformed path '", path, "'"); throw Lookup_failed(); } } @@ -204,7 +205,7 @@ class File_system::Session_component : public Session_rpc_object Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create) { - PERR("%s not implemented", __func__); + Genode::error(__func__, " not implemented"); return Symlink_handle(); } @@ -270,19 +271,19 @@ class File_system::Session_component : public Session_rpc_object return s; } - PERR("%s for symlinks not implemented", __func__); + Genode::error(__func__, " for symlinks not implemented"); return Status(); } void control(Node_handle, Control) { - PERR("%s not implemented", __func__); + Genode::error(__func__, " not implemented"); } void unlink(Dir_handle, Name const &) { - PERR("%s not implemented", __func__); + Genode::error(__func__, " not implemented"); } void truncate(File_handle file_handle, file_size_t size) @@ -297,7 +298,7 @@ class File_system::Session_component : public Session_rpc_object void move(Dir_handle, Name const &, Dir_handle, Name const &) { - PERR("%s not implemented", __func__); + Genode::error(__func__, " not implemented"); } void sigh(Node_handle node_handle, Signal_context_capability sigh) @@ -310,7 +311,7 @@ class File_system::Session_component : public Session_rpc_object * reminder because besides testing, there is currently no * use-case. */ - void sync(Node_handle) override { PWRN("sync() not implemented!"); } + void sync(Node_handle) override { Genode::warning("sync() not implemented!"); } }; @@ -353,7 +354,8 @@ class File_system::Root : public Root_component * lookup, we remove all leading slashes. */ if (root[0] != '/') { - PERR("Root directory must start with / but is \"%s\"", root); + Genode::error("Root directory must start with / but is \"", + Genode::Cstring(root), "\""); throw Root::Unavailable(); } @@ -363,7 +365,7 @@ class File_system::Root : public Root_component if (*root_dir == 0) root_dir = "."; } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"root\" attribute in policy definition"); + Genode::error("missing \"root\" attribute in policy definition"); throw Root::Unavailable(); } @@ -373,7 +375,7 @@ class File_system::Root : public Root_component writeable = policy.attribute_value("writeable", false); } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("invalid session request, no matching policy"); throw Root::Unavailable(); } @@ -383,7 +385,7 @@ class File_system::Root : public Root_component Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) { - PERR("%s requested a session with a zero length transmission buffer", label.string()); + Genode::error(label, " requested a session with a zero length transmission buffer"); throw Root::Invalid_args(); } @@ -393,8 +395,8 @@ class File_system::Root : public Root_component */ size_t session_size = sizeof(Session_component) + tx_buf_size; if (max((size_t)4096, session_size) > ram_quota) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, session_size); + Genode::error("insufficient 'ram_quota', " + "got ", ram_quota, ", need ", session_size); throw Root::Quota_exceeded(); } @@ -402,7 +404,8 @@ class File_system::Root : public Root_component return new (md_alloc()) Session_component(tx_buf_size, _ep, root_dir, writeable, *md_alloc()); } catch (Lookup_failed) { - PERR("Session root directory \"%s\" does not exist", root); + Genode::error("session root directory \"", Genode::Cstring(root), "\" " + "does not exist"); throw Root::Unavailable(); } } diff --git a/repos/os/src/server/mixer/mixer.cc b/repos/os/src/server/mixer/mixer.cc index 088337c77..3fd777621 100644 --- a/repos/os/src/server/mixer/mixer.cc +++ b/repos/os/src/server/mixer/mixer.cc @@ -39,7 +39,13 @@ static bool verbose = false; -#define PLOGV(...) do { if (verbose) PLOG(__VA_ARGS__); } while (0) + +template +static inline void logv(ARGS&&... args) +{ + if (verbose) + Genode::log(args...); +} typedef Mixer::Channel Channel; @@ -235,7 +241,7 @@ class Audio_out::Mixer }); }); }); - } catch (...) { PWRN("could report current channels"); } + } catch (...) { Genode::warning("could report current channels"); } } /* @@ -426,12 +432,12 @@ class Audio_out::Mixer v = default_node.attribute_value("muted", 1); _default_muted = v ; - PLOGV("default settings: out_volume: %d volume: %d muted: %d", - (int)(MAX_VOLUME*_default_out_volume), - (int)(MAX_VOLUME*_default_volume), - _default_muted); + logv("default settings: " + "out_volume: ", (int)(MAX_VOLUME*_default_out_volume), " " + "volume: ", (int)(MAX_VOLUME*_default_volume), " " + "muted: ", _default_muted); - } catch (...) { PWRN("could not read mixer default values"); } + } catch (...) { Genode::warning("could not read mixer default values"); } } /** @@ -470,9 +476,10 @@ class Audio_out::Mixer session.volume = (float)ch.volume / MAX_VOLUME; session.muted = ch.muted; - PLOGV("label: '%s' nr: %d vol: %d muted: %d", - ch.label.string(), (int)ch.number, - (int)(MAX_VOLUME*session.volume), ch.muted); + logv("label: '", ch.label, "' " + "nr: ", (int)ch.number, " " + "vol: ", (int)(MAX_VOLUME*session.volume), " " + "muted: ", ch.muted); }); }); } @@ -482,13 +489,14 @@ class Audio_out::Mixer _out_volume[i] = (float)ch.volume / MAX_VOLUME; - PLOGV("label: '%s' nr: %d vol: %d muted: %d", - "master", (int)ch.number, - (int)(MAX_VOLUME*_out_volume[i]), ch.muted); + logv("label: 'master' " + "nr: ", (int)ch.number, " " + "vol: ", (int)(MAX_VOLUME*_out_volume[i]), " " + "muted: ", ch.muted); }); } }); - } catch (...) { PWRN("mixer channel_list was invalid"); } + } catch (...) { Genode::warning("mixer channel_list was invalid"); } /* * Report back any changes so a front-end can update its state @@ -557,10 +565,11 @@ class Audio_out::Mixer session.volume = _default_volume; session.muted = _default_muted; - PLOG("add label: \"%s\" channel: \"%s\" nr: %u volume: %d muted: %d", - session.label.string(), string_from_number(ch), ch, - (int)(MAX_VOLUME*session.volume), session.muted); - + log("add label: \"", session.label, "\" " + "channel: \"", string_from_number(ch), "\" " + "nr: ", (int)ch, " " + "volume: ", (int)(MAX_VOLUME*session.volume), " " + "muted: %d", session.muted); _channels[ch].insert(&session); _report_channels(); @@ -571,8 +580,9 @@ class Audio_out::Mixer */ void remove_session(Channel::Number ch, Session_elem &session) { - PLOG("remove label: \"%s\" channel: \"%s\" nr: %u", - session.label.string(), string_from_number(ch), ch); + log("remove label: \"", session.label, "\" " + "channel: \"", string_from_number(ch), "\" " + "nr: ", (int)ch); _channels[ch].remove(&session); _report_channels(); @@ -665,8 +675,8 @@ class Audio_out::Root : public Audio_out::Root_component if ((ram_quota < session_size) || (sizeof(Stream) > ram_quota - session_size)) { - PERR("insufficient 'ram_quota', got %zu, need %zu", - ram_quota, sizeof(Stream) + session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", sizeof(Stream) + session_size); throw Root::Quota_exceeded(); } @@ -714,7 +724,6 @@ struct Server::Main Main(Server::Entrypoint &ep) : ep(ep) { Genode::env()->parent()->announce(ep.manage(root)); - PINF("--- Mixer started ---"); } }; diff --git a/repos/os/src/server/nic_loopback/main.cc b/repos/os/src/server/nic_loopback/main.cc index 7adb339fb..14b903f29 100644 --- a/repos/os/src/server/nic_loopback/main.cc +++ b/repos/os/src/server/nic_loopback/main.cc @@ -125,7 +125,7 @@ void Nic::Loopback_component::_handle_packet_stream() /* obtain packet */ Packet_descriptor const packet_from_client = _tx.sink()->get_packet(); if (!packet_from_client.size()) { - PWRN("received zero-size packet"); + Genode::warning("received zero-size packet"); _rx.source()->release_packet(packet_to_client); continue; } @@ -170,8 +170,8 @@ class Nic::Root : public Genode::Root_component */ if (tx_buf_size + rx_buf_size < tx_buf_size || tx_buf_size + rx_buf_size > ram_quota - session_size) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, tx_buf_size + rx_buf_size + session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", tx_buf_size + rx_buf_size + session_size); throw Root::Quota_exceeded(); } diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index 0621e187c..7658ec573 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/repos/os/src/server/part_blk/driver.h b/repos/os/src/server/part_blk/driver.h index 9f412f42e..d02d94841 100644 --- a/repos/os/src/server/part_blk/driver.h +++ b/repos/os/src/server/part_blk/driver.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/repos/os/src/server/ram_blk/main.cc b/repos/os/src/server/ram_blk/main.cc index 52af03bd2..765dc525e 100644 --- a/repos/os/src/server/ram_blk/main.cc +++ b/repos/os/src/server/ram_blk/main.cc @@ -178,7 +178,7 @@ struct Main try { if (use_file) { Genode::log("Creating RAM-basd block device populated by file='", - (char const*)file, "' with block size ", block_size); + Genode::Cstring(file), "' with block size ", block_size); return new (&alloc) Ram_blk(env, alloc, file, block_size); } else { Genode::log("Creating RAM-based block device with size ", diff --git a/repos/os/src/server/ram_fs/main.cc b/repos/os/src/server/ram_fs/main.cc index 142c01f70..65f8d62e1 100644 --- a/repos/os/src/server/ram_fs/main.cc +++ b/repos/os/src/server/ram_fs/main.cc @@ -14,6 +14,7 @@ /* Genode includes */ #include #include +#include #include #include #include @@ -94,7 +95,7 @@ namespace File_system { _process_packet_op(packet, *node); } - catch (Invalid_handle) { PERR("Invalid_handle"); } + catch (Invalid_handle) { Genode::error("Invalid_handle"); } /* * The 'acknowledge_packet' function cannot block because we @@ -136,7 +137,7 @@ namespace File_system { static void _assert_valid_path(char const *path) { if (!path || path[0] != '/') { - PWRN("malformed path '%s'", path); + Genode::warning("malformed path ''", path, "'"); throw Lookup_failed(); } } @@ -459,10 +460,11 @@ namespace File_system { session_root_dir->unlock(); } } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"root\" attribute in policy definition"); + Genode::error("missing \"root\" attribute in policy definition"); throw Root::Unavailable(); } catch (Lookup_failed) { - PERR("Session root directory \"%s\" does not exist", root); + Genode::error("session root directory \"", + Genode::Cstring(root), "\" does not exist"); throw Root::Unavailable(); } @@ -472,7 +474,7 @@ namespace File_system { writeable = policy.attribute_value("writeable", false); } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("invalid session request, no matching policy"); throw Root::Unavailable(); } @@ -482,7 +484,7 @@ namespace File_system { Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) { - PERR("%s requested a session with a zero length transmission buffer", label.string()); + Genode::error(label, " requested a session with a zero length transmission buffer"); throw Root::Invalid_args(); } @@ -492,8 +494,8 @@ namespace File_system { */ size_t session_size = sizeof(Session_component) + tx_buf_size; if (max((size_t)4096, session_size) > ram_quota) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", session_size); throw Root::Quota_exceeded(); } return new (md_alloc()) @@ -548,13 +550,16 @@ struct Attribute_string } else { char type_name[16]; node.type_name(type_name, sizeof(type_name)); - PWRN("missing \"%s\" attribute in <%s> node", attr, type_name); + Genode::warning("missing \"", attr, "\" attribute in " + "<", Genode::Cstring(type_name), "> node"); throw Genode::Xml_node::Nonexistent_attribute(); } } } operator char * () { return buf; } + + void print(Genode::Output &out) const { Genode::print(out, Genode::Cstring(buf)); } }; @@ -602,9 +607,9 @@ static void preload_content(Genode::Allocator &alloc, dir.adopt_unsynchronized(file); } catch (Rom_connection::Rom_connection_failed) { - PWRN("failed to open ROM file \"%s\"", (char *)name); } + Genode::warning("failed to open ROM file \"", name, "\""); } catch (Rm_session::Attach_failed) { - PWRN("Could not locally attach ROM file \"%s\"", (char *)name); } + Genode::warning("Could not locally attach ROM file \"", name, "\""); } } /* diff --git a/repos/os/src/server/report_rom/rom_registry.h b/repos/os/src/server/report_rom/rom_registry.h index 0dcc2fe0d..2ae6fed3f 100644 --- a/repos/os/src/server/report_rom/rom_registry.h +++ b/repos/os/src/server/report_rom/rom_registry.h @@ -137,7 +137,7 @@ struct Rom::Registry : Registry_for_reader, Registry_for_writer, Genode::Noncopy catch (Session_policy::No_policy_defined) { } } - warning("no valid policy for ROM request '", rom_label.string(), "'"); + warning("no valid policy for ROM request '", rom_label, "'"); throw Root::Invalid_args(); } diff --git a/repos/os/src/server/rom_blk/main.cc b/repos/os/src/server/rom_blk/main.cc index 14a36bee3..5836963d5 100644 --- a/repos/os/src/server/rom_blk/main.cc +++ b/repos/os/src/server/rom_blk/main.cc @@ -102,13 +102,12 @@ struct Main } catch (...) { } - log("Using file=", file, " as device with block size ", - blk_sz, "."); + log("Using file=", file, " as device with block size ", blk_sz, "."); try { return new (&heap) Rom_blk(env, file, blk_sz); } catch(Rom_connection::Rom_connection_failed) { - error("Cannot open file ", file, "."); + error("cannot open file ", file); } throw Root::Unavailable(); } diff --git a/repos/os/src/server/rom_filter/input_rom_registry.h b/repos/os/src/server/rom_filter/input_rom_registry.h index 0911e5f34..11a386897 100644 --- a/repos/os/src/server/rom_filter/input_rom_registry.h +++ b/repos/os/src/server/rom_filter/input_rom_registry.h @@ -191,8 +191,8 @@ class Rom_filter::Input_rom_registry if (content_node.has_type(expected.string())) return _query_value(input_node.sub_node(), content_node); else - PWRN("top-level node <%s> missing in input ROM %s", - expected.string(), name().string()); + Genode::warning("top-level node <", expected, "> " + "missing in input ROM ", name()); } catch (...) { } diff --git a/repos/os/src/server/rom_filter/main.cc b/repos/os/src/server/rom_filter/main.cc index 8ecc6a0e5..123060351 100644 --- a/repos/os/src/server/rom_filter/main.cc +++ b/repos/os/src/server/rom_filter/main.cc @@ -266,7 +266,7 @@ void Rom_filter::Main::_evaluate_node(Xml_node node, Xml_generator &xml) condition_satisfied = true; } catch (Input_rom_registry::Nonexistent_input_value) { - PWRN("could not obtain input value for input %s", input_name.string()); + Genode::warning("could not obtain input value for input ", input_name); } } @@ -313,7 +313,7 @@ void Rom_filter::Main::_evaluate() Xml_node output = Genode::config()->xml_node().sub_node("output"); if (!output.has_attribute("node")) { - PERR("missing 'node' attribute in '' node"); + Genode::error("missing 'node' attribute in '' node"); return; } diff --git a/repos/os/src/server/rom_prefetcher/main.cc b/repos/os/src/server/rom_prefetcher/main.cc index 00ba310a0..a0e0d4e95 100644 --- a/repos/os/src/server/rom_prefetcher/main.cc +++ b/repos/os/src/server/rom_prefetcher/main.cc @@ -17,9 +17,10 @@ #include #include #include -#include +#include #include #include +#include #include #include #include @@ -125,10 +126,10 @@ int main(int argc, char **argv) try { Rom_connection rom(name); - PINF("prefetching ROM file %s", name); + log("prefetching ROM module ", Cstring(name)); prefetch_dataspace(rom.dataspace()); } catch (...) { - PERR("could not open ROM file %s", name); + error("could not open ROM module ", Cstring(name)); } /* proceed with next XML node */ diff --git a/repos/os/src/server/tar_rom/main.cc b/repos/os/src/server/tar_rom/main.cc index 646b2fa02..03969eefa 100755 --- a/repos/os/src/server/tar_rom/main.cc +++ b/repos/os/src/server/tar_rom/main.cc @@ -20,7 +20,8 @@ #include #include #include -#include +#include +#include #include #include @@ -115,7 +116,7 @@ class Rom_session_component : public Genode::Rpc_object } if (!file_found) { - PERR("couldn't find file '%s', empty result", _filename); + Genode::error("couldn't find file '", _filename, "', empty result"); return Genode::Ram_dataspace_capability(); } @@ -127,7 +128,7 @@ class Rom_session_component : public Genode::Rpc_object /* get content of file copied into dataspace and return */ _copy_content_to_dataspace(file_ds); } catch (...) { - PERR("couldn't allocate memory for file, empty result\n"); + Genode::error("couldn't allocate memory for file, empty result"); return file_ds; } @@ -186,7 +187,7 @@ class Rom_root : public Genode::Root_component Session_label const label = label_from_args(args); Session_label const module_name = label.last_element(); - PINF("connection for module '%s' requested", module_name.string()); + Genode::log("connection for module '", module_name, "' requested"); /* create new session for the requested file */ return new (md_alloc()) Rom_session_component(_tar_addr, _tar_size, @@ -225,7 +226,7 @@ int main(void) config()->xml_node().sub_node("archive"); archive_node.attribute("name").value(tar_filename, sizeof(tar_filename)); } catch (...) { - PERR("Could not read 'filename' argument from config"); + Genode::error("could not read 'filename' argument from config"); return -1; } @@ -237,11 +238,11 @@ int main(void) tar_base = env()->rm_session()->attach(tar_rom.dataspace()); tar_size = Dataspace_client(tar_rom.dataspace()).size(); } catch (...) { - PERR("Could not obtain tar archive from ROM service"); + Genode::error("could not obtain tar archive from ROM service"); return -2; } - PINF("using tar archive '%s' with size %zd", tar_filename, tar_size); + Genode::log("using tar archive '", Cstring(tar_filename), "' with size ", tar_size); /* connection to capability service needed to create capabilities */ static Cap_connection cap; diff --git a/repos/os/src/server/terminal_log/main.cc b/repos/os/src/server/terminal_log/main.cc index 59a0ef45a..e1ada7311 100644 --- a/repos/os/src/server/terminal_log/main.cc +++ b/repos/os/src/server/terminal_log/main.cc @@ -57,7 +57,7 @@ namespace Genode { size_t write(String const &string_buf) { if (!(string_buf.valid_string())) { - PERR("corrupted string"); + Genode::error("corrupted string"); return 0; } diff --git a/repos/os/src/server/trace_fs/directory.h b/repos/os/src/server/trace_fs/directory.h index fee792b1b..9e0c2c1a4 100644 --- a/repos/os/src/server/trace_fs/directory.h +++ b/repos/os/src/server/trace_fs/directory.h @@ -70,8 +70,6 @@ namespace File_system { */ void discard_unsynchronized(Node *node) { - /* PWRN("discard node '%s' from '%s'", node->name(), Node::name()); */ - _entries.remove(node); _num_entries--; @@ -165,14 +163,14 @@ namespace File_system { size_t read(char *dst, size_t len, seek_off_t seek_offset) { if (len < sizeof(Directory_entry)) { - PERR("read buffer too small for directory entry"); + Genode::error("read buffer too small for directory entry"); return 0; } seek_off_t index = seek_offset / sizeof(Directory_entry); if (seek_offset % sizeof(Directory_entry)) { - PERR("seek offset not alighed to sizeof(Directory_entry)"); + Genode::error("seek offset not alighed to sizeof(Directory_entry)"); return 0; } diff --git a/repos/os/src/server/trace_fs/file.h b/repos/os/src/server/trace_fs/file.h index 79fd7e72e..5fc335b7b 100644 --- a/repos/os/src/server/trace_fs/file.h +++ b/repos/os/src/server/trace_fs/file.h @@ -173,7 +173,7 @@ namespace File_system { if (seek_offset + len >= Chunk_level_0::SIZE) { len = (Chunk_level_0::SIZE-1) - seek_offset; - PERR("%s: size limit %d reached", name(), Chunk_level_0::SIZE); + Genode::error(name(), ": size limit ", (long)Chunk_level_0::SIZE, " reached"); } _chunk.write(src, len, (size_t)seek_offset); diff --git a/repos/os/src/server/trace_fs/main.cc b/repos/os/src/server/trace_fs/main.cc index 5c6c02f4c..15005f8bb 100644 --- a/repos/os/src/server/trace_fs/main.cc +++ b/repos/os/src/server/trace_fs/main.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -34,9 +35,6 @@ #include -static bool const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - /** * Return true if 'str' is a valid file name */ @@ -261,8 +259,6 @@ class Trace_file_system if (!manager) return; - PDBGV("update events for subject:'%s'", subject->name()); - Process_entry<512> process_entry; while (!manager->last_entry()) { @@ -272,7 +268,7 @@ class Trace_file_system continue; try { subject->events_file.append(process_entry.data(), len); } - catch (...) { PERR("could not write entry"); } + catch (...) { Genode::error("could not write entry"); } } if (manager->last_entry()) { @@ -287,14 +283,12 @@ class Trace_file_system */ void _disable_tracing(Followed_subject *subject) { - PDBGV("disable tracing of subject:'%s'", subject->name()); - subject->active_file.set_inactive(); _trace.pause(subject->id()); _gather_events(subject); try { subject->unmanage_trace_buffer(); } - catch (...) { PERR("trace buffer was not managed"); } + catch (...) { Genode::error("trace buffer was not managed"); } _trace.free(subject->id()); } @@ -305,18 +299,15 @@ class Trace_file_system */ void _enable_tracing(Followed_subject *subject) { - PDBGV("activate tracing of subject:'%s' with policy:'%u' and buffer_size:'%lu'", - subject->name(), subject->policy_id().id, subject->buffer_size_file.size()); - try { _trace.trace(subject->id().id, subject->policy_id().id, subject->buffer_size_file.size()); try { subject->manage_trace_buffer(_trace.buffer(subject->id())); } - catch (...) { PERR("trace buffer is already managed"); } + catch (...) { Genode::error("trace buffer is already managed"); } subject->active_file.set_active(); - } catch (...) { PERR("could not enable tracing"); } + } catch (...) { Genode::error("could not enable tracing"); } } /** @@ -335,16 +326,13 @@ class Trace_file_system Directory *child; - PDBGV("parent '%s' num_entries '%zu' lookup '%s'", parent.name(), - parent.num_entries(), walker.element()); - try { child = _node_to_directory(parent.lookup(walker.element())); } catch (File_system::Lookup_failed) { try { child = new (&_alloc) Directory(walker.element()); parent.adopt_unsynchronized(child); } catch (...) { - PERR("could not create '%s'", walker.element()); + Genode::error("could not create '", walker.element(), "'"); return 0; } } @@ -456,12 +444,12 @@ class Trace_file_system size_t n = policy_file->read((char *)ram, policy_length, 0UL); if (n != policy_length) { - PERR("error while copying policy content"); + Genode::error("error while copying policy content"); } else { subject->policy_id(id); } Genode::env()->rm_session()->detach(ram); } - } catch (...) { PERR("could not allocate policy"); } + } catch (...) { Genode::error("could not allocate policy"); } } policy_changed = true; @@ -522,9 +510,6 @@ class Trace_file_system Subject_info info = _trace.subject_info(subjects[i]); Subject_info::State state = info.state(); - PDBGV("subject:'%s.%u' state:'%u'", info.thread_name().string(), - subjects[i].id, state); - /* opt-out early */ switch (state) { case Subject_info::State::INVALID: @@ -563,7 +548,7 @@ class Trace_file_system Directory *parent = _find_parent_node(list, walker, _root_dir); if (!parent) { - PERR("could not find parent node for label:'%s'", label); + Genode::error("could not find parent node for label:'", label, "'"); continue; } @@ -598,7 +583,7 @@ class Trace_file_system Util::Label_walker walker(label); Directory *parent = _find_parent_node(list, walker, _root_dir); if (!parent) { - PERR("could not find parent node on creation"); + Genode::error("could not find parent node on creation"); continue; } @@ -647,7 +632,6 @@ class File_system::Session_component : public Session_rpc_object */ void _fs_update(unsigned) { - PDBGV("trace_fs update, limit:%d", _subject_limit); _trace_fs->update(_subject_limit); } @@ -699,7 +683,7 @@ class File_system::Session_component : public Session_rpc_object _process_packet_op(packet, *node); } - catch (Invalid_handle) { PERR("Invalid_handle"); } + catch (Invalid_handle) { Genode::error("Invalid_handle"); } /* * The 'acknowledge_packet' function cannot block because we @@ -741,7 +725,7 @@ class File_system::Session_component : public Session_rpc_object static void _assert_valid_path(char const *path) { if (!path || path[0] != '/') { - PWRN("malformed path '%s'", path); + Genode::warning("malformed path '", path, "'"); throw Lookup_failed(); } } @@ -827,7 +811,7 @@ class File_system::Session_component : public Session_rpc_object Symlink_handle symlink(Dir_handle dir_handle, Name const &name, bool create) { - PWRN("symlinks not supported"); + Genode::warning("symlinks not supported"); return Symlink_handle(); } @@ -867,7 +851,7 @@ class File_system::Session_component : public Session_rpc_object try { node = _handle_registry.lookup(handle); } catch (Invalid_handle) { - PERR("close() called with invalid handle"); + Genode::error("close() called with invalid handle"); return; } @@ -985,15 +969,16 @@ class File_system::Root : public Root_component if (root[0] != '/') throw Lookup_failed(); } catch (Xml_node::Nonexistent_attribute) { - PERR("Missing \"root\" attribute in policy definition"); + Genode::error("Missing \"root\" attribute in policy definition"); throw Root::Unavailable(); } catch (Lookup_failed) { - PERR("Session root directory \"%s\" does not exist", root); + Genode::error("session root directory " + "\"", Genode::Cstring(root), "\" does not exist"); throw Root::Unavailable(); } } catch (Session_policy::No_policy_defined) { - PERR("Invalid session request, no matching policy"); + Genode::error("Invalid session request, no matching policy"); throw Root::Unavailable(); } @@ -1003,7 +988,7 @@ class File_system::Root : public Root_component Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); if (!tx_buf_size) { - PERR("%s requested a session with a zero length transmission buffer", label.string()); + Genode::error(label, " requested a session with a zero length transmission buffer"); throw Root::Invalid_args(); } @@ -1013,8 +998,8 @@ class File_system::Root : public Root_component */ size_t session_size = sizeof(Session_component) + tx_buf_size; if (max((size_t)4096, session_size) > ram_quota) { - PERR("insufficient 'ram_quota', got %zd, need %zd", - ram_quota, session_size); + Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " + "need ", session_size); throw Root::Quota_exceeded(); } return new (md_alloc()) diff --git a/repos/os/src/server/trace_fs/trace_files.h b/repos/os/src/server/trace_fs/trace_files.h index 2cc9a84cb..da2311701 100644 --- a/repos/os/src/server/trace_fs/trace_files.h +++ b/repos/os/src/server/trace_fs/trace_files.h @@ -323,7 +323,7 @@ namespace File_system { size_t read(char *dst, size_t len, seek_off_t seek_offset) { if (len > 32) { - PERR("len:'%zu' to small", len); + Genode::error("len:'", len, "' to small"); return 0; } diff --git a/repos/os/src/server/tz_vmm/block.cc b/repos/os/src/server/tz_vmm/block.cc index bb13863ca..0a41a1605 100644 --- a/repos/os/src/server/tz_vmm/block.cc +++ b/repos/os/src/server/tz_vmm/block.cc @@ -237,7 +237,7 @@ class Device_registry Device_registry() { try { _init(); } - catch(...) { PERR("blk: config parsing error"); } + catch(...) { Genode::error("blk: config parsing error"); } } public: @@ -353,7 +353,7 @@ void Vmm::Block::_name(Vm_base * const vm) strncpy((char *)_buf, dev->name(), _buf_size); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); } } @@ -366,7 +366,7 @@ void Vmm::Block::_block_count(Vm_base * const vm) vm->smc_ret(dev->block_count()); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(0); } } @@ -380,7 +380,7 @@ void Vmm::Block::_block_size(Vm_base * const vm) vm->smc_ret(dev->block_size()); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(0); } } @@ -394,7 +394,7 @@ void Vmm::Block::_queue_size(Vm_base * const vm) vm->smc_ret(dev->session()->tx()->bulk_buffer_size()); return; - } catch (Device_registry::Bad_device_id) { PERR("Bad block device ID"); } + } catch (Device_registry::Bad_device_id) { Genode::error("bad block device ID"); } vm->smc_ret(0); } @@ -407,7 +407,7 @@ void Vmm::Block::_writeable(Vm_base * const vm) vm->smc_ret(dev->writeable()); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(0); } } @@ -421,7 +421,7 @@ void Vmm::Block::_irq(Vm_base * const vm) vm->smc_ret(dev->irq()); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(0); } } @@ -440,7 +440,7 @@ void Vmm::Block::_buffer(Vm_base * const vm) buf_err |= buf_base < ram->base(); buf_err |= buf_top >= ram_top; if (buf_err) { - PERR("Illegal block buffer constraints"); + Genode::error("illegal block buffer constraints"); return; } addr_t const buf_off = buf_base - ram->base(); @@ -472,15 +472,15 @@ void Vmm::Block::_new_request(Vm_base * const vm) vm->smc_ret((long)addr, p.offset()); } catch (Request_cache::Full) { - PERR("Block request cache full"); + Genode::error("block request cache full"); vm->smc_ret(0, 0); } catch (::Block::Session::Tx::Source::Packet_alloc_failed) { - PERR("Failed to allocate packet for block request"); + Genode::error("failed to allocate packet for block request"); vm->smc_ret(0, 0); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(0, 0); } } @@ -513,10 +513,10 @@ void Vmm::Block::_submit_request(Vm_base * const vm) dev->session()->tx()->submit_packet(p); } catch (Oversized_request) { - PERR("Oversized block request"); + Genode::error("oversized block request"); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); } } @@ -556,11 +556,11 @@ void Vmm::Block::_collect_reply(Vm_base * const vm) vm->smc_ret(1); } catch (Oversized_request) { - PERR("Oversized block request"); + Genode::error("oversized block request"); vm->smc_ret(-1); } catch (Device_registry::Bad_device_id) { - PERR("Bad block device ID"); + Genode::error("bad block device ID"); vm->smc_ret(-1); } } @@ -596,7 +596,7 @@ void Vmm::Block::handle(Vm_base * const vm) case BUFFER: _buffer(vm); break; case NAME: _name(vm); break; default: - PERR("Unknown function %lu requested on VMM block", vm->smc_arg_1()); + Genode::error("Unknown function ", vm->smc_arg_1(), " requested on VMM block"); break; } } diff --git a/repos/os/src/server/tz_vmm/include/mmu.h b/repos/os/src/server/tz_vmm/include/mmu.h index 4b72cc8f1..e7231e485 100644 --- a/repos/os/src/server/tz_vmm/include/mmu.h +++ b/repos/os/src/server/tz_vmm/include/mmu.h @@ -62,7 +62,7 @@ class Mmu Genode::addr_t _supersection(Genode::addr_t fe, Genode::addr_t va) { - PWRN("Not implemented yet!"); + Genode::warning(__func__, " not implemented yet!"); return 0; } diff --git a/repos/os/src/server/tz_vmm/include/vm_base.h b/repos/os/src/server/tz_vmm/include/vm_base.h index ad27b5383..65b5d76a0 100644 --- a/repos/os/src/server/tz_vmm/include/vm_base.h +++ b/repos/os/src/server/tz_vmm/include/vm_base.h @@ -15,6 +15,7 @@ #define _SRC__SERVER__VMM__INCLUDE__VM_H_ /* Genode includes */ +#include #include #include #include diff --git a/repos/os/src/server/tz_vmm/serial.cc b/repos/os/src/server/tz_vmm/serial.cc index e6e3a4ac5..15bbda38e 100644 --- a/repos/os/src/server/tz_vmm/serial.cc +++ b/repos/os/src/server/tz_vmm/serial.cc @@ -28,7 +28,7 @@ void Serial::_push(char const c) void Serial::_flush() { _push(0); - printf("[vm] %s\n", local_addr()); + log("[vm] ", local_addr()); _off = 0; } @@ -48,7 +48,7 @@ void Serial::handle(Vm_base * const vm) switch (vm->smc_arg_1()) { case SEND: _send(vm); break; default: - PERR("Unknown function %lu requested on VMM serial", vm->smc_arg_1()); + Genode::error("Unknown function ", vm->smc_arg_1(), " requested on VMM serial"); break; } } diff --git a/repos/os/src/server/tz_vmm/spec/imx53/main.cc b/repos/os/src/server/tz_vmm/spec/imx53/main.cc index 2229ae1a7..86d6caa8e 100644 --- a/repos/os/src/server/tz_vmm/spec/imx53/main.cc +++ b/repos/os/src/server/tz_vmm/spec/imx53/main.cc @@ -71,7 +71,7 @@ class Vmm::Vmm : public Thread_deprecated<8192> case SERIAL: _serial.handle(_vm); break; case BLOCK: _block.handle(_vm); break; default: - PERR("Unknown hypervisor call!"); + Genode::error("unknown hypervisor call!"); _vm->dump(); }; } @@ -88,7 +88,7 @@ class Vmm::Vmm : public Thread_deprecated<8192> switch (_vm->state()->cpu_exception) { case Cpu_state::DATA_ABORT: if (!_handle_data_abort()) { - PERR("Could not handle data-abort will exit!"); + Genode::error("could not handle data-abort will exit!"); return false; } break; @@ -96,7 +96,7 @@ class Vmm::Vmm : public Thread_deprecated<8192> _handle_hypervisor_call(); break; default: - PERR("Curious exception occured"); + Genode::error("curious exception occured"); _vm->dump(); return false; } @@ -118,7 +118,7 @@ class Vmm::Vmm : public Thread_deprecated<8192> if (_handle_vm()) _vm->run(); } else { - PWRN("Invalid context"); + Genode::warning("invalid context"); continue; } on_vmm_exit(); @@ -146,7 +146,7 @@ int main() KERNEL_OFFSET, MACH_TYPE_QSB); static Vmm::Vmm vmm(&vm); - PINF("Start virtual machine ..."); + Genode::log("Start virtual machine ..."); vmm.start(); sleep_forever(); diff --git a/repos/os/src/server/vfs/main.cc b/repos/os/src/server/vfs/main.cc index dd8522ffd..546d18027 100644 --- a/repos/os/src/server/vfs/main.cc +++ b/repos/os/src/server/vfs/main.cc @@ -13,6 +13,7 @@ /* Genode includes */ #include +#include #include #include #include @@ -39,7 +40,7 @@ namespace Vfs_server { { try { return Genode::config()->xml_node().sub_node("vfs"); } catch (...) { - Genode::error("vfs not configured"); + Genode::error("VFS not configured"); Genode::env()->parent()->exit(~0); Genode::sleep_forever(); } diff --git a/repos/os/src/server/vfs/node.h b/repos/os/src/server/vfs/node.h index b017edb69..52c45ea21 100644 --- a/repos/os/src/server/vfs/node.h +++ b/repos/os/src/server/vfs/node.h @@ -111,7 +111,7 @@ struct Vfs_server::Symlink : Node size_t write(Vfs::File_system &vfs, char const *src, size_t len, seek_off_t seek_offset) { /* ensure symlink gets something null-terminated */ - Genode::String target(src, len); + Genode::String target(Genode::Cstring(src, len)); if (vfs.symlink(target.string(), path()) == Directory_service::SYMLINK_OK) return 0; diff --git a/repos/os/src/server/vmm/main.cc b/repos/os/src/server/vmm/main.cc index 44f11cb37..a5f757484 100644 --- a/repos/os/src/server/vmm/main.cc +++ b/repos/os/src/server/vmm/main.cc @@ -165,7 +165,7 @@ class Vm { Exception() : Exception("undefined") {} - void print() { PERR("%s", _buf); } + void print() { Genode::error(Genode::Cstring(_buf)); } }; @@ -177,7 +177,9 @@ class Vm { _ram(RAM_ADDRESS, ram_size, (Genode::addr_t)_vm_ram.local_addr()), _state((State*)Genode::env()->rm_session()->attach(_vm_con.cpu_state())) { - PINF("ram is at %lx", Genode::Dataspace_client(_vm_ram.cap()).phys_addr()); + Genode::log("ram is at ", + Genode::Hex(Genode::Dataspace_client(_vm_ram.cap()).phys_addr())); + _vm_con.exception_handler(sig_cap); _vm_con.attach(_vm_ram.cap(), RAM_ADDRESS); _vm_con.attach_pic(0x2C002000); @@ -203,7 +205,7 @@ class Vm { _state->gic_lr[2] = 0; _state->gic_lr[3] = 0; - PINF("ready to run"); + Genode::log("ready to run"); } void run() { if (_active) _vm_con.run(); } @@ -366,12 +368,14 @@ class Vmm if (reg) reg = reg->find_by_encoding(Iss::mask_encoding(v)); if (!reg) { - PERR("Unknown cp15 access @ ip=%08lx:", state->ip); - PERR("%s: c15 %d r%d c%d c%d %d", - Iss::Direction::get(v) ? "read" : "write", - Iss::Opcode1::get(v), Iss::Register::get(v), - Iss::Crn::get(v), Iss::Crm::get(v), - Iss::Opcode2::get(v)); + Genode::error("unknown cp15 access @ ip=", state->ip, ":"); + Genode::error(Iss::Direction::get(v) ? "read" : "write", + ": " + "c15 ", Iss::Opcode1::get(v), " " + "r", Iss::Register::get(v), " " + "c", Iss::Crn::get(v), " " + "c", Iss::Crm::get(v), " ", + Iss::Opcode2::get(v)); return false; } @@ -379,8 +383,8 @@ class Vmm *(state->r(Iss::Register::get(v))) = reg->read(state); } else { /* write access */ if (!reg->writeable()) { - PERR("Writing to cp15 register %s not allowed!", - reg->name()); + Genode::error("writing to cp15 register ", + reg->name(), " not allowed!"); return false; } reg->write(state, *(state->r(Iss::Register::get(v)))); @@ -814,7 +818,7 @@ class Vmm _irqs[irq].cpu_state = Irq::PENDING; if (_irqs[irq].distr_state == Irq::DISABLED) { - PWRN("Disabled irq %u injected", irq); + Genode::warning("disabled irq ", irq, " injected"); return; } @@ -1316,7 +1320,7 @@ int main() static Vmm vmm; try { - PINF("Start virtual machine ..."); + Genode::log("Start virtual machine ..."); vmm.run(); } catch(Vm::Exception &e) { e.print(); diff --git a/repos/os/src/test/audio_out/main.cc b/repos/os/src/test/audio_out/main.cc index 55a0d01f1..d105e0b6f 100644 --- a/repos/os/src/test/audio_out/main.cc +++ b/repos/os/src/test/audio_out/main.cc @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include #include @@ -73,15 +73,15 @@ class Track : Thread_deprecated<8192> base = env()->rm_session()->attach(ds_cap); } catch (...) { - PDBG("Error: Could not open: %s", _file); + error("could not open: ", _file); return; } Dataspace_client ds_client(ds_cap); if (verbose) - PDBG("%s size is %zu Bytes (attached to %p)", - _file, ds_client.size(), base); + log(_file, " size is ", ds_client.size(), " bytes " + "(attached to ", (void *)base, ")"); size_t file_size = ds_client.size(); for (int i = 0; i < CHN_CNT; ++i) @@ -131,14 +131,14 @@ class Track : Thread_deprecated<8192> } if (verbose) - PDBG("%s submit packet %u", _file, - _audio_out[0]->stream()->packet_position((p[0]))); + log(_file, " submit packet ", + _audio_out[0]->stream()->packet_position((p[0]))); for (int i = 0; i < CHN_CNT; i++) _audio_out[i]->submit(p[i]); } - PLOG("played '%s' %u time(s)", _file, ++cnt); + log("played '", _file, "' ", ++cnt, " time(s)"); } } @@ -162,14 +162,14 @@ static int process_config(const char ***files) for (unsigned i = 0; i < config_node.num_sub_nodes(); ++i) { if (!(i < MAX_FILES)) { - PWRN("Test supports max %d files. Skipping...", MAX_FILES); + warning("test supports max ", (int)MAX_FILES, " files. Skipping..."); break; } Xml_node file_node = config_node.sub_node(i); if (!config_node.has_type("config")) { - printf("Error: Root node of config file is not a tag.\n"); + error("root node of config file is not a tag"); return -1; } @@ -188,7 +188,7 @@ static int process_config(const char ***files) int main(int argc, char **argv) { - PDBG("--- Audio_out test ---\n"); + log("--- Audio_out test ---"); const char *defaults[] = { "1.raw", "2.raw" }; const char **files = defaults; @@ -198,7 +198,7 @@ int main(int argc, char **argv) cnt = process_config(&files); } catch (...) { - PWRN("Couldn't get input files, failing back to defaults"); + warning("couldn't get input files, failing back to defaults"); } Track *track[cnt]; diff --git a/repos/os/src/test/audio_out_click/main.cc b/repos/os/src/test/audio_out_click/main.cc index b2a1948a6..413a205cc 100644 --- a/repos/os/src/test/audio_out_click/main.cc +++ b/repos/os/src/test/audio_out_click/main.cc @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include #include @@ -68,7 +68,7 @@ class Click ds_cap = rom.dataspace(); _base = env()->rm_session()->attach(ds_cap); } catch (...) { - PDBG("Error: Could not open: %s", file); + error("could not open: ", file); return; } @@ -78,7 +78,7 @@ class Click void play() { - PLOG("play click"); + log("play click"); for (int i = 0; i < CHANNELS; i++) _audio_out[i]->stream()->reset(); @@ -129,7 +129,7 @@ class Click int main(int argc, char **argv) { - PDBG("--- Audio_out click test ---\n"); + log("--- Audio_out click test ---"); Genode::Signal_context sig_ctx; Genode::Signal_receiver sig_rec; diff --git a/repos/os/src/test/blk/bench/main.cc b/repos/os/src/test/blk/bench/main.cc index 29f51bdf1..8d1f2bcc7 100644 --- a/repos/os/src/test/blk/bench/main.cc +++ b/repos/os/src/test/blk/bench/main.cc @@ -77,7 +77,8 @@ class Test::Throughput Block::Packet_descriptor p = _session.tx()->get_acked_packet(); if (!p.succeeded()) - PERR("Packet error: block: %llu count: %zu", p.block_number(), p.block_count()); + error("packet error: block: ", p.block_number(), " " + "count: ", p.block_count()); if (!_read_done || (_read_done && p.operation() == Block::Packet_descriptor::WRITE)) _bytes += p.size(); @@ -133,8 +134,8 @@ class Test::Throughput Block::Session::Operations blk_ops; _session.info(&_blk_count, &_blk_size, &blk_ops); - PWRN("block count %llu size %zu", _blk_count, _blk_size); - PINF("read/write %u KB ...", TEST_SIZE / 1024); + warning("block count ", _blk_count, " size ", _blk_size); + log("read/write ", TEST_SIZE / 1024, " KB ..."); _start = _timer.elapsed_ms(); _submit(); } diff --git a/repos/os/src/test/blk/cli/main.cc b/repos/os/src/test/blk/cli/main.cc index 53767b4c6..02fc7a426 100644 --- a/repos/os/src/test/blk/cli/main.cc +++ b/repos/os/src/test/blk/cli/main.cc @@ -47,18 +47,18 @@ class Test virtual void print_error() { - Genode::error("couldn't ", _write ? "write" : "read", - " block ", _nr, " - ", _nr+_cnt); + Genode::error("couldn't ", _write ? "write" : "read", " " + "block ", _nr, " - ", _nr+_cnt); } }; struct Submit_queue_full : Exception { void print_error() { - Genode::error("The submit queue is full!"); } }; + Genode::error("submit queue is full!"); } }; struct Timeout : Exception { void print_error() { - Genode::error("Test timed out!"); } }; + Genode::error("test timed out!"); } }; virtual void perform() = 0; virtual void ack_avail() = 0; @@ -175,7 +175,7 @@ struct Write_test : Test { struct Invalid_dimensions : Exception { void print_error() { - Genode::error("Invalid bulk buffer, or batch size!"); } }; + Genode::error("invalid bulk buffer, or batch size!"); } }; struct Integrity_exception : Block_exception { @@ -184,7 +184,7 @@ struct Write_test : Test void print_error() { - Genode::error("Integrity check failed: block ", _nr, " - ", + Genode::error("integrity check failed: block ", _nr, " - ", _nr+_cnt); } }; @@ -323,7 +323,7 @@ struct Violation_test : Test void print_error() { - Genode::error("Range check failed: access to block ", _nr, + Genode::error("range check failed: access to block ", _nr, " - ", _nr+_cnt, " succeeded"); } }; @@ -427,9 +427,9 @@ void Component::construct(Genode::Env &env) log("Tests finished successfully!"); } catch(Genode::Parent::Service_denied) { - error("Opening block session was denied!"); + error("opening block session was denied!"); } catch(Test::Exception &e) { - error("Test failed!"); + error("test failed!"); e.print_error(); } } diff --git a/repos/os/src/test/bomb/main.cc b/repos/os/src/test/bomb/main.cc index 35b4e606d..3437bc7f3 100644 --- a/repos/os/src/test/bomb/main.cc +++ b/repos/os/src/test/bomb/main.cc @@ -116,7 +116,7 @@ class Bomb_child : private Bomb_child_resources, _entrypoint.activate(); } - ~Bomb_child() { PLOG("%s", __PRETTY_FUNCTION__); } + ~Bomb_child() { Genode::log(__PRETTY_FUNCTION__); } /**************************** @@ -257,7 +257,7 @@ int main(int argc, char **argv) unsigned const sleeptime = node.attribute_value("sleep", 2000U); unsigned long const demand = node.attribute_value("demand", 1024UL * 1024); - printf("--- bomb started ---\n"); + log("--- bomb started ---"); /* connect to core's cap service used for creating parent capabilities */ Cap_connection cap; @@ -273,12 +273,11 @@ int main(int argc, char **argv) unsigned long avail = env()->ram_session()->avail(); unsigned long amount = (avail - demand) / children; if (amount < (demand * children)) { - PLOG("I'm a leaf node - generation %u - not enough memory.", - generation); + log("I'm a leaf node - generation ", generation, " - not enough memory."); sleep_forever(); } if (generation == 0) { - PLOG("I'm a leaf node - generation 0"); + log("I'm a leaf node - generation 0"); sleep_forever(); } @@ -298,7 +297,7 @@ int main(int argc, char **argv) } timer()->msleep(sleeptime); - PINF("[%03d] It's time to kill all my children...", round); + log("[", round, "] It's time to kill all my children..."); while (1) { Bomb_child *c; @@ -312,12 +311,12 @@ int main(int argc, char **argv) else break; } - PINF("[%03d] Done.", round); + log("[", round, "] Done."); } /* master if we have a timer connection */ if (timer()) - PINF("Done. Going to sleep"); + log("Done. Going to sleep"); sleep_forever(); return 0; diff --git a/repos/os/src/test/clipboard/main.cc b/repos/os/src/test/clipboard/main.cc index e510f4ae3..a3ae8b2b7 100644 --- a/repos/os/src/test/clipboard/main.cc +++ b/repos/os/src/test/clipboard/main.cc @@ -87,7 +87,7 @@ class Subsystem { char buf[Label::capacity()]; Genode::snprintf(buf, sizeof(buf), "%s -> clipboard", _name.string()); - return Label(buf); + return Label(Genode::Cstring(buf)); } Genode::Attached_rom_dataspace _import_rom; @@ -101,7 +101,7 @@ class Subsystem static void _log_lines(char const *string, Genode::size_t len) { Genode::print_lines<200>(string, len, - [&] (char const *line) { PLOG(" %s", line); }); + [&] (char const *line) { Genode::log(" ", line); }); } void _handle_import(unsigned) @@ -111,7 +111,7 @@ class Subsystem throw Unexpected_clipboard_import(); } - PLOG("\n%s: import new content:", _name.string()); + log("\n", _name, ": import new content:"); _import_rom.update(); @@ -182,7 +182,7 @@ class Subsystem }); }); - PLOG("\n%s: export content:", _name.string()); + log("\n", _name, ": export content:"); _log_lines(_export_report_ds.local_addr(), xml.used()); _export_report.submit(xml.used()); @@ -264,13 +264,13 @@ struct Server::Main : Handle_step_fn void _enter_state(State state) { - PINF("\n-> entering state %s", _state_name(state)); + log("\n-> entering state ", _state_name(state)); _state = state; } void handle_step(unsigned cnt) override { - PLOG("\n -- state %s --", _state_name(_state)); + log("\n -- state ", _state_name(_state), " --"); char const * const cat_picture = "cat picture"; char const * const private_key = "private key"; diff --git a/repos/os/src/test/config_args/main.cc b/repos/os/src/test/config_args/main.cc index 16d1285b6..24b809346 100644 --- a/repos/os/src/test/config_args/main.cc +++ b/repos/os/src/test/config_args/main.cc @@ -12,31 +12,31 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include using namespace Genode; int main(int argc, char **argv) { - printf("--- config args test started ---\n"); + log("--- config args test started ---"); if (argc != 2) { - PERR("Error: argc is not as expected"); + error("argc is not as expected"); return -1; } if (strcmp(argv[0], "test-config_args") != 0) { - PERR("Error: argv[0] is not as expected"); + error("argv[0] is not as expected"); return -1; } if (strcmp(argv[1], "-testarg") != 0) { - PERR("Error: argv[1] is not as expected"); + error("argv[1] is not as expected"); return -1; } - printf("--- end of config args test ---\n"); + log("--- end of config args test ---"); return 0; } diff --git a/repos/os/src/test/cpufreq/main.cc b/repos/os/src/test/cpufreq/main.cc index 7a40ac945..f092518b8 100644 --- a/repos/os/src/test/cpufreq/main.cc +++ b/repos/os/src/test/cpufreq/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -24,7 +24,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- test-cpufreq started ---\n"); + log("--- test-cpufreq started ---"); static Timer::Connection timer; static Regulator::Connection cpu_regulator(Regulator::CLK_CPU); @@ -32,7 +32,7 @@ int main(int argc, char **argv) while (true) { timer.msleep(10000); - PINF("Setting CPU frequency %s", high ? "low" : "high"); + log("Setting CPU frequency ", high ? "low" : "high"); cpu_regulator.level(high ? Regulator::CPU_FREQ_200 : Regulator::CPU_FREQ_1600); high = !high; diff --git a/repos/os/src/test/dynamic_config/main.cc b/repos/os/src/test/dynamic_config/main.cc index 86deb6979..b680fceb3 100644 --- a/repos/os/src/test/dynamic_config/main.cc +++ b/repos/os/src/test/dynamic_config/main.cc @@ -20,10 +20,10 @@ void parse_config() try { long counter = 1; Genode::config()->xml_node().sub_node("counter").value(&counter); - Genode::printf("obtained counter value %ld from config\n", counter); + Genode::log("obtained counter value ", counter, " from config"); } catch (...) { - PERR("Error while parsing the configuration"); + Genode::error("could not parse configuration"); } } diff --git a/repos/os/src/test/dynamic_config/server/main.cc b/repos/os/src/test/dynamic_config/server/main.cc index 2a1c61d8a..4d9d9920b 100644 --- a/repos/os/src/test/dynamic_config/server/main.cc +++ b/repos/os/src/test/dynamic_config/server/main.cc @@ -79,7 +79,7 @@ class Rom_session_component : public Genode::Rpc_object Genode::Lock::Guard guard(_lock); if (!_fg.size() && !_bg_has_pending_data) { - PERR("Error: no data loaded"); + Genode::error("no data loaded"); return Genode::Rom_dataspace_capability(); } diff --git a/repos/os/src/test/fault_detection/main.cc b/repos/os/src/test/fault_detection/main.cc index 0b0b9d394..48f28efdb 100644 --- a/repos/os/src/test/fault_detection/main.cc +++ b/repos/os/src/test/fault_detection/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -34,9 +34,9 @@ static void wait_for_signal_for_context(Genode::Signal_receiver &sig_rec, Genode::Signal s = sig_rec.wait_for_signal(); if (s.num() && s.context() == &sig_ctx) { - PLOG("got exception for child"); + Genode::log("got exception for child"); } else { - PERR("got unexpected signal while waiting for child"); + Genode::error("got unexpected signal while waiting for child"); class Unexpected_signal { }; throw Unexpected_signal(); } @@ -139,7 +139,7 @@ void faulting_child_test() { using namespace Genode; - printf("-- exercise failure detection of immediate child --\n"); + log("-- exercise failure detection of immediate child --"); /* * Entry point used for serving the parent interface @@ -160,12 +160,12 @@ void faulting_child_test() */ for (int i = 0; i < 5; i++) { - PLOG("create child %d", i); + log("create child ", i); /* create and start child process */ Test_child child(ep, "test-segfault", sig_rec.manage(&sig_ctx)); - PLOG("wait_for_signal"); + log("wait_for_signal"); wait_for_signal_for_context(sig_rec, sig_ctx); @@ -179,7 +179,7 @@ void faulting_child_test() */ } - printf("\n"); + log(""); } @@ -191,7 +191,7 @@ void faulting_loader_child_test() { using namespace Genode; - printf("-- exercise failure detection of loaded child --\n"); + log("-- exercise failure detection of loaded child --"); /* * Signal receiver and signal context for receiving faults originating from @@ -202,7 +202,7 @@ void faulting_loader_child_test() for (int i = 0; i < 5; i++) { - PLOG("create loader session %d", i); + log("create loader session ", i); Loader::Connection loader(1024*1024); @@ -217,7 +217,7 @@ void faulting_loader_child_test() sig_rec.dissolve(&sig_ctx); } - printf("\n"); + log(""); } @@ -229,7 +229,7 @@ void faulting_loader_grand_child_test() { using namespace Genode; - printf("-- exercise failure detection of loaded grand child --\n"); + log("-- exercise failure detection of loaded grand child --"); /* * Signal receiver and signal context for receiving faults originating from @@ -240,7 +240,7 @@ void faulting_loader_grand_child_test() for (int i = 0; i < 5; i++) { - PLOG("create loader session %d", i); + log("create loader session ", i); Loader::Connection loader(2024*1024); @@ -284,7 +284,7 @@ void faulting_loader_grand_child_test() sig_rec.dissolve(&sig_ctx); } - printf("\n"); + log(""); } @@ -296,7 +296,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- fault_detection test started ---\n"); + log("--- fault_detection test started ---"); faulting_child_test(); @@ -304,7 +304,7 @@ int main(int argc, char **argv) faulting_loader_grand_child_test(); - printf("--- finished fault_detection test ---\n"); + log("--- finished fault_detection test ---"); return 0; } diff --git a/repos/os/src/test/framebuffer/main.cc b/repos/os/src/test/framebuffer/main.cc index 54a9ac1b8..29992b61a 100644 --- a/repos/os/src/test/framebuffer/main.cc +++ b/repos/os/src/test/framebuffer/main.cc @@ -139,8 +139,7 @@ void Test_environment::_mode_handle() _fb_ds.construct(_fb.dataspace()); - Genode::log("framebuffer is ", _mode.width(), "x", _mode.height(), - "@", (int)_mode.format()); + Genode::log("framebuffer is ", _mode); if (_mode.bytes_per_pixel() != 2) { Genode::error("pixel format not supported"); diff --git a/repos/os/src/test/gpio_led/main.cc b/repos/os/src/test/gpio_led/main.cc index cb0379ddc..2b804f0a9 100644 --- a/repos/os/src/test/gpio_led/main.cc +++ b/repos/os/src/test/gpio_led/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -38,20 +38,21 @@ int main(int, char **) Genode::config()->xml_node().attribute("times").value(&_times); } catch (...) { } - PDBG("--- GPIO Led test [GPIO Pin: %d, Timer delay: %d, Times: %d] ---",_gpio_pin, _delay, _times); + Genode::log("--- GPIO Led test [GPIO Pin: ", _gpio_pin, ", " + "Timer delay: ", _delay, ", Times: ", _times, "] ---"); Gpio::Connection _led(_gpio_pin); Timer::Connection _timer; while(_times--) { - PDBG("Remains blinks: %d",_times); + Genode::log("Remains blinks: ",_times); _led.write(false); _timer.msleep(_delay); _led.write(true); _timer.msleep(_delay); } - Genode::printf("Test finished\n"); + Genode::log("Test finished"); return 0; } diff --git a/repos/os/src/test/gpio_signal/main.cc b/repos/os/src/test/gpio_signal/main.cc index 33bcc83d1..5d9e525b5 100644 --- a/repos/os/src/test/gpio_signal/main.cc +++ b/repos/os/src/test/gpio_signal/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -51,7 +51,11 @@ int main(int, char **) } catch (...) { } _state = _tmp>0; - PDBG("--- GPIO Signals test [LED pin: %d, Input pin: %d, Output pin: %d, Initial state: %d] ---", _gpio_pin, _gpio_pin_in, _gpio_pin_out, _state); + log("--- GPIO Signals test [LED " + "pin: ", _gpio_pin, ", " + "Input pin: ", _gpio_pin_in, ", " + "Output pin: ", _gpio_pin_out, ", " + "Initial state: ", _state, "] ---"); Gpio::Connection _led(_gpio_pin); Gpio::Connection _signal_input(_gpio_pin_in); @@ -98,10 +102,10 @@ int main(int, char **) */ if(!_state) { - PDBG("Led going OFF"); + Genode::log("Led going OFF"); }else { - PDBG("Led going ON"); + Genode::log("Led going ON"); } irq.ack_irq(); diff --git a/repos/os/src/test/input/test.cc b/repos/os/src/test/input/test.cc index 8bb417aad..248e06902 100644 --- a/repos/os/src/test/input/test.cc +++ b/repos/os/src/test/input/test.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include #include @@ -54,11 +54,11 @@ int main(int argc, char **argv) static Input::Connection input; static Timer::Connection timer; - PLOG("--- Input test is up ---"); + log("--- Input test is up ---"); Input::Event *ev_buf = (env()->rm_session()->attach(input.dataspace())); - PLOG("input buffer at %p", ev_buf); + log("input buffer at ", ev_buf); /* * Handle input events @@ -76,9 +76,14 @@ int main(int argc, char **argv) if (ev->type() == Input::Event::RELEASE) key_cnt--; /* log event */ - PLOG("Input event type=%s\tcode=%d\trx=%d\try=%d\tax=%d\tay=%d\tkey_cnt=%d\t%s", - ev_type(ev->type()), ev->code(), ev->rx(), ev->ry(), - ev->ax(), ev->ay(), key_cnt, key_name(ev)); + log("Input event " + "type=", ev_type(ev->type()), "\t" + "code=", ev->code(), "\t" + "rx=", ev->rx(), "\t" + "ry=", ev->ry(), "\t" + "ax=", ev->ax(), "\t" + "ay=", ev->ay(), "\t" + "key_cnt=", key_cnt, "\t", key_name(ev)); } } diff --git a/repos/os/src/test/iso/main.cc b/repos/os/src/test/iso/main.cc index dc6d8f5da..17937687f 100644 --- a/repos/os/src/test/iso/main.cc +++ b/repos/os/src/test/iso/main.cc @@ -11,55 +11,68 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include +#include #include using namespace Genode; -void dump(uint8_t *ptr, unsigned long offset) +struct Hexdump { - unsigned long *_ptr = (unsigned long *)(ptr + offset); - for (int i = 0; i < 4; i++) { - printf("%08lx: ", offset); + uint8_t const * const ptr; + unsigned long const offset; - int j; - for (j = 0; j < 5; j++) - printf("%08lx ", _ptr[(i * 8) + j]); + Hexdump(uint8_t const *ptr, unsigned long offset) + : ptr(ptr), offset(offset) { } - offset += j * sizeof(unsigned long); - printf("\n"); + void print(Genode::Output &out) const + { + using Genode::print; + unsigned long off = offset; + unsigned long *_ptr = (unsigned long *)(ptr + off); + + for (int i = 0; i < 4; i++) { + print(out, Hex((uint32_t)off, Hex::OMIT_PREFIX, Hex::PAD), ": "); + + int j; + for (j = 0; j < 5; j++) + print(out, Hex(_ptr[(i * 8) + j], Hex::OMIT_PREFIX, Hex::PAD), " "); + + off += j * sizeof(unsigned long); + print(out, "\n"); + } + + print(out, "\n"); } +}; - printf("\n"); + +namespace Component { + + Genode::size_t stack_size() { return 4*1024*sizeof(long); } + void construct(Genode::Env &env); } -int main() +void Component::construct(Genode::Env &env) { - Attached_rom_dataspace *ds; - uint8_t *ptr = 0; + Attached_rom_dataspace ds(env, "/test.txt"); - try { + uint8_t * const ptr = ds.local_addr(); - ds = new (env()->heap())Attached_rom_dataspace("/test.txt"); - ptr = ds->local_addr(); - printf("File size is %zx at %p\n", ds->size(), ptr); - } - catch (...) { - PDBG("Rom error"); - return 1; - } + log("File size is ", Hex(ds.size(), Hex::OMIT_PREFIX), " " + "at ", Hex((addr_t)ptr, Hex::OMIT_PREFIX)); - dump(ptr, 0x1000); - dump(ptr, 0x10000); - dump(ptr, 0x20000); + log(Hexdump(ptr, 0x1000)); + log(Hexdump(ptr, 0x10000)); + log(Hexdump(ptr, 0x20000)); Attached_rom_dataspace rom("/notavail.txt"); if (!rom.valid()) - PDBG("Expected ROM error occured"); + log("Expected ROM error occured"); else - PERR("found file where no file should be!"); + error("found file where no file should be!"); - return 0; + env.parent().exit(0); } diff --git a/repos/os/src/test/nic_loopback/main.cc b/repos/os/src/test/nic_loopback/main.cc index da73abc68..b1d7bd0a9 100644 --- a/repos/os/src/test/nic_loopback/main.cc +++ b/repos/os/src/test/nic_loopback/main.cc @@ -11,12 +11,21 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include #include +namespace Genode { + + static inline void print(Output &out, Packet_descriptor packet) + { + Genode::print(out, "offset=", packet.offset(), ", size=", packet.size()); + } +} + + using namespace Genode; @@ -26,19 +35,18 @@ static bool single_packet_roundtrip(Nic::Session *nic, { Packet_descriptor tx_packet; - printf("single_packet_roundtrip(content='%c', packet_size=%zd)\n", - content_pattern, packet_size); + log("single_packet_roundtrip(content='", Char(content_pattern), "', " + "packet_size=", packet_size, ")"); /* allocate transmit packet */ try { tx_packet = nic->tx()->alloc_packet(packet_size); } catch (Nic::Session::Tx::Source::Packet_alloc_failed) { - PERR("tx packet alloc failed"); + error(__func__, ": tx packet alloc failed"); return false; } - printf("allocated tx packet (offset=%ld, size=%zd)\n", - tx_packet.offset(), tx_packet.size()); + log("allocated tx packet ", tx_packet); /* fill packet with pattern */ char *tx_content = nic->tx()->packet_content(tx_packet); @@ -52,7 +60,7 @@ static bool single_packet_roundtrip(Nic::Session *nic, if (ack_tx_packet.size() != tx_packet.size() || ack_tx_packet.offset() != tx_packet.offset()) { - PERR("unexpected acked packet"); + error("unexpected acked packet"); return false; } @@ -62,11 +70,10 @@ static bool single_packet_roundtrip(Nic::Session *nic, * session. */ Packet_descriptor rx_packet = nic->rx()->get_packet(); - printf("received rx packet (offset=%ld, size=%zd)\n", - tx_packet.offset(), tx_packet.size()); + log("received rx packet ", rx_packet); if (rx_packet.size() != tx_packet.size()) { - PERR("sent and echoed packets differ in size"); + error("sent and echoed packets differ in size"); return false; } @@ -74,7 +81,7 @@ static bool single_packet_roundtrip(Nic::Session *nic, char *rx_content = nic->rx()->packet_content(rx_packet); for (unsigned i = 0; i < packet_size; i++) if (rx_content[i] != tx_content[i]) { - PERR("sent and echoed packets have differnt content"); + error("sent and echoed packets have differnt content"); return false; } @@ -140,28 +147,28 @@ static bool batch_packets(Nic::Session *nic, unsigned num_packets) Packet_descriptor rx_packet = nic->rx()->get_packet(); if (!nic->rx()->ready_to_ack()) - PWRN("not ready for ack, going to blocK"); + warning("not ready for ack, going to blocK"); nic->rx()->acknowledge_packet(rx_packet); rx_cnt++; batch_rx_cnt++; } - printf("acked %u packets, received %u packets " - "-> tx: %u, acked: %u, rx: %u\n", - batch_acked_cnt, batch_rx_cnt, tx_cnt, acked_cnt, rx_cnt); + log("acked ", batch_acked_cnt, " packets, " + "received ", batch_rx_cnt, " packets " + "-> tx: ", tx_cnt, ", acked: ", acked_cnt, ", rx: ", rx_cnt); batch_cnt++; } - printf("test used %u batches\n", batch_cnt); + log("test used ", batch_cnt, " batches"); return true; } int main(int, char **) { - printf("--- NIC loop-back test ---\n"); + log("--- NIC loop-back test ---"); enum { BUF_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE * 128 }; @@ -169,7 +176,7 @@ int main(int, char **) bool config_test_batch = true; if (config_test_roundtrip) { - printf("-- test roundtrip two times (packet offsets should be the same) --\n"); + log("-- test roundtrip two times (packet offsets should be the same) --"); Allocator_avl tx_block_alloc(env()->heap()); Nic::Connection nic(&tx_block_alloc, BUF_SIZE, BUF_SIZE); single_packet_roundtrip(&nic, 'a', 100); @@ -177,13 +184,13 @@ int main(int, char **) } if (config_test_batch) { - printf("-- test submitting and receiving batches of packets --\n"); + log("-- test submitting and receiving batches of packets --"); Allocator_avl tx_block_alloc(env()->heap()); Nic::Connection nic(&tx_block_alloc, BUF_SIZE, BUF_SIZE); enum { NUM_PACKETS = 1000 }; batch_packets(&nic, NUM_PACKETS); } - printf("--- finished NIC loop-back test ---\n"); + log("--- finished NIC loop-back test ---"); return 0; } diff --git a/repos/os/src/test/nic_raw/main.cc b/repos/os/src/test/nic_raw/main.cc index b0f41cf18..4ed5ac0b3 100644 --- a/repos/os/src/test/nic_raw/main.cc +++ b/repos/os/src/test/nic_raw/main.cc @@ -15,7 +15,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -41,12 +41,6 @@ class Nic_worker : public Genode::Thread_deprecated Genode::uint64_t count; } _stat, _drop; - void _dump_mac(Genode::uint8_t * mac) const { - Genode::printf("%2x", mac[0] & 0xff); - for(unsigned i=1; i < 6; ++i) - Genode::printf(":%2x", mac[i] & 0xff); - } - Genode::uint16_t _ntoh(Genode::uint16_t value) { return ((value & 0xFFU) << 8) | ((value >> 8) & 0xFFU); } @@ -62,17 +56,16 @@ class Nic_worker : public Genode::Thread_deprecated memset(&_drop, 0, sizeof(_drop)); memcpy(_mac.addr, nic->mac_address().addr, 6); - printf("mac: "); - _dump_mac(_mac.addr); - printf("\n"); + log("MAC: ", _mac); } - void entry() { + void entry() + { using namespace Genode; Timer::Connection timer; - PINF("ready to receive packets"); + log("ready to receive packets"); Nic::Measurement stat(timer); stat.set_mac(_mac.addr); @@ -107,7 +100,7 @@ static void net_init() nic = new (env()->heap()) Nic::Connection(tx_block_alloc, BUF_SIZE, BUF_SIZE); } catch (Parent::Service_denied) { destroy(env()->heap(), tx_block_alloc); - PERR("could not start Nic service"); + Genode::error("could not start Nic service"); return; } @@ -119,7 +112,7 @@ static void net_init() int main(int, char **) { - Genode::printf("--- NIC performance measurements ---\n"); + Genode::log("--- NIC performance measurements ---"); net_init(); diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc index 9ad07d5ee..9af7362a2 100644 --- a/repos/os/src/test/nitpicker/test.cc +++ b/repos/os/src/test/nitpicker/test.cc @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -155,9 +155,9 @@ int main(int argc, char **argv) int const scr_w = mode.width(), scr_h = mode.height(); - printf("screen is %dx%d\n", scr_w, scr_h); + log("screen is ", mode); if (!scr_w || !scr_h) { - PERR("Got invalid screen - spinning"); + error("got invalid screen - sleeping forever"); sleep_forever(); } diff --git a/repos/os/src/test/packet_stream/main.cc b/repos/os/src/test/packet_stream/main.cc index be46ef154..fb7667c71 100644 --- a/repos/os/src/test/packet_stream/main.cc +++ b/repos/os/src/test/packet_stream/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -34,11 +34,11 @@ enum { STACK_SIZE = 4096 }; void Genode::Packet_stream_base::_debug_print_buffers() { - Genode::printf("_ds_local_base = 0x%p\n", _ds_local_base); - Genode::printf("_submit_queue_offset = 0x%lx\n", _submit_queue_offset); - Genode::printf("_ack_queue_offset = 0x%lx\n", _ack_queue_offset); - Genode::printf("_bulk_buffer_offset = 0x%lx\n", _bulk_buffer_offset); - Genode::printf("_bulk_buffer_size = 0x%zx (%zd)\n", _bulk_buffer_size, _bulk_buffer_size); + Genode::log("_ds_local_base = ", _ds_local_base); + Genode::log("_submit_queue_offset = ", Genode::Hex(_submit_queue_offset)); + Genode::log("_ack_queue_offset = ", Genode::Hex(_ack_queue_offset)); + Genode::log("_bulk_buffer_offset = ", Genode::Hex(_bulk_buffer_offset)); + Genode::log("_bulk_buffer_size = ", Genode::Hex(_bulk_buffer_size)); } @@ -66,9 +66,9 @@ class Source : private Genode::Thread_deprecated, char *content = packet_content(packet); if (!content) { - PWRN("Source: invalid packet"); + Genode::warning("source: invalid packet"); } - Genode::printf("Source: allocated packet (offset=0x%lx, size=0x%zd\n", + Genode::log("Source: allocated packet (offset=0x%lx, size=0x%zd\n", packet.offset(), packet.size()); for (unsigned i = 0; i < packet.size(); i++) @@ -76,15 +76,15 @@ class Source : private Genode::Thread_deprecated, bool is_blocking = !ready_to_submit(); if (is_blocking) - Genode::printf("Source: submit queue is full, going to block\n"); + Genode::log("Source: submit queue is full, going to block"); submit_packet(packet); if (is_blocking) - Genode::printf("Source: returned from submit_packet function\n"); + Genode::log("Source: returned from submit_packet function"); } catch (Packet_stream_source<>::Packet_alloc_failed) { - PDBG("Source: Packet allocation failed"); + Genode::error("Source: Packet allocation failed"); } } } @@ -93,26 +93,27 @@ class Source : private Genode::Thread_deprecated, { for (unsigned i = 0; i < cnt; i++) { if (!ack_avail()) - Genode::printf("Source: acknowledgement queue is empty, going to block\n"); + Genode::log("Source: acknowledgement queue is empty, going to block"); Packet_descriptor packet = get_acked_packet(); char *content = packet_content(packet); if (!content) { - PWRN("Source: invalid packet"); + Genode::warning("source: invalid packet"); } else { /* validate packet content */ for (unsigned i = 0; i < packet.size(); i++) { if (content[i] != (char)i) { - PERR("Source: packet content is corrupted\n"); + Genode::error("source: packet content is corrupted"); break; } } } - Genode::printf("Source: release packet (offset=0x%lx, size=0x%zd\n", - packet.offset(), packet.size()); + Genode::log("Source: release packet (" + "offset=", Genode::Hex(packet.offset()), ", " + "size=", packet.size(), ")"); release_packet(packet); } } @@ -147,7 +148,7 @@ class Source : private Genode::Thread_deprecated, _lock(Genode::Lock::LOCKED), _cnt(0) { - Genode::printf("Source: packet stream buffers:"); + Genode::log("Source: packet stream buffers:"); debug_print_buffers(); start(); } @@ -184,19 +185,20 @@ class Sink : private Genode::Thread_deprecated, for (unsigned i = 0; i < cnt; i++) { if (!packet_avail()) - Genode::printf("Sink: no packet available, going to block\n"); + Genode::log("Sink: no packet available, going to block"); Packet_descriptor packet = get_packet(); char *content = packet_content(packet); if (!content) - PWRN("Invalid packet"); + Genode::warning("invalid packet"); - Genode::printf("Sink: got packet (offset=0x%lx, size=0x%zd\n", - packet.offset(), packet.size()); + Genode::log("Sink: got packet (" + "offset=", Genode::Hex(packet.offset()), ", " + "size=", packet.size(), ")"); if (!ready_to_ack()) - Genode::printf("Sink: ack queue is full, going to block\n"); + Genode::log("Sink: ack queue is full, going to block"); acknowledge_packet(packet); } @@ -227,7 +229,7 @@ class Sink : private Genode::Thread_deprecated, _lock(Genode::Lock::LOCKED), _cnt(0) { - Genode::printf("Sink: packet stream buffers:"); + Genode::log("Sink: packet stream buffers:"); debug_print_buffers(); start(); } @@ -248,19 +250,20 @@ void test_1_good_case(Timer::Session *timer, Source *source, Sink *sink, enum { DELAY = 200 }; - Genode::printf("- round %u -", i); + Genode::log("- round ", i, " -"); - Genode::printf("generate %u packets, fitting in bulk buffer and submit queue\n", batch_size); + Genode::log("generate ", batch_size, " packets, " + "fitting in bulk buffer and submit queue"); source->generate(batch_size); timer->msleep(DELAY); - Genode::printf("process %u packets\n", batch_size); + Genode::log("process ", batch_size, " packets"); sink->process(batch_size); timer->msleep(DELAY); - Genode::printf("acknowledge %u packets\n", batch_size); + Genode::log("acknowledge ", batch_size, " packets"); source->acknowledge(batch_size); timer->msleep(DELAY); @@ -276,17 +279,17 @@ void test_2_flood_submit(Timer::Session *timer, Source *source, Sink *sink) source->generate(PACKETS); timer->msleep(DELAY); - Genode::printf("- source should block, process 3 packets, source should wake up -\n"); + Genode::log("- source should block, process 3 packets, source should wake up -"); sink->process(1); timer->msleep(5*DELAY); sink->process(2); - Genode::printf("- let source acknowledge %u packets -\n", 3); + Genode::log("- let source acknowledge 3 packets -"); source->acknowledge(3); timer->msleep(DELAY); - Genode::printf("- process and acknowledge the remaining packets in batches 3 -\n"); + Genode::log("- process and acknowledge the remaining packets in batches 3 -\n"); for (int i = 0; i < 2; i++) { sink->process(3); timer->msleep(DELAY); @@ -301,7 +304,7 @@ using namespace Genode; int main(int, char **) { - printf("--- packet stream test ---\n"); + log("--- packet stream test ---"); Timer::Connection timer; @@ -319,15 +322,15 @@ int main(int, char **) timer.msleep(1000); - printf("\n-- test 1: good case, no queue pressure, no blocking --\n"); + log("\n-- test 1: good case, no queue pressure, no blocking --"); test_1_good_case(&timer, &source, &sink, 3, 5); - printf("\n-- test 2: flood submit queue, sender blocks, gets woken up --\n"); + log("\n-- test 2: flood submit queue, sender blocks, gets woken up --"); test_2_flood_submit(&timer, &source, &sink); - printf("waiting to settle down\n"); + log("waiting to settle down"); timer.msleep(2*1000); - printf("--- end of packet stream test ---\n"); + log("--- end of packet stream test ---"); return 0; } diff --git a/repos/os/src/test/pci/test.cc b/repos/os/src/test/pci/test.cc index 684d97fde..da2cf5361 100644 --- a/repos/os/src/test/pci/test.cc +++ b/repos/os/src/test/pci/test.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include @@ -27,7 +27,7 @@ enum { INTEL_VENDOR_ID = 0x8086 }; static void print_device_info(Platform::Device_capability device_cap) { if (!device_cap.valid()) { - PERR("Invalid device capability"); + error("invalid device capability"); return; } @@ -39,26 +39,33 @@ static void print_device_info(Platform::Device_capability device_cap) unsigned short device_id = device.device_id(); unsigned class_code = device.class_code() >> 8; - printf("%02x:%02x.%x %04x: %04x:%04x (Vendor %s)\n", - bus, dev, fun, class_code, vendor_id, device_id, - vendor_id == INTEL_VENDOR_ID ? "Intel" : "unknown"); + log(Hex(bus, Hex::OMIT_PREFIX), ":", + Hex(dev, Hex::OMIT_PREFIX), ".", + Hex(fun, Hex::OMIT_PREFIX), " " + "class=", Hex(class_code), " " + "vendor=", Hex(vendor_id), " ", + (vendor_id == INTEL_VENDOR_ID ? "(Intel)" : "(unknown)"), + "device=", Hex(device_id)); for (int resource_id = 0; resource_id < 6; resource_id++) { - Platform::Device::Resource resource = device.resource(resource_id); + typedef Platform::Device::Resource Resource; - if (resource.type() != Platform::Device::Resource::INVALID) - printf(" Resource %d (%s): base=0x%08x size=0x%08x %s\n", resource_id, - resource.type() == Platform::Device::Resource::IO ? "I/O" : "MEM", - resource.base(), resource.size(), - resource.prefetchable() ? "prefetchable" : ""); + Resource const resource = device.resource(resource_id); + + if (resource.type() != Resource::INVALID) + log(" Resource ", resource_id, " " + "(", (resource.type() == Resource::IO ? "I/O" : "MEM"), "): " + "base=", Genode::Hex(resource.base()), " " + "size=", Genode::Hex(resource.size()), " ", + (resource.prefetchable() ? "prefetchable" : "")); } } int main(int argc, char **argv) { - printf("--- Platform test started ---\n"); + log("--- Platform test started ---"); /* open session to pci service */ static Platform::Connection pci; @@ -80,7 +87,7 @@ int main(int argc, char **argv) /* release last device */ pci.release_device(prev_device_cap); - printf("--- Platform test finished ---\n"); + log("--- Platform test finished ---"); return 0; } diff --git a/repos/os/src/test/ram_fs_chunk/main.cc b/repos/os/src/test/ram_fs_chunk/main.cc index 389b6541f..ead9a0798 100644 --- a/repos/os/src/test/ram_fs_chunk/main.cc +++ b/repos/os/src/test/ram_fs_chunk/main.cc @@ -6,7 +6,7 @@ /* Genode includes */ #include -#include +#include #include namespace File_system { @@ -46,49 +46,53 @@ namespace Genode { }; -static void dump(File_system::Chunk_level_0 &chunk) -{ - using namespace File_system; +namespace Genode { - static char read_buf[Chunk_level_0::SIZE]; + /** + * Helper for the formatted output of a chunk state + */ + static inline void print(Output &out, File_system::Chunk_level_0 const &chunk) + { + using namespace File_system; + + static char read_buf[Chunk_level_0::SIZE]; + + size_t used_size = chunk.used_size(); + + struct File_size_out_of_bounds { }; + if (used_size > Chunk_level_0::SIZE) + throw File_size_out_of_bounds(); + + chunk.read(read_buf, used_size, 0); + + Genode::print(out, "content (size=", used_size, "): "); - size_t used_size = chunk.used_size(); - - struct File_size_out_of_bounds { }; - if (used_size > Chunk_level_0::SIZE) - throw File_size_out_of_bounds(); - - chunk.read(read_buf, used_size, 0); - - printf("content (size=%zd): \"", used_size); - for (unsigned i = 0; i < used_size; i++) { - char c = read_buf[i]; - if (c) - printf("%c", c); - else - printf("."); + Genode::print(out, "\""); + for (unsigned i = 0; i < used_size; i++) { + char const c = read_buf[i]; + if (c) + Genode::print(out, Genode::Char(c)); + else + Genode::print(out, "."); + } + Genode::print(out, "\""); } - printf("\"\n"); } static void write(File_system::Chunk_level_0 &chunk, char const *str, Genode::off_t seek_offset) { - using namespace Genode; - printf("write \"%s\" at offset %ld -> ", str, seek_offset); - chunk.write(str, strlen(str), seek_offset); - dump(chunk); + chunk.write(str, Genode::strlen(str), seek_offset); + Genode::log("write \"", str, "\" at offset ", seek_offset, " -> ", chunk); } static void truncate(File_system::Chunk_level_0 &chunk, File_system::file_size_t size) { - using namespace Genode; - printf("trunc(%zd) -> ", (size_t)size); chunk.truncate(size); - dump(chunk); + Genode::log("trunc(", size, ") -> ", chunk); } @@ -97,13 +101,13 @@ int main(int, char **) using namespace File_system; using namespace Genode; - printf("--- ram_fs_chunk test ---\n"); + log("--- ram_fs_chunk test ---"); - PINF("chunk sizes"); - PINF(" level 0: payload=%d sizeof=%zd", Chunk_level_0::SIZE, sizeof(Chunk_level_0)); - PINF(" level 1: payload=%d sizeof=%zd", Chunk_level_1::SIZE, sizeof(Chunk_level_1)); - PINF(" level 2: payload=%d sizeof=%zd", Chunk_level_2::SIZE, sizeof(Chunk_level_2)); - PINF(" level 3: payload=%d sizeof=%zd", Chunk_level_3::SIZE, sizeof(Chunk_level_3)); + log("chunk sizes"); + log(" level 0: payload=", (int)Chunk_level_0::SIZE, " sizeof=", sizeof(Chunk_level_0)); + log(" level 1: payload=", (int)Chunk_level_1::SIZE, " sizeof=", sizeof(Chunk_level_1)); + log(" level 2: payload=", (int)Chunk_level_2::SIZE, " sizeof=", sizeof(Chunk_level_2)); + log(" level 3: payload=", (int)Chunk_level_3::SIZE, " sizeof=", sizeof(Chunk_level_3)); static Allocator_tracer alloc(*env()->heap()); @@ -125,7 +129,7 @@ int main(int, char **) truncate(chunk, i); } - printf("allocator: sum=%zd\n", alloc.sum()); + log("allocator: sum=", alloc.sum()); return 0; } diff --git a/repos/os/src/test/report_rom/main.cc b/repos/os/src/test/report_rom/main.cc index bd86dba07..7b92be466 100644 --- a/repos/os/src/test/report_rom/main.cc +++ b/repos/os/src/test/report_rom/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -19,7 +19,7 @@ #define ASSERT(cond) \ if (!(cond)) { \ - PERR("assertion %s failed", #cond); \ + Genode::error("assertion ", #cond, " failed"); \ return -2; } @@ -38,35 +38,35 @@ int main(int argc, char **argv) Signal_context sig_ctx; Signal_context_capability sig_cap = sig_rec.manage(&sig_ctx); - printf("--- test-report_rom started ---\n"); + log("--- test-report_rom started ---"); - printf("Reporter: open session\n"); + log("Reporter: open session"); Reporter brightness_reporter("brightness"); brightness_reporter.enabled(true); - printf("Reporter: brightness 10\n"); + log("Reporter: brightness 10"); report_brightness(brightness_reporter, 10); - printf("ROM client: request brightness report\n"); + log("ROM client: request brightness report"); Attached_rom_dataspace brightness_rom("brightness"); ASSERT(brightness_rom.valid()); brightness_rom.sigh(sig_cap); - printf(" -> %s\n", brightness_rom.local_addr()); + log(" -> ", brightness_rom.local_addr()); - printf("Reporter: updated brightness to 77\n"); + log("Reporter: updated brightness to 77"); report_brightness(brightness_reporter, 77); - printf("ROM client: wait for update notification\n"); + log("ROM client: wait for update notification"); sig_rec.wait_for_signal(); - printf("ROM client: got signal\n"); + log("ROM client: got signal"); - printf("ROM client: request updated brightness report\n"); + log("ROM client: request updated brightness report"); brightness_rom.update(); - printf(" -> %s\n", brightness_rom.local_addr()); + log(" -> ", brightness_rom.local_addr()); - printf("Reporter: close report session\n"); + log("Reporter: close report session"); brightness_reporter.enabled(false); /* give report_rom some time to close the report session */ @@ -75,26 +75,26 @@ int main(int argc, char **argv) brightness_rom.update(); ASSERT(brightness_rom.valid()); - printf("ROM client: ROM is available despite report was closed - OK\n"); + log("ROM client: ROM is available despite report was closed - OK"); - printf("Reporter: start reporting (while the ROM client still listens)\n"); + log("Reporter: start reporting (while the ROM client still listens)"); brightness_reporter.enabled(true); report_brightness(brightness_reporter, 99); - printf("ROM client: wait for update notification\n"); + log("ROM client: wait for update notification"); sig_rec.wait_for_signal(); try { - printf("ROM client: try to open the same report again\n"); + log("ROM client: try to open the same report again"); Reporter again("brightness"); again.enabled(true); - PERR("expected Service_denied"); + error("expected Service_denied"); return -3; } catch (Genode::Parent::Service_denied) { - printf("ROM client: catched Parent::Service_denied - OK\n"); + log("ROM client: catched Parent::Service_denied - OK"); } - printf("--- test-report_rom finished ---\n"); + log("--- test-report_rom finished ---"); sig_rec.dissolve(&sig_ctx); diff --git a/repos/os/src/test/resource_request/main.cc b/repos/os/src/test/resource_request/main.cc index d48645aeb..3a758dcbc 100644 --- a/repos/os/src/test/resource_request/main.cc +++ b/repos/os/src/test/resource_request/main.cc @@ -15,7 +15,7 @@ */ #include -#include +#include #include @@ -27,14 +27,14 @@ static Genode::size_t used_quota() static void print_quota_stats() { - PLOG("quota: avail=%zd used=%zd", - Genode::env()->ram_session()->avail(), used_quota()); + Genode::log("quota: avail=", Genode::env()->ram_session()->avail(), " " + "used=", used_quota()); } #define ASSERT(cond) \ if (!(cond)) { \ - PERR("assertion %s failed", #cond); \ + Genode::error("assertion ", #cond, " failed"); \ return -2; } @@ -42,7 +42,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- test-resource_request started ---\n"); + log("--- test-resource_request started ---"); /* * Consume initial quota to let the test trigger the corner cases of @@ -55,7 +55,7 @@ int main(int argc, char **argv) if (wasted_quota) env()->ram_session()->alloc(wasted_quota); - printf("wasted available quota of %zd bytes\n", wasted_quota); + log("wasted available quota of ", wasted_quota, " bytes"); print_quota_stats(); @@ -71,7 +71,7 @@ int main(int argc, char **argv) * Note that the construction of the signal receiver will consume a part * of the quota we preserved as 'KEEP_QUOTA'. */ - printf("\n-- draining signal session --\n"); + log("\n-- draining signal session --"); { enum { NUM_SIG_CTX = 2000U }; static Signal_context sig_ctx[NUM_SIG_CTX]; @@ -93,7 +93,7 @@ int main(int argc, char **argv) * Because, we don't have any RAM quota left, we need to issue another * resource request to the parent. */ - printf("\n-- out-of-memory during session request --\n"); + log("\n-- out-of-memory during session request --"); static Ram_connection ram; ram.ref_account(env()->ram_session_cap()); print_quota_stats(); @@ -103,10 +103,10 @@ int main(int argc, char **argv) * Quota transfers from the process' RAM session may result in resource * requests, too. */ - printf("\n-- out-of-memory during transfer-quota --\n"); + log("\n-- out-of-memory during transfer-quota --"); int ret = env()->ram_session()->transfer_quota(ram.cap(), 512*1024); if (ret != 0) { - PERR("transfer quota failed (ret = %d)", ret); + error("transfer quota failed (ret = ", ret, ")"); return -1; } print_quota_stats(); @@ -116,7 +116,7 @@ int main(int argc, char **argv) * Finally, resource requests could be caused by a regular allocation, * which is the most likely case in normal scenarios. */ - printf("\n-- out-of-memory during RAM allocation --\n"); + log("\n-- out-of-memory during RAM allocation --"); env()->ram_session()->alloc(512*1024); print_quota_stats(); size_t used_quota_after_alloc = used_quota(); @@ -128,7 +128,7 @@ int main(int argc, char **argv) ASSERT(used_quota_after_transfer == used_quota_after_session_request); ASSERT(used_quota_after_alloc > used_quota_after_transfer); - printf("--- finished test-resource_request ---\n"); + log("--- finished test-resource_request ---"); return 0; } diff --git a/repos/os/src/test/resource_yield/main.cc b/repos/os/src/test/resource_yield/main.cc index 28d51fea4..5e366980b 100644 --- a/repos/os/src/test/resource_yield/main.cc +++ b/repos/os/src/test/resource_yield/main.cc @@ -27,7 +27,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -97,7 +97,7 @@ void Child::_dispatch_periodic_timeout(unsigned) if (Genode::env()->ram_session()->avail() < chunk_size) { if (_expand) { - PLOG("quota consumed, request additional resources"); + Genode::log("quota consumed, request additional resources"); /* * The attempt to allocate RAM will result in a resource request to @@ -106,7 +106,7 @@ void Child::_dispatch_periodic_timeout(unsigned) */ } else { - PLOG("consumed all of our quota, stop allocating"); + Genode::log("consumed all of our quota, stop allocating"); return; } } @@ -114,7 +114,7 @@ void Child::_dispatch_periodic_timeout(unsigned) /* perform allocation and remember chunk in list */ _ram_chunks.insert(new (Genode::env()->heap()) Ram_chunk(chunk_size)); - PLOG("allocated chunk of %zd KiB", chunk_size / 1024); + Genode::log("allocated chunk of ", chunk_size / 1024, " KiB"); _schedule_next_timeout(); } @@ -127,7 +127,7 @@ void Child::_dispatch_yield(unsigned) /* request yield request arguments */ Parent::Resource_args const args = env()->parent()->yield_request(); - PLOG("yield request: %s", args.string()); + log("yield request: ", args.string()); size_t const requested_ram_quota = Arg_string::find_arg(args.string(), "ram_quota").ulong_value(0); @@ -138,7 +138,7 @@ void Child::_dispatch_yield(unsigned) Ram_chunk *chunk = _ram_chunks.first(); if (!chunk) { - PWRN("no chunk left to release"); + warning("no chunk left to release"); break; } @@ -147,7 +147,7 @@ void Child::_dispatch_yield(unsigned) destroy(env()->heap(), chunk); released_quota += chunk_size; - PLOG("released chunk of %zd bytes", chunk_size); + log("released chunk of ", chunk_size, " bytes"); } /* acknowledge yield request */ @@ -233,9 +233,8 @@ class Parent : Genode::Slave_policy void _print_status() { - PLOG("quota: %zd KiB used: %zd KiB", - _slave.ram().quota() / 1024, - _slave.ram().used() / 1024); + Genode::log("quota: ", _slave.ram().quota() / 1024, " KiB " + "used: ", _slave.ram().used() / 1024, " KiB"); } public: @@ -319,17 +318,17 @@ int Parent::main() * Synchronously wait for a yield response. Note that a careful parent * would never trust its child to comply to the yield request. */ - PLOG("wait for yield response"); + log("wait for yield response"); _yield_blockade.lock(); _yield_blockade.lock(); - PLOG("got yield response"); + log("got yield response"); _print_status(); /* validate that the amount of yielded resources matches the request */ size_t const used_after_yield = _slave.ram().used(); if (used_after_yield + 5*1024*1024 > used_prior_yield) { - PERR("child has not yielded enough resources"); + error("child has not yielded enough resources"); return -1; } @@ -337,7 +336,7 @@ int Parent::main() _yield_blockade.unlock(); } - printf("--- test-resource_yield finished ---\n"); + log("--- test-resource_yield finished ---"); return 0; } @@ -359,12 +358,12 @@ int main(int argc, char **argv) && config()->xml_node().attribute_value("child", false); if (is_child) { - printf("--- test-resource_yield child role started ---\n"); + log("--- test-resource_yield child role started ---"); static ::Child child; child.main(); return -1; /* the child should never reach this point */ } else { - printf("--- test-resource_yield parent role started ---\n"); + log("--- test-resource_yield parent role started ---"); static ::Parent parent; return parent.main(); } diff --git a/repos/os/src/test/rom_blk/main.cc b/repos/os/src/test/rom_blk/main.cc index 51b68576b..0c527bf06 100644 --- a/repos/os/src/test/rom_blk/main.cc +++ b/repos/os/src/test/rom_blk/main.cc @@ -15,7 +15,7 @@ */ #include -#include +#include #include #include #include @@ -58,10 +58,11 @@ class Comparer : public Genode::Thread_deprecated<8192> _blk_con.info(&blk_cnt, &blk_size, &ops); if (!ops.supported(Block::Packet_descriptor::READ)) { - PERR("Block device not readable!"); + error("Block device not readable!"); } - PINF("We have %llu blocks with a size of 0x%zx bytes", blk_cnt, blk_size); + log("We have ", blk_cnt, " blocks with a " + "size of ", Hex(blk_size), " bytes"); for (size_t i = 0; i < blk_cnt; i += BLOCK_REQ_PARALLEL) { try { @@ -74,7 +75,7 @@ class Comparer : public Genode::Thread_deprecated<8192> p = source->get_acked_packet(); if (!p.succeeded()) { - PERR("Could not read block %zx-%zx", i, i+cnt); + error("could not read block ", Hex(i), "-", Hex(i + cnt)); return; } @@ -84,23 +85,23 @@ class Comparer : public Genode::Thread_deprecated<8192> for (size_t j = 0; j < cnt; j++) for (size_t k = 0; k < blk_size; k++) { if (&rom_src[j*blk_size+k] >= (char*)end) { - PERR("End of image file reached!"); + error("end of image file reached!"); return; } if (blk_src[j*blk_size+k] != rom_src[j*blk_size+k]) differ = true; } if (differ) { - PWRN("block %zx differs!", i); + warning("block ", i, " differs!"); throw Block_file_differ(); } source->release_packet(p); } catch (Block::Session::Tx::Source::Packet_alloc_failed) { - PERR("Mmh, strange we run out of packets"); + error("Mmh, strange we run out of packets"); return; } } - PINF("all done, finished!"); + log("all done, finished!"); } }; @@ -109,7 +110,7 @@ int main(int argc, char **argv) { using namespace Genode; - PINF("--- Block session test ---\n"); + log("--- Block session test ---"); try { static char filename[64]; @@ -119,8 +120,8 @@ int main(int argc, char **argv) th.start(); sleep_forever(); } catch (Rom_connection::Rom_connection_failed) { - PERR("Config file or file given by tag is missing."); + error("config file or file given by tag is missing."); } - PINF("An error occured, exit now ..."); + log("An error occured, exit now ..."); return -1; } diff --git a/repos/os/src/test/signal/main.cc b/repos/os/src/test/signal/main.cc index 4ae78801d..6a97ce3d0 100644 --- a/repos/os/src/test/signal/main.cc +++ b/repos/os/src/test/signal/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include #include @@ -48,7 +48,7 @@ class Sender : Thread_deprecated<4096> _submit_cnt++; if (_verbose) - printf("submit signal %d\n", _submit_cnt); + log("submit signal ", _submit_cnt); _transmitter.submit(); @@ -136,11 +136,9 @@ class Handler : Thread_deprecated<4096> Signal signal = _receiver->wait_for_signal(); if (_verbose) - printf("handler %d got %u signal%s with context %p\n", - _id, - signal.num(), - signal.num() == 1 ? "" : "s", - signal.context()); + log("handler ", _id, " got ", signal.num(), " " + "signal", (signal.num() == 1 ? "" : "s"), " " + "with context ", signal.context()); _receive_cnt += signal.num(); _activation_cnt++; @@ -267,9 +265,9 @@ static void fast_sender_test() enum { SENDER_INTERVAL = 2*SPEED }; enum { FINISH_IDLE_TIME = 2*HANDLER_INTERVAL }; - printf("\n"); - printf("TEST %d: one sender, one handler, sender is faster than handler\n", ++test_cnt); - printf("\n"); + log(""); + log("TEST ", ++test_cnt, ": one sender, one handler, sender is faster than handler"); + log(""); Signal_receiver receiver; Id_signal_context context_123(123); @@ -281,14 +279,14 @@ static void fast_sender_test() timer.msleep(TEST_DURATION); /* stop emitting signals */ - printf("deactivate sender\n"); + log("deactivate sender"); sender->idle(); timer.msleep(FINISH_IDLE_TIME); - printf("\n"); - printf("sender submitted a total of %d signals\n", sender->submit_cnt()); - printf("handler received a total of %d signals\n", handler->receive_cnt()); - printf("\n"); + log(""); + log("sender submitted a total of ", sender->submit_cnt(), " signals"); + log("handler received a total of ", handler->receive_cnt(), " signals"); + log(""); if (sender->submit_cnt() != handler->receive_cnt()) throw Test_failed(); @@ -298,7 +296,7 @@ static void fast_sender_test() destroy(env()->heap(), sender); destroy(env()->heap(), handler); - printf("TEST %d FINISHED\n", test_cnt); + log("TEST ", test_cnt, " FINISHED"); } @@ -319,10 +317,9 @@ static void multiple_handlers_test() enum { FINISH_IDLE_TIME = 2*HANDLER_INTERVAL }; enum { NUM_HANDLERS = 4 }; - printf("\n"); - printf("TEST %d: one busy sender, %d handlers\n", - ++test_cnt, NUM_HANDLERS); - printf("\n"); + log(""); + log("TEST ", ++test_cnt, ": one busy sender, ", (int)NUM_HANDLERS, " handlers"); + log(""); Signal_receiver receiver; @@ -336,7 +333,7 @@ static void multiple_handlers_test() timer.msleep(TEST_DURATION); /* stop emitting signals */ - printf("stop generating new notifications\n"); + log("stop generating new notifications"); sender->idle(); timer.msleep(FINISH_IDLE_TIME); @@ -346,28 +343,25 @@ static void multiple_handlers_test() timer.msleep(FINISH_IDLE_TIME); /* print signal delivery statistics */ - printf("\n"); - printf("sender submitted a total of %d signals\n", - sender->submit_cnt()); + log(""); + log("sender submitted a total of ", sender->submit_cnt(), " signals"); unsigned total_receive_cnt = 0; for (int i = 0; i < NUM_HANDLERS; i++) { - printf("handler %d received a total of %d signals\n", - i, handler[i]->receive_cnt()); + log("handler ", i, " " + "received a total of ", handler[i]->receive_cnt(), " signals"); total_receive_cnt += handler[i]->receive_cnt(); } - printf("all handlers received a total of %d signals\n", - total_receive_cnt); + log("all handlers received a total of ", total_receive_cnt, " signals"); /* check if number of sent notifications match the received ones */ if (sender->submit_cnt() != total_receive_cnt) throw Test_failed_with_unequal_sent_and_received_signals(); /* print activation statistics */ - printf("\n"); + log(""); for (int i = 0; i < NUM_HANDLERS; i++) - printf("handler %d was activated %d times\n", - i, handler[i]->activation_cnt()); - printf("\n"); + log("handler ", i, " was activated ", handler[i]->activation_cnt(), " times"); + log(""); /* check if handlers had been activated equally (tolerating a difference of one) */ for (int i = 0; i < NUM_HANDLERS; i++) { @@ -385,7 +379,7 @@ static void multiple_handlers_test() for (int i = 0; i < NUM_HANDLERS; i++) destroy(env()->heap(), handler[i]); - printf("TEST %d FINISHED\n", test_cnt); + log("TEST ", test_cnt, " FINISHED"); } @@ -402,9 +396,9 @@ static void stress_test() enum { DURATION_SECONDS = 5 }; enum { FINISH_IDLE_TIME = 100*SPEED }; - printf("\n"); - printf("TEST %d: stress test, busy signal transmission and handling\n", ++test_cnt); - printf("\n"); + log(""); + log("TEST ", ++test_cnt, ": stress test, busy signal transmission and handling"); + log(""); Signal_receiver receiver; Id_signal_context context_123(123); @@ -414,28 +408,26 @@ static void stress_test() 0, false); for (int i = 1; i <= DURATION_SECONDS; i++) { - printf("%d/%d\n", i, DURATION_SECONDS); + log(i, "/", (int)DURATION_SECONDS); timer.msleep(1000); } /* stop emitting signals */ - printf("deactivate sender\n"); + log("deactivate sender"); sender->idle(); while (handler->receive_cnt() < sender->submit_cnt()) { - printf("waiting for signals still in flight..."); + log("waiting for signals still in flight..."); timer.msleep(FINISH_IDLE_TIME); } - printf("\n"); - printf("sender submitted a total of %d signals\n", sender->submit_cnt()); - printf("handler received a total of %d signals\n", handler->receive_cnt()); - printf("\n"); - printf("processed %d notifications per second\n", - (handler->receive_cnt())/DURATION_SECONDS); - printf("handler was activated %d times per second\n", - (handler->activation_cnt())/DURATION_SECONDS); - printf("\n"); + log(""); + log("sender submitted a total of ", sender->submit_cnt(), " signals"); + log("handler received a total of ", handler->receive_cnt(), " signals"); + log(""); + log("processed ", (handler->receive_cnt()/DURATION_SECONDS), " notifications per second"); + log("handler was activated ", (handler->activation_cnt()/DURATION_SECONDS), " times per second"); + log(""); if (sender->submit_cnt() != handler->receive_cnt()) throw Test_failed_with_unequal_sent_and_received_signals(); @@ -444,15 +436,15 @@ static void stress_test() destroy(env()->heap(), sender); destroy(env()->heap(), handler); - printf("TEST %d FINISHED\n", test_cnt); + log("TEST ", test_cnt, " FINISHED"); } static void lazy_receivers_test() { - printf("\n"); - printf("TEST %d: lazy and out-of-order signal reception test\n", ++test_cnt); - printf("\n"); + log(""); + log("TEST ", ++test_cnt, ": lazy and out-of-order signal reception test"); + log(""); Signal_receiver rec_1, rec_2; Signal_context rec_context_1, rec_context_2; @@ -460,34 +452,34 @@ static void lazy_receivers_test() Signal_transmitter transmitter_1(rec_1.manage(&rec_context_1)); Signal_transmitter transmitter_2(rec_2.manage(&rec_context_2)); - printf("submit and receive signals with multiple receivers in order\n"); + log("submit and receive signals with multiple receivers in order"); transmitter_1.submit(); transmitter_2.submit(); { Signal signal = rec_1.wait_for_signal(); - printf("returned from wait_for_signal for receiver 1\n"); + log("returned from wait_for_signal for receiver 1"); signal = rec_2.wait_for_signal(); - printf("returned from wait_for_signal for receiver 2\n"); + log("returned from wait_for_signal for receiver 2"); } - printf("submit and receive signals with multiple receivers out of order\n"); + log("submit and receive signals with multiple receivers out of order"); transmitter_1.submit(); transmitter_2.submit(); { Signal signal = rec_2.wait_for_signal(); - printf("returned from wait_for_signal for receiver 2\n"); + log("returned from wait_for_signal for receiver 2"); signal = rec_1.wait_for_signal(); - printf("returned from wait_for_signal for receiver 1\n"); + log("returned from wait_for_signal for receiver 1"); } rec_1.dissolve(&rec_context_1); rec_2.dissolve(&rec_context_2); - printf("TEST %d FINISHED\n", test_cnt); + log("TEST ", test_cnt, " FINISHED"); } @@ -510,24 +502,24 @@ static void check_context_management() /* stop sender after timeout */ timer.msleep(1000); - printf("suspend sender\n"); + log("suspend sender"); sender->idle(); /* collect pending signals and dissolve context from receiver */ { Signal signal = rec->wait_for_signal(); - printf("got %d signal(s) from %p\n", signal.num(), signal.context()); + log("got ", signal.num(), " signal(s) from ", signal.context()); } rec->dissolve(context); /* let sender spin for some time */ - printf("resume sender\n"); + log("resume sender"); sender->idle(false); timer.msleep(1000); - printf("suspend sender\n"); + log("suspend sender"); sender->idle(); - printf("destroy sender\n"); + log("destroy sender"); destroy(env()->heap(), sender); destroy(env()->heap(), context); @@ -593,7 +585,7 @@ static void synchronized_context_destruction_test() signal_copy = signal_copy2; if (signal_context_destroyed) { - PERR("signal context destroyed too early"); + error("signal context destroyed too early"); sleep_forever(); } } @@ -608,20 +600,20 @@ static void many_managed_contexts() for (unsigned round = 0; round < 10; ++round) { unsigned const num_contexts = 200 + 5*round; - printf("round %u: create and manage %u contexts\n", round, num_contexts); + log("round ", round, ": create and manage ", num_contexts, " contexts"); Signal_receiver rec; for (unsigned i = 0; i < num_contexts; ++i) { Id_signal_context *context = new (env()->heap()) Id_signal_context(i); if (!rec.manage(context).valid()) { - PERR("failed to manage signal context"); + error("failed to manage signal context"); sleep_forever(); } } } - printf("many contexts finished\n"); + log("many contexts finished"); } @@ -630,7 +622,7 @@ static void many_managed_contexts() */ int main(int, char **) { - printf("--- signalling test ---\n"); + log("--- signalling test ---"); fast_sender_test(); multiple_handlers_test(); @@ -640,6 +632,6 @@ int main(int, char **) synchronized_context_destruction_test(); many_managed_contexts(); - printf("--- signalling test finished ---\n"); + log("--- signalling test finished ---"); return 0; } diff --git a/repos/os/src/test/synced_interface/main.cc b/repos/os/src/test/synced_interface/main.cc index 8238781da..10766875d 100644 --- a/repos/os/src/test/synced_interface/main.cc +++ b/repos/os/src/test/synced_interface/main.cc @@ -13,14 +13,14 @@ /* Genode includes */ #include -#include +#include struct Adder { int add(int a, int b) { - PLOG("adding %d + %d", a, b); + Genode::log("adding ", a, " + ", b); return a + b; } }; @@ -28,8 +28,8 @@ struct Adder struct Pseudo_lock { - void lock() { PLOG("lock"); } - void unlock() { PLOG("unlock"); } + void lock() { Genode::log("lock"); } + void unlock() { Genode::log("unlock"); } }; @@ -44,6 +44,6 @@ int main(int, char **) int const res = synced_adder()->add(13, 14); - PLOG("result is %d", res); + log("result is ", res); return 0; } diff --git a/repos/os/src/test/terminal_echo/main.cc b/repos/os/src/test/terminal_echo/main.cc index ce0ff0b1b..12bc0a08b 100644 --- a/repos/os/src/test/terminal_echo/main.cc +++ b/repos/os/src/test/terminal_echo/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -42,7 +42,7 @@ int main(int, char **) int num_bytes = terminal.read(read_buffer, sizeof(read_buffer)); if (verbose && (num_bytes > 0)) - PDBG("got %d bytes", num_bytes); + log("got ", num_bytes, " bytes"); for (int i = 0; i < num_bytes; i++) { if (read_buffer[i] == '\r') { diff --git a/repos/os/src/test/thread_join/main.cc b/repos/os/src/test/thread_join/main.cc index 12c4b84ad..ef5fdbf9d 100644 --- a/repos/os/src/test/thread_join/main.cc +++ b/repos/os/src/test/thread_join/main.cc @@ -11,7 +11,7 @@ * under the terms of the GNU General Public License version 2. */ -#include +#include #include #include @@ -26,11 +26,11 @@ struct Worker : Genode::Thread_deprecated<4096> void entry() { - PLOG("worker thread is up"); + log("worker thread is up"); timer.msleep(250); - PLOG("worker is leaving the entry function with result=%u...", - result_value); + log("worker is leaving the entry function with " + "result=", result_value, "..."); result = result_value; } @@ -49,7 +49,7 @@ struct Worker : Genode::Thread_deprecated<4096> */ int main(int, char **) { - printf("--- thread join test ---\n"); + log("--- thread join test ---"); Timer::Connection timer; @@ -65,11 +65,11 @@ int main(int, char **) worker.join(); if (worker.result != i) { - PERR("work remains unfinished after 'join()' returned"); + error("work remains unfinished after 'join()' returned"); return -1; } } - printf("--- signalling test finished ---\n"); + log("--- signalling test finished ---"); return 0; } diff --git a/repos/os/src/test/timed_semaphore/main.cc b/repos/os/src/test/timed_semaphore/main.cc index 77eacade5..91003cee7 100644 --- a/repos/os/src/test/timed_semaphore/main.cc +++ b/repos/os/src/test/timed_semaphore/main.cc @@ -80,24 +80,24 @@ bool test_loop(Timer::Session *timer, Alarm::Time timeout1, Alarm::Time timeout2 int main(int, char **) { - printf("--- timed-semaphore test ---\n"); + log("--- timed-semaphore test ---"); Timer::Connection timer; - printf("--- test 1: good case, no timeout triggers --\n"); + log("--- test 1: good case, no timeout triggers --"); if(!test_loop(&timer, 1000, 100, 10)) { - PERR("Test 1 failed!"); + error("Test 1 failed!"); return -1; } - printf("--- everything went ok --\n"); + log("--- everything went ok --"); - printf("--- test 2: triggers timeouts --\n"); + log("--- test 2: triggers timeouts --"); if(test_loop(&timer, 100, 1000, 10)) { - PERR("Test 2 failed!"); + error("Test 2 failed!"); return -2; } - printf("--- everything went ok --\n"); + log("--- everything went ok --"); - printf("--- end of timed-semaphore test ---\n"); + log("--- end of timed-semaphore test ---"); return 0; } diff --git a/repos/os/src/test/timer/main.cc b/repos/os/src/test/timer/main.cc index 204fd5471..bf57cd311 100644 --- a/repos/os/src/test/timer/main.cc +++ b/repos/os/src/test/timer/main.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include #include @@ -113,7 +113,7 @@ extern "C" int usleep(unsigned long usec); int main(int argc, char **argv) { - printf("--- timer test ---\n"); + log("--- timer test ---"); static Genode::List timer_clients; static Timer::Connection main_timer; @@ -126,9 +126,9 @@ int main(int argc, char **argv) /* will get destructed at the end of the current scope */ Timer_stressful_client stressful_client(250*1000); - printf("register two-seconds timeout...\n"); + log("register two-seconds timeout..."); main_timer.msleep(2000); - printf("timeout fired\n"); + log("timeout fired"); } /* check periodic timeouts */ @@ -138,7 +138,7 @@ int main(int argc, char **argv) main_timer.sigh(sig); enum { PTEST_TIME_US = 2000000 }; unsigned period_us = 500000, periods = PTEST_TIME_US / period_us, i = 0; - printf("start periodic timeouts\n"); + log("start periodic timeouts"); for (unsigned j = 0; j < 5; j++) { unsigned elapsed_ms = main_timer.elapsed_ms(); main_timer.trigger_periodic(period_us); @@ -152,12 +152,13 @@ int main(int argc, char **argv) unsigned const max_err_us = max_us / 100; unsigned const max_ms = (max_us + max_err_us) / 1000; if (min_ms > elapsed_ms || max_ms < elapsed_ms) { - PERR("Timing %u ms period %u times failed: %u ms (min %u, max %u)", - period_us / 1000, i, elapsed_ms, min_ms, max_ms); + error("timing ", period_us / 1000, " ms " + "period ", i, " times failed: ", + elapsed_ms, " ms (min ", min_ms, ", max ", max_ms, ")"); return -1; } - printf("Done %u ms period %u times: %u ms (min %u, max %u)\n", - period_us / 1000, i, elapsed_ms, min_ms, max_ms); + log("Done ", period_us / 1000, " ms period ", i, " times: ", + elapsed_ms, " ms (min ", min_ms, ", max ", max_ms, ")"); i = 0, period_us /= 2, periods = PTEST_TIME_US / period_us; } @@ -171,7 +172,7 @@ int main(int argc, char **argv) enum { SECONDS_TO_WAIT = 10 }; for (unsigned i = 0; i < SECONDS_TO_WAIT; i++) { main_timer.msleep(1000); - printf("wait %d/%d\n", i + 1, SECONDS_TO_WAIT); + log("wait ", i + 1, "/", (int)SECONDS_TO_WAIT); } /* stop all timers */ @@ -180,10 +181,11 @@ int main(int argc, char **argv) /* print statistics about each timer client */ for (Timer_client *curr = timer_clients.first(); curr; curr = curr->next()) - printf("timer (period %ld ms) triggered %ld times -> slept %ld ms\n", - curr->period_msec(), curr->cnt(), curr->period_msec()*curr->cnt()); + log("timer (period ", curr->period_msec(), " ms) " + "triggered ", curr->cnt(), " times -> " + "slept ", curr->period_msec()*curr->cnt(), " ms"); - printf("--- timer test finished ---\n"); + log("--- timer test finished ---"); Genode::sleep_forever(); return 0; diff --git a/repos/os/src/test/trace/main.cc b/repos/os/src/test/trace/main.cc index daee21c30..35e8290f6 100644 --- a/repos/os/src/test/trace/main.cc +++ b/repos/os/src/test/trace/main.cc @@ -86,7 +86,7 @@ class Trace_buffer_monitor _buffer(env()->rm_session()->attach(ds_cap)), _curr_entry(_buffer->first()) { - PLOG("monitor subject:%d buffer:0x%lx", _id.id, (addr_t)_buffer); + log("monitor subject:", _id.id, " buffer:", Hex((addr_t)_buffer)); } ~Trace_buffer_monitor() @@ -99,9 +99,9 @@ class Trace_buffer_monitor void dump() { - PLOG("overflows: %u", _buffer->wrapped()); + log("overflows: ", _buffer->wrapped()); - PLOG("read all remaining events"); + log("read all remaining events"); for (; !_curr_entry.last(); _curr_entry = _buffer->next(_curr_entry)) { /* omit empty entries */ if (_curr_entry.length() == 0) @@ -109,7 +109,7 @@ class Trace_buffer_monitor const char *data = _terminate_entry(_curr_entry); if (data) - PLOG("%s", data); + log(data); } /* reset after we read all available entries */ @@ -120,7 +120,7 @@ class Trace_buffer_monitor static void test_out_of_metadata() { - printf("test Out_of_metadata exception of Trace::Session::subjects call\n"); + log("test Out_of_metadata exception of Trace::Session::subjects call"); /* * The call of 'subjects' will prompt core's TRACE service to import those @@ -141,7 +141,7 @@ static void test_out_of_metadata() struct Unexpectedly_got_no_exception{}; throw Unexpectedly_got_no_exception(); } catch (Genode::Parent::Service_denied) { - printf("got Genode::Parent::Service_denied exception as expected\n"); + log("got Genode::Parent::Service_denied exception as expected"); } try { @@ -153,10 +153,10 @@ static void test_out_of_metadata() throw Unexpectedly_got_no_exception(); } catch (Trace::Out_of_metadata) { - printf("got Trace::Out_of_metadata exception as expected\n"); + log("got Trace::Out_of_metadata exception as expected"); } - printf("passed Out_of_metadata test\n"); + log("passed Out_of_metadata test"); } @@ -164,7 +164,7 @@ int main(int argc, char **argv) { using namespace Genode; - printf("--- test-trace started ---\n"); + log("--- test-trace started ---"); test_out_of_metadata(); @@ -207,10 +207,12 @@ int main(int argc, char **argv) env()->rm_session()->detach(rom); } } catch (...) { - PERR("could not load module '%s' for label '%s'", policy_module, policy_label); + error("could not load module '", Cstring(policy_module), "' for " + "label '", Cstring(policy_label), "'"); } - PINF("load module: '%s' for label: '%s'", policy_module, policy_label); + log("load module: '", Cstring(policy_module), "' for " + "label: '", Cstring(policy_label), "'"); if (policy.last("trace_policy")) break; } @@ -224,33 +226,33 @@ int main(int argc, char **argv) Trace::Subject_id subjects[32]; size_t num_subjects = trace.subjects(subjects, 32); - printf("%zd tracing subjects present\n", num_subjects); + log(num_subjects, " tracing subjects present"); for (size_t i = 0; i < num_subjects; i++) { Trace::Subject_info info = trace.subject_info(subjects[i]); - printf("ID:%d label:\"%s\" name:\"%s\" state:%s policy:%d time:%lld\n", - subjects[i].id, - info.session_label().string(), - info.thread_name().string(), - state_name(info.state()), - info.policy_id().id, - info.execution_time().value); + log("ID:", subjects[i].id, " " + "label:\"", info.session_label(), "\" " + "name:\"", info.thread_name(), "\" " + "state:", state_name(info.state()), " " + "policy:", info.policy_id().id, " " + "time:", info.execution_time().value); /* enable tracing */ if (!policy_set && strcmp(info.session_label().string(), policy_label) == 0 && strcmp(info.thread_name().string(), "test-thread") == 0) { try { - PINF("enable tracing for thread:'%s' with policy:%d", - info.thread_name().string(), policy_id.id); + log("enable tracing for " + "thread:'", info.thread_name().string(), "' with " + "policy:", policy_id.id); trace.trace(subjects[i].id, policy_id, 16384U); Dataspace_capability ds_cap = trace.buffer(subjects[i].id); test_monitor = new (env()->heap()) Trace_buffer_monitor(subjects[i].id, ds_cap); - } catch (Trace::Source_is_dead) { PERR("source is dead"); } + } catch (Trace::Source_is_dead) { error("source is dead"); } policy_set = true; } @@ -266,6 +268,6 @@ int main(int argc, char **argv) if (test_monitor) destroy(env()->heap(), test_monitor); - printf("--- test-trace finished ---\n"); + log("--- test-trace finished ---"); return 0; } diff --git a/repos/os/src/test/uart/main.cc b/repos/os/src/test/uart/main.cc index c5bf2bbcf..39d4bcc6a 100644 --- a/repos/os/src/test/uart/main.cc +++ b/repos/os/src/test/uart/main.cc @@ -12,6 +12,7 @@ */ #include +#include #include #include @@ -20,7 +21,7 @@ using namespace Genode; int main() { - printf("--- UART test started ---\n"); + log("--- UART test started ---"); static Timer::Connection timer; static Uart::Connection uart; diff --git a/repos/os/src/test/vfs_stress/main.cc b/repos/os/src/test/vfs_stress/main.cc index f93332d61..afb269720 100644 --- a/repos/os/src/test/vfs_stress/main.cc +++ b/repos/os/src/test/vfs_stress/main.cc @@ -187,7 +187,7 @@ struct Mkdir_test : public Stress_test : Stress_test(vfs, parent) { try { mkdir_a(1); } catch (...) { - error("failed at '",path,"' after ",count," directories"); + error("failed at '", path, "' after ", count, " directories"); } } @@ -231,7 +231,7 @@ struct Populate_test : public Stress_test return; default: - Genode::String<2> dir_name(&dir_type, 1); + Genode::String<2> dir_name(Genode::Cstring(&dir_type, 1)); error("bad directory '", dir_name, "' at the end of '", path, "'"); throw Exception(); } @@ -297,7 +297,7 @@ struct Write_test : public Stress_test return; default: - Genode::String<2> dir_name(&dir_type, 1); + Genode::String<2> dir_name(Genode::Cstring(&dir_type, 1)); error("bad directory ",dir_name," at the end of '", path, "'"); throw Exception(); } @@ -365,7 +365,7 @@ struct Read_test : public Stress_test return; default: - Genode::String<2> dir_name(&dir_type, 1); + Genode::String<2> dir_name(Genode::Cstring(&dir_type, 1)); error("bad directory ",dir_name," at the end of '", path, "'"); throw Exception(); } diff --git a/repos/os/src/test/volatile_object/main.cc b/repos/os/src/test/volatile_object/main.cc index 0e67d6d52..bffa1a828 100644 --- a/repos/os/src/test/volatile_object/main.cc +++ b/repos/os/src/test/volatile_object/main.cc @@ -13,10 +13,11 @@ /* Genode includes */ #include -#include +#include using Genode::Volatile_object; using Genode::Lazy_volatile_object; +using Genode::log; struct Object @@ -25,16 +26,16 @@ struct Object Object(unsigned id) : id(id) { - PLOG("construct Object %d", id); + log("construct Object ", id); } ~Object() { - PLOG("destruct Object %d", id); + log("destruct Object ", id); } - void method() { PLOG("method called on Object %d", id); } - void const_method() const { PLOG("const method called on Object %d", id); } + void method() { log("method called on Object ", id); } + void const_method() const { log("const method called on Object ", id); } }; @@ -46,12 +47,12 @@ struct Member_with_reference Member_with_reference(Object &reference) : reference(reference) { - PLOG("construct Member_with_reference"); + log("construct Member_with_reference"); } ~Member_with_reference() { - PLOG("destruct Member_with_reference"); + log("destruct Member_with_reference"); } }; @@ -65,12 +66,12 @@ struct Compound : member(object) { - PLOG("construct Compound"); + log("construct Compound"); } ~Compound() { - PLOG("destruct Compound"); + log("destruct Compound"); } }; @@ -90,16 +91,16 @@ struct Throwing Throwing(Bool const &throws) { if (throws.b) { - PLOG("construct Throwing -> throw exception"); + log("construct Throwing -> throw exception"); throw -1; } else { - PLOG("construct Throwing -> don't throw"); + log("construct Throwing -> don't throw"); } } virtual ~Throwing() { - PLOG("destruct Throwing"); + log("destruct Throwing"); } }; @@ -114,58 +115,58 @@ int main(int, char **) { using namespace Genode; - printf("--- test-volatile_object started ---\n"); + log("--- test-volatile_object started ---"); { Object object_1(1); Object object_2(2); - printf("-- create Compound object --\n"); + log("-- create Compound object --"); Compound compound(object_1); - PLOG("compound.member.constructed returns %d", - compound.member.constructed()); - PLOG("compound.lazy_member.constructed returns %d", - compound.lazy_member.constructed()); + log("compound.member.constructed returns ", + compound.member.constructed()); + log("compound.lazy_member.constructed returns ", + compound.lazy_member.constructed()); - printf("-- construct lazy member --\n"); + log("-- construct lazy member --"); compound.lazy_member.construct(object_2); - PLOG("compound.lazy_member.constructed returns %d", - compound.lazy_member.constructed()); + log("compound.lazy_member.constructed returns ", + compound.lazy_member.constructed()); - printf("-- call method on member (with reference to Object 1) --\n"); + log("-- call method on member (with reference to Object 1) --"); call_const_method(compound); - printf("-- reconstruct member with Object 2 as reference --\n"); + log("-- reconstruct member with Object 2 as reference --"); compound.member.construct(object_2); - printf("-- call method on member --\n"); + log("-- call method on member --"); call_const_method(compound); - printf("-- destruct member --\n"); + log("-- destruct member --"); compound.member.destruct(); - printf("-- try to call method on member, catch exception --\n"); + log("-- try to call method on member, catch exception --"); try { call_const_method(compound); } catch (typename Volatile_object::Deref_unconstructed_object) { - PLOG("got exception, as expected"); } + log("got exception, as expected"); } - printf("-- destruct Compound and Objects 1 and 2 --\n"); + log("-- destruct Compound and Objects 1 and 2 --"); } try { - printf("-- construct Throwing object\n"); + log("-- construct Throwing object"); Bool const b_false(false), b_true(true); Volatile_object inst(b_false); inst.construct(b_true); - PERR("expected contructor to throw"); + Genode::error("expected contructor to throw"); } catch (int i) { - printf("-- catched exception as expected\n"); + log("-- catched exception as expected"); } - printf("--- test-volatile_object finished ---\n"); + log("--- test-volatile_object finished ---"); return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/genode_block.cc b/repos/ports-foc/src/lib/l4lx/genode_block.cc index c34b1fe7b..5de76bf8b 100644 --- a/repos/ports-foc/src/lib/l4lx/genode_block.cc +++ b/repos/ports-foc/src/lib/l4lx/genode_block.cc @@ -12,7 +12,7 @@ */ #include -#include +#include #include #include #include @@ -64,7 +64,7 @@ namespace { { int idx = _find(0); if (idx == 0) { - PERR("Req cache full!"); + Genode::error("Req cache full!"); enter_kdebug("Req_cache"); } @@ -75,7 +75,7 @@ namespace { { int idx = _find(packet); if (idx == 0) { - PERR("Req cache entry not found!"); + Genode::error("Req cache entry not found!"); enter_kdebug("Req_cache"); } @@ -168,7 +168,7 @@ namespace { for (unsigned i = 0; i < _count; i++) { if (_devs[i]->context() == s.context()) { if (l4_error(l4_irq_trigger(_devs[i]->irq_cap())) != -1) - PWRN("IRQ block trigger failed\n"); + Genode::warning("IRQ block trigger failed"); break; } } @@ -234,7 +234,7 @@ extern "C" { j++; } } - } catch(...) { PWRN("config parsing error!"); } + } catch(...) { Genode::warning("config parsing error!"); } } return count; } @@ -243,7 +243,7 @@ extern "C" { const char* genode_block_name(unsigned idx) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return 0; } return devices[idx]->name(); @@ -253,7 +253,7 @@ extern "C" { l4_cap_idx_t genode_block_irq_cap(unsigned idx) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return 0; } return devices[idx]->irq_cap(); @@ -278,7 +278,7 @@ extern "C" { int *write, unsigned long *queue_sz) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return; } @@ -295,7 +295,7 @@ extern "C" { void *req, unsigned long *offset) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return 0; } @@ -317,7 +317,7 @@ extern "C" { unsigned long size, unsigned long long disc_offset, int write) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return; } @@ -336,7 +336,7 @@ extern "C" { void genode_block_collect_responses(unsigned idx) { if (idx >= genode_block_count()) { - PWRN("Invalid index!"); + Genode::warning(__func__, ": invalid index!"); return; } diff --git a/repos/ports-foc/src/lib/l4lx/genode_net.cc b/repos/ports-foc/src/lib/l4lx/genode_net.cc index 375d137f8..af134b075 100644 --- a/repos/ports-foc/src/lib/l4lx/genode_net.cc +++ b/repos/ports-foc/src/lib/l4lx/genode_net.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,7 +52,8 @@ struct Counter : public Genode::Thread_deprecated<8192> int interval = 5; while(1) { _timer.msleep(interval * 1000); - PDBG("LX Packets %d/s bytes/s: %d", cnt / interval, size / interval); + Genode::log("LX Packets ", cnt/interval, "/s " + "bytes/s: ", size / interval); cnt = 0; size = 0; } @@ -120,7 +121,7 @@ namespace { receiver.wait_for_signal(); if (l4_error(l4_irq_trigger(_cap)) != -1) - PWRN("IRQ net trigger failed\n"); + warning("IRQ net trigger failed"); } } diff --git a/repos/ports-foc/src/lib/l4lx/include/platform_env.h b/repos/ports-foc/src/lib/l4lx/include/platform_env.h index 4ffcc1e75..5566483e5 100644 --- a/repos/ports-foc/src/lib/l4lx/include/platform_env.h +++ b/repos/ports-foc/src/lib/l4lx/include/platform_env.h @@ -21,7 +21,7 @@ #define _PLATFORM_ENV_H_ /* Genode includes */ -#include +#include #include #include #include @@ -71,8 +71,9 @@ struct Upgradeable_client : CLIENT void upgrade_ram(Genode::size_t quota) { - PINF("upgrading quota donation for Env::%s (%zd bytes)", - CLIENT::Rpc_interface::service_name(), quota); + Genode::log("upgrading quota donation for " + "Env::", CLIENT::Rpc_interface::service_name(), " " + "(", quota, " bytes)"); char buf[128]; Genode::snprintf(buf, sizeof(buf), "ram_quota=%zd", quota); diff --git a/repos/ports-foc/src/lib/l4lx/l4_io.cc b/repos/ports-foc/src/lib/l4lx/l4_io.cc index 5136f59ad..ad49a67a4 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_io.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_io.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -24,13 +24,11 @@ namespace Fiasco { using namespace Fiasco; -static bool DEBUG = false; - extern "C" { l4io_device_handle_t l4io_get_root_device(void) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } @@ -38,7 +36,7 @@ extern "C" { int l4io_iterate_devices(l4io_device_handle_t *devhandle, l4io_device_t *dev, l4io_resource_handle_t *reshandle) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 1; } @@ -48,14 +46,14 @@ extern "C" { l4io_resource_handle_t *reshandle, l4io_resource_t *res) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } long l4io_request_ioport(unsigned portnum, unsigned len) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } @@ -65,14 +63,11 @@ extern "C" { { using namespace Genode; - if(DEBUG) - PDBG("phys=%lx virt=%lx size=%lx flags=%x", phys, virt, size, flags); - Io_mem_connection *iomem = new (env()->heap()) Io_mem_connection(phys, size); L4lx::Dataspace *ds = L4lx::Env::env()->dataspaces()->insert("iomem", iomem->dataspace()); if (!L4lx::Env::env()->rm()->attach_at(ds, size, 0, (void*)virt)) { - PERR("Could not reserve IO mem region at %lx", virt); + error("could not reserve IO mem region at ", Hex(virt)); L4lx::Env::env()->dataspaces()->remove(ds); destroy(env()->heap(), iomem); return 1; @@ -84,7 +79,7 @@ extern "C" { long l4io_search_iomem_region(l4_addr_t phys, l4_addr_t size, l4_addr_t *rstart, l4_addr_t *rsize) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } @@ -92,28 +87,28 @@ extern "C" { long l4io_request_iomem(l4_addr_t phys, unsigned long size, int flags, l4_addr_t *virt) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } long l4io_release_iomem(l4_addr_t virt, unsigned long size) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } long l4io_request_irq(int irqnum, l4_cap_idx_t irqcap) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } long l4io_release_irq(int irqnum, l4_cap_idx_t irq_cap) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } @@ -121,7 +116,7 @@ extern "C" { int l4io_has_resource(enum l4io_resource_types_t type, l4vbus_paddr_t start, l4vbus_paddr_t end) { - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc b/repos/ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc index 6096d7d95..8a15bcc63 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_c_dataspace.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include /* L4lx includes */ @@ -27,8 +27,6 @@ namespace Fiasco { using namespace Fiasco; -static bool DEBUG = false; - extern "C" { int l4re_ds_map_region(const l4re_ds_t ds, l4_addr_t offset, unsigned long flags, @@ -36,13 +34,9 @@ extern "C" { { using namespace L4lx; - if(DEBUG) - PDBG("ds=%lx offset=%lx flags=%lx min_addr=%lx max_addr=%lx", - ds, offset, flags, min_addr, max_addr); - Dataspace *ref = Env::env()->dataspaces()->find_by_ref(ds); if (!ref) { - PWRN("ds=%lx doesn't exist", ds); + Genode::warning(__func__, ": ds=", Genode::Hex(ds), " doesn't exist"); enter_kdebug("ENOTF"); return L4_ERANGE; } @@ -50,7 +44,8 @@ extern "C" { try { Genode::env()->rm_session()->attach_at(ref->cap(), min_addr); } catch(...) { - PWRN("Could not attach dataspace %s at %p!", ref->name(), (void*)min_addr); + Genode::warning(__func__, ": could not attach " + "dataspace ", ref->name(), " at ", (void*)min_addr); enter_kdebug("EXC"); return -1; } @@ -62,12 +57,9 @@ extern "C" { { using namespace L4lx; - if (DEBUG) - PDBG("ds=%lx", ds); - Dataspace *ref = Env::env()->dataspaces()->find_by_ref(ds); if (!ref) { - PWRN("ds=%lx doesn't exist", ds); + Genode::warning(__func__, ": ds=", Genode::Hex(ds), " doesn't exist"); return -1; } @@ -80,21 +72,16 @@ extern "C" { { using namespace L4lx; - if (DEBUG) - PDBG("ds=%lx offset=%lx", ds, offset); - Dataspace *ref = Env::env()->dataspaces()->find_by_ref(ds); if (!ref) { - PWRN("ds=%lx doesn't exist", ds); + Genode::warning(__func__, ": ds=", Genode::Hex(ds), " doesn't exist"); enter_kdebug("ERR"); return -1; } - if (DEBUG) - PDBG("Found dataspace %s", ref->name()); - if (!ref->cap().valid()) { - PWRN("Cannot determine physical address for dataspace %s!", ref->name()); + Genode::warning(__func__, ": cannot determine physical address for " + "dataspace ", ref->name()); return -1; } @@ -108,7 +95,7 @@ extern "C" { int l4re_ds_copy_in(const l4re_ds_t ds, l4_addr_t dst_offs, const l4re_ds_t src, l4_addr_t src_offs, unsigned long size) { - PWRN("%s: Not implemented yet!",__func__); + Genode::warning(__func__, ": not implemented"); return 0; } @@ -117,18 +104,12 @@ extern "C" { { using namespace L4lx; - if (DEBUG) - PDBG("ds=%lx", ds); - Dataspace *ref = Env::env()->dataspaces()->find_by_ref(ds); if (!ref) { - PWRN("ds=%lx doesn't exist", ds); + Genode::warning(__func__, ": ds=", Genode::Hex(ds), " doesn't exist"); return -1; } - if (DEBUG) - PDBG("Found dataspace %s", ref->name()); - stats->size = ref->size(); return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc b/repos/ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc index 004f14751..15efd2126 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_c_mem_alloc.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -26,8 +26,6 @@ namespace Fiasco { using namespace Fiasco; -static const bool DEBUG = false; - extern "C" { long l4re_ma_alloc(unsigned long size, l4re_ds_t const mem, @@ -35,9 +33,6 @@ extern "C" { { using namespace L4lx; - if (DEBUG) - PDBG("size=%lx mem=%lx flags=%lx", size, mem, flags); - Dataspace *ds; if (Genode::log2(size) >= Chunked_dataspace::CHUNK_SIZE_LOG2) { ds = new (Genode::env()->heap()) @@ -60,7 +55,7 @@ extern "C" { long l4re_ma_free(l4re_ds_t const mem) { - PWRN("%s: Not implemented yet!",__func__); + Genode::warning(__func__, " not implemented"); return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_c_namespace.cc b/repos/ports-foc/src/lib/l4lx/l4_re_c_namespace.cc index aa55bacaf..3120b68b2 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_c_namespace.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_c_namespace.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include namespace Fiasco { #include @@ -25,8 +25,10 @@ extern "C" { long l4re_ns_query_srv(l4re_namespace_t srv, char const *name, l4_cap_idx_t const cap) { - PDBG("srv=%lx name=%s cap=%lx", srv, name, cap); - PWRN("%s: Not implemented yet!", __func__); + Genode::log(__func__, ": srv=", Genode::Hex(srv), " name=", name, " " + "cap=", Genode::Hex(cap)); + + Genode::warning(__func__, " not implemented"); return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_c_rm.cc b/repos/ports-foc/src/lib/l4lx/l4_re_c_rm.cc index 16fabb64d..2a9e3814d 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_c_rm.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_c_rm.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -27,11 +27,6 @@ namespace Fiasco { using namespace Fiasco; -static const bool DEBUG = false; /* print usage of region map functions */ -static const bool DEBUG_FIND = false; /* print also usage of region map lookups */ -static const bool DEBUG_SEARCH = false; /* print also information about the - search for alternative address ranges */ - enum { L4RE_SEARCH_FOR_REGION = 0x20, L4RE_REGION_RESERVED = 0x08 @@ -44,9 +39,6 @@ extern "C" { { using namespace L4lx; - if(DEBUG_FIND) - PDBG("addr=%lx size=%lx", *addr, *size); - *m = L4_INVALID_CAP; Region *r = Env::env()->rm()->find_region(addr, (Genode::size_t*)size); if (r) { @@ -56,9 +48,6 @@ extern "C" { } else *flags = 0; - if(DEBUG_FIND) - PDBG("Found addr=%lx size=%lx reserved?=%x ds=%lx", - *addr, *size, *flags, *m); return 0; } @@ -71,13 +60,9 @@ extern "C" { void *original_start = *start; - if (DEBUG) - PDBG("start=%p size=%lx flags=%lx mem=%lx offs=%lx align=%u", - *start, size, flags, mem, offs, align); - L4lx::Dataspace *ds = L4lx::Env::env()->dataspaces()->find_by_ref(mem); if (!ds) { - PERR("mem=%lx doesn't exist", mem); + error(__func__, "mem=", Hex(mem), " doesn't exist"); return -L4_ERANGE; } @@ -87,45 +72,36 @@ extern "C" { l4_addr_t start_addr = (l4_addr_t)*start; l4_addr_t aligned_start_addr = align_addr(start_addr, align); if (aligned_start_addr != start_addr) { - if (DEBUG_SEARCH) - PDBG("attach failed: start=%lx, trying %lx instead", - start_addr, aligned_start_addr); *start = (void*)aligned_start_addr; } else { if (start_addr <= ((addr_t)~0 - 2*(1 << align) + 1)) { - if (DEBUG_SEARCH) - PDBG("attach failed: start=%lx, trying %lx instead", - start_addr, start_addr + (1 << align)); start_addr += (1 << align); *start = (void*)start_addr; } else { - PWRN("Couldn't attach ds of size 0x%lx at %p", size, original_start); + warning(__func__, ": couldn't attach ds of " + "size ", Hex(size), " at ", original_start); return -L4_ERANGE; } } } else { - PWRN("Couldn't attach ds of size 0x%lx at %p", size, original_start); + warning(__func__, ": couldn't attach ds of " + "size ", Hex(size), " at ", original_start); return -L4_ERANGE; } } - if (DEBUG) - PDBG("attached at %p", *start); return 0; } int l4re_rm_detach(void *addr) { - if(DEBUG) - PDBG("addr=%p", addr); - Genode::addr_t start = (Genode::addr_t) addr; Genode::size_t size = 0; L4lx::Region *r = L4lx::Env::env()->rm()->find_region(&start, &size); if (!r) { - PWRN("Nothing found at %p", addr); + Genode::warning(__func__, ": nothing found at ", addr); return -1; } @@ -138,20 +114,13 @@ extern "C" { int l4re_rm_reserve_area(l4_addr_t *start, unsigned long size, unsigned flags, unsigned char align) { - if (DEBUG) - PDBG("*start=%lx size=%lx align=%u flags=%x", - *start, size, align, flags); - L4lx::Region *r = L4lx::Env::env()->rm()->reserve_range(size, align, *start); if (r) { *start = (l4_addr_t) r->addr(); - if (DEBUG) - PDBG("return %lx", *start); - return 0; } - PWRN("Could not reserve area!"); + Genode::warning(__func__, ": could not reserve area!"); return -1; } @@ -160,11 +129,8 @@ extern "C" { { L4lx::Region* md = L4lx::Env::env()->rm()->metadata((void*)addr); - if (DEBUG) - PDBG("%lx", addr); - if (!md) { - PWRN("No region found at %p", (void*) addr); + Genode::warning(__func__, ": no region found at ", Genode::Hex(addr)); return -1; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc b/repos/ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc index 5d7651d11..60ed451a3 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_c_util_cap.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include namespace Fiasco { @@ -22,31 +22,26 @@ namespace Fiasco { using namespace Fiasco; -static const bool DEBUG = false; - extern "C" { l4_cap_idx_t l4re_util_cap_alloc(void) { l4_cap_idx_t ret = Genode::Capability_space::alloc_kcap(); - if (DEBUG) - PDBG("ret=%lx", ret); - return ret; } void l4re_util_cap_free(l4_cap_idx_t cap) { - PWRN("%s: Not implemented yet!",__func__); + Genode::warning(__func__, " not implemented"); } l4_msgtag_t l4re_util_cap_release(l4_cap_idx_t cap) { l4_msgtag_t ret = l4_msgtag(0, 0, 0, 0); - PWRN("%s: Not implemented yet!",__func__); + Genode::warning(__func__, " not implemented"); return ret; } diff --git a/repos/ports-foc/src/lib/l4lx/l4_re_env.cc b/repos/ports-foc/src/lib/l4lx/l4_re_env.cc index 85362fe01..3eb304407 100644 --- a/repos/ports-foc/src/lib/l4lx/l4_re_env.cc +++ b/repos/ports-foc/src/lib/l4lx/l4_re_env.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -25,7 +25,6 @@ namespace Fiasco { using namespace Fiasco; -static const bool DEBUG = false; static l4re_env_t __l4re_env; extern void* l4lx_kinfo; @@ -39,9 +38,6 @@ extern "C" { { using namespace L4lx; - if (DEBUG) - PDBG("name=%s l=%x", name, l); - try { Genode::Rom_connection rom(name); Genode::size_t size = Genode::Dataspace_client(rom.dataspace()).size(); @@ -62,7 +58,7 @@ extern "C" { entry->cap = ds->ref(); return entry; } catch(Genode::Rom_connection::Rom_connection_failed) { - PWRN("File %s is missing", name); + Genode::warning(__func__, ": file ", name, " is missing"); } return 0; } diff --git a/repos/ports-foc/src/lib/l4lx/l4lx_irq.cc b/repos/ports-foc/src/lib/l4lx/l4lx_irq.cc index 0d434f7ab..6e5106f69 100644 --- a/repos/ports-foc/src/lib/l4lx/l4lx_irq.cc +++ b/repos/ports-foc/src/lib/l4lx/l4lx_irq.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -30,8 +30,6 @@ namespace Fiasco { using namespace Fiasco; -static const bool DEBUG = false; - enum { TIMER_IRQ = 0 }; unsigned int l4lx_irq_max = l4x_nr_irqs(); @@ -59,15 +57,12 @@ unsigned int l4lx_irq_dev_startup(struct irq_data *data) struct l4x_irq_desc_private *p = (struct l4x_irq_desc_private*) irq_get_chip_data(irq); - if (DEBUG) - PDBG("irq=%d", irq); - /* First test whether a capability has been registered with * this IRQ number */ p->irq_cap = l4x_have_irqcap(irq); p->cpu = l4x_smp_processor_id(); if (l4_is_invalid_cap(p->irq_cap)) { - PERR("Invalid irq cap!"); + Genode::error("invalid irq cap!"); return 0; } @@ -80,13 +75,10 @@ void l4lx_irq_dev_shutdown(struct irq_data *data) { if (data->irq == TIMER_IRQ) { - PWRN("timer shutdown not implemented yet"); + Genode::warning("timer shutdown not implemented yet"); return; } - if (DEBUG) - PDBG("irq=%d", data->irq); - l4lx_irq_dev_disable(data); } @@ -105,14 +97,12 @@ void l4lx_irq_dev_enable(struct irq_data *data) unsigned long flags = 0; p->enabled = 1; - if (DEBUG) - PDBG("irq=%d cap=%lx", data->irq, p->irq_cap); - l4x_irq_save(&flags); l4_msgtag_t ret = l4_irq_attach(p->irq_cap, data->irq << 2, l4x_cpu_thread_get_cap(p->cpu)); if (l4_error(ret)) - PWRN("Attach to irq %lx failed with error %ld!", p->irq_cap, l4_error(ret)); + Genode::warning("attach to irq ", Genode::Hex(p->irq_cap), " " + "failed, error=", l4_error(ret)); l4x_irq_restore(flags); l4lx_irq_dev_eoi(data); @@ -125,12 +115,9 @@ void l4lx_irq_dev_disable(struct irq_data *data) (struct l4x_irq_desc_private*) irq_get_chip_data(data->irq);; p->enabled = 0; - if (DEBUG) - PDBG("irq=%d cap=%lx", data->irq, p->irq_cap); - Linux::Irq_guard guard; if (l4_error(l4_irq_detach(p->irq_cap))) - PWRN("%02d: Unable to detach from IRQ\n", data->irq); + Genode::warning("unable to detach from IRQ ", data->irq); } @@ -174,17 +161,17 @@ int l4lx_irq_dev_set_affinity(struct irq_data *data, unsigned long flags = 0; l4x_migrate_lock(&flags); if (l4_error(l4_irq_detach(p->irq_cap))) - PWRN("%02d: Unable to detach from IRQ\n", data->irq); + Genode::warning("unable to detach from IRQ ", data->irq); l4x_cpumask_copy(data, dest); p->cpu = target_cpu; - PDBG("switched irq %d to cpu %d", data->irq, target_cpu); + Genode::log("switched irq ", data->irq, " to cpu ", target_cpu); l4_msgtag_t ret = l4_irq_attach(p->irq_cap, data->irq << 2, l4x_cpu_thread_get_cap(p->cpu)); if (l4_error(ret)) - PWRN("Attach to irq %lx failed with error %ld!", p->irq_cap, l4_error(ret)); + Genode::warning("attach to irq ", p->irq_cap, " failed, error=", l4_error(ret)); if (p->enabled) l4_irq_unmask(p->irq_cap); @@ -259,7 +246,7 @@ int l4x_alloc_irq_desc_data(int irq) struct l4x_irq_desc_private *p; Genode::env()->heap()->alloc(sizeof(struct l4x_irq_desc_private), (void**)&p); if (!p) { - PWRN("Could not allocate irq descriptor memory!"); + Genode::warning("could not allocate irq descriptor memory!"); return -12; //ENOMEM; } diff --git a/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc b/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc index 0ff0dd53b..81e572405 100644 --- a/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc +++ b/repos/ports-foc/src/lib/l4lx/l4lx_thread.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -38,7 +38,6 @@ struct l4lx_thread_name_struct { typedef l4_utcb_t *l4lx_thread_t; -static const bool DEBUG = false; static L4lx::Vcpu* vcpus[L4LX_THREAD_NO_THREADS]; struct l4lx_thread_name_struct l4lx_thread_names[L4LX_THREAD_NO_THREADS]; @@ -69,7 +68,7 @@ static void* alloc_vcpu_state() L4lx::Region_manager *rm = L4lx::Env::env()->rm(); L4lx::Region* r = rm->reserve_range(L4_PAGESIZE, 12); if (!r) { - PWRN("Couldn't allocate vcpu area"); + Genode::warning("couldn't allocate vcpu area"); return 0; } l4_addr_t addr = r->addr(); @@ -78,8 +77,8 @@ static void* alloc_vcpu_state() l4_fpage_t fpage = l4_fpage(addr, L4_LOG2_PAGESIZE, L4_CAP_FPAGE_RW); l4_msgtag_t tag = l4_task_add_ku_mem(Fiasco::TASK_CAP, fpage); if (l4_error(tag)) - PERR("l4_task_add_ku_mem for %p failed with %ld!", - (void*)addr, l4_error(tag)); + Genode::error("l4_task_add_ku_mem for ", Genode::Hex(addr), " " + "failed, error=", l4_error(tag)); return (void*)addr; } @@ -123,16 +122,11 @@ l4lx_thread_t l4lx_thread_create(L4_CV void (*thread_func)(void *data), Linux::Irq_guard guard; - if (DEBUG) - PDBG("func=%p cpu=%x stack=%p data=%p data_size=%x prio=%d name=%s", - thread_func, cpu_nr, stack_pointer, stack_data, - stack_data_size, prio, name); - void *addr = 0; if (vcpu_state) { addr = alloc_vcpu_state(); if (!addr) { - PWRN("No kernel-user memory left!"); + Genode::warning(__func__, ": no kernel-user memory left!"); return 0; } *vcpu_state = (l4_vcpu_state_t *) addr; @@ -161,8 +155,6 @@ int l4lx_thread_start(struct l4lx_thread_start_info_t *startinfo) { Linux::Irq_guard guard; - if (DEBUG) - PDBG("ip=%lx sp=%lx", startinfo->ip, startinfo->sp); L4lx::Vcpu *vc = (L4lx::Vcpu*) startinfo->l4cap; vc->unblock(); return 0; @@ -173,9 +165,6 @@ void l4lx_thread_pager_change(l4_cap_idx_t thread, l4_cap_idx_t pager) { Linux::Irq_guard guard; - if (DEBUG) - PDBG("Change pager of %lx to %lx", thread, pager); - l4_cap_idx_t p_id = thread - Fiasco::THREAD_GATE_CAP + Fiasco::THREAD_PAGER_CAP; @@ -188,7 +177,7 @@ void l4lx_thread_set_kernel_pager(l4_cap_idx_t thread) { Linux::Irq_guard guard; - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); } @@ -196,7 +185,7 @@ void l4lx_thread_shutdown(l4lx_thread_t u, void *v) { Linux::Irq_guard guard; - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); } @@ -204,7 +193,7 @@ int l4lx_thread_equal(l4_cap_idx_t t1, l4_cap_idx_t t2) { Linux::Irq_guard guard; - PWRN("%s: Not implemented yet!", __func__); + Genode::warning(__func__, " not implemented"); return 0; } @@ -212,7 +201,7 @@ int l4lx_thread_equal(l4_cap_idx_t t1, l4_cap_idx_t t2) l4_cap_idx_t l4lx_thread_get_cap(l4lx_thread_t t) { if (!vcpus[thread_id(t)]) { - PWRN("Invalid utcb %lx", (unsigned long) t); + Genode::warning("invalid utcb ", t); return L4_INVALID_CAP; } return vcpus[thread_id(t)]->native_thread().kcap; diff --git a/repos/ports-foc/src/lib/l4lx/rm.cc b/repos/ports-foc/src/lib/l4lx/rm.cc index 0bca5a3ce..f07d674e0 100644 --- a/repos/ports-foc/src/lib/l4lx/rm.cc +++ b/repos/ports-foc/src/lib/l4lx/rm.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -28,9 +28,6 @@ namespace Fiasco { using namespace L4lx; -static const bool DEBUG_SEARCH = false; /* print information about the search - for alternative address ranges */ - Region* Region_manager::find_region(Genode::addr_t *addr, Genode::size_t *size) { Genode::Allocator_avl_base::Block *b = _find_by_address(*addr); @@ -117,7 +114,6 @@ Region* Region_manager::reserve_range(Genode::size_t size, int align, addr = start ? env()->rm_session()->attach_at(rm->dataspace(), start) : env()->rm_session()->attach(rm->dataspace()); - //PDBG("attach done addr=%p!", addr); break; } catch(Rm_session::Attach_failed e) { destroy(env()->heap(), rm); @@ -126,23 +122,23 @@ Region* Region_manager::reserve_range(Genode::size_t size, int align, /* the original start address might have a different alignment */ addr_t aligned_start = align_addr(start, align); if (aligned_start != start) { - if (DEBUG_SEARCH) - PDBG("attach failed: start=%lx, trying %lx instead", - start, aligned_start); start = aligned_start; } else { if (start <= ((addr_t)~0 - 2*(1 << align) + 1)) { - if (DEBUG_SEARCH) - PDBG("attach failed: start=%lx, trying %lx instead", - start, start + (1 << align)); start += (1 << align); } else { - PWRN("attach failed: start=%lx, size=0x%zx, align=%d", original_start, size, align); + warning(__func__, ": attach failed: " + "start=", Hex(original_start), " " + "size=", Hex(size), " " + "align=", align); return 0; } } } else { - PWRN("attach failed: start=0, size=0x%zx, align=%d", size, align); + warning(__func__, ": attach failed: " + "start=", Hex(original_start), " " + "size=", Hex(size), " " + "align=", align); return 0; } } @@ -174,18 +170,18 @@ void Region_manager::reserve_range(Genode::addr_t addr, Genode::size_t size, void Region_manager::dump() { Genode::addr_t addr = 0; - Genode::printf("Region map:\n"); + Genode::log("Region map:"); while (true) { Allocator_avl_base::Block *b = _find_by_address(addr); Region *r = metadata((void*)addr); if (!b) return; - Genode::printf(" 0x%08lx - 0x%08lx ", - b->addr(), b->addr() + b->size()); - if (b->used()) - Genode::printf("[%s]\n", (r && r->ds()) ? r->ds()->name() : "reserved"); - else - Genode::printf("[unused]\n"); + + Genode::log(" ", Genode::Hex_range(b->addr(), b->size()), + " [", b->used() ? ((r && r->ds()) ? r->ds()->name() : "reserved") + : "unused", + "]"); + addr = b->addr() + b->size(); } }; @@ -222,7 +218,7 @@ void Region_manager::remove_mapping(void *virt) l4_fpage_t fpage = l4_fpage((l4_addr_t)virt, L4_LOG2_PAGESIZE, L4_FPAGE_RW); l4_msgtag_t tag = l4_task_unmap(L4_BASE_TASK_CAP, fpage, L4_FP_ALL_SPACES); if (l4_error(tag)) - PWRN("unmapping %p failed with error %ld!", virt, l4_error(tag)); + Genode::warning("unmapping ", virt, " failed, error=", l4_error(tag)); Mapping *m = _virt_to_phys(virt); if (m) { @@ -259,8 +255,8 @@ void Region_manager::map(void *phys) l4_msgtag_t tag = l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP, snd_fpage, (l4_addr_t)m->virt()); if (l4_error(tag)) { - PERR("mapping from %p to %p failed with error %ld!", - phys, m->virt(), l4_error(tag)); + Genode::error("mapping from ", phys, " to ", m->virt(), " " + "failed, error=", l4_error(tag)); } m = m->next(); } diff --git a/repos/ports-foc/src/lib/l4lx/startup.cc b/repos/ports-foc/src/lib/l4lx/startup.cc index bd2f3c966..57163fbdc 100644 --- a/repos/ports-foc/src/lib/l4lx/startup.cc +++ b/repos/ports-foc/src/lib/l4lx/startup.cc @@ -39,8 +39,6 @@ extern void* l4lx_kinfo; /* pointer to the KIP */ extern "C" int linux_main(int argc, char **argv); /* l4linux entry function */ -static const bool DEBUG = false; - static void parse_cmdline(char*** cmd, int *num) { using namespace Genode; @@ -53,13 +51,10 @@ static void parse_cmdline(char*** cmd, int *num) try { config()->xml_node().attribute("args").value(arg_str, sizeof(arg_str)); } catch(...) { - PWRN("Couldn't parse commandline from config!"); + warning("couldn't parse commandline from config!"); arg_str[0] = 0; } - if (DEBUG) - PDBG("Read the following commandline from config: %s", arg_str); - unsigned i = 1; words[0] = (char*) "vmlinux"; for (char* start = &arg_str[0], *ptr = start; i < MAX_ARGS; ptr++) { @@ -142,15 +137,12 @@ int main(int, char**) int cmd_num = 0; char** cmdline = 0; - PINF("Booting L4Linux ..."); + Genode::log("Booting L4Linux ..."); register_reserved_areas(); map_kip(); prepare_l4re_env(); parse_cmdline(&cmdline, &cmd_num); - if (DEBUG) - L4lx::Env::env()->rm()->dump(); - return linux_main(cmd_num, cmdline); } diff --git a/repos/ports/include/noux_session/client.h b/repos/ports/include/noux_session/client.h index 8be0b456f..89a34ecf8 100644 --- a/repos/ports/include/noux_session/client.h +++ b/repos/ports/include/noux_session/client.h @@ -17,7 +17,7 @@ #include #include #include -#include +#include namespace Noux { @@ -39,7 +39,7 @@ namespace Noux { bool result = call(sc); if ((result == false) && verbose) - PERR("syscall %s failed", syscall_name(sc)); + error("syscall ", syscall_name(sc), " failed"); return result; } diff --git a/repos/ports/include/vmm/guest_memory.h b/repos/ports/include/vmm/guest_memory.h index 553b890c4..114c87a7d 100644 --- a/repos/ports/include/vmm/guest_memory.h +++ b/repos/ports/include/vmm/guest_memory.h @@ -62,7 +62,7 @@ struct Vmm::Virtual_reservation : private Rm_connection, Region_map_client PAGE_SIZE, 0, PAGE_SIZE); } catch (Rm_session::Region_conflict) { - PERR("region conflict while attaching guest-physical memory"); + error("region conflict while attaching guest-physical memory"); } } diff --git a/repos/ports/include/vmm/printf.h b/repos/ports/include/vmm/printf.h index 159c8a0ca..0cca5bd9b 100644 --- a/repos/ports/include/vmm/printf.h +++ b/repos/ports/include/vmm/printf.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include /* NOVA includes */ #include @@ -26,33 +26,25 @@ namespace Vmm { using namespace Genode; - void printf(const char *format, ...) __attribute__((format(printf, 1, 2))); -} + /** + * Print message while preserving the UTCB content + */ + template + void log(ARGS... args) + { + struct Utcb_backup { char buf[Nova::Utcb::size()]; }; + static Lock lock; + static Utcb_backup utcb_backup; -/** - * Print message while preserving the UTCB content - */ -inline void Vmm::printf(const char *format, ...) -{ - va_list list; - va_start(list, format); + Lock::Guard guard(lock); - struct Utcb_backup { char buf[Nova::Utcb::size()]; }; + utcb_backup = *(Utcb_backup *)Thread::myself()->utcb(); - static Lock lock; - static Utcb_backup utcb_backup; + Genode::log("VMM: ", args...); - Lock::Guard guard(lock); - - utcb_backup = *(Utcb_backup *)Thread::myself()->utcb(); - - Genode::printf("VMM: "); - Genode::vprintf(format, list); - - *(Utcb_backup *)Thread::myself()->utcb() = utcb_backup; - - va_end(list); + *(Utcb_backup *)Thread::myself()->utcb() = utcb_backup; + } } #endif /* _INCLUDE__VMM__PRINTF_H_ */ diff --git a/repos/ports/lib/mk/virtualbox-drivers.mk b/repos/ports/lib/mk/virtualbox-drivers.mk index 739764728..35dc1c988 100644 --- a/repos/ports/lib/mk/virtualbox-drivers.mk +++ b/repos/ports/lib/mk/virtualbox-drivers.mk @@ -1,5 +1,11 @@ include $(REP_DIR)/lib/mk/virtualbox-common.inc +# +# Prevent inclusion of the Genode::Log definition after the vbox #define +# of 'Log'. Otherwise, the attemt to compile base/log.h will fail. +# +VBOX_CC_OPT += -include base/log.h + SRC_CC += Devices/Input/DrvKeyboardQueue.cpp SRC_CC += Devices/Input/DrvMouseQueue.cpp SRC_CC += Devices/USB/DrvVUSBRootHub.cpp diff --git a/repos/ports/ports/virtualbox.hash b/repos/ports/ports/virtualbox.hash index 82d95f74d..1dbc9fae6 100644 --- a/repos/ports/ports/virtualbox.hash +++ b/repos/ports/ports/virtualbox.hash @@ -1 +1 @@ -2ee908cb3d7d8e0189158b7b0b55bda5ba406654 +91cce27022768a9213a803ed6530319cc1228fb0 diff --git a/repos/ports/run/noux_net_netcat.run b/repos/ports/run/noux_net_netcat.run index 86f1bdaeb..e5fadffc9 100644 --- a/repos/ports/run/noux_net_netcat.run +++ b/repos/ports/run/noux_net_netcat.run @@ -194,18 +194,14 @@ if {[have_include "power_on/qemu"]} { run_genode_until {.*got IP address.*\n} 60 set serial_id [output_spawn_id] } else { - # - # We have to look for 'got IP address' twice because tcp_terminal - # as well as noux_net will request one and we do not know the - # order in advance. - run_genode_until {.*got IP address.*} 60 + # wait until we got both IP addresses in the output afterwards + run_genode_until {.*got IP address.*\n.*got IP address.*\n} 60 set serial_id [output_spawn_id] - run_genode_until {.*got IP address.*\n} 10 $serial_id - regexp {\[init -> noux_net\] .{1,5}got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output noux_ip_addr + regexp {\[init -> noux_net\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output noux_ip_addr regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $noux_ip_addr noux_ip_addr - regexp {\[init -> tcp_terminal\] .{1,5}got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr + regexp {\[init -> tcp_terminal\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $serial_ip_addr serial_ip_addr # connect to Genode target and reading log output via network connection @@ -215,7 +211,13 @@ if {[have_include "power_on/qemu"]} { sleep 4 + puts "--- serial '$serial_ip_addr' noux '$noux_ip_addr'" +# +# This usage of netcat needs the OpenBSD nc command and will not +# work with GNU netcat because it will not close the connection +# automatically after sending the string. +# exec echo -e "Hello Genode" | netcat $noux_ip_addr 5555 & run_genode_until {exited with exit value 1} 20 $serial_id diff --git a/repos/ports/run/vbox_auto_win7_share.run b/repos/ports/run/vbox_auto_win7_share.run index 097cc36c5..1bbf913fa 100644 --- a/repos/ports/run/vbox_auto_win7_share.run +++ b/repos/ports/run/vbox_auto_win7_share.run @@ -253,10 +253,10 @@ build_boot_image $boot_modules # # Step 2: Read out TCP/IP address of tcp_terminal running on Genode target # -run_genode_until {\[init -> tcp_terminal\] .{1,5}got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} 20 +run_genode_until {\[init -> tcp_terminal\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} 20 set serial_id [output_spawn_id] -regexp {\[init -> tcp_terminal\] .{1,5}got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr +regexp {\[init -> tcp_terminal\] got IP address [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $output serial_ip_addr regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $serial_ip_addr serial_ip_addr # diff --git a/repos/ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.cpp b/repos/ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.cpp index 3ac3ba39d..722730352 100644 --- a/repos/ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.cpp +++ b/repos/ports/src/app/arora/qwebplugins/nitpicker/nitpickerplugin.cpp @@ -49,8 +49,6 @@ QWidget *NitpickerPlugin::create(const QString &mimeType, const QUrl &url, QString("-1"); int max_height = max_height_string.remove("px").toInt(); - PDBG("max_width = %d, max_height = %d", max_width, max_height); - NitpickerPluginWidget *m_widget = new NitpickerPluginWidget(this, url, args_string, max_width, max_height); m_widget->url = url; m_widget->argumentNames = argumentNames; diff --git a/repos/ports/src/app/gdb_monitor/app_child.h b/repos/ports/src/app/gdb_monitor/app_child.h index 33a145ab3..dcbbcb41b 100644 --- a/repos/ports/src/app/gdb_monitor/app_child.h +++ b/repos/ports/src/app/gdb_monitor/app_child.h @@ -178,7 +178,7 @@ class Gdb_monitor::App_child : public Child_policy, auto lambda = [&] (Child_session *session) { if (!session) { - PERR("attempt to upgrade unknown session"); + error("attempt to upgrade unknown session"); return; } @@ -208,7 +208,7 @@ class Gdb_monitor::App_child : public Child_policy, session = s; if (!session) { - PERR("attempt to close unknown session"); + error("attempt to close unknown session"); return; } _sessions.remove(session); diff --git a/repos/ports/src/app/gdb_monitor/cpu_session_component.cc b/repos/ports/src/app/gdb_monitor/cpu_session_component.cc index c2980c412..d1eed9f7b 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_session_component.cc +++ b/repos/ports/src/app/gdb_monitor/cpu_session_component.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -109,7 +109,7 @@ int Cpu_session_component::send_signal(Thread_capability thread_cap, Signal_transmitter(cpu_thread->sigint_signal_context_cap()).submit(); return 1; default: - PERR("unexpected signal %d", signo); + error("unexpected signal ", signo); return 0; } } @@ -268,8 +268,8 @@ void Cpu_session_component::kill_thread(Thread_capability thread_cap) _thread_list.remove(cpu_thread); destroy(_md_alloc, cpu_thread); } else - PERR("%s: could not find thread info for the given thread capability", - __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": " + "could not find thread info for the given thread capability"); _parent_cpu_session.kill_thread(thread_cap); } diff --git a/repos/ports/src/app/gdb_monitor/cpu_session_component.h b/repos/ports/src/app/gdb_monitor/cpu_session_component.h index ce678faf4..a1da9b950 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_session_component.h +++ b/repos/ports/src/app/gdb_monitor/cpu_session_component.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/repos/ports/src/app/gdb_monitor/cpu_thread_component.h b/repos/ports/src/app/gdb_monitor/cpu_thread_component.h index 7462c4c2a..d277ca443 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_thread_component.h +++ b/repos/ports/src/app/gdb_monitor/cpu_thread_component.h @@ -111,7 +111,7 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, _cpu_session_component.thread_ep().manage(this); if (pipe(_pipefd) != 0) - PERR("could not create pipe"); + error("could not create pipe"); } ~Cpu_thread_component() @@ -166,7 +166,7 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, Signal_transmitter(sigint_signal_context_cap()).submit(); return 1; default: - PERR("unexpected signal %d", signo); + error("unexpected signal ", signo); return 0; } } @@ -178,7 +178,7 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, _initial_sigtrap_pending = false; if (_verbose) - PDBG("received initial SIGTRAP for lwpid %lu", _lwpid); + log("received initial SIGTRAP for lwpid ", _lwpid); if (_lwpid == GENODE_MAIN_LWPID) { _remove_breakpoint_at_first_instruction(); @@ -210,26 +210,26 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, switch (signo) { case SIGSTOP: if (_verbose) - PDBG("delivering SIGSTOP to thread %lu", _lwpid); + log("delivering SIGSTOP to thread ", _lwpid); break; case SIGTRAP: if (_verbose) - PDBG("delivering SIGTRAP to thread %lu", _lwpid); + log("delivering SIGTRAP to thread ", _lwpid); break; case SIGSEGV: if (_verbose) - PDBG("delivering SIGSEGV to thread %lu", _lwpid); + log("delivering SIGSEGV to thread ", _lwpid); break; case SIGINT: if (_verbose) - PDBG("delivering SIGINT to thread %lu", _lwpid); + log("delivering SIGINT to thread ", _lwpid); break; case SIGINFO: if (_verbose) - PDBG("delivering initial SIGSTOP to thread %lu", _lwpid); + log("delivering initial SIGSTOP to thread ", _lwpid); break; default: - PERR("unexpected signal %d", signo); + error("unexpected signal ", signo); } write(_pipefd[1], &signo, sizeof(signo)); diff --git a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc index fb42fe828..3f51a885d 100644 --- a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc +++ b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc @@ -27,7 +27,7 @@ extern "C" { int linux_detach_one_lwp (struct inferior_list_entry *entry, void *args); } -#include +#include #include #include #include @@ -74,8 +74,8 @@ static void genode_stop_thread(unsigned long lwpid) Cpu_thread_component *cpu_thread = csc->lookup_cpu_thread(lwpid); if (!cpu_thread) { - PERR("%s: could not find CPU thread object for lwpid %lu", - __PRETTY_FUNCTION__, lwpid); + error(__PRETTY_FUNCTION__, ": " + "could not find CPU thread object for lwpid ", lwpid); return; } @@ -137,7 +137,8 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) continue; } else { if (verbose) - PDBG("input_interrupt, count = %d c = %d ('%c')", cc, c, c); + log("input_interrupt, " + "count=", cc, " c=", c, " ('", Char(c), "%c')"); } } else if (FD_ISSET(_new_thread_pipe[0], &readset)) { @@ -171,7 +172,7 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) unsigned long lwpid = csc->lwpid(thread_cap); if (verbose) - PDBG("thread %lu received signal %d", lwpid, signal); + log("thread ", lwpid, " received signal ", signal); if (signal == SIGTRAP) { @@ -201,7 +202,7 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) } else if (signal == SIGINFO) { if (verbose) - PDBG("received SIGINFO for new lwpid %lu", lwpid); + log("received SIGINFO for new lwpid ", lwpid); if (lwpid != GENODE_MAIN_LWPID) write(_new_thread_pipe[1], &lwpid, sizeof(lwpid)); @@ -256,7 +257,7 @@ extern "C" long ptrace(enum __ptrace_request request, pid_t pid, void *addr, voi case PTRACE_GETREGSET: request_str = "PTRACE_GETREGSET"; break; } - PWRN("ptrace(%s (0x%x)) called - not implemented!", request_str, request); + warning("ptrace(", request_str, " (", Hex(request), ")) called - not implemented!"); errno = EINVAL; return -1; @@ -268,7 +269,7 @@ extern "C" int fork() /* create the thread announcement pipe */ if (pipe(_new_thread_pipe) != 0) { - PERR("could not create the 'new thread' pipe"); + error("could not create the 'new thread' pipe"); return -1; } @@ -279,7 +280,7 @@ extern "C" int fork() Rom_connection ldso_rom("ld.lib.so"); ldso_cap = clone_rom(ldso_rom.dataspace()); } catch (...) { - PDBG("ld.lib.so not found"); + warning("ld.lib.so not found"); } /* extract target filename from config file */ @@ -289,10 +290,10 @@ extern "C" int fork() try { config()->xml_node().sub_node("target").attribute("name").value(filename, sizeof(filename)); } catch (Xml_node::Nonexistent_sub_node) { - PERR("Error: Missing '' sub node."); + error("missing '' sub node"); return -1; } catch (Xml_node::Nonexistent_attribute) { - PERR("Error: Missing 'name' attribute of '' sub node."); + error("missing 'name' attribute of '' sub node"); return -1; } @@ -311,7 +312,7 @@ extern "C" int fork() else throw Xml_node::Exception(); } catch (...) { - PERR("Error: could not find a valid config node"); + error("could not find a valid config node"); return -1; } @@ -321,11 +322,11 @@ extern "C" int fork() char *unique_name = filename; Capability file_cap; try { - static Rom_connection rom(prefixed_label(Session_label(unique_name), - Session_label(filename)).string()); + static Rom_connection rom(prefixed_label(Session_label(Cstring(unique_name)), + Session_label(Cstring(filename))).string()); file_cap = rom.dataspace(); } catch (Rom_connection::Rom_connection_failed) { - Genode::printf("Error: Could not access file \"%s\" from ROM service.\n", filename); + error("could not access ROM module \"", Cstring(filename), "\""); return -1; } @@ -378,8 +379,8 @@ extern "C" int kill(pid_t pid, int sig) Thread_capability thread_cap = csc->thread_cap(pid); if (!thread_cap.valid()) { - PERR("%s: could not find thread capability for lwpid %d", - __PRETTY_FUNCTION__, pid); + error(__PRETTY_FUNCTION__, ": " + "could not find thread capability for pid ", pid); return -1; } @@ -433,7 +434,7 @@ int genode_detach(int pid) int genode_kill(int pid) { /* TODO */ - if (verbose) PDBG("not implemented, just detaching instead..."); + if (verbose) warning(__func__, " not implemented, just detaching instead..."); return genode_detach(pid); } @@ -446,8 +447,7 @@ void genode_continue_thread(unsigned long lwpid, int single_step) Cpu_thread_component *cpu_thread = csc->lookup_cpu_thread(lwpid); if (!cpu_thread) { - PERR("%s: could not find CPU thread object for lwpid %lu", - __PRETTY_FUNCTION__, lwpid); + error(__func__, ": " "could not find CPU thread object for lwpid ", lwpid); return; } @@ -478,7 +478,7 @@ void genode_fetch_registers(struct regcache *regcache, int regno) void genode_store_registers(struct regcache *regcache, int regno) { - if (verbose) PDBG("genode_store_registers(): regno = %d", regno); + if (verbose) log(__func__, ": regno=", regno); unsigned long reg_content = 0; @@ -548,7 +548,7 @@ class Memory_model 0, _region->offset()); } catch (Region_map::Attach_failed) { flush(); - PERR("Memory_model: RM attach failed"); + error(__func__, ": RM attach failed"); } } @@ -602,7 +602,7 @@ class Memory_model unsigned char *local_base = _update_curr_region(region); if (!local_base) { - PWRN("Memory model: no memory at address %p", addr); + warning(__func__, ": no memory at address ", addr); throw No_memory_at_address(); } @@ -610,7 +610,7 @@ class Memory_model local_base[offset_in_region]; if (verbose) - Genode::printf("read addr=%p, value=%x\n", addr, value); + log(__func__, ": read addr=", addr, ", value=", Hex(value)); return value; } @@ -618,7 +618,7 @@ class Memory_model void write(void *addr, unsigned char value) { if (verbose) - Genode::printf("write addr=%p, value=%x\n", addr, value); + log(__func__, ": write addr=", addr, ", value=", Hex(value)); Lock::Guard guard(_lock); @@ -629,8 +629,8 @@ class Memory_model unsigned char *local_base = _update_curr_region(region); if (!local_base) { - PWRN("Memory model: no memory at address %p", addr); - PWRN("(attempted to write %x)", (int)value); + warning(__func__, ": no memory at address=", addr); + warning("(attempted to write ", Hex(value), ")"); throw No_memory_at_address(); } @@ -658,7 +658,7 @@ unsigned char genode_read_memory_byte(void *addr) int genode_read_memory(CORE_ADDR memaddr, unsigned char *myaddr, int len) { if (verbose) - PDBG("genode_read_memory(%llx, %p, %d)", memaddr, myaddr, len); + log(__func__, "(", Hex(memaddr), ", ", myaddr, ", ", len, ")"); if (myaddr) try { @@ -681,7 +681,7 @@ void genode_write_memory_byte(void *addr, unsigned char value) int genode_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len) { if (verbose) - PDBG("genode_write_memory(%llx, %p, %d)", memaddr, myaddr, len); + log(__func__, "(", Hex(memaddr), ", ", myaddr, ", ", len, ")"); if (myaddr && (len > 0)) { if (debug_threads) { diff --git a/repos/ports/src/app/gdb_monitor/region_map_component.cc b/repos/ports/src/app/gdb_monitor/region_map_component.cc index ccb7eb525..b4393d9df 100644 --- a/repos/ports/src/app/gdb_monitor/region_map_component.cc +++ b/repos/ports/src/app/gdb_monitor/region_map_component.cc @@ -20,8 +20,6 @@ /* local includes */ #include "region_map_component.h" -static bool const verbose = false; - /************************************** ** Region map component ** @@ -33,8 +31,6 @@ Region_map_component::Region *Region_map_component::find_region(void *local_addr { Lock::Guard lock_guard(_region_map_lock); -// PDBG("local_addr = %p", local_addr); - Region *first = _region_map.first(); Region *region = first ? first->find_by_addr(local_addr) : 0; @@ -42,7 +38,6 @@ Region_map_component::Region *Region_map_component::find_region(void *local_addr return 0; *offset_in_region = ((addr_t)local_addr - (addr_t)region->start()); -// PDBG("offset_in_region = %lx", *offset_in_region); _managed_ds_map.apply(region->ds_cap(), [&] (Dataspace_object *managed_ds_obj) { if (managed_ds_obj) @@ -61,9 +56,6 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, Region_map::Local_addr local_addr, bool executable) { - if (verbose) - PDBG("size = %zd, offset = %x", size, (unsigned int)offset); - size_t ds_size = Dataspace_client(ds_cap).size(); if (offset < 0 || (size_t)offset >= ds_size) { @@ -85,18 +77,12 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size, Lock::Guard lock_guard(_region_map_lock); _region_map.insert(new (env()->heap()) Region(addr, (void*)((addr_t)addr + size - 1), ds_cap, offset)); - if (verbose) - PDBG("region: %p - %p", addr, (void*)((addr_t)addr + size - 1)); - return addr; } void Region_map_component::detach(Region_map::Local_addr local_addr) { - if (verbose) - PDBG("local_addr = %p", (void *)local_addr); - _parent_region_map.detach(local_addr); Lock::Guard lock_guard(_region_map_lock); @@ -112,27 +98,18 @@ void Region_map_component::detach(Region_map::Local_addr local_addr) void Region_map_component::fault_handler(Signal_context_capability handler) { - if (verbose) - PDBG("fault_handler()"); - _parent_region_map.fault_handler(handler); } Region_map::State Region_map_component::state() { - if (verbose) - PDBG("state()"); - return _parent_region_map.state(); } Dataspace_capability Region_map_component::dataspace() { - if (verbose) - PDBG("dataspace()"); - Dataspace_capability ds_cap = _parent_region_map.dataspace(); _managed_ds_map.insert(new (env()->heap()) Dataspace_object(ds_cap, this)); return ds_cap; @@ -149,9 +126,6 @@ Region_map_component::Region_map_component(Rpc_entrypoint &ep, _managed_ds_map(managed_ds_map) { _ep.manage(this); - - if (verbose) - PDBG("Region_map_component()"); } diff --git a/repos/ports/src/app/gdb_monitor/rom.h b/repos/ports/src/app/gdb_monitor/rom.h index c47b316df..758a21b16 100644 --- a/repos/ports/src/app/gdb_monitor/rom.h +++ b/repos/ports/src/app/gdb_monitor/rom.h @@ -42,7 +42,7 @@ clone_rom(Genode::Capability rom_cap) Capability clone_cap = env()->ram_session()->alloc(rom_size); if (!clone_cap.valid()) { - PERR("%s: memory allocation for cloned dataspace failed", __func__); + error(__func__, ": memory allocation for cloned dataspace failed"); return Capability(); } diff --git a/repos/ports/src/app/openvpn/main.cc b/repos/ports/src/app/openvpn/main.cc index 398e5788d..4185c5b32 100644 --- a/repos/ports/src/app/openvpn/main.cc +++ b/repos/ports/src/app/openvpn/main.cc @@ -12,6 +12,7 @@ */ /* Genode includes */ +#include #include #include #include @@ -26,10 +27,6 @@ #include "tuntap.h" -static int const verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) - - /* external symbols provided by Genode's startup code */ extern char **genode_argv; extern int genode_argc; @@ -57,10 +54,7 @@ class Openvpn_thread : public Genode::Thread_deprecated<16UL * 1024 * sizeof (lo Thread_deprecated("openvpn_main"), _argc(argc), _argv(argv), _exitcode(-1) - { - //for (int i = 0; i < _argc; i++) - // PINF("_argv[%i]: '%s'", i, _argv[i]); - } + { } void entry() { @@ -111,7 +105,7 @@ class Openvpn_component : public Tuntap_device, Packet_descriptor packet = _tx.sink()->get_packet(); if (!packet.size()) { - PWRN("Invalid tx packet"); + Genode::warning("invalid tx packet"); return true; } @@ -145,7 +139,7 @@ class Openvpn_component : public Tuntap_device, : Session_component(tx_buf_size, rx_buf_size, rx_block_md_alloc, ram_session, ep) { if (pipe(_pipefd)) { - PERR("could not create pipe"); + Genode::error("could not create pipe"); throw Genode::Exception(); } } @@ -171,8 +165,6 @@ class Openvpn_component : public Tuntap_device, /* tx */ int read(char *buf, Genode::size_t len) { - PDBGV("buf:0x%p len:%zu", len); - Genode::memcpy(buf, _packet, len); _packet = 0; @@ -185,7 +177,6 @@ class Openvpn_component : public Tuntap_device, /* rx */ int write(char const *buf, Genode::size_t len) { - PDBGV("buf:0x%p len:%zu", len); _handle_packet_stream(); if (!_rx.source()->ready_to_submit()) @@ -234,7 +225,7 @@ class Root : public Genode::Root_component ram_quota - session_size) { - PERR("insufficient 'ram_quota', got %zd, need %zd", + Genode::error("insufficient 'ram_quota', got %zd, need %zd", ram_quota, tx_buf_size + rx_buf_size + session_size); throw Genode::Root::Quota_exceeded(); } @@ -251,7 +242,6 @@ class Root : public Genode::Root_componentheap()) Openvpn_thread(genode_argc, genode_argv); _thread->start(); diff --git a/repos/ports/src/app/openvpn/tun_genode.cc b/repos/ports/src/app/openvpn/tun_genode.cc index 1b62470cb..d0b206f56 100644 --- a/repos/ports/src/app/openvpn/tun_genode.cc +++ b/repos/ports/src/app/openvpn/tun_genode.cc @@ -11,9 +11,8 @@ * under the terms of the GNU General Public License version 2. */ - /* Genode includes */ -#include +#include #include #include #include @@ -33,11 +32,6 @@ extern "C" { } -static bool verbose = false; -#define PDBGV(...) if (verbose) PDBG(__VA_ARGS__) -#define TRACE do { PDBGV("%s: called", __func__); } while (0) - - extern Tuntap_device *tuntap_dev(); @@ -52,12 +46,12 @@ extern "C" void open_tun(char const *dev, char const *dev_type, tt->fd = -1; if (tt->ipv6) { - PERR("IPv6 is currently not supported!"); + Genode::error("IPv6 is currently not supported!"); return; } if (tt->type == DEV_TYPE_NULL) { - PERR("null device not supported"); + Genode::error("null device not supported"); return; } @@ -66,7 +60,6 @@ extern "C" void open_tun(char const *dev, char const *dev_type, tt->actual_name = string_alloc(name, NULL); tt->fd = tuntap_dev()->fd(); - PDBGV("tt->fd:%d", tuntap_dev()->fd()); } @@ -79,8 +72,6 @@ extern "C" void close_tun(struct tuntap *tt) extern "C" int write_tun(struct tuntap *tt, uint8_t *buf, int len) { - PDBGV("tt->fd:%d buf:0x%p len: %d", tt->fd, buf, len); - if (len <= 0) return -1; @@ -98,8 +89,6 @@ extern "C" int write_tun(struct tuntap *tt, uint8_t *buf, int len) extern "C" int read_tun(struct tuntap *tt, uint8_t *buf, int len) { - PDBGV("tt->fd:%d buf:0x%p len: %d", tt->fd, buf, len); - if (len <= 0) return -1; @@ -124,12 +113,7 @@ extern "C" int read_tun(struct tuntap *tt, uint8_t *buf, int len) extern "C" void tuncfg(char const *dev, char const *dev_type, char const *dev_node, int persist_mode, char const *username, char const *groupname, - struct tuntap_options const *options) -{ - PDBGV("dev:'%s' dev_type:'%s' dev_node:'%s' persist_mode:%d" - "username:'%s' groupname:'%s' options:0x%p", - dev, dev_type, dev_node, persist_mode, username, groupname, options); -} + struct tuntap_options const *options) { } extern "C" char const *guess_tuntap_dev(char const *dev, char const *dev_type, @@ -148,10 +132,6 @@ extern "C" struct tuntap *init_tun(char const *dev, char const *dev_type, in_addr_t local_public, in_addr_t remote_public, bool const strict_warn, struct env_set *es) { - PDBGV("dev:'%s' dev_type:'%s' topology:%d ifconfig_local_parm:'%s'" - "ifconfig_remote_netmask_parm:'%s' es:0x%p", dev, dev_type, - topology, ifconfig_local_parm, ifconfig_remote_netmask_parm, es); - struct tuntap *tt; ALLOC_OBJ(tt, struct tuntap); @@ -186,17 +166,12 @@ extern "C" struct tuntap *init_tun(char const *dev, char const *dev_type, extern "C" void init_tun_post(struct tuntap *tt, struct frame const *frame, - struct tuntap_options const *options) -{ - TRACE; -} + struct tuntap_options const *options) { } extern "C" void do_ifconfig(struct tuntap *tt, char const *actual_name, int tun_mtu, struct env_set const *es) { - TRACE; - /** * After OpenVPN has received a PUSH_REPLY it will configure * the TUN/TAP device by calling this function. At this point @@ -255,8 +230,6 @@ extern "C" char const *ifconfig_options_string(struct tuntap const* tt, bool remote, bool disable, struct gc_arena *gc) { - TRACE; - return 0; } @@ -271,17 +244,17 @@ extern "C" bool is_tun_p2p(struct tuntap const *tt) else if (tt->type == DEV_TYPE_TUN) tun = true; else - PERR("problem with tun vs. tap setting"); + Genode::error("problem with tun vs. tap setting"); return tun; } extern "C" void check_subnet_conflict(const in_addr_t, const in_addr_t, - char const *) { TRACE; } + char const *) { } -extern "C" void warn_on_use_of_common_subnets(void) { TRACE; } +extern "C" void warn_on_use_of_common_subnets(void) { } extern "C" char const *tun_stat(struct tuntap const *tt, unsigned rwflags, diff --git a/repos/ports/src/app/seoul/boot_module_provider.h b/repos/ports/src/app/seoul/boot_module_provider.h index a26baf19f..2f756be32 100644 --- a/repos/ports/src/app/seoul/boot_module_provider.h +++ b/repos/ports/src/app/seoul/boot_module_provider.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include @@ -99,7 +99,7 @@ class Boot_module_provider size_t const src_len = Dataspace_client(ds).size(); if (src_len > dst_len) { - PDBG("src_len=%zd dst_len=%zd", src_len, dst_len); + warning(__func__, ": src_len=", src_len, " dst_len=", dst_len); throw Destination_buffer_too_small(); } @@ -134,22 +134,21 @@ class Boot_module_provider return mod_node.content_size(); } - PWRN("XML node %d in multiboot node has unexpected type", - module_index); + warning("XML node ", module_index, " in multiboot node has unexpected type"); throw Module_loading_failed(); } catch (Xml_node::Nonexistent_sub_node) { } catch (Xml_node::Nonexistent_attribute) { } catch (Destination_buffer_too_small) { - PERR("Boot_module_provider: destination buffer too small"); } - catch (Genode::Rm_session::Attach_failed) { - PERR("Boot_module_provider: Rm_session::Attach_failed"); + error("Boot_module_provider: destination buffer too small"); } + catch (Region_map::Attach_failed) { + error("Boot_module_provider: Region_map::Attach_failed"); throw Module_loading_failed(); } - catch (Genode::Rom_connection::Rom_connection_failed) { - PERR("Boot_module_provider: Rom_connection_failed"); } + catch (Rom_connection::Rom_connection_failed) { + error("Boot_module_provider: Rom_connection_failed"); } catch (...) { - PERR("Boot_module_provider: Spurious exception"); + error("Boot_module_provider: Spurious exception"); throw Module_loading_failed(); } @@ -223,8 +222,7 @@ class Boot_module_provider return cmd_len; } - PWRN("XML node %d in multiboot node has unexpected type", - module_index); + warning("XML node ", module_index, " in multiboot node has unexpected type"); return 0; } diff --git a/repos/ports/src/app/seoul/console.cc b/repos/ports/src/app/seoul/console.cc index 27888234b..5cef12cdc 100644 --- a/repos/ports/src/app/seoul/console.cc +++ b/repos/ports/src/app/seoul/console.cc @@ -223,7 +223,7 @@ void Vancouver_console::entry() try { framebuffer = new (env()->heap()) Framebuffer::Connection(); } catch (...) { - PERR("Headless mode - no framebuffer session available"); + Genode::error("Headless mode - no framebuffer session available"); _startup_lock.unlock(); return; } diff --git a/repos/ports/src/app/seoul/disk.cc b/repos/ports/src/app/seoul/disk.cc index 256a1f6dc..11de9683d 100644 --- a/repos/ports/src/app/seoul/disk.cc +++ b/repos/ports/src/app/seoul/disk.cc @@ -21,7 +21,7 @@ /* Genode includes */ #include -#include +#include #include #include #include @@ -120,7 +120,7 @@ void Vancouver_disk::_signal_dispatch_entry(unsigned disknr) obj = obj->find(reinterpret_cast(source_addr)); if (!obj) { - PWRN("Unknown MessageDisk object - drop ack of block session"); + Genode::warning("unknown MessageDisk object - drop ack of block session"); continue; } @@ -137,7 +137,7 @@ void Vancouver_disk::_signal_dispatch_entry(unsigned disknr) !(packet.operation() == Block::Packet_descriptor::Opcode::READ || packet.operation() == Block::Packet_descriptor::Opcode::WRITE)) { - PDBG("Getting block failed !"); + Genode::warning("getting block failed"); MessageDiskCommit mdc(disknr, msg->usertag, MessageDisk::DISK_STATUS_DEVICE); @@ -157,7 +157,7 @@ void Vancouver_disk::_signal_dispatch_entry(unsigned disknr) // check for bounds if (dma_addr >= _backing_store_base + _backing_store_size || dma_addr < _backing_store_base) { - PERR("dma bounds violation"); + Genode::error("dma bounds violation"); } else memcpy(dma_addr, source_addr + sector, msg->dma[i].bytecount); diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc index 10c85d689..625da7e66 100644 --- a/repos/ports/src/app/seoul/main.cc +++ b/repos/ports/src/app/seoul/main.cc @@ -211,7 +211,7 @@ class Guest_memory ((Genode::addr_t) _local_addr)+backing_store_size-fb_size); } catch (Genode::Rm_session::Region_conflict) { - PERR("region conflict"); + Genode::error("region conflict"); } } @@ -690,7 +690,7 @@ class Vcpu_dispatcher : public Vcpu_handler, void _register_handler(Genode::addr_t exc_base, Nova::Mtd mtd) { if (!register_handler(exc_base, mtd)) - PERR("could not register handler %lx", exc_base + EV); + Genode::error("could not register handler ", Genode::Hex(exc_base + EV)); } public: diff --git a/repos/ports/src/app/vbox_pointer/main.cc b/repos/ports/src/app/vbox_pointer/main.cc index 2ebe7bf97..8e56a70d1 100644 --- a/repos/ports/src/app/vbox_pointer/main.cc +++ b/repos/ports/src/app/vbox_pointer/main.cc @@ -127,8 +127,8 @@ void Main::_show_default_pointer() try { _resize_nitpicker_buffer_if_needed(pointer_size); } catch (...) { - PERR("%s: could not resize the pointer buffer for %u x %u pixels", - __func__, pointer_size.w(), pointer_size.h()); + Genode::error(__func__, ": could not resize the pointer buffer " + "for ", pointer_size.w(), "x", pointer_size.h(), " pixels"); return; } @@ -151,8 +151,8 @@ void Main::_show_shape_pointer(Policy *p) try { _resize_nitpicker_buffer_if_needed(p->shape_size()); } catch (...) { - PERR("%s: could not resize the pointer buffer for %u x %u pixels", - __func__, p->shape_size().w(), p->shape_size().h()); + error(__func__, ": could not resize the pointer buffer " + "for ", p->shape_size(), " pixels"); throw; } @@ -208,7 +208,7 @@ void Main::_handle_hover(unsigned) } } catch (...) { - PWRN("could not parse hover report"); + Genode::warning("could not parse hover report"); } } @@ -231,7 +231,7 @@ void Main::_handle_xray(unsigned) } } catch (...) { - PWRN("could not parse xray report"); + Genode::warning("could not parse xray report"); } } diff --git a/repos/ports/src/app/vbox_pointer/policy.cc b/repos/ports/src/app/vbox_pointer/policy.cc index 8f50fe1d5..eb6925925 100644 --- a/repos/ports/src/app/vbox_pointer/policy.cc +++ b/repos/ports/src/app/vbox_pointer/policy.cc @@ -194,9 +194,9 @@ void Vbox_pointer::Policy_registry::update(Genode::Xml_node config) String rom = read_string_attribute(policy, "rom", String()); if (!label.valid() && !domain.valid()) - PWRN("policy does not declare label/domain attribute"); + Genode::warning("policy does not declare label/domain attribute"); else if (!rom.valid()) - PWRN("policy does not declare shape rom"); + Genode::warning("policy does not declare shape rom"); else insert(new (Genode::env()->heap()) Policy_entry(label, domain, rom, _updater)); diff --git a/repos/ports/src/app/vbox_pointer/util.h b/repos/ports/src/app/vbox_pointer/util.h index 2732a9d32..faaa54e24 100644 --- a/repos/ports/src/app/vbox_pointer/util.h +++ b/repos/ports/src/app/vbox_pointer/util.h @@ -35,7 +35,7 @@ Vbox_pointer::String Vbox_pointer::read_string_attribute(Genode::Xml_node const try { char buf[String::capacity()]; node.attribute(attr).value(buf, sizeof(buf)); - return String(buf); + return String(Genode::Cstring(buf)); } catch (...) { return default_value; } } diff --git a/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc b/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc index 27140720a..f32b9a9b3 100644 --- a/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc +++ b/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc @@ -64,14 +64,14 @@ void fetch_register(const char *reg_name, value = thread_state_reg; if (verbose) - PDBG("%s = %8lx", reg_name, value); + log(__func__, ": ", reg_name, " = ", Hex(value)); } void cannot_fetch_register(const char *reg_name) { if (verbose) - PDBG("cannot fetch register %s", reg_name); + log("cannot fetch register ", reg_name); } @@ -80,7 +80,7 @@ bool store_register(const char *reg_name, unsigned long value) { if (verbose) - PDBG("%s = %8lx", reg_name, value); + log(__func__, ": ", reg_name, " = ", Hex(value)); if (thread_state_reg == value) return false; @@ -94,5 +94,5 @@ bool store_register(const char *reg_name, void cannot_store_register(const char *reg_name, unsigned long value) { if (verbose) - PDBG("cannot set contents of register %s (%8lx)", reg_name, value); + log("cannot set contents of register ", reg_name, " (", Hex(value), ")"); } diff --git a/repos/ports/src/lib/gdbserver_platform/spec/foc_arm/low.cc b/repos/ports/src/lib/gdbserver_platform/spec/foc_arm/low.cc index ea12b9374..e9f4e5678 100644 --- a/repos/ports/src/lib/gdbserver_platform/spec/foc_arm/low.cc +++ b/repos/ports/src/lib/gdbserver_platform/spec/foc_arm/low.cc @@ -17,7 +17,7 @@ extern "C" { #define _private private } -#include +#include #include "cpu_session_component.h" #include "reg-arm.h" #include "gdbserver_platform_helper.h" @@ -51,7 +51,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return -1; } @@ -106,7 +106,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case F7: cannot_fetch_register("F7"); return -1; case FPS: cannot_fetch_register("FPS"); return -1; case CPSR: cannot_fetch_register("CPSR"); return -1; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } } else { @@ -139,7 +139,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case F7: cannot_fetch_register("F7"); return -1; case FPS: cannot_fetch_register("FPS"); return -1; case CPSR: fetch_register("CPSR", ts.cpsr, *value); return 0; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } } @@ -153,12 +153,12 @@ extern "C" void genode_store_register(int regno, unsigned long value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return; } if (in_syscall(ts)) { - PDBG("cannot set registers while thread is in syscall"); + log("cannot set registers while thread is in syscall"); return; } diff --git a/repos/ports/src/lib/gdbserver_platform/spec/foc_x86_32/low.cc b/repos/ports/src/lib/gdbserver_platform/spec/foc_x86_32/low.cc index a42c508e2..5d48b609c 100644 --- a/repos/ports/src/lib/gdbserver_platform/spec/foc_x86_32/low.cc +++ b/repos/ports/src/lib/gdbserver_platform/spec/foc_x86_32/low.cc @@ -17,7 +17,7 @@ extern "C" { #define _private private } -#include +#include #include "i386.h" #include "cpu_session_component.h" #include "gdbserver_platform_helper.h" @@ -47,7 +47,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return -1; } @@ -115,7 +115,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case ES: cannot_fetch_register("ES"); return -1; case FS: cannot_fetch_register("FS"); return -1; case GS: cannot_fetch_register("GS"); return -1; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } } else { @@ -138,7 +138,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case ES: cannot_fetch_register("ES"); return -1; case FS: fetch_register("FS", ts.fs, *value); return 0; case GS: fetch_register("GS", ts.gs, *value); return 0; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } } @@ -151,12 +151,12 @@ extern "C" void genode_store_register(int regno, unsigned long value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return; } if (in_syscall(ts)) { - PDBG("cannot set registers while thread is in syscall"); + log("cannot set registers while thread is in syscall"); return; } @@ -178,7 +178,7 @@ extern "C" void genode_store_register(int regno, unsigned long value) case ES: cannot_store_register("ES", value); return; case FS: if (!store_register("FS ", ts.fs, value)) return; break; case GS: if (!store_register("GS ", ts.gs, value)) return; break; - default: PERR("unhandled register %d", regno); return; + default: error("unhandled register ", regno); return; } set_current_thread_state(ts); diff --git a/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_32/low.cc b/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_32/low.cc index 9177137e0..1d2018dd9 100644 --- a/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_32/low.cc +++ b/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_32/low.cc @@ -24,7 +24,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return -1; } @@ -46,7 +46,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case ES: cannot_fetch_register("ES"); return -1; case FS: cannot_fetch_register("FS"); return -1; case GS: cannot_fetch_register("GS"); return -1; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } return -1; @@ -59,7 +59,7 @@ extern "C" void genode_store_register(int regno, unsigned long value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return; } @@ -81,7 +81,7 @@ extern "C" void genode_store_register(int regno, unsigned long value) case ES: cannot_store_register("ES", value); return; case FS: cannot_store_register("FS", value); return; case GS: cannot_store_register("GS", value); return; - default: PERR("unhandled register %d", regno); return; + default: error("unhandled register ", regno); return; } set_current_thread_state(ts); diff --git a/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_64/low.cc b/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_64/low.cc index b04814d8a..e04cb6836 100644 --- a/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_64/low.cc +++ b/repos/ports/src/lib/gdbserver_platform/spec/nova_x86_64/low.cc @@ -25,7 +25,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return -1; } @@ -88,7 +88,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) case XMM14: cannot_fetch_register("XMM14"); return -1; case XMM15: cannot_fetch_register("XMM15"); return -1; case MXCSR: cannot_fetch_register("MXCSR"); return -1; - default: PERR("unhandled register %d", regno); return -1; + default: error("unhandled register ", regno); return -1; } return -1; @@ -101,7 +101,7 @@ extern "C" void genode_store_register(int regno, unsigned long value) try { ts = get_current_thread_state(); } catch (...) { - PERR("%s: could not get current thread state", __PRETTY_FUNCTION__); + error(__PRETTY_FUNCTION__, ": could not get current thread state"); return; } @@ -164,7 +164,7 @@ extern "C" void genode_store_register(int regno, unsigned long value) case XMM14: cannot_store_register("XMM14", value); return; case XMM15: cannot_store_register("XMM15", value); return; case MXCSR: cannot_store_register("MXCSR", value); return; - default: PERR("unhandled register %d", regno); return; + default: error("unhandled register ", regno); return; } set_current_thread_state(ts); diff --git a/repos/ports/src/lib/libc_noux/plugin.cc b/repos/ports/src/lib/libc_noux/plugin.cc index a941e7c63..6898a523a 100644 --- a/repos/ports/src/lib/libc_noux/plugin.cc +++ b/repos/ports/src/lib/libc_noux/plugin.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,6 +59,12 @@ #include +using Genode::log; +using Genode::error; +using Genode::warning; +using Genode::Hex; + + enum { verbose = false }; enum { verbose_signals = false }; @@ -148,7 +154,7 @@ static bool noux_syscall(Noux::Session::Syscall opcode) while (!sysio()->pending_signals.empty()) { Noux::Sysio::Signal signal = sysio()->pending_signals.get(); if (verbose_signals) - PDBG("received signal %d", signal); + log(__func__, ": received signal ", (int)signal); if (signal_action[signal].sa_flags & SA_SIGINFO) { memcpy(&saved_sysio, sysio(), sizeof(Noux::Sysio)); /* TODO: pass siginfo_t struct */ @@ -232,14 +238,12 @@ extern "C" struct passwd *getpwuid(uid_t uid) extern "C" int getdtablesize() { if (!noux_syscall(Noux::Session::SYSCALL_GETDTABLESIZE)) { - PWRN("getdtablesize syscall failed"); + warning("getdtablesize syscall failed"); errno = ENOSYS; return -1; } int n = sysio()->getdtablesize_out.n; - if (verbose) - PDBG("%d", n); return n; } @@ -284,7 +288,7 @@ extern "C" uid_t geteuid() void *sbrk(intptr_t increment) { if (verbose) - PDBG("not implemented %ld", (long int)increment); + warning(__func__, " not implemented ", (long int)increment); errno = ENOMEM; return reinterpret_cast(-1); } @@ -324,7 +328,7 @@ extern "C" int getrlimit(int resource, struct rlimit *rlim) return 0; } errno = ENOSYS; - PDBG("not implemented %d", resource); + warning(__func__, " not implemented (resource=", resource, ")"); return -1; } @@ -581,7 +585,7 @@ static void suspended_callback() sysio()->fork_in.parent_cap_addr = (Genode::addr_t)(&new_parent); if (!noux_syscall(Noux::Session::SYSCALL_FORK)) { - PERR("fork error %d", sysio()->error.general); + error("fork error ", (int)sysio()->error.general); switch (sysio()->error.fork) { case Noux::Sysio::FORK_NOMEM: errno = ENOMEM; break; default: errno = EAGAIN; @@ -622,7 +626,7 @@ extern "C" pid_t getppid(void) { return getpid(); } extern "C" int chmod(char const *path, mode_t mode) { if (verbose) - PDBG("chmod '%s' to 0x%x not implemented", path, mode); + warning(__func__, ": chmod '", path, "' to ", Hex(mode), " not implemented"); return 0; } @@ -654,7 +658,7 @@ extern "C" pid_t _wait4(pid_t pid, int *status, int options, int getrusage(int who, struct rusage *usage) { if (verbose) - PDBG("not implemented"); + warning(__func__, " not implemented"); errno = ENOSYS; return -1; @@ -664,7 +668,7 @@ int getrusage(int who, struct rusage *usage) void endpwent(void) { if (verbose) - PDBG("not implemented"); + warning(__func__, " not implemented"); } @@ -677,7 +681,7 @@ extern "C" void sync(void) extern "C" int kill(int pid, int sig) { if (verbose_signals) - PDBG("pid = %d, sig = %d", pid, sig); + log(__func__, ": pid=", pid, ", sig=", sig); sysio()->kill_in.pid = pid; sysio()->kill_in.sig = Noux::Sysio::Signal(sig); @@ -818,7 +822,7 @@ extern "C" int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) for (int sig = 1; sig < NSIG; sig++) if (sigismember(set, sig)) { if (verbose_signals) - PDBG("signal %d requested to get blocked", sig); + log(__func__, ": signal ", sig, " requested to get blocked"); sigaddset(&signal_mask, sig); } break; @@ -826,7 +830,7 @@ extern "C" int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) for (int sig = 1; sig < NSIG; sig++) if (sigismember(set, sig)) { if (verbose_signals) - PDBG("signal %d requested to get unblocked", sig); + log(__func__, ": signal ", sig, " requested to get unblocked"); sigdelset(&signal_mask, sig); } break; @@ -834,7 +838,7 @@ extern "C" int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) if (verbose_signals) for (int sig = 1; sig < NSIG; sig++) if (sigismember(set, sig)) - PDBG("signal %d requested to get blocked", sig); + log(__func__, ": signal ", sig, " requested to get blocked"); signal_mask = *set; break; default: @@ -855,7 +859,7 @@ extern "C" int _sigprocmask(int how, const sigset_t *set, sigset_t *oldset) extern "C" int _sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { if (verbose_signals) - PDBG("signum = %d, handler = %p", signum, act ? act->sa_handler : 0); + log("signum=", signum, ", handler=", act ? act->sa_handler : nullptr); if ((signum < 1) || (signum > NSIG)) { errno = EINVAL; @@ -1000,7 +1004,8 @@ namespace { int Plugin::access(char const *pathname, int mode) { if (verbose) - PDBG("access '%s' (mode=%x) called, not implemented", pathname, mode); + log(__func__, ": access '", pathname, "' (mode=", Hex(mode), ") " + "called, not implemented"); struct stat stat; if (::stat(pathname, &stat) == 0) @@ -1015,19 +1020,19 @@ namespace { char *const envp[]) { if (verbose) { - PDBG("filename=%s", filename); + log(__func__, ": filename=", filename); for (int i = 0; argv[i]; i++) - PDBG("argv[%d]='%s'", i, argv[i]); + log(__func__, "argv[", i, "]='", Genode::Cstring(argv[i]), "'"); for (int i = 0; envp[i]; i++) - PDBG("envp[%d]='%s'", i, envp[i]); + log(__func__, "envp[", i, "]='", Genode::Cstring(envp[i]), "'"); } Genode::strncpy(sysio()->execve_in.filename, filename, sizeof(sysio()->execve_in.filename)); if (!serialize_string_array(argv, sysio()->execve_in.args, sizeof(sysio()->execve_in.args))) { - PERR("execve: argument buffer exceeded"); + error("execve: argument buffer exceeded"); errno = E2BIG; return -1; } @@ -1040,7 +1045,7 @@ namespace { if (!getcwd(&(sysio()->execve_in.env[noux_cwd_len]), sizeof(sysio()->execve_in.env) - noux_cwd_len)) { - PERR("execve: environment buffer exceeded"); + error("execve: environment buffer exceeded"); errno = E2BIG; return -1; } @@ -1049,13 +1054,13 @@ namespace { if (!serialize_string_array(envp, &(sysio()->execve_in.env[noux_cwd_len]), sizeof(sysio()->execve_in.env) - noux_cwd_len)) { - PERR("execve: environment buffer exceeded"); + error("execve: environment buffer exceeded"); errno = E2BIG; return -1; } if (!noux_syscall(Noux::Session::SYSCALL_EXECVE)) { - PWRN("exec syscall failed for path \"%s\"", filename); + warning("exec syscall failed for path \", filename, \""); switch (sysio()->error.execve) { case Noux::Sysio::EXECVE_NONEXISTENT: errno = ENOENT; break; case Noux::Sysio::EXECVE_NOMEM: errno = ENOMEM; break; @@ -1075,7 +1080,7 @@ namespace { int Plugin::stat(char const *path, struct stat *buf) { if (verbose) - PDBG("path = %s", path); + log(__func__, ": path=", path); if ((path == NULL) or (buf == NULL)) { errno = EFAULT; @@ -1086,7 +1091,7 @@ namespace { if (!noux_syscall(Noux::Session::SYSCALL_STAT)) { if (verbose) - PWRN("stat syscall failed for path \"%s\"", path); + warning("stat syscall failed for path \"", path, "\""); switch (sysio()->error.stat) { case Vfs::Directory_service::STAT_ERR_NO_ENTRY: errno = ENOENT; return -1; case Vfs::Directory_service::STAT_ERR_NO_PERM: errno = EACCES; return -1; @@ -1102,7 +1107,7 @@ namespace { Libc::File_descriptor *Plugin::open(char const *pathname, int flags) { if (Genode::strlen(pathname) + 1 > sizeof(sysio()->open_in.path)) { - PDBG("ENAMETOOLONG"); + log(__func__, ": ENAMETOOLONG"); errno = ENAMETOOLONG; return 0; } @@ -1154,11 +1159,11 @@ namespace { int Plugin::symlink(const char *oldpath, const char *newpath) { if (verbose) - PDBG("%s -> %s", newpath, oldpath); + log(__func__, ": ", newpath, " -> ", oldpath); if ((Genode::strlen(oldpath) + 1 > sizeof(sysio()->symlink_in.oldpath)) || (Genode::strlen(newpath) + 1 > sizeof(sysio()->symlink_in.newpath))) { - PDBG("ENAMETOOLONG"); + log(__func__, ": ENAMETOOLONG"); errno = ENAMETOOLONG; return 0; } @@ -1166,7 +1171,7 @@ namespace { Genode::strncpy(sysio()->symlink_in.oldpath, oldpath, sizeof(sysio()->symlink_in.oldpath)); Genode::strncpy(sysio()->symlink_in.newpath, newpath, sizeof(sysio()->symlink_in.newpath)); if (!noux_syscall(Noux::Session::SYSCALL_SYMLINK)) { - PWRN("symlink syscall failed for path \"%s\"", newpath); + warning("symlink syscall failed for path \"", newpath, "\""); typedef Vfs::Directory_service::Symlink_result Result; switch (sysio()->error.symlink) { case Result::SYMLINK_ERR_NO_ENTRY: errno = ENOENT; return -1; @@ -1284,7 +1289,7 @@ namespace { { sysio()->close_in.fd = noux_fd(fd->context); if (!noux_syscall(Noux::Session::SYSCALL_CLOSE)) { - PERR("close error"); + error("close error"); /* XXX set errno */ return -1; } @@ -1310,7 +1315,7 @@ namespace { case TIOCGETA: { if (verbose) - PDBG("TIOCGETA - argp=0x%p", argp); + log(__func__, ": TIOCGETA - argp=", (void *)argp); ::termios *termios = (::termios *)argp; termios->c_iflag = 0; @@ -1361,7 +1366,7 @@ namespace { case FIONBIO: { if (verbose) - PDBG("FIONBIO - *argp=%d", *argp); + log(__func__, ": FIONBIO - *argp=", *argp); sysio()->ioctl_in.request = Vfs::File_io_service::IOCTL_OP_FIONBIO; sysio()->ioctl_in.argp = argp ? *(int*)argp : 0; @@ -1379,7 +1384,7 @@ namespace { default: - PWRN("unsupported ioctl (request=0x%x)", request); + warning("unsupported ioctl (request=", Hex(request), ")"); break; } @@ -1434,7 +1439,7 @@ namespace { { /* perform syscall */ if (!noux_syscall(Noux::Session::SYSCALL_PIPE)) { - PERR("pipe error"); + error("pipe error"); /* XXX set errno */ return -1; } @@ -1453,7 +1458,7 @@ namespace { sysio()->dup2_in.to_fd = -1; if (!noux_syscall(Noux::Session::SYSCALL_DUP2)) { - PERR("dup error"); + error("dup error"); /* XXX set errno */ return 0; } @@ -1476,7 +1481,7 @@ namespace { /* perform syscall */ if (!noux_syscall(Noux::Session::SYSCALL_DUP2)) { - PERR("dup2 error"); + error("dup2 error"); /* XXX set errno */ return -1; } @@ -1489,7 +1494,7 @@ namespace { { sysio()->fstat_in.fd = noux_fd(fd->context); if (!noux_syscall(Noux::Session::SYSCALL_FSTAT)) { - PERR("fstat error"); + error("fstat error"); /* XXX set errno */ return -1; } @@ -1502,7 +1507,7 @@ namespace { int Plugin::fsync(Libc::File_descriptor *fd) { if (verbose) - PDBG("not implemented"); + warning(__func__, ": not implemented"); return 0; } @@ -1546,7 +1551,7 @@ namespace { * duplicate. */ if (dup2(fd, new_fd) == -1) { - PERR("Plugin::fcntl: dup2 unexpectedly failed"); + error("Plugin::fcntl: dup2 unexpectedly failed"); errno = EINVAL; return -1; } @@ -1561,7 +1566,7 @@ namespace { * XXX: FD_CLOEXEC not yet supported */ if (verbose) - PWRN("fcntl(F_GETFD) not implemented, returning 0"); + warning("fcntl(F_GETFD) not implemented, returning 0"); return 0; case F_SETFD: @@ -1571,26 +1576,26 @@ namespace { case F_GETFL: if (verbose) - PINF("fcntl: F_GETFL for libc_fd=%d", fd->libc_fd); + log("fcntl: F_GETFL for libc_fd=", fd->libc_fd); sysio()->fcntl_in.cmd = Noux::Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS; break; case F_SETFL: if (verbose) - PINF("fcntl: F_SETFL for libc_fd=%d", fd->libc_fd); + log("fcntl: F_SETFL for libc_fd=", fd->libc_fd); sysio()->fcntl_in.cmd = Noux::Sysio::FCNTL_CMD_SET_FILE_STATUS_FLAGS; sysio()->fcntl_in.long_arg = arg; break; default: - PERR("fcntl: unsupported command %d", cmd); + error("fcntl: unsupported command ", cmd); errno = EINVAL; return -1; }; /* invoke system call */ if (!noux_syscall(Noux::Session::SYSCALL_FCNTL)) { - PWRN("fcntl failed (libc_fd= %d, cmd=%x)", fd->libc_fd, cmd); + warning("fcntl failed (libc_fd=", fd->libc_fd, ", cmd=", Hex(cmd), ")"); switch (sysio()->error.fcntl) { case Noux::Sysio::FCNTL_ERR_CMD_INVALID: errno = EINVAL; break; default: @@ -1611,7 +1616,7 @@ namespace { ::size_t nbytes, ::off_t *basep) { if (nbytes < sizeof(struct dirent)) { - PERR("buf too small"); + error("buf too small"); return -1; } @@ -1625,7 +1630,7 @@ namespace { case Vfs::Directory_service::ERR_FD_INVALID: errno = EBADF; - PERR("dirent: ERR_FD_INVALID"); + error("dirent: ERR_FD_INVALID"); return -1; case Vfs::Directory_service::NUM_GENERAL_ERRORS: return -1; @@ -1673,7 +1678,7 @@ namespace { case Vfs::Directory_service::ERR_FD_INVALID: errno = EBADF; - PERR("lseek: ERR_FD_INVALID"); + error("lseek: ERR_FD_INVALID"); return -1; case Vfs::Directory_service::NUM_GENERAL_ERRORS: return -1; @@ -1689,7 +1694,7 @@ namespace { Genode::strncpy(sysio()->unlink_in.path, path, sizeof(sysio()->unlink_in.path)); if (!noux_syscall(Noux::Session::SYSCALL_UNLINK)) { - PWRN("unlink syscall failed for path \"%s\"", path); + warning("unlink syscall failed for path \"", path, "\""); typedef Vfs::Directory_service::Unlink_result Result; switch (sysio()->error.unlink) { case Result::UNLINK_ERR_NO_ENTRY: errno = ENOENT; break; @@ -1713,13 +1718,13 @@ namespace { ssize_t Plugin::readlink(const char *path, char *buf, size_t bufsiz) { if (verbose) - PDBG("path = %s, bufsiz = %zu", path, bufsiz); + log(__func__, ": path=", path, ", bufsiz=", bufsiz); Genode::strncpy(sysio()->readlink_in.path, path, sizeof(sysio()->readlink_in.path)); sysio()->readlink_in.bufsiz = bufsiz; if (!noux_syscall(Noux::Session::SYSCALL_READLINK)) { - PWRN("readlink syscall failed for path \"%s\"", path); + warning("readlink syscall failed for path \"", path, "\""); typedef Vfs::Directory_service::Readlink_result Result; switch (sysio()->error.readlink) { case Result::READLINK_ERR_NO_ENTRY: errno = ENOENT; return -1; @@ -1733,7 +1738,7 @@ namespace { Genode::memcpy(buf, sysio()->readlink_out.chunk, size); if (verbose) - PDBG("result = %s", buf); + log(__func__, ": result=", Genode::Cstring(buf)); return size; } @@ -1745,7 +1750,7 @@ namespace { Genode::strncpy(sysio()->rename_in.to_path, to_path, sizeof(sysio()->rename_in.to_path)); if (!noux_syscall(Noux::Session::SYSCALL_RENAME)) { - PWRN("rename syscall failed for \"%s\" -> \"%s\"", from_path, to_path); + warning("rename syscall failed for \"", from_path, "\" -> \"", to_path, "\""); switch (sysio()->error.rename) { case Vfs::Directory_service::RENAME_ERR_NO_ENTRY: errno = ENOENT; break; case Vfs::Directory_service::RENAME_ERR_CROSS_FS: errno = EXDEV; break; @@ -1764,7 +1769,7 @@ namespace { Genode::strncpy(sysio()->mkdir_in.path, path, sizeof(sysio()->mkdir_in.path)); if (!noux_syscall(Noux::Session::SYSCALL_MKDIR)) { - PWRN("mkdir syscall failed for \"%s\" mode=0x%x", path, (int)mode); + warning("mkdir syscall failed for \"", path, "\" mode=", Hex(mode)); switch (sysio()->error.mkdir) { case Vfs::Directory_service::MKDIR_ERR_EXISTS: errno = EEXIST; break; case Vfs::Directory_service::MKDIR_ERR_NO_ENTRY: errno = ENOENT; break; @@ -1783,13 +1788,13 @@ namespace { Libc::File_descriptor *fd, ::off_t offset) { if (prot != PROT_READ) { - PERR("mmap for prot=%x not supported", prot); + error("mmap for prot=", Hex(prot), " not supported"); errno = EACCES; return (void *)-1; } if (addr_in != 0) { - PERR("mmap for predefined address not supported"); + error("mmap for predefined address not supported"); errno = EINVAL; return (void *)-1; } @@ -1801,7 +1806,7 @@ namespace { } if (::pread(fd->libc_fd, addr, length, offset) < 0) { - PERR("mmap could not obtain file content"); + error("mmap could not obtain file content"); ::munmap(addr, length); errno = EACCES; return (void *)-1; @@ -2113,7 +2118,7 @@ namespace { Genode::memcpy(sysio()->send_in.buf, src, curr_len); if (!noux_syscall(Noux::Session::SYSCALL_SEND)) { - PERR("write error %d", sysio()->error.general); + error("write error ", (int)sysio()->error.general); switch (sysio()->error.send) { case Noux::Sysio::SEND_ERR_AGAIN: errno = EAGAIN; break; case Noux::Sysio::SEND_ERR_WOULD_BLOCK: errno = EWOULDBLOCK; break; @@ -2237,12 +2242,12 @@ void init_libc_noux(void) for (unsigned i = 0; arg_buf[i] && (i < ARG_BUF_SIZE - 2); ) { if (i >= ARG_BUF_SIZE - 2) { - PWRN("command-line argument buffer exceeded\n"); + warning("command-line argument buffer exceeded"); break; } if (argc >= MAX_ARGS - 1) { - PWRN("number of command-line arguments exceeded\n"); + warning("number of command-line arguments exceeded"); break; } diff --git a/repos/ports/src/noux/args.h b/repos/ports/src/noux/args.h index 2f256ce9a..bf87b64cf 100644 --- a/repos/ports/src/noux/args.h +++ b/repos/ports/src/noux/args.h @@ -17,7 +17,7 @@ /* Genode includes */ #include #include -#include +#include namespace Noux { @@ -90,7 +90,7 @@ namespace Noux { { for (unsigned i = 0, j = 0; _buf[i] && (i < _buf_size - 2); i += strlen(&_buf[i]) + 1, j++) - PINF("arg(%u): \"%s\"", j, &_buf[i]); + log("arg(", j, "): \"", Cstring(&_buf[i]), "\""); } }; diff --git a/repos/ports/src/noux/child.h b/repos/ports/src/noux/child.h index ca7f25fa5..5d0df81d3 100644 --- a/repos/ports/src/noux/child.h +++ b/repos/ports/src/noux/child.h @@ -435,7 +435,7 @@ namespace Noux { _args.dump(); if (!forked && !_elf._binary_ds.valid()) { - PERR("Lookup of executable \"%s\" failed", binary_name); + error("lookup of executable \"", binary_name, "\" failed"); _destruct(); throw Binary_does_not_exist(); @@ -464,7 +464,7 @@ namespace Noux { void submit_exit_signal() { if (init_process(this)) { - PINF("init process exited"); + log("init process exited"); /* trigger exit of main event loop */ init_process_exited(_child_policy.exit_value()); @@ -573,7 +573,7 @@ namespace Noux { try { _pending_signals.add(sig); } catch (Signal_queue::Overflow) { - PERR("signal queue is full - signal dropped"); + error("signal queue is full - signal dropped"); } _blocker.unlock(); diff --git a/repos/ports/src/noux/child_policy.h b/repos/ports/src/noux/child_policy.h index 75769068c..2aae90c36 100644 --- a/repos/ports/src/noux/child_policy.h +++ b/repos/ports/src/noux/child_policy.h @@ -127,7 +127,7 @@ namespace Noux { _exit_value = exit_value; if (_verbose || (exit_value != 0)) - PERR("child %s exited with exit value %d", _name, exit_value); + log("child ", _name, " exited with exit value ", exit_value); /* * Close all open file descriptors. This is necessary to unblock diff --git a/repos/ports/src/noux/cpu_session_component.h b/repos/ports/src/noux/cpu_session_component.h index fc2e9344a..203e0d912 100644 --- a/repos/ports/src/noux/cpu_session_component.h +++ b/repos/ports/src/noux/cpu_session_component.h @@ -104,7 +104,7 @@ namespace Noux { return cap; } - PERR("maximum number of threads per session reached"); + error("maximum number of threads per session reached"); throw Thread_creation_failed(); } diff --git a/repos/ports/src/noux/dataspace_registry.h b/repos/ports/src/noux/dataspace_registry.h index 36a209f41..e90efd47f 100644 --- a/repos/ports/src/noux/dataspace_registry.h +++ b/repos/ports/src/noux/dataspace_registry.h @@ -153,7 +153,7 @@ namespace Noux { { auto lambda = [this] (Static_dataspace_info *info) { if (!info) { - PERR("lookup of binary ds info failed"); + error("lookup of binary ds info failed"); return; } @@ -173,7 +173,7 @@ namespace Noux { void poke(addr_t dst_offset, void const *src, size_t len) { - PERR("Attempt to poke onto a static dataspace"); + error("attempt to poke onto a static dataspace"); } }; } diff --git a/repos/ports/src/noux/file_descriptor_registry.h b/repos/ports/src/noux/file_descriptor_registry.h index 87f8cea04..2b173c8e9 100644 --- a/repos/ports/src/noux/file_descriptor_registry.h +++ b/repos/ports/src/noux/file_descriptor_registry.h @@ -75,12 +75,12 @@ namespace Noux { virtual int add_io_channel(Shared_pointer io_channel, int fd = -1) { if ((fd == -1) && !_find_available_fd(&fd)) { - PERR("Could not allocate file descriptor"); + error("could not allocate file descriptor"); return -1; } if (!_valid_fd(fd)) { - PERR("File descriptor %d is out of range", fd); + error("file descriptor ", fd, " is out of range"); return -2; } @@ -91,7 +91,7 @@ namespace Noux { virtual void remove_io_channel(int fd) { if (!_valid_fd(fd)) - PERR("File descriptor %d is out of range", fd); + error("file descriptor ", fd, " is out of range"); else _reset_fd(fd); } diff --git a/repos/ports/src/noux/local_cpu_service.h b/repos/ports/src/noux/local_cpu_service.h index c070ecdf9..725adbc69 100644 --- a/repos/ports/src/noux/local_cpu_service.h +++ b/repos/ports/src/noux/local_cpu_service.h @@ -39,7 +39,7 @@ namespace Noux { Genode::Session_capability session(const char *args, Affinity const &) { - PDBG("Implement me!"); + Genode::warning(__func__, ": implement me!"); return Genode::Session_capability(); } @@ -50,7 +50,7 @@ namespace Noux { void close(Genode::Session_capability session) { - PDBG("Implement me!"); + Genode::warning(__func__, ": implement me!"); } }; } diff --git a/repos/ports/src/noux/local_pd_service.h b/repos/ports/src/noux/local_pd_service.h index 99e29aaef..7ec1b138d 100644 --- a/repos/ports/src/noux/local_pd_service.h +++ b/repos/ports/src/noux/local_pd_service.h @@ -39,7 +39,7 @@ namespace Noux { Genode::Session_capability session(const char *args, Affinity const &) override { - PDBG("not implemented"); + warning(__func__, " not implemented"); return Genode::Session_capability(); } @@ -50,7 +50,7 @@ namespace Noux { void close(Genode::Session_capability session) override { - PDBG("not implemented"); + warning(__func__, " not implemented"); } }; } diff --git a/repos/ports/src/noux/main.cc b/repos/ports/src/noux/main.cc index 3ff0c3c75..f99e18e96 100644 --- a/repos/ports/src/noux/main.cc +++ b/repos/ports/src/noux/main.cc @@ -155,8 +155,7 @@ namespace Noux { bool Noux::Child::syscall(Noux::Session::Syscall sc) { if (trace_syscalls) - Genode::printf("PID %d -> SYSCALL %s\n", - pid(), Noux::Session::syscall_name(sc)); + log("PID ", pid(), " -> SYSCALL ", Noux::Session::syscall_name(sc)); bool result = false; @@ -515,8 +514,8 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) if (_sysio->select_in.timeout.zero() || timeout_reached) { /* - if (timeout_reached) PINF("timeout_reached"); - else PINF("timeout.zero()"); + if (timeout_reached) log("timeout_reached"); + else log("timeout.zero()"); */ _sysio->select_out.fds.num_rd = 0; _sysio->select_out.fds.num_wr = 0; @@ -657,7 +656,7 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) Family_member::remove(exited); if (verbose) - PINF("submit exit signal for PID %d", exited->pid()); + log("submit exit signal for PID ", exited->pid()); static_cast(exited)->submit_exit_signal(); } else { @@ -897,9 +896,9 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc) catch (Invalid_fd) { _sysio->error.general = Vfs::Directory_service::ERR_FD_INVALID; - PERR("Invalid file descriptor"); } + error("invalid file descriptor"); } - catch (...) { PERR("Unexpected exception"); } + catch (...) { error("unexpected exception"); } /* handle signals which might have occured */ while (!_pending_signals.empty() && @@ -945,7 +944,7 @@ static Noux::Args const &args_of_init_process() } } catch (Genode::Xml_node::Nonexistent_sub_node) { } - catch (Noux::Args::Overrun) { PERR("Argument buffer overrun"); } + catch (Noux::Args::Overrun) { Genode::error("argument buffer overrun"); } return args; } @@ -1058,7 +1057,7 @@ static Noux::Io_channel *connect_stdio(Vfs::Dir_file_system &root, path, sizeof(path)); if (root.open(path, mode, &vfs_handle) != Directory_service::OPEN_OK) { - PERR("failed to connect %s to '%s'", stdio_name, path); + error("failed to connect ", stdio_name, " to '", Cstring(path), "'"); Genode::env()->parent()->exit(1); } @@ -1066,7 +1065,7 @@ static Noux::Io_channel *connect_stdio(Vfs::Dir_file_system &root, Vfs_io_channel(path, root.leaf_path(path), &root, vfs_handle, sig_rec); } catch (Genode::Xml_node::Nonexistent_attribute) { - PWRN("%s VFS path not defined, connecting to Terminal session", stdio_name); + warning(stdio_name, " VFS path not defined, connecting to terminal session"); } return new (Genode::env()->heap()) @@ -1113,7 +1112,7 @@ void *operator new (Genode::size_t size) { void operator delete (void * ptr) { if (Genode::env()->heap()->need_size_for_free()) { - PWRN("leaking memory"); + Genode::warning("leaking memory"); return; } @@ -1134,7 +1133,7 @@ struct File_system_factory : Vfs::File_system_factory int main(int argc, char **argv) { using namespace Noux; - PINF("--- noux started ---"); + log("--- noux started ---"); /* whitelist of service requests to be routed to the parent */ static Genode::Service_registry parent_services; @@ -1248,11 +1247,10 @@ int main(int argc, char **argv) destruct_queue.flush(); if (verbose_quota) - PINF("quota: avail=%zd, used=%zd", - env()->ram_session()->avail(), - env()->ram_session()->used()); + log("quota: avail=", env()->ram_session()->avail(), " " + "used=", env()->ram_session()->used()); } - PINF("--- exiting noux ---"); + log("--- exiting noux ---"); return exit_value; } diff --git a/repos/ports/src/noux/net/net.cc b/repos/ports/src/noux/net/net.cc index f8694352e..36e31a932 100644 --- a/repos/ports/src/noux/net/net.cc +++ b/repos/ports/src/noux/net/net.cc @@ -66,7 +66,7 @@ static void select_notify() void init_network() { - PINF("--- noux: initialize network ---"); + log("--- noux: initialize network ---"); if (!libc_select_notify) libc_select_notify = select_notify; diff --git a/repos/ports/src/noux/net/socket_io_channel.h b/repos/ports/src/noux/net/socket_io_channel.h index d3251d683..39da1eaf6 100644 --- a/repos/ports/src/noux/net/socket_io_channel.h +++ b/repos/ports/src/noux/net/socket_io_channel.h @@ -16,7 +16,7 @@ #define _NOUX__SOCKET_IO_CHANNEL_H_ /* Genode includes */ -#include +#include /* Noux includes */ #include @@ -87,7 +87,7 @@ namespace Noux { case EINVAL: sysio->error.read = Vfs::File_io_service::READ_ERR_INVALID; break; case EIO: sysio->error.read = Vfs::File_io_service::READ_ERR_IO; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } @@ -111,7 +111,7 @@ namespace Noux { case EINVAL: sysio->error.read = Vfs::File_io_service::READ_ERR_INVALID; break; case EIO: sysio->error.read = Vfs::File_io_service::READ_ERR_IO; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } @@ -126,8 +126,8 @@ namespace Noux { case Sysio::FCNTL_CMD_GET_FILE_STATUS_FLAGS: cmd = F_GETFL; break; case Sysio::FCNTL_CMD_SET_FILE_STATUS_FLAGS: cmd = F_SETFL; break; default: - PDBG("invalid fcntl command: %d", sysio->fcntl_in.cmd); - sysio->error.fcntl = Sysio::FCNTL_ERR_CMD_INVALID; + log("invalid fcntl command: ", (int)sysio->fcntl_in.cmd); + sysio->error.fcntl = Sysio::FCNTL_ERR_CMD_INVALID; return false; } @@ -147,7 +147,7 @@ namespace Noux { case Vfs::File_io_service::IOCTL_OP_FIONBIO: request = FIONBIO; break; default: - PDBG("invalid ioctl request: %d", sysio->ioctl_in.request); + log(__func__, ": invalid ioctl request: ", (int)sysio->ioctl_in.request); return false; } int result = ::ioctl(_socket, request, NULL); @@ -231,7 +231,7 @@ namespace Noux { case EOPNOTSUPP: sysio->error.accept = Sysio::ACCEPT_ERR_NOT_SUPPORTED; break; case EWOULDBLOCK: sysio->error.accept = Sysio::ACCEPT_ERR_WOULD_BLOCK; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -251,7 +251,7 @@ namespace Noux { case EINVAL: sysio->error.bind = Sysio::BIND_ERR_INVALID; break; case ENOMEM: sysio->error.bind = Sysio::BIND_ERR_NO_MEMORY; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -276,7 +276,7 @@ namespace Noux { case EHOSTUNREACH: sysio->error.connect = Sysio::CONNECT_ERR_NO_ROUTE; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -309,7 +309,7 @@ namespace Noux { case EADDRINUSE: sysio->error.listen = Sysio::LISTEN_ERR_ADDR_IN_USE; break; case EOPNOTSUPP: sysio->error.listen = Sysio::LISTEN_ERR_NOT_SUPPORTED; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -328,7 +328,7 @@ namespace Noux { case EINVAL: sysio->error.recv = Sysio::RECV_ERR_INVALID; break; case ENOTCONN: sysio->error.recv = Sysio::RECV_ERR_NOT_CONNECTED; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -351,7 +351,7 @@ namespace Noux { case EINVAL: sysio->error.recv = Sysio::RECV_ERR_INVALID; break; case ENOTCONN: sysio->error.recv = Sysio::RECV_ERR_NOT_CONNECTED; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, " unhandled errno: ", (int)errno); break; } } @@ -371,8 +371,8 @@ namespace Noux { switch (sysio->setsockopt_in.optname) { case SO_DEBUG: case SO_LINGER: - PWRN("SOL_SOCKET option '%d' is currently not supported, however we report success", - sysio->setsockopt_in.optname); + warning("SOL_SOCKET option '", sysio->setsockopt_in.optname, "' " + "is currently not supported, however we report success"); return true; } @@ -398,7 +398,7 @@ namespace Noux { case EISCONN: sysio->error.send = Sysio::SEND_ERR_IS_CONNECTED; break; case ENOMEM: sysio->error.send = Sysio::SEND_ERR_NO_MEMORY; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -424,7 +424,7 @@ namespace Noux { case EISCONN: sysio->error.send = Sysio::SEND_ERR_IS_CONNECTED; break; case ENOMEM: sysio->error.send = Sysio::SEND_ERR_NO_MEMORY; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } @@ -442,7 +442,7 @@ namespace Noux { switch (errno) { case ENOTCONN: sysio->error.shutdown = Sysio::SHUTDOWN_ERR_NOT_CONNECTED; break; default: - PDBG("unhandled errno: %d", errno); + log(__func__, ": unhandled errno: ", (int)errno); break; } } diff --git a/repos/ports/src/noux/ram_session_component.h b/repos/ports/src/noux/ram_session_component.h index b1d7787cd..819725cc7 100644 --- a/repos/ports/src/noux/ram_session_component.h +++ b/repos/ports/src/noux/ram_session_component.h @@ -80,8 +80,8 @@ namespace Noux { void poke(addr_t dst_offset, void const *src, size_t len) { if ((dst_offset >= size()) || (dst_offset + len > size())) { - PERR("illegal attemt to write beyond dataspace boundary"); - return; + error("illegal attemt to write beyond dataspace boundary"); + return; } char *dst = 0; @@ -159,7 +159,7 @@ namespace Noux { ds_info = rdi; if (!ds_info) { - PERR("RAM free: dataspace lookup failed"); + error("RAM free: dataspace lookup failed"); return; } diff --git a/repos/ports/src/noux/region_map_component.h b/repos/ports/src/noux/region_map_component.h index 184bf7c39..cd961b547 100644 --- a/repos/ports/src/noux/region_map_component.h +++ b/repos/ports/src/noux/region_map_component.h @@ -180,8 +180,8 @@ class Noux::Region_map_component : public Rpc_object, } else { - PWRN("replay: missing ds_info for dataspace at addr 0x%lx", - curr->local_addr); + warning("replay: missing ds_info for dataspace at addr ", + Hex(curr->local_addr)); /* * If the dataspace is not a RAM dataspace, assume that @@ -205,8 +205,8 @@ class Noux::Region_map_component : public Rpc_object, */ if (!ds.valid()) { if (verbose_replay) - PWRN("replay: skip dataspace of region 0x%lx", - curr->local_addr); + warning("replay: skip dataspace of region ", + Hex(curr->local_addr)); return; } @@ -255,10 +255,12 @@ class Noux::Region_map_component : public Rpc_object, info->register_user(*region); } else { if (verbose_attach) { - PWRN("Trying to attach unknown dataspace type ds=%ld", ds.local_name()); - PWRN(" ds_info@%p at 0x%lx size=%zd offset=0x%lx", - info, (long)local_addr, - Dataspace_client(ds).size(), (long)offset); + warning("trying to attach unknown dataspace type " + "ds=", ds.local_name(), " " + "info@", info, " " + "local_addr=", Hex(local_addr), " " + "size=", Dataspace_client(ds).size(), " " + "offset=", Hex(offset)); } } }; @@ -280,8 +282,7 @@ class Noux::Region_map_component : public Rpc_object, Lock::Guard guard(_region_lock); region = _lookup_region_by_addr(local_addr); if (!region) { - PWRN("Attempt to detach unknown region at 0x%p", - (void *)local_addr); + warning("attempt to detach unknown region at ", (void *)local_addr); return; } @@ -370,7 +371,7 @@ class Noux::Region_map_component : public Rpc_object, Region *region = _lookup_region_by_addr(dst_addr); if (!region) { - PERR("poke: no region at 0x%lx", dst_addr); + error("poke: no region at ", Hex(dst_addr)); return; } @@ -379,12 +380,12 @@ class Noux::Region_map_component : public Rpc_object, * type refers to the same region. */ if (region != _lookup_region_by_addr(dst_addr + len - 1)) { - PERR("attempt to write beyond region boundary"); + error("attempt to write beyond region boundary"); return; } if (region->offset) { - PERR("poke: writing to region with offset is not supported"); + error("poke: writing to region with offset is not supported"); return; } @@ -394,7 +395,7 @@ class Noux::Region_map_component : public Rpc_object, _ds_registry.apply(ds_cap, [&] (Dataspace_info *info) { if (!info) { - PERR("attempt to write to unknown dataspace type"); + error("attempt to write to unknown dataspace type"); for (;;); } info->poke(dst_addr - local_addr, src, len); diff --git a/repos/ports/src/noux/rom_session_component.h b/repos/ports/src/noux/rom_session_component.h index 20f6d8abc..72cde48fa 100644 --- a/repos/ports/src/noux/rom_session_component.h +++ b/repos/ports/src/noux/rom_session_component.h @@ -35,7 +35,7 @@ namespace Noux { void poke(addr_t dst_offset, void const *src, size_t len) { - PERR("Attempt to poke onto a ROM dataspace"); + error("attempt to poke onto a ROM dataspace"); } }; @@ -70,9 +70,10 @@ namespace Noux { * the '_ds_info' member. */ _ds_registry.apply(_ds_info.ds_cap(), [this] (Dataspace_info *info) { + if (!info) { - PERR("~Rom_session_component: unexpected !info"); - return; + error("~Rom_session_component: unexpected !info"); + return; } _ds_registry.remove(&_ds_info); diff --git a/repos/ports/src/noux/shared_pointer.h b/repos/ports/src/noux/shared_pointer.h index d9b40822f..04b8321c6 100644 --- a/repos/ports/src/noux/shared_pointer.h +++ b/repos/ports/src/noux/shared_pointer.h @@ -15,10 +15,9 @@ #define _NOUX__SHARED_POINTER_PTR_H_ /* Genode includes */ -#include #include #include -#include +#include /* Noux includes */ #include @@ -88,9 +87,6 @@ namespace Noux { { if (Shared_pointer_base::_dec_ref_count()) { - if (0) - PINF("ref count for %p reached zero -> delete object", _ptr); - destroy(_alloc, _ptr); _ptr = 0; _alloc = 0; diff --git a/repos/ports/src/noux/stdio_file_system.h b/repos/ports/src/noux/stdio_file_system.h index e603c1a03..051917757 100644 --- a/repos/ports/src/noux/stdio_file_system.h +++ b/repos/ports/src/noux/stdio_file_system.h @@ -15,7 +15,7 @@ #define _NOUX__STDIO_FILE_SYSTEM_H_ /* Genode includes */ -#include +#include #include #include @@ -93,13 +93,12 @@ namespace Noux { case Vfs::File_io_service::IOCTL_OP_TIOCSETAW: { - PDBG("OP_TIOCSETAW not implemented"); + warning(__func__, ": OP_TIOCSETAW not implemented"); return IOCTL_ERR_INVALID; } default: - - PDBG("invalid ioctl(request=0x%x)", opcode); + warning(__func__, ": invalid ioctl(request=", Hex(opcode), ")"); break; } diff --git a/repos/ports/src/noux/terminal_io_channel.h b/repos/ports/src/noux/terminal_io_channel.h index f92df49f5..06a5e0ebd 100644 --- a/repos/ports/src/noux/terminal_io_channel.h +++ b/repos/ports/src/noux/terminal_io_channel.h @@ -16,7 +16,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -78,7 +78,7 @@ namespace Noux { bool read(Sysio *sysio) override { if (type != STDIN) { - PERR("attempt to read from terminal output channel"); + error("attempt to read from terminal output channel"); return false; } @@ -183,19 +183,19 @@ namespace Noux { case Vfs::File_io_service::IOCTL_OP_TIOCSETAF: { - PDBG("OP_TIOCSETAF not implemented"); + warning(__func__, ": OP_TIOCSETAF not implemented"); return false; } case Vfs::File_io_service::IOCTL_OP_TIOCSETAW: { - PDBG("OP_TIOCSETAW not implemented"); + warning(__func__, ": OP_TIOCSETAW not implemented"); return false; } default: - PDBG("invalid ioctl request %d", sysio->ioctl_in.request); + warning("invalid ioctl request ", (int)sysio->ioctl_in.request); return false; }; } diff --git a/repos/ports/src/test/gdb_monitor_target_config/main.cc b/repos/ports/src/test/gdb_monitor_target_config/main.cc index d52695068..b1a606fcd 100644 --- a/repos/ports/src/test/gdb_monitor_target_config/main.cc +++ b/repos/ports/src/test/gdb_monitor_target_config/main.cc @@ -21,11 +21,11 @@ int main(void) try { config()->xml_node().sub_node("test_config_subnode"); } catch (Xml_node::Nonexistent_sub_node) { - PERR("Error: Missing '' sub node."); + error("missing '' sub node"); return -1; } - printf("Test succeeded\n"); + log("Test succeeded"); return 0; } diff --git a/repos/ports/src/test/vbox_pointer/main.cc b/repos/ports/src/test/vbox_pointer/main.cc index 032425450..5840f4030 100644 --- a/repos/ports/src/test/vbox_pointer/main.cc +++ b/repos/ports/src/test/vbox_pointer/main.cc @@ -30,7 +30,7 @@ static String read_string_attribute(Genode::Xml_node const &node, try { char buf[String::capacity()]; node.attribute(attr).value(buf, sizeof(buf)); - return String(buf); + return String(Genode::Cstring(buf)); } catch (...) { return default_value; } diff --git a/repos/ports/src/test/vmm_utils/main.cc b/repos/ports/src/test/vmm_utils/main.cc index 0bcbbfbfb..ad0927905 100644 --- a/repos/ports/src/test/vmm_utils/main.cc +++ b/repos/ports/src/test/vmm_utils/main.cc @@ -20,7 +20,6 @@ #include using Genode::Cap_connection; -using Genode::printf; using Genode::sleep_forever; @@ -51,7 +50,7 @@ class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher void _svm_startup() { - Vmm::printf("_svm_startup called\n"); + Vmm::log("_svm_startup called"); } public: @@ -86,12 +85,12 @@ class Vcpu_dispatcher : public Vmm::Vcpu_dispatcher int main(int argc, char **argv) { - printf("--- VBox started ---\n"); + Genode::log("--- VBox started ---"); static Cap_connection cap; static Vcpu_dispatcher vcpu_dispatcher(cap, Vcpu_dispatcher::SVM); - printf("going to sleep forever...\n"); + Genode::log("going to sleep forever..."); sleep_forever(); return 0; } diff --git a/repos/ports/src/virtualbox/accloff/sup.cc b/repos/ports/src/virtualbox/accloff/sup.cc index 295ead2fb..d0020c4f0 100644 --- a/repos/ports/src/virtualbox/accloff/sup.cc +++ b/repos/ports/src/virtualbox/accloff/sup.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -71,11 +71,11 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned case VMMR0_DO_GVMM_SCHED_POLL: /* called by 'vmR3HaltGlobal1Halt' */ - PDBG("SUPR3CallVMMR0Ex: VMMR0_DO_GVMM_SCHED_POLL"); + Genode::log(__func__, ": SUPR3CallVMMR0Ex: VMMR0_DO_GVMM_SCHED_POLL"); return VINF_SUCCESS; default: - PERR("SUPR3CallVMMR0Ex: unhandled uOperation %d", uOperation); + Genode::error("SUPR3CallVMMR0Ex: unhandled uOperation ", (int)uOperation); return VERR_GENERAL_FAILURE; } } @@ -131,9 +131,9 @@ HRESULT genode_setup_machine(ComObjPtr machine) bool Vmm_memory::revoke_from_vm(Mem_region *r) { - PWRN("%s unimplemented", __func__); + Genode::warning(__func__, " unimplemented"); return false; } -extern "C" void pthread_yield() { PWRN("%s unimplemented", __func__); } +extern "C" void pthread_yield() { Genode::warning(__func__, " unimplemented"); } diff --git a/repos/ports/src/virtualbox/audiodrv.cpp b/repos/ports/src/virtualbox/audiodrv.cpp index f634adfa8..d111d152b 100644 --- a/repos/ports/src/virtualbox/audiodrv.cpp +++ b/repos/ports/src/virtualbox/audiodrv.cpp @@ -31,10 +31,6 @@ extern "C" { } -static bool const verbose = false; -#define PLOGV(...) if (verbose) PLOG(__VA_ARGS__); - - template struct A_ring_buffer_to_bind_them { @@ -196,7 +192,7 @@ static int write_samples(GenodeVoiceOut *out, int16_t *src, int samples) int16_t buf[Audio_out::PERIOD*2]; size_t const n = packet_buf.read(buf, sizeof(buf)); if (n != sizeof(buf)) - PERR("%s: n: %zu buf: %zu", __func__, n, buf); + Genode::error(__func__, ": n: ", n, " buf: ", buf); for (int i = 0; i < Audio_out::PERIOD; i++) { left_content[i] = (float)(buf[i * VBOX_CHANNELS + 0]) / 32768.0f; @@ -230,7 +226,7 @@ static int genode_run_out(HWVoiceOut *hw) size_t const avail = pcm_buf.read_avail(); if ((avail / (VBOX_SAMPLE_SIZE*VBOX_CHANNELS)) < decr) - PERR("%s: avail: %zu < decr %d", __func__, avail, decr); + Genode::error(__func__, ": avail: ", avail, " < decr ", decr); char buf[decr*VBOX_SAMPLE_SIZE*VBOX_CHANNELS]; pcm_buf.read(buf, sizeof(buf), true); @@ -252,11 +248,11 @@ static int genode_write(SWVoiceOut *sw, void *buf, int size) size_t const avail = pcm_buf.write_avail(); if (size > avail) - PWRN("%s: size: %d available: %zu", __func__, size, avail); + Genode::warning(__func__, ": size: ", size, " available: ", avail); size_t const n = pcm_buf.write(buf, size); if (n < size) - PWRN("%s: written: %zu expected: %d", __func__, n, size); + Genode::warning(__func__, ": written: ", n, " expected: ", size); /* needed by audio_pcm_hw_get_live_out() to calculate ``live'' samples */ sw->total_hw_samples_mixed += (size / 4); @@ -269,14 +265,14 @@ static int genode_init_out(HWVoiceOut *hw, audsettings_t *as) GenodeVoiceOut * const out = (GenodeVoiceOut *)hw; if (as->nchannels != VBOX_CHANNELS) { - PERR("only %d channels supported (%d were requested)", - VBOX_CHANNELS, as->nchannels); + Genode::error("only ", (int)VBOX_CHANNELS, " channels supported ", + "( ", as->nchannels, " were requested)"); return -1; } if (as->freq != Audio_out::SAMPLE_RATE) { - PERR("only %d frequency supported (%d was requested)", - Audio_out::SAMPLE_RATE, as->freq); + Genode::error("only ", (int)Audio_out::SAMPLE_RATE, " frequency supported " + "(", as->freq, " was requested)"); return -1; } @@ -285,7 +281,7 @@ static int genode_init_out(HWVoiceOut *hw, audsettings_t *as) out->audio[i] = new (Genode::env()->heap()) Audio_out::Connection(channel_names[i]); } catch (...) { - PERR("could not establish Audio_out connection"); + Genode::error("could not establish Audio_out connection"); while (--i > 0) Genode::destroy(Genode::env()->heap(), out->audio[i]); return -1; @@ -296,11 +292,11 @@ static int genode_init_out(HWVoiceOut *hw, audsettings_t *as) out->hw.samples = Audio_out::PERIOD; out->packets = 0; - PLOG("--- using Audio_out session ---"); - PLOGV("freq: %d", as->freq); - PLOGV("channels: %d", as->nchannels); - PLOGV("format: %d", as->fmt); - PLOGV("endianness: %d", as->endianness); + Genode::log("--- using Audio_out session ---"); + Genode::log("freq: ", as->freq); + Genode::log("channels: ", as->nchannels); + Genode::log("format: ", (int)as->fmt); + Genode::log("endianness: ", as->endianness); return 0; } @@ -319,13 +315,11 @@ static int genode_ctl_out(HWVoiceOut *hw, int cmd, ...) GenodeVoiceOut *out = (GenodeVoiceOut*)hw; switch (cmd) { case VOICE_ENABLE: - PLOGV("enable playback"); out->packets = 0; for (int i = 0; i < VBOX_CHANNELS; i++) out->audio[i]->start(); break; case VOICE_DISABLE: - PLOGV("disable playback (packets: %u)", out->packets); for (int i = 0; i < VBOX_CHANNELS; i++) { out->audio[i]->stop(); out->audio[i]->stream()->invalidate_all(); @@ -347,7 +341,7 @@ static int genode_init_in(HWVoiceIn *hw, audsettings_t *as) try { in->audio = new (Genode::env()->heap()) Audio_in::Connection("left"); } catch (...) { - PERR("could not establish Audio_in connection"); + Genode::error("could not establish Audio_in connection"); return -1; } @@ -355,11 +349,11 @@ static int genode_init_in(HWVoiceIn *hw, audsettings_t *as) in->hw.samples = Audio_in::PERIOD; in->packets = 0; - PLOG("--- using Audio_in session ---"); - PLOGV("freq: %d", as->freq); - PLOGV("channels: %d", as->nchannels); - PLOGV("format: %d", as->fmt); - PLOGV("endianness: %d", as->endianness); + Genode::log("--- using Audio_in session ---"); + Genode::log("freq: ", as->freq); + Genode::log("channels: ", as->nchannels); + Genode::log("format: ", (int)as->fmt); + Genode::log("endianness: ", as->endianness); return 0; } @@ -403,7 +397,7 @@ static int read_samples(GenodeVoiceIn *in, int samples) size_t const w = packet_buf.write(buf, sizeof(buf)); if (w != sizeof(buf)) - PERR("%s: write n: %zu buf: %zu", __func__, w, sizeof(buf)); + Genode::error(__func__, ": write n: ", w, " buf: ", sizeof(buf)); p->invalidate(); p->mark_as_recorded(); @@ -417,7 +411,7 @@ static int read_samples(GenodeVoiceIn *in, int samples) size_t const r = packet_buf.read(buf, sizeof(buf), true); size_t const w = pcm_buf.write(buf, r); if (w != r) - PERR("%s: w: %zu != r: %zu", __func__, w, r); + Genode::error(__func__, ": w: ", w, " != r: ", r); packet_buf.read_advance(w); @@ -448,11 +442,11 @@ static int genode_read(SWVoiceIn *sw, void *buf, int size) size_t const avail = pcm_buf.read_avail(); if (avail < size) - PERR("%s: avail: %zu size: %zu", __func__, avail, size); + Genode::error(__func__, ": avail: ", avail, " size: ", size); size_t const r = pcm_buf.read(buf, size); if (r != size) - PERR("%s: r: %zu size: %d", __func__, r, size); + Genode::error(__func__, ": r: ", r, " size: ", size); /* needed by audio_pcm_hw_get_live_in() to calculate ``live'' samples */ sw->total_hw_samples_acquired += (r / (VBOX_SAMPLE_SIZE*VBOX_CHANNELS)); @@ -465,12 +459,10 @@ static int genode_ctl_in(HWVoiceIn *hw, int cmd, ...) GenodeVoiceIn * const in = (GenodeVoiceIn*)hw; switch (cmd) { case VOICE_ENABLE: - PLOGV("enable recording"); in->packets = 0; in->audio->start(); break; case VOICE_DISABLE: - PLOGV("disable recording (packets: %u)", in->packets); in->audio->stop(); break; } diff --git a/repos/ports/src/virtualbox/devices.cc b/repos/ports/src/virtualbox/devices.cc index 5c3158c05..064c5fbe4 100644 --- a/repos/ports/src/virtualbox/devices.cc +++ b/repos/ports/src/virtualbox/devices.cc @@ -12,7 +12,6 @@ */ /* Genode includes */ -#include #include /* VirtualBox includes */ diff --git a/repos/ports/src/virtualbox/devxhci.cc b/repos/ports/src/virtualbox/devxhci.cc index 64e043dac..5eabe0227 100644 --- a/repos/ports/src/virtualbox/devxhci.cc +++ b/repos/ports/src/virtualbox/devxhci.cc @@ -14,7 +14,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -161,7 +161,7 @@ struct Timer_queue : public Qemu::Timer_queue { Context *c = _find_context(qtimer); if (c == nullptr) { - PERR("qtimer: %p not found", qtimer); + Genode::error("qtimer: ", qtimer, " not found"); throw -1; } @@ -210,7 +210,7 @@ struct Timer_queue : public Qemu::Timer_queue unsigned res = 0; for (Context *c = _context_list.first(); c; c = c->next()) { - if (c->pending) PINF("timer: %p is pending", c); + if (c->pending) Genode::log("timer: ", c, " is pending"); res++; } @@ -229,11 +229,11 @@ struct Timer_queue : public Qemu::Timer_queue { Genode::Lock::Guard lock_guard(_timer_lock); if (verbose_timer) - PDBG("qtimer: %p cb: %p data: %p", qtimer, cb, data); + Genode::log("qtimer: ", qtimer, " cb: ", cb, " data: ", data); Context *c = _find_context(qtimer); if (c != nullptr) { - PERR("qtimer: %p already registred", qtimer); + Genode::error("qtimer: ", qtimer, " already registred"); throw -1; } @@ -244,11 +244,11 @@ struct Timer_queue : public Qemu::Timer_queue { Genode::Lock::Guard lock_guard(_timer_lock); if (verbose_timer) - PDBG("qtimer: %p", qtimer); + Genode::log("qtimer: ", qtimer); Context *c = _find_context(qtimer); if (c == nullptr) { - PERR("qtimer: %p not found", qtimer); + Genode::error("qtimer: ", qtimer, " not found"); throw -1; } @@ -262,11 +262,11 @@ struct Timer_queue : public Qemu::Timer_queue { Genode::Lock::Guard lock_guard(_timer_lock); if (verbose_timer) - PDBG("qtimer: %p expire: %lld", qtimer, expire_abs); + Genode::log("qtimer: ", qtimer, " expire: ", expire_abs); Context *c = _find_context(qtimer); if (c == nullptr) { - PERR("qtimer: %p not found", qtimer); + Genode::error("qtimer: ", qtimer, " not found"); throw -1; } @@ -280,7 +280,7 @@ struct Timer_queue : public Qemu::Timer_queue { Genode::Lock::Guard lock_guard(_timer_lock); if (verbose_timer) - PDBG("qtimer: %p", qtimer); + Genode::log("qtimer: ", qtimer); _deactivate_timer(qtimer); } diff --git a/repos/ports/src/virtualbox/drivers.cc b/repos/ports/src/virtualbox/drivers.cc index 07acef184..09a59df88 100644 --- a/repos/ports/src/virtualbox/drivers.cc +++ b/repos/ports/src/virtualbox/drivers.cc @@ -5,15 +5,12 @@ */ /* - * Copyright (C) 2013 Genode Labs GmbH + * Copyright (C) 2013-2016 Genode Labs GmbH * * This file is distributed under the terms of the GNU General Public License * version 2. */ -/* Genode includes */ -#include - /* VirtualBox includes */ #include diff --git a/repos/ports/src/virtualbox/dummies.cc b/repos/ports/src/virtualbox/dummies.cc index 495aa8077..2c48fc257 100644 --- a/repos/ports/src/virtualbox/dummies.cc +++ b/repos/ports/src/virtualbox/dummies.cc @@ -11,7 +11,8 @@ * version 2. */ -#include +#include +#include #include /* libc memcpy */ @@ -37,8 +38,8 @@ static const bool trace = false; #define TRACE(retval) \ { \ if (trace) \ - PDBG("called, return dummy, eip=%p", \ - __builtin_return_address(0)); \ + Genode::log(__func__, " called, return dummy, eip=", \ + __builtin_return_address(0)); \ return retval; \ } @@ -69,8 +70,9 @@ RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW type[3] = 0; - PDBG("called - not implemented - 0x%p+%0zx protect %x - '%s'", - pv, cb, fProtect, type); + Genode::warning(__func__, " called - not implemented - ", pv, "+", + Genode::Hex(cb), " protect ", Genode::Hex(fProtect), " - " + "'", Genode::Cstring(type), "'"); return VINF_SUCCESS; } @@ -103,7 +105,7 @@ int DBGFR3AsSymbolByAddr(PUVM, RTDBGAS, PCDBGFADDRESS, uint32_t, PRTGCINTPTR, int DBGFR3Term(PVM) TRACE(VINF_SUCCESS) int DBGFR3Event(PVM pVM, DBGFEVENTTYPE enmEvent) { - PDBG("%u", enmEvent); + Genode::log(__func__, ": ", (int)enmEvent); TRACE(VERR_NOT_SUPPORTED) } @@ -190,7 +192,7 @@ char *pdmR3FileR3(const char * file, bool) char * pv = reinterpret_cast(RTMemTmpAllocZ(1)); if (trace) - PDBG("file %s %s %p", file, pv, __builtin_return_address(0)); + Genode::log(__func__, ": file ", file, " ", (void *)pv, " ", __builtin_return_address(0)); TRACE(pv) } diff --git a/repos/ports/src/virtualbox/dynlib.cc b/repos/ports/src/virtualbox/dynlib.cc index ed44778a8..4f68e1eb4 100644 --- a/repos/ports/src/virtualbox/dynlib.cc +++ b/repos/ports/src/virtualbox/dynlib.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* VirtualBox includes */ @@ -46,7 +46,7 @@ int RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod) return VINF_SUCCESS; } - PERR("shared library '%s' not supported", pszFilename); + Genode::error("shared library '", pszFilename, "' not supported"); return VERR_NOT_SUPPORTED; } @@ -59,15 +59,15 @@ int RTLdrGetSymbol(RTLDRMOD hLdrMod, const char *pszSymbol, void **ppvValue) if (!(shared <= library && library < shared + sizeof(shared) / sizeof(shared[0]))) { - PERR("shared library handle %p unknown - symbol looked for '%s'", - hLdrMod, pszSymbol); + Genode::error("shared library handle ", hLdrMod, " unknown - " + "symbol looked for '", pszSymbol, "'"); return VERR_NOT_SUPPORTED; } if (Genode::strcmp(pszSymbol, library->symbol)) { - PERR("shared library '%s' does not provide symbol '%s'", - library->name, pszSymbol); + Genode::error("shared library '", library->name, "' does not provide " + "symbol '", pszSymbol, "'"); return VERR_NOT_SUPPORTED; } diff --git a/repos/ports/src/virtualbox/frontend/VirtualBoxBase.h b/repos/ports/src/virtualbox/frontend/VirtualBoxBase.h index 646eb74a8..47cf2cd5c 100644 --- a/repos/ports/src/virtualbox/frontend/VirtualBoxBase.h +++ b/repos/ports/src/virtualbox/frontend/VirtualBoxBase.h @@ -1,7 +1,7 @@ #ifndef ____H_VIRTUALBOXBASEIMPL #define ____H_VIRTUALBOXBASEIMPL -#include +#include #include #include @@ -153,23 +153,23 @@ class Shareable Shareable () : _verbose(false), _obj(nullptr) { } /* operators */ - T * operator->() const { if (_verbose) PDBG("called"); return _obj; } + T * operator->() const { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); return _obj; } bool isNull() const { return _obj == nullptr; } bool operator!() const { return isNull(); } - void allocate() { if (_verbose) PDBG("called %p %u", __builtin_return_address(0), sizeof(*_obj)); _obj = new T; } - void attach(T * t) { if (_verbose) PDBG("called"); } - void attach(Shareable &s) { if (_verbose) PDBG("called"); } - void share(const Shareable &s) { if (_verbose) PDBG("called"); _obj = s._obj; } - void share(T * obj) { if (_verbose) PDBG("called"); _obj = obj; } - void free() { if (_verbose) PDBG("called"); } - void attachCopy(const T *) { if(_verbose) PDBG("called"); } - void attachCopy(const Shareable &) { if (_verbose)PDBG("called"); } + void allocate() { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); _obj = new T; } + void attach(T * t) { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); } + void attach(Shareable &s) { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); } + void share(const Shareable &s) { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); _obj = s._obj; } + void share(T * obj) { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); _obj = obj; } + void free() { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); } + void attachCopy(const T *) { if(_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); } + void attachCopy(const Shareable &) { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); } - T *data() const { if (_verbose) PDBG("called"); return _obj; } + T *data() const { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); return _obj; } - bool isShared() const { if (_verbose) PDBG("called"); return false; } + bool isShared() const { if (_verbose) Genode::log(__PRETTY_FUNCTION__, " called"); return false; } }; template @@ -189,7 +189,7 @@ class Backupable : public Shareable HRESULT backupEx() { return S_OK; } - T *backedUpData() const { PDBG("called"); return nullptr; } + T *backedUpData() const { Genode::log(__PRETTY_FUNCTION__, " called"); return nullptr; } bool isBackedUp() const { return false; } }; diff --git a/repos/ports/src/virtualbox/frontend/console.cc b/repos/ports/src/virtualbox/frontend/console.cc index ff37eb910..ebee462ff 100644 --- a/repos/ports/src/virtualbox/frontend/console.cc +++ b/repos/ports/src/virtualbox/frontend/console.cc @@ -11,7 +11,6 @@ * version 2. */ -#include #include #include @@ -141,8 +140,9 @@ void fireStateChangedEvent(IEventSource* aSource, void fireRuntimeErrorEvent(IEventSource* aSource, BOOL a_fatal, CBSTR a_id, CBSTR a_message) { - PERR("%s : %u %s %s", __func__, a_fatal, - Utf8Str(a_id).c_str(), Utf8Str(a_message).c_str()); + Genode::error(__func__, " : ", a_fatal, " ", + Utf8Str(a_id).c_str(), " ", + Utf8Str(a_message).c_str()); TRACE(); } @@ -162,7 +162,7 @@ void GenodeConsole::update_video_mode() if (fb && (fb->w() == 0) && (fb->h() == 0)) { /* interpret a size of 0x0 as indication to quit VirtualBox */ if (PowerButton() != S_OK) - PERR("ACPI shutdown failed"); + Genode::error("ACPI shutdown failed"); return; } @@ -478,7 +478,7 @@ int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t format, clipboard_rom->update(); if (!clipboard_rom->valid()) { - PERR("invalid clipboard dataspace"); + Genode::error("invalid clipboard dataspace"); return VERR_NOT_SUPPORTED; } @@ -488,7 +488,7 @@ int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t format, Genode::Xml_node node(data); if (!node.has_type("clipboard")) { - PERR("invalid clipboard xml syntax"); + Genode::error("invalid clipboard xml syntax"); return VERR_INVALID_PARAMETER; } @@ -497,7 +497,7 @@ int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t format, decoded_clipboard_content = (char*)malloc(node.content_size()); if (!decoded_clipboard_content) { - PERR("could not allocate buffer for decoded clipboard content"); + Genode::error("could not allocate buffer for decoded clipboard content"); return 0; } @@ -519,7 +519,7 @@ int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t format, *pcbActual = 0; } catch (Genode::Xml_node::Invalid_syntax) { - PERR("invalid clipboard xml syntax"); + Genode::error("invalid clipboard xml syntax"); return VERR_INVALID_PARAMETER; } @@ -545,7 +545,7 @@ void vboxClipboardWriteData (VBOXCLIPBOARDCLIENTDATA *pClient, void *pv, Genode::Reporter::Xml_generator xml(*clipboard_reporter, [&] () { xml.append_sanitized(message, strlen(message)); }); } catch (...) { - PERR("could not write clipboard data"); + Genode::error("could not write clipboard data"); } RTStrFree(message); diff --git a/repos/ports/src/virtualbox/frontend/console.h b/repos/ports/src/virtualbox/frontend/console.h index 0fb4cd7d8..d42ea6504 100644 --- a/repos/ports/src/virtualbox/frontend/console.h +++ b/repos/ports/src/virtualbox/frontend/console.h @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -193,8 +193,8 @@ class GenodeConsole : public Console { size_t shape_size = shape_array.size() - (shape - and_mask); if (shape_size > Vbox_pointer::MAX_SHAPE_SIZE) { - PERR("%s: shape data buffer is too small for %zu bytes", - __func__, shape_size); + Genode::error(__func__, ": shape data buffer is too small " + "for ", shape_size, " bytes"); return; } diff --git a/repos/ports/src/virtualbox/frontend/dummy/autostart.cc b/repos/ports/src/virtualbox/frontend/dummy/autostart.cc index 81b8ee1cb..b75420939 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/autostart.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/autostart.cc @@ -1,5 +1,3 @@ -#include - #include "VirtualBoxBase.h" #include "dummy/macros.h" diff --git a/repos/ports/src/virtualbox/frontend/dummy/errorinfo.cc b/repos/ports/src/virtualbox/frontend/dummy/errorinfo.cc index 0120e9ae0..b8e1a783a 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/errorinfo.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/errorinfo.cc @@ -1,5 +1,3 @@ -#include - #include "VirtualBoxBase.h" #include "dummy/macros.h" diff --git a/repos/ports/src/virtualbox/frontend/dummy/host.cc b/repos/ports/src/virtualbox/frontend/dummy/host.cc index 15f208a81..98500cbbe 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/host.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/host.cc @@ -1,5 +1,3 @@ -#include - #include "VirtualBoxBase.h" #include diff --git a/repos/ports/src/virtualbox/frontend/dummy/macros.h b/repos/ports/src/virtualbox/frontend/dummy/macros.h index ace9b6cd4..77121bbb7 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/macros.h +++ b/repos/ports/src/virtualbox/frontend/dummy/macros.h @@ -1,20 +1,21 @@ #ifndef ____H_MACROS #define ____H_MACROS -#include +#include #define TRACE(X) \ { \ if (debug) \ - PDBG(" called (%s) - eip=%p", __FILE__, \ - __builtin_return_address(0)); \ + Genode::log(__func__, " called (", __FILE__, ") - eip=", \ + __builtin_return_address(0)); \ return X; \ } #define DUMMY(X) \ { \ - PERR("%s called (%s:%u), not implemented, eip=%p", __func__, __FILE__, __LINE__, \ - __builtin_return_address(0)); \ + Genode::error(__func__, " called (", __FILE__, ":", __LINE__, "), " \ + "not implemented, eip=", \ + __builtin_return_address(0)); \ while (1) \ asm volatile ("ud2a"); \ \ @@ -24,8 +25,9 @@ #define DUMMY_STATIC(X) \ { \ static X dummy; \ - PERR("%s called (%s), not implemented, eip=%p", __func__, __FILE__, \ - __builtin_return_address(0)); \ + Genode::error(__func__, " called (", __FILE__, "), " \ + "not implemented, eip=", \ + __builtin_return_address(0)); \ while (1) \ asm volatile ("ud2a"); \ \ diff --git a/repos/ports/src/virtualbox/frontend/dummy/rest.cc b/repos/ports/src/virtualbox/frontend/dummy/rest.cc index a958564e8..9ef4efb4d 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/rest.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/rest.cc @@ -1,5 +1,3 @@ -#include - #include "dummy/macros.h" static bool debug = false; diff --git a/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc b/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc index 6e4e7d726..cb62bc50b 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc @@ -1,4 +1,3 @@ -#include #include #include "VirtualBoxImpl.h" @@ -10,18 +9,13 @@ static bool debug = false; HRESULT VirtualBoxBase::setError(HRESULT aResultCode, const char *pcsz, ...) { - Genode::printf(ESC_ERR); - va_list list; va_start(list, pcsz); - Genode::printf("%s : %s", this->getComponentName(), - Utf8Str(pcsz, list).c_str()); + Genode::error(this->getComponentName(), " : ", Utf8Str(pcsz, list).c_str()); va_end(list); - Genode::printf(ESC_END "\n"); - TRACE(aResultCode); } diff --git a/repos/ports/src/virtualbox/frontend/fb.h b/repos/ports/src/virtualbox/frontend/fb.h index 867d7649c..66ae8327f 100644 --- a/repos/ports/src/virtualbox/frontend/fb.h +++ b/repos/ports/src/virtualbox/frontend/fb.h @@ -150,9 +150,10 @@ class Genodefb : (h <= (ULONG)_next_fb_mode.height()); if (ok) { - PINF("fb resize : %dx%d@%zu -> %ux%u@%u", - _virtual_fb_mode.width(), _virtual_fb_mode.height(), - _virtual_fb_mode.bytes_per_pixel() * 8, w, h, bitsPerPixel); + Genode::log("fb resize : ", _virtual_fb_mode.width(), + "x", _virtual_fb_mode.height(), "@", + _virtual_fb_mode.bytes_per_pixel() * 8, " -> ", + w, "x", h, "@", bitsPerPixel); if ((w < (ULONG)_next_fb_mode.width()) || (h < (ULONG)_next_fb_mode.height())) { @@ -171,9 +172,10 @@ class Genodefb : result = S_OK; } else - PWRN("fb resize : %dx%d@%zu -> %ux%u@%u ignored", - _virtual_fb_mode.width(), _virtual_fb_mode.height(), - _virtual_fb_mode.bytes_per_pixel() * 8, w, h, bitsPerPixel); + Genode::warning("fb resize : ", _virtual_fb_mode.width(), + "x", _virtual_fb_mode.height(), "@", + _virtual_fb_mode.bytes_per_pixel() * 8, " -> ", + w, "x", h, "@", bitsPerPixel, " ignored"); *finished = true; diff --git a/repos/ports/src/virtualbox/frontend/main.cc b/repos/ports/src/virtualbox/frontend/main.cc index 4f05362c3..bbf3ef0a9 100644 --- a/repos/ports/src/virtualbox/frontend/main.cc +++ b/repos/ports/src/virtualbox/frontend/main.cc @@ -14,7 +14,7 @@ /* Genode includes */ -#include +#include #include /* Virtualbox includes */ @@ -202,8 +202,8 @@ int main(int argc, char **argv) Xml_node::Attribute vm_name = node.attribute("vm_name"); vm_name.value(c_vbox_vmname, sizeof(c_vbox_vmname)); } catch (...) { - PERR("Missing attributes in configuration, minimum requirements: "); - PERR(" " ); + Genode::error("missing attributes in configuration, minimum requirements: "); + Genode::error(" " ); throw; } @@ -213,11 +213,11 @@ int main(int argc, char **argv) HRESULT hrc = setupmachine(); if (FAILED(hrc)) { - PERR("Start-up of VMM failed - reason 0x%x - exiting ...", hrc); + Genode::error("startup of VMM failed - reason ", hrc, " - exiting ..."); return -2; } - PERR("VMM exiting ..."); + Genode::error("VMM exiting ..."); return 0; } diff --git a/repos/ports/src/virtualbox/guest_memory.h b/repos/ports/src/virtualbox/guest_memory.h index 15b3076c4..1134d437e 100644 --- a/repos/ports/src/virtualbox/guest_memory.h +++ b/repos/ports/src/virtualbox/guest_memory.h @@ -25,9 +25,9 @@ #undef PAGE_SIZE /* Genode includes */ -#include #include #include +#include #include #include #include @@ -117,10 +117,9 @@ class Guest_memory void dump() const { - Genode::printf("phys [0x%16lx-0x%16lx] -> virt [0x%16lx-0x%16lx] (dev='%s')\n", - (long)_GCPhys, (long)_GCPhys + (long)_cb - 1, - (long)_pv, (long)_pv + (long)_cb - 1, - _pDevIns && _pDevIns->pReg ? _pDevIns->pReg->szName : 0); + Genode::log("phys ", Genode::Hex_range(_GCPhys, _cb), + " -> virt ", Genode::Hex_range((Genode::addr_t)_pv, _cb), + " (dev='", _pDevIns && _pDevIns->pReg ? _pDevIns->pReg->szName : 0, "'"); } void *pv_at_offset(addr_t offset) @@ -300,15 +299,15 @@ class Guest_memory void dump() const { - Genode::printf("guest-physical to VMM-local RAM mappings:\n"); + Genode::log("guest-physical to VMM-local RAM mappings:"); for (Region const *r = _ram_regions.first(); r; r = r->next()) r->dump(); - Genode::printf("guest-physical to VMM-local ROM mappings:\n"); + Genode::log("guest-physical to VMM-local ROM mappings:"); for (Region const *r = _rom_regions.first(); r; r = r->next()) r->dump(); - Genode::printf("guest-physical MMIO regions:\n"); + Genode::log("guest-physical MMIO regions:"); for (Region const *r = _mmio_regions.first(); r; r = r->next()) r->dump(); } @@ -361,9 +360,9 @@ class Guest_memory Region *r = _lookup(vm_phys, size); if (!r) { - PERR("Guest_memory::mmio_write: lookup failed - " - "GCPhys=0x%llx, u32Value=0x%x, size=%zd", - (Genode::uint64_t)vm_phys, u32Value, size); + Genode::error("Guest_memory::mmio_write: lookup failed - " + "GCPhys=", Genode::Hex(vm_phys), " u32Value=", + u32Value, " size=", size); return VERR_IOM_MMIO_RANGE_NOT_FOUND; } @@ -385,9 +384,9 @@ class Guest_memory Region *r = _lookup(vm_phys, size); if (!r) { - PERR("Guest_memory::mmio_read: lookup faile - " - "GCPhys=0x%llx, u32Value=0x%p, size=%zd", - (Genode::uint64_t)vm_phys, u32Value, size); + Genode::error("Guest_memory::mmio_read: lookup faile - " + "GCPhys=", Genode::Hex(vm_phys), " u32Value=", + u32Value, " size=", size); return VERR_IOM_MMIO_RANGE_NOT_FOUND; } diff --git a/repos/ports/src/virtualbox/hm.cc b/repos/ports/src/virtualbox/hm.cc index 903a762c2..c64103c08 100644 --- a/repos/ports/src/virtualbox/hm.cc +++ b/repos/ports/src/virtualbox/hm.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include /* VirtualBox includes */ #include "HMInternal.h" /* enable access to hm.s.* */ @@ -105,7 +105,6 @@ VMMDECL(bool) HMIsEnabledNotMacro(PVM pVM) VMMR3DECL(bool) HMR3IsVmxPreemptionTimerUsed(PVM pVM) { -// PLOG("HMR3IsVmxPreemptionTimerUsed"); return false; } @@ -131,7 +130,6 @@ VMMR3DECL(bool) HMR3IsRescheduleRequired(PVM pVM, PCPUMCTX pCtx) VMMR3DECL(bool) HMR3IsEventPending(PVMCPU pVCpu) { -// PLOG("HMR3IsEventPending false"); return false; } diff --git a/repos/ports/src/virtualbox/include/VBox/com/ptr.h b/repos/ports/src/virtualbox/include/VBox/com/ptr.h index 12bd6d6c0..939f434a0 100644 --- a/repos/ports/src/virtualbox/include/VBox/com/ptr.h +++ b/repos/ports/src/virtualbox/include/VBox/com/ptr.h @@ -3,7 +3,7 @@ #include -#include +#include template class ComPtr { @@ -23,7 +23,7 @@ class ComPtr { ComPtr (X *obj) : _obj(dynamic_cast(obj)) { if (!_obj) - PDBG("dynamic cast failed"); + Genode::log(__func__, ": dynamic cast failed"); } template @@ -49,7 +49,7 @@ class ComPtr { { _obj = dynamic_cast(p); if (!_obj) - PDBG("dynamic cast failed"); + Genode::log(__func__, ": dynamic cast failed"); return *this; } diff --git a/repos/ports/src/virtualbox/iommio.cc b/repos/ports/src/virtualbox/iommio.cc index b254a7922..d2697d490 100644 --- a/repos/ports/src/virtualbox/iommio.cc +++ b/repos/ports/src/virtualbox/iommio.cc @@ -11,9 +11,6 @@ * version 2. */ -/* Genode includes */ -#include - /* VirtualBox includes */ #include "IOMInternal.h" #include @@ -48,8 +45,6 @@ VMMR3_INT_DECL(int) IOMR3Init(PVM pVM) int IOMR3Term(PVM) { - if (verbose) - PDBG("called"); return VINF_SUCCESS; } @@ -72,12 +67,6 @@ int IOMR3MmioRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, R3PTRTYPE(PFNIOMMMIOFILL) pfnFillCallback, uint32_t fFlags, const char *pszDesc) { - if (verbose) - PLOG("%s: GCPhys=0x%llx cb=0x%x pszDesc=%s rd=%p wr=%p fl=%p flags=%x", - __PRETTY_FUNCTION__, - (Genode::uint64_t)GCPhysStart, cbRange, pszDesc, - pfnWriteCallback, pfnReadCallback, pfnFillCallback, fFlags); - REMR3NotifyHandlerPhysicalRegister(pVM, PGMPHYSHANDLERTYPE_MMIO, GCPhysStart, cbRange, true); @@ -93,10 +82,6 @@ int IOMR3MmioRegisterR3(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, int IOMR3MmioDeregister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhysStart, uint32_t cbRange) { - if (verbose) - PLOG("%s: GCPhys=0x%llx cb=0x%x", __PRETTY_FUNCTION__, - (Genode::uint64_t)GCPhysStart, cbRange); - bool status = guest_memory()->remove_mmio_mapping(GCPhysStart, cbRange); if (status) return VINF_SUCCESS; @@ -190,16 +175,11 @@ VMMDECL(VBOXSTRICTRC) IOMMMIORead(PVM pVM, PVMCPU, RTGCPHYS GCPhys, int IOMMMIOMapMMIO2Page(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysRemapped, uint64_t fPageFlags) { - if (verbose) - PDBG("called - %llx %llx", (Genode::uint64_t)GCPhys, - (Genode::uint64_t)GCPhysRemapped); return VINF_SUCCESS; } int IOMMMIOResetRegion(PVM pVM, RTGCPHYS GCPhys) { - if (verbose) - PDBG("called - %llx", (Genode::uint64_t)GCPhys); return VINF_SUCCESS; } diff --git a/repos/ports/src/virtualbox/ioport.cc b/repos/ports/src/virtualbox/ioport.cc index 9efce01ab..a5802bba7 100644 --- a/repos/ports/src/virtualbox/ioport.cc +++ b/repos/ports/src/virtualbox/ioport.cc @@ -13,7 +13,7 @@ /* Genode includes */ #include -#include +#include #include #include @@ -116,8 +116,9 @@ class Guest_ioports PDMCritSectLeave(_pDevIns->CTX_SUFF(pCritSectRo)); if (rc != VERR_IOM_IOPORT_UNUSED && rc != VINF_SUCCESS) - PDBG("IOPORT read port=0x%x failed - callback %p eip %p", - port, _pfnInCallback, __builtin_return_address(0)); + Genode::log("IOPORT read port=", Genode::Hex(port), " failed" + " - callback=", _pfnInCallback, " eip=", + __builtin_return_address(0)); return rc; } @@ -138,9 +139,9 @@ class Guest_ioports void dump() { for (Range *r = _ranges.first(); r; r = r->next()) - PINF("0x%x+0x%x - '%s'\n", - r->_PortStart, r->_cPorts, - r->_pDevIns && r->_pDevIns->pReg ? r->_pDevIns->pReg->szName : 0); + Genode::log(Genode::Hex(r->_PortStart), "+", + Genode::Hex(r->_cPorts), " - '", + r->_pDevIns && r->_pDevIns->pReg ? r->_pDevIns->pReg->szName : 0, "'"); } public: @@ -154,17 +155,19 @@ class Guest_ioports { Range *r = _lookup(PortStart, cPorts); if (r) { - PERR("io port inseration failure 0x%x+0x%x - '%s'", - PortStart, cPorts, - pDevIns && pDevIns->pReg ? pDevIns->pReg->szName : 0); + Genode::error("io port inseration failure ", + Genode::Hex(PortStart), "+", + Genode::Hex(cPorts), " - '", + pDevIns && pDevIns->pReg ? pDevIns->pReg->szName : 0, "'"); dump(); Assert(!r); return VERR_GENERAL_FAILURE; } if (verbose) - PLOG("insert io port range 0x%x+0x%x - '%s'", PortStart, cPorts, - pDevIns && pDevIns->pReg ? pDevIns->pReg->szName : 0); + Genode::log("insert io port range ", Genode::Hex(PortStart), "+", + Genode::Hex(cPorts), " - '", + pDevIns && pDevIns->pReg ? pDevIns->pReg->szName : 0, "'"); _ranges.insert(new (Genode::env()->heap()) Range(pDevIns, PortStart, cPorts, pvUser, @@ -188,10 +191,13 @@ class Guest_ioports deleted = true; if (verbose) - PLOG("delete io port range 0x%x+0x%x out of 0x%x+0x%x - '%s'", - r->_PortStart, r->_cPorts, PortStart, cPorts, - r->_pDevIns && - r->_pDevIns->pReg ? r->_pDevIns->pReg->szName : 0); + Genode::log("delete io port range ", + Genode::Hex(r->_PortStart), "+", + Genode::Hex(r->_cPorts), " out of ", + Genode::Hex(PortStart), "+", + Genode::Hex(cPorts), " - '", + r->_pDevIns && + r->_pDevIns->pReg ? r->_pDevIns->pReg->szName : 0, "'"); Range *s = r; r = r->next(); @@ -211,8 +217,9 @@ class Guest_ioports if (verbose) { char c = u32Value & 0xff; - PWRN("attempted to write to non-existing port 0x%x+%zu %c (%02x)", - port, cbValue, c >= 32 && c <= 176 ? c : '.', c); + Genode::warning("attempted to write to non-existing port ", + Genode::Hex(port), "+", cbValue, " " + "value=", Genode::Hex(c)); } return VINF_SUCCESS; @@ -227,8 +234,8 @@ class Guest_ioports return err; } else if (verbose) - PWRN("attempted to read from non-existing port 0x%x+%zu %p", - port, cbValue, r); + Genode::warning("attempted to read from non-existing port ", + Genode::Hex(port), "+", cbValue, " ", r); switch (cbValue) { @@ -242,8 +249,8 @@ class Guest_ioports *reinterpret_cast(pu32Value) = 0xFFFFFFFFU; break; default: - PERR("Invalid I/O port (%x) access of size (%zx)", - port, cbValue); + Genode::error("Invalid I/O port (", Genode::Hex(port), ") " + "access of size (", Genode::Hex(cbValue), ")"); return VERR_IOM_INVALID_IOPORT_SIZE; } return VINF_SUCCESS; @@ -272,8 +279,9 @@ IOMR3IOPortRegisterR3(PVM pVM, PPDMDEVINS pDevIns, const char *pszDesc) { if (verbose) - PLOG("register I/O port range 0x%x-0x%x '%s'", - PortStart, PortStart + cPorts - 1, pszDesc); + Genode::log("register I/O port range ", + Genode::Hex(PortStart), "-", + Genode::Hex(PortStart + cPorts - 1), " '", pszDesc, "'"); return guest_ioports()->add_range(pDevIns, PortStart, cPorts, pvUser, pfnOutCallback, pfnInCallback, @@ -285,8 +293,9 @@ int IOMR3IOPortDeregister(PVM pVM, PPDMDEVINS pDevIns, RTIOPORT PortStart, RTUINT cPorts) { if (verbose) - PLOG("deregister I/O port range 0x%x-0x%x", - PortStart, PortStart + cPorts - 1); + Genode::log("deregister I/O port range ", + Genode::Hex(PortStart), "-", + Genode::Hex(PortStart + cPorts - 1)); return guest_ioports()->remove_range(pDevIns, PortStart, cPorts); } diff --git a/repos/ports/src/virtualbox/libc.cc b/repos/ports/src/virtualbox/libc.cc index 45adc9f34..0936d2a62 100644 --- a/repos/ports/src/virtualbox/libc.cc +++ b/repos/ports/src/virtualbox/libc.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -131,7 +131,7 @@ extern "C" char *getenv(const char *name) Genode::strcmp(name, "VBOX_RELEASE_LOG_FLAGS") == 0) return (char *)"thread"; - PWRN("getenv called for non-existent variable \"%s\"", name); + Genode::warning("getenv called for non-existent variable \"", name, "\""); return 0; } @@ -165,7 +165,7 @@ extern "C" int nanosleep(const struct timespec *req, struct timespec *rem) extern "C" pid_t getpid(void) { if (verbose) - PINF("%s called - rip %p", __func__, __builtin_return_address(0)); + Genode::log(__func__, " called - rip ", __builtin_return_address(0)); return 1345; } @@ -173,7 +173,7 @@ extern "C" pid_t getpid(void) extern "C" int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) { if (verbose) - PINF("%s called - rip %p", __func__, __builtin_return_address(0)); + Genode::log(__func__, " called - rip ", __builtin_return_address(0)); return -1; } @@ -181,28 +181,28 @@ extern "C" int sigprocmask(int how, const sigset_t *set, sigset_t *oldset) extern "C" int _sigaction(int, const struct sigaction *, struct sigaction *) { if (verbose) - PINF("%s called - rip %p", __func__, __builtin_return_address(0)); + Genode::log(__func__, " called - rip ", __builtin_return_address(0)); return -1; } extern "C" int futimes(int fd, const struct timeval tv[2]) { - PINF("%s called - rip %p", __func__, __builtin_return_address(0)); + Genode::log("%s called - rip %p", __func__, __builtin_return_address(0)); return 0; } extern "C" int lutimes(const char *filename, const struct timeval tv[2]) { - PINF("%s called - file '%s' - rip %p", __func__, filename, - __builtin_return_address(0)); + Genode::log(__func__, ": called - file '", filename, "' - rip ", + __builtin_return_address(0)); return 0; } extern "C" int _sigprocmask() { if (verbose) - PINF("%s called - rip %p", __func__, __builtin_return_address(0)); + Genode::log("%s called - rip %p", __func__, __builtin_return_address(0)); return 0; } @@ -249,8 +249,7 @@ extern "C" int statfs(const char *path, struct statfs *buf) buf->f_bavail = buf->f_blocks; if (show_warning) - PWRN("statfs provides bogus values for '%s' (probably a shared folder)", - path); + Genode::warning("statfs provides bogus values for '", path, "' (probably a shared folder)"); return res; } @@ -259,7 +258,7 @@ extern "C" long pathconf(char const *path, int name) { if (name == _PC_NAME_MAX) return 255; - PERR("pathconf does not support config option %d", name); + Genode::error("pathconf does not support config option ", name); errno = EINVAL; return -1; } diff --git a/repos/ports/src/virtualbox/logger.cc b/repos/ports/src/virtualbox/logger.cc index cc269f759..524e5a2f1 100644 --- a/repos/ports/src/virtualbox/logger.cc +++ b/repos/ports/src/virtualbox/logger.cc @@ -80,7 +80,8 @@ namespace { { switch (cmd) { case F_GETFL: return O_WRONLY; - default: PERR("fcntl(): command %d not supported", cmd); return -1; + default: Genode::error("fcntl(): command ", cmd, " not supported"); + return -1; } } diff --git a/repos/ports/src/virtualbox/mm.cc b/repos/ports/src/virtualbox/mm.cc index 8e43382fc..9e2096b67 100644 --- a/repos/ports/src/virtualbox/mm.cc +++ b/repos/ports/src/virtualbox/mm.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -199,7 +199,6 @@ int MMR3HyperInitFinalize(PVM) int MMR3HyperSetGuard(PVM, void* ptr, size_t, bool) { -// PDBG("called %p", ptr); return VINF_SUCCESS; } @@ -291,8 +290,6 @@ int MMR3HyperMapHCPhys(PVM pVM, void *pvR3, RTR0PTR pvR0, RTHCPHYS HCPhys, int MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr) { -// PINF("MMR3HyperReserve: cb=0x%x, pszDesc=%s", cb, pszDesc); - return VINF_SUCCESS; } @@ -301,10 +298,6 @@ int MMR3HyperMapMMIO2(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr) { -/* - PLOG("MMR3HyperMapMMIO2: pszDesc=%s iRegion=%u off=0x%lx cb=0x%zx", - pszDesc, iRegion, (long)off, (size_t)cb); -*/ return VINF_SUCCESS; } diff --git a/repos/ports/src/virtualbox/network.cpp b/repos/ports/src/virtualbox/network.cpp index 1ee1ad86f..9977e9416 100644 --- a/repos/ports/src/virtualbox/network.cpp +++ b/repos/ports/src/virtualbox/network.cpp @@ -456,7 +456,7 @@ static DECLCALLBACK(void) drvNicDestruct(PPDMDRVINS pDrvIns) Nic_client *nic_client = pThis->nic_client; if (!nic_client) - PERR("nic_client not valid at destruction time"); + Genode::error("nic_client not valid at destruction time"); if (nic_client) Genode::Signal_transmitter(nic_client->dispatcher()).submit(); diff --git a/repos/ports/src/virtualbox/patches/mouse.patch b/repos/ports/src/virtualbox/patches/mouse.patch index cef31f301..bad9bcfc9 100644 --- a/repos/ports/src/virtualbox/patches/mouse.patch +++ b/repos/ports/src/virtualbox/patches/mouse.patch @@ -8,7 +8,7 @@ index 9d0a8d2..7eb6a09 100644 /** * @interface_method_impl{PDMIMOUSEPORT,pfnPutEvent} */ -+#include ++#include static DECLCALLBACK(int) drvMouseQueuePutEvent(PPDMIMOUSEPORT pInterface, int32_t dx, int32_t dy, int32_t dz, int32_t dw, @@ -17,7 +17,7 @@ index 9d0a8d2..7eb6a09 100644 return VINF_SUCCESS; } - return VERR_PDM_NO_QUEUE_ITEMS; -+ PERR("%s - drop event", __func__); ++ Genode::error(__func__, " - drop event"); + return VINF_SUCCESS; } @@ -27,7 +27,7 @@ index 9d0a8d2..7eb6a09 100644 return VINF_SUCCESS; } - return VERR_PDM_NO_QUEUE_ITEMS; -+ PERR("%s - drop event", __func__); ++ Genode::error(__func__, " - drop event"); + return VINF_SUCCESS; } diff --git a/repos/ports/src/virtualbox/pdm.cc b/repos/ports/src/virtualbox/pdm.cc index b8c5eefb7..bd987847f 100644 --- a/repos/ports/src/virtualbox/pdm.cc +++ b/repos/ports/src/virtualbox/pdm.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* VirtualBox includes */ @@ -26,7 +26,7 @@ static void RCSymbolDummy() { - PDBG("unexpected call of RC symbol"); + Genode::log(__func__, ": unexpected call of RC symbol"); for (;;); } @@ -130,7 +130,7 @@ int PDMR3LdrGetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, } } - PERR("pszModule=%s pszSymbol=%s", pszModule, pszSymbol); + Genode::error("pszModule=", pszModule, " pszSymbol=", pszSymbol); return VERR_SYMBOL_NOT_FOUND; } diff --git a/repos/ports/src/virtualbox/pgm.cc b/repos/ports/src/virtualbox/pgm.cc index 4cde517da..ff1f8ed79 100644 --- a/repos/ports/src/virtualbox/pgm.cc +++ b/repos/ports/src/virtualbox/pgm.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include /* VirtualBox includes */ @@ -33,8 +33,6 @@ using Genode::Ram_session; using Genode::Rm_session; -static bool verbose = false; -static bool verbose_debug = false; Vmm_memory *vmm_memory() { @@ -64,10 +62,6 @@ int PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb, const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc) { - if (verbose) - PLOG("%s: GCPhys=0x%llx cb=0x%llx pvBinary=0x%p - '%s'", __func__, - (Genode::uint64_t)GCPhys, (Genode::uint64_t)cb, pvBinary, pszDesc); - try { RTGCPHYS GCPhysLast = GCPhys + (cb - 1); @@ -112,10 +106,6 @@ int PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) { void *pv = guest_memory()->lookup(GCPhys, cbWrite); - if (verbose_debug) - PDBG("%s: GCPhys=0x%llx pvBuf=0x%p cb=0x%zx pv=%p", __func__, - (Genode::uint64_t)GCPhys, pvBuf, cbWrite, pv); - if (pv) { void * pvx = vmm_memory()->lookup(GCPhys, cbWrite); Assert(!pvx); @@ -130,8 +120,7 @@ int PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) pv = vmm_memory()->lookup(GCPhys, cbWrite, &pfnHandlerR3, &pvUserR3); if (!pv || !pfnHandlerR3 || !pvUserR3) { - PERR("%s skipped: GCPhys=0x%llx pvBuf=0x%p cbWrite=0x%zx", __func__, - (Genode::uint64_t)GCPhys, pvBuf, cbWrite); + Genode::error(__func__, " skipped: GCPhys=", Genode::Hex(GCPhys)); return VERR_GENERAL_FAILURE; } @@ -139,7 +128,7 @@ int PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) pvUserR3); if (rc != VINF_PGM_HANDLER_DO_DEFAULT) { - PERR("unexpected %s return code %d", __FUNCTION__, rc); + Genode::error(__FUNCTION__, " unexpected return code ", rc); return VERR_GENERAL_FAILURE; } @@ -161,10 +150,6 @@ int PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) { void *pv = guest_memory()->lookup(GCPhys, cbRead); - if (verbose_debug) - PDBG("%s: GCPhys=0x%llx pvBuf=0x%p cbRead=0x%zx pv=%p", __func__, - (Genode::uint64_t)GCPhys, pvBuf, cbRead, pv); - if (pv) { void * pvx = vmm_memory()->lookup(GCPhys, cbRead); Assert(!pvx); @@ -177,8 +162,7 @@ int PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) pv = vmm_memory()->lookup(GCPhys, cbRead, &pfnHandlerR3, &pvUserR3); if (!pv || !pfnHandlerR3 || !pvUserR3) { - PERR("PGMPhysRead skipped: GCPhys=0x%llx pvBuf=0x%p cbRead=0x%zx", - (Genode::uint64_t)GCPhys, pvBuf, cbRead); + Genode::error("PGMPhysRead skipped: GCPhys=", Genode::Hex(GCPhys)); return VERR_GENERAL_FAILURE; } @@ -201,17 +185,13 @@ int PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, { *ppv = vmm_memory()->alloc((size_t)cb, pDevIns, iRegion); - if (verbose) - PLOG("PGMR3PhysMMIO2Register: pszDesc=%s iRegion=%u cb=0x%zx -> 0x%p", - pszDesc, iRegion, (size_t)cb, *ppv); - return VINF_SUCCESS; } int PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion) { - PERR("%s: pDevIns %p iRegion=%x", __func__, pDevIns, iRegion); + Genode::warning(__func__, ": pDevIns ", pDevIns, " iRegion=", iRegion); return VINF_SUCCESS; } @@ -221,15 +201,11 @@ int PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, { size_t cb = vmm_memory()->map_to_vm(pDevIns, GCPhys, iRegion); if (cb == 0) { - PERR("%s: lookup for pDevIns=%p iRegion=%u failed\n", __func__, - pDevIns, iRegion); + Genode::error(__func__, ": lookup for pDevIns=", pDevIns, " iRegion=", + iRegion, " failed"); Assert(cb); } - if (verbose) - PLOG("%s: pDevIns=%p iRegion=%u cb=0x%zx GCPhys=0x%llx\n", __func__, - pDevIns, iRegion, cb, (Genode::uint64_t)GCPhys); - #ifdef VBOX_WITH_REM REMR3NotifyPhysRamRegister(pVM, GCPhys, cb, REM_NOTIFY_PHYS_RAM_FLAGS_MMIO2); #endif @@ -241,10 +217,6 @@ int PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, int PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys) { - if (verbose_debug) - PDBG("called phys=%llx iRegion=0x%x", (Genode::uint64_t)GCPhys, - iRegion); - RTGCPHYS GCPhysStart = GCPhys; size_t size = 1; bool io = vmm_memory()->lookup_range(GCPhysStart, size); @@ -264,10 +236,7 @@ int PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, bool PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys) { - bool res = vmm_memory()->lookup(GCPhys, 1); - if (verbose_debug) - PDBG("called phys=%llx res=%u", (Genode::uint64_t)GCPhys, res); - return res; + return vmm_memory()->lookup(GCPhys, 1); } @@ -280,11 +249,6 @@ int PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, const char *pszHandlerRC, RTRCPTR pvUserRC, const char *pszDesc) { - if (verbose) - PLOG("%s: GCPhys=0x%llx-%llx r3=0x%p enmType=%x - '%s'\n", __func__, - (Genode::uint64_t)GCPhys, (Genode::uint64_t)GCPhysLast, - pfnHandlerR3, enmType, pszDesc); - bool ok = vmm_memory()->add_handler(GCPhys, GCPhysLast - GCPhys + 1, pfnHandlerR3, pvUserR3, enmType); Assert(ok); @@ -308,10 +272,6 @@ int PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys) void * pv = vmm_memory()->lookup(GCPhys, size, &pfnHandlerR3, 0, &enmType); Assert(pv); - - if (verbose_debug) - PDBG("called phys=%llx enmType=%x", (Genode::uint64_t)GCPhys, enmType); - #endif bool ok = vmm_memory()->add_handler(GCPhys, size, 0, 0); @@ -336,10 +296,6 @@ int PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys) int PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc) { - if (verbose) - PLOG("PGMR3PhysRegisterRam: GCPhys=0x%llx, cb=0x%llx, pszDesc=%s", - (Genode::uint64_t)GCPhys, (Genode::uint64_t)cb, pszDesc); - try { /* @@ -370,18 +326,12 @@ int PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, int PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags) { - if (verbose) - PLOG("%s: GCPtr=0x%llx cb=0x%llx, flags=0x%llx", __func__, - (Genode::uint64_t)GCPtr, (Genode::uint64_t)cb, - (Genode::uint64_t)fFlags); - return VINF_SUCCESS; } RTHCPHYS PGMGetHyperCR3(PVMCPU pVCpu) { -// PDBG("%s %lx", __func__, CPUMGetHyperCR3(pVCpu)); return 1; } @@ -408,20 +358,14 @@ int PGMR3Init(PVM pVM) } -int PGMR3Term(PVM pVM) -{ - if (verbose) - PDBG("called"); - - return VINF_SUCCESS; -} +int PGMR3Term(PVM pVM) { return VINF_SUCCESS; } int PGMPhysGCPtr2CCPtrReadOnly(PVMCPU pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock) { - PERR("%s not implemented - caller 0x%p", - __func__, __builtin_return_address(0)); + Genode::error(__func__, " not implemented - caller ", + __builtin_return_address(0)); Assert(!"not implemented"); return VERR_GENERAL_FAILURE; @@ -442,17 +386,13 @@ int PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv) pv = guest_memory()->lookup(GCPhys, size); if (!pv) { - PERR("%s: lookup for GCPhys=0x%llx failed", __func__, - (Genode::uint64_t)GCPhys); + Genode::error(__func__, ": lookup for GCPhys=", + Genode::Hex(GCPhys), " failed"); return VERR_PGM_PHYS_TLB_UNASSIGNED; } *ppv = pv; - if (verbose_debug) - PDBG("%s: %llx %u -> 0x%p", __func__, - (Genode::uint64_t)GCPhys, fWritable, pv); - return VINF_SUCCESS; } @@ -466,8 +406,8 @@ int PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv) *ppv = pv; return VINF_PGM_PHYS_TLB_CATCH_WRITE; } - PERR("%s: denied access - handlers set - GCPhys=0x%llx %p %p %x", __func__, - (Genode::uint64_t)GCPhys, pfnHandlerR3, pvUserR3, enmType); + Genode::error(__func__, ": denied access - handlers set - GCPhys=", + Genode::Hex(GCPhys)); return VERR_PGM_PHYS_TLB_CATCH_ALL; } @@ -499,13 +439,9 @@ static void PGMR3PhysWrite(PVM pVM, RTGCPHYS GCPhys, T value) void *pv = guest_memory()->lookup(GCPhys, sizeof(value)); - if (verbose_debug) - PDBG("%s: GCPhys=0x%llx cb=0x%zx pv=%p", __func__, - (Genode::uint64_t)GCPhys, sizeof(value), pv); - if (!pv) { - PERR("%s: invalid write attempt phy=%llx", __func__, - (Genode::uint64_t)GCPhys); + Genode::error(__func__, ": invalid write attempt GCPhys=", + Genode::Hex(GCPhys)); return; } @@ -540,13 +476,9 @@ static T PGMR3PhysRead(PVM pVM, RTGCPHYS GCPhys) { void *pv = guest_memory()->lookup(GCPhys, sizeof(T)); - if (verbose_debug) - PDBG("%s: GCPhys=0x%llx cb=0x%zx pv=%p", - __func__, (Genode::uint64_t)GCPhys, sizeof(T), pv); - if (!pv) { - PERR("%s: invalid read attempt phys=%llx", __func__, - (Genode::uint64_t)GCPhys); + Genode::error(__func__, ": invalid read attempt GCPhys=", + Genode::Hex(GCPhys)); return 0; } @@ -575,13 +507,8 @@ int PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, { void *pv = guest_memory()->lookup(GCPhys, 0x1000); - if (verbose_debug) - PDBG("%s: GCPhys=0x%llx cb=0x%d pv=%p", - __func__, (Genode::uint64_t)GCPhys, 0x1000, pv); - if (!pv) { - PERR("unknown address pv=%p ppv=%p GCPhys=%llx", pv, ppv, - (Genode::uint64_t)GCPhys); + Genode::error("unknown address GCPhys=", Genode::Hex(GCPhys)); guest_memory()->dump(); @@ -598,8 +525,8 @@ int PGMHandlerPhysicalReset(PVM, RTGCPHYS GCPhys) { size_t size = 1; if (!vmm_memory()->unmap_from_vm(GCPhys, size)) - PWRN("%s: unbacked region - GCPhys %llx", __func__, - (Genode::uint64_t)GCPhys); + Genode::warning(__func__, ": unbacked region - GCPhys ", + Genode::Hex(GCPhys)); return VINF_SUCCESS; } @@ -626,8 +553,6 @@ extern "C" int MMIO2_MAPPED_SYNC(PVM pVM, RTGCPHYS GCPhys, size_t cbWrite, if (!pfnHandlerR3 && !pvUserR3) { *ppv = pv; -// Vmm::printf("------------------ %s: GCPhys=0x%llx vmm local %p io mem map - no handlers\n", __func__, GCPhys, pv); -// return VERR_PGM_PHYS_TLB_UNASSIGNED; /* you may map it */ return VINF_SUCCESS; } @@ -641,9 +566,6 @@ extern "C" int MMIO2_MAPPED_SYNC(PVM pVM, RTGCPHYS GCPhys, size_t cbWrite, /* you may map it */ return VINF_SUCCESS; } - -// Vmm::printf("%s: GCPhys=0x%llx failed - unexpected rc=%d\n", -// __func__, (Genode::uint64_t)GCPhys, rc); return rc; } @@ -657,10 +579,6 @@ extern "C" int MMIO2_MAPPED_SYNC(PVM pVM, RTGCPHYS GCPhys, size_t cbWrite, Assert(pv); fli = Flexpage_iterator((addr_t)pv, map_size, map_start, map_size, map_start); -// if (verbose_debug) -// Vmm::printf("%s: GCPhys=0x%llx - %llx+%zx\n", __func__, -// (Genode::uint64_t)GCPhys, (Genode::uint64_t)map_start, -// map_size); *ppv = pv; @@ -732,21 +650,13 @@ void PGMR3Reset(PVM pVM) int PGMR3MappingsSize(PVM pVM, uint32_t *pcb) { - if (verbose) - PINF("%s - not implemented - %p", __func__, - __builtin_return_address(0)); - *pcb = 0; return 0; } -void PGMR3MemSetup(PVM pVM, bool fAtReset) -{ - if (verbose) - PDBG(" called"); -} +void PGMR3MemSetup(PVM pVM, bool fAtReset) { } VMMDECL(bool) PGMIsLockOwner(PVM pVM) @@ -755,9 +665,4 @@ VMMDECL(bool) PGMIsLockOwner(PVM pVM) } -VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe) -{ - if (verbose) - PINF("%s - not implemented - %p", __func__, - __builtin_return_address(0)); -} +VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe) { } diff --git a/repos/ports/src/virtualbox/rt.cc b/repos/ports/src/virtualbox/rt.cc index ab52b09fa..b62e3985b 100644 --- a/repos/ports/src/virtualbox/rt.cc +++ b/repos/ports/src/virtualbox/rt.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include #include @@ -66,9 +66,9 @@ class Avl_ds : public Genode::Avl_node _mem_allocated -= _size; Genode::env()->ram_session()->free(_ds); - PWRN("free up %lu %lu/%lu hit=%lu/%lu avail=%zu", - _size, _mem_allocated, _mem_unused, hit, hit_coarse, - Genode::env()->ram_session()->avail()); + Genode::log("free up ", _size, " ", _mem_allocated, "/", + _mem_unused, " hit=", hit, "/", hit_coarse, " avail=", + Genode::env()->ram_session()->avail()); } void unused() @@ -165,9 +165,10 @@ class Avl_ds : public Genode::Avl_node if (ds_obj && ds_obj->_used_size == cb) ds_obj->unused(); else { - PERR("%s unknown memory region %p(%lx)+%zx(%lx)", - __func__, pv, ds_obj ? ds_obj->ds_virt() : 0, - cb, ds_obj ? ds_obj->_size : 0); + Genode::error(__func__, " unknown memory region ", pv, "(", + Genode::Hex(ds_obj ? ds_obj->ds_virt() : 0), + ")+", Genode::Hex(cb), "(", + Genode::Hex(ds_obj ? ds_obj->_size : 0), ")"); } } }; @@ -228,7 +229,7 @@ static void *alloc_mem(size_t cb, const char *pszTag, bool executable = false) return local_addr; } catch (...) { - PERR("Could not allocate RTMem* memory of size=%zx", cb); + Genode::error("Could not allocate RTMem* memory of size=", cb); return nullptr; } } diff --git a/repos/ports/src/virtualbox/spec/muen/mem_region.h b/repos/ports/src/virtualbox/spec/muen/mem_region.h index 341300581..500bb051f 100644 --- a/repos/ports/src/virtualbox/spec/muen/mem_region.h +++ b/repos/ports/src/virtualbox/spec/muen/mem_region.h @@ -84,11 +84,11 @@ struct Mem_region : Genode::List::Element, struct Genode::Sinfo::Memregion_info region1, region4; if (!sinfo.get_memregion_info("vm_ram_1", ®ion1)) { - PERR("Unable to retrieve vm_ram_1 region"); + Genode::error("unable to retrieve vm_ram_1 region"); return 0; } if (!sinfo.get_memregion_info("vm_ram_4", ®ion4)) { - PERR("Unable to retrieve vm_ram_4 region"); + Genode::error("unable to retrieve vm_ram_4 region"); return 0; } @@ -102,7 +102,7 @@ struct Mem_region : Genode::List::Element, if (cur_region.size == 0) { - PERR("Region size is zero!!!"); + Genode::error("region size is zero!!!"); return 0; } counter++; @@ -110,7 +110,8 @@ struct Mem_region : Genode::List::Element, } if (size > cur_region.size) - PERR("Size: 0x%zx, cur_region.size: 0x%zx", size, cur_region.size); + Genode::error("size: ", Genode::Hex(size), ", " + "cur_region.size: ", Genode::Hex(cur_region.size)); Assert(size <= cur_region.size); return cur_region.base; diff --git a/repos/ports/src/virtualbox/spec/muen/sup.cc b/repos/ports/src/virtualbox/spec/muen/sup.cc index 378939ec8..d47d0a62d 100644 --- a/repos/ports/src/virtualbox/spec/muen/sup.cc +++ b/repos/ports/src/virtualbox/spec/muen/sup.cc @@ -14,7 +14,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -97,7 +97,7 @@ static Genode::Sinfo * sinfo() (addr_t)env()->rm_session()->attach(sinfo_rom.dataspace())); ptr = &sinfo; } catch (...) { - PERR("Unable to attach Sinfo ROM"); + error("unable to attach Sinfo ROM"); Assert(false); } } @@ -118,7 +118,7 @@ bool setup_subject_state() struct Sinfo::Memregion_info region; if (!sinfo()->get_memregion_info("monitor_state", ®ion)) { - PERR("Unable to retrieve monitor state region"); + error("unable to retrieve monitor state region"); return false; } @@ -128,7 +128,7 @@ bool setup_subject_state() cur_state = subject_ds.local_addr(); return true; } catch (...) { - PERR("Unable to attach subject state I/O mem dataspace"); + error("unable to attach subject state I/O mem dataspace"); } return false; } @@ -147,7 +147,7 @@ bool setup_subject_interrupts() struct Sinfo::Memregion_info region; if (!sinfo()->get_memregion_info("monitor_interrupts", ®ion)) { - PERR("Unable to retrieve monitor interrupts region"); + error("unable to retrieve monitor interrupts region"); return false; } @@ -158,7 +158,7 @@ bool setup_subject_interrupts() guest_interrupts = &g; return true; } catch (...) { - PERR("Unable to attach subject interrupts I/O mem dataspace"); + error("unable to attach subject interrupts I/O mem dataspace"); } return false; } @@ -196,7 +196,7 @@ inline uint64_t get_reg_val (struct Subject_state *cur_state, unsigned reg) return cur_state->Regs.Rdi; break; default: - PERR("Invalid register %u", reg); + Genode::error("invalid register ", reg); return 0; } } @@ -229,7 +229,7 @@ inline bool set_cr(struct Subject_state *cur_state, unsigned cr, uint64_t value) res = true; break; default: - PERR("Invalid control register %u", cr); + Genode::error("invalid control register ", cr); res = false; } @@ -254,7 +254,7 @@ inline bool handle_cr(struct Subject_state *cur_state) res = set_cr(cur_state, cr, get_reg_val(cur_state, reg)); break; default: - PERR("Invalid control register %u access %u, reg %u", cr, acc, reg); + Genode::error("Invalid control register ", cr, " access ", acc, ", reg ", reg); return false; } @@ -632,7 +632,7 @@ int SUPR3CallVMMR0Fast(PVMR0 pVMR0, unsigned uOperation, VMCPUID idCpu) return rc; } - PERR("SUPR3CallVMMR0Fast: unhandled uOperation %d", uOperation); + Genode::error("SUPR3CallVMMR0Fast: unhandled uOperation ", (int)uOperation); return VERR_INTERNAL_ERROR; } @@ -695,7 +695,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned return VINF_SUCCESS; default: - PERR("SUPR3CallVMMR0Ex: unhandled uOperation %d", uOperation); + Genode::error("SUPR3CallVMMR0Ex: unhandled uOperation ", (int)uOperation); return VERR_GENERAL_FAILURE; } } @@ -741,7 +741,7 @@ uint64_t genode_cpu_hz() if (!cpu_freq) { cpu_freq = sinfo()->get_tsc_khz() * 1000; if (!cpu_freq) - PERR("Unable to determine CPU frequency"); + Genode::error("unable to determine CPU frequency"); } return cpu_freq; } @@ -756,7 +756,7 @@ HRESULT genode_setup_machine(ComObjPtr machine) return rc; if (cCpus != 1) { - PWRN("Configured CPUs %u not supported, reducing to 1.", cCpus); + Genode::warning("configured CPUs ", cCpus, " not supported, reducing to 1."); rc = machine->COMSETTER(CPUCount)(1); if (FAILED(rc)) return rc; @@ -781,4 +781,4 @@ bool Vmm_memory::revoke_from_vm(Mem_region *r) } -extern "C" void pthread_yield() { PWRN("%s unimplemented", __func__); } +extern "C" void pthread_yield() { Genode::warning(__func__, " unimplemented"); } diff --git a/repos/ports/src/virtualbox/spec/muen/vcpu.h b/repos/ports/src/virtualbox/spec/muen/vcpu.h index b717c4175..5e9c69244 100644 --- a/repos/ports/src/virtualbox/spec/muen/vcpu.h +++ b/repos/ports/src/virtualbox/spec/muen/vcpu.h @@ -77,46 +77,4 @@ struct Subject_state Segment idtr; } __attribute__((packed)); - -/** - * Print subject state information - */ -inline void dump_register_state(Subject_state * state) -{ - PINF("subject state"); - PLOG("ip:sp:efl ax:bx:cx:dx:si:di %lx:%lx:%lx %lx:%lx:%lx:%lx:%lx:%lx", - state->Rip, state->Rsp, state->Rflags, - state->Regs.Rax, state->Regs.Rbx, state->Regs.Rcx, state->Regs.Rdx, - state->Regs.Rsi, state->Regs.Rdi); - - PLOG("cs base:limit:sel:ar %lx:%x:%x:%x", state->cs.base, - state->cs.limit, state->cs.sel, state->cs.access); - PLOG("ds base:limit:sel:ar %lx:%x:%x:%x", state->ds.base, - state->ds.limit, state->ds.sel, state->ds.access); - PLOG("es base:limit:sel:ar %lx:%x:%x:%x", state->es.base, - state->es.limit, state->es.sel, state->es.access); - PLOG("fs base:limit:sel:ar %lx:%x:%x:%x", state->fs.base, - state->fs.limit, state->fs.sel, state->fs.access); - PLOG("gs base:limit:sel:ar %lx:%x:%x:%x", state->gs.base, - state->gs.limit, state->gs.sel, state->gs.access); - PLOG("ss base:limit:sel:ar %lx:%x:%x:%x", state->ss.base, - state->ss.limit, state->ss.sel, state->ss.access); - - PLOG("cr0:cr2:cr3:cr4 %lx:%lx:%lx:%lx", - state->Cr0, state->Regs.Cr2, state->Cr3, state->Cr4); - - PLOG("ldtr base:limit:sel:ar %lx:%x:%x:%x", state->ldtr.base, - state->ldtr.limit, state->ldtr.sel, state->ldtr.access); - PLOG("tr base:limit:sel:ar %lx:%x:%x:%x", state->tr.base, - state->tr.limit, state->tr.sel, state->tr.access); - - PLOG("gdtr base:limit %lx:%x", state->gdtr.base, state->gdtr.limit); - PLOG("idtr base:limit %lx:%x", state->idtr.base, state->idtr.limit); - - PLOG("sysenter cs:eip:esp %lx %lx %lx", state->Sysenter_cs, - state->Sysenter_eip, state->Sysenter_esp); - - PLOG("%x", state->Intr_state); -} - #endif /* _VIRTUALBOX__SPEC__MUEN__VCPU_H_ */ diff --git a/repos/ports/src/virtualbox/spec/nova/sup.cc b/repos/ports/src/virtualbox/spec/nova/sup.cc index ad633a24f..b7dee220a 100644 --- a/repos/ports/src/virtualbox/spec/nova/sup.cc +++ b/repos/ports/src/virtualbox/spec/nova/sup.cc @@ -13,7 +13,7 @@ */ /* Genode includes */ -#include +#include #include #include #include @@ -75,13 +75,14 @@ void SUPR3QueryHWACCLonGenodeSupport(VM * pVM) pVM->hm.s.vmx.fSupported = hip->has_feature_vmx(); if (hip->has_feature_svm() || hip->has_feature_vmx()) { - PINF("Using %s virtualization extension.", - hip->has_feature_svm() ? "SVM" : "VMX"); + Genode::log("Using ", + hip->has_feature_svm() ? "SVM" : "VMX", " " + "virtualization extension."); return; } } catch (...) { /* if we get an exception let hardware support off */ } - PWRN("No virtualization hardware acceleration available"); + Genode::warning("No virtualization hardware acceleration available"); } @@ -156,7 +157,7 @@ int SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned } default: - PERR("SUPR3CallVMMR0Ex: unhandled uOperation %d", uOperation); + Genode::error("SUPR3CallVMMR0Ex: unhandled uOperation ", uOperation); return VERR_GENERAL_FAILURE; } } @@ -180,7 +181,7 @@ uint64_t genode_cpu_hz() cpu_freq = hip->tsc_freq * 1000; } catch (...) { - PERR("could not read out CPU frequency."); + Genode::error("could not read out CPU frequency"); Genode::Lock lock; lock.lock(); } @@ -255,12 +256,6 @@ bool Vmm_memory::revoke_from_vm(Mem_region *r) extern "C" void pthread_yield(void) { -/* - char _name[64]; - Genode::Thread::myself()->name(_name, sizeof(_name)); - PERR("pthread_yield %p - '%s'", __builtin_return_address(0), _name); - Assert(!"pthread_yield called"); -*/ Nova::ec_ctrl(Nova::EC_YIELD); } diff --git a/repos/ports/src/virtualbox/spec/nova/vcpu.h b/repos/ports/src/virtualbox/spec/nova/vcpu.h index fc269ca50..aae237788 100644 --- a/repos/ports/src/virtualbox/spec/nova/vcpu.h +++ b/repos/ports/src/virtualbox/spec/nova/vcpu.h @@ -16,7 +16,7 @@ #define _VIRTUALBOX__SPEC__NOVA__VCPU_H_ /* Genode includes */ -#include +#include #include #include #include @@ -174,13 +174,14 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, Assert(utcb->flags & X86_EFL_IF); if (utcb->intr_state != INTERRUPT_STATE_NONE) - Vmm::printf("intr state %x %x\n", utcb->intr_state, utcb->intr_state & 0xF); + Vmm::log("intr state ", Genode::Hex(utcb->intr_state), + " ", Genode::Hex(utcb->intr_state & 0xf)); Assert(utcb->intr_state == INTERRUPT_STATE_NONE); /* if (!continue_hw_accelerated(utcb)) - Vmm::printf("WARNING - recall ignored during IRQ delivery\n"); + Vmm::log("WARNING - recall ignored during IRQ delivery"); */ /* got recall during irq injection and the guest is ready for * delivery of IRQ - just continue */ @@ -227,7 +228,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, Assert(utcb->actv_state == ACTIVITY_STATE_ACTIVE); if (unmap) { - PERR("unmap not implemented\n"); + Vmm::log("error: unmap not implemented"); Nova::reply(_stack_reply); } @@ -296,9 +297,9 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, res = utcb->append_item(crd, flexpage.hotspot, USER_PD, GUEST_PGT); if (debug_map_memory) - Vmm::printf("map guest mem %p+%x -> %lx - reason %lx\n", - flexpage.addr, 1UL << flexpage.log2_order, - flexpage.hotspot, reason); + Vmm::log("map guest mem ", Genode::Hex(flexpage.addr), + "+", 1UL << flexpage.log2_order, " -> ", + Genode::Hex(flexpage.hotspot), " reason=", reason); } while (res); Nova::reply(_stack_reply); @@ -312,7 +313,8 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, void _register_handler(Genode::addr_t exc_base, Nova::Mtd mtd) { if (!register_handler(exc_base, mtd)) - PERR("could not register handler %lx", exc_base + EV); + Genode::error("could not register handler ", + Genode::Hex(exc_base + EV)); } @@ -616,8 +618,11 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, _last_inj_error = utcb->inj_error; /* - Vmm::printf("type:info:vector %x:%x:%x intr:actv - %x:%x mtd %x\n", - Event.n.u3Type, utcb->inj_info, u8Vector, utcb->intr_state, utcb->actv_state, utcb->mtd); + Vmm::log("type:info:vector ", Genode::Hex(Event.n.u3Type), + Genode::Hex(utcb->inj_info), Genode::Hex(u8Vector), + " intr:actv - ", Genode::Hex(utcb->intr_state), + Genode::Hex(utcb->actv_state), " mtd ", + Genode::Hex(utcb->mtd)); */ utcb->mtd = Nova::Mtd::INJ | Nova::Mtd::FPU; Nova::reply(_stack_reply); @@ -645,13 +650,13 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, #define VERBOSE_VM(flag) \ do { \ if (VM_FF_IS_PENDING(_current_vm, flag)) \ - Vmm::printf("flag " #flag " pending\n"); \ + Vmm::log("flag ", flag, " pending"); \ } while (0) #define VERBOSE_VMCPU(flag) \ do { \ if (VMCPU_FF_IS_PENDING(_current_vcpu, flag)) \ - Vmm::printf("flag " #flag " pending\n"); \ + Vmm::log("flag ", flag, " pending"); \ } while (0) if (verbose) { @@ -732,7 +737,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, using namespace Nova; if (ec_ctrl(EC_RECALL, _ec_sel) != NOVA_OK) { - PERR("recall failed"); + Genode::error("recall failed"); Genode::Lock lock(Genode::Lock::LOCKED); lock.lock(); } @@ -748,88 +753,6 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, _halt_sem.up(); } - inline void dump_register_state(PCPUMCTX pCtx) - { - PINF("pCtx"); - PLOG("ip:sp:efl ax:bx:cx:dx:si:di %llx:%llx:%llx" - " %llx:%llx:%llx:%llx:%llx:%llx", - pCtx->rip, pCtx->rsp, pCtx->rflags.u, pCtx->rax, pCtx->rbx, - pCtx->rcx, pCtx->rdx, pCtx->rsi, pCtx->rdi); - - PLOG("cs.attr.n.u4LimitHigh=0x%x", pCtx->cs.Attr.n.u4LimitHigh); - - PLOG("cs base:limit:sel:ar %llx:%x:%x:%x", pCtx->cs.u64Base, - pCtx->cs.u32Limit, pCtx->cs.Sel, pCtx->cs.Attr.u); - PLOG("ds base:limit:sel:ar %llx:%x:%x:%x", pCtx->ds.u64Base, - pCtx->ds.u32Limit, pCtx->ds.Sel, pCtx->ds.Attr.u); - PLOG("es base:limit:sel:ar %llx:%x:%x:%x", pCtx->es.u64Base, - pCtx->es.u32Limit, pCtx->es.Sel, pCtx->es.Attr.u); - PLOG("fs base:limit:sel:ar %llx:%x:%x:%x", pCtx->fs.u64Base, - pCtx->fs.u32Limit, pCtx->fs.Sel, pCtx->fs.Attr.u); - PLOG("gs base:limit:sel:ar %llx:%x:%x:%x", pCtx->gs.u64Base, - pCtx->gs.u32Limit, pCtx->gs.Sel, pCtx->gs.Attr.u); - PLOG("ss base:limit:sel:ar %llx:%x:%x:%x", pCtx->ss.u64Base, - pCtx->ss.u32Limit, pCtx->ss.Sel, pCtx->ss.Attr.u); - - PLOG("cr0:cr2:cr3:cr4 %llx:%llx:%llx:%llx", - pCtx->cr0, pCtx->cr2, pCtx->cr3, pCtx->cr4); - - PLOG("ldtr base:limit:sel:ar %llx:%x:%x:%x", pCtx->ldtr.u64Base, - pCtx->ldtr.u32Limit, pCtx->ldtr.Sel, pCtx->ldtr.Attr.u); - PLOG("tr base:limit:sel:ar %llx:%x:%x:%x", pCtx->tr.u64Base, - pCtx->tr.u32Limit, pCtx->tr.Sel, pCtx->tr.Attr.u); - - PLOG("gdtr base:limit %llx:%x", pCtx->gdtr.pGdt, pCtx->gdtr.cbGdt); - PLOG("idtr base:limit %llx:%x", pCtx->idtr.pIdt, pCtx->idtr.cbIdt); - - PLOG("dr 0:1:2:3:4:5:6:7 %llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx", - pCtx->dr[0], pCtx->dr[1], pCtx->dr[2], pCtx->dr[3], - pCtx->dr[4], pCtx->dr[5], pCtx->dr[6], pCtx->dr[7]); - - PLOG("sysenter cs:eip:esp %llx %llx %llx", pCtx->SysEnter.cs, - pCtx->SysEnter.eip, pCtx->SysEnter.esp); - } - - inline void dump_register_state(Nova::Utcb * utcb) - { - PINF("utcb"); - PLOG("ip:sp:efl ax:bx:cx:dx:si:di %lx:%lx:%lx" - " %lx:%lx:%lx:%lx:%lx:%lx", - utcb->ip, utcb->sp, utcb->flags, utcb->ax, utcb->bx, - utcb->cx, utcb->dx, utcb->si, utcb->di); - - PLOG("cs base:limit:sel:ar %lx:%x:%x:%x", utcb->cs.base, - utcb->cs.limit, utcb->cs.sel, utcb->cs.ar); - PLOG("ds base:limit:sel:ar %lx:%x:%x:%x", utcb->ds.base, - utcb->ds.limit, utcb->ds.sel, utcb->ds.ar); - PLOG("es base:limit:sel:ar %lx:%x:%x:%x", utcb->es.base, - utcb->es.limit, utcb->es.sel, utcb->es.ar); - PLOG("fs base:limit:sel:ar %lx:%x:%x:%x", utcb->fs.base, - utcb->fs.limit, utcb->fs.sel, utcb->fs.ar); - PLOG("gs base:limit:sel:ar %lx:%x:%x:%x", utcb->gs.base, - utcb->gs.limit, utcb->gs.sel, utcb->gs.ar); - PLOG("ss base:limit:sel:ar %lx:%x:%x:%x", utcb->ss.base, - utcb->ss.limit, utcb->ss.sel, utcb->ss.ar); - - PLOG("cr0:cr2:cr3:cr4 %lx:%lx:%lx:%lx", - utcb->cr0, utcb->cr2, utcb->cr3, utcb->cr4); - - PLOG("ldtr base:limit:sel:ar %lx:%x:%x:%x", utcb->ldtr.base, - utcb->ldtr.limit, utcb->ldtr.sel, utcb->ldtr.ar); - PLOG("tr base:limit:sel:ar %lx:%x:%x:%x", utcb->tr.base, - utcb->tr.limit, utcb->tr.sel, utcb->tr.ar); - - PLOG("gdtr base:limit %lx:%x", utcb->gdtr.base, utcb->gdtr.limit); - PLOG("idtr base:limit %lx:%x", utcb->idtr.base, utcb->idtr.limit); - - PLOG("dr 7 %lx", utcb->dr7); - - PLOG("sysenter cs:eip:esp %lx %lx %lx", utcb->sysenter_cs, - utcb->sysenter_ip, utcb->sysenter_sp); - - PLOG("%x %x %x", utcb->intr_state, utcb->actv_state, utcb->mtd); - } - int run_hw(PVMR0 pVMR0) { VM * pVM = reinterpret_cast(pVMR0); @@ -854,7 +777,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, if (!vbox_to_utcb(utcb, pVM, pVCpu) || !hw_load_state(utcb, pVM, pVCpu)) { - PERR("loading vCPU state failed"); + Genode::error("loading vCPU state failed"); return VERR_INTERNAL_ERROR; } @@ -902,7 +825,7 @@ class Vcpu_handler : public Vmm::Vcpu_dispatcher, if (!utcb_to_vbox(utcb, pVM, pVCpu) || !hw_save_state(utcb, pVM, pVCpu)) { - PERR("saving vCPU state failed"); + Genode::error("saving vCPU state failed"); return VERR_INTERNAL_ERROR; } diff --git a/repos/ports/src/virtualbox/spec/nova/vcpu_svm.h b/repos/ports/src/virtualbox/spec/nova/vcpu_svm.h index f0883b923..7b8caefc2 100644 --- a/repos/ports/src/virtualbox/spec/nova/vcpu_svm.h +++ b/repos/ports/src/virtualbox/spec/nova/vcpu_svm.h @@ -37,7 +37,7 @@ class Vcpu_handler_svm : public Vcpu_handler if (utcb->qual[0] & 0x4) { unsigned ctrl0 = utcb->ctrl[0]; - Vmm::printf("invalid gueststate\n"); + Vmm::warning("invalid gueststate"); utcb->ctrl[0] = ctrl0; utcb->ctrl[1] = 0; diff --git a/repos/ports/src/virtualbox/spec/nova/vcpu_vmx.h b/repos/ports/src/virtualbox/spec/nova/vcpu_vmx.h index ea899f362..c62d2dded 100644 --- a/repos/ports/src/virtualbox/spec/nova/vcpu_vmx.h +++ b/repos/ports/src/virtualbox/spec/nova/vcpu_vmx.h @@ -91,7 +91,7 @@ class Vcpu_handler_vmx : public Vcpu_handler __attribute__((noreturn)) void _vmx_triple() { - Vmm::printf("triple fault - dead\n"); + Vmm::error("triple fault - dead"); exit(-1); } @@ -110,12 +110,13 @@ class Vcpu_handler_vmx : public Vcpu_handler unsigned const dubious = utcb->inj_info | utcb->intr_state | utcb->actv_state; if (dubious) - Vmm::printf("%s - dubious - inj_info=0x%x inj_error=%x" - " intr_state=0x%x actv_state=0x%x\n", __func__, - utcb->inj_info, utcb->inj_error, - utcb->intr_state, utcb->actv_state); + Vmm::warning(__func__, " - dubious -" + " inj_info=", Genode::Hex(utcb->inj_info), + " inj_error=", Genode::Hex(utcb->inj_error), + " intr_state=", Genode::Hex(utcb->intr_state), + " actv_state=", Genode::Hex(utcb->actv_state)); - Vmm::printf("invalid guest state - dead\n"); + Vmm::error("invalid guest state - dead"); exit(-1); } diff --git a/repos/ports/src/virtualbox/sup.cc b/repos/ports/src/virtualbox/sup.cc index 827cb8b02..5882c10e8 100644 --- a/repos/ports/src/virtualbox/sup.cc +++ b/repos/ports/src/virtualbox/sup.cc @@ -204,7 +204,7 @@ int SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent) if (hEvent) reinterpret_cast(hEvent)->up(); else - PERR("%s called - not implemented", __FUNCTION__); + Genode::error(__FUNCTION__, " called - not implemented"); return VINF_SUCCESS; } @@ -216,7 +216,8 @@ int SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, if (hEvent && cMillies == RT_INDEFINITE_WAIT) reinterpret_cast(hEvent)->down(); else { - PERR("%s called millis=%u - not implemented", __FUNCTION__, cMillies); + Genode::error(__FUNCTION__, " called millis=", cMillies, + " - not implemented"); reinterpret_cast(hEvent)->down(); } @@ -255,15 +256,15 @@ int SUPR3CallVMMR0(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, void *pvArg) { if (uOperation == VMMR0_DO_CALL_HYPERVISOR) { - PDBG("VMMR0_DO_CALL_HYPERVISOR - doing nothing"); + Genode::log(__func__, ": VMMR0_DO_CALL_HYPERVISOR - doing nothing"); return VINF_SUCCESS; } if (uOperation == VMMR0_DO_VMMR0_TERM) { - PDBG("VMMR0_DO_VMMR0_TERM - doing nothing"); + Genode::log(__func__, ": VMMR0_DO_VMMR0_TERM - doing nothing"); return VINF_SUCCESS; } if (uOperation == VMMR0_DO_GVMM_DESTROY_VM) { - PDBG("VMMR0_DO_GVMM_DESTROY_VM - doing nothing"); + Genode::log(__func__, ": VMMR0_DO_GVMM_DESTROY_VM - doing nothing"); return VINF_SUCCESS; } @@ -345,13 +346,14 @@ HRESULT genode_check_memory_config(ComObjPtr machine) size_t memory_vmm = 28; if (memory_vbox + memory_vmm > memory_genode) { - PERR("Configured memory %u MB (vbox file) is insufficient.", - memory_vbox); - PERR("%zu MB (1) - %zu MB (2) = %zu MB (3)", - memory_genode, memory_vmm, memory_genode - memory_vmm); - PERR("(1) available memory based defined by Genode config"); - PERR("(2) minimum memory required for VBox VMM"); - PERR("(3) maximal available memory to VM"); + using Genode::error; + error("Configured memory ", memory_vmm, " MB (vbox file) is insufficient."); + error(memory_genode, " MB (1) - ", + memory_vmm, " MB (2) = ", + memory_genode - memory_vmm, " MB (3)"); + error("(1) available memory based defined by Genode config"); + error("(2) minimum memory required for VBox VMM"); + error("(3) maximal available memory to VM"); return E_FAIL; } return S_OK; diff --git a/repos/ports/src/virtualbox/target.mk b/repos/ports/src/virtualbox/target.mk index fd9d2ffe8..11548679a 100644 --- a/repos/ports/src/virtualbox/target.mk +++ b/repos/ports/src/virtualbox/target.mk @@ -3,6 +3,12 @@ VBOX_CC_OPT += -DVBOX_WITH_GENERIC_SESSION_WATCHER include $(REP_DIR)/lib/mk/virtualbox-common.inc +# +# Prevent inclusion of the Genode::Log definition after the vbox #define +# of 'Log'. Otherwise, the attemt to compile base/log.h will fail. +# +VBOX_CC_OPT += -include base/log.h + CC_WARN += -Wall TARGET = virtualbox diff --git a/repos/ports/src/virtualbox/thread.cc b/repos/ports/src/virtualbox/thread.cc index 499b5015e..efa1c26b0 100644 --- a/repos/ports/src/virtualbox/thread.cc +++ b/repos/ports/src/virtualbox/thread.cc @@ -12,7 +12,7 @@ */ /* Genode */ -#include +#include #include #include #include @@ -76,9 +76,10 @@ static int create_thread(pthread_t *thread, const pthread_attr_t *attr, if (rtthread->cbStack < stack_size) stack_size = rtthread->cbStack; else - PWRN("requested stack for thread '%s' of %zu Bytes is too large, " - "limit to %zu Bytes", rtthread->szName, rtthread->cbStack, - stack_size); + Genode::warning("requested stack for " + "thread '", Genode::Cstring(rtthread->szName), "' " + "of ", rtthread->cbStack, " Bytes is too large, " + "limit to ", stack_size, " Bytes"); /* sanity check - emt and vcpu thread have to have same prio class */ if (strstr(rtthread->szName, "EMT") == rtthread->szName) @@ -133,14 +134,14 @@ extern "C" int pthread_create(pthread_t *thread, const pthread_attr_t *attr, try { return create_thread(thread, attr, start_routine, arg); } catch (Cpu_session::Out_of_metadata) { - PWRN("Upgrading memory for creation of thread '%s'", - rtthread->szName); + log("Upgrading memory for creation of " + "thread '", Cstring(rtthread->szName), "'"); env()->parent()->upgrade(cpu_connection(rtthread->enmType)->cap(), "ram_quota=4096"); } catch (...) { break; } } - PERR("Could not create vbox pthread - halt"); + Genode::error("could not create vbox pthread - halt"); Genode::Lock lock(Genode::Lock::LOCKED); lock.lock(); return EAGAIN; diff --git a/repos/ports/src/virtualbox/unimpl.cc b/repos/ports/src/virtualbox/unimpl.cc index 37147a277..741323781 100644 --- a/repos/ports/src/virtualbox/unimpl.cc +++ b/repos/ports/src/virtualbox/unimpl.cc @@ -11,7 +11,7 @@ * version 2. */ -#include +#include #include @@ -19,8 +19,8 @@ extern "C" { #define DUMMY(name) \ void name(void) { \ - PDBG( #name " called, not implemented, eip=%p", \ - __builtin_return_address(0)); \ + Genode::warning(__func__, ": " #name " called, not implemented, eip=", \ + __builtin_return_address(0)); \ while (1) { Assert(!"not implemented"); } \ } diff --git a/repos/ports/src/virtualbox/vmm_memory.h b/repos/ports/src/virtualbox/vmm_memory.h index a6619e11a..ecbe6d0f8 100644 --- a/repos/ports/src/virtualbox/vmm_memory.h +++ b/repos/ports/src/virtualbox/vmm_memory.h @@ -93,10 +93,12 @@ class Vmm_memory return r->local_addr(); } catch (Ram_session::Alloc_failed) { - PERR("Vmm_memory::alloc(0x%zx): RAM allocation failed", cb); + Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): " + "RAM allocation failed"); throw; } catch (Region_map::Attach_failed) { - PERR("Vmm_memory::alloc(0x%zx): RM attach failed", cb); + Genode::error("Vmm_memory::alloc(", Genode::Hex(cb), "): " + "RM attach failed"); throw; }