mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[ASM x64] Change ; by /* */ for comments
Syntax with semi-colon is not supported by gas.
This commit is contained in:
parent
4bb7bd1f50
commit
ff7035d940
6 changed files with 101 additions and 98 deletions
|
@ -62,44 +62,44 @@ PUBLIC KiRaiseUserExceptionDispatcher
|
||||||
PUBLIC KiUserCallbackDispatcher
|
PUBLIC KiUserCallbackDispatcher
|
||||||
.PROC KiUserCallbackDispatcher
|
.PROC KiUserCallbackDispatcher
|
||||||
|
|
||||||
; The stack is set up with a UCALLOUT_FRAME
|
/* The stack is set up with a UCALLOUT_FRAME */
|
||||||
; The frame ends with a MACHINE_FRAME.
|
/* The frame ends with a MACHINE_FRAME. */
|
||||||
.PUSHFRAME
|
.PUSHFRAME
|
||||||
|
|
||||||
; This is for the Home space, Buffer, Length and ApiNumber
|
/* This is for the Home space, Buffer, Length and ApiNumber */
|
||||||
.ALLOCSTACK 6 * 8
|
.ALLOCSTACK 6 * 8
|
||||||
.ENDPROLOG
|
.ENDPROLOG
|
||||||
|
|
||||||
#if DBG
|
#if DBG
|
||||||
; We enter the function with a fully setup stack, so it must be aligned!
|
/* We enter the function with a fully setup stack, so it must be aligned! */
|
||||||
test rsp, 15
|
test rsp, 15
|
||||||
jz AlignmentOk
|
jz AlignmentOk
|
||||||
int HEX(2C)
|
int HEX(2C)
|
||||||
AlignmentOk:
|
AlignmentOk:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
; Get the parameters from the callout frame
|
/* Get the parameters from the callout frame */
|
||||||
mov rcx, [rsp + CkBuffer]
|
mov rcx, [rsp + CkBuffer]
|
||||||
mov edx, [rsp + CkLength]
|
mov edx, [rsp + CkLength]
|
||||||
mov r8d, [rsp + CkApiNumber]
|
mov r8d, [rsp + CkApiNumber]
|
||||||
|
|
||||||
; Get the callback table
|
/* Get the callback table */
|
||||||
mov rax, gs:[TePeb]
|
mov rax, gs:[TePeb]
|
||||||
mov r9, [rax + PeKernelCallbackTable]
|
mov r9, [rax + PeKernelCallbackTable]
|
||||||
|
|
||||||
; Call the routine
|
/* Call the routine */
|
||||||
call qword ptr [r9 + r8 * 8]
|
call qword ptr [r9 + r8 * 8]
|
||||||
|
|
||||||
; Return from callback
|
/* Return from callback */
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov r8d, eax
|
mov r8d, eax
|
||||||
call ZwCallbackReturn
|
call ZwCallbackReturn
|
||||||
|
|
||||||
; Save callback return value
|
/* Save callback return value */
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
|
|
||||||
; Raise status
|
/* Raise status */
|
||||||
StatusRaise:
|
StatusRaise:
|
||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
call RtlRaiseStatus
|
call RtlRaiseStatus
|
||||||
|
@ -158,11 +158,11 @@ EXTERN RtlRaiseException:PROC
|
||||||
PUBLIC KiUserExceptionDispatcher
|
PUBLIC KiUserExceptionDispatcher
|
||||||
.PROC KiUserExceptionDispatcher
|
.PROC KiUserExceptionDispatcher
|
||||||
|
|
||||||
; The stack is set up with a KUSER_EXCEPTION_STACK
|
/* The stack is set up with a KUSER_EXCEPTION_STACK */
|
||||||
; The frame ends with a MACHINE_FRAME.
|
/* The frame ends with a MACHINE_FRAME. */
|
||||||
.PUSHFRAME
|
.PUSHFRAME
|
||||||
|
|
||||||
; This is for the alignment, EXCEPTION_RECORD and CONTEXT
|
/* This is for the alignment, EXCEPTION_RECORD and CONTEXT */
|
||||||
.ALLOCSTACK 8 + EXCEPTION_RECORD_LENGTH + CONTEXT_FRAME_LENGTH
|
.ALLOCSTACK 8 + EXCEPTION_RECORD_LENGTH + CONTEXT_FRAME_LENGTH
|
||||||
.ENDPROLOG
|
.ENDPROLOG
|
||||||
|
|
||||||
|
@ -177,8 +177,8 @@ PUBLIC KiUserExceptionDispatcher
|
||||||
jz RaiseException
|
jz RaiseException
|
||||||
|
|
||||||
/* We're fine, continue execution */
|
/* We're fine, continue execution */
|
||||||
lea rcx, [rsp] ; ContextRecord
|
lea rcx, [rsp] /* ContextRecord */
|
||||||
mov dl, 0 ; TestAlert
|
mov dl, 0 /* TestAlert */
|
||||||
call ZwContinue
|
call ZwContinue
|
||||||
|
|
||||||
/* Exit */
|
/* Exit */
|
||||||
|
@ -187,13 +187,13 @@ PUBLIC KiUserExceptionDispatcher
|
||||||
RaiseException:
|
RaiseException:
|
||||||
|
|
||||||
/* Raise the exception */
|
/* Raise the exception */
|
||||||
lea rcx, [rsp + CONTEXT_FRAME_LENGTH] ; ExceptionRecord
|
lea rcx, [rsp + CONTEXT_FRAME_LENGTH] /* ExceptionRecord */
|
||||||
lea rdx, [rsp] ; ContextRecord
|
lea rdx, [rsp] /* ContextRecord */
|
||||||
xor r8, r8
|
xor r8, r8
|
||||||
call ZwRaiseException
|
call ZwRaiseException
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
lea rcx, [rsp + CONTEXT_FRAME_LENGTH] ; ExceptionRecord
|
lea rcx, [rsp + CONTEXT_FRAME_LENGTH] /* ExceptionRecord */
|
||||||
mov rdx, rax
|
mov rdx, rax
|
||||||
call KiUserExceptionDispatcherNested
|
call KiUserExceptionDispatcherNested
|
||||||
ret
|
ret
|
||||||
|
|
|
@ -11,11 +11,13 @@
|
||||||
|
|
||||||
#include <ksamd64.inc>
|
#include <ksamd64.inc>
|
||||||
|
|
||||||
; BOOLEAN
|
/*
|
||||||
; KiSwapContextResume(
|
* BOOLEAN
|
||||||
; _In_ KIRQL WaitIrql,
|
* KiSwapContextResume(
|
||||||
; _In_ PKTHREAD OldThread,
|
* _In_ KIRQL WaitIrql,
|
||||||
; _In_ PKTHREAD NewThread)
|
* _In_ PKTHREAD OldThread,
|
||||||
|
* _In_ PKTHREAD NewThread)
|
||||||
|
*/
|
||||||
EXTERN KiSwapContextResume:PROC
|
EXTERN KiSwapContextResume:PROC
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
|
@ -825,7 +825,7 @@ no_user_apc_pending:
|
||||||
/* Swap gs back to user */
|
/* Swap gs back to user */
|
||||||
swapgs
|
swapgs
|
||||||
|
|
||||||
; Zero out volatiles
|
/* Zero out volatiles */
|
||||||
pxor xmm0, xmm0
|
pxor xmm0, xmm0
|
||||||
pxor xmm1, xmm1
|
pxor xmm1, xmm1
|
||||||
pxor xmm2, xmm2
|
pxor xmm2, xmm2
|
||||||
|
@ -965,7 +965,7 @@ FUNC KiConvertToGuiThread
|
||||||
test rax, rax
|
test rax, rax
|
||||||
jz KiConvertToGuiThreadFailed
|
jz KiConvertToGuiThreadFailed
|
||||||
|
|
||||||
; OldStack = KeSwitchKernelStack((PVOID)NewStack, (PVOID)(NewStack - KERNEL_STACK_SIZE));
|
/* OldStack = KeSwitchKernelStack((PVOID)NewStack, (PVOID)(NewStack - KERNEL_STACK_SIZE)); */
|
||||||
mov rcx, rax
|
mov rcx, rax
|
||||||
mov rdx, rax
|
mov rdx, rax
|
||||||
sub rdx, KERNEL_STACK_SIZE
|
sub rdx, KERNEL_STACK_SIZE
|
||||||
|
@ -1011,44 +1011,45 @@ KiConvertToGuiThreadFailed:
|
||||||
|
|
||||||
ENDFUNC
|
ENDFUNC
|
||||||
|
|
||||||
;
|
/*
|
||||||
; VOID
|
* VOID
|
||||||
; KiDeliverApc(
|
* KiDeliverApc(
|
||||||
; _In_ KPROCESSOR_MODE DeliveryMode,
|
* _In_ KPROCESSOR_MODE DeliveryMode,
|
||||||
; _In_ PKEXCEPTION_FRAME ExceptionFrame,
|
* _In_ PKEXCEPTION_FRAME ExceptionFrame,
|
||||||
; _In_ PKTRAP_FRAME TrapFrame);
|
* _In_ PKTRAP_FRAME TrapFrame);
|
||||||
;
|
*
|
||||||
|
*/
|
||||||
EXTERN KiDeliverApc:PROC
|
EXTERN KiDeliverApc:PROC
|
||||||
|
|
||||||
PUBLIC KiInitiateUserApc
|
PUBLIC KiInitiateUserApc
|
||||||
.PROC KiInitiateUserApc
|
.PROC KiInitiateUserApc
|
||||||
|
|
||||||
; Generate a KEXCEPTION_FRAME on the stack
|
/* Generate a KEXCEPTION_FRAME on the stack */
|
||||||
GENERATE_EXCEPTION_FRAME
|
GENERATE_EXCEPTION_FRAME
|
||||||
|
|
||||||
; Raise IRQL to APC_LEVEL
|
/* Raise IRQL to APC_LEVEL */
|
||||||
mov rax, APC_LEVEL
|
mov rax, APC_LEVEL
|
||||||
mov cr8, rax
|
mov cr8, rax
|
||||||
|
|
||||||
; Enable interrupts
|
/* Enable interrupts */
|
||||||
sti
|
sti
|
||||||
|
|
||||||
; Get the current trap frame
|
/* Get the current trap frame */
|
||||||
mov rax, gs:[PcCurrentThread]
|
mov rax, gs:[PcCurrentThread]
|
||||||
mov r8, [rax + KTHREAD_TrapFrame]
|
mov r8, [rax + KTHREAD_TrapFrame]
|
||||||
|
|
||||||
; Call the C function
|
/* Call the C function */
|
||||||
mov ecx, 1
|
mov ecx, 1
|
||||||
mov rdx, rsp
|
mov rdx, rsp
|
||||||
call KiDeliverApc
|
call KiDeliverApc
|
||||||
|
|
||||||
; Disable interrupts again
|
/* Disable interrupts again */
|
||||||
cli
|
cli
|
||||||
|
|
||||||
; Restore the registers from the KEXCEPTION_FRAME
|
/* Restore the registers from the KEXCEPTION_FRAME */
|
||||||
RESTORE_EXCEPTION_STATE
|
RESTORE_EXCEPTION_STATE
|
||||||
|
|
||||||
; Return
|
/* Return */
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.ENDP
|
.ENDP
|
||||||
|
@ -1092,22 +1093,22 @@ FUNC KeSwitchKernelStack
|
||||||
sub rsp, 40
|
sub rsp, 40
|
||||||
.allocstack 40
|
.allocstack 40
|
||||||
|
|
||||||
; Save rcx
|
/* Save rcx */
|
||||||
mov [rsp], rcx
|
mov [rsp], rcx
|
||||||
.savereg rcx, 0
|
.savereg rcx, 0
|
||||||
.endprolog
|
.endprolog
|
||||||
|
|
||||||
; Call the C handler, which returns the old stack in rax
|
/* Call the C handler, which returns the old stack in rax */
|
||||||
call KiSwitchKernelStack
|
call KiSwitchKernelStack
|
||||||
|
|
||||||
; Restore rcx (StackBase)
|
/* Restore rcx (StackBase) */
|
||||||
mov rcx, [rsp]
|
mov rcx, [rsp]
|
||||||
|
|
||||||
; Switch to new stack: RSP += (StackBase - OldStackBase)
|
/* Switch to new stack: RSP += (StackBase - OldStackBase) */
|
||||||
sub rcx, rax
|
sub rcx, rax
|
||||||
add rsp, rcx
|
add rsp, rcx
|
||||||
|
|
||||||
; Deallocate the home frame
|
/* Deallocate the home frame */
|
||||||
add rsp, 40
|
add rsp, 40
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
;++
|
/*
|
||||||
; PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS Kernel
|
||||||
; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
; PURPOSE: ReactOS AMD64 user mode callback helper
|
* PURPOSE: ReactOS AMD64 user mode callback helper
|
||||||
; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||||
;--
|
*/
|
||||||
|
|
||||||
#include <ksamd64.inc>
|
#include <ksamd64.inc>
|
||||||
|
|
||||||
;
|
/*
|
||||||
; NTSTATUS
|
* NTSTATUS
|
||||||
; KiUserModeCallout (
|
* KiUserModeCallout (
|
||||||
; _Inout_ PKCALLOUT_FRAME CalloutFrame);
|
* _Inout_ PKCALLOUT_FRAME CalloutFrame);
|
||||||
;
|
*/
|
||||||
EXTERN KiUserModeCallout:PROC
|
EXTERN KiUserModeCallout:PROC
|
||||||
|
|
||||||
.code64
|
.code64
|
||||||
|
|
||||||
;
|
/*
|
||||||
; NTSTATUS
|
* NTSTATUS
|
||||||
; KiCallUserMode (
|
* KiCallUserMode (
|
||||||
; _In_ PVOID *OutputBuffer@<rcx>,
|
* _In_ PVOID *OutputBuffer@<rcx>,
|
||||||
; _In_ PULONG OutputLength@<rdx>);
|
* _In_ PULONG OutputLength@<rdx>);
|
||||||
;
|
*/
|
||||||
PUBLIC KiCallUserMode
|
PUBLIC KiCallUserMode
|
||||||
.PROC KiCallUserMode
|
.PROC KiCallUserMode
|
||||||
|
|
||||||
; Generate a KEXCEPTION_FRAME on the stack
|
/* Generate a KEXCEPTION_FRAME on the stack */
|
||||||
; This is identical to a KCALLOUT_FRAME
|
/* This is identical to a KCALLOUT_FRAME */
|
||||||
GENERATE_EXCEPTION_FRAME
|
GENERATE_EXCEPTION_FRAME
|
||||||
|
|
||||||
; Save OutputBuffer and OutputLength
|
/* Save OutputBuffer and OutputLength */
|
||||||
mov [rsp + ExOutputBuffer], rcx
|
mov [rsp + ExOutputBuffer], rcx
|
||||||
mov [rsp + ExOutputLength], rdx
|
mov [rsp + ExOutputLength], rdx
|
||||||
|
|
||||||
; Call the C function
|
/* Call the C function */
|
||||||
mov rcx, rsp
|
mov rcx, rsp
|
||||||
call KiUserModeCallout
|
call KiUserModeCallout
|
||||||
|
|
||||||
; Restore the registers from the KEXCEPTION_FRAME
|
/* Restore the registers from the KEXCEPTION_FRAME */
|
||||||
RESTORE_EXCEPTION_STATE
|
RESTORE_EXCEPTION_STATE
|
||||||
|
|
||||||
; Return
|
/* Return */
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.ENDP
|
.ENDP
|
||||||
|
|
||||||
;
|
/*
|
||||||
; DECLSPEC_NORETURN
|
* DECLSPEC_NORETURN
|
||||||
; VOID
|
* VOID
|
||||||
; KiCallbackReturn (
|
* KiCallbackReturn (
|
||||||
; _In_ PVOID Stack,
|
* _In_ PVOID Stack,
|
||||||
; _In_ NTSTATUS Status);
|
* _In_ NTSTATUS Status);
|
||||||
;
|
*/
|
||||||
PUBLIC KiCallbackReturn
|
PUBLIC KiCallbackReturn
|
||||||
.PROC KiCallbackReturn
|
.PROC KiCallbackReturn
|
||||||
|
|
||||||
.ENDPROLOG
|
.ENDPROLOG
|
||||||
|
|
||||||
; Restore the stack
|
/* Restore the stack */
|
||||||
mov rsp, rcx
|
mov rsp, rcx
|
||||||
|
|
||||||
; Set return status
|
/* Set return status */
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
|
|
||||||
; Restore the registers from the KEXCEPTION_FRAME
|
/* Restore the registers from the KEXCEPTION_FRAME */
|
||||||
RESTORE_EXCEPTION_STATE
|
RESTORE_EXCEPTION_STATE
|
||||||
|
|
||||||
; Return
|
/* Return */
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.ENDP
|
.ENDP
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
;++
|
/*
|
||||||
; PROJECT: ReactOS SDK
|
* PROJECT: ReactOS SDK
|
||||||
; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
; PURPOSE: ReactOS AMD64 architecture asm macros
|
* PURPOSE: ReactOS AMD64 architecture asm macros
|
||||||
; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||||
;--
|
*/
|
||||||
|
|
||||||
#include <macamd64.inc>
|
#include <macamd64.inc>
|
||||||
|
|
||||||
MACRO(GENERATE_EXCEPTION_FRAME)
|
MACRO(GENERATE_EXCEPTION_FRAME)
|
||||||
|
|
||||||
; Allocate a KEXCEPTION_FRAME on the stack
|
/* Allocate a KEXCEPTION_FRAME on the stack */
|
||||||
; -8 because the last field is the return address
|
/* -8 because the last field is the return address */
|
||||||
sub rsp, KEXCEPTION_FRAME_LENGTH - 8
|
sub rsp, KEXCEPTION_FRAME_LENGTH - 8
|
||||||
.allocstack KEXCEPTION_FRAME_LENGTH - 8
|
.allocstack KEXCEPTION_FRAME_LENGTH - 8
|
||||||
|
|
||||||
; Save non-volatiles in KEXCEPTION_FRAME
|
/* Save non-volatiles in KEXCEPTION_FRAME */
|
||||||
mov [rsp + ExRbp], rbp
|
mov [rsp + ExRbp], rbp
|
||||||
.savereg rbp, ExRbp
|
.savereg rbp, ExRbp
|
||||||
mov [rsp + ExRbx], rbx
|
mov [rsp + ExRbx], rbx
|
||||||
|
@ -56,7 +56,7 @@ ENDM
|
||||||
|
|
||||||
MACRO(RESTORE_EXCEPTION_STATE)
|
MACRO(RESTORE_EXCEPTION_STATE)
|
||||||
|
|
||||||
; Restore non-volatile registers
|
/* Restore non-volatile registers */
|
||||||
mov rbp, [rsp + ExRbp]
|
mov rbp, [rsp + ExRbp]
|
||||||
mov rbx, [rsp + ExRbx]
|
mov rbx, [rsp + ExRbx]
|
||||||
mov rdi, [rsp + ExRdi]
|
mov rdi, [rsp + ExRdi]
|
||||||
|
@ -76,7 +76,7 @@ MACRO(RESTORE_EXCEPTION_STATE)
|
||||||
movaps xmm14, [rsp + ExXmm14]
|
movaps xmm14, [rsp + ExXmm14]
|
||||||
movaps xmm15, [rsp + ExXmm15]
|
movaps xmm15, [rsp + ExXmm15]
|
||||||
|
|
||||||
; Clean stack and return
|
/* Clean stack and return */
|
||||||
add rsp, KEXCEPTION_FRAME_LENGTH - 8
|
add rsp, KEXCEPTION_FRAME_LENGTH - 8
|
||||||
|
|
||||||
ENDM
|
ENDM
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
;++
|
/*
|
||||||
; PROJECT: ReactOS SDK
|
* PROJECT: ReactOS SDK
|
||||||
; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||||
; PURPOSE: ReactOS AMD64 architecture asm macros
|
* PURPOSE: ReactOS AMD64 architecture asm macros
|
||||||
; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
* COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||||
;--
|
*/
|
||||||
|
|
||||||
#include <asm.inc>
|
#include <asm.inc>
|
||||||
|
|
||||||
|
@ -156,4 +156,4 @@ MACRO(Yield)
|
||||||
pause
|
pause
|
||||||
ENDM
|
ENDM
|
||||||
|
|
||||||
; EOF
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue