base: avoid use of deprecated base/printf.h

Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.

While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).

To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.

Issue #1987
This commit is contained in:
Norman Feske
2016-07-13 19:07:09 +02:00
committed by Christian Helmuth
parent a5d3aa8373
commit 17c79a9e23
699 changed files with 5156 additions and 5865 deletions

View File

@ -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 <base/heap.h>
#include <os/attached_ram_dataspace.h>
#include <os/ring_buffer.h>
#include <os/server.h>
@ -18,7 +19,6 @@
#include <terminal_session/terminal_session.h>
#include <usb/usb.h>
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");
}
/**