Root/
Source at commit 1900 created 12 years 4 months ago. By ifabio, Update GFX IDs list. | |
---|---|
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 | #include "bootstruct.h"␊ |
49 | #include <vers.h>␊ |
50 | ␊ |
51 | extern int␉vprf(const char * fmt, va_list ap);␊ |
52 | ␊ |
53 | bool gVerboseMode;␊ |
54 | bool gErrors;␊ |
55 | ␊ |
56 | /*␊ |
57 | * Azi: Doubled available log size; this seems to fix some hangs and instant reboots caused by␊ |
58 | * booting with -f (ignore caches). 96kb are enough to hold full log, booting with -f; even so,␊ |
59 | * this depends on how much we "play" at the boot prompt and with what patches we're playing,␊ |
60 | * depending on how much they print to the log.␊ |
61 | *␉␊ |
62 | * Kabyl: BooterLog␊ |
63 | */␊ |
64 | #define BOOTER_LOG_SIZE␉(128 * 1024)␊ |
65 | #define SAFE_LOG_SIZE␉134␊ |
66 | ␊ |
67 | char *msgbuf = 0;␊ |
68 | char *cursor = 0;␊ |
69 | ␊ |
70 | struct putc_info //Azi: exists on gui.c & printf.c␊ |
71 | {␊ |
72 | char * str;␊ |
73 | char * last_str;␊ |
74 | };␊ |
75 | ␊ |
76 | static int␊ |
77 | sputc(int c, struct putc_info * pi) //Azi: same as above␊ |
78 | {␊ |
79 | ␉if (pi->last_str)␊ |
80 | ␉if (pi->str == pi->last_str)␊ |
81 | ␉{␊ |
82 | ␉␉*(pi->str) = '\0';␊ |
83 | ␉␉return 0;␊ |
84 | ␉}␊ |
85 | ␉*(pi->str)++ = c;␊ |
86 | return c;␊ |
87 | }␊ |
88 | ␊ |
89 | void initBooterLog(void)␊ |
90 | {␊ |
91 | ␉msgbuf = malloc(BOOTER_LOG_SIZE);␊ |
92 | ␉bzero(msgbuf, BOOTER_LOG_SIZE);␊ |
93 | ␉cursor = msgbuf;␊ |
94 | ␉msglog("%s\n", "Chameleon " I386BOOT_CHAMELEONVERSION " (svn-r" I386BOOT_CHAMELEONREVISION ")" " [" I386BOOT_BUILDDATE "]");␊ |
95 | }␊ |
96 | ␊ |
97 | void msglog(const char * fmt, ...)␊ |
98 | {␊ |
99 | ␉va_list ap;␊ |
100 | ␉struct putc_info pi;␊ |
101 | ␊ |
102 | ␉if (!msgbuf)␊ |
103 | ␉␉return;␊ |
104 | ␊ |
105 | ␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
106 | ␉␉return;␊ |
107 | ␊ |
108 | ␉va_start(ap, fmt);␊ |
109 | ␉pi.str = cursor;␊ |
110 | ␉pi.last_str = 0;␊ |
111 | ␉prf(fmt, ap, sputc, &pi);␊ |
112 | ␉va_end(ap);␊ |
113 | ␉cursor += strlen((char *)cursor);␊ |
114 | }␊ |
115 | ␊ |
116 | void setupBooterLog(void)␊ |
117 | {␊ |
118 | ␉if (!msgbuf)␊ |
119 | ␉␉return;␊ |
120 | ␊ |
121 | ␉Node *node = DT__FindNode("/", false);␊ |
122 | ␉if (node)␊ |
123 | ␉␉DT__AddProperty(node, "boot-log", strlen((char *)msgbuf) + 1, msgbuf);␊ |
124 | }␊ |
125 | /* Kabyl: !BooterLog */␊ |
126 | ␊ |
127 | /*␊ |
128 | * write one character to console␊ |
129 | */␊ |
130 | int putchar(int c)␊ |
131 | {␊ |
132 | ␉if ( c == '\t' )␊ |
133 | ␉{␊ |
134 | ␉␉for (c = 0; c < 8; c++) bios_putchar(' ');␊ |
135 | ␉␉return c;␊ |
136 | ␉}␊ |
137 | ␊ |
138 | ␉if ( c == '\n' )␊ |
139 | {␊ |
140 | ␉␉bios_putchar('\r');␊ |
141 | }␊ |
142 | ␊ |
143 | ␉bios_putchar(c);␊ |
144 | ␊ |
145 | return c;␊ |
146 | }␊ |
147 | ␊ |
148 | int getc()␊ |
149 | {␊ |
150 | int c = bgetc();␊ |
151 | ␊ |
152 | if ((c & 0xff) == 0)␊ |
153 | return c;␊ |
154 | else␊ |
155 | return (c & 0xff);␊ |
156 | }␊ |
157 | ␊ |
158 | // Read and echo a character from console. This doesn't echo backspace␊ |
159 | // since that screws up higher level handling␊ |
160 | ␊ |
161 | int getchar()␊ |
162 | {␊ |
163 | ␉register int c = getc();␊ |
164 | ␊ |
165 | //␉if ( c == '\r' ) c = '\n';␊ |
166 | ␊ |
167 | //␉if ( c >= ' ' && c < 0x7f) putchar(c);␊ |
168 | ␉␊ |
169 | ␉return (c);␊ |
170 | }␊ |
171 | ␊ |
172 | int printf(const char * fmt, ...)␊ |
173 | {␊ |
174 | va_list ap;␊ |
175 | ␉va_start(ap, fmt);␊ |
176 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
177 | ␉␉prf(fmt, ap, putchar, 0);␊ |
178 | ␉else␊ |
179 | ␉␉vprf(fmt, ap);␊ |
180 | ␊ |
181 | ␉{␊ |
182 | ␉␉// Kabyl: BooterLog␊ |
183 | ␉␉struct putc_info pi;␊ |
184 | ␊ |
185 | ␉␉if (!msgbuf)␊ |
186 | ␉␉␉return 0;␊ |
187 | ␊ |
188 | ␉␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
189 | ␉␉␉return 0;␊ |
190 | ␉␉pi.str = cursor;␊ |
191 | ␉␉pi.last_str = 0;␊ |
192 | ␉␉prf(fmt, ap, sputc, &pi);␊ |
193 | ␉␉cursor += strlen((char *)cursor);␊ |
194 | ␉}␊ |
195 | ␊ |
196 | ␉va_end(ap);␊ |
197 | return 0;␊ |
198 | }␊ |
199 | ␊ |
200 | int verbose(const char * fmt, ...)␊ |
201 | {␊ |
202 | va_list ap;␊ |
203 | ␊ |
204 | ␉va_start(ap, fmt);␊ |
205 | if (gVerboseMode)␊ |
206 | {␊ |
207 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
208 | ␉␉␉prf(fmt, ap, putchar, 0);␊ |
209 | ␉␉else␊ |
210 | ␉␉␉vprf(fmt, ap);␊ |
211 | }␊ |
212 | ␊ |
213 | ␉{␊ |
214 | ␉␉// Kabyl: BooterLog␊ |
215 | ␉␉struct putc_info pi;␊ |
216 | ␊ |
217 | ␉␉if (!msgbuf)␊ |
218 | ␉␉␉return 0;␊ |
219 | ␊ |
220 | ␉␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
221 | ␉␉␉return 0;␊ |
222 | ␉␉pi.str = cursor;␊ |
223 | ␉␉pi.last_str = 0;␊ |
224 | ␉␉prf(fmt, ap, sputc, &pi);␊ |
225 | ␉␉cursor += strlen((char *)cursor);␊ |
226 | ␉}␊ |
227 | ␊ |
228 | va_end(ap);␊ |
229 | return(0);␊ |
230 | }␊ |
231 | ␊ |
232 | int error(const char * fmt, ...)␊ |
233 | {␊ |
234 | va_list ap;␊ |
235 | gErrors = true;␊ |
236 | va_start(ap, fmt);␊ |
237 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
238 | ␉␉prf(fmt, ap, putchar, 0);␊ |
239 | else␊ |
240 | ␉␉vprf(fmt, ap);␊ |
241 | ␉va_end(ap);␊ |
242 | return(0);␊ |
243 | }␊ |
244 | ␊ |
245 | void stop(const char * fmt, ...)␊ |
246 | {␊ |
247 | ␉va_list ap;␊ |
248 | ␊ |
249 | ␉printf("\n");␊ |
250 | ␉va_start(ap, fmt);␊ |
251 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE) {␊ |
252 | ␉␉prf(fmt, ap, putchar, 0);␊ |
253 | ␉} else {␊ |
254 | ␉␉vprf(fmt, ap);␊ |
255 | ␉}␊ |
256 | ␉va_end(ap);␊ |
257 | ␉printf("\nThis is a non recoverable error! System HALTED!!!");␊ |
258 | ␉halt();␊ |
259 | ␉while (1);␊ |
260 | }␊ |
261 | ␊ |
262 | /** Print a "Press a key to continue..." message and wait for a key press. */␊ |
263 | void pause() ␊ |
264 | {␊ |
265 | printf("Press a key to continue...\n");␊ |
266 | ␉getchar(); // replace getchar() by pause() were useful.␊ |
267 | }␊ |
268 |