From: Timo Kreuzer Date: Sat, 20 Nov 2010 11:09:32 +0000 (+0000) Subject: [NTOSKRNL] X-Git-Tag: backups/GSoC_2011/GSoC_Themes@51550~481 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=66a7b7ba1d1b6dea572ffa48282fd28817ee3e82 [NTOSKRNL] Convert assembly to new sytax svn path=/branches/cmake-bringup/; revision=49657 --- diff --git a/ntoskrnl/ex/i386/fastinterlck_asm.S b/ntoskrnl/ex/i386/fastinterlck_asm.S index f09edfd3b9c..566f37f5a0c 100644 --- a/ntoskrnl/ex/i386/fastinterlck_asm.S +++ b/ntoskrnl/ex/i386/fastinterlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -30,7 +29,7 @@ *ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend, * IN ULONG Increment) */ -.global @ExInterlockedAddLargeStatistic@8 +PUBLIC @ExInterlockedAddLargeStatistic@8 @ExInterlockedAddLargeStatistic@8: #ifdef CONFIG_SMP @@ -38,10 +37,10 @@ lock add [ecx], edx /* Check for carry bit and return */ - jb 1f + jb .l1 ret -1: +.l1: /* Add carry */ lock adc dword ptr [ecx+4], 0 #else @@ -58,7 +57,7 @@ * IN ULONG Increment, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedAddUlong@12 +PUBLIC @ExfInterlockedAddUlong@12 @ExfInterlockedAddUlong@12: /* Save flags */ @@ -103,7 +102,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertHeadList@12 +PUBLIC @ExfInterlockedInsertHeadList@12 @ExfInterlockedInsertHeadList@12: #ifdef CONFIG_SMP @@ -139,11 +138,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l2 /* Return list pointer */ xor eax, ecx -2: +.l2: ret 4 #ifdef CONFIG_SMP @@ -159,7 +158,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedInsertTailList@12 +PUBLIC @ExfInterlockedInsertTailList@12 @ExfInterlockedInsertTailList@12: #ifdef CONFIG_SMP @@ -195,11 +194,11 @@ /* Check if list was empty */ xor eax, ecx - jz 2f + jz .l3 /* Return list pointer */ xor eax, ecx -2: +.l3: ret 4 #ifdef CONFIG_SMP @@ -214,7 +213,7 @@ *ExfInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedRemoveHeadList@8 +PUBLIC @ExfInterlockedRemoveHeadList@8 @ExfInterlockedRemoveHeadList@8: /* Save flags and disable interrupts */ @@ -228,7 +227,7 @@ /* Check if it's empty */ cmp eax, ecx - je 2f + je .l4 /* Get the next entry and do the deletion */ #ifdef CONFIG_SMP @@ -254,7 +253,7 @@ /* Return */ ret -2: +.l4: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -276,7 +275,7 @@ *ExfInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntryList@8 +PUBLIC @ExfInterlockedPopEntryList@8 @ExfInterlockedPopEntryList@8: /* Save flags and disable interrupts */ @@ -290,7 +289,7 @@ /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ #ifdef CONFIG_SMP @@ -302,7 +301,7 @@ pop edx #endif -2: +.l5: /* Release lock */ RELEASE_SPINLOCK(edx) @@ -312,10 +311,10 @@ /* Return */ ret -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin5: @@ -329,7 +328,7 @@ * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntryList@12 +PUBLIC @ExfInterlockedPushEntryList@12 @ExfInterlockedPushEntryList@12: /* Save flags */ @@ -383,11 +382,11 @@ *ExInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPopEntrySList@8 -.global @InterlockedPopEntrySList@4 -.global _ExpInterlockedPopEntrySListResume@0 -.global _ExpInterlockedPopEntrySListFault@0 -.global _ExpInterlockedPopEntrySListEnd@0 +PUBLIC @ExInterlockedPopEntrySList@8 +PUBLIC @InterlockedPopEntrySList@4 +PUBLIC _ExpInterlockedPopEntrySListResume@0 +PUBLIC _ExpInterlockedPopEntrySListFault@0 +PUBLIC _ExpInterlockedPopEntrySListEnd@0 @ExInterlockedPopEntrySList@8: @InterlockedPopEntrySList@4: @@ -405,7 +404,7 @@ _ExpInterlockedPopEntrySListResume@0: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l7 /* Copy sequence number and adjust it */ lea ecx, [edx-1] @@ -418,7 +417,7 @@ _ExpInterlockedPopEntrySListEnd@0: jnz _ExpInterlockedPopEntrySListResume@0 /* Restore registers and return */ -2: +.l7: pop ebp pop ebx ret @@ -429,13 +428,13 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedPushEntrySList@12 +PUBLIC @ExInterlockedPushEntrySList@12 @ExInterlockedPushEntrySList@12: /* So we can fall through below */ pop [esp] -.global @InterlockedPushEntrySList@8 +PUBLIC @InterlockedPushEntrySList@8 @InterlockedPushEntrySList@8: /* Save registers */ @@ -450,19 +449,18 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l8: /* Set link pointer */ mov [ebx], eax /* Copy sequence number and adjust it */ - lea ecx, [edx+0x10001] + lea ecx, [edx + HEX(10001)] /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l8 /* Restore registers and return */ -2: pop ebp pop ebx ret @@ -471,7 +469,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *ExInterlockedFlushSList(IN PSINGLE_LIST_ENTRY ListHead) */ -.global @ExInterlockedFlushSList@4 +PUBLIC @ExInterlockedFlushSList@4 @ExInterlockedFlushSList@4: /* Save registers */ @@ -488,10 +486,10 @@ _ExpInterlockedPopEntrySListEnd@0: mov edx, [ebp+4] mov eax, [ebp] -1: +.l9: /* Check if the list is empty */ or eax, eax - jz 2f + jz .l10 /* Clear sequence and pointer */ mov ecx, edx @@ -499,10 +497,10 @@ _ExpInterlockedPopEntrySListEnd@0: /* Do the exchange */ LOCK cmpxchg8b qword ptr [ebp] - jnz 1b + jnz .l9 /* Restore registers and return */ -2: +.l10: pop ebp pop ebx ret @@ -511,7 +509,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedIncrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedIncrementLong@4 +PUBLIC @Exfi386InterlockedIncrementLong@4 @Exfi386InterlockedIncrementLong@4: /* Do the op */ @@ -526,7 +524,7 @@ _ExpInterlockedPopEntrySListEnd@0: *FASTCALL *Exfi386InterlockedDecrementLong(IN PLONG Addend) */ -.global @Exfi386InterlockedDecrementLong@4 +PUBLIC @Exfi386InterlockedDecrementLong@4 @Exfi386InterlockedDecrementLong@4: /* Do the op */ @@ -542,7 +540,7 @@ _ExpInterlockedPopEntrySListEnd@0: *Exfi386InterlockedExchangeUlong(IN PULONG Taget, * IN ULONG Value) */ -.global @Exfi386InterlockedExchangeUlong@8 +PUBLIC @Exfi386InterlockedExchangeUlong@8 @Exfi386InterlockedExchangeUlong@8: #ifdef CONFIG_SMP @@ -552,9 +550,9 @@ _ExpInterlockedPopEntrySListEnd@0: #else /* On UP, use cmpxchg */ mov eax, [ecx] -1: +.l11: cmpxchg [ecx], edx - jnz 1b + jnz .l11 #endif /* Return */ @@ -566,7 +564,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Exchange, * IN PLONGLONG Comperand) */ -.global @ExfInterlockedCompareExchange64@12 +PUBLIC @ExfInterlockedCompareExchange64@12 @ExfInterlockedCompareExchange64@12: /* Save registers */ @@ -598,7 +596,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExInterlockedCompareExchange64@16 +PUBLIC @ExInterlockedCompareExchange64@16 @ExInterlockedCompareExchange64@16: /* Save registers */ @@ -630,7 +628,7 @@ _ExpInterlockedPopEntrySListEnd@0: *ExfInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPopEntrySList@8 +PUBLIC @ExfInterlockedPopEntrySList@8 @ExfInterlockedPopEntrySList@8: /* Save flags */ @@ -646,7 +644,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Get the next link and check if it's empty */ mov eax, [ecx] or eax, eax - jz 1f + jz .l12 /* Get address of the next link and store it */ push [eax] @@ -655,7 +653,7 @@ _ExpInterlockedPopEntrySListEnd@0: /* Decrement list depth */ dec dword ptr [ecx+4] -1: +.l12: #ifdef CONFIG_SMP /* Release spinlock */ RELEASE_SPINLOCK(edx) @@ -678,7 +676,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global @ExfInterlockedPushEntrySList@12 +PUBLIC @ExfInterlockedPushEntrySList@12 @ExfInterlockedPushEntrySList@12: /* Save flags */ @@ -727,7 +725,7 @@ _ExpInterlockedPopEntrySListEnd@0: * IN PLONGLONG Comperand, * IN PKSPIN_LOCK Lock) */ -.global @ExpInterlockedCompareExchange64@16 +PUBLIC @ExpInterlockedCompareExchange64@16 @ExpInterlockedCompareExchange64@16: /* Save registers */ @@ -802,4 +800,6 @@ NoMatch: pushfd SPIN_ON_LOCK(esi, .startc) #endif + +END /* EOF */ diff --git a/ntoskrnl/ex/i386/interlck_asm.S b/ntoskrnl/ex/i386/interlck_asm.S index 954091cee85..755813e80d8 100644 --- a/ntoskrnl/ex/i386/interlck_asm.S +++ b/ntoskrnl/ex/i386/interlck_asm.S @@ -8,14 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include /* FUNCTIONS ****************************************************************/ .code32 -.text /* * NOTE: These functions must obey the following rules: @@ -31,7 +30,7 @@ * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddLargeInteger@16 +PUBLIC _ExInterlockedAddLargeInteger@16 _ExInterlockedAddLargeInteger@16: /* Prepare stack frame */ @@ -97,7 +96,7 @@ _ExInterlockedAddLargeInteger@16: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedAddUlong@12 +PUBLIC _ExInterlockedAddUlong@12 _ExInterlockedAddUlong@12: /* Save flags and disable interrupts */ @@ -153,7 +152,7 @@ _ExInterlockedAddUlong@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertHeadList@12 +PUBLIC _ExInterlockedInsertHeadList@12 _ExInterlockedInsertHeadList@12: /* Save lock pointer */ @@ -189,12 +188,12 @@ _ExInterlockedInsertHeadList@12: /* check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l2 /* Return pointer */ mov eax, edx -2: +.l2: ret 12 #ifdef CONFIG_SMP @@ -209,7 +208,7 @@ _ExInterlockedInsertHeadList@12: * IN PLIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedInsertTailList@12 +PUBLIC _ExInterlockedInsertTailList@12 _ExInterlockedInsertTailList@12: /* Save lock pointer */ @@ -245,12 +244,12 @@ _ExInterlockedInsertTailList@12: /* Check if the list was empty and return NULL */ xor eax, edx - jz 2f + jz .l3 /* Return pointer */ mov eax, edx -2: +.l3: ret 12 #ifdef CONFIG_SMP @@ -264,7 +263,7 @@ _ExInterlockedInsertTailList@12: *ExInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedRemoveHeadList@8 +PUBLIC _ExInterlockedRemoveHeadList@8 _ExInterlockedRemoveHeadList@8: /* Save lock pointer */ @@ -284,7 +283,7 @@ _ExInterlockedRemoveHeadList@8: /* Check if it's empty */ cmp eax, edx - je 2f + je .l4 /* Get next entry and do deletion */ mov ecx, [eax] @@ -303,7 +302,7 @@ _ExInterlockedRemoveHeadList@8: /* Return */ ret 8 -2: +.l4: /* Release lock */ #ifdef CONFIG_SMP mov edx, [esp+12] @@ -328,7 +327,7 @@ _ExInterlockedRemoveHeadList@8: *ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPopEntryList@8 +PUBLIC _ExInterlockedPopEntryList@8 _ExInterlockedPopEntryList@8: /* Save lock pointer */ @@ -348,13 +347,13 @@ _ExInterlockedPopEntryList@8: /* Check if it's empty */ or eax, eax - je 3f + je .l6 /* Get next entry and do deletion */ mov edx, [eax] mov [ecx], edx -2: +.l5: /* Release lock */ #ifdef CONFIG_SMP mov ecx, [esp+12] @@ -367,10 +366,10 @@ _ExInterlockedPopEntryList@8: /* Return */ ret 8 -3: +.l6: /* Return empty list */ xor eax, eax - jmp 2b + jmp .l5 #ifdef CONFIG_SMP .spin6: @@ -384,7 +383,7 @@ _ExInterlockedPopEntryList@8: * IN PSINGLE_LIST_ENTRY ListEntry, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedPushEntryList@12 +PUBLIC _ExInterlockedPushEntryList@12 _ExInterlockedPushEntryList@12: /* Save lock pointer */ @@ -430,7 +429,7 @@ _ExInterlockedPushEntryList@12: *ExInterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedIncrementLong@8 +PUBLIC _ExInterlockedIncrementLong@8 _ExInterlockedIncrementLong@8: /* Get addend */ @@ -449,7 +448,7 @@ _ExInterlockedIncrementLong@8: *ExInterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedDecrementLong@8 +PUBLIC _ExInterlockedDecrementLong@8 _ExInterlockedDecrementLong@8: /* Get addend */ @@ -469,7 +468,7 @@ _ExInterlockedDecrementLong@8: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _ExInterlockedExchangeUlong@12 +PUBLIC _ExInterlockedExchangeUlong@12 _ExInterlockedExchangeUlong@12: /* Get pointers */ @@ -498,7 +497,7 @@ _ExInterlockedExchangeUlong@12: *Exi386InterlockedIncrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedIncrementLong@4 +PUBLIC _Exi386InterlockedIncrementLong@4 _Exi386InterlockedIncrementLong@4: /* Get addend */ @@ -517,7 +516,7 @@ _Exi386InterlockedIncrementLong@4: *Exi386InterlockedDecrementLong(IN PLONG Addend, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedDecrementLong@4 +PUBLIC _Exi386InterlockedDecrementLong@4 _Exi386InterlockedDecrementLong@4: /* Get addend */ @@ -537,7 +536,7 @@ _Exi386InterlockedDecrementLong@4: * IN ULONG Value, * IN PKSPIN_LOCK Lock) */ -.global _Exi386InterlockedExchangeUlong@12 +PUBLIC _Exi386InterlockedExchangeUlong@12 _Exi386InterlockedExchangeUlong@12: /* Get pointers */ @@ -560,5 +559,6 @@ _Exi386InterlockedExchangeUlong@12: /* Return */ ret 8 - + +END /* EOF */ diff --git a/ntoskrnl/ex/i386/ioport.S b/ntoskrnl/ex/i386/ioport.S index c9c55a160f4..ba456c799f8 100644 --- a/ntoskrnl/ex/i386/ioport.S +++ b/ntoskrnl/ex/i386/ioport.S @@ -8,54 +8,52 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* GLOBALS *******************************************************************/ -.globl _READ_REGISTER_UCHAR@4 -.globl _READ_REGISTER_USHORT@4 -.globl _READ_REGISTER_ULONG@4 -.globl _READ_REGISTER_BUFFER_UCHAR@12 -.globl _READ_REGISTER_BUFFER_USHORT@12 -.globl _READ_REGISTER_BUFFER_ULONG@12 -.globl _WRITE_REGISTER_UCHAR@8 -.globl _WRITE_REGISTER_USHORT@8 -.globl _WRITE_REGISTER_ULONG@8 -.globl _WRITE_REGISTER_BUFFER_UCHAR@12 -.globl _WRITE_REGISTER_BUFFER_USHORT@12 -.globl _WRITE_REGISTER_BUFFER_ULONG@12 +PUBLIC _READ_REGISTER_UCHAR@4 +PUBLIC _READ_REGISTER_USHORT@4 +PUBLIC _READ_REGISTER_ULONG@4 +PUBLIC _READ_REGISTER_BUFFER_UCHAR@12 +PUBLIC _READ_REGISTER_BUFFER_USHORT@12 +PUBLIC _READ_REGISTER_BUFFER_ULONG@12 +PUBLIC _WRITE_REGISTER_UCHAR@8 +PUBLIC _WRITE_REGISTER_USHORT@8 +PUBLIC _WRITE_REGISTER_ULONG@8 +PUBLIC _WRITE_REGISTER_BUFFER_UCHAR@12 +PUBLIC _WRITE_REGISTER_BUFFER_USHORT@12 +PUBLIC _WRITE_REGISTER_BUFFER_ULONG@12 /* FUNCTIONS *****************************************************************/ -.func READ_REGISTER_UCHAR@4 +.code + _READ_REGISTER_UCHAR@4: /* Return the requested memory location */ mov edx, [esp+4] mov al, [edx] ret 4 -.endfunc -.func READ_REGISTER_USHORT@4 + _READ_REGISTER_USHORT@4: /* Return the requested memory location */ mov edx, [esp+4] mov ax, [edx] ret 4 -.endfunc -.func READ_REGISTER_ULONG@4 + _READ_REGISTER_ULONG@4: /* Return the requested memory location */ mov edx, [esp+4] mov eax, [edx] ret 4 -.endfunc -.func READ_REGISTER_BUFFER_UCHAR@12 + _READ_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -72,9 +70,8 @@ _READ_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_USHORT@12 + _READ_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -91,9 +88,8 @@ _READ_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func READ_REGISTER_BUFFER_ULONG@12 + _READ_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -110,9 +106,8 @@ _READ_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_UCHAR@8 + _WRITE_REGISTER_UCHAR@8: /* Write to memory */ @@ -123,9 +118,8 @@ _WRITE_REGISTER_UCHAR@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_USHORT@8 + _WRITE_REGISTER_USHORT@8: /* Write to memory */ @@ -136,9 +130,8 @@ _WRITE_REGISTER_USHORT@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_ULONG@8 + _WRITE_REGISTER_ULONG@8: /* Write to memory */ @@ -149,9 +142,8 @@ _WRITE_REGISTER_ULONG@8: /* Flush posted write buffers and return */ lock or [esp+4], edx ret 8 -.endfunc -.func WRITE_REGISTER_BUFFER_UCHAR@12 + _WRITE_REGISTER_BUFFER_UCHAR@12: /* Save volatiles */ @@ -171,9 +163,8 @@ _WRITE_REGISTER_BUFFER_UCHAR@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_USHORT@12 + _WRITE_REGISTER_BUFFER_USHORT@12: /* Save volatiles */ @@ -193,9 +184,8 @@ _WRITE_REGISTER_BUFFER_USHORT@12: mov edi, edx mov esi, eax ret 12 -.endfunc -.func WRITE_REGISTER_BUFFER_ULONG@12 + _WRITE_REGISTER_BUFFER_ULONG@12: /* Save volatiles */ @@ -215,6 +205,6 @@ _WRITE_REGISTER_BUFFER_ULONG@12: mov edi, edx mov esi, eax ret 12 -.endfunc +END /* EOF */ diff --git a/ntoskrnl/include/internal/i386/asmmacro.S b/ntoskrnl/include/internal/i386/asmmacro.S index 6ddb9d015ad..2a64a938320 100644 --- a/ntoskrnl/include/internal/i386/asmmacro.S +++ b/ntoskrnl/include/internal/i386/asmmacro.S @@ -60,8 +60,8 @@ // @remark None. // MACRO(idt, Handler, Bits) - .long \Handler - .short \Bits + .long VAL(Handler) + .short VAL(Bits) .short KGDT_R0_CODE ENDM @@ -128,17 +128,17 @@ MACRO(KiEnterTrap, Flags) mov [esp + KTRAP_FRAME_EAX], eax /* Does the caller want nonvolatiles only? */ - if ((Flags AND KI_NONVOLATILES_ONLY) == 0) + if (NOT (Flags AND KI_NONVOLATILES_ONLY)) /* Otherwise, save the volatiles as well */ mov [esp + KTRAP_FRAME_ECX], ecx mov [esp + KTRAP_FRAME_EDX], edx endif /* Save segment registers? */ - if ((Flags AND KI_DONT_SAVE_SEGS) == 0) + if (NOT (Flags AND KI_DONT_SAVE_SEGS)) /* Check for V86 mode */ - test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK >> 16) + test byte ptr [esp + KTRAP_FRAME_EFLAGS + 2], (EFLAGS_V86_MASK / HEX(10000)) jz not_v86_trap /* Restore V8086 segments into Protected Mode segments */ @@ -173,7 +173,7 @@ set_sane_segs: mov es, ax /* Fast system calls have fs already fixed */ - if ((Flags AND KI_FAST_SYSTEM_CALL) == 0) + if (NOT (Flags AND KI_FAST_SYSTEM_CALL)) /* Otherwise fix fs now */ mov ax, KGDT_R0_PCR mov fs, ax @@ -296,7 +296,7 @@ PUBLIC @&Name&@4 mov ecx, [esp - OffsetEsp + KTRAP_FRAME_ESP] /* Keep interrupts disabled until the sti / sysexit */ - and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], ~(EFLAGS_INTERRUPT_MASK >> 8) + and byte ptr [esp - OffsetEsp + KTRAP_FRAME_EFLAGS + 1], NOT (EFLAGS_INTERRUPT_MASK / HEX(100)) endif diff --git a/ntoskrnl/kdbg/amd64/kdb_help.S b/ntoskrnl/kdbg/amd64/kdb_help.S index eb777010513..eca6dcfbdac 100644 --- a/ntoskrnl/kdbg/amd64/kdb_help.S +++ b/ntoskrnl/kdbg/amd64/kdb_help.S @@ -1,7 +1,9 @@ -#include -#include -.globl KdbEnter +#include + +#include + +PUBLIC KdbEnter KdbEnter: /* save flags */ @@ -149,4 +151,6 @@ KdbpStackSwitchAndCall: mov rsp, rax /* Return */ - ret \ No newline at end of file + ret + +END \ No newline at end of file diff --git a/ntoskrnl/kdbg/i386/kdb_help.S b/ntoskrnl/kdbg/i386/kdb_help.S index 00cb522c17c..e586f14c5e7 100644 --- a/ntoskrnl/kdbg/i386/kdb_help.S +++ b/ntoskrnl/kdbg/i386/kdb_help.S @@ -1,68 +1,72 @@ -#include -.text +#include +#include -.globl _KdbEnter +EXTERN _KdbEnterDebuggerException:PROC + +.code + +PUBLIC _KdbEnter _KdbEnter: /* * Set up a trap frame */ - pushfl /* Eflags */ - pushl %cs /* Cs */ - pushl $0 /* ErrorCode */ - pushl %ebp /* Ebp */ - pushl %ebx /* Ebx */ - movl 20(%esp), %ebp /* Eip */ - movl 16(%esp), %ebx /* Eflags */ - movl %ebx, 20(%esp) - movl 12(%esp), %ebx /* Cs */ - movl %ebx, 16(%esp) - movl %ebp, 12(%esp) - pushl %esi /* Esi */ - pushl %edi /* Edi */ - pushl %fs /* Fs */ - pushl $0 /* ExceptionList */ - pushl $0 /* PreviousMode */ - pushl %eax /* Eax */ - pushl %ecx /* Ecx */ - pushl %edx /* Edx */ - pushl %ds /* Ds */ - pushl %es /* Es */ - pushl %gs /* Gs */ - movl %dr7, %eax - pushl %eax /* Dr7 */ + pushf /* Eflags */ + push cs /* Cs */ + push 0 /* ErrorCode */ + push ebp /* Ebp */ + push ebx /* Ebx */ + mov ebp, [esp + 20] /* Eip */ + mov ebx, [esp + 16] /* Eflags */ + mov [esp + 20], ebx + mov ebx, [esp + 12] /* Cs */ + mov [esp + 16], ebx + mov [esp + 12], ebp + push esi /* Esi */ + push edi /* Edi */ + push fs /* Fs */ + push 0 /* ExceptionList */ + push 0 /* PreviousMode */ + push eax /* Eax */ + push ecx /* Ecx */ + push edx /* Edx */ + push ds /* Ds */ + push es /* Es */ + push gs /* Gs */ + mov eax, dr7 + push eax /* Dr7 */ /* Clear all breakpoint enables in dr7. */ - andl $0xFFFF0000, %eax - movl %eax, %dr7 - movl %dr6, %eax - pushl %eax /* Dr6 */ - movl %dr3, %eax - pushl %eax /* Dr3 */ - movl %dr2, %eax - pushl %eax /* Dr2 */ - movl %dr1, %eax - pushl %eax /* Dr1 */ - movl %dr0, %eax - pushl %eax /* Dr0 */ - leal 0x58(%esp), %eax - pushl %eax /* TempEsp */ - pushl %ss /* TempSegSs */ - pushl $0 /* DebugPointer */ - pushl $3 /* DebugArgMark (Exception number) */ - pushl 0x60(%esp) /* DebugEip */ - pushl %ebp /* DebugEbp */ + and eax, HEX(0FFFF0000) + mov dr7, eax + mov eax, dr6 + push eax /* Dr6 */ + mov eax, dr3 + push eax /* Dr3 */ + mov eax, dr2 + push eax /* Dr2 */ + mov eax, dr1 + push eax /* Dr1 */ + mov eax, dr0 + push eax /* Dr0 */ + lea eax, [esp + HEX(58)] + push eax /* TempEsp */ + push ss /* TempSegSs */ + push 0 /* DebugPointer */ + push 3 /* DebugArgMark (Exception number) */ + push [esp + HEX(60)] /* DebugEip */ + push ebp /* DebugEbp */ /* * Call KDB */ - movl %esp, %eax - pushl $1 /* FirstChance */ - pushl %eax /* Push a pointer to the trap frame */ - pushl $0 /* Context */ - pushl $0 /* PreviousMode (KernelMode) */ - pushl $0 /* ExceptionRecord */ - call _KdbEnterDebuggerException + mov eax, esp + push 1 /* FirstChance */ + push eax /* Push a pointer to the trap frame */ + push 0 /* Context */ + push 0 /* PreviousMode (KernelMode) */ + push 0 /* ExceptionRecord */ + call _KdbEnterDebuggerException /* * Pop the arguments and unused portions of the trap frame: @@ -73,41 +77,41 @@ _KdbEnter: * TempSegSs * TempEsp */ - addl $(11*4), %esp + add esp, 11*4 /* * Restore/update debugging registers. */ - popl %eax /* Dr0 */ - movl %eax, %dr0 - popl %eax /* Dr1 */ - movl %eax, %dr1 - popl %eax /* Dr2 */ - movl %eax, %dr2 - popl %eax /* Dr3 */ - movl %eax, %dr3 - popl %eax /* Dr6 */ - movl %eax, %dr6 - popl %eax /* Dr7 */ - movl %eax, %dr7 + pop eax /* Dr0 */ + mov dr0, eax + pop eax /* Dr1 */ + mov dr1, eax + pop eax /* Dr2 */ + mov dr2, eax + pop eax /* Dr3 */ + mov dr3, eax + pop eax /* Dr6 */ + mov dr6, eax + pop eax /* Dr7 */ + mov dr7, eax /* * Restore registers including any that might have been changed * inside the debugger. */ - popl %gs /* Gs */ - popl %es /* Es */ - popl %ds /* Ds */ - popl %edx /* Edx */ - popl %ecx /* Ecx */ - popl %eax /* Eax */ - addl $8, %esp /* PreviousMode, ExceptionList */ - popl %fs /* Fs */ - popl %edi /* Edi */ - popl %esi /* Esi */ - popl %ebx /* Ebx */ - popl %ebp /* Ebp */ - addl $4, %esp /* ErrorCode */ + pop gs /* Gs */ + pop es /* Es */ + pop ds /* Ds */ + pop edx /* Edx */ + pop ecx /* Ecx */ + pop eax /* Eax */ + add esp, 8 /* PreviousMode, ExceptionList */ + pop fs /* Fs */ + pop edi /* Edi */ + pop esi /* Esi */ + pop ebx /* Ebx */ + pop ebp /* Ebp */ + add esp, 4 /* ErrorCode */ /* * Return to the caller. @@ -115,26 +119,27 @@ _KdbEnter: iret -.globl _KdbpStackSwitchAndCall@8 +PUBLIC _KdbpStackSwitchAndCall@8 _KdbpStackSwitchAndCall@8: - pushl %ebp - movl %esp, %ebp + push ebp + mov ebp, esp - movl 0x8(%esp), %eax /* New stack */ - movl 0xC(%esp), %ecx /* Function to call */ - movl %esp, %edx /* Old stack */ + mov eax, [esp + 8] /* New stack */ + mov ecx, [esp + 12] /* Function to call */ + mov edx, esp /* Old stack */ /* Switch stack */ - movl %eax, %esp - pushl %edx + mov esp, eax + push edx /* Call function */ - call *%ecx + call ecx /* Switch back to old stack */ - popl %esp + pop esp /* Return */ - popl %ebp - ret $8 + pop ebp + ret 8 +END diff --git a/ntoskrnl/ke/amd64/boot.S b/ntoskrnl/ke/amd64/boot.S index f1715c6663e..4efbef3f94a 100644 --- a/ntoskrnl/ke/amd64/boot.S +++ b/ntoskrnl/ke/amd64/boot.S @@ -2,14 +2,14 @@ * FILE: ntoskrnl/ke/i386/boot.S * COPYRIGHT: See COPYING in the top level directory * PURPOSE: FreeLDR Wrapper Bootstrap Code and Bootstrap Trampoline - * PROGRAMMERs: Alex Ionescu (alex@relsoft.net) - * Thomas Weidenmueller + * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiInitializeKernelAndGotoIdleLoop:PROC diff --git a/ntoskrnl/ke/amd64/ctxswitch.S b/ntoskrnl/ke/amd64/ctxswitch.S index 61ce1473e53..1c9b13e5737 100644 --- a/ntoskrnl/ke/amd64/ctxswitch.S +++ b/ntoskrnl/ke/amd64/ctxswitch.S @@ -9,8 +9,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include /* FUNCTIONS ****************************************************************/ diff --git a/ntoskrnl/ke/amd64/trap.S b/ntoskrnl/ke/amd64/trap.S index 532f6bbdb91..2b95b42894d 100644 --- a/ntoskrnl/ke/amd64/trap.S +++ b/ntoskrnl/ke/amd64/trap.S @@ -7,8 +7,9 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include + +#include EXTERN KiDispatchException:PROC EXTERN FrLdrDbgPrint:DWORD diff --git a/ntoskrnl/ke/i386/cpu.c b/ntoskrnl/ke/i386/cpu.c index a8db4d5b5dd..2606297c1b4 100644 --- a/ntoskrnl/ke/i386/cpu.c +++ b/ntoskrnl/ke/i386/cpu.c @@ -109,7 +109,13 @@ RDMSR(IN ULONG Register) #define CX86_CCR1 0xc1 /* NSC/Cyrix CPU indexed register access macros */ -#define getCx86(reg) ({ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23); }) +static __inline +ULONG +getCx86(UCHAR reg) +{ + WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg); + return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23); +} #define setCx86(reg, data) do { \ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); \ diff --git a/ntoskrnl/ke/i386/ctxswitch.S b/ntoskrnl/ke/i386/ctxswitch.S index 9a9c95f4db1..8fba093426f 100644 --- a/ntoskrnl/ke/i386/ctxswitch.S +++ b/ntoskrnl/ke/i386/ctxswitch.S @@ -10,22 +10,27 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include + +EXTERN @KiSwapContextEntry@8:PROC +EXTERN @KiSwapContextExit@8:PROC +EXTERN @KiRetireDpcList@4:PROC +EXTERN @KiEnterV86Mode@4:PROC +EXTERN @KiExitV86Mode@4:PROC /* FUNCTIONS ****************************************************************/ +.code -.globl @KiSwapContextInternal@0 -.func @KiSwapContextInternal@0, @KiSwapContextInternal@0 +PUBLIC @KiSwapContextInternal@0 @KiSwapContextInternal@0: /* Build switch frame */ sub esp, 2 * 4 mov ecx, esp jmp @KiSwapContextEntry@8 -.endfunc -.globl @KiSwapContext@8 -.func @KiSwapContext@8, @KiSwapContext@8 + +PUBLIC @KiSwapContext@8 @KiSwapContext@8: /* Save 4 registers */ sub esp, 4 * 4 @@ -51,10 +56,9 @@ /* Clean stack */ add esp, 4 * 4 ret -.endfunc -.globl @KiSwitchThreads@8 -.func @KiSwitchThreads@8, @KiSwitchThreads@8 + +PUBLIC @KiSwitchThreads@8 @KiSwitchThreads@8: /* Load the new kernel stack and switch OS to new thread */ mov esp, edx @@ -63,10 +67,9 @@ /* Now we're on the new thread. Return to the caller to restore registers */ add esp, 2 * 4 ret -.endfunc -.globl @KiRetireDpcListInDpcStack@8 -.func @KiRetireDpcListInDpcStack@8, @KiRetireDpcListInDpcStack@8 + +PUBLIC @KiRetireDpcListInDpcStack@8 @KiRetireDpcListInDpcStack@8: /* Switch stacks and retire DPCs */ mov eax, esp @@ -77,11 +80,10 @@ /* Return on original stack */ pop esp ret -.endfunc + /* FIXFIX: Move to C code ****/ -.globl _Ki386SetupAndExitToV86Mode@4 -.func Ki386SetupAndExitToV86Mode@4 +PUBLIC _Ki386SetupAndExitToV86Mode@4 _Ki386SetupAndExitToV86Mode@4: /* Enter V8086 mode */ @@ -90,9 +92,9 @@ _Ki386SetupAndExitToV86Mode@4: mov ecx, esp call @KiEnterV86Mode@4 jmp $ -.endfunc -.globl @Ki386BiosCallReturnAddress@4 + +PUBLIC @Ki386BiosCallReturnAddress@4 @Ki386BiosCallReturnAddress@4: /* Exit V8086 mode */ @@ -102,3 +104,4 @@ _Ki386SetupAndExitToV86Mode@4: popad ret 4 +END diff --git a/ntoskrnl/ke/i386/trap.s b/ntoskrnl/ke/i386/trap.s index adfcd322dd9..f3c99c48c77 100644 --- a/ntoskrnl/ke/i386/trap.s +++ b/ntoskrnl/ke/i386/trap.s @@ -9,8 +9,8 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include MACRO(GENERATE_IDT_STUB, Number) @@ -18,16 +18,19 @@ idt _KiUnexpectedInterrupt&Number, INT_32_DPL0 ENDM MACRO(GENERATE_INT_HANDLER, Number) -.func KiUnexpectedInterrupt&Number +//.func KiUnexpectedInterrupt&Number _KiUnexpectedInterrupt&Number: push PRIMARY_VECTOR_BASE + Number jmp _KiEndUnexpectedRange@0 -.endfunc +//.endfunc ENDM +EXTERN _KiTrap02:PROC + /* GLOBALS *******************************************************************/ .data +ASSUME nothing PUBLIC _KiIdt _KiIdt: @@ -52,9 +55,9 @@ idt _KiTrap10, INT_32_DPL0 /* INT 10: x87 FPU Error (#MF) */ idt _KiTrap11, INT_32_DPL0 /* INT 11: Align Check Exception (#AC) */ idt _KiTrap0F, INT_32_DPL0 /* INT 12: Machine Check Exception (#MC)*/ idt _KiTrap0F, INT_32_DPL0 /* INT 13: SIMD FPU Exception (#XF) */ -.rept 22 +REPEAT 22 idt _KiTrap0F, INT_32_DPL0 /* INT 14-29: UNDEFINED INTERRUPTS */ -.endr +ENDR idt _KiGetTickCount, INT_32_DPL3 /* INT 2A: Get Tick Count Handler */ idt _KiCallbackReturn, INT_32_DPL3 /* INT 2B: User-Mode Callback Return */ idt _KiRaiseAssertion, INT_32_DPL3 /* INT 2C: Debug Assertion Handler */ @@ -62,15 +65,15 @@ idt _KiDebugService, INT_32_DPL3 /* INT 2D: Debug Service Handler */ idt _KiSystemService, INT_32_DPL3 /* INT 2E: System Call Service Handler */ idt _KiTrap0F, INT_32_DPL0 /* INT 2F: RESERVED */ i = 0 -.rept 208 +REPEAT 208 GENERATE_IDT_STUB %i i = i + 1 -.endr +ENDR PUBLIC _KiIdtDescriptor _KiIdtDescriptor: .short 0 - .short 0x7FF + .short HEX(7FF) .long _KiIdt PUBLIC _KiUnexpectedEntrySize @@ -78,8 +81,7 @@ _KiUnexpectedEntrySize: .long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0 /******************************************************************************/ -.code32 -.text +.code TRAP_ENTRY KiTrap00, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiTrap01, KI_PUSH_FAKE_ERROR_CODE @@ -106,7 +108,7 @@ TRAP_ENTRY KiDebugService, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY KiUnexpectedInterruptTail, 0 ALIGN 4 -EXTERN @KiInterruptTemplateHandler@8 +EXTERN @KiInterruptTemplateHandler@8:PROC PUBLIC _KiInterruptTemplate _KiInterruptTemplate: KiEnterTrap KI_PUSH_FAKE_ERROR_CODE @@ -135,10 +137,10 @@ _KiFastCallEntry: PUBLIC _KiStartUnexpectedRange@0 _KiStartUnexpectedRange@0: i = 0 -.rept 208 +REPEAT 208 GENERATE_INT_HANDLER %i i = i + 1 -.endr +ENDR PUBLIC _KiEndUnexpectedRange@0 _KiEndUnexpectedRange@0: jmp _KiUnexpectedInterruptTail diff --git a/ntoskrnl/ke/i386/usercall_asm.S b/ntoskrnl/ke/i386/usercall_asm.S index 2da726882eb..dcdc7ba9e88 100644 --- a/ntoskrnl/ke/i386/usercall_asm.S +++ b/ntoskrnl/ke/i386/usercall_asm.S @@ -8,17 +8,18 @@ /* INCLUDES ******************************************************************/ -#include -#include +#include +#include #include -/* FUNCTIONS ****************************************************************/ +EXTERN _MmGrowKernelStack@4:PROC +EXTERN _KeUserCallbackDispatcher:PROC +EXTERN @KiServiceExit@8:PROC -.code32 -.text +/* FUNCTIONS ****************************************************************/ +.code -.globl _KiGetUserModeStackAddress@0 -.func KiGetUserModeStackAddress@0 +PUBLIC _KiGetUserModeStackAddress@0 _KiGetUserModeStackAddress@0: /* Get the current thread's trapframe and return the esp */ @@ -27,7 +28,6 @@ _KiGetUserModeStackAddress@0: lea eax, [eax+KTRAP_FRAME_ESP] ret -.endfunc /*++ * @name KiCallUserMode @@ -53,8 +53,7 @@ _KiGetUserModeStackAddress@0: * This call MUST be paired by interrupt 0x2B or NtCallbackReturn. * *--*/ -.globl _KiCallUserMode@8 -.func KiCallUserMode@8 +PUBLIC _KiCallUserMode@8 _KiCallUserMode@8: /* Save volatile registers */ @@ -102,7 +101,7 @@ ApcsEnabled: #endif /* Get the lowest stack limit and check if we can handle it */ - lea eax, [esp-0x3000] + lea eax, [esp-HEX(3000)] cmp eax, [ebx+KTHREAD_STACK_LIMIT] jnb StackOk @@ -130,7 +129,7 @@ StackOk: mov [ebx+KTHREAD_CALLBACK_STACK], esp /* Align stack on 16-byte boundary */ - and esp, ~15 + and esp, NOT 15 mov edi, esp /* Set destination and origin NPX Areas */ @@ -181,7 +180,7 @@ DontBias: /* Copy DR7 */ mov edi, [edx+KTRAP_FRAME_DR7] - test edi, ~DR7_RESERVED_MASK + test edi, NOT DR7_RESERVED_MASK mov [esp+KTRAP_FRAME_DR7], edi /* Check if we need to save debug registers */ @@ -226,7 +225,6 @@ GrowFailed: /* Return */ ret 8 -.endfunc /*++ * @name NtCallbackReturn @@ -251,8 +249,7 @@ GrowFailed: * @remark This call MUST be paired with KeUserModeCallback. * *--*/ -.globl _NtCallbackReturn@12 -.func NtCallbackReturn@12 +PUBLIC _NtCallbackReturn@12 _NtCallbackReturn@12: /* Get the current thread and make sure we have a callback stack */ @@ -316,7 +313,7 @@ CheckDebug: and dword ptr [edi+KTRAP_FRAME_DR7], 0 /* Check if debugging was active */ - test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], 0xFF + test byte ptr [eax+KTHREAD_DEBUG_ACTIVE], HEX(0FF) jnz RestoreDebug RestoreStack: @@ -407,7 +404,6 @@ NoStack: /* Return failure */ mov eax, STATUS_NO_CALLBACK_ACTIVE ret 12 -.endfunc /*++ * @name KeSwitchKernelStack @@ -429,8 +425,7 @@ NoStack: * this routine. * *--*/ -.globl _KeSwitchKernelStack@8 -.func KeSwitchKernelStack@8 +PUBLIC _KeSwitchKernelStack@8 _KeSwitchKernelStack@8: /* Save volatiles */ @@ -515,4 +510,5 @@ V86Switch: pop edi pop esi ret 8 -.endfunc + +END diff --git a/ntoskrnl/rtl/i386/stack.S b/ntoskrnl/rtl/i386/stack.S index d71cc4f0c3e..7fbb6e0106a 100644 --- a/ntoskrnl/rtl/i386/stack.S +++ b/ntoskrnl/rtl/i386/stack.S @@ -8,13 +8,13 @@ /* INCLUDES ******************************************************************/ -#include -.intel_syntax noprefix +#include +#include /* FUNCTIONS *****************************************************************/ +.code -.func RtlpGetStackLimits@8 -.globl _RtlpGetStackLimits@8 +PUBLIC _RtlpGetStackLimits@8 _RtlpGetStackLimits@8: /* Get the current thread */ @@ -34,4 +34,5 @@ _RtlpGetStackLimits@8: /* return */ ret 8 -.endfunc + +END