]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 A |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_FREE_COPYRIGHT@ | |
30 | */ | |
31 | ||
32 | #include <pexpert/pexpert.h> | |
2d21ac55 | 33 | #include <pexpert/protos.h> |
fe8ab488 | 34 | #include <pexpert/device_tree.h> |
1c79356b A |
35 | #include <kern/debug.h> |
36 | ||
37 | static int DEBUGFlag; | |
3e170ce0 | 38 | static uint32_t gPEKernelConfigurationBitmask; |
1c79356b | 39 | |
91447636 A |
40 | int32_t gPESerialBaud = -1; |
41 | ||
1c79356b A |
42 | void pe_init_debug(void) |
43 | { | |
3e170ce0 A |
44 | boolean_t boot_arg_value; |
45 | ||
46 | if (!PE_parse_boot_argn("debug", &DEBUGFlag, sizeof (DEBUGFlag))) | |
47 | DEBUGFlag = 0; | |
48 | ||
49 | gPEKernelConfigurationBitmask = 0; | |
50 | ||
51 | if (!PE_parse_boot_argn("assertions", &boot_arg_value, sizeof(boot_arg_value))) { | |
52 | #if MACH_ASSERT | |
53 | boot_arg_value = TRUE; | |
54 | #else | |
55 | boot_arg_value = FALSE; | |
56 | #endif | |
57 | } | |
58 | gPEKernelConfigurationBitmask |= (boot_arg_value ? kPEICanHasAssertions : 0); | |
59 | ||
60 | if (!PE_parse_boot_argn("statistics", &boot_arg_value, sizeof(boot_arg_value))) { | |
61 | #if DEVELOPMENT || DEBUG | |
62 | boot_arg_value = TRUE; | |
63 | #else | |
64 | boot_arg_value = FALSE; | |
65 | #endif | |
66 | } | |
67 | gPEKernelConfigurationBitmask |= (boot_arg_value ? kPEICanHasStatistics : 0); | |
68 | ||
69 | #if SECURE_KERNEL | |
70 | boot_arg_value = FALSE; | |
71 | #else | |
72 | if (!PE_i_can_has_debugger(NULL)) { | |
73 | boot_arg_value = FALSE; | |
74 | } else if (!PE_parse_boot_argn("diagnostic_api", &boot_arg_value, sizeof(boot_arg_value))) { | |
75 | boot_arg_value = TRUE; | |
76 | } | |
77 | #endif | |
78 | gPEKernelConfigurationBitmask |= (boot_arg_value ? kPEICanHasDiagnosticAPI : 0); | |
79 | ||
1c79356b A |
80 | } |
81 | ||
593a1d5f | 82 | void PE_enter_debugger(const char *cause) |
1c79356b A |
83 | { |
84 | if (DEBUGFlag & DB_NMI) | |
85 | Debugger(cause); | |
86 | } | |
87 | ||
3e170ce0 A |
88 | uint32_t |
89 | PE_i_can_has_kernel_configuration(void) | |
90 | { | |
91 | return gPEKernelConfigurationBitmask; | |
92 | } | |
93 | ||
1c79356b | 94 | /* extern references */ |
1c79356b A |
95 | extern void vcattach(void); |
96 | ||
97 | /* Globals */ | |
2d21ac55 | 98 | void (*PE_putc)(char c); |
1c79356b A |
99 | |
100 | void PE_init_printf(boolean_t vm_initialized) | |
101 | { | |
102 | if (!vm_initialized) { | |
103 | PE_putc = cnputc; | |
104 | } else { | |
105 | vcattach(); | |
106 | } | |
107 | } | |
0b4e3aa0 | 108 | |
fe8ab488 A |
109 | uint32_t |
110 | PE_get_random_seed(unsigned char *dst_random_seed, uint32_t request_size) | |
111 | { | |
112 | DTEntry entryP; | |
113 | uint32_t size = 0; | |
114 | void *dt_random_seed; | |
115 | ||
116 | if ((DTLookupEntry(NULL, "/chosen", &entryP) == kSuccess) | |
117 | && (DTGetProperty(entryP, "random-seed", | |
118 | (void **)&dt_random_seed, &size) == kSuccess)) { | |
119 | unsigned char *src_random_seed; | |
120 | unsigned int i; | |
121 | unsigned int null_count = 0; | |
122 | ||
123 | src_random_seed = (unsigned char *)dt_random_seed; | |
124 | ||
125 | if (size > request_size) size = request_size; | |
126 | ||
127 | /* | |
128 | * Copy from the device tree into the destination buffer, | |
129 | * count the number of null bytes and null out the device tree. | |
130 | */ | |
131 | for (i=0 ; i< size; i++, src_random_seed++, dst_random_seed++) { | |
132 | *dst_random_seed = *src_random_seed; | |
133 | null_count += *src_random_seed == (unsigned char)0; | |
134 | *src_random_seed = (unsigned char)0; | |
135 | } | |
136 | if (null_count == size) | |
137 | /* All nulls is no seed - return 0 */ | |
138 | size = 0; | |
139 | } | |
140 | ||
141 | return(size); | |
142 | } | |
143 | ||
0b4e3aa0 A |
144 | unsigned char appleClut8[ 256 * 3 ] = { |
145 | // 00 | |
146 | 0xFF,0xFF,0xFF, 0xFF,0xFF,0xCC, 0xFF,0xFF,0x99, 0xFF,0xFF,0x66, | |
147 | 0xFF,0xFF,0x33, 0xFF,0xFF,0x00, 0xFF,0xCC,0xFF, 0xFF,0xCC,0xCC, | |
148 | 0xFF,0xCC,0x99, 0xFF,0xCC,0x66, 0xFF,0xCC,0x33, 0xFF,0xCC,0x00, | |
149 | 0xFF,0x99,0xFF, 0xFF,0x99,0xCC, 0xFF,0x99,0x99, 0xFF,0x99,0x66, | |
150 | // 10 | |
151 | 0xFF,0x99,0x33, 0xFF,0x99,0x00, 0xFF,0x66,0xFF, 0xFF,0x66,0xCC, | |
152 | 0xFF,0x66,0x99, 0xFF,0x66,0x66, 0xFF,0x66,0x33, 0xFF,0x66,0x00, | |
153 | 0xFF,0x33,0xFF, 0xFF,0x33,0xCC, 0xFF,0x33,0x99, 0xFF,0x33,0x66, | |
154 | 0xFF,0x33,0x33, 0xFF,0x33,0x00, 0xFF,0x00,0xFF, 0xFF,0x00,0xCC, | |
155 | // 20 | |
156 | 0xFF,0x00,0x99, 0xFF,0x00,0x66, 0xFF,0x00,0x33, 0xFF,0x00,0x00, | |
157 | 0xCC,0xFF,0xFF, 0xCC,0xFF,0xCC, 0xCC,0xFF,0x99, 0xCC,0xFF,0x66, | |
158 | 0xCC,0xFF,0x33, 0xCC,0xFF,0x00, 0xCC,0xCC,0xFF, 0xCC,0xCC,0xCC, | |
159 | 0xCC,0xCC,0x99, 0xCC,0xCC,0x66, 0xCC,0xCC,0x33, 0xCC,0xCC,0x00, | |
160 | // 30 | |
161 | 0xCC,0x99,0xFF, 0xCC,0x99,0xCC, 0xCC,0x99,0x99, 0xCC,0x99,0x66, | |
162 | 0xCC,0x99,0x33, 0xCC,0x99,0x00, 0xCC,0x66,0xFF, 0xCC,0x66,0xCC, | |
163 | 0xCC,0x66,0x99, 0xCC,0x66,0x66, 0xCC,0x66,0x33, 0xCC,0x66,0x00, | |
164 | 0xCC,0x33,0xFF, 0xCC,0x33,0xCC, 0xCC,0x33,0x99, 0xCC,0x33,0x66, | |
165 | // 40 | |
166 | 0xCC,0x33,0x33, 0xCC,0x33,0x00, 0xCC,0x00,0xFF, 0xCC,0x00,0xCC, | |
167 | 0xCC,0x00,0x99, 0xCC,0x00,0x66, 0xCC,0x00,0x33, 0xCC,0x00,0x00, | |
168 | 0x99,0xFF,0xFF, 0x99,0xFF,0xCC, 0x99,0xFF,0x99, 0x99,0xFF,0x66, | |
169 | 0x99,0xFF,0x33, 0x99,0xFF,0x00, 0x99,0xCC,0xFF, 0x99,0xCC,0xCC, | |
170 | // 50 | |
171 | 0x99,0xCC,0x99, 0x99,0xCC,0x66, 0x99,0xCC,0x33, 0x99,0xCC,0x00, | |
172 | 0x99,0x99,0xFF, 0x99,0x99,0xCC, 0x99,0x99,0x99, 0x99,0x99,0x66, | |
173 | 0x99,0x99,0x33, 0x99,0x99,0x00, 0x99,0x66,0xFF, 0x99,0x66,0xCC, | |
174 | 0x99,0x66,0x99, 0x99,0x66,0x66, 0x99,0x66,0x33, 0x99,0x66,0x00, | |
175 | // 60 | |
176 | 0x99,0x33,0xFF, 0x99,0x33,0xCC, 0x99,0x33,0x99, 0x99,0x33,0x66, | |
177 | 0x99,0x33,0x33, 0x99,0x33,0x00, 0x99,0x00,0xFF, 0x99,0x00,0xCC, | |
178 | 0x99,0x00,0x99, 0x99,0x00,0x66, 0x99,0x00,0x33, 0x99,0x00,0x00, | |
179 | 0x66,0xFF,0xFF, 0x66,0xFF,0xCC, 0x66,0xFF,0x99, 0x66,0xFF,0x66, | |
180 | // 70 | |
181 | 0x66,0xFF,0x33, 0x66,0xFF,0x00, 0x66,0xCC,0xFF, 0x66,0xCC,0xCC, | |
182 | 0x66,0xCC,0x99, 0x66,0xCC,0x66, 0x66,0xCC,0x33, 0x66,0xCC,0x00, | |
183 | 0x66,0x99,0xFF, 0x66,0x99,0xCC, 0x66,0x99,0x99, 0x66,0x99,0x66, | |
184 | 0x66,0x99,0x33, 0x66,0x99,0x00, 0x66,0x66,0xFF, 0x66,0x66,0xCC, | |
185 | // 80 | |
186 | 0x66,0x66,0x99, 0x66,0x66,0x66, 0x66,0x66,0x33, 0x66,0x66,0x00, | |
187 | 0x66,0x33,0xFF, 0x66,0x33,0xCC, 0x66,0x33,0x99, 0x66,0x33,0x66, | |
188 | 0x66,0x33,0x33, 0x66,0x33,0x00, 0x66,0x00,0xFF, 0x66,0x00,0xCC, | |
189 | 0x66,0x00,0x99, 0x66,0x00,0x66, 0x66,0x00,0x33, 0x66,0x00,0x00, | |
190 | // 90 | |
191 | 0x33,0xFF,0xFF, 0x33,0xFF,0xCC, 0x33,0xFF,0x99, 0x33,0xFF,0x66, | |
192 | 0x33,0xFF,0x33, 0x33,0xFF,0x00, 0x33,0xCC,0xFF, 0x33,0xCC,0xCC, | |
193 | 0x33,0xCC,0x99, 0x33,0xCC,0x66, 0x33,0xCC,0x33, 0x33,0xCC,0x00, | |
194 | 0x33,0x99,0xFF, 0x33,0x99,0xCC, 0x33,0x99,0x99, 0x33,0x99,0x66, | |
195 | // a0 | |
196 | 0x33,0x99,0x33, 0x33,0x99,0x00, 0x33,0x66,0xFF, 0x33,0x66,0xCC, | |
197 | 0x33,0x66,0x99, 0x33,0x66,0x66, 0x33,0x66,0x33, 0x33,0x66,0x00, | |
198 | 0x33,0x33,0xFF, 0x33,0x33,0xCC, 0x33,0x33,0x99, 0x33,0x33,0x66, | |
199 | 0x33,0x33,0x33, 0x33,0x33,0x00, 0x33,0x00,0xFF, 0x33,0x00,0xCC, | |
200 | // b0 | |
201 | 0x33,0x00,0x99, 0x33,0x00,0x66, 0x33,0x00,0x33, 0x33,0x00,0x00, | |
202 | 0x00,0xFF,0xFF, 0x00,0xFF,0xCC, 0x00,0xFF,0x99, 0x00,0xFF,0x66, | |
203 | 0x00,0xFF,0x33, 0x00,0xFF,0x00, 0x00,0xCC,0xFF, 0x00,0xCC,0xCC, | |
204 | 0x00,0xCC,0x99, 0x00,0xCC,0x66, 0x00,0xCC,0x33, 0x00,0xCC,0x00, | |
205 | // c0 | |
206 | 0x00,0x99,0xFF, 0x00,0x99,0xCC, 0x00,0x99,0x99, 0x00,0x99,0x66, | |
207 | 0x00,0x99,0x33, 0x00,0x99,0x00, 0x00,0x66,0xFF, 0x00,0x66,0xCC, | |
208 | 0x00,0x66,0x99, 0x00,0x66,0x66, 0x00,0x66,0x33, 0x00,0x66,0x00, | |
209 | 0x00,0x33,0xFF, 0x00,0x33,0xCC, 0x00,0x33,0x99, 0x00,0x33,0x66, | |
210 | // d0 | |
211 | 0x00,0x33,0x33, 0x00,0x33,0x00, 0x00,0x00,0xFF, 0x00,0x00,0xCC, | |
212 | 0x00,0x00,0x99, 0x00,0x00,0x66, 0x00,0x00,0x33, 0xEE,0x00,0x00, | |
213 | 0xDD,0x00,0x00, 0xBB,0x00,0x00, 0xAA,0x00,0x00, 0x88,0x00,0x00, | |
214 | 0x77,0x00,0x00, 0x55,0x00,0x00, 0x44,0x00,0x00, 0x22,0x00,0x00, | |
215 | // e0 | |
216 | 0x11,0x00,0x00, 0x00,0xEE,0x00, 0x00,0xDD,0x00, 0x00,0xBB,0x00, | |
217 | 0x00,0xAA,0x00, 0x00,0x88,0x00, 0x00,0x77,0x00, 0x00,0x55,0x00, | |
218 | 0x00,0x44,0x00, 0x00,0x22,0x00, 0x00,0x11,0x00, 0x00,0x00,0xEE, | |
219 | 0x00,0x00,0xDD, 0x00,0x00,0xBB, 0x00,0x00,0xAA, 0x00,0x00,0x88, | |
220 | // f0 | |
221 | 0x00,0x00,0x77, 0x00,0x00,0x55, 0x00,0x00,0x44, 0x00,0x00,0x22, | |
222 | 0x00,0x00,0x11, 0xEE,0xEE,0xEE, 0xDD,0xDD,0xDD, 0xBB,0xBB,0xBB, | |
223 | 0xAA,0xAA,0xAA, 0x88,0x88,0x88, 0x77,0x77,0x77, 0x55,0x55,0x55, | |
224 | 0x44,0x44,0x44, 0x22,0x22,0x22, 0x11,0x11,0x11, 0x00,0x00,0x00 | |
225 | }; | |
fe8ab488 | 226 |