2 * (c) 2009 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(unsigned long /*base*/)
16 char path[64], type[16];
17 for(phandle_t node = 0; prom_next_node(&node); ) {
18 prom_getprop(node, "device_type", type, sizeof(type));
20 if(strcmp(type, "serial"))
23 if(prom_call("package-to-path", 3, 1, node, path, sizeof(path)) == Of::PROM_ERROR)
27 if((_serial = (ihandle_t)prom_call("open", 1, 1, path)) <= 0)
32 //prom_call("exit", 0, 0);
33 return (!_serial)?false:true;
36 void Uart_of::shutdown()
38 prom_call("close", 1, 0, _serial);
41 int Uart_of::get_char(bool blocking) const
45 while(len != 1 && blocking)
46 len = prom_call("read", 3, 1, _serial, &c, 1);
51 int Uart_of::write(char const *s, unsigned long count) const
53 return prom_call("write", 3, 1, _serial, s, count);
56 void Uart_of::out_char(char c) const
58 prom_call("write", 3, 0, _serial, c, 1);
62 bool Uart_of::enable_rx_irq(bool){return true;}
63 bool Uart_of::enable_tx_irq(bool){return true;}
64 bool Uart_of::change_mode(Transfer_mode, Baud_rate){return true;}
65 int Uart_of::char_avail() const {return 1;}