xref: /illumos-gate/usr/src/uts/intel/promif/prom_putchar.c (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 #include <sys/promif.h>
28 #include <sys/promimpl.h>
29 #include <sys/bootsvcs.h>
30 
31 /*ARGSUSED*/
32 int
33 prom_mayput(char c)
34 {
35 	prom_putchar(c);
36 	return (1);
37 }
38 
39 void
40 prom_putchar(char c)
41 {
42 	static int bhcharpos = 0;
43 	promif_owrap_t *ow;
44 
45 	ow = promif_preout();
46 	switch (c) {
47 	case '\t':
48 		do {
49 			BSVC_PUTCHAR(SYSP, ' ');
50 		} while (++bhcharpos % 8);
51 		break;
52 	case '\n':
53 	case '\r':
54 		bhcharpos = 0;
55 		BSVC_PUTCHAR(SYSP, c);
56 		break;
57 	case '\b':
58 		if (bhcharpos)
59 			bhcharpos--;
60 		BSVC_PUTCHAR(SYSP, c);
61 		break;
62 	default:
63 		bhcharpos++;
64 		BSVC_PUTCHAR(SYSP, c);
65 		break;
66 	}
67 	promif_postout(ow);
68 }
69 
70 void
71 prom_writestr(const char *s, size_t n)
72 {
73 	while (n-- != 0)
74 		prom_putchar(*s++);
75 }
76