Linux Kernel Markers - Samples
[pv_ops_mirror.git] / arch / sparc64 / prom / console.c
blob3fafa9a8b50bb3d541ebbc0a9814379b292dcbd2
1 /* $Id: console.c,v 1.9 1997/10/29 07:41:43 ecd 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) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 */
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <asm/openprom.h>
13 #include <asm/oplib.h>
14 #include <asm/system.h>
15 #include <linux/string.h>
17 extern int prom_stdin, prom_stdout;
19 /* Non blocking get character from console input device, returns -1
20 * if no input was taken. This can be used for polling.
22 __inline__ int
23 prom_nbgetchar(void)
25 char inc;
27 if (p1275_cmd("read", P1275_ARG(1,P1275_ARG_OUT_BUF)|
28 P1275_INOUT(3,1),
29 prom_stdin, &inc, P1275_SIZE(1)) == 1)
30 return inc;
31 else
32 return -1;
35 /* Non blocking put character to console device, returns -1 if
36 * unsuccessful.
38 __inline__ int
39 prom_nbputchar(char c)
41 char outc;
43 outc = c;
44 if (p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
45 P1275_INOUT(3,1),
46 prom_stdout, &outc, P1275_SIZE(1)) == 1)
47 return 0;
48 else
49 return -1;
52 /* Blocking version of get character routine above. */
53 char
54 prom_getchar(void)
56 int character;
57 while((character = prom_nbgetchar()) == -1) ;
58 return (char) character;
61 /* Blocking version of put character routine above. */
62 void
63 prom_putchar(char c)
65 prom_nbputchar(c);
66 return;
69 void
70 prom_puts(const char *s, int len)
72 p1275_cmd("write", P1275_ARG(1,P1275_ARG_IN_BUF)|
73 P1275_INOUT(3,1),
74 prom_stdout, s, P1275_SIZE(len));