1 /* console.c: Routines that deal with sending and receiving IO
2 * to/from the current console device using the PROM.
4 * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
5 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/sched.h>
11 #include <asm/openprom.h>
12 #include <asm/oplib.h>
13 #include <asm/system.h>
14 #include <linux/string.h>
16 extern int prom_stdin
, prom_stdout
;
18 /* Non blocking get character from console input device, returns -1
19 * if no input was taken. This can be used for polling.
24 unsigned long args
[7];
27 args
[0] = (unsigned long) "read";
30 args
[3] = (unsigned int) prom_stdin
;
31 args
[4] = (unsigned long) &inc
;
33 args
[6] = (unsigned long) -1;
35 p1275_cmd_direct(args
);
42 /* Non blocking put character to console device, returns -1 if
46 prom_nbputchar(char c
)
48 unsigned long args
[7];
53 args
[0] = (unsigned long) "write";
56 args
[3] = (unsigned int) prom_stdout
;
57 args
[4] = (unsigned long) &outc
;
59 args
[6] = (unsigned long) -1;
61 p1275_cmd_direct(args
);
69 /* Blocking version of get character routine above. */
74 while((character
= prom_nbgetchar()) == -1) ;
75 return (char) character
;
78 /* Blocking version of put character routine above. */
87 prom_puts(const char *s
, int len
)
89 unsigned long args
[7];
91 args
[0] = (unsigned long) "write";
94 args
[3] = (unsigned int) prom_stdout
;
95 args
[4] = (unsigned long) s
;
97 args
[6] = (unsigned long) -1;
99 p1275_cmd_direct(args
);