]> git.saurik.com Git - apple/boot.git/blame - i386/libsaio/console.c
boot-132.tar.gz
[apple/boot.git] / i386 / libsaio / console.c
CommitLineData
14c7c974 1/*
57c72a9a 2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
14c7c974
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
57c72a9a 6 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
4f6e3300
A
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
57c72a9a 9 * Source License Version 2.0 (the "License"). You may not use this file
4f6e3300
A
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
14c7c974
A
13 *
14 * The Original Code and all software distributed under the License are
4f6e3300 15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14c7c974
A
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
4f6e3300
A
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
14c7c974
A
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24/*
25 * Mach Operating System
26 * Copyright (c) 1990 Carnegie-Mellon University
27 * Copyright (c) 1989 Carnegie-Mellon University
28 * All rights reserved. The CMU software License Agreement specifies
29 * the terms and conditions for use and redistribution.
30 */
31
32/*
33 * INTEL CORPORATION PROPRIETARY INFORMATION
34 *
35 * This software is supplied under the terms of a license agreement or
36 * nondisclosure agreement with Intel Corporation and may not be copied
37 * nor disclosed except in accordance with the terms of that agreement.
38 *
39 * Copyright 1988, 1989 Intel Corporation
40 */
41
42/*
43 * Copyright 1993 NeXT, Inc.
44 * All rights reserved.
45 */
46
47#include "libsaio.h"
57c72a9a 48#include "bootstruct.h"
14c7c974 49
47b0a8bd 50BOOL gVerboseMode;
75b89a82 51BOOL gErrors;
14c7c974
A
52
53/*
54 * write one character to console
55 */
56void putchar(int c)
57{
58 if ( c == '\t' )
59 {
60 for (c = 0; c < 8; c++) putc(' ');
61 return;
62 }
63
64 if ( c == '\n' )
65 {
66 putc('\r');
67 }
68
69 putc(c);
70}
71
72int getc()
73{
74 int c = bgetc();
75
76 if ((c & 0xff) == 0)
77 return c;
78 else
79 return (c & 0xff);
80}
81
82// Read and echo a character from console. This doesn't echo backspace
83// since that screws up higher level handling
84
85int getchar()
86{
87 register int c = getc();
88
89 if ( c == '\r' ) c = '\n';
90
91 if ( c >= ' ' && c < 0x7f) putchar(c);
92
93 return (c);
94}
95
96int printf(const char * fmt, ...)
97{
98 va_list ap;
bba600dd 99 if (bootArgs->Video.v_display != VGA_TEXT_MODE) return -1;
14c7c974
A
100 va_start(ap, fmt);
101 prf(fmt, ap, putchar, 0);
102 va_end(ap);
103 return 0;
104}
105
106int verbose(const char * fmt, ...)
107{
108 va_list ap;
109
47b0a8bd 110 if (gVerboseMode)
14c7c974
A
111 {
112 va_start(ap, fmt);
113 prf(fmt, ap, putchar, 0);
114 va_end(ap);
115 }
116 return(0);
117}
118
119int error(const char * fmt, ...)
120{
121 va_list ap;
75b89a82 122 gErrors = YES;
14c7c974
A
123 va_start(ap, fmt);
124 prf(fmt, ap, putchar, 0);
125 va_end(ap);
126 return(0);
127}
f083c6c3 128
bba600dd 129void stop(const char * fmt, ...)
f083c6c3 130{
bba600dd
A
131 va_list ap;
132
133 printf("\n");
134 va_start(ap, fmt);
135 prf(fmt, ap, putchar, 0);
136 va_end(ap);
137 printf("\n");
f083c6c3
A
138 halt();
139}