1 /* $Id: console.c,v 1.25 2001/10/30 04:54:22 davem Exp $
2 * console.c: Routines that deal with sending and receiving IO
3 * to/from the current console device using the PROM.
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 * Copyright (C) 1998 Pete Zaitcev <zaitcev@yahoo.com>
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <asm/openprom.h>
13 #include <asm/sun4prom.h>
14 #include <asm/oplib.h>
15 #include <asm/system.h>
16 #include <linux/string.h>
18 extern void restore_current(void);
20 /* Non blocking get character from console input device, returns -1
21 * if no input was taken. This can be used for polling.
30 spin_lock_irqsave(&prom_lock, flags);
34 i = (*(romvec->pv_nbgetchar))();
38 if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) {
49 spin_unlock_irqrestore(&prom_lock, flags);
50 return i; /* Ugh, we could spin forever on unsupported proms ;( */
53 /* Non blocking put character to console device, returns -1 if
57 prom_nbputchar(char c)
63 spin_lock_irqsave(&prom_lock, flags);
67 i = (*(romvec->pv_nbputchar))(c);
72 if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1)
82 spin_unlock_irqrestore(&prom_lock, flags);
83 return i; /* Ugh, we could spin forever on unsupported proms ;( */
86 /* Blocking version of get character routine above. */
91 while((character = prom_nbgetchar()) == -1) ;
92 return (char) character;
95 /* Blocking version of put character routine above. */
99 while(prom_nbputchar(c) == -1) ;