1 /* console.c: Routines that deal with sending and receiving IO 2 * to/from the current console device using the PROM. 3 * 4 * Copyright (C) 1995 David S. Miller (davem@davemloft.net) 5 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 6 */ 7 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> 15 16 extern int prom_stdin, prom_stdout; 17 18 /* Non blocking put character to console device, returns -1 if 19 * unsuccessful. 20 */ 21 static int prom_nbputchar(const char *buf) 22 { 23 unsigned long args[7]; 24 25 args[0] = (unsigned long) "write"; 26 args[1] = 3; 27 args[2] = 1; 28 args[3] = (unsigned int) prom_stdout; 29 args[4] = (unsigned long) buf; 30 args[5] = 1; 31 args[6] = (unsigned long) -1; 32 33 p1275_cmd_direct(args); 34 35 if (args[6] == 1) 36 return 0; 37 else 38 return -1; 39 } 40 41 /* Blocking version of put character routine above. */ 42 void prom_putchar(const char *buf) 43 { 44 while (1) { 45 int err = prom_nbputchar(buf); 46 if (!err) 47 break; 48 } 49 } 50