]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
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 | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | /* | |
31 | * This file contains firmware code. | |
32 | * | |
33 | */ | |
34 | ||
1c79356b A |
35 | #include <debug.h> |
36 | #include <mach_vm_debug.h> | |
37 | #include <db_machine_commands.h> | |
38 | ||
39 | #include <kern/thread.h> | |
40 | #include <mach/vm_attributes.h> | |
41 | #include <mach/vm_param.h> | |
42 | #include <kern/spl.h> | |
43 | ||
44 | #include <kern/misc_protos.h> | |
45 | #include <ppc/misc_protos.h> | |
46 | #include <ppc/proc_reg.h> | |
47 | #include <ppc/mem.h> | |
48 | #include <ppc/pmap.h> | |
1c79356b A |
49 | #include <ppc/new_screen.h> |
50 | #include <ppc/Firmware.h> | |
51 | #include <ppc/mappings.h> | |
1c79356b A |
52 | #include <pexpert/pexpert.h> |
53 | #include <ddb/db_output.h> | |
54 | ||
55 | extern Boot_Video boot_video_info; | |
56 | Boot_Video dgVideo; | |
57 | extern GDWorkArea GratefulDebWork[]; | |
58 | ||
59 | typedef struct RuptCtr { /* Counts hardware interrupts */ | |
60 | struct GDpos { /* Screen position for Grateful Deb display */ | |
61 | unsigned short col; /* Column (-1 means no display) */ | |
62 | unsigned short row; /* Row */ | |
63 | } GDpos; | |
64 | unsigned int count; /* Count of interrupt */ | |
65 | unsigned int timed; /* If set, count updates at timed rate */ | |
66 | unsigned int lasttime; /* Low of timebase when last updated */ | |
67 | } RuptCtr; | |
68 | ||
69 | /* Window layout for Grateful Deb: | |
70 | * | |
71 | * 0 9 | |
72 | * | |
73 | * 0 Total Decrimenter | |
74 | * 1 DSI ISI | |
75 | * 2 System call External | |
76 | * 3 SIGP Floating point | |
77 | * 4 Program Alignment | |
78 | */ | |
79 | ||
80 | ||
81 | ||
82 | ||
83 | ||
84 | RuptCtr RuptCtrs[96] = { | |
85 | { { 0, 0}, 0, 1 }, /* Total interruptions */ | |
86 | { {-1, -1}, 0, 0 }, /* Reset */ | |
87 | { {-1, -1}, 0, 0 }, /* Machine check */ | |
88 | { { 0, 1}, 0, 1 }, /* DSIs */ | |
89 | { { 1, 1}, 0, 1 }, /* ISIs */ | |
90 | { { 1, 2}, 0, 1 }, /* Externals */ | |
91 | { { 1, 4}, 0, 0 }, /* Alignment */ | |
92 | { { 0, 4}, 0, 0 }, /* Program */ | |
93 | { { 1, 3}, 0, 0 }, /* Floating point */ | |
94 | { { 1, 0}, 0, 1 }, /* Decrementer */ | |
95 | { {-1, -1}, 0, 0 }, /* I/O error */ | |
96 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
97 | { { 0, 2}, 0, 1 }, /* System call */ | |
98 | { {-1, -1}, 0, 0 }, /* Trace */ | |
99 | { {-1, -1}, 0, 0 }, /* Floating point assist */ | |
100 | { {-1, -1}, 0, 0 }, /* Performance monitor */ | |
101 | { {-1, -1}, 0, 0 }, /* VMX */ | |
102 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
103 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
104 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
105 | { {-1, -1}, 0, 0 }, /* Instruction breakpoint */ | |
106 | { {-1, -1}, 0, 0 }, /* System management */ | |
107 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
108 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
109 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
110 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
111 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
112 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
113 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
114 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
115 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
116 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
117 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
118 | { {-1, -1}, 0, 0 }, /* Trace */ | |
119 | { { 0, 3}, 0, 0 }, /* SIGP */ | |
120 | { {-1, -1}, 0, 0 }, /* Preemption */ | |
121 | { {-1, -1}, 0, 0 }, /* Context switch */ | |
122 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
123 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
124 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
125 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
126 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
127 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
128 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
129 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
130 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
131 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
132 | { {-1, -1}, 0, 0 }, /* Special, update frequency controls */ | |
133 | ||
134 | /* Start of second processor counts */ | |
135 | ||
136 | { { 0, 0}, 0, 1 }, /* Total interruptions */ | |
137 | { {-1, -1}, 0, 0 }, /* Reset */ | |
138 | { {-1, -1}, 0, 0 }, /* Machine check */ | |
139 | { { 0, 1}, 0, 1 }, /* DSIs */ | |
140 | { { 1, 1}, 0, 1 }, /* ISIs */ | |
141 | { { 1, 2}, 0, 1 }, /* Externals */ | |
142 | { { 1, 4}, 0, 0 }, /* Alignment */ | |
143 | { { 0, 4}, 0, 0 }, /* Program */ | |
144 | { { 1, 3}, 0, 0 }, /* Floating point */ | |
145 | { { 1, 0}, 0, 1 }, /* Decrementer */ | |
146 | { {-1, -1}, 0, 0 }, /* I/O error */ | |
147 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
148 | { { 0, 2}, 0, 1 }, /* System call */ | |
149 | { {-1, -1}, 0, 0 }, /* Trace */ | |
150 | { {-1, -1}, 0, 0 }, /* Floating point assist */ | |
151 | { {-1, -1}, 0, 0 }, /* Performance monitor */ | |
152 | { {-1, -1}, 0, 0 }, /* VMX */ | |
153 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
154 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
155 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
156 | { {-1, -1}, 0, 0 }, /* Instruction breakpoint */ | |
157 | { {-1, -1}, 0, 0 }, /* System management */ | |
158 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
159 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
160 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
161 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
162 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
163 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
164 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
165 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
166 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
167 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
168 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
169 | { {-1, -1}, 0, 0 }, /* Trace */ | |
170 | { { 0, 3}, 0, 0 }, /* SIGP */ | |
171 | { {-1, -1}, 0, 0 }, /* Preemption */ | |
172 | { {-1, -1}, 0, 0 }, /* Context switch */ | |
173 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
174 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
175 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
176 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
177 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
178 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
179 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
180 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
181 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
182 | { {-1, -1}, 0, 0 }, /* Reserved */ | |
183 | { {-1, -1}, 0, 0 } /* Special, update frequency controls */ | |
184 | }; | |
185 | ||
186 | void GratefulDebInit(bootBumbleC *boot_video_info) { /* Initialize the video debugger */ | |
187 | ||
188 | unsigned int fillframe[256]; | |
189 | unsigned int startpos, startbyte, windowleft, newwidth, i, j, startword, oldwidth, nrmlgn; | |
190 | unsigned int nwords, *byteleft, lstlgn, pixlgn, bytelgn; | |
191 | ||
192 | if(!boot_video_info) { /* Are we disabling it? | |
193 | GratefulDebWork[0].GDready = 0; /* Disable output */ | |
194 | return; | |
195 | } | |
196 | ||
197 | nrmlgn = (9 * GDfontsize) * (boot_video_info->v_depth / 8); /* Get the normal column size in bytes */ | |
198 | lstlgn = (((8 * GDfontsize) + (GDfontsize >> 1)) * boot_video_info->v_depth) / 8; /* Same as normal, but with 1/2 character space */ | |
199 | nrmlgn = (nrmlgn + 31) & -32; /* Round to a line */ | |
200 | ||
201 | bytelgn = (nrmlgn * (GDdispcols - 1)) + lstlgn; /* Length in bytes */ | |
202 | pixlgn = bytelgn / (boot_video_info->v_depth / 8); /* Number of pixels wide */ | |
203 | ||
204 | startbyte = (boot_video_info->v_width * (boot_video_info->v_depth / 8)) - bytelgn; /* Get the starting byte unaligned */ | |
205 | startpos = boot_video_info->v_width - pixlgn; /* Starting pixel position */ | |
206 | ||
207 | startbyte += (unsigned int)boot_video_info->v_baseAddr & 31; /* Add the extra to cache boundary in frame buffer */ | |
208 | startbyte &= -32; /* Make sure it's on a cache line for speed */ | |
209 | startbyte += (unsigned int)boot_video_info->v_baseAddr & 31; /* Subtract the extra to cache boundary in frame buffer */ | |
210 | ||
211 | windowleft = startbyte - (((GDfontsize / 2) * boot_video_info->v_depth) / 8); /* Back up a half character */ | |
212 | windowleft &= -4; /* Make sure it is on a word boundary */ | |
213 | newwidth = windowleft / (boot_video_info->v_depth / 8); /* Get the new pixel width of screen */ | |
214 | ||
215 | oldwidth = boot_video_info->v_width; /* Save the old width */ | |
216 | // boot_video_info->v_width = newwidth; /* Set the new width */ | |
217 | ||
218 | nwords = oldwidth - newwidth; /* See how much to fill in pixels */ | |
219 | nwords = nwords / (32 / boot_video_info->v_depth); /* Get that in bytes */ | |
220 | ||
221 | startword = (newwidth + 3) / 4; /* Where does it start? */ | |
222 | ||
223 | ||
224 | byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft); /* Starting place */ | |
225 | for (i=0; i < nwords; i++) byteleft[i] = 0; /* Set the row to all black */ | |
226 | ||
227 | byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 1)); /* Starting place */ | |
228 | for (i=0; i < nwords; i++) byteleft[i] = 0; /* Set the row to all black */ | |
229 | ||
230 | byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + | |
231 | (boot_video_info->v_rowBytes * (boot_video_info->v_height - 2))); /* Starting place */ | |
232 | for (i=0; i < nwords; i++) byteleft[i] = 0; /* Set the row to all black */ | |
233 | ||
234 | byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + | |
235 | (boot_video_info->v_rowBytes * (boot_video_info->v_height - 1))); /* Starting place */ | |
236 | for (i=0; i < nwords; i++) byteleft[i] = 0; /* Set the row to all black */ | |
237 | ||
238 | for (i=0; i < nwords; i++) fillframe[i] = 0xFFFFFFFF; /* Set the row to all white */ | |
239 | ||
240 | if(boot_video_info->v_depth == 8) { /* See if 8 bits a pixel */ | |
241 | fillframe[0] = 0x0000FFFF; /* Make left border */ | |
242 | fillframe[nwords - 1] = 0xFFFF0000; /* Make right border */ | |
243 | } | |
244 | else if(boot_video_info->v_depth == 16) { /* See if 16 bits a pixel */ | |
245 | fillframe[0] = 0x00000000; /* Make left border */ | |
246 | fillframe[nwords - 1] = 0x00000000; /* Make right border */ | |
247 | } | |
248 | else { | |
249 | fillframe[0] = 0x00000000; /* Make left border */ | |
250 | fillframe[1] = 0x00000000; /* Make left border */ | |
251 | fillframe[nwords - 1] = 0x00000000; /* Make right border */ | |
252 | fillframe[nwords - 2] = 0x00000000; /* Make right border */ | |
253 | } | |
254 | ||
255 | byteleft = (unsigned int *)(boot_video_info->v_baseAddr + windowleft + (boot_video_info->v_rowBytes * 2)); /* Place to start filling */ | |
256 | ||
257 | for(i=2; i < (boot_video_info->v_height - 2); i++) { /* Fill the rest */ | |
258 | for(j=0; j<nwords; j++) byteleft[j] = fillframe[j]; /* Fill the row */ | |
259 | byteleft = (unsigned int *)((unsigned int)byteleft + boot_video_info->v_rowBytes); /* Next row */ | |
260 | } | |
261 | ||
262 | for(i=0; i<2; i++) { /* Initialize both (for now) processor areas */ | |
263 | ||
264 | GratefulDebWork[i].GDtop = 2 + (GDfontsize / 2) + (i * 18 * GDfontsize); | |
265 | GratefulDebWork[i].GDleft = 2 + startpos + (GDfontsize / 2); | |
266 | GratefulDebWork[i].GDtopleft = boot_video_info->v_baseAddr + startbyte + | |
267 | (GratefulDebWork[i].GDtop * boot_video_info->v_rowBytes); | |
268 | GratefulDebWork[i].GDrowbytes = boot_video_info->v_rowBytes; | |
269 | GratefulDebWork[i].GDrowchar = boot_video_info->v_rowBytes * (GDfontsize + (GDfontsize / 4)); | |
270 | GratefulDebWork[i].GDdepth = boot_video_info->v_depth; | |
271 | GratefulDebWork[i].GDcollgn = nrmlgn; | |
272 | ||
90556fb8 A |
273 | // RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 4; /* (Update every 16th of a second (16 fps) */ |
274 | RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 3; /* (Update every 8th of a second (8 fps) */ | |
275 | // RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 2; /* (Update every 4th of a second (4 fps) */ | |
276 | // RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 1; /* (Update every 2th of a second (2 fps) */ | |
277 | // RuptCtrs[(48*i)+47].timed = gPEClockFrequencyInfo.timebase_frequency_hz >> 0; /* (Update every 1 second (1 fps) */ | |
1c79356b A |
278 | |
279 | sync(); | |
280 | ||
281 | GratefulDebWork[i].GDready = 1; /* This one's all ready */ | |
282 | } | |
283 | ||
284 | } | |
285 | ||
55e303ae A |
286 | void debugNoop(void); |
287 | void debugNoop(void) { /* This does absolutely nothing */ | |
288 | return; | |
289 | } |