mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:43:13 +00:00
cleanup/reformat syscall code, save return value as soon as possible so that eax is freed up, which also simplifies the implementation of KiAfterSystemCallHook(), also removes a couple redundant instructions.
svn path=/trunk/; revision=9955
This commit is contained in:
parent
aa33e15965
commit
209e1d7692
2 changed files with 222 additions and 203 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: syscall.S,v 1.14 2004/04/07 15:35:14 ekohl Exp $
|
||||
/* $Id: syscall.S,v 1.15 2004/07/01 01:52:37 royce Exp $
|
||||
*
|
||||
* FILE: ntoskrnl/hal/x86/syscall.s
|
||||
* PURPOSE: 2E trap handler
|
||||
|
@ -28,6 +28,7 @@
|
|||
#include <ddk/status.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/i386/ke.h>
|
||||
#include <roscfg.h>
|
||||
|
||||
#define KernelMode (0)
|
||||
|
@ -116,18 +117,18 @@ L3:
|
|||
* register.
|
||||
*/
|
||||
movl KTHREAD_TRAP_FRAME(%esi), %ebx
|
||||
movl %ebx, 0x3C(%esp)
|
||||
movl %ebx, KTRAP_FRAME_EDX(%esp)
|
||||
|
||||
/* Allocate new Kernel stack frame */
|
||||
movl %esp,%ebp
|
||||
|
||||
/* Save a pointer to the trap frame in the TCB */
|
||||
movl %esp, KTHREAD_TRAP_FRAME(%esi)
|
||||
movl %ebp, KTHREAD_TRAP_FRAME(%esi)
|
||||
|
||||
/* Set ES to kernel segment */
|
||||
movw $KERNEL_DS,%bx
|
||||
movw %bx,%es
|
||||
|
||||
/* Allocate new Kernel stack frame */
|
||||
movl %esp,%ebp
|
||||
|
||||
/* Users's current stack frame pointer is source */
|
||||
movl %edx,%esi
|
||||
|
||||
|
@ -139,6 +140,7 @@ L3:
|
|||
cmpl %es:_KeServiceDescriptorTable + 8, %eax
|
||||
jbe new_serviceInRange
|
||||
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
||||
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||
jmp KeReturnFromSystemCall
|
||||
|
||||
new_serviceInRange:
|
||||
|
@ -174,21 +176,13 @@ new_serviceInRange:
|
|||
movl %es:_KeServiceDescriptorTable, %ecx
|
||||
movl %es:(%ecx, %eax, 4), %eax
|
||||
call *%eax
|
||||
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||
|
||||
#if CHECKED
|
||||
/* Bump Service Counter */
|
||||
#endif
|
||||
|
||||
/* Deallocate the kernel stack frame */
|
||||
movl %ebp,%esp
|
||||
|
||||
/* Call the post system call hook and deliver any pending APCs */
|
||||
pushl %ebp
|
||||
pushl %eax
|
||||
call _KiAfterSystemCallHook
|
||||
addl $8,%esp
|
||||
|
||||
jmp KeReturnFromSystemCall
|
||||
jmp KeDeallocateStackAndReturnFromSystemCallWithHook
|
||||
|
||||
new_useShadowTable:
|
||||
|
||||
|
@ -198,6 +192,7 @@ new_useShadowTable:
|
|||
cmpl %es:_KeServiceDescriptorTableShadow + 24, %eax
|
||||
jbe new_shadowServiceInRange
|
||||
movl $STATUS_INVALID_SYSTEM_SERVICE, %eax
|
||||
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||
jmp KeReturnFromSystemCall
|
||||
|
||||
new_shadowServiceInRange:
|
||||
|
@ -238,20 +233,21 @@ new_shadowServiceInRange:
|
|||
movl %es:_KeServiceDescriptorTableShadow + 16, %ecx
|
||||
movl %es:(%ecx, %eax, 4), %eax
|
||||
call *%eax
|
||||
movl %eax, KTRAP_FRAME_EAX(%ebp) /* save our return value in PKTRAP_FRAME->Eax */
|
||||
|
||||
#if CHECKED
|
||||
/* Bump Service Counter */
|
||||
#endif
|
||||
|
||||
KeDeallocateStackAndReturnFromSystemCallWithHook:
|
||||
/* Deallocate the kernel stack frame */
|
||||
movl %ebp,%esp
|
||||
|
||||
KeReturnFromSystemCallWithHook:
|
||||
/* Call the post system call hook and deliver any pending APCs */
|
||||
pushl %esp
|
||||
pushl %eax
|
||||
call _KiAfterSystemCallHook
|
||||
addl $8,%esp
|
||||
addl $4,%esp
|
||||
|
||||
KeReturnFromSystemCall:
|
||||
|
||||
|
@ -260,9 +256,10 @@ KeReturnFromSystemCall:
|
|||
movl %fs:0x124, %esi
|
||||
|
||||
/* Restore the old trap frame pointer */
|
||||
movl 0x3c(%esp), %ebx
|
||||
movl KTRAP_FRAME_EDX(%esp), %ebx
|
||||
movl %ebx, KTHREAD_TRAP_FRAME(%esi)
|
||||
|
||||
KiRosTrapReturn:
|
||||
/* Skip debug information and unsaved registers */
|
||||
addl $0x30, %esp
|
||||
popl %gs
|
||||
|
@ -270,7 +267,7 @@ KeReturnFromSystemCall:
|
|||
popl %ds
|
||||
popl %edx
|
||||
popl %ecx
|
||||
addl $0x4, %esp /* Don't restore eax */
|
||||
popl %eax
|
||||
|
||||
/* Restore the old previous mode */
|
||||
popl %ebx
|
||||
|
@ -288,3 +285,23 @@ KeReturnFromSystemCall:
|
|||
addl $0x4, %esp /* Ignore error code */
|
||||
|
||||
iret
|
||||
|
||||
/* R3: NOTE: This is part of my in-progress attempt at correcting NtContinue
|
||||
* It is not being called, yet...
|
||||
*/
|
||||
.globl @KeRosTrapReturn@8
|
||||
@KeRosTrapReturn@8:
|
||||
/* Call the post system call hook and deliver any pending APCs */
|
||||
pushl %esp
|
||||
call _KiAfterSystemCallHook
|
||||
addl $4,%esp
|
||||
|
||||
/* Restore the user context */
|
||||
/* Get a pointer to the current thread */
|
||||
movl %fs:0x124, %esi
|
||||
/* Restore the old trap frame pointer */
|
||||
movl %edx, KTHREAD_TRAP_FRAME(%esi)
|
||||
|
||||
/* point %esp to the trap frame to restore */
|
||||
movl %ecx, %esp
|
||||
jmp KiRosTrapReturn;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: usercall.c,v 1.26 2004/06/23 22:32:24 ion Exp $
|
||||
/* $Id: usercall.c,v 1.27 2004/07/01 01:52:37 royce Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -26,7 +26,8 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID KiSystemCallHook(ULONG Nr, ...)
|
||||
VOID
|
||||
KiSystemCallHook(ULONG Nr, ...)
|
||||
{
|
||||
#if 0
|
||||
va_list ap;
|
||||
|
@ -46,7 +47,8 @@ VOID KiSystemCallHook(ULONG Nr, ...)
|
|||
#endif
|
||||
}
|
||||
|
||||
ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
|
||||
VOID
|
||||
KiAfterSystemCallHook(PKTRAP_FRAME TrapFrame)
|
||||
{
|
||||
if (KeGetCurrentThread()->Alerted[1] != 0 && TrapFrame->Cs != KERNEL_CS)
|
||||
{
|
||||
|
@ -56,11 +58,11 @@ ULONG KiAfterSystemCallHook(ULONG NtStatus, PKTRAP_FRAME TrapFrame)
|
|||
{
|
||||
KiDeliverUserApc(TrapFrame);
|
||||
}
|
||||
return(NtStatus);
|
||||
}
|
||||
|
||||
|
||||
VOID KiServiceCheck (ULONG Nr)
|
||||
VOID
|
||||
KiServiceCheck (ULONG Nr)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue