xref: /titanic_44/usr/src/uts/intel/promif/prom_putchar.c (revision bde3d612a7c090234c60e6e4578821237a5db135)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
31 #include <sys/bootsvcs.h>
32 
33 /*ARGSUSED*/
34 int
35 prom_mayput(char c)
36 {
37 	prom_putchar(c);
38 	return (1);
39 }
40 
41 void
42 prom_putchar(char c)
43 {
44 	static int bhcharpos = 0;
45 	promif_owrap_t *ow;
46 
47 	ow = promif_preout();
48 	switch (c) {
49 	case '\t':
50 		do {
51 			BSVC_PUTCHAR(SYSP, ' ');
52 		} while (++bhcharpos % 8);
53 		break;
54 	case '\n':
55 	case '\r':
56 		bhcharpos = 0;
57 		BSVC_PUTCHAR(SYSP, c);
58 		break;
59 	case '\b':
60 		if (bhcharpos)
61 			bhcharpos--;
62 		BSVC_PUTCHAR(SYSP, c);
63 		break;
64 	default:
65 		bhcharpos++;
66 		BSVC_PUTCHAR(SYSP, c);
67 		break;
68 	}
69 	promif_postout(ow);
70 }
71 
72 void
73 prom_writestr(const char *s, size_t n)
74 {
75 	while (n-- != 0)
76 		prom_putchar(*s++);
77 }
78