From ff7035d940d31f3168b5ca767bae262615797562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Wed, 6 Jan 2021 22:50:22 +0100 Subject: [PATCH] [ASM x64] Change ; by /* */ for comments Syntax with semi-colon is not supported by gas. --- dll/ntdll/dispatch/amd64/dispatch.S | 36 +++++++-------- ntoskrnl/ke/amd64/ctxswitch.S | 12 ++--- ntoskrnl/ke/amd64/trap.S | 47 ++++++++++---------- ntoskrnl/ke/amd64/usercall_asm.S | 68 ++++++++++++++--------------- sdk/include/asm/kxamd64.inc | 22 +++++----- sdk/include/asm/macamd64.inc | 14 +++--- 6 files changed, 101 insertions(+), 98 deletions(-) diff --git a/dll/ntdll/dispatch/amd64/dispatch.S b/dll/ntdll/dispatch/amd64/dispatch.S index 86fe423ab2c..c78ff86e78d 100644 --- a/dll/ntdll/dispatch/amd64/dispatch.S +++ b/dll/ntdll/dispatch/amd64/dispatch.S @@ -62,44 +62,44 @@ PUBLIC KiRaiseUserExceptionDispatcher PUBLIC KiUserCallbackDispatcher .PROC KiUserCallbackDispatcher - ; The stack is set up with a UCALLOUT_FRAME - ; The frame ends with a MACHINE_FRAME. + /* The stack is set up with a UCALLOUT_FRAME */ + /* The frame ends with a MACHINE_FRAME. */ .PUSHFRAME - ; This is for the Home space, Buffer, Length and ApiNumber + /* This is for the Home space, Buffer, Length and ApiNumber */ .ALLOCSTACK 6 * 8 .ENDPROLOG #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 jz AlignmentOk int HEX(2C) AlignmentOk: #endif - ; Get the parameters from the callout frame + /* Get the parameters from the callout frame */ mov rcx, [rsp + CkBuffer] mov edx, [rsp + CkLength] mov r8d, [rsp + CkApiNumber] - ; Get the callback table + /* Get the callback table */ mov rax, gs:[TePeb] mov r9, [rax + PeKernelCallbackTable] - ; Call the routine + /* Call the routine */ call qword ptr [r9 + r8 * 8] - ; Return from callback + /* Return from callback */ xor ecx, ecx xor edx, edx mov r8d, eax call ZwCallbackReturn - ; Save callback return value + /* Save callback return value */ mov esi, eax - ; Raise status + /* Raise status */ StatusRaise: mov ecx, esi call RtlRaiseStatus @@ -158,11 +158,11 @@ EXTERN RtlRaiseException:PROC PUBLIC KiUserExceptionDispatcher .PROC KiUserExceptionDispatcher - ; The stack is set up with a KUSER_EXCEPTION_STACK - ; The frame ends with a MACHINE_FRAME. + /* The stack is set up with a KUSER_EXCEPTION_STACK */ + /* The frame ends with a MACHINE_FRAME. */ .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 .ENDPROLOG @@ -177,8 +177,8 @@ PUBLIC KiUserExceptionDispatcher jz RaiseException /* We're fine, continue execution */ - lea rcx, [rsp] ; ContextRecord - mov dl, 0 ; TestAlert + lea rcx, [rsp] /* ContextRecord */ + mov dl, 0 /* TestAlert */ call ZwContinue /* Exit */ @@ -187,13 +187,13 @@ PUBLIC KiUserExceptionDispatcher RaiseException: /* Raise the exception */ - lea rcx, [rsp + CONTEXT_FRAME_LENGTH] ; ExceptionRecord - lea rdx, [rsp] ; ContextRecord + lea rcx, [rsp + CONTEXT_FRAME_LENGTH] /* ExceptionRecord */ + lea rdx, [rsp] /* ContextRecord */ xor r8, r8 call ZwRaiseException Exit: - lea rcx, [rsp + CONTEXT_FRAME_LENGTH] ; ExceptionRecord + lea rcx, [rsp + CONTEXT_FRAME_LENGTH] /* ExceptionRecord */ mov rdx, rax call KiUserExceptionDispatcherNested ret diff --git a/ntoskrnl/ke/amd64/ctxswitch.S b/ntoskrnl/ke/amd64/ctxswitch.S index a88188e00d0..ddd9a734499 100644 --- a/ntoskrnl/ke/amd64/ctxswitch.S +++ b/ntoskrnl/ke/amd64/ctxswitch.S @@ -11,11 +11,13 @@ #include -; BOOLEAN -; KiSwapContextResume( -; _In_ KIRQL WaitIrql, -; _In_ PKTHREAD OldThread, -; _In_ PKTHREAD NewThread) +/* + * BOOLEAN + * KiSwapContextResume( + * _In_ KIRQL WaitIrql, + * _In_ PKTHREAD OldThread, + * _In_ PKTHREAD NewThread) + */ EXTERN KiSwapContextResume:PROC /* FUNCTIONS ****************************************************************/ diff --git a/ntoskrnl/ke/amd64/trap.S b/ntoskrnl/ke/amd64/trap.S index 2d7194b82de..b32d0ef4a4b 100644 --- a/ntoskrnl/ke/amd64/trap.S +++ b/ntoskrnl/ke/amd64/trap.S @@ -825,7 +825,7 @@ no_user_apc_pending: /* Swap gs back to user */ swapgs - ; Zero out volatiles + /* Zero out volatiles */ pxor xmm0, xmm0 pxor xmm1, xmm1 pxor xmm2, xmm2 @@ -965,7 +965,7 @@ FUNC KiConvertToGuiThread test rax, rax jz KiConvertToGuiThreadFailed - ; OldStack = KeSwitchKernelStack((PVOID)NewStack, (PVOID)(NewStack - KERNEL_STACK_SIZE)); + /* OldStack = KeSwitchKernelStack((PVOID)NewStack, (PVOID)(NewStack - KERNEL_STACK_SIZE)); */ mov rcx, rax mov rdx, rax sub rdx, KERNEL_STACK_SIZE @@ -1011,44 +1011,45 @@ KiConvertToGuiThreadFailed: ENDFUNC -; -; VOID -; KiDeliverApc( -; _In_ KPROCESSOR_MODE DeliveryMode, -; _In_ PKEXCEPTION_FRAME ExceptionFrame, -; _In_ PKTRAP_FRAME TrapFrame); -; +/* + * VOID + * KiDeliverApc( + * _In_ KPROCESSOR_MODE DeliveryMode, + * _In_ PKEXCEPTION_FRAME ExceptionFrame, + * _In_ PKTRAP_FRAME TrapFrame); + * + */ EXTERN KiDeliverApc:PROC PUBLIC KiInitiateUserApc .PROC KiInitiateUserApc - ; Generate a KEXCEPTION_FRAME on the stack + /* Generate a KEXCEPTION_FRAME on the stack */ GENERATE_EXCEPTION_FRAME - ; Raise IRQL to APC_LEVEL + /* Raise IRQL to APC_LEVEL */ mov rax, APC_LEVEL mov cr8, rax - ; Enable interrupts + /* Enable interrupts */ sti - ; Get the current trap frame + /* Get the current trap frame */ mov rax, gs:[PcCurrentThread] mov r8, [rax + KTHREAD_TrapFrame] - ; Call the C function + /* Call the C function */ mov ecx, 1 mov rdx, rsp call KiDeliverApc - ; Disable interrupts again + /* Disable interrupts again */ cli - ; Restore the registers from the KEXCEPTION_FRAME + /* Restore the registers from the KEXCEPTION_FRAME */ RESTORE_EXCEPTION_STATE - ; Return + /* Return */ ret .ENDP @@ -1092,22 +1093,22 @@ FUNC KeSwitchKernelStack sub rsp, 40 .allocstack 40 - ; Save rcx + /* Save rcx */ mov [rsp], rcx .savereg rcx, 0 .endprolog - ; Call the C handler, which returns the old stack in rax - call KiSwitchKernelStack + /* Call the C handler, which returns the old stack in rax */ + call KiSwitchKernelStack - ; Restore rcx (StackBase) + /* Restore rcx (StackBase) */ mov rcx, [rsp] - ; Switch to new stack: RSP += (StackBase - OldStackBase) + /* Switch to new stack: RSP += (StackBase - OldStackBase) */ sub rcx, rax add rsp, rcx - ; Deallocate the home frame + /* Deallocate the home frame */ add rsp, 40 ret diff --git a/ntoskrnl/ke/amd64/usercall_asm.S b/ntoskrnl/ke/amd64/usercall_asm.S index 2d894161fed..8962f2470e0 100644 --- a/ntoskrnl/ke/amd64/usercall_asm.S +++ b/ntoskrnl/ke/amd64/usercall_asm.S @@ -1,72 +1,72 @@ -;++ -; PROJECT: ReactOS Kernel -; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) -; PURPOSE: ReactOS AMD64 user mode callback helper -; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) -;-- +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: ReactOS AMD64 user mode callback helper + * COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) + */ #include -; -; NTSTATUS -; KiUserModeCallout ( -; _Inout_ PKCALLOUT_FRAME CalloutFrame); -; +/* + * NTSTATUS + * KiUserModeCallout ( + * _Inout_ PKCALLOUT_FRAME CalloutFrame); + */ EXTERN KiUserModeCallout:PROC .code64 -; -; NTSTATUS -; KiCallUserMode ( -; _In_ PVOID *OutputBuffer@, -; _In_ PULONG OutputLength@); -; +/* + * NTSTATUS + * KiCallUserMode ( + * _In_ PVOID *OutputBuffer@, + * _In_ PULONG OutputLength@); + */ PUBLIC KiCallUserMode .PROC KiCallUserMode - ; Generate a KEXCEPTION_FRAME on the stack - ; This is identical to a KCALLOUT_FRAME + /* Generate a KEXCEPTION_FRAME on the stack */ + /* This is identical to a KCALLOUT_FRAME */ GENERATE_EXCEPTION_FRAME - ; Save OutputBuffer and OutputLength + /* Save OutputBuffer and OutputLength */ mov [rsp + ExOutputBuffer], rcx mov [rsp + ExOutputLength], rdx - ; Call the C function + /* Call the C function */ mov rcx, rsp call KiUserModeCallout - ; Restore the registers from the KEXCEPTION_FRAME + /* Restore the registers from the KEXCEPTION_FRAME */ RESTORE_EXCEPTION_STATE - ; Return + /* Return */ ret .ENDP -; -; DECLSPEC_NORETURN -; VOID -; KiCallbackReturn ( -; _In_ PVOID Stack, -; _In_ NTSTATUS Status); -; +/* + * DECLSPEC_NORETURN + * VOID + * KiCallbackReturn ( + * _In_ PVOID Stack, + * _In_ NTSTATUS Status); + */ PUBLIC KiCallbackReturn .PROC KiCallbackReturn .ENDPROLOG - ; Restore the stack + /* Restore the stack */ mov rsp, rcx - ; Set return status + /* Set return status */ mov eax, edx - ; Restore the registers from the KEXCEPTION_FRAME + /* Restore the registers from the KEXCEPTION_FRAME */ RESTORE_EXCEPTION_STATE - ; Return + /* Return */ ret .ENDP diff --git a/sdk/include/asm/kxamd64.inc b/sdk/include/asm/kxamd64.inc index 187cf74e4ff..dccf8a2c409 100644 --- a/sdk/include/asm/kxamd64.inc +++ b/sdk/include/asm/kxamd64.inc @@ -1,20 +1,20 @@ -;++ -; PROJECT: ReactOS SDK -; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) -; PURPOSE: ReactOS AMD64 architecture asm macros -; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) -;-- +/* + * PROJECT: ReactOS SDK + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: ReactOS AMD64 architecture asm macros + * COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) + */ #include MACRO(GENERATE_EXCEPTION_FRAME) - ; Allocate a KEXCEPTION_FRAME on the stack - ; -8 because the last field is the return address + /* Allocate a KEXCEPTION_FRAME on the stack */ + /* -8 because the last field is the return address */ sub rsp, 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 .savereg rbp, ExRbp mov [rsp + ExRbx], rbx @@ -56,7 +56,7 @@ ENDM MACRO(RESTORE_EXCEPTION_STATE) - ; Restore non-volatile registers + /* Restore non-volatile registers */ mov rbp, [rsp + ExRbp] mov rbx, [rsp + ExRbx] mov rdi, [rsp + ExRdi] @@ -76,7 +76,7 @@ MACRO(RESTORE_EXCEPTION_STATE) movaps xmm14, [rsp + ExXmm14] movaps xmm15, [rsp + ExXmm15] - ; Clean stack and return + /* Clean stack and return */ add rsp, KEXCEPTION_FRAME_LENGTH - 8 ENDM diff --git a/sdk/include/asm/macamd64.inc b/sdk/include/asm/macamd64.inc index e342e440ded..af917f54f31 100644 --- a/sdk/include/asm/macamd64.inc +++ b/sdk/include/asm/macamd64.inc @@ -1,9 +1,9 @@ -;++ -; PROJECT: ReactOS SDK -; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) -; PURPOSE: ReactOS AMD64 architecture asm macros -; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) -;-- +/* + * PROJECT: ReactOS SDK + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) + * PURPOSE: ReactOS AMD64 architecture asm macros + * COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) + */ #include @@ -156,4 +156,4 @@ MACRO(Yield) pause ENDM -; EOF +/* EOF */