ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
January 2010
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
26 participants
522 discussions
Start a n
N
ew thread
[cgutman] 45006: - Use a spin lock to protect the port bitmap instead of a fast mutex
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jan 8 19:21:52 2010 New Revision: 45006 URL:
http://svn.reactos.org/svn/reactos?rev=45006&view=rev
Log: - Use a spin lock to protect the port bitmap instead of a fast mutex Modified: branches/aicom-network-branch/drivers/network/tcpip/include/ports.h branches/aicom-network-branch/lib/drivers/ip/network/ports.c Modified: branches/aicom-network-branch/drivers/network/tcpip/include/ports.h URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/drivers/ne…
============================================================================== --- branches/aicom-network-branch/drivers/network/tcpip/include/ports.h [iso-8859-1] (original) +++ branches/aicom-network-branch/drivers/network/tcpip/include/ports.h [iso-8859-1] Fri Jan 8 19:21:52 2010 @@ -16,7 +16,7 @@ PVOID ProtoBitBuffer; UINT StartingPort; UINT PortsToOversee; - FAST_MUTEX Mutex; + KSPIN_LOCK Lock; } PORT_SET, *PPORT_SET; NTSTATUS PortsStartup( PPORT_SET PortSet, Modified: branches/aicom-network-branch/lib/drivers/ip/network/ports.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/network/ports.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/network/ports.c [iso-8859-1] Fri Jan 8 19:21:52 2010 @@ -24,7 +24,7 @@ PortSet->ProtoBitBuffer, PortSet->PortsToOversee ); RtlClearAllBits( &PortSet->ProtoBitmap ); - ExInitializeFastMutex( &PortSet->Mutex ); + KeInitializeSpinLock( &PortSet->Lock ); return STATUS_SUCCESS; } @@ -33,17 +33,20 @@ } VOID DeallocatePort( PPORT_SET PortSet, ULONG Port ) { + KIRQL OldIrql; + Port = htons(Port); ASSERT(Port >= PortSet->StartingPort); ASSERT(Port < PortSet->StartingPort + PortSet->PortsToOversee); - ExAcquireFastMutex( &PortSet->Mutex ); + KeAcquireSpinLock( &PortSet->Lock, &OldIrql ); RtlClearBits( &PortSet->ProtoBitmap, Port - PortSet->StartingPort, 1 ); - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); } BOOLEAN AllocatePort( PPORT_SET PortSet, ULONG Port ) { BOOLEAN Clear; + KIRQL OldIrql; Port = htons(Port); @@ -55,32 +58,34 @@ Port -= PortSet->StartingPort; - ExAcquireFastMutex( &PortSet->Mutex ); + KeAcquireSpinLock( &PortSet->Lock, &OldIrql ); Clear = RtlAreBitsClear( &PortSet->ProtoBitmap, Port, 1 ); if( Clear ) RtlSetBits( &PortSet->ProtoBitmap, Port, 1 ); - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); return Clear; } ULONG AllocateAnyPort( PPORT_SET PortSet ) { ULONG AllocatedPort; + KIRQL OldIrql; - ExAcquireFastMutex( &PortSet->Mutex ); + KeAcquireSpinLock( &PortSet->Lock, &OldIrql ); AllocatedPort = RtlFindClearBits( &PortSet->ProtoBitmap, 1, 0 ); if( AllocatedPort != (ULONG)-1 ) { RtlSetBit( &PortSet->ProtoBitmap, AllocatedPort ); AllocatedPort += PortSet->StartingPort; - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); return htons(AllocatedPort); } - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); return -1; } ULONG AllocatePortFromRange( PPORT_SET PortSet, ULONG Lowest, ULONG Highest ) { ULONG AllocatedPort; + KIRQL OldIrql; if ((Lowest < PortSet->StartingPort) || (Highest >= PortSet->StartingPort + PortSet->PortsToOversee)) @@ -91,15 +96,15 @@ Lowest -= PortSet->StartingPort; Highest -= PortSet->StartingPort; - ExAcquireFastMutex( &PortSet->Mutex ); + KeAcquireSpinLock( &PortSet->Lock, &OldIrql ); AllocatedPort = RtlFindClearBits( &PortSet->ProtoBitmap, 1, Lowest ); if( AllocatedPort != (ULONG)-1 && AllocatedPort <= Highest) { RtlSetBit( &PortSet->ProtoBitmap, AllocatedPort ); AllocatedPort += PortSet->StartingPort; - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); return htons(AllocatedPort); } - ExReleaseFastMutex( &PortSet->Mutex ); + KeReleaseSpinLock( &PortSet->Lock, OldIrql ); return -1; }
14 years, 11 months
1
0
0
0
[sir_richard] 45005: Trap Handlers in C Patch 3 of X (Patch by Sir_Richard <ros.arm@reactos.org>): [NTOS]: Fix a bug in the assertion handler. [NTOS]: Implement page fault trap (14) in C instead of ASM. [NTOS]: Implement V8086 trap entry/exit, we were hitting these during page faults in Ke386CallBios for video reset during GUI boot.
by sir_richard@svn.reactos.org
Author: sir_richard Date: Fri Jan 8 19:21:47 2010 New Revision: 45005 URL:
http://svn.reactos.org/svn/reactos?rev=45005&view=rev
Log: Trap Handlers in C Patch 3 of X (Patch by Sir_Richard <ros.arm(a)reactos.org>): [NTOS]: Fix a bug in the assertion handler. [NTOS]: Implement page fault trap (14) in C instead of ASM. [NTOS]: Implement V8086 trap entry/exit, we were hitting these during page faults in Ke386CallBios for video reset during GUI boot. Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h trunk/reactos/ntoskrnl/ke/i386/trap.s trunk/reactos/ntoskrnl/ke/i386/traphdlr.c Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Fri Jan 8 19:21:47 2010 @@ -9,7 +9,6 @@ // // Debug Macros // -#if YDEBUG VOID NTAPI KiDumpTrapFrame(IN PKTRAP_FRAME TrapFrame) @@ -52,6 +51,7 @@ DPRINT1("V86Gs: %x\n", TrapFrame->V86Gs); } +#if YDEBUG FORCEINLINE VOID KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame) @@ -220,6 +220,18 @@ KiDispatchExceptionFromTrapFrame(Code, Address, 0, 0, 0, 0, TrapFrame); } +VOID +FORCEINLINE +KiDispatchException2Args(IN NTSTATUS Code, + IN ULONG_PTR Address, + IN ULONG P1, + IN ULONG P2, + IN PKTRAP_FRAME TrapFrame) +{ + /* Helper for exceptions with no arguments */ + KiDispatchExceptionFromTrapFrame(Code, Address, 2, P1, P2, 0, TrapFrame); +} + FORCEINLINE VOID KiTrapReturn(IN PKTRAP_FRAME TrapFrame) Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Fri Jan 8 19:21:47 2010 @@ -58,6 +58,10 @@ .globl _KiTrap8 .globl _KiTrap19 +/* System call code referenced from C code */ +.globl _CopyParams +.globl _ReadBatch + /* System call entrypoints: */ .globl _KiFastCallEntry .globl _KiSystemService @@ -193,7 +197,7 @@ /* Check if we should flush the User Batch */ xor ebx, ebx -ReadBatch: +_ReadBatch: or ebx, [ecx+TEB_GDI_BATCH_COUNT] jz NotWin32K @@ -239,7 +243,7 @@ cmp esi, _MmUserProbeAddress jnb AccessViolation -CopyParams: +_CopyParams: /* Copy the parameters */ rep movsd @@ -359,7 +363,7 @@ test byte ptr [ebp+KTRAP_FRAME_CS], MODE_MASK /* It's fine, go ahead with it */ - jz CopyParams + jz _CopyParams /* Caller sent invalid parameters, fail here */ mov eax, STATUS_ACCESS_VIOLATION @@ -1219,9 +1223,9 @@ test dword ptr [ebp+KTRAP_FRAME_CS], MODE_MASK jnz UserModeGpf - /* Check if we have a VDM alert */ - cmp dword ptr PCR[KPCR_VDM_ALERT], 0 - jnz VdmAlertGpf + ///* Check if we have a VDM alert */ + //cmp dword ptr PCR[KPCR_VDM_ALERT], 0 // BUGBUG: Add this back later + //jnz VdmAlertGpf /* Check for GPF during GPF */ mov eax, [ebp+KTRAP_FRAME_EIP] @@ -1607,203 +1611,7 @@ UNHANDLED_V86_PATH .endfunc -.func KiTrap14 -TRAP_FIXUPS kite_a, kite_t, DoFixupV86, DoNotFixupAbios -_KiTrap14: - - /* Enter trap */ - TRAP_PROLOG kite_a, kite_t - - /* Check if we have a VDM alert */ - cmp dword ptr PCR[KPCR_VDM_ALERT], 0 - jnz VdmAlertGpf - - /* Get the current thread */ - mov edi, PCR[KPCR_CURRENT_THREAD] - - /* Get the stack address of the frame */ - lea eax, [esp+KTRAP_FRAME_LENGTH+NPX_FRAME_LENGTH] - sub eax, [edi+KTHREAD_INITIAL_STACK] - jz NoFixUp - - /* This isn't the base frame, check if it's the second */ - cmp eax, -KTRAP_FRAME_EFLAGS - jb NoFixUp - - /* Check if we have a TEB */ - mov eax, PCR[KPCR_TEB] - or eax, eax - jle NoFixUp - - /* Fixup the frame */ - call _KiFixupFrame - - /* Save CR2 */ -NoFixUp: - mov edi, cr2 - - /* Check if this processor has the cmpxchg8b lock errata */ - cmp byte ptr _KiI386PentiumLockErrataPresent, 0 - jnz HandleLockErrata - -NotLockErrata: - /* HACK: Handle page faults with interrupts disabled */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_INTERRUPT_MASK - je HandlePf - - /* Enable interrupts and check if we got here with interrupts disabled */ - sti -#ifdef HACK_ABOVE_FIXED - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_INTERRUPT_MASK - jz IllegalState -#endif - -HandlePf: - /* Send trap frame and check if this is kernel-mode or usermode */ - push ebp - mov eax, [ebp+KTRAP_FRAME_CS] - and eax, MODE_MASK - push eax - - /* Send faulting address and check if this is read or write */ - push edi - mov eax, [ebp+KTRAP_FRAME_ERROR_CODE] - and eax, 1 - push eax - - /* Call the access fault handler */ - call _MmAccessFault@16 - test eax, eax - jl AccessFail - - /* Access fault handled, return to caller */ - jmp _Kei386EoiHelper@0 - -AccessFail: - /* First check if this is a fault in the S-LIST functions */ - mov ecx, offset _ExpInterlockedPopEntrySListFault@0 - cmp [ebp+KTRAP_FRAME_EIP], ecx - jz SlistFault - - /* Check if this is a fault in the syscall handler */ - mov ecx, offset CopyParams - cmp [ebp+KTRAP_FRAME_EIP], ecx - jz SysCallCopyFault - mov ecx, offset ReadBatch - cmp [ebp+KTRAP_FRAME_EIP], ecx - jnz CheckVdmPf - - /* FIXME: TODO */ - UNHANDLED_PATH "SYSENTER Fault" - jmp _Kei386EoiHelper@0 - -SysCallCopyFault: - /* FIXME: TODO */ - UNHANDLED_PATH "SYSENTER Fault" - jmp _Kei386EoiHelper@0 - - /* Check if the fault occured in a V86 mode */ -CheckVdmPf: - mov ecx, [ebp+KTRAP_FRAME_ERROR_CODE] - shr ecx, 1 - and ecx, 1 - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz VdmPF - - /* Check if the fault occured in a VDM */ - mov esi, PCR[KPCR_CURRENT_THREAD] - mov esi, [esi+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [esi+EPROCESS_VDM_OBJECTS], 0 - jz CheckStatus - - /* Check if we this was in kernel-mode */ - test byte ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz CheckStatus - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jz CheckStatus - -VdmPF: - /* FIXME: TODO */ - UNHANDLED_V86_PATH - - /* Save EIP and check what kind of status failure we got */ -CheckStatus: - mov esi, [ebp+KTRAP_FRAME_EIP] - cmp eax, STATUS_ACCESS_VIOLATION - je AccessViol - cmp eax, STATUS_GUARD_PAGE_VIOLATION - je SpecialCode - cmp eax, STATUS_STACK_OVERFLOW - je SpecialCode - - /* Setup an in-page exception to dispatch */ - mov edx, ecx - mov ebx, esi - mov esi, edi - mov ecx, 3 - mov edi, eax - mov eax, STATUS_IN_PAGE_ERROR - call _CommonDispatchException - -AccessViol: - /* Use more proper status code */ - mov eax, KI_EXCEPTION_ACCESS_VIOLATION - -SpecialCode: - /* Setup a normal page fault exception */ - mov ebx, esi - mov edx, ecx - mov esi, edi - jmp _DispatchTwoParam - -SlistFault: - /* FIXME: TODO */ - UNHANDLED_PATH "SLIST Fault" - -IllegalState: - - /* This is completely illegal, bugcheck the system */ - push ebp - push esi - push ecx - push eax - push edi - push IRQL_NOT_LESS_OR_EQUAL - call _KeBugCheckWithTf@24 - -VdmAlertGpf: - - /* FIXME: NOT SUPPORTED */ - UNHANDLED_V86_PATH - -HandleLockErrata: - - /* Fail if this isn't a write fault */ - test word ptr [ebp+KTRAP_FRAME_ERROR_CODE], 0x4 - jnz NotLockErrata - - /* Also make sure the page fault is for IDT entry 6 */ - mov eax, PCR[KPCR_IDT] - add eax, 0x30 - cmp eax, edi - jne NotLockErrata - - /* - * This is a write fault to the Invalid Opcode handler entry. - * We assume this is the lock errata and not a real write fault. - */ - - /* Clear the error code */ - and dword ptr [ebp+KTRAP_FRAME_ERROR_CODE], 0 - - /* Check if this happened in V86 mode */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz VdmOpCodeFault - - /* Dispatch this to the invalid opcode handler */ - jmp DispatchLockErrata -.endfunc - +GENERATE_TRAP_HANDLER KiTrap14, 0 GENERATE_TRAP_HANDLER KiTrap0F, 1 .func KiTrap16 Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Fri Jan 8 19:21:47 2010 @@ -43,13 +43,8 @@ } /* Check if this was a V8086 trap */ - if (TrapFrame->EFlags & EFLAGS_V86_MASK) - { - /* Not handled yet */ - UNIMPLEMENTED; - while (TRUE); - } - + if (TrapFrame->EFlags & EFLAGS_V86_MASK) KiTrapReturn(TrapFrame); + /* Check if the trap frame was edited */ if (!(TrapFrame->SegCs & FRAME_EDITED)) { @@ -155,8 +150,11 @@ /* Check for V86 mode */ if (TrapFrame->EFlags & EFLAGS_V86_MASK) { - UNIMPLEMENTED; - while (TRUE); + /* Restore V8086 segments into Protected Mode segments */ + TrapFrame->SegFs = TrapFrame->V86Fs; + TrapFrame->SegGs = TrapFrame->V86Gs; + TrapFrame->SegDs = TrapFrame->V86Ds; + TrapFrame->SegEs = TrapFrame->V86Es; } /* Clear direction flag */ @@ -404,6 +402,130 @@ VOID FASTCALL +KiTrap14Handler(IN PKTRAP_FRAME TrapFrame) +{ + PKTHREAD Thread; + ULONG_PTR Cr2; + NTSTATUS Status; + extern VOID NTAPI ExpInterlockedPopEntrySListFault(VOID); + extern VOID CopyParams(VOID); + extern VOID ReadBatch(VOID); + + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for custom VDM trap handler */ + if (KeGetPcr()->VdmAlert) + { + /* Not implemented */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if this is the base frame */ + Thread = KeGetCurrentThread(); + if (KeGetTrapFrame(Thread) != TrapFrame) + { + /* It isn't, check if this is a second nested frame */ + if (((ULONG_PTR)KeGetTrapFrame(Thread) - (ULONG_PTR)TrapFrame) <= + FIELD_OFFSET(KTRAP_FRAME, EFlags)) + { + /* The stack is somewhere in between frames, we need to fix it */ + UNIMPLEMENTED; + while (TRUE); + } + } + + /* Save CR2 */ + Cr2 = __readcr2(); + + /* Check for Pentium LOCK errata */ + if (KiI386PentiumLockErrataPresent) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + + /* HACK: Check if interrupts are disabled and enable them */ + if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) + { + /* Enable interupts */ + _enable(); +#ifdef HACK_ABOVE_FIXED + if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) + { + /* This is illegal */ + KeBugCheckWithTf(IRQL_NOT_LESS_OR_EQUAL, + Cr2, + -1, + TrapFrame->ErrCode & 1, + TrapFrame->Eip, + TrapFrame); + } +#endif + } + + /* Call the access fault handler */ + Status = MmAccessFault(TrapFrame->ErrCode & 1, + (PVOID)Cr2, + TrapFrame->SegCs & MODE_MASK, + TrapFrame); + if (Status == STATUS_SUCCESS) KiEoiHelper(TrapFrame); + + /* Check for S-LIST fault */ + if (TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check for syscall fault */ + if ((TrapFrame->Eip == (ULONG_PTR)CopyParams) || + (TrapFrame->Eip == (ULONG_PTR)ReadBatch)) + { + /* Not yet implemented */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Either kernel or user trap (non VDM) so dispatch exception */ + if (Status == STATUS_ACCESS_VIOLATION) + { + /* This status code is repurposed so we can recognize it later */ + KiDispatchException2Args(KI_EXCEPTION_ACCESS_VIOLATION, + TrapFrame->Eip, + TrapFrame->ErrCode & 1, + Cr2, + TrapFrame); + } + else if ((Status == STATUS_GUARD_PAGE_VIOLATION) || + (Status == STATUS_STACK_OVERFLOW)) + { + /* These faults only have two parameters */ + KiDispatchException2Args(Status, + TrapFrame->Eip, + TrapFrame->ErrCode & 1, + Cr2, + TrapFrame); + } + + /* Only other choice is an in-page error, with 3 parameters */ + KiDispatchExceptionFromTrapFrame(STATUS_IN_PAGE_ERROR, + TrapFrame->Eip, + 3, + TrapFrame->ErrCode & 1, + Cr2, + Status, + TrapFrame); +} + +VOID +FASTCALL KiTrap0FHandler(IN PKTRAP_FRAME TrapFrame) { /* Save trap frame */ @@ -433,8 +555,8 @@ /* Save trap frame */ KiEnterTrap(TrapFrame); - /* Increment EIP to skip the INT2C instruction (2 bytes, not 1 like INT3) */ - TrapFrame->Eip += 2; + /* Decrement EIP to point to the INT2C instruction (2 bytes, not 1 like INT3) */ + TrapFrame->Eip -= 2; /* Dispatch the exception */ KiDispatchException0Args(STATUS_ASSERTION_FAILURE,
14 years, 11 months
1
0
0
0
[cgutman] 45004: - Add locking to ICMPSendDatagram
by cgutman@svn.reactos.org
Author: cgutman Date: Fri Jan 8 19:10:05 2010 New Revision: 45004 URL:
http://svn.reactos.org/svn/reactos?rev=45004&view=rev
Log: - Add locking to ICMPSendDatagram Modified: branches/aicom-network-branch/lib/drivers/ip/network/icmp.c Modified: branches/aicom-network-branch/lib/drivers/ip/network/icmp.c URL:
http://svn.reactos.org/svn/reactos/branches/aicom-network-branch/lib/driver…
============================================================================== --- branches/aicom-network-branch/lib/drivers/ip/network/icmp.c [iso-8859-1] (original) +++ branches/aicom-network-branch/lib/drivers/ip/network/icmp.c [iso-8859-1] Fri Jan 8 19:10:05 2010 @@ -159,6 +159,7 @@ USHORT RemotePort; NTSTATUS Status; PNEIGHBOR_CACHE_ENTRY NCE; + KIRQL OldIrql; TI_DbgPrint(MID_TRACE,("Sending Datagram(%x %x %x %d)\n", AddrFile, ConnInfo, BufferData, DataSize)); @@ -177,6 +178,8 @@ } TI_DbgPrint(MID_TRACE,("About to get route to destination\n")); + + LockObject(AddrFile, &OldIrql); LocalAddress = AddrFile->Address; if (AddrIsUnspecified(&LocalAddress)) @@ -186,14 +189,20 @@ * interface we're sending over */ if(!(NCE = RouteGetRouteToDestination( &RemoteAddress ))) + { + UnlockObject(AddrFile, OldIrql); return STATUS_NETWORK_UNREACHABLE; + } LocalAddress = NCE->Interface->Unicast; } else { if(!(NCE = NBLocateNeighbor( &LocalAddress ))) + { + UnlockObject(AddrFile, OldIrql); return STATUS_INVALID_PARAMETER; + } } Status = PrepareICMPPacket( NCE->Interface, @@ -203,17 +212,23 @@ DataSize ); if( !NT_SUCCESS(Status) ) + { + UnlockObject(AddrFile, OldIrql); return Status; + } TI_DbgPrint(MID_TRACE,("About to send datagram\n")); if (!NT_SUCCESS(Status = IPSendDatagram( &Packet, NCE, ICMPSendPacketComplete, NULL ))) { + UnlockObject(AddrFile, OldIrql); FreeNdisPacket(Packet.NdisPacket); return Status; } TI_DbgPrint(MID_TRACE,("Leaving\n")); + + UnlockObject(AddrFile, OldIrql); return STATUS_SUCCESS; }
14 years, 11 months
1
0
0
0
[khornicek] 45003: - fix build, spotted by Stefan
by khornicek@svn.reactos.org
Author: khornicek Date: Fri Jan 8 17:06:33 2010 New Revision: 45003 URL:
http://svn.reactos.org/svn/reactos?rev=45003&view=rev
Log: - fix build, spotted by Stefan Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Fri Jan 8 17:06:33 2010 @@ -239,4 +239,4 @@ : "r"(TrapFrame), "i"(KTRAP_FRAME_LENGTH - KTRAP_FRAME_PREVIOUS_MODE) : "%esp" ); -} +}
14 years, 11 months
1
0
0
0
[ros-arm-bringup] 45002: Trap Handlers in C Patch 2 of X (Patch by Sir_Richard <ros.arm@reactos.org>): [NTOS]: Convert Trap 0, 1, 3, 4, 5, 8, 10, 11, 12, 15, 17, 2C (Assertion) and 2D (Debug) to C. Tested INT3 and still works as expected, and obviously DbgPrint is still functionning (0x2D). The other traps are mainly programming errors such as bound overflow or integer overflow, so we need some test cases, but they should work. Note the 3-4 lines of C for what used to be dozens of ASM lines. [NT
by ros-arm-bringup@svn.reactos.org
Author: ros-arm-bringup Date: Fri Jan 8 16:16:00 2010 New Revision: 45002 URL:
http://svn.reactos.org/svn/reactos?rev=45002&view=rev
Log: Trap Handlers in C Patch 2 of X (Patch by Sir_Richard <ros.arm(a)reactos.org>): [NTOS]: Convert Trap 0, 1, 3, 4, 5, 8, 10, 11, 12, 15, 17, 2C (Assertion) and 2D (Debug) to C. Tested INT3 and still works as expected, and obviously DbgPrint is still functionning (0x2D). The other traps are mainly programming errors such as bound overflow or integer overflow, so we need some test cases, but they should work. Note the 3-4 lines of C for what used to be dozens of ASM lines. [NTOS]: Fix infinite loop in KiCheckForApcDelivery. Stefan Ginsberg: Could you please implement the relevant Extended GCC ASM into MSVC? Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h trunk/reactos/ntoskrnl/ke/i386/trap.s trunk/reactos/ntoskrnl/ke/i386/traphdlr.c Modified: trunk/reactos/ntoskrnl/include/internal/trap_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Fri Jan 8 16:16:00 2010 @@ -194,19 +194,18 @@ Thread->Alerted[KernelMode] = FALSE; /* Are there pending user APCs? */ - if (Thread->ApcState.UserApcPending) - { - /* Raise to APC level and enable interrupts */ - OldIrql = KfRaiseIrql(APC_LEVEL); - _enable(); - - /* Deliver APCs */ - KiDeliverApc(UserMode, NULL, TrapFrame); - - /* Restore IRQL and disable interrupts once again */ - KfLowerIrql(OldIrql); - _disable(); - } + if (!Thread->ApcState.UserApcPending) break; + + /* Raise to APC level and enable interrupts */ + OldIrql = KfRaiseIrql(APC_LEVEL); + _enable(); + + /* Deliver APCs */ + KiDeliverApc(UserMode, NULL, TrapFrame); + + /* Restore IRQL and disable interrupts once again */ + KfLowerIrql(OldIrql); + _disable(); } } } Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?re…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/trap.s [iso-8859-1] Fri Jan 8 16:16:00 2010 @@ -53,6 +53,11 @@ idt _KiTrap0F, INT_32_DPL0 /* INT 2F: RESERVED */ GENERATE_IDT_STUBS /* INT 30-FF: UNEXPECTED INTERRUPTS */ +/* Trap handlers referenced from C code */ +.globl _KiTrap2 +.globl _KiTrap8 +.globl _KiTrap19 + /* System call entrypoints: */ .globl _KiFastCallEntry .globl _KiSystemService @@ -464,50 +469,8 @@ /* FIXME: TODO */ UNHANDLED_PATH "ABIOS Exit" -.func KiRaiseAssertion -TRAP_FIXUPS kira_a, kira_t, DoFixupV86, DoFixupAbios -_KiRaiseAssertion: - - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kira_a, kira_t - - /* - * Modify EIP so it points to the faulting instruction and set it as the - * exception address. Note that the 'int 2C' instruction used for this call - * is 2 bytes long as opposed to 1 byte 'int 3'. - */ - sub dword ptr [ebp+KTRAP_FRAME_EIP], 2 - mov ebx, [ebp+KTRAP_FRAME_EIP] - - /* Raise an assertion failure */ - mov eax, STATUS_ASSERTION_FAILURE - jmp _DispatchNoParam -.endfunc - -.func KiDebugService -TRAP_FIXUPS kids_a, kids_t, DoFixupV86, DoFixupAbios -_KiDebugService: - - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kids_a, kids_t - - /* Increase EIP so we skip the INT3 */ - inc dword ptr [ebp+KTRAP_FRAME_EIP] - - /* Call debug service dispatcher */ - mov eax, [ebp+KTRAP_FRAME_EAX] - mov ecx, [ebp+KTRAP_FRAME_ECX] - mov edx, [ebp+KTRAP_FRAME_EDX] - - /* Jump to INT3 handler */ - jmp PrepareInt3 -.endfunc +GENERATE_TRAP_HANDLER KiRaiseAssertion, 1 +GENERATE_TRAP_HANDLER KiDebugService, 1 .func NtRaiseException@12 _NtRaiseException@12: @@ -704,91 +667,9 @@ UNHANDLED_PATH "Trap Frame Fixup" .endfunc -.func KiTrap0 -TRAP_FIXUPS kit0_a, kit0_t, DoFixupV86, DoNotFixupAbios -_KiTrap0: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit0_a, kit0_t - - /* Check for V86 */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86Int0 - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz SendException - - /* Check the old mode */ - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jne VdmCheck - -SendException: - /* Re-enable interrupts for user-mode and send the exception */ - sti - mov eax, STATUS_INTEGER_DIVIDE_BY_ZERO - mov ebx, [ebp+KTRAP_FRAME_EIP] - jmp _DispatchNoParam - -VdmCheck: - /* Check if this is a VDM process */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0 - jz SendException - - /* We don't support this yet! */ -V86Int0: - /* FIXME: TODO */ - UNHANDLED_V86_PATH -.endfunc - -.func KiTrap1 -TRAP_FIXUPS kit1_a, kit1_t, DoFixupV86, DoNotFixupAbios -_KiTrap1: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit1_a, kit1_t - - /* Check for V86 */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86Int1 - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz PrepInt1 - - /* Check the old mode */ - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jne V86Int1 - -EnableInterrupts: - /* Enable interrupts for user-mode */ - sti - -PrepInt1: - /* Prepare the exception */ - and dword ptr [ebp+KTRAP_FRAME_EFLAGS], ~EFLAGS_TF - mov ebx, [ebp+KTRAP_FRAME_EIP] - mov eax, STATUS_SINGLE_STEP - jmp _DispatchNoParam - -V86Int1: - /* Check if this is a VDM process */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0 - jz EnableInterrupts - - /* We don't support VDM! */ - UNHANDLED_V86_PATH -.endfunc - -.globl _KiTrap2 +GENERATE_TRAP_HANDLER KiTrap0, 1 +GENERATE_TRAP_HANDLER KiTrap1, 1 + .func KiTrap2 _KiTrap2: // @@ -811,148 +692,9 @@ jmp _KiSystemFatalException // Bugcheck helper .endfunc -.func KiTrap3 -TRAP_FIXUPS kit3_a, kit3_t, DoFixupV86, DoNotFixupAbios -_KiTrap3: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit3_a, kit3_t - - /* - * Set the special code to indicate that this is a software breakpoint - * and not a debug service call - */ - mov eax, BREAKPOINT_BREAK - - /* Check for V86 */ -PrepareInt3: - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86Int3 - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz PrepInt3 - - /* Check the old mode */ - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jne V86Int3 - -EnableInterrupts3: - /* Enable interrupts for user-mode */ - sti - -PrepInt3: - - /* Prepare the exception */ - mov esi, ecx - mov edi, edx - mov edx, eax - - /* Setup EIP, NTSTATUS and parameter count, then dispatch */ - mov ebx, [ebp+KTRAP_FRAME_EIP] - dec ebx - mov ecx, 3 - mov eax, STATUS_BREAKPOINT - call _CommonDispatchException - -V86Int3: - /* Check if this is a VDM process */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0 - jz EnableInterrupts3 - - /* We don't support VDM! */ - UNHANDLED_V86_PATH -.endfunc - -.func KiTrap4 -TRAP_FIXUPS kit4_a, kit4_t, DoFixupV86, DoNotFixupAbios -_KiTrap4: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit4_a, kit4_t - - /* Check for V86 */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86Int4 - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz SendException4 - - /* Check the old mode */ - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jne VdmCheck4 - -SendException4: - /* Re-enable interrupts for user-mode and send the exception */ - sti - mov eax, STATUS_INTEGER_OVERFLOW - mov ebx, [ebp+KTRAP_FRAME_EIP] - dec ebx - jmp _DispatchNoParam - -VdmCheck4: - /* Check if this is a VDM process */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0 - jz SendException4 - - /* We don't support this yet! */ -V86Int4: - UNHANDLED_V86_PATH -.endfunc - -.func KiTrap5 -TRAP_FIXUPS kit5_a, kit5_t, DoFixupV86, DoNotFixupAbios -_KiTrap5: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit5_a, kit5_t - - /* Check for V86 */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86Int5 - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jnz CheckMode - - /* It did, and this should never happen */ - mov eax, 5 - jmp _KiSystemFatalException - - /* Check the old mode */ -CheckMode: - cmp word ptr [ebp+KTRAP_FRAME_CS], KGDT_R3_CODE + RPL_MASK - jne VdmCheck5 - - /* Re-enable interrupts for user-mode and send the exception */ -SendException5: - sti - mov eax, STATUS_ARRAY_BOUNDS_EXCEEDED - mov ebx, [ebp+KTRAP_FRAME_EIP] - jmp _DispatchNoParam - -VdmCheck5: - /* Check if this is a VDM process */ - mov ebx, PCR[KPCR_CURRENT_THREAD] - mov ebx, [ebx+KTHREAD_APCSTATE_PROCESS] - cmp dword ptr [ebx+EPROCESS_VDM_OBJECTS], 0 - jz SendException5 - - /* We don't support this yet! */ -V86Int5: - UNHANDLED_V86_PATH -.endfunc +GENERATE_TRAP_HANDLER KiTrap3, 1 +GENERATE_TRAP_HANDLER KiTrap4, 1 +GENERATE_TRAP_HANDLER KiTrap5, 1 .func KiTrap6 TRAP_FIXUPS kit6_a, kit6_t, DoFixupV86, DoNotFixupAbios @@ -1380,80 +1122,11 @@ call _KeBugCheckEx@20 .endfunc -.globl _KiTrap8 -.func KiTrap8 -_KiTrap8: - /* Can't really do too much */ - mov eax, 8 - jmp _KiSystemFatalException -.endfunc - -.func KiTrap9 -TRAP_FIXUPS kit9_a, kit9_t, DoFixupV86, DoNotFixupAbios -_KiTrap9: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit9_a, kit9_t - - /* Enable interrupts and bugcheck */ - sti - mov eax, 9 - jmp _KiSystemFatalException -.endfunc - -.func KiTrap10 -TRAP_FIXUPS kita_a, kita_t, DoFixupV86, DoNotFixupAbios -_KiTrap10: - /* Enter trap */ - TRAP_PROLOG kita_a, kita_t - - /* Check for V86 */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAGS_V86_MASK - jnz V86IntA - - /* Check if the frame was from kernelmode */ - test word ptr [ebp+KTRAP_FRAME_CS], MODE_MASK - jz Fatal - -V86IntA: - /* Check if OF was set during iretd */ - test dword ptr [ebp+KTRAP_FRAME_EFLAGS], EFLAG_ZERO - sti - jz Fatal - - /* It was, just mask it out */ - and dword ptr [ebp+KTRAP_FRAME_EFLAGS], ~EFLAG_ZERO - jmp _Kei386EoiHelper@0 - -Fatal: - /* TSS failure for some other reason: crash */ - mov eax, 10 - jmp _KiSystemFatalException -.endfunc - -.func KiTrap11 -TRAP_FIXUPS kitb_a, kitb_t, DoFixupV86, DoNotFixupAbios -_KiTrap11: - /* Enter trap */ - TRAP_PROLOG kitb_a, kitb_t - - /* FIXME: ROS Doesn't handle segment faults yet */ - mov eax, 11 - jmp _KiSystemFatalException -.endfunc - -.func KiTrap12 -TRAP_FIXUPS kitc_a, kitc_t, DoFixupV86, DoNotFixupAbios -_KiTrap12: - /* Enter trap */ - TRAP_PROLOG kitc_a, kitc_t - - /* FIXME: ROS Doesn't handle stack faults yet */ - mov eax, 12 - jmp _KiSystemFatalException -.endfunc +GENERATE_TRAP_HANDLER KiTrap8, 0 +GENERATE_TRAP_HANDLER KiTrap9, 1 +GENERATE_TRAP_HANDLER KiTrap10, 0 +GENERATE_TRAP_HANDLER KiTrap11, 0 +GENERATE_TRAP_HANDLER KiTrap12, 0 .func KiTrapExceptHandler _KiTrapExceptHandler: @@ -2131,20 +1804,7 @@ jmp DispatchLockErrata .endfunc -.func KiTrap0F -TRAP_FIXUPS kitf_a, kitf_t, DoFixupV86, DoNotFixupAbios -_KiTrap0F: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kitf_a, kitf_t - sti - - /* Raise a fatal exception */ - mov eax, 15 - jmp _KiSystemFatalException -.endfunc +GENERATE_TRAP_HANDLER KiTrap0F, 1 .func KiTrap16 TRAP_FIXUPS kit10_a, kit10_t, DoFixupV86, DoNotFixupAbios @@ -2172,21 +1832,8 @@ jmp _Kei386EoiHelper@0 .endfunc -.func KiTrap17 -TRAP_FIXUPS kit11_a, kit11_t, DoFixupV86, DoNotFixupAbios -_KiTrap17: - /* Push error code */ - push 0 - - /* Enter trap */ - TRAP_PROLOG kit11_a, kit11_t - - /* FIXME: ROS Doesn't handle alignment faults yet */ - mov eax, 17 - jmp _KiSystemFatalException -.endfunc - -.globl _KiTrap19 +GENERATE_TRAP_HANDLER KiTrap17, 1 + .func KiTrap19 TRAP_FIXUPS kit19_a, kit19_t, DoFixupV86, DoNotFixupAbios _KiTrap19: @@ -2358,7 +2005,6 @@ push TRAP_CAUSE_UNKNOWN call _KeBugCheckWithTf@24 .endfunc - .func KiSystemFatalException _KiSystemFatalException: Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Fri Jan 8 16:16:00 2010 @@ -228,4 +228,232 @@ KiEoiHelper(TrapFrame); } +/* TRAP HANDLERS **************************************************************/ + +VOID +FASTCALL +KiDebugHandler(IN PKTRAP_FRAME TrapFrame, + IN ULONG Parameter1, + IN ULONG Parameter2, + IN ULONG Parameter3) +{ + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Enable interrupts if the trap came from user-mode */ + if (KiUserTrap(TrapFrame)) _enable(); + + /* Dispatch the exception */ + KiDispatchExceptionFromTrapFrame(STATUS_BREAKPOINT, + TrapFrame->Eip - 1, + 3, + Parameter1, + Parameter2, + Parameter3, + TrapFrame); +} + +VOID +FASTCALL +KiTrap0Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Enable interrupts */ + _enable(); + + /* Dispatch the exception */ + KiDispatchException0Args(STATUS_INTEGER_DIVIDE_BY_ZERO, + TrapFrame->Eip, + TrapFrame); +} + +VOID +FASTCALL +KiTrap1Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Enable interrupts if the trap came from user-mode */ + if (KiUserTrap(TrapFrame)) _enable(); + + /* Mask out trap flag and dispatch the exception */ + TrapFrame->EFlags &= ~EFLAGS_TF; + KiDispatchException0Args(STATUS_SINGLE_STEP, + TrapFrame->Eip, + TrapFrame); +} + +VOID +FASTCALL +KiTrap3Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Continue with the common handler */ + KiDebugHandler(TrapFrame, BREAKPOINT_BREAK, 0, 0); +} + +VOID +FASTCALL +KiTrap4Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Enable interrupts */ + _enable(); + + /* Dispatch the exception */ + KiDispatchException0Args(STATUS_INTEGER_OVERFLOW, + TrapFrame->Eip - 1, + TrapFrame); +} + +VOID +FASTCALL +KiTrap5Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Check for kernel-mode fault */ + if (!KiUserTrap(TrapFrame)) KiSystemFatalException(EXCEPTION_BOUND_CHECK, TrapFrame); + + /* Enable interrupts */ + _enable(); + + /* Dispatch the exception */ + KiDispatchException0Args(STATUS_ARRAY_BOUNDS_EXCEEDED, + TrapFrame->Eip, + TrapFrame); +} + +VOID +FASTCALL +KiTrap8Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* FIXME: Not handled */ + KiSystemFatalException(EXCEPTION_DOUBLE_FAULT, TrapFrame); +} + +VOID +FASTCALL +KiTrap9Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Enable interrupts and kill the system */ + _enable(); + KiSystemFatalException(EXCEPTION_NPX_OVERRUN, TrapFrame); +} + +VOID +FASTCALL +KiTrap10Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Check for VDM trap */ + ASSERT((KiVdmTrap(TrapFrame)) == FALSE); + + /* Kill the system */ + KiSystemFatalException(EXCEPTION_INVALID_TSS, TrapFrame); +} + +VOID +FASTCALL +KiTrap11Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* FIXME: Kill the system */ + UNIMPLEMENTED; + KiSystemFatalException(EXCEPTION_SEGMENT_NOT_PRESENT, TrapFrame); +} + +VOID +FASTCALL +KiTrap12Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* FIXME: Kill the system */ + UNIMPLEMENTED; + KiSystemFatalException(EXCEPTION_STACK_FAULT, TrapFrame); +} + +VOID +FASTCALL +KiTrap0FHandler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* FIXME: Kill the system */ + UNIMPLEMENTED; + KiSystemFatalException(EXCEPTION_RESERVED_TRAP, TrapFrame); +} + +VOID +FASTCALL +KiTrap17Handler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Enable interrupts and kill the system */ + _enable(); + KiSystemFatalException(EXCEPTION_ALIGNMENT_CHECK, TrapFrame); +} + +VOID +FASTCALL +KiRaiseAssertionHandler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Increment EIP to skip the INT2C instruction (2 bytes, not 1 like INT3) */ + TrapFrame->Eip += 2; + + /* Dispatch the exception */ + KiDispatchException0Args(STATUS_ASSERTION_FAILURE, + TrapFrame->Eip, + TrapFrame); +} + +VOID +FASTCALL +KiDebugServiceHandler(IN PKTRAP_FRAME TrapFrame) +{ + /* Save trap frame */ + KiEnterTrap(TrapFrame); + + /* Increment EIP to skip the INT3 instruction */ + TrapFrame->Eip++; + + /* Continue with the common handler */ + KiDebugHandler(TrapFrame, TrapFrame->Eax, TrapFrame->Ecx, TrapFrame->Edx); +} + /* EOF */
14 years, 11 months
1
0
0
0
[martinf] 45001: define _tcscpy_s and _tsplitpath_s again for native VC++ builds
by martinf@svn.reactos.org
Author: martinf Date: Fri Jan 8 16:10:50 2010 New Revision: 45001 URL:
http://svn.reactos.org/svn/reactos?rev=45001&view=rev
Log: define _tcscpy_s and _tsplitpath_s again for native VC++ builds Modified: trunk/reactos/base/shell/explorer/utility/utility.h Modified: trunk/reactos/base/shell/explorer/utility/utility.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] Fri Jan 8 16:10:50 2010 @@ -194,10 +194,20 @@ #define strcpy_s(d, l, s) strcpy(d, s) #define wcscpy_s(d, l, s) wcscpy(d, s) #define wcsncpy_s(d, l, s, n) wcsncpy(d, s, n) + +#if defined(_tcscpy) && !defined(_tcscpy_s) +#define _tcscpy_s(d, l, s) _tcscpy(d, s) +#endif + +#if defined(_tsplitpath) && !defined(_tsplitpath_s) +#define _tsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _tsplitpath(f, d, p, n, e) +#else +#define _wsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _wsplitpath(f, d, p, n, e) +#define _splitpath_s(f, d,dl, p,pl, n,nl, e,el) _splitpath(f, d, p, n, e) +#endif + #define _stprintf_s1(b, l, f, p1) _stprintf(b, f, p1) #define _stprintf_s2(b, l, f, p1,p2) _stprintf(b, f, p1,p2) -#define _wsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _wsplitpath(f, d, p, n, e) -#define _splitpath_s(f, d,dl, p,pl, n,nl, e,el) _splitpath(f, d, p, n, e) #endif // __STDC_WANT_SECURE_LIB__
14 years, 11 months
1
0
0
0
[ros-arm-bringup] 45000: Trap Handlers in C Patch 1 of X (Patch by Sir_Richard <ros.arm@reactos.org>): [NTOS]: The kernel normally does not save FPU state during Ring 0 transitions since the FPU should not be used. The one exception is when a kernel debugger is attached. Unfortunately, the latter check in ReactOS results in even "print on the serial line" to count as "debugger attached", and thus FPU state was almost always saved, slowing down traps significantly. [NTOS]: The kernel also does no
by ros-arm-bringup@svn.reactos.org
Author: ros-arm-bringup Date: Fri Jan 8 16:04:19 2010 New Revision: 45000 URL:
http://svn.reactos.org/svn/reactos?rev=45000&view=rev
Log: Trap Handlers in C Patch 1 of X (Patch by Sir_Richard <ros.arm(a)reactos.org>): [NTOS]: The kernel normally does not save FPU state during Ring 0 transitions since the FPU should not be used. The one exception is when a kernel debugger is attached. Unfortunately, the latter check in ReactOS results in even "print on the serial line" to count as "debugger attached", and thus FPU state was almost always saved, slowing down traps significantly. [NTOS]: The kernel also does not typically save DRx (debug) registers unless they were in use. During an exception dispatch, they are zeroed out, and later during trap exit, if any debug register is set, DR7 is updated to enable that hardware breakpoint. Unfortunately, the code to clear the debug registers had a bug: DR2 was never cleared. Because DR2 ended up being a random stack value during trap frame generation, this caused a bogus address to be added to DR2, and DR7 would then enable the 2nd hardware breakpoint. This caused the kernel to always save DRx state, which is slow, and worse, could cause random hardware breakpoints to fire. [NTOS]: Start implementing trap handling in C. ASM trap handlers will now only be 5 lines of assembly including a function call to a C handler. All C handling code uses maximum two arguments and is all FASTCALL for efficiency. [NTOS]: Implement C versions of TRAP_PROLOG and TRAP_EPILOG. Implement C version of Ki386EoiHelper. Implement C version of CommonDispatchException (and helper) and KiFatalSystemException. Implement C version of CHECK_FOR_APC_DELIVER. Implement trap debugging checks as a separate entity instead of always doing them. [NTOS]: Add missing intrinsics for DS/ES/GS segment query. The kernel is now ready for some trap handling to be done in C. Due to the FPU/Debug fixes and relaxation of paranoid debug checks, the C code will likely be faster than the original assembly. Added: trunk/reactos/ntoskrnl/include/internal/trap_x.h (with props) trunk/reactos/ntoskrnl/ke/i386/traphdlr.c (with props) Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S trunk/reactos/ntoskrnl/include/internal/i386/intrin_i.h trunk/reactos/ntoskrnl/include/internal/ke.h trunk/reactos/ntoskrnl/ke/i386/exp.c trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -221,6 +221,28 @@ .endm // +// @name GENERATE_TRAP_HANDLER +// +// This macro creates a kernel trap handler. +// +// @param None. +// +// @remark None. +// +.macro GENERATE_TRAP_HANDLER Name, ErrorCode +.func Name +_&Name: + .if \ErrorCode + push 0 + .endif + pushad + sub esp, KTRAP_FRAME_LENGTH - KTRAP_FRAME_PREVIOUS_MODE + mov ecx, esp + call @&Name&Handler@4 +.endfunc +.endm + +// // @name GENERATE_HAL_INT_HANDLER // // This macro creates a HAL hardware interrupt handler. Modified: trunk/reactos/ntoskrnl/include/internal/i386/intrin_i.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/i386/intrin_i.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/i386/intrin_i.h [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -52,6 +52,7 @@ #define _Ke386SetSeg(N,X) __asm__ __volatile__("movl %0,%%" #N : :"r" (X)); #define Ke386FnInit() __asm__("fninit\n\t"); +#define Ke386ClearDirectionFlag() __asm__ __volatile__ ("cld") // @@ -64,6 +65,9 @@ // #define Ke386GetSs() _Ke386GetSeg(ss) #define Ke386GetFs() _Ke386GetSeg(fs) +#define Ke386GetDs() _Ke386GetSeg(ds) +#define Ke386GetEs() _Ke386GetSeg(es) +#define Ke386GetGs() _Ke386GetSeg(gs) #define Ke386SetFs(X) _Ke386SetSeg(fs, X) #define Ke386SetDs(X) _Ke386SetSeg(ds, X) #define Ke386SetEs(X) _Ke386SetSeg(es, X) Modified: trunk/reactos/ntoskrnl/include/internal/ke.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -71,6 +71,20 @@ PVOID Context; PVOID Handle; } KNMI_HANDLER_CALLBACK, *PKNMI_HANDLER_CALLBACK; + +typedef union _KTRAP_STATE_BITS +{ + struct + { + UCHAR SystemCall:1; + UCHAR PreviousMode:1; + UCHAR Segments:1; + UCHAR Volatiles:1; + UCHAR Full:1; + UCHAR Reserved:3; + }; + UCHAR Bits; +} KTRAP_STATE_BITS, *PKTRAP_STATE_BITS; typedef PCHAR (NTAPI *PKE_BUGCHECK_UNICODE_TO_ANSI)( @@ -225,6 +239,12 @@ #endif +#define KTS_SYSCALL_BIT (((KTRAP_STATE_BITS) { { .SystemCall = TRUE } }).Bits) +#define KTS_PM_BIT (((KTRAP_STATE_BITS) { { .PreviousMode = TRUE } }).Bits) +#define KTS_SEG_BIT (((KTRAP_STATE_BITS) { { .Segments = TRUE } }).Bits) +#define KTS_VOL_BIT (((KTRAP_STATE_BITS) { { .Volatiles = TRUE } }).Bits) +#define KTS_FULL_BIT (((KTRAP_STATE_BITS) { { .Full = TRUE } }).Bits) + /* INTERNAL KERNEL FUNCTIONS ************************************************/ VOID @@ -863,6 +883,18 @@ PKTRAP_FRAME Tf ); +VOID +NTAPI +KiDispatchExceptionFromTrapFrame( + IN NTSTATUS Code, + IN ULONG_PTR Address, + IN ULONG ParameterCount, + IN ULONG_PTR Parameter1, + IN ULONG_PTR Parameter2, + IN ULONG_PTR Parameter3, + IN PKTRAP_FRAME TrapFrame +); + BOOLEAN NTAPI KiHandleNmi(VOID); Added: trunk/reactos/ntoskrnl/include/internal/trap_x.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
============================================================================== --- trunk/reactos/ntoskrnl/include/internal/trap_x.h (added) +++ trunk/reactos/ntoskrnl/include/internal/trap_x.h [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -1,0 +1,243 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/include/trap_x.h + * PURPOSE: Internal Inlined Functions for the Trap Handling Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +// +// Debug Macros +// +#if YDEBUG +VOID +NTAPI +KiDumpTrapFrame(IN PKTRAP_FRAME TrapFrame) +{ + /* Dump the whole thing */ + DPRINT1("DbgEbp: %x\n", TrapFrame->DbgEbp); + DPRINT1("DbgEip: %x\n", TrapFrame->DbgEip); + DPRINT1("DbgArgMark: %x\n", TrapFrame->DbgArgMark); + DPRINT1("DbgArgPointer: %x\n", TrapFrame->DbgArgPointer); + DPRINT1("TempSegCs: %x\n", TrapFrame->TempSegCs); + DPRINT1("TempEsp: %x\n", TrapFrame->TempEsp); + DPRINT1("Dr0: %x\n", TrapFrame->Dr0); + DPRINT1("Dr1: %x\n", TrapFrame->Dr1); + DPRINT1("Dr2: %x\n", TrapFrame->Dr2); + DPRINT1("Dr3: %x\n", TrapFrame->Dr3); + DPRINT1("Dr6: %x\n", TrapFrame->Dr6); + DPRINT1("Dr7: %x\n", TrapFrame->Dr7); + DPRINT1("SegGs: %x\n", TrapFrame->SegGs); + DPRINT1("SegEs: %x\n", TrapFrame->SegEs); + DPRINT1("SegDs: %x\n", TrapFrame->SegDs); + DPRINT1("Edx: %x\n", TrapFrame->Edx); + DPRINT1("Ecx: %x\n", TrapFrame->Ecx); + DPRINT1("Eax: %x\n", TrapFrame->Eax); + DPRINT1("PreviousPreviousMode: %x\n", TrapFrame->PreviousPreviousMode); + DPRINT1("ExceptionList: %x\n", TrapFrame->ExceptionList); + DPRINT1("SegFs: %x\n", TrapFrame->SegFs); + DPRINT1("Edi: %x\n", TrapFrame->Edi); + DPRINT1("Esi: %x\n", TrapFrame->Esi); + DPRINT1("Ebx: %x\n", TrapFrame->Ebx); + DPRINT1("Ebp: %x\n", TrapFrame->Ebp); + DPRINT1("ErrCode: %x\n", TrapFrame->ErrCode); + DPRINT1("Eip: %x\n", TrapFrame->Eip); + DPRINT1("SegCs: %x\n", TrapFrame->SegCs); + DPRINT1("EFlags: %x\n", TrapFrame->EFlags); + DPRINT1("HardwareEsp: %x\n", TrapFrame->HardwareEsp); + DPRINT1("HardwareSegSs: %x\n", TrapFrame->HardwareSegSs); + DPRINT1("V86Es: %x\n", TrapFrame->V86Es); + DPRINT1("V86Ds: %x\n", TrapFrame->V86Ds); + DPRINT1("V86Fs: %x\n", TrapFrame->V86Fs); + DPRINT1("V86Gs: %x\n", TrapFrame->V86Gs); +} + +FORCEINLINE +VOID +KiFillTrapFrameDebug(IN PKTRAP_FRAME TrapFrame) +{ + /* Set the debug information */ + TrapFrame->DbgArgPointer = TrapFrame->Edx; + TrapFrame->DbgArgMark = 0xBADB0D00; + TrapFrame->DbgEip = TrapFrame->Eip; + TrapFrame->DbgEbp = TrapFrame->Ebp; +} + +FORCEINLINE +VOID +KiExitTrapDebugChecks(IN PKTRAP_FRAME TrapFrame, + IN KTRAP_STATE_BITS StateBits) +{ + /* Make sure interrupts are disabled */ + if (__readeflags() & EFLAGS_INTERRUPT_MASK) + { + DPRINT1("Exiting with interrupts enabled: %lx\n", __readeflags()); + while (TRUE); + } + + /* Make sure this is a real trap frame */ + if (TrapFrame->DbgArgMark != 0xBADB0D00) + { + DPRINT1("Exiting with an invalid trap frame? (No MAGIC in trap frame)\n"); + KiDumpTrapFrame(TrapFrame); + while (TRUE); + } + + /* Make sure we're not in user-mode or something */ + if (Ke386GetFs() != KGDT_R0_PCR) + { + DPRINT1("Exiting with an invalid FS: %lx\n", Ke386GetFs()); + while (TRUE); + } + + /* Make sure we have a valid SEH chain */ + if (KeGetPcr()->Tib.ExceptionList == 0) + { + DPRINT1("Exiting with NULL exception chain: %p\n", KeGetPcr()->Tib.ExceptionList); + while (TRUE); + } + + /* Make sure we're restoring a valid SEH chain */ + if (TrapFrame->ExceptionList == 0) + { + DPRINT1("Entered a trap with a NULL exception chain: %p\n", TrapFrame->ExceptionList); + while (TRUE); + } + + /* If we're ignoring previous mode, make sure caller doesn't actually want it */ + if (!(StateBits.PreviousMode) && (TrapFrame->PreviousPreviousMode != -1)) + { + DPRINT1("Exiting a trap witout restoring previous mode, yet previous mode seems valid: %lx", TrapFrame->PreviousPreviousMode); + while (TRUE); + } +} +#else +#define KiExitTrapDebugChecks(x, y) +#define KiFillTrapFrameDebug(x) +#endif + +// +// Helper Code +// + +BOOLEAN +FORCEINLINE +KiUserTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Anything else but Ring 0 is Ring 3 */ + return (TrapFrame->SegCs != KGDT_R0_CODE); +} + +BOOLEAN +FORCEINLINE +KiVdmTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Either the V8086 flag is on, or this is user-mode with a VDM */ + return ((TrapFrame->EFlags & EFLAGS_V86_MASK) || + ((KiUserTrap(TrapFrame)) && (PsGetCurrentProcess()->VdmObjects))); +} + +VOID +FORCEINLINE +KiTrapFrameFromPushaStack(IN PKTRAP_FRAME TrapFrame) +{ + /* + * This sequence is Bavarian Alchemist Black Magic + * + * *** DO NOT MODIFY *** + */ + TrapFrame->Edx = TrapFrame->Esi; + TrapFrame->Esi = TrapFrame->PreviousPreviousMode; + TrapFrame->Ecx = TrapFrame->Ebx; + TrapFrame->Ebx = TrapFrame->Edi; + TrapFrame->Edi = TrapFrame->Eax; + TrapFrame->Eax = TrapFrame->Ebp; + TrapFrame->Ebp = (ULONG)TrapFrame->ExceptionList; + TrapFrame->TempEsp = TrapFrame->SegFs; +} + +VOID +FORCEINLINE +KiPushaStackFromTrapFrame(IN PKTRAP_FRAME TrapFrame) +{ + /* + * This sequence is Bavarian Alchemist Black Magic + * + * *** DO NOT MODIFY *** + */ + TrapFrame->SegFs = TrapFrame->TempEsp; + TrapFrame->ExceptionList = (PVOID)TrapFrame->Ebp; + TrapFrame->Ebp = TrapFrame->Eax; + TrapFrame->Eax = TrapFrame->Edi; + TrapFrame->Edi = TrapFrame->Ebx; + TrapFrame->Ebx = TrapFrame->Ecx; + TrapFrame->PreviousPreviousMode = TrapFrame->Esi; + TrapFrame->Esi = TrapFrame->Edx; +} + +VOID +FORCEINLINE +KiCheckForApcDelivery(IN PKTRAP_FRAME TrapFrame) +{ + PKTHREAD Thread; + KIRQL OldIrql; + + /* Check for V8086 or user-mode trap */ + if ((TrapFrame->EFlags & EFLAGS_V86_MASK) || + (KiUserTrap(TrapFrame))) + { + /* Get the thread */ + Thread = KeGetCurrentThread(); + while (TRUE) + { + /* Turn off the alerted state for kernel mode */ + Thread->Alerted[KernelMode] = FALSE; + + /* Are there pending user APCs? */ + if (Thread->ApcState.UserApcPending) + { + /* Raise to APC level and enable interrupts */ + OldIrql = KfRaiseIrql(APC_LEVEL); + _enable(); + + /* Deliver APCs */ + KiDeliverApc(UserMode, NULL, TrapFrame); + + /* Restore IRQL and disable interrupts once again */ + KfLowerIrql(OldIrql); + _disable(); + } + } + } +} + +VOID +FORCEINLINE +KiDispatchException0Args(IN NTSTATUS Code, + IN ULONG_PTR Address, + IN PKTRAP_FRAME TrapFrame) +{ + /* Helper for exceptions with no arguments */ + KiDispatchExceptionFromTrapFrame(Code, Address, 0, 0, 0, 0, TrapFrame); +} + +FORCEINLINE +VOID +KiTrapReturn(IN PKTRAP_FRAME TrapFrame) +{ + /* Restore registers */ + KiPushaStackFromTrapFrame(TrapFrame); + + /* Regular interrupt exit */ + __asm__ __volatile__ + ( + "movl %0, %%esp\n" + "addl %1, %%esp\n" + "popa\n" + "addl $4, %%esp\n" + "iret\n" + : + : "r"(TrapFrame), "i"(KTRAP_FRAME_LENGTH - KTRAP_FRAME_PREVIOUS_MODE) + : "%esp" + ); +} Propchange: trunk/reactos/ntoskrnl/include/internal/trap_x.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/exp.c?rev…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ke/i386/exp.c [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -772,6 +772,7 @@ /* Otherwise clear DR registers */ Context->Dr0 = Context->Dr1 = + Context->Dr2 = Context->Dr3 = Context->Dr6 = Context->Dr7 = 0; @@ -838,8 +839,8 @@ /* Set the context flags */ Context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS; - /* Check if User Mode or if the debugger is enabled */ - if ((PreviousMode == UserMode) || (KdDebuggerEnabled)) + /* Check if User Mode or if the kernel debugger is enabled */ + if ((PreviousMode == UserMode) || (KeGetPcr()->KdVersionBlock)) { /* Add the FPU Flag */ Context.ContextFlags |= CONTEXT_FLOATING_POINT; Added: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.…
============================================================================== --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c (added) +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -1,0 +1,231 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: ntoskrnl/ke/i386/traphdlr.c + * PURPOSE: Kernel Trap Handlers + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *****************************************************************/ + +#include <ntoskrnl.h> +#define NDEBUG +#include <debug.h> +#include "internal/trap_x.h" + +/* TRAP EXIT CODE *************************************************************/ + +VOID +FASTCALL +KiExitTrap(IN PKTRAP_FRAME TrapFrame, + IN UCHAR State) +{ + KTRAP_STATE_BITS StateBits = { .Bits = State }; + KiExitTrapDebugChecks(TrapFrame, StateBits); + + /* Restore the SEH handler chain */ + KeGetPcr()->Tib.ExceptionList = TrapFrame->ExceptionList; + + /* Check if the previous mode must be restored */ + if (StateBits.PreviousMode) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if there are active debug registers */ + if (TrapFrame->Dr7 & ~DR7_RESERVED_MASK) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if this was a V8086 trap */ + if (TrapFrame->EFlags & EFLAGS_V86_MASK) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if the trap frame was edited */ + if (!(TrapFrame->SegCs & FRAME_EDITED)) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check if all registers must be restored */ + if (StateBits.Full) + { + /* Only do the restore if we made a transition from user-mode */ + if (KiUserTrap(TrapFrame)) + { + /* Restore segments */ + Ke386SetGs(TrapFrame->SegGs); + Ke386SetEs(TrapFrame->SegEs); + Ke386SetDs(TrapFrame->SegDs); + } + } + + /* Check if we came from user-mode */ + if (KiUserTrap(TrapFrame)) + { + /* Check if the caller wants segments restored */ + if (StateBits.Segments) + { + /* Restore them */ + Ke386SetGs(TrapFrame->SegGs); + Ke386SetEs(TrapFrame->SegEs); + Ke386SetDs(TrapFrame->SegDs); + } + + /* Always restore FS since it goes from KPCR to TEB */ + Ke386SetFs(TrapFrame->SegFs); + } + + /* Check for ABIOS code segment */ + if (TrapFrame->SegCs == 0x80) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + + /* Check for system call */ + if (StateBits.SystemCall) + { + /* Not handled yet */ + UNIMPLEMENTED; + while (TRUE); + } + else + { + /* Return from interrupt */ + KiTrapReturn(TrapFrame); + } +} + +VOID +FASTCALL +KiEoiHelper(IN PKTRAP_FRAME TrapFrame) +{ + /* Disable interrupts until we return */ + _disable(); + + /* Check for APC delivery */ + KiCheckForApcDelivery(TrapFrame); + + /* Now exit the trap for real */ + KiExitTrap(TrapFrame, KTS_SEG_BIT | KTS_VOL_BIT); +} + +/* TRAP ENTRY CODE ************************************************************/ + +VOID +FASTCALL +KiEnterTrap(IN PKTRAP_FRAME TrapFrame) +{ + /* Save registers */ + KiTrapFrameFromPushaStack(TrapFrame); + + /* Save segments and then switch to correct ones */ + TrapFrame->SegFs = Ke386GetFs(); + TrapFrame->SegGs = Ke386GetGs(); + TrapFrame->SegDs = Ke386GetDs(); + TrapFrame->SegEs = Ke386GetEs(); + Ke386SetFs(KGDT_R0_PCR); + Ke386SetDs(KGDT_R3_DATA | RPL_MASK); + Ke386SetEs(KGDT_R3_DATA | RPL_MASK); + + /* Save exception list and bogus previous mode */ + TrapFrame->PreviousPreviousMode = -1; + TrapFrame->ExceptionList = KeGetPcr()->Tib.ExceptionList; + + /* Check for 16-bit stack */ + if ((ULONG_PTR)TrapFrame < 0x10000) + { + UNIMPLEMENTED; + while (TRUE); + } + + /* Check for V86 mode */ + if (TrapFrame->EFlags & EFLAGS_V86_MASK) + { + UNIMPLEMENTED; + while (TRUE); + } + + /* Clear direction flag */ + Ke386ClearDirectionFlag(); + + /* Flush DR7 and check for debugging */ + TrapFrame->Dr7 = 0; + if (KeGetCurrentThread()->DispatcherHeader.DebugActive & 0xFF) + { + UNIMPLEMENTED; + while (TRUE); + } + + /* Set debug header */ + KiFillTrapFrameDebug(TrapFrame); +} + +/* EXCEPTION CODE *************************************************************/ + +VOID +FASTCALL +KiSystemFatalException(IN ULONG ExceptionCode, + IN PKTRAP_FRAME TrapFrame) +{ + /* Bugcheck the system */ + KeBugCheckWithTf(UNEXPECTED_KERNEL_MODE_TRAP, + ExceptionCode, + 0, + 0, + 0, + TrapFrame); +} + +VOID +NTAPI +KiDispatchExceptionFromTrapFrame(IN NTSTATUS Code, + IN ULONG_PTR Address, + IN ULONG ParameterCount, + IN ULONG_PTR Parameter1, + IN ULONG_PTR Parameter2, + IN ULONG_PTR Parameter3, + IN PKTRAP_FRAME TrapFrame) +{ + EXCEPTION_RECORD ExceptionRecord; + + /* Build the exception record */ + ExceptionRecord.ExceptionCode = Code; + ExceptionRecord.ExceptionFlags = 0; + ExceptionRecord.ExceptionRecord = NULL; + ExceptionRecord.ExceptionAddress = (PVOID)Address; + ExceptionRecord.NumberParameters = ParameterCount; + if (ParameterCount) + { + /* Copy extra parameters */ + ExceptionRecord.ExceptionInformation[0] = Parameter1; + ExceptionRecord.ExceptionInformation[1] = Parameter2; + ExceptionRecord.ExceptionInformation[2] = Parameter3; + } + + /* Now go dispatch the exception */ + KiDispatchException(&ExceptionRecord, + NULL, + TrapFrame, + TrapFrame->EFlags & EFLAGS_V86_MASK ? + -1 : TrapFrame->SegCs & MODE_MASK, + TRUE); + + /* Return from this trap */ + KiEoiHelper(TrapFrame); +} + +/* EOF */ Propchange: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl-generic.…
============================================================================== --- trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/ntoskrnl-generic.rbuild [iso-8859-1] Fri Jan 8 16:04:19 2010 @@ -51,6 +51,7 @@ <file>systimer.S</file> <file>thrdini.c</file> <file>trap.s</file> + <file>traphdlr.c</file> <file>usercall_asm.S</file> <file>usercall.c</file> <file>v86vdm.c</file>
14 years, 11 months
1
0
0
0
[martinf] 44999: temporarily revert to query "defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER)"
by martinf@svn.reactos.org
Author: martinf Date: Fri Jan 8 15:48:22 2010 New Revision: 44999 URL:
http://svn.reactos.org/svn/reactos?rev=44999&view=rev
Log: temporarily revert to query "defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER)" Modified: trunk/reactos/base/shell/explorer/utility/utility.h trunk/reactos/base/shell/explorer/utility/xmlstorage.h Modified: trunk/reactos/base/shell/explorer/utility/utility.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] Fri Jan 8 15:48:22 2010 @@ -182,12 +182,9 @@ #endif -#ifndef _MS_VER // modified gedmurphy's "secure CRT usage rehack" -#undef __STDC_WANT_SECURE_LIB__ -#endif - // secure CRT functions -#ifdef __STDC_WANT_SECURE_LIB__ // for VS 2005: _MSC_VER>=1400 +//@@ _MS_VER: temporarily needed for the ReactOS build environment +#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER) // for VS 2005: _MSC_VER>=1400 #define _stprintf_s1 _stprintf_s #define _stprintf_s2 _stprintf_s Modified: trunk/reactos/base/shell/explorer/utility/xmlstorage.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/xmlstorage.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/xmlstorage.h [iso-8859-1] Fri Jan 8 15:48:22 2010 @@ -518,7 +518,8 @@ { FileHolder(LPCTSTR path, LPCTSTR mode) { -#ifdef __STDC_WANT_SECURE_LIB__ +//@@ _MS_VER: temporarily needed for the ReactOS build environment +#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER) // secure CRT functions using VS 2005 if (_tfopen_s(&_pfile, path, mode) != 0) _pfile = NULL; #else
14 years, 11 months
1
0
0
0
[martinf] 44998: update XMLStorage to 2010 version
by martinf@svn.reactos.org
Author: martinf Date: Fri Jan 8 14:59:15 2010 New Revision: 44998 URL:
http://svn.reactos.org/svn/reactos?rev=44998&view=rev
Log: update XMLStorage to 2010 version Modified: trunk/reactos/base/shell/explorer/ (props changed) trunk/reactos/base/shell/explorer/utility/utility.h trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp trunk/reactos/base/shell/explorer/utility/xmlstorage.h Propchange: trunk/reactos/base/shell/explorer/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Fri Jan 8 14:59:15 2010 @@ -16,3 +16,6 @@ *.aps *.gch *.exe +pack.* +.gdbinit +*.zip Modified: trunk/reactos/base/shell/explorer/utility/utility.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/utility.h [iso-8859-1] Fri Jan 8 14:59:15 2010 @@ -182,8 +182,12 @@ #endif +#ifndef _MS_VER // modified gedmurphy's "secure CRT usage rehack" +#undef __STDC_WANT_SECURE_LIB__ +#endif + // secure CRT functions -#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER) // for VS 2005: _MSC_VER>=1400 +#ifdef __STDC_WANT_SECURE_LIB__ // for VS 2005: _MSC_VER>=1400 #define _stprintf_s1 _stprintf_s #define _stprintf_s2 _stprintf_s Modified: trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/xmlstorage.cpp [iso-8859-1] Fri Jan 8 14:59:15 2010 @@ -2,7 +2,7 @@ // // XML storage C++ classes version 1.3 // - // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009 Martin Fuchs <martin-fuchs(a)gmx.net> + // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Martin Fuchs <martin-fuchs(a)gmx.net> // /// \file xmlstorage.cpp Modified: trunk/reactos/base/shell/explorer/utility/xmlstorage.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer/utilit…
============================================================================== --- trunk/reactos/base/shell/explorer/utility/xmlstorage.h [iso-8859-1] (original) +++ trunk/reactos/base/shell/explorer/utility/xmlstorage.h [iso-8859-1] Fri Jan 8 14:59:15 2010 @@ -2,7 +2,7 @@ // // XML storage C++ classes version 1.3 // - // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009 Martin Fuchs <martin-fuchs(a)gmx.net> + // Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Martin Fuchs <martin-fuchs(a)gmx.net> // /// \file xmlstorage.h @@ -205,7 +205,7 @@ #define _tcsicmp strcasecmp #define strnicmp strncasecmp #define _tcsnicmp strncasecmp -#endif +#endif // UNICODE #endif // _WIN32 @@ -309,14 +309,14 @@ #if defined(UNICODE) && !defined(XS_STRING_UTF8) XS_String(LPCSTR s) {assign(s);} XS_String(LPCSTR s, size_t l) {assign(s, l);} - XS_String(const std::string& other) {assign(other.c_str());} + XS_String(const std::string& s) {assign(s.c_str());} XS_String& operator=(LPCSTR s) {assign(s); return *this;} void assign(LPCSTR s) {if (s) {size_t bl=strlen(s); LPWSTR b=(LPWSTR)alloca(sizeof(WCHAR)*bl); super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, bl, b, bl));} else erase();} void assign(LPCSTR s, size_t l) {if (s) {size_t bl=l; LPWSTR b=(LPWSTR)alloca(sizeof(WCHAR)*bl); super::assign(b, MultiByteToWideChar(CP_ACP, 0, s, l, b, bl));} else erase();} #else XS_String(LPCWSTR s) {assign(s);} XS_String(LPCWSTR s, size_t l) {assign(s, l);} - XS_String(const std::wstring& other) {assign(other.c_str());} + XS_String(const std::wstring& ws) {assign(ws.c_str());} XS_String& operator=(LPCWSTR s) {assign(s); return *this;} #ifdef XS_STRING_UTF8 void assign(LPCWSTR s) {if (s) {size_t bl=wcslen(s); LPSTR b=(LPSTR)alloca(bl); super::assign(b, WideCharToMultiByte(CP_UTF8, 0, s, (int)bl, b, (int)bl, 0, 0));} else erase();} @@ -327,6 +327,12 @@ #endif #endif #endif // _WIN32 + +#ifdef __ISSD_H +// XS_String(const _ISSD RString& s) {assign(s.c_str());} +// void assign(const _ISSD RString& s) {assign(s.c_str());} + XS_String& operator=(const _ISSD RString& s) {assign(s); return *this;} +#endif #ifdef XS_STRING_UTF8 void assign(const XS_String& s) {assign(s.c_str());} @@ -512,7 +518,7 @@ { FileHolder(LPCTSTR path, LPCTSTR mode) { -#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER) // secure CRT functions using VS 2005 +#ifdef __STDC_WANT_SECURE_LIB__ if (_tfopen_s(&_pfile, path, mode) != 0) _pfile = NULL; #else @@ -544,6 +550,8 @@ _buf(_pfile) #endif { + if (!_pfile) + setstate(badbit); } protected: @@ -564,6 +572,8 @@ _buf(_pfile) #endif { + if (!_pfile) + setstate(badbit); } ~tofstream() @@ -1065,7 +1075,7 @@ { Children::iterator it, next=_children.begin(); - while((it=next++)!=_children.end()) + while((it=next++) != _children.end()) if (**it == name) _children.erase(it); } @@ -1559,6 +1569,7 @@ /// index operator attribute access template<typename T> XS_String get(const T& attr_name) const {return (*_cur)[attr_name];} XS_String& operator[](const XS_String& attr_name) {return (*_cur)[attr_name];} + const XS_String& operator[](const XS_String& attr_name) const {return (*_cur)[attr_name];} /// insert children when building tree void add_down(XMLNode* child) @@ -1635,6 +1646,14 @@ add_down(new XMLNode(name)); } + /// create node with string content + void create_node_content(const XS_String& node_name, const XS_String& content) + { + XMLNode* pNode = new XMLNode(node_name); + pNode->set_content(content); + _cur->add_child(pNode); + } + /// create node if not already existing and move to it void smart_create(const XS_String& child_name) { @@ -1815,6 +1834,7 @@ /// index operator attribute access template<typename T> XS_String get(const T& attr_name) const {return _cur->get(attr_name);} + XS_String operator[](const XS_String& attr_name) const {return _cur->get(attr_name);} /// go back to previous position bool back() @@ -2722,6 +2742,9 @@ bool read_file(LPCTSTR path) { tifstream in(path); + if (!in.good()) + return false; + XMLReader reader(this, in); #if defined(_STRING_DEFINED) && !defined(XS_STRING_UTF8) @@ -2926,6 +2949,14 @@ { if (!_stack.empty()) _stack.top()._content = EncodeXMLString(s.c_str(), cdata); + } + + /// create node with string content + void create_node_content(const XS_String& node_name, const XS_String& content) + { + create(node_name); + set_content(content); + back(); } // public for access in StackEntry
14 years, 11 months
1
0
0
0
[martinf] 44997: restore svn:ignore settings
by martinf@svn.reactos.org
Author: martinf Date: Fri Jan 8 14:20:42 2010 New Revision: 44997 URL:
http://svn.reactos.org/svn/reactos?rev=44997&view=rev
Log: restore svn:ignore settings Modified: trunk/reactos/base/shell/explorer/notifyhook/ (props changed) Propchange: trunk/reactos/base/shell/explorer/notifyhook/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Fri Jan 8 14:20:42 2010 @@ -5,3 +5,6 @@ *.ncb *.suo *.sln +Debug +Release +Win32
14 years, 11 months
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
53
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Results per page:
10
25
50
100
200