/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/asm.h>
+#include <asm.inc>
+#include <ks386.inc>
#include <internal/i386/asmmacro.S>
/* FUNCTIONS ****************************************************************/
.code32
-.text
/*
* NOTE: These functions must obey the following rules:
*ExInterlockedAddLargeStatistic(IN PLARGE_INTEGER Addend,
* IN ULONG Increment)
*/
-.global @ExInterlockedAddLargeStatistic@8
+PUBLIC @ExInterlockedAddLargeStatistic@8
@ExInterlockedAddLargeStatistic@8:
#ifdef CONFIG_SMP
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
* IN ULONG Increment,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedAddUlong@12
+PUBLIC @ExfInterlockedAddUlong@12
@ExfInterlockedAddUlong@12:
/* Save flags */
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedInsertHeadList@12
+PUBLIC @ExfInterlockedInsertHeadList@12
@ExfInterlockedInsertHeadList@12:
#ifdef CONFIG_SMP
/* 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
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedInsertTailList@12
+PUBLIC @ExfInterlockedInsertTailList@12
@ExfInterlockedInsertTailList@12:
#ifdef CONFIG_SMP
/* 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
*ExfInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedRemoveHeadList@8
+PUBLIC @ExfInterlockedRemoveHeadList@8
@ExfInterlockedRemoveHeadList@8:
/* Save flags and disable interrupts */
/* Check if it's empty */
cmp eax, ecx
- je 2f
+ je .l4
/* Get the next entry and do the deletion */
#ifdef CONFIG_SMP
/* Return */
ret
-2:
+.l4:
/* Release lock */
RELEASE_SPINLOCK(edx)
*ExfInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedPopEntryList@8
+PUBLIC @ExfInterlockedPopEntryList@8
@ExfInterlockedPopEntryList@8:
/* Save flags and disable interrupts */
/* Check if it's empty */
or eax, eax
- je 3f
+ je .l6
/* Get next entry and do deletion */
#ifdef CONFIG_SMP
pop edx
#endif
-2:
+.l5:
/* Release lock */
RELEASE_SPINLOCK(edx)
/* Return */
ret
-3:
+.l6:
/* Return empty list */
xor eax, eax
- jmp 2b
+ jmp .l5
#ifdef CONFIG_SMP
.spin5:
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedPushEntryList@12
+PUBLIC @ExfInterlockedPushEntryList@12
@ExfInterlockedPushEntryList@12:
/* Save flags */
*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:
/* Check if the list is empty */
or eax, eax
- jz 2f
+ jz .l7
/* Copy sequence number and adjust it */
lea ecx, [edx-1]
jnz _ExpInterlockedPopEntrySListResume@0
/* Restore registers and return */
-2:
+.l7:
pop ebp
pop ebx
ret
* 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 */
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
*FASTCALL
*ExInterlockedFlushSList(IN PSINGLE_LIST_ENTRY ListHead)
*/
-.global @ExInterlockedFlushSList@4
+PUBLIC @ExInterlockedFlushSList@4
@ExInterlockedFlushSList@4:
/* Save registers */
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
/* Do the exchange */
LOCK cmpxchg8b qword ptr [ebp]
- jnz 1b
+ jnz .l9
/* Restore registers and return */
-2:
+.l10:
pop ebp
pop ebx
ret
*FASTCALL
*Exfi386InterlockedIncrementLong(IN PLONG Addend)
*/
-.global @Exfi386InterlockedIncrementLong@4
+PUBLIC @Exfi386InterlockedIncrementLong@4
@Exfi386InterlockedIncrementLong@4:
/* Do the op */
*FASTCALL
*Exfi386InterlockedDecrementLong(IN PLONG Addend)
*/
-.global @Exfi386InterlockedDecrementLong@4
+PUBLIC @Exfi386InterlockedDecrementLong@4
@Exfi386InterlockedDecrementLong@4:
/* Do the op */
*Exfi386InterlockedExchangeUlong(IN PULONG Taget,
* IN ULONG Value)
*/
-.global @Exfi386InterlockedExchangeUlong@8
+PUBLIC @Exfi386InterlockedExchangeUlong@8
@Exfi386InterlockedExchangeUlong@8:
#ifdef CONFIG_SMP
#else
/* On UP, use cmpxchg */
mov eax, [ecx]
-1:
+.l11:
cmpxchg [ecx], edx
- jnz 1b
+ jnz .l11
#endif
/* Return */
* IN PLONGLONG Exchange,
* IN PLONGLONG Comperand)
*/
-.global @ExfInterlockedCompareExchange64@12
+PUBLIC @ExfInterlockedCompareExchange64@12
@ExfInterlockedCompareExchange64@12:
/* Save registers */
* IN PLONGLONG Comperand,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExInterlockedCompareExchange64@16
+PUBLIC @ExInterlockedCompareExchange64@16
@ExInterlockedCompareExchange64@16:
/* Save registers */
*ExfInterlockedPopEntrySList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedPopEntrySList@8
+PUBLIC @ExfInterlockedPopEntrySList@8
@ExfInterlockedPopEntrySList@8:
/* Save flags */
/* 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]
/* Decrement list depth */
dec dword ptr [ecx+4]
-1:
+.l12:
#ifdef CONFIG_SMP
/* Release spinlock */
RELEASE_SPINLOCK(edx)
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExfInterlockedPushEntrySList@12
+PUBLIC @ExfInterlockedPushEntrySList@12
@ExfInterlockedPushEntrySList@12:
/* Save flags */
* IN PLONGLONG Comperand,
* IN PKSPIN_LOCK Lock)
*/
-.global @ExpInterlockedCompareExchange64@16
+PUBLIC @ExpInterlockedCompareExchange64@16
@ExpInterlockedCompareExchange64@16:
/* Save registers */
pushfd
SPIN_ON_LOCK(esi, .startc)
#endif
+
+END
/* EOF */
/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/asm.h>
+#include <asm.inc>
+#include <ks386.inc>
#include <internal/i386/asmmacro.S>
/* FUNCTIONS ****************************************************************/
.code32
-.text
/*
* NOTE: These functions must obey the following rules:
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedAddLargeInteger@16
+PUBLIC _ExInterlockedAddLargeInteger@16
_ExInterlockedAddLargeInteger@16:
/* Prepare stack frame */
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedAddUlong@12
+PUBLIC _ExInterlockedAddUlong@12
_ExInterlockedAddUlong@12:
/* Save flags and disable interrupts */
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedInsertHeadList@12
+PUBLIC _ExInterlockedInsertHeadList@12
_ExInterlockedInsertHeadList@12:
/* Save lock pointer */
/* 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
* IN PLIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedInsertTailList@12
+PUBLIC _ExInterlockedInsertTailList@12
_ExInterlockedInsertTailList@12:
/* Save lock pointer */
/* 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
*ExInterlockedRemoveHeadList(IN PLIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedRemoveHeadList@8
+PUBLIC _ExInterlockedRemoveHeadList@8
_ExInterlockedRemoveHeadList@8:
/* Save lock pointer */
/* Check if it's empty */
cmp eax, edx
- je 2f
+ je .l4
/* Get next entry and do deletion */
mov ecx, [eax]
/* Return */
ret 8
-2:
+.l4:
/* Release lock */
#ifdef CONFIG_SMP
mov edx, [esp+12]
*ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedPopEntryList@8
+PUBLIC _ExInterlockedPopEntryList@8
_ExInterlockedPopEntryList@8:
/* Save lock pointer */
/* 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]
/* Return */
ret 8
-3:
+.l6:
/* Return empty list */
xor eax, eax
- jmp 2b
+ jmp .l5
#ifdef CONFIG_SMP
.spin6:
* IN PSINGLE_LIST_ENTRY ListEntry,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedPushEntryList@12
+PUBLIC _ExInterlockedPushEntryList@12
_ExInterlockedPushEntryList@12:
/* Save lock pointer */
*ExInterlockedIncrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedIncrementLong@8
+PUBLIC _ExInterlockedIncrementLong@8
_ExInterlockedIncrementLong@8:
/* Get addend */
*ExInterlockedDecrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedDecrementLong@8
+PUBLIC _ExInterlockedDecrementLong@8
_ExInterlockedDecrementLong@8:
/* Get addend */
* IN ULONG Value,
* IN PKSPIN_LOCK Lock)
*/
-.global _ExInterlockedExchangeUlong@12
+PUBLIC _ExInterlockedExchangeUlong@12
_ExInterlockedExchangeUlong@12:
/* Get pointers */
*Exi386InterlockedIncrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
-.global _Exi386InterlockedIncrementLong@4
+PUBLIC _Exi386InterlockedIncrementLong@4
_Exi386InterlockedIncrementLong@4:
/* Get addend */
*Exi386InterlockedDecrementLong(IN PLONG Addend,
* IN PKSPIN_LOCK Lock)
*/
-.global _Exi386InterlockedDecrementLong@4
+PUBLIC _Exi386InterlockedDecrementLong@4
_Exi386InterlockedDecrementLong@4:
/* Get addend */
* IN ULONG Value,
* IN PKSPIN_LOCK Lock)
*/
-.global _Exi386InterlockedExchangeUlong@12
+PUBLIC _Exi386InterlockedExchangeUlong@12
_Exi386InterlockedExchangeUlong@12:
/* Get pointers */
/* Return */
ret 8
-
+
+END
/* EOF */
/* INCLUDES ******************************************************************/
-#include <ndk/asm.h>
-.intel_syntax noprefix
+#include <asm.inc>
+#include <ks386.inc>
/* 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 */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
-.func READ_REGISTER_BUFFER_USHORT@12
+
_READ_REGISTER_BUFFER_USHORT@12:
/* Save volatiles */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
-.func READ_REGISTER_BUFFER_ULONG@12
+
_READ_REGISTER_BUFFER_ULONG@12:
/* Save volatiles */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
-.func WRITE_REGISTER_UCHAR@8
+
_WRITE_REGISTER_UCHAR@8:
/* Write to memory */
/* 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 */
/* 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 */
/* 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 */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
-.func WRITE_REGISTER_BUFFER_USHORT@12
+
_WRITE_REGISTER_BUFFER_USHORT@12:
/* Save volatiles */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
-.func WRITE_REGISTER_BUFFER_ULONG@12
+
_WRITE_REGISTER_BUFFER_ULONG@12:
/* Save volatiles */
mov edi, edx
mov esi, eax
ret 12
-.endfunc
+END
/* EOF */
// @remark None.
//
MACRO(idt, Handler, Bits)
- .long \Handler
- .short \Bits
+ .long VAL(Handler)
+ .short VAL(Bits)
.short KGDT_R0_CODE
ENDM
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 */
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
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
-#include <reactos/asm.h>
-#include <ndk/amd64/asm.h>
-.globl KdbEnter
+#include <asm.inc>
+
+#include <ksamd64.inc>
+
+PUBLIC KdbEnter
KdbEnter:
/* save flags */
mov rsp, rax
/* Return */
- ret
\ No newline at end of file
+ ret
+
+END
\ No newline at end of file
-#include <ndk/asm.h>
-.text
+#include <asm.inc>
+#include <ks386.inc>
-.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:
* 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.
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
* 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 <w3seek@reactos.org>
+ * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/amd64/asm.h>
+#include <asm.inc>
+
+#include <ksamd64.inc>
EXTERN KiInitializeKernelAndGotoIdleLoop:PROC
/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/amd64/asm.h>
+#include <asm.inc>
+
+#include <ksamd64.inc>
/* FUNCTIONS ****************************************************************/
/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/amd64/asm.h>
+#include <asm.inc>
+
+#include <ksamd64.inc>
EXTERN KiDispatchException:PROC
EXTERN FrLdrDbgPrint:DWORD
#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)); \
/* INCLUDES ******************************************************************/
-#include <ndk/asm.h>
-.intel_syntax noprefix
+#include <asm.inc>
+#include <ks386.inc>
+
+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
/* 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
/* 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
/* 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 */
mov ecx, esp
call @KiEnterV86Mode@4
jmp $
-.endfunc
-.globl @Ki386BiosCallReturnAddress@4
+
+PUBLIC @Ki386BiosCallReturnAddress@4
@Ki386BiosCallReturnAddress@4:
/* Exit V8086 mode */
popad
ret 4
+END
/* INCLUDES ******************************************************************/
-#include <reactos/asm.h>
-#include <ndk/i386/asm.h>
+#include <asm.inc>
+#include <ks386.inc>
#include <internal/i386/asmmacro.S>
MACRO(GENERATE_IDT_STUB, Number)
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:
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 */
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
.long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0
/******************************************************************************/
-.code32
-.text
+.code
TRAP_ENTRY KiTrap00, KI_PUSH_FAKE_ERROR_CODE
TRAP_ENTRY KiTrap01, 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
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
/* 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
-.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 */
lea eax, [eax+KTRAP_FRAME_ESP]
ret
-.endfunc
/*++
* @name KiCallUserMode
* This call MUST be paired by interrupt 0x2B or NtCallbackReturn.
*
*--*/
-.globl _KiCallUserMode@8
-.func KiCallUserMode@8
+PUBLIC _KiCallUserMode@8
_KiCallUserMode@8:
/* Save volatile registers */
#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
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 */
/* 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 */
/* Return */
ret 8
-.endfunc
/*++
* @name NtCallbackReturn
* @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 */
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:
/* Return failure */
mov eax, STATUS_NO_CALLBACK_ACTIVE
ret 12
-.endfunc
/*++
* @name KeSwitchKernelStack
* this routine.
*
*--*/
-.globl _KeSwitchKernelStack@8
-.func KeSwitchKernelStack@8
+PUBLIC _KeSwitchKernelStack@8
_KeSwitchKernelStack@8:
/* Save volatiles */
pop edi
pop esi
ret 8
-.endfunc
+
+END
/* INCLUDES ******************************************************************/
-#include <ndk/asm.h>
-.intel_syntax noprefix
+#include <asm.inc>
+#include <ks386.inc>
/* FUNCTIONS *****************************************************************/
+.code
-.func RtlpGetStackLimits@8
-.globl _RtlpGetStackLimits@8
+PUBLIC _RtlpGetStackLimits@8
_RtlpGetStackLimits@8:
/* Get the current thread */
/* return */
ret 8
-.endfunc
+
+END