3 Copyright (c) 1998-2001 Klaus P. Gerlicher
11 initialisation and cleanup of debugger kernel module
24 15-Nov-2000: general cleanup of source files
28 This file may be distributed under the terms of the GNU Public License.
32 ////////////////////////////////////////////////////
39 #include <asm/uaccess.h>
41 #include <asm/delay.h>
43 ////////////////////////////////////////////////////
45 ULONG ulDoInitialBreak
=1;
46 char szBootParams
[1024]="";
49 //*************************************************************************
52 //*************************************************************************
53 BOOLEAN
InitPICE(void)
55 ULONG ulHandleScancode
=0,ulHandleKbdEvent
=0;
60 DPRINT((0,"InitPICE(): trace step 1\n"));
61 // enable monochrome passthrough on BX type chipset
64 DPRINT((0,"InitPICE(): trace step 2\n"));
65 // now load all symbol files described in /etc/pice.conf
66 if(!LoadSymbolsFromConfig(FALSE
))
68 DPRINT((0,"InitPICE: LoadSymbolsFromConfig() failed\n"));
73 DPRINT((0,"InitPICE(): trace step 3\n"));
74 // init the output console
75 // this might be one of the following depending setup
77 // b) serial terminal (TODO)
80 DPRINT((0,"InitPICE: ConsoleInit() failed\n"));
86 DPRINT((0,"InitPICE(): trace step 4\n"));
87 // print the initial screen template
90 DPRINT((0,"InitPICE(): trace step 5\n"));
91 // ask the user if he wants to abort the debugger load
94 Print(OUTPUT_WINDOW
,"pICE: ABORT (abort by user)\n");
101 DPRINT((0,"InitPICE(): trace step 6\n"));
102 // get kernel mm_struct
103 my_init_mm
= GetInitMm();
106 Print(OUTPUT_WINDOW
,"pICE: ABORT (initial memory map not found)\n");
107 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
108 while(!GetKeyPolled());
114 DPRINT((0,"init_mm @ %X\n",my_init_mm
));
116 DPRINT((0,"InitPICE(): trace step 7\n"));
117 // load the file /boot/System.map.
118 // !!! It must be consistent with the current kernel at all cost!!!
121 Print(OUTPUT_WINDOW
,"pICE: failed to load exports\n");
122 Print(OUTPUT_WINDOW
,"press any key to continue...\n");
123 while(!GetKeyPolled());
130 DPRINT((0,"InitPICE(): trace step 8\n"));
132 ScanExports("_end",(PULONG
)&kernel_end
);
135 Print(OUTPUT_WINDOW
,"pICE: ABORT (kernel size is unknown)\n");
136 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
137 while(!GetKeyPolled());
145 DPRINT((0,"InitPICE(): trace step 9\n"));
146 // the loaded module list
147 ScanExports("module_list",(PULONG
)&pmodule_list
);
150 Print(OUTPUT_WINDOW
,"pICE: ABORT (couldn't retreive kernel module list)\n");
151 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
152 while(!GetKeyPolled());
160 DPRINT((0,"InitPICE(): trace step 10\n"));
161 // setup a fake module struct for use by symbol routines
162 if(!InitFakeKernelModule())
164 Print(OUTPUT_WINDOW
,"pICE: ABORT (couldn't initialize kernel module)\n");
165 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
166 while(!GetKeyPolled());
174 DPRINT((0,"InitPICE(): trace step 11\n"));
175 // do a sanity check on exports
176 if(!SanityCheckExports())
178 Print(OUTPUT_WINDOW
,"pICE: ABORT (exports are conflicting with kernel symbols)\n");
179 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
180 while(!GetKeyPolled());
188 DPRINT((0,"InitPICE(): trace step 12\n"));
191 DPRINT((0,"InitPICE(): trace step 13\n"));
192 // patch the keyboard driver
194 if(PatchKeyboardDriver())
196 Print(OUTPUT_WINDOW
,"pICE: ABORT (couldn't patch keyboard driver)\n");
197 Print(OUTPUT_WINDOW
,"pICE: press any key to continue...\n");
198 while(!GetKeyPolled());
206 DPRINT((0,"InitPICE(): trace step 14\n"));
207 // partial init of shadow registers
208 CurrentCS
= GLOBAL_CODE_SEGMENT
;
209 CurrentEIP
= (ULONG
)RealIsr
;
211 CurrentDS
= CurrentSS
= GLOBAL_DATA_SEGMENT
;
218 // display version and symbol information
221 // disable HW breakpoints
233 DPRINT((0,"InitPICE(): trace step 15\n"));
236 DPRINT((0,"InitPICE(): trace step 16\n"));
239 InstallGlobalKeyboardHook();
240 InstallSyscallHook();
244 InstallGPFaultHook();
247 DPRINT((0,"InitPICE(): trace step 16\n"));
250 DPRINT((0,"about to do initial break...\n"));
252 // simulate an initial break
256 pushl $initialreturnpoint
257 pushl $" STR(REASON_CTRLF
) "
259 initialreturnpoint:");
263 // display register contents
266 // display data window
267 Args
.Value
[0]=CurrentDS
;
268 Args
.Value
[1]=CurrentEIP
;
270 DisplayMemory(&Args
);
272 // disassembly from current address
273 Args
.Value
[0]=CurrentCS
;
274 Args
.Value
[1]=CurrentEIP
;
279 DPRINT((0,"InitPICE(): trace step 17\n"));
280 InitPiceRunningTimer();
286 //*************************************************************************
289 //*************************************************************************
290 void CleanUpPICE(void)
292 DPRINT((0,"CleanUpPICE(): trace step 1\n"));
293 RemovePiceRunningTimer();
295 DPRINT((0,"CleanUpPICE(): trace step 2\n"));
296 // de-install all hooks
297 DeInstallGlobalKeyboardHook();
298 DeInstallSyscallHook();
300 DeInstallPrintkHook();
301 DeInstallDblFltHook();
302 DeInstallGPFaultHook();
304 DeInstallTraceHook();
306 DPRINT((0,"CleanUpPICE(): trace step 3\n"));
309 DPRINT((0,"CleanUpPICE(): trace step 4\n"));
310 UnloadExports(); // don't use ScanExports() after this
313 DPRINT((0,"CleanUpPICE(): trace step 5\n"));
314 // restore patch of keyboard driver
315 RestoreKeyboardDriver();
317 DPRINT((0,"CleanUpPICE(): trace step 6\n"));
318 Print(OUTPUT_WINDOW
,"pICE: shutting down...\n");
320 DPRINT((0,"CleanUpPICE(): trace step 7\n"));
321 // cleanup the console