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.
21 static int prom_nbgetchar(void)
23 unsigned long args[7];
26 args[0] = (unsigned long) "read";
29 args[3] = (unsigned int) prom_stdin;
30 args[4] = (unsigned long) &inc;
32 args[6] = (unsigned long) -1;
34 p1275_cmd_direct(args);
41 /* Non blocking put character to console device, returns -1 if
44 static int prom_nbputchar(char c)
46 unsigned long args[7];
51 args[0] = (unsigned long) "write";
54 args[3] = (unsigned int) prom_stdout;
55 args[4] = (unsigned long) &outc;
57 args[6] = (unsigned long) -1;
59 p1275_cmd_direct(args);
67 /* Blocking version of get character routine above. */
72 while((character = prom_nbgetchar()) == -1) ;
73 return (char) character;
76 /* Blocking version of put character routine above. */