Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* console.c: Routines that deal with sending and receiving IO
0003  *            to/from the current console device using the PROM.
0004  *
0005  * Copyright (C) 1995 David S. Miller (davem@davemloft.net)
0006  * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
0007  */
0008 
0009 #include <linux/types.h>
0010 #include <linux/kernel.h>
0011 #include <linux/sched.h>
0012 #include <asm/openprom.h>
0013 #include <asm/oplib.h>
0014 #include <linux/string.h>
0015 
0016 static int __prom_console_write_buf(const char *buf, int len)
0017 {
0018     unsigned long args[7];
0019     int ret;
0020 
0021     args[0] = (unsigned long) "write";
0022     args[1] = 3;
0023     args[2] = 1;
0024     args[3] = (unsigned int) prom_stdout;
0025     args[4] = (unsigned long) buf;
0026     args[5] = (unsigned int) len;
0027     args[6] = (unsigned long) -1;
0028 
0029     p1275_cmd_direct(args);
0030 
0031     ret = (int) args[6];
0032     if (ret < 0)
0033         return -1;
0034     return ret;
0035 }
0036 
0037 void prom_console_write_buf(const char *buf, int len)
0038 {
0039     while (len) {
0040         int n = __prom_console_write_buf(buf, len);
0041         if (n < 0)
0042             continue;
0043         len -= n;
0044         buf += len;
0045     }
0046 }