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