Root/
Source at commit 214 created 13 years 5 months ago. By ifabio, update to chameleon trunk 630, and now the pakage folder is the same as blackosx branch, also add Icon "building" into buildpkg script, and add mint theme info into the English localizable.strings. | |
---|---|
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 | ␊ |
50 | extern int␉vprf(const char * fmt, va_list ap);␊ |
51 | ␊ |
52 | bool gVerboseMode;␊ |
53 | bool gErrors;␊ |
54 | ␊ |
55 | /* Kabyl: BooterLog */␊ |
56 | //Azi: Doubled log available size.␊ |
57 | // 64kb are not enough to hold the full log while booting with -f argument (ignore caches).␊ |
58 | // It also seems to fix some reported problems while booting with the mentioned argument.␊ |
59 | // Note: 96kb are enough to hold full log, booting with -f; even so, this depends on how much␊ |
60 | // we "play" at the boot prompt, with what patches we're playing and how much they print to the log,␊ |
61 | // kexts loaded, etc...␊ |
62 | // Please remove this comment when this gets checked by a "true" dev.␊ |
63 | #define BOOTER_LOG_SIZE␉(128 * 1024)␊ |
64 | #define SAFE_LOG_SIZE␉134␊ |
65 | ␊ |
66 | char *msgbuf = 0;␊ |
67 | char *cursor = 0;␊ |
68 | ␊ |
69 | struct putc_info {␊ |
70 | char * str;␊ |
71 | char * last_str;␊ |
72 | };␊ |
73 | ␊ |
74 | static void sputc(int c, struct putc_info * pi)␊ |
75 | {␊ |
76 | ␉if (pi->last_str)␊ |
77 | ␉if (pi->str == pi->last_str)␊ |
78 | ␉{␊ |
79 | ␉␉*(pi->str) = '\0';␊ |
80 | ␉␉return;␊ |
81 | ␉}␊ |
82 | ␉*(pi->str)++ = 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 | ␉Node *node = DT__FindNode("/", false);␊ |
117 | ␉if (node)␊ |
118 | ␉␉DT__AddProperty(node, "boot-log", strlen((char *)msgbuf) + 1, msgbuf);␊ |
119 | }␊ |
120 | /* Kabyl: !BooterLog */␊ |
121 | ␊ |
122 | ␊ |
123 | /*␊ |
124 | * write one character to console␊ |
125 | */␊ |
126 | void putchar(int c)␊ |
127 | {␊ |
128 | ␉if ( c == '\t' )␊ |
129 | ␉{␊ |
130 | ␉␉for (c = 0; c < 8; c++) putc(' ');␊ |
131 | ␉␉return;␊ |
132 | ␉}␊ |
133 | ␊ |
134 | ␉if ( c == '\n' )␊ |
135 | {␊ |
136 | ␉␉putc('\r');␊ |
137 | }␊ |
138 | ␊ |
139 | ␉putc(c);␊ |
140 | }␊ |
141 | ␊ |
142 | int getc()␊ |
143 | {␊ |
144 | int c = bgetc();␊ |
145 | ␊ |
146 | if ((c & 0xff) == 0)␊ |
147 | return c;␊ |
148 | else␊ |
149 | return (c & 0xff);␊ |
150 | }␊ |
151 | ␊ |
152 | // Read and echo a character from console. This doesn't echo backspace␊ |
153 | // since that screws up higher level handling␊ |
154 | ␊ |
155 | int getchar()␊ |
156 | {␊ |
157 | ␉register int c = getc();␊ |
158 | ␊ |
159 | ␉if ( c == '\r' ) c = '\n';␊ |
160 | ␊ |
161 | ␉if ( c >= ' ' && c < 0x7f) putchar(c);␊ |
162 | ␉␊ |
163 | ␉return (c);␊ |
164 | }␊ |
165 | ␊ |
166 | int printf(const char * fmt, ...)␊ |
167 | {␊ |
168 | va_list ap;␊ |
169 | ␉va_start(ap, fmt);␊ |
170 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
171 | ␉␉prf(fmt, ap, putchar, 0);␊ |
172 | ␉else␊ |
173 | ␉␉vprf(fmt, ap);␊ |
174 | ␊ |
175 | ␉{␊ |
176 | ␉/* Kabyl: BooterLog */␊ |
177 | ␉␉struct putc_info pi;␊ |
178 | ␊ |
179 | ␉␉if (!msgbuf)␊ |
180 | ␉␉␉return 0;␊ |
181 | ␊ |
182 | ␉␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
183 | ␉␉␉return 0;␊ |
184 | ␉␉pi.str = cursor;␊ |
185 | ␉␉pi.last_str = 0;␊ |
186 | ␉␉prf(fmt, ap, sputc, &pi);␊ |
187 | ␉␉cursor += strlen((char *)cursor);␊ |
188 | ␉}␊ |
189 | ␊ |
190 | ␉va_end(ap);␊ |
191 | return 0;␊ |
192 | }␊ |
193 | ␊ |
194 | int verbose(const char * fmt, ...)␊ |
195 | {␊ |
196 | va_list ap;␊ |
197 | ␊ |
198 | ␉va_start(ap, fmt);␊ |
199 | if (gVerboseMode)␊ |
200 | {␊ |
201 | ␉␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
202 | ␉␉␉prf(fmt, ap, putchar, 0);␊ |
203 | ␉␉else␊ |
204 | ␉␉␉vprf(fmt, ap);␊ |
205 | }␊ |
206 | ␊ |
207 | ␉{␊ |
208 | ␉/* Kabyl: BooterLog */␊ |
209 | ␉␉struct putc_info pi;␊ |
210 | ␊ |
211 | ␉␉if (!msgbuf)␊ |
212 | ␉␉␉return 0;␊ |
213 | ␊ |
214 | ␉␉if (((cursor - msgbuf) > (BOOTER_LOG_SIZE - SAFE_LOG_SIZE)))␊ |
215 | ␉␉␉return 0;␊ |
216 | ␉␉pi.str = cursor;␊ |
217 | ␉␉pi.last_str = 0;␊ |
218 | ␉␉prf(fmt, ap, sputc, &pi);␊ |
219 | ␉␉cursor += strlen((char *)cursor);␊ |
220 | ␉}␊ |
221 | ␊ |
222 | va_end(ap);␊ |
223 | return(0);␊ |
224 | }␊ |
225 | ␊ |
226 | int error(const char * fmt, ...)␊ |
227 | {␊ |
228 | va_list ap;␊ |
229 | gErrors = true;␊ |
230 | va_start(ap, fmt);␊ |
231 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE)␊ |
232 | ␉␉prf(fmt, ap, putchar, 0);␊ |
233 | else␊ |
234 | ␉␉vprf(fmt, ap);␊ |
235 | ␉va_end(ap);␊ |
236 | return(0);␊ |
237 | }␊ |
238 | ␊ |
239 | void stop(const char * fmt, ...)␊ |
240 | {␊ |
241 | ␉va_list ap;␊ |
242 | ␊ |
243 | ␉printf("\n");␊ |
244 | ␉va_start(ap, fmt);␊ |
245 | ␉if (bootArgs->Video.v_display == VGA_TEXT_MODE) {␊ |
246 | ␉␉prf(fmt, ap, putchar, 0);␊ |
247 | ␉} else {␊ |
248 | ␉␉vprf(fmt, ap);␊ |
249 | ␉}␊ |
250 | ␉va_end(ap);␊ |
251 | ␉printf("\nThis is a non recoverable error! System HALTED!!!");␊ |
252 | ␉halt();␊ |
253 | ␉while (1);␊ |
254 | }␊ |
255 | ␊ |
256 | /** Print a "Press a key to continue..." message and wait for a key press. */␊ |
257 | void pause() ␊ |
258 | {␊ |
259 | printf("Press a key to continue...");␊ |
260 | getc();␊ |
261 | }␊ |
262 |