Root/
Source at commit 1263 created 12 years 8 months ago. By meklort, Update i386 makefiles | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
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␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
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.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
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.␊ |
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"␊ |
48 | ␊ |
49 | bool gVerboseMode;␊ |
50 | bool gErrors;␊ |
51 | ␊ |
52 | /*␊ |
53 | * Azi: Doubled available log size; this seems to fix some hangs and instant reboots caused by␊ |
54 | * booting with -f (ignore caches). 96kb are enough to hold full log, booting with -f; even so,␊ |
55 | * this depends on how much we "play" at the boot prompt and with what patches we're playing,␊ |
56 | * depending on how much they print to the log.␊ |
57 | *␉␊ |
58 | * Kabyl: BooterLog␊ |
59 | */␊ |
60 | #define BOOTER_LOG_SIZE␉(128 * 1024)␊ |
61 | #define SAFE_LOG_SIZE␉134␊ |
62 | ␊ |
63 | char *msgbuf = 0;␊ |
64 | char *cursor = 0;␊ |
65 | ␊ |
66 | struct putc_info //Azi: exists on gui.c & printf.c␊ |
67 | {␊ |
68 | char * str;␊ |
69 | char * last_str;␊ |
70 | };␊ |
71 | ␊ |
72 | static int␊ |
73 | sputc(int c, struct putc_info * pi) //Azi: same as above␊ |
74 | {␊ |
75 | ␉if (pi->last_str)␊ |
76 | ␉if (pi->str == pi->last_str)␊ |
77 | ␉{␊ |
78 | ␉␉*(pi->str) = '\0';␊ |
79 | ␉␉return 0;␊ |
80 | ␉}␊ |
81 | ␉*(pi->str)++ = c;␊ |
82 | return c;␊ |
83 | }␊ |
84 | ␊ |
85 | void initBooterLog(void)␊ |
86 | {␊ |
87 | ␉msgbuf = malloc(BOOTER_LOG_SIZE);␊ |
88 | ␉bzero(msgbuf, BOOTER_LOG_SIZE);␊ |
89 | ␉cursor = msgbuf;␊ |
90 | }␊ |
91 | ␊ |
92 | void msglog(const char * fmt, ...)␊ |
93 | {␊ |
94 | ␉va_list ap;␊ |
95 | ␉struct putc_info pi;␊ |
96 | ␊ |
97 | ␉if (!msgbuf)␊ |
98 | ␉␉return;␊ |
99 | ␊ |
100 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
101 | ␉␉return;␊ |
102 | ␊ |
103 | ␉va_start(ap, fmt);␊ |
104 | ␉pi.str = cursor;␊ |
105 | ␉pi.last_str = 0;␊ |
106 | ␉prf(fmt, ap, sputc, &pi);␊ |
107 | ␉va_end(ap);␊ |
108 | ␉cursor += strlen((char *)cursor);␊ |
109 | }␊ |
110 | ␊ |
111 | void setupBooterLog(void)␊ |
112 | {␊ |
113 | ␉if (!msgbuf)␊ |
114 | ␉␉return;␊ |
115 | }␊ |
116 | /* Kabyl: !BooterLog */␊ |
117 | ␊ |
118 | /*␊ |
119 | * write one character to console␊ |
120 | */␊ |
121 | int putchar(int c)␊ |
122 | {␊ |
123 | ␉if ( c == '\t' )␊ |
124 | ␉{␊ |
125 | ␉␉for (c = 0; c < 8; c++) bios_putchar(' ');␊ |
126 | ␉␉return c;␊ |
127 | ␉}␊ |
128 | ␊ |
129 | ␉if ( c == '\n' )␊ |
130 | {␊ |
131 | ␉␉bios_putchar('\r');␊ |
132 | }␊ |
133 | ␊ |
134 | ␉bios_putchar(c);␊ |
135 | ␊ |
136 | return c;␊ |
137 | }␊ |
138 | ␊ |
139 | int getc()␊ |
140 | {␊ |
141 | int c = bgetc();␊ |
142 | ␊ |
143 | if ((c & 0xff) == 0)␊ |
144 | return c;␊ |
145 | else␊ |
146 | return (c & 0xff);␊ |
147 | }␊ |
148 | ␊ |
149 | // Read and echo a character from console. This doesn't echo backspace␊ |
150 | // since that screws up higher level handling␊ |
151 | ␊ |
152 | int getchar()␊ |
153 | {␊ |
154 | ␉register int c = getc();␊ |
155 | ␊ |
156 | //␉if ( c == '\r' ) c = '\n';␊ |
157 | ␊ |
158 | //␉if ( c >= ' ' && c < 0x7f) putchar(c);␊ |
159 | ␉␊ |
160 | ␉return (c);␊ |
161 | }␊ |
162 | ␊ |
163 | int verbose(const char * fmt, ...)␊ |
164 | {␊ |
165 | va_list ap;␊ |
166 | ␊ |
167 | ␉va_start(ap, fmt);␊ |
168 | if (gVerboseMode)␊ |
169 | {␊ |
170 | prf(fmt, ap, putchar, 0);␊ |
171 | }␊ |
172 | ␊ |
173 | ␉{␊ |
174 | ␉␉// Kabyl: BooterLog␊ |
175 | ␉␉struct putc_info pi;␊ |
176 | ␊ |
177 | ␉␉if (!msgbuf)␊ |
178 | ␉␉␉return 0;␊ |
179 | ␊ |
180 | ␉␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
181 | ␉␉␉return 0;␊ |
182 | ␉␉pi.str = cursor;␊ |
183 | ␉␉pi.last_str = 0;␊ |
184 | ␉␉prf(fmt, ap, sputc, &pi);␊ |
185 | ␉␉cursor += strlen((char *)cursor);␊ |
186 | ␉}␊ |
187 | ␊ |
188 | va_end(ap);␊ |
189 | return(0);␊ |
190 | }␊ |
191 | ␊ |
192 | int error(const char * fmt, ...)␊ |
193 | {␊ |
194 | va_list ap;␊ |
195 | gErrors = true;␊ |
196 | va_start(ap, fmt);␊ |
197 | prf(fmt, ap, putchar, 0);␊ |
198 | ␉va_end(ap);␊ |
199 | return(0);␊ |
200 | }␊ |
201 | ␊ |
202 | void stop(const char * fmt, ...)␊ |
203 | {␊ |
204 | ␉va_list ap;␊ |
205 | ␊ |
206 | ␉printf("\n");␊ |
207 | ␉va_start(ap, fmt);␊ |
208 | prf(fmt, ap, putchar, 0);␊ |
209 | ␉va_end(ap);␊ |
210 | ␉printf("\nThis is a non recoverable error! System HALTED!!!");␊ |
211 | ␉halt();␊ |
212 | ␉while (1);␊ |
213 | }␊ |
214 | ␊ |
215 | /** Print a "Press a key to continue..." message and wait for a key press. */␊ |
216 | void pause() ␊ |
217 | {␊ |
218 | printf("Press a key to continue...\n");␊ |
219 | ␉getchar(); // replace getchar() by pause() ?? were useful...?␊ |
220 | }␊ |
221 |