mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 17:56:06 +00:00
- Tree cleanups proposed on the mailing list. Move all non-Core OS modules to rosapps. Tests were already moved by Fireball to rostests.
svn path=/trunk/; revision=26033
This commit is contained in:
parent
ad07a1e58f
commit
1e3d5d70e9
420 changed files with 78215 additions and 0 deletions
142
rosapps/sysutils/utils/pice/module/gpfault.c
Normal file
142
rosapps/sysutils/utils/pice/module/gpfault.c
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 1998-2001 Klaus P. Gerlicher
|
||||
|
||||
Module Name:
|
||||
|
||||
GPFault.c
|
||||
|
||||
Abstract:
|
||||
|
||||
handle general protection faults on x86
|
||||
|
||||
Environment:
|
||||
|
||||
Kernel mode only
|
||||
|
||||
Author:
|
||||
|
||||
Klaus P. Gerlicher
|
||||
|
||||
Revision History:
|
||||
|
||||
13-Nov-1999: created
|
||||
15-Nov-2000: general cleanup of source files
|
||||
|
||||
Copyright notice:
|
||||
|
||||
This file may be distributed under the terms of the GNU Public License.
|
||||
|
||||
--*/
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// INCLUDES
|
||||
////
|
||||
#include "remods.h"
|
||||
#include "precomp.h"
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// GLOBALS
|
||||
////
|
||||
ULONG OldGPFaultHandler = 0;
|
||||
|
||||
char tempGP[1024];
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// FUNCTIONS
|
||||
////
|
||||
|
||||
//*************************************************************************
|
||||
// NewGPFaultHandler()
|
||||
//
|
||||
//*************************************************************************
|
||||
void HandleGPFault(FRAME* ptr)
|
||||
{
|
||||
DPRINT((0,"HandleGPFault(): ptr = %x at eip: %x\n",ptr, ptr->eip));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// NewGPFaultHandler()
|
||||
//
|
||||
//*************************************************************************
|
||||
__asm__ ("\n\t \
|
||||
NewGPFaultHandler:\n\t \
|
||||
pushfl\n\t \
|
||||
cli\n\t \
|
||||
cld\n\t \
|
||||
pushal\n\t \
|
||||
pushl %ds\n\t \
|
||||
\n\t \
|
||||
// test for v86 mode\n\t \
|
||||
testl $0x20000,40(%esp)\n\t \
|
||||
jnz notv86\n\t \
|
||||
popl %ds\n\t \
|
||||
popal\n\t \
|
||||
popfl\n\t \
|
||||
.byte 0x2e\n\t \
|
||||
jmp *_OldGPFaultHandler\n\t \
|
||||
notv86:\n\t \
|
||||
// setup default data selectors\n\t \
|
||||
movw %ss,%ax\n\t \
|
||||
movw %ax,%ds\n\t \
|
||||
\n\t \
|
||||
// get frame ptr\n\t \
|
||||
lea 40(%esp),%eax\n\t \
|
||||
pushl %eax\n\t \
|
||||
call _HandleGPFault\n\t \
|
||||
addl $4,%esp\n\t \
|
||||
\n \t \
|
||||
popl %ds\n\t \
|
||||
popal\n\t \
|
||||
popfl\n\t \
|
||||
// remove error code from stack and replace with reason code\n\t \
|
||||
movl $" STR(REASON_GP_FAULT) ",(%esp)\n\t \
|
||||
// call debugger loop\n\t \
|
||||
jmp NewInt31Handler\n\t \
|
||||
");
|
||||
|
||||
//*************************************************************************
|
||||
// InstallGPFaultHook()
|
||||
//
|
||||
//*************************************************************************
|
||||
void InstallGPFaultHook(void)
|
||||
{
|
||||
ULONG LocalGPFaultHandler;
|
||||
|
||||
ENTER_FUNC();
|
||||
|
||||
MaskIrqs();
|
||||
if(!OldGPFaultHandler)
|
||||
{
|
||||
__asm__("mov $NewGPFaultHandler,%0"
|
||||
:"=r" (LocalGPFaultHandler)
|
||||
:
|
||||
:"eax");
|
||||
OldGPFaultHandler=SetGlobalInt(0x0D,(ULONG)LocalGPFaultHandler);
|
||||
}
|
||||
UnmaskIrqs();
|
||||
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// DeInstallGPFaultHook()
|
||||
//
|
||||
//*************************************************************************
|
||||
void DeInstallGPFaultHook(void)
|
||||
{
|
||||
ENTER_FUNC();
|
||||
|
||||
MaskIrqs();
|
||||
if(OldGPFaultHandler)
|
||||
{
|
||||
RemoveAllSWBreakpoints(TRUE);
|
||||
SetGlobalInt(0x0D,(ULONG)OldGPFaultHandler);
|
||||
OldGPFaultHandler=0;
|
||||
}
|
||||
UnmaskIrqs();
|
||||
|
||||
LEAVE_FUNC();
|
||||
}
|
||||
|
||||
// EOF
|
Loading…
Add table
Add a link
Reference in a new issue