[NTOSKRNL]
[reactos.git] / ntoskrnl / ke / i386 / usercall_asm.S
index 2da7268..a5ab6c9 100644 (file)
@@ -8,17 +8,20 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <reactos/asm.h>
-#include <ndk/i386/asm.h>
+#include <asm.inc>
+#include <ks386.inc>
 #include <internal/i386/asmmacro.S>
 
-/* FUNCTIONS ****************************************************************/
+EXTERN _MmGrowKernelStack@4:PROC
+EXTERN _KeUserCallbackDispatcher:PROC
+EXTERN @KiServiceExit@8:PROC
+EXTERN _KeGetCurrentIrql@0:PROC
+EXTERN _KeBugCheckEx@20: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,10 +30,9 @@ _KiGetUserModeStackAddress@0:
     lea eax, [eax+KTRAP_FRAME_ESP]
     ret
 
-.endfunc
 
 /*++
- * @name KiCallUserMode 
+ * @name KiCallUserMode
  *
  *     The KiSwitchToUserMode routine sets up a Trap Frame and a Callback stack
  *     for the purpose of switching to user mode. The actual final jump is done
@@ -53,8 +55,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 +103,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 +131,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 +182,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 +227,6 @@ GrowFailed:
     /* Return */
     ret 8
 
-.endfunc
 
 /*++
  * @name NtCallbackReturn
@@ -251,8 +251,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 +315,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,10 +406,9 @@ NoStack:
     /* Return failure */
     mov eax, STATUS_NO_CALLBACK_ACTIVE
     ret 12
-.endfunc
 
 /*++
- * @name KeSwitchKernelStack 
+ * @name KeSwitchKernelStack
  *
  *     The KeSwitchKernelStack routine switches from the current thread's stack
  *     to the new specified base and limit.
@@ -423,14 +421,13 @@ NoStack:
  *
  * @return The previous Stack Base of the thread.
  *
- * @remark This routine should typically only be used when converting from a 
+ * @remark This routine should typically only be used when converting from a
  *         non-GUI to a GUI Thread. The caller is responsible for freeing the
  *         previous stack. The new stack values MUST be valid before calling
  *         this routine.
  *
  *--*/
-.globl _KeSwitchKernelStack@8
-.func KeSwitchKernelStack@8
+PUBLIC _KeSwitchKernelStack@8
 _KeSwitchKernelStack@8:
 
     /* Save volatiles */
@@ -515,4 +512,5 @@ V86Switch:
     pop edi
     pop esi
     ret 8
-.endfunc
+
+END