David S. Miller | d979f17 | 2007-10-27 00:13:04 -0700 | [diff] [blame] | 1 | /* console.c: Routines that deal with sending and receiving IO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * to/from the current console device using the PROM. |
| 3 | * |
David S. Miller | d979f17 | 2007-10-27 00:13:04 -0700 | [diff] [blame] | 4 | * Copyright (C) 1995 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/string.h> |
| 14 | |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 15 | static int __prom_console_write_buf(const char *buf, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | { |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 17 | unsigned long args[7]; |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 18 | int ret; |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 19 | |
| 20 | args[0] = (unsigned long) "write"; |
| 21 | args[1] = 3; |
| 22 | args[2] = 1; |
| 23 | args[3] = (unsigned int) prom_stdout; |
David S. Miller | e62cac1 | 2010-11-30 14:33:29 -0800 | [diff] [blame] | 24 | args[4] = (unsigned long) buf; |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 25 | args[5] = (unsigned int) len; |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 26 | args[6] = (unsigned long) -1; |
| 27 | |
| 28 | p1275_cmd_direct(args); |
| 29 | |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 30 | ret = (int) args[6]; |
| 31 | if (ret < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | return -1; |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 33 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
| 35 | |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 36 | void prom_console_write_buf(const char *buf, int len) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { |
David S. Miller | 595a251 | 2010-11-30 20:15:58 -0800 | [diff] [blame] | 38 | while (len) { |
| 39 | int n = __prom_console_write_buf(buf, len); |
| 40 | if (n < 0) |
| 41 | continue; |
| 42 | len -= n; |
| 43 | buf += len; |
David S. Miller | e62cac1 | 2010-11-30 14:33:29 -0800 | [diff] [blame] | 44 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |