2 * (c) 2009-2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
14 bool Uart_of::startup(Io_register_block const *)
16 char path[64], type[16];
17 for (phandle_t node = 0; prom_next_node(&node); )
19 prom_getprop(node, "device_type", type, sizeof(type));
21 if (strcmp(type, "serial"))
24 if (prom_call("package-to-path", 3, 1, node,
25 path, sizeof(path)) == Of::PROM_ERROR)
29 if ((_serial = (ihandle_t)prom_call("open", 1, 1, path)) != 0)
34 //prom_call("exit", 0, 0);
38 void Uart_of::shutdown()
40 prom_call("close", 1, 0, _serial);
43 int Uart_of::get_char(bool blocking) const
47 while (len != 1 && blocking)
48 len = prom_call("read", 3, 1, _serial, &c, 1);
53 int Uart_of::write(char const *s, unsigned long count) const
55 return prom_call("write", 3, 1, _serial, s, count);
58 void Uart_of::out_char(char c) const
60 prom_call("write", 3, 0, _serial, c, 1);
64 bool Uart_of::change_mode(Transfer_mode, Baud_rate){ return true; }
65 int Uart_of::char_avail() const { return 1; }