fix end-of-lines

svn path=/trunk/; revision=9897
This commit is contained in:
Royce Mitchell III 2004-06-27 04:08:57 +00:00
parent 0ce9ce5756
commit 8d2f559189

View file

@ -1,291 +1,291 @@
/* $Id: except.s,v 1.4 2004/06/25 16:39:41 weiden Exp $ /* $Id: except.s,v 1.5 2004/06/27 04:08:57 royce Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Kernel-mode exception support for IA-32 * PURPOSE: Kernel-mode exception support for IA-32
* FILE: ntoskrnl/rtl/i386/except.s * FILE: ntoskrnl/rtl/i386/except.s
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* NOTES: This file is shared with lib/ntdll/rtl/i386/except.s. * NOTES: This file is shared with lib/ntdll/rtl/i386/except.s.
* Please keep them in sync. * Please keep them in sync.
*/ */
#define EXCEPTION_UNWINDING 0x02 #define EXCEPTION_UNWINDING 0x02
#define EREC_FLAGS 0x04 #define EREC_FLAGS 0x04
#define ExceptionContinueExecution 0 #define ExceptionContinueExecution 0
#define ExceptionContinueSearch 1 #define ExceptionContinueSearch 1
#define ExceptionNestedException 2 #define ExceptionNestedException 2
#define ExceptionCollidedUnwind 3 #define ExceptionCollidedUnwind 3
.globl _RtlpExecuteHandlerForException .globl _RtlpExecuteHandlerForException
.globl _RtlpExecuteHandlerForUnwind .globl _RtlpExecuteHandlerForUnwind
#define CONTEXT_FLAGS 0x00 #define CONTEXT_FLAGS 0x00
#define CONTEXT_SEGGS 0x8C #define CONTEXT_SEGGS 0x8C
#define CONTEXT_SEGFS 0x90 #define CONTEXT_SEGFS 0x90
#define CONTEXT_SEGES 0x94 #define CONTEXT_SEGES 0x94
#define CONTEXT_SEGDS 0x98 #define CONTEXT_SEGDS 0x98
#define CONTEXT_EDI 0x9C #define CONTEXT_EDI 0x9C
#define CONTEXT_ESI 0xA0 #define CONTEXT_ESI 0xA0
#define CONTEXT_EBX 0xA4 #define CONTEXT_EBX 0xA4
#define CONTEXT_EDX 0xA8 #define CONTEXT_EDX 0xA8
#define CONTEXT_ECX 0xAC #define CONTEXT_ECX 0xAC
#define CONTEXT_EAX 0xB0 #define CONTEXT_EAX 0xB0
#define CONTEXT_EBP 0xB4 #define CONTEXT_EBP 0xB4
#define CONTEXT_EIP 0xB8 #define CONTEXT_EIP 0xB8
#define CONTEXT_SEGCS 0xBC #define CONTEXT_SEGCS 0xBC
#define CONTEXT_EFLAGS 0xC0 #define CONTEXT_EFLAGS 0xC0
#define CONTEXT_ESP 0xC4 #define CONTEXT_ESP 0xC4
#define CONTEXT_SEGSS 0xC8 #define CONTEXT_SEGSS 0xC8
#define RCC_CONTEXT 0x08 #define RCC_CONTEXT 0x08
// EAX = value to print // EAX = value to print
_do_debug: _do_debug:
pushal pushal
pushl %eax pushl %eax
call _AsmDebug@4 call _AsmDebug@4
popal popal
ret ret
#ifndef __NTOSKRNL__ #ifndef __NTOSKRNL__
// //
// VOID // VOID
// RtlpCaptureContext(PCONTEXT pContext); // RtlpCaptureContext(PCONTEXT pContext);
// //
// Parameters: // Parameters:
// [ESP+08h] - PCONTEXT_X86 pContext // [ESP+08h] - PCONTEXT_X86 pContext
// Registers: // Registers:
// None // None
// Returns: // Returns:
// Nothing // Nothing
// Notes: // Notes:
// Grabs the current CPU context. // Grabs the current CPU context.
.globl _RtlpCaptureContext .globl _RtlpCaptureContext
_RtlpCaptureContext: _RtlpCaptureContext:
pushl %ebp pushl %ebp
movl %esp, %ebp movl %esp, %ebp
movl RCC_CONTEXT(%ebp), %edx // EDX = Address of context structure movl RCC_CONTEXT(%ebp), %edx // EDX = Address of context structure
cld cld
pushf pushf
pop %eax pop %eax
movl %eax, CONTEXT_EFLAGS(%edx) movl %eax, CONTEXT_EFLAGS(%edx)
xorl %eax, %eax xorl %eax, %eax
movl %eax, CONTEXT_EAX(%edx) movl %eax, CONTEXT_EAX(%edx)
movl %eax, CONTEXT_EBX(%edx) movl %eax, CONTEXT_EBX(%edx)
movl %eax, CONTEXT_ECX(%edx) movl %eax, CONTEXT_ECX(%edx)
movl %eax, CONTEXT_EDX(%edx) movl %eax, CONTEXT_EDX(%edx)
movl %eax, CONTEXT_ESI(%edx) movl %eax, CONTEXT_ESI(%edx)
movl %eax, CONTEXT_EDI(%edx) movl %eax, CONTEXT_EDI(%edx)
movl %cs, %eax movl %cs, %eax
movl %eax, CONTEXT_SEGCS(%edx) movl %eax, CONTEXT_SEGCS(%edx)
movl %ds, %eax movl %ds, %eax
movl %eax, CONTEXT_SEGDS(%edx) movl %eax, CONTEXT_SEGDS(%edx)
movl %es, %eax movl %es, %eax
movl %eax, CONTEXT_SEGES(%edx) movl %eax, CONTEXT_SEGES(%edx)
movl %fs, %eax movl %fs, %eax
movl %eax, CONTEXT_SEGFS(%edx) movl %eax, CONTEXT_SEGFS(%edx)
movl %gs, %eax movl %gs, %eax
movl %eax, CONTEXT_SEGGS(%edx) movl %eax, CONTEXT_SEGGS(%edx)
movl %ss, %eax movl %ss, %eax
movl %eax, CONTEXT_SEGSS(%edx) movl %eax, CONTEXT_SEGSS(%edx)
// //
// STACK LAYOUT: - (ESP to put in context structure) // STACK LAYOUT: - (ESP to put in context structure)
// - RETURN ADDRESS OF CALLER OF CALLER // - RETURN ADDRESS OF CALLER OF CALLER
// - EBP OF CALLER OF CALLER // - EBP OF CALLER OF CALLER
// ... // ...
// - RETURN ADDRESS OF CALLER // - RETURN ADDRESS OF CALLER
// - EBP OF CALLER // - EBP OF CALLER
// ... // ...
// //
// Get return address of the caller of the caller of this function // Get return address of the caller of the caller of this function
movl %ebp, %ebx movl %ebp, %ebx
//movl 4(%ebx), %eax // EAX = return address of caller //movl 4(%ebx), %eax // EAX = return address of caller
movl (%ebx), %ebx // EBX = EBP of caller movl (%ebx), %ebx // EBX = EBP of caller
movl 4(%ebx), %eax // EAX = return address of caller of caller movl 4(%ebx), %eax // EAX = return address of caller of caller
movl (%ebx), %ebx // EBX = EBP of caller of caller movl (%ebx), %ebx // EBX = EBP of caller of caller
movl %eax, CONTEXT_EIP(%edx) // EIP = return address of caller of caller movl %eax, CONTEXT_EIP(%edx) // EIP = return address of caller of caller
movl %ebx, CONTEXT_EBP(%edx) // EBP = EBP of caller of caller movl %ebx, CONTEXT_EBP(%edx) // EBP = EBP of caller of caller
addl $8, %ebx addl $8, %ebx
movl %ebx, CONTEXT_ESP(%edx) // ESP = EBP of caller of caller + 8 movl %ebx, CONTEXT_ESP(%edx) // ESP = EBP of caller of caller + 8
movl %ebp, %esp movl %ebp, %esp
popl %ebp popl %ebp
ret ret
#endif /* !__NTOSKRNL__ */ #endif /* !__NTOSKRNL__ */
#define REH_ERECORD 0x08 #define REH_ERECORD 0x08
#define REH_RFRAME 0x0C #define REH_RFRAME 0x0C
#define REH_CONTEXT 0x10 #define REH_CONTEXT 0x10
#define REH_DCONTEXT 0x14 #define REH_DCONTEXT 0x14
#define REH_EROUTINE 0x18 #define REH_EROUTINE 0x18
// Parameters: // Parameters:
// None // None
// Registers: // Registers:
// [EBP+08h] - PEXCEPTION_RECORD ExceptionRecord // [EBP+08h] - PEXCEPTION_RECORD ExceptionRecord
// [EBP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame // [EBP+0Ch] - PEXCEPTION_REGISTRATION RegistrationFrame
// [EBP+10h] - PVOID Context // [EBP+10h] - PVOID Context
// [EBP+14h] - PVOID DispatcherContext // [EBP+14h] - PVOID DispatcherContext
// [EBP+18h] - PEXCEPTION_HANDLER ExceptionRoutine // [EBP+18h] - PEXCEPTION_HANDLER ExceptionRoutine
// EDX - Address of protecting exception handler // EDX - Address of protecting exception handler
// Returns: // Returns:
// EXCEPTION_DISPOSITION // EXCEPTION_DISPOSITION
// Notes: // Notes:
// Setup the protecting exception handler and call the exception // Setup the protecting exception handler and call the exception
// handler in the right context. // handler in the right context.
_RtlpExecuteHandler: _RtlpExecuteHandler:
pushl %ebp pushl %ebp
movl %esp, %ebp movl %esp, %ebp
pushl REH_RFRAME(%ebp) pushl REH_RFRAME(%ebp)
pushl %edx pushl %edx
pushl %fs:0x0 pushl %fs:0x0
movl %esp, %fs:0x0 movl %esp, %fs:0x0
// Prepare to call the exception handler // Prepare to call the exception handler
pushl REH_DCONTEXT(%ebp) pushl REH_DCONTEXT(%ebp)
pushl REH_CONTEXT(%ebp) pushl REH_CONTEXT(%ebp)
pushl REH_RFRAME(%ebp) pushl REH_RFRAME(%ebp)
pushl REH_ERECORD(%ebp) pushl REH_ERECORD(%ebp)
// Now call the exception handler // Now call the exception handler
movl REH_EROUTINE(%ebp), %eax movl REH_EROUTINE(%ebp), %eax
call *%eax call *%eax
cmpl $-1, %fs:0x0 cmpl $-1, %fs:0x0
jne .reh_stack_looks_ok jne .reh_stack_looks_ok
// This should not happen // This should not happen
pushl 0 pushl 0
pushl 0 pushl 0
pushl 0 pushl 0
pushl 0 pushl 0
call _RtlAssert@16 call _RtlAssert@16
.reh_loop: .reh_loop:
jmp .reh_loop jmp .reh_loop
.reh_stack_looks_ok: .reh_stack_looks_ok:
movl %fs:0x0, %esp movl %fs:0x0, %esp
// Return to the 'front-end' for this function // Return to the 'front-end' for this function
popl %fs:0x0 popl %fs:0x0
movl %ebp, %esp movl %ebp, %esp
popl %ebp popl %ebp
ret ret
#define REP_ERECORD 0x04 #define REP_ERECORD 0x04
#define REP_RFRAME 0x08 #define REP_RFRAME 0x08
#define REP_CONTEXT 0x0C #define REP_CONTEXT 0x0C
#define REP_DCONTEXT 0x10 #define REP_DCONTEXT 0x10
// Parameters: // Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord // [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame // [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context // [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext // [ESP+10h] - PVOID DispatcherContext
// Registers: // Registers:
// None // None
// Returns: // Returns:
// EXCEPTION_DISPOSITION // EXCEPTION_DISPOSITION
// Notes: // Notes:
// This exception handler protects the exception handling // This exception handler protects the exception handling
// mechanism by detecting nested exceptions. // mechanism by detecting nested exceptions.
_RtlpExceptionProtector: _RtlpExceptionProtector:
movl $ExceptionContinueSearch, %eax movl $ExceptionContinueSearch, %eax
movl REP_ERECORD(%esp), %ecx movl REP_ERECORD(%esp), %ecx
testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx) testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx)
jnz .rep_end jnz .rep_end
// Unwinding is not taking place, so return ExceptionNestedException // Unwinding is not taking place, so return ExceptionNestedException
// Set DispatcherContext field to the exception registration for the // Set DispatcherContext field to the exception registration for the
// exception handler that executed when a nested exception occurred // exception handler that executed when a nested exception occurred
movl REP_DCONTEXT(%esp), %ecx movl REP_DCONTEXT(%esp), %ecx
movl REP_RFRAME(%esp), %eax movl REP_RFRAME(%esp), %eax
movl %eax, (%ecx) movl %eax, (%ecx)
movl $ExceptionNestedException, %eax movl $ExceptionNestedException, %eax
.rep_end: .rep_end:
ret ret
// Parameters: // Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord // [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame // [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context // [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext // [ESP+10h] - PVOID DispatcherContext
// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler // [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler
// Registers: // Registers:
// None // None
// Returns: // Returns:
// EXCEPTION_DISPOSITION // EXCEPTION_DISPOSITION
// Notes: // Notes:
// Front-end // Front-end
_RtlpExecuteHandlerForException: _RtlpExecuteHandlerForException:
movl $_RtlpExceptionProtector, %edx movl $_RtlpExceptionProtector, %edx
jmp _RtlpExecuteHandler jmp _RtlpExecuteHandler
#define RUP_ERECORD 0x04 #define RUP_ERECORD 0x04
#define RUP_RFRAME 0x08 #define RUP_RFRAME 0x08
#define RUP_CONTEXT 0x0C #define RUP_CONTEXT 0x0C
#define RUP_DCONTEXT 0x10 #define RUP_DCONTEXT 0x10
// Parameters: // Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord // [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame // [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context // [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext // [ESP+10h] - PVOID DispatcherContext
// Registers: // Registers:
// None // None
// Returns: // Returns:
// EXCEPTION_DISPOSITION // EXCEPTION_DISPOSITION
// Notes: // Notes:
// This exception handler protects the exception handling // This exception handler protects the exception handling
// mechanism by detecting collided unwinds. // mechanism by detecting collided unwinds.
_RtlpUnwindProtector: _RtlpUnwindProtector:
movl $ExceptionContinueSearch, %eax movl $ExceptionContinueSearch, %eax
movl %ecx, RUP_ERECORD(%esp) movl %ecx, RUP_ERECORD(%esp)
testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx) testl $EXCEPTION_UNWINDING, EREC_FLAGS(%ecx)
jz .rup_end jz .rup_end
// Unwinding is taking place, so return ExceptionCollidedUnwind // Unwinding is taking place, so return ExceptionCollidedUnwind
movl RUP_RFRAME(%esp), %ecx movl RUP_RFRAME(%esp), %ecx
movl RUP_DCONTEXT(%esp), %edx movl RUP_DCONTEXT(%esp), %edx
// Set DispatcherContext field to the exception registration for the // Set DispatcherContext field to the exception registration for the
// exception handler that executed when a collision occurred // exception handler that executed when a collision occurred
movl RUP_RFRAME(%ecx), %eax movl RUP_RFRAME(%ecx), %eax
movl %eax, (%edx) movl %eax, (%edx)
movl $ExceptionCollidedUnwind, %eax movl $ExceptionCollidedUnwind, %eax
.rup_end: .rup_end:
ret ret
// Parameters: // Parameters:
// [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord // [ESP+04h] - PEXCEPTION_RECORD ExceptionRecord
// [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame // [ESP+08h] - PEXCEPTION_REGISTRATION RegistrationFrame
// [ESP+0Ch] - PCONTEXT Context // [ESP+0Ch] - PCONTEXT Context
// [ESP+10h] - PVOID DispatcherContext // [ESP+10h] - PVOID DispatcherContext
// [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler // [ESP+14h] - PEXCEPTION_HANDLER ExceptionHandler
// Registers: // Registers:
// None // None
// Returns: // Returns:
// EXCEPTION_DISPOSITION // EXCEPTION_DISPOSITION
_RtlpExecuteHandlerForUnwind: _RtlpExecuteHandlerForUnwind:
movl $_RtlpUnwindProtector, %edx movl $_RtlpUnwindProtector, %edx
jmp _RtlpExecuteHandler jmp _RtlpExecuteHandler