mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:56:00 +00:00
- Convert pure inline assembler .c files to .S files.
- Move SMP IRQ handlers to irqhand.s (at the same place where the UP ones are). svn path=/trunk/; revision=16428
This commit is contained in:
parent
7afd05c217
commit
51c604714a
7 changed files with 626 additions and 1042 deletions
143
reactos/ntoskrnl/ex/i386/interlck.S
Normal file
143
reactos/ntoskrnl/ex/i386/interlck.S
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
/* $Id: interlck.c 15557 2005-05-28 07:26:38Z hbirr $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ex/i386/interlck.c
|
||||||
|
* PURPOSE: No purpose listed.
|
||||||
|
*
|
||||||
|
* PROGRAMMERS: No programmer listed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
#define LOCK lock
|
||||||
|
#else
|
||||||
|
#define LOCK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
.global @Exfi386InterlockedIncrementLong@4
|
||||||
|
@Exfi386InterlockedIncrementLong@4:
|
||||||
|
LOCK
|
||||||
|
addl $1,(%ecx)
|
||||||
|
lahf
|
||||||
|
andl $0xC000, %eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @Exfi386InterlockedDecrementLong@4
|
||||||
|
@Exfi386InterlockedDecrementLong@4:
|
||||||
|
LOCK
|
||||||
|
subl $1,(%ecx)
|
||||||
|
lahf
|
||||||
|
andl $0xC000, %eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @Exfi386InterlockedExchangeUlong@8
|
||||||
|
@Exfi386InterlockedExchangeUlong@8:
|
||||||
|
LOCK
|
||||||
|
xchgl %edx,(%ecx)
|
||||||
|
movl %edx,%eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global _Exi386InterlockedIncrementLong@4
|
||||||
|
_Exi386InterlockedIncrementLong@4:
|
||||||
|
movl 4(%esp),%eax
|
||||||
|
LOCK
|
||||||
|
addl $1,(%eax)
|
||||||
|
lahf
|
||||||
|
andl $0xC000, %eax
|
||||||
|
ret $4
|
||||||
|
|
||||||
|
.global _Exi386InterlockedDecrementLong@4
|
||||||
|
_Exi386InterlockedDecrementLong@4:
|
||||||
|
movl 4(%esp),%eax
|
||||||
|
LOCK
|
||||||
|
subl $1,(%eax)
|
||||||
|
lahf
|
||||||
|
andl $0xC000, %eax
|
||||||
|
ret $4
|
||||||
|
|
||||||
|
.global _Exi386InterlockedExchangeUlong@8
|
||||||
|
_Exi386InterlockedExchangeUlong@8:
|
||||||
|
movl 4(%esp),%edx
|
||||||
|
movl 8(%esp),%eax
|
||||||
|
LOCK
|
||||||
|
xchgl %eax,(%edx)
|
||||||
|
ret $8
|
||||||
|
|
||||||
|
.global @InterlockedIncrement@4
|
||||||
|
@InterlockedIncrement@4:
|
||||||
|
movl $1,%eax
|
||||||
|
LOCK
|
||||||
|
xaddl %eax,(%ecx)
|
||||||
|
incl %eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @InterlockedDecrement@4
|
||||||
|
@InterlockedDecrement@4:
|
||||||
|
movl $-1,%eax
|
||||||
|
LOCK
|
||||||
|
xaddl %eax,(%ecx)
|
||||||
|
decl %eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @InterlockedExchange@8
|
||||||
|
@InterlockedExchange@8:
|
||||||
|
LOCK
|
||||||
|
xchgl %edx,(%ecx)
|
||||||
|
movl %edx,%eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @InterlockedExchangeAdd@8
|
||||||
|
@InterlockedExchangeAdd@8:
|
||||||
|
LOCK
|
||||||
|
xaddl %edx,(%ecx)
|
||||||
|
movl %edx,%eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @InterlockedClearBit@8
|
||||||
|
@InterlockedClearBit@8:
|
||||||
|
LOCK
|
||||||
|
btr %edx,(%ecx)
|
||||||
|
setc %al
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @InterlockedCompareExchange@12
|
||||||
|
@InterlockedCompareExchange@12:
|
||||||
|
movl 4(%esp),%eax
|
||||||
|
LOCK
|
||||||
|
cmpxchg %edx,(%ecx)
|
||||||
|
ret $4
|
||||||
|
|
||||||
|
.global @ExfpInterlockedExchange64@8
|
||||||
|
@ExfpInterlockedExchange64@8:
|
||||||
|
pushl %ebx
|
||||||
|
pushl %esi
|
||||||
|
movl %ecx,%esi
|
||||||
|
movl (%edx),%ebx
|
||||||
|
movl 4(%edx),%ecx
|
||||||
|
1:
|
||||||
|
movl (%esi),%eax
|
||||||
|
movl 4(%esi),%edx
|
||||||
|
LOCK
|
||||||
|
cmpxchg8b (%esi)
|
||||||
|
jnz 1b
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global @ExfInterlockedCompareExchange64@12
|
||||||
|
@ExfInterlockedCompareExchange64@12:
|
||||||
|
pushl %ebx
|
||||||
|
pushl %esi
|
||||||
|
movl %ecx,%esi
|
||||||
|
movl (%edx),%ebx
|
||||||
|
movl 4(%edx),%ecx
|
||||||
|
movl 12(%esp),%edx
|
||||||
|
movl (%edx),%eax
|
||||||
|
movl 4(%edx),%edx
|
||||||
|
LOCK
|
||||||
|
cmpxchg8b (%esi)
|
||||||
|
popl %esi
|
||||||
|
popl %ebx
|
||||||
|
ret $4
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,536 +0,0 @@
|
||||||
/* $Id$
|
|
||||||
*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: ntoskrnl/ex/i386/interlck.c
|
|
||||||
* PURPOSE: No purpose listed.
|
|
||||||
*
|
|
||||||
* PROGRAMMERS: No programmer listed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
|
||||||
|
|
||||||
#ifdef LOCK
|
|
||||||
#undef LOCK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do not declare any variable after this point!!
|
|
||||||
*/
|
|
||||||
__asm__("\n\t.text\n\t");
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#define LOCK "lock ; "
|
|
||||||
#else
|
|
||||||
#define LOCK ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
#define LOCK lock
|
|
||||||
#else
|
|
||||||
#define LOCK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
INTERLOCKED_RESULT FASTCALL
|
|
||||||
Exfi386InterlockedIncrementLong(IN PLONG Addend);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @Exfi386InterlockedIncrementLong@4\n\t"
|
|
||||||
"@Exfi386InterlockedIncrementLong@4:\n\t"
|
|
||||||
LOCK
|
|
||||||
"addl $1,(%ecx)\n\t"
|
|
||||||
"lahf\n\t"
|
|
||||||
"andl $0xC000, %eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
INTERLOCKED_RESULT FASTCALL
|
|
||||||
Exfi386InterlockedIncrementLong(IN PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm LOCK add dword ptr [ecx], 1
|
|
||||||
__asm lahf
|
|
||||||
__asm and eax, 0xC000
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
INTERLOCKED_RESULT FASTCALL
|
|
||||||
Exfi386InterlockedDecrementLong(IN PLONG Addend);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @Exfi386InterlockedDecrementLong@4\n\t"
|
|
||||||
"@Exfi386InterlockedDecrementLong@4:\n\t"
|
|
||||||
LOCK
|
|
||||||
"subl $1,(%ecx)\n\t"
|
|
||||||
"lahf\n\t"
|
|
||||||
"andl $0xC000, %eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
INTERLOCKED_RESULT FASTCALL
|
|
||||||
Exfi386InterlockedDecrementLong(IN PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm LOCK sub dword ptr [ecx], 1
|
|
||||||
__asm lahf
|
|
||||||
__asm and eax, 0xC000
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
ULONG FASTCALL
|
|
||||||
Exfi386InterlockedExchangeUlong(IN PULONG Target,
|
|
||||||
IN ULONG Value);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @Exfi386InterlockedExchangeUlong@8\n\t"
|
|
||||||
"@Exfi386InterlockedExchangeUlong@8:\n\t"
|
|
||||||
LOCK
|
|
||||||
"xchgl %edx,(%ecx)\n\t"
|
|
||||||
"movl %edx,%eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
ULONG FASTCALL
|
|
||||||
Exfi386InterlockedExchangeUlong(IN PULONG Target,
|
|
||||||
IN ULONG Value)
|
|
||||||
{
|
|
||||||
__asm LOCK xchg [ecx], edx
|
|
||||||
__asm mov eax, edx
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
INTERLOCKED_RESULT STDCALL
|
|
||||||
Exi386InterlockedIncrementLong(IN PLONG Addend);
|
|
||||||
|
|
||||||
__asm__("\n\t.global _Exi386InterlockedIncrementLong@4\n\t"
|
|
||||||
"_Exi386InterlockedIncrementLong@4:\n\t"
|
|
||||||
"movl 4(%esp),%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"addl $1,(%eax)\n\t"
|
|
||||||
"lahf\n\t"
|
|
||||||
"andl $0xC000, %eax\n\t"
|
|
||||||
"ret $4\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
__declspec(naked)
|
|
||||||
INTERLOCKED_RESULT STDCALL
|
|
||||||
Exi386InterlockedIncrementLong(IN PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm mov eax, Addend
|
|
||||||
__asm LOCK add dword ptr [eax], 1
|
|
||||||
__asm lahf
|
|
||||||
__asm and eax, 0xC000
|
|
||||||
__asm ret 4
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
INTERLOCKED_RESULT STDCALL
|
|
||||||
Exi386InterlockedDecrementLong(IN PLONG Addend);
|
|
||||||
|
|
||||||
__asm__("\n\t.global _Exi386InterlockedDecrementLong@4\n\t"
|
|
||||||
"_Exi386InterlockedDecrementLong@4:\n\t"
|
|
||||||
"movl 4(%esp),%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"subl $1,(%eax)\n\t"
|
|
||||||
"lahf\n\t"
|
|
||||||
"andl $0xC000, %eax\n\t"
|
|
||||||
"ret $4\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
__declspec(naked)
|
|
||||||
INTERLOCKED_RESULT STDCALL
|
|
||||||
Exi386InterlockedDecrementLong(IN PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm mov eax, Addend
|
|
||||||
__asm LOCK sub dword ptr [eax], 1
|
|
||||||
__asm lahf
|
|
||||||
__asm and eax, 0xC000
|
|
||||||
__asm ret 4
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
ULONG STDCALL
|
|
||||||
Exi386InterlockedExchangeUlong(IN PULONG Target,
|
|
||||||
IN ULONG Value);
|
|
||||||
|
|
||||||
__asm__("\n\t.global _Exi386InterlockedExchangeUlong@8\n\t"
|
|
||||||
"_Exi386InterlockedExchangeUlong@8:\n\t"
|
|
||||||
"movl 4(%esp),%edx\n\t"
|
|
||||||
"movl 8(%esp),%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"xchgl %eax,(%edx)\n\t"
|
|
||||||
"ret $8\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
__declspec(naked)
|
|
||||||
ULONG STDCALL
|
|
||||||
Exi386InterlockedExchangeUlong(IN PULONG Target,
|
|
||||||
IN ULONG Value)
|
|
||||||
{
|
|
||||||
__asm mov edx, Value
|
|
||||||
__asm mov eax, Target
|
|
||||||
__asm LOCK xchg [edx], eax
|
|
||||||
__asm ret 8
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedIncrement@4
|
|
||||||
* STDCALL : _InterlockedIncrement@4
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedIncrement(PLONG Addend);
|
|
||||||
/*
|
|
||||||
* FUNCTION: Increments a caller supplied variable of type LONG as an
|
|
||||||
* atomic operation
|
|
||||||
* ARGUMENTS:
|
|
||||||
* Addend = Points to a variable whose value is to be increment
|
|
||||||
* RETURNS: The incremented value
|
|
||||||
*/
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedIncrement@4\n\t"
|
|
||||||
"@InterlockedIncrement@4:\n\t"
|
|
||||||
"movl $1,%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"xaddl %eax,(%ecx)\n\t"
|
|
||||||
"incl %eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedIncrement(PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm mov eax, 1
|
|
||||||
__asm LOCK xadd [ecx], eax
|
|
||||||
__asm inc eax
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedDecrement@4
|
|
||||||
* STDCALL : _InterlockedDecrement@4
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedDecrement(PLONG Addend);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedDecrement@4\n\t"
|
|
||||||
"@InterlockedDecrement@4:\n\t"
|
|
||||||
"movl $-1,%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"xaddl %eax,(%ecx)\n\t"
|
|
||||||
"decl %eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedDecrement(PLONG Addend)
|
|
||||||
{
|
|
||||||
__asm mov eax, -1
|
|
||||||
__asm LOCK xadd [ecx], eax
|
|
||||||
__asm dec eax
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedExchange@8
|
|
||||||
* STDCALL : _InterlockedExchange@8
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedExchange(PLONG Target,
|
|
||||||
LONG Value);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedExchange@8\n\t"
|
|
||||||
"@InterlockedExchange@8:\n\t"
|
|
||||||
LOCK
|
|
||||||
"xchgl %edx,(%ecx)\n\t"
|
|
||||||
"movl %edx,%eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedExchange(PLONG Target,
|
|
||||||
LONG Value)
|
|
||||||
{
|
|
||||||
__asm LOCK xchg [ecx], edx
|
|
||||||
__asm mov eax, edx
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedExchangeAdd@8
|
|
||||||
* STDCALL: _InterlockedExchangeAdd@8
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedExchangeAdd(PLONG Addend,
|
|
||||||
LONG Value);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedExchangeAdd@8\n\t"
|
|
||||||
"@InterlockedExchangeAdd@8:\n\t"
|
|
||||||
LOCK
|
|
||||||
"xaddl %edx,(%ecx)\n\t"
|
|
||||||
"movl %edx,%eax\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedExchangeAdd(PLONG Addend,
|
|
||||||
LONG Value)
|
|
||||||
{
|
|
||||||
__asm LOCK xadd [ecx], edx
|
|
||||||
__asm mov eax, edx
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedClearBit@8
|
|
||||||
* STDCALL: _InterlockedClearBit@8
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
UCHAR
|
|
||||||
FASTCALL
|
|
||||||
InterlockedClearBit(PLONG Destination,
|
|
||||||
LONG Bit);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedClearBit@8\n\t"
|
|
||||||
"@InterlockedClearBit@8:\n\t"
|
|
||||||
LOCK
|
|
||||||
"btr %edx,(%ecx)\n\t"
|
|
||||||
"setc %al\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
__declspec(naked)
|
|
||||||
UCHAR
|
|
||||||
FASTCALL
|
|
||||||
InterlockedClearBit(PUCHAR Destination,
|
|
||||||
UCHAR Bit)
|
|
||||||
{
|
|
||||||
__asm LOCK btr [ecx], edx
|
|
||||||
__asm setc al
|
|
||||||
__asm ret
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedCompareExchange@12
|
|
||||||
* STDCALL: _InterlockedCompareExchange@12
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedCompareExchange(PLONG Destination,
|
|
||||||
LONG Exchange,
|
|
||||||
LONG Comperand);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @InterlockedCompareExchange@12\n\t"
|
|
||||||
"@InterlockedCompareExchange@12:\n\t"
|
|
||||||
"movl 4(%esp),%eax\n\t"
|
|
||||||
LOCK
|
|
||||||
"cmpxchg %edx,(%ecx)\n\t"
|
|
||||||
"ret $4\n\t");
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
|
|
||||||
__declspec(naked)
|
|
||||||
LONG FASTCALL
|
|
||||||
InterlockedCompareExchange(PLONG Destination,
|
|
||||||
LONG Exchange,
|
|
||||||
LONG Comperand)
|
|
||||||
{
|
|
||||||
__asm mov eax, Comperand
|
|
||||||
__asm LOCK cmpxchg [ecx], edx
|
|
||||||
__asm ret 4
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @InterlockedCompareExchange64@8
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
LONGLONG FASTCALL
|
|
||||||
ExfpInterlockedExchange64(LONGLONG volatile * Destination,
|
|
||||||
PLONGLONG Exchange);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @ExfpInterlockedExchange64@8\n\t"
|
|
||||||
"@ExfpInterlockedExchange64@8:\n\t"
|
|
||||||
"pushl %ebx\n\t"
|
|
||||||
"pushl %esi\n\t"
|
|
||||||
"movl %ecx,%esi\n\t"
|
|
||||||
"movl (%edx),%ebx\n\t"
|
|
||||||
"movl 4(%edx),%ecx\n\t"
|
|
||||||
"\n1:\t"
|
|
||||||
"movl (%esi),%eax\n\t"
|
|
||||||
"movl 4(%esi),%edx\n\t"
|
|
||||||
LOCK
|
|
||||||
"cmpxchg8b (%esi)\n\t"
|
|
||||||
"jnz 1b\n\t"
|
|
||||||
"popl %esi\n\t"
|
|
||||||
"popl %ebx\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* FASTCALL: @ExfInterlockedCompareExchange@12
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
LONGLONG FASTCALL
|
|
||||||
ExfInterlockedCompareExchange64(LONGLONG volatile * Destination,
|
|
||||||
PLONGLONG Exchange,
|
|
||||||
PLONGLONG Comperand);
|
|
||||||
|
|
||||||
__asm__("\n\t.global @ExfInterlockedCompareExchange64@12\n\t"
|
|
||||||
"@ExfInterlockedCompareExchange64@12:\n\t"
|
|
||||||
"pushl %ebx\n\t"
|
|
||||||
"pushl %esi\n\t"
|
|
||||||
"movl %ecx,%esi\n\t"
|
|
||||||
"movl (%edx),%ebx\n\t"
|
|
||||||
"movl 4(%edx),%ecx\n\t"
|
|
||||||
"movl 12(%esp),%edx\n\t"
|
|
||||||
"movl (%edx),%eax\n\t"
|
|
||||||
"movl 4(%edx),%edx\n\t"
|
|
||||||
LOCK
|
|
||||||
"cmpxchg8b (%esi)\n\t"
|
|
||||||
"popl %esi\n\t"
|
|
||||||
"popl %ebx\n\t"
|
|
||||||
"ret $4\n\t");
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* EOF */
|
|
22
reactos/ntoskrnl/ke/i386/brkpoint.S
Normal file
22
reactos/ntoskrnl/ke/i386/brkpoint.S
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/* $Id: brkpoint.c 15164 2005-05-09 01:38:29Z sedwards $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ke/i386/brkpoint.c
|
||||||
|
* PURPOSE: Handles breakpoints
|
||||||
|
*
|
||||||
|
* PROGRAMMERS: No programmer listed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.global _DbgBreakPoint@0
|
||||||
|
_DbgBreakPoint@0:
|
||||||
|
.global _DbgBreakPointNoBugCheck@0
|
||||||
|
_DbgBreakPointNoBugCheck@0:
|
||||||
|
int $3
|
||||||
|
ret
|
||||||
|
|
||||||
|
.global _DbgBreakPointWithStatus@4
|
||||||
|
_DbgBreakPointWithStatus@4:
|
||||||
|
mov 0x4(%esp), %eax
|
||||||
|
int $3
|
||||||
|
ret $4
|
|
@ -1,59 +0,0 @@
|
||||||
/* $Id$
|
|
||||||
*
|
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS kernel
|
|
||||||
* FILE: ntoskrnl/ke/i386/brkpoint.c
|
|
||||||
* PURPOSE: Handles breakpoints
|
|
||||||
*
|
|
||||||
* PROGRAMMERS: No programmer listed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
|
||||||
#include <internal/debug.h>
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
VOID STDCALL
|
|
||||||
DbgBreakPoint(VOID)
|
|
||||||
{
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
__asm__("int $3\n\t");
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
__asm int 3;
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
__asm__(".globl _DbgBreakPointNoBugCheck@0\n\t"
|
|
||||||
"_DbgBreakPointNoBugCheck@0:\n\t"
|
|
||||||
"int $3\n\t"
|
|
||||||
"ret\n\t");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
VOID STDCALL
|
|
||||||
DbgBreakPointWithStatus(ULONG Status)
|
|
||||||
{
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
__asm__("mov %0, %%eax\n\t"
|
|
||||||
"int $3\n\t"
|
|
||||||
::"m"(Status));
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
__asm mov eax, Status
|
|
||||||
__asm int 3;
|
|
||||||
#else
|
|
||||||
#error Unknown compiler for inline assembler
|
|
||||||
#endif
|
|
||||||
}
|
|
|
@ -26,73 +26,28 @@
|
||||||
|
|
||||||
/* GLOBALS *****************************************************************/
|
/* GLOBALS *****************************************************************/
|
||||||
|
|
||||||
|
/* Interrupt handler list */
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
|
||||||
#define __STR(x) #x
|
|
||||||
#define STR(x) __STR(x)
|
|
||||||
|
|
||||||
#define INT_NAME(intnum) _KiUnexpectedInterrupt##intnum
|
|
||||||
#define INT_NAME2(intnum) KiUnexpectedInterrupt##intnum
|
#define INT_NAME2(intnum) KiUnexpectedInterrupt##intnum
|
||||||
|
|
||||||
#define BUILD_COMMON_INTERRUPT_HANDLER() \
|
|
||||||
__asm__( \
|
|
||||||
"_KiCommonInterrupt:\n\t" \
|
|
||||||
"cld\n\t" \
|
|
||||||
"pushl %ds\n\t" \
|
|
||||||
"pushl %es\n\t" \
|
|
||||||
"pushl %fs\n\t" \
|
|
||||||
"pushl %gs\n\t" \
|
|
||||||
"movl $0xceafbeef,%eax\n\t" \
|
|
||||||
"pushl %eax\n\t" \
|
|
||||||
"movl $" STR(KERNEL_DS) ",%eax\n\t" \
|
|
||||||
"movl %eax,%ds\n\t" \
|
|
||||||
"movl %eax,%es\n\t" \
|
|
||||||
"movl %eax,%gs\n\t" \
|
|
||||||
"movl $" STR(PCR_SELECTOR) ",%eax\n\t" \
|
|
||||||
"movl %eax,%fs\n\t" \
|
|
||||||
"pushl %esp\n\t" \
|
|
||||||
"pushl %ebx\n\t" \
|
|
||||||
"call _KiInterruptDispatch\n\t" \
|
|
||||||
"addl $0xC, %esp\n\t" \
|
|
||||||
"popl %gs\n\t" \
|
|
||||||
"popl %fs\n\t" \
|
|
||||||
"popl %es\n\t" \
|
|
||||||
"popl %ds\n\t" \
|
|
||||||
"popa\n\t" \
|
|
||||||
"iret\n\t");
|
|
||||||
|
|
||||||
#define BUILD_INTERRUPT_HANDLER(intnum) \
|
#define BUILD_INTERRUPT_HANDLER(intnum) \
|
||||||
VOID INT_NAME2(intnum)(VOID); \
|
VOID INT_NAME2(intnum)(VOID);
|
||||||
__asm__( \
|
|
||||||
STR(INT_NAME(intnum)) ":\n\t" \
|
|
||||||
"pusha\n\t" \
|
|
||||||
"movl $0x" STR(intnum) ",%ebx\n\t" \
|
|
||||||
"jmp _KiCommonInterrupt");
|
|
||||||
|
|
||||||
|
#define D(x,y) \
|
||||||
/* Interrupt handlers and declarations */
|
|
||||||
|
|
||||||
#define B(x,y) \
|
|
||||||
BUILD_INTERRUPT_HANDLER(x##y)
|
BUILD_INTERRUPT_HANDLER(x##y)
|
||||||
|
|
||||||
#define B16(x) \
|
#define D16(x) \
|
||||||
B(x,0) B(x,1) B(x,2) B(x,3) \
|
D(x,0) D(x,1) D(x,2) D(x,3) \
|
||||||
B(x,4) B(x,5) B(x,6) B(x,7) \
|
D(x,4) D(x,5) D(x,6) D(x,7) \
|
||||||
B(x,8) B(x,9) B(x,A) B(x,B) \
|
D(x,8) D(x,9) D(x,A) D(x,B) \
|
||||||
B(x,C) B(x,D) B(x,E) B(x,F)
|
D(x,C) D(x,D) D(x,E) D(x,F)
|
||||||
|
|
||||||
|
D16(3) D16(4) D16(5) D16(6)
|
||||||
BUILD_COMMON_INTERRUPT_HANDLER()
|
D16(7) D16(8) D16(9) D16(A)
|
||||||
B16(3) B16(4) B16(5) B16(6)
|
D16(B) D16(C) D16(D) D16(E)
|
||||||
B16(7) B16(8) B16(9) B16(A)
|
D16(F)
|
||||||
B16(B) B16(C) B16(D) B16(E)
|
|
||||||
B16(F)
|
|
||||||
|
|
||||||
#undef B
|
|
||||||
#undef B16
|
|
||||||
|
|
||||||
|
|
||||||
/* Interrupt handler list */
|
|
||||||
|
|
||||||
#define L(x,y) \
|
#define L(x,y) \
|
||||||
(ULONG)& INT_NAME2(x##y)
|
(ULONG)& INT_NAME2(x##y)
|
||||||
|
@ -111,28 +66,30 @@ static ULONG irq_handler[ROUND_UP(NR_IRQS, 16)] = {
|
||||||
|
|
||||||
#undef L
|
#undef L
|
||||||
#undef L16
|
#undef L16
|
||||||
|
#undef D
|
||||||
|
#undef D16
|
||||||
|
|
||||||
#else /* CONFIG_SMP */
|
#else /* CONFIG_SMP */
|
||||||
|
|
||||||
void irq_handler_0(void);
|
void irq_handler_0(void);
|
||||||
void irq_handler_1(void);
|
void irq_handler_1(void);
|
||||||
void irq_handler_2(void);
|
void irq_handler_2(void);
|
||||||
void irq_handler_3(void);
|
void irq_handler_3(void);
|
||||||
void irq_handler_4(void);
|
void irq_handler_4(void);
|
||||||
void irq_handler_5(void);
|
void irq_handler_5(void);
|
||||||
void irq_handler_6(void);
|
void irq_handler_6(void);
|
||||||
void irq_handler_7(void);
|
void irq_handler_7(void);
|
||||||
void irq_handler_8(void);
|
void irq_handler_8(void);
|
||||||
void irq_handler_9(void);
|
void irq_handler_9(void);
|
||||||
void irq_handler_10(void);
|
void irq_handler_10(void);
|
||||||
void irq_handler_11(void);
|
void irq_handler_11(void);
|
||||||
void irq_handler_12(void);
|
void irq_handler_12(void);
|
||||||
void irq_handler_13(void);
|
void irq_handler_13(void);
|
||||||
void irq_handler_14(void);
|
void irq_handler_14(void);
|
||||||
void irq_handler_15(void);
|
void irq_handler_15(void);
|
||||||
|
|
||||||
static unsigned int irq_handler[NR_IRQS]=
|
static unsigned int irq_handler[NR_IRQS]=
|
||||||
{
|
{
|
||||||
(int)&irq_handler_0,
|
(int)&irq_handler_0,
|
||||||
(int)&irq_handler_1,
|
(int)&irq_handler_1,
|
||||||
(int)&irq_handler_2,
|
(int)&irq_handler_2,
|
||||||
|
@ -149,7 +106,7 @@ static unsigned int irq_handler[NR_IRQS]=
|
||||||
(int)&irq_handler_13,
|
(int)&irq_handler_13,
|
||||||
(int)&irq_handler_14,
|
(int)&irq_handler_14,
|
||||||
(int)&irq_handler_15,
|
(int)&irq_handler_15,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIG_SMP */
|
#endif /* CONFIG_SMP */
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,61 @@
|
||||||
#include <ndk/i386/segment.h>
|
#include <ndk/i386/segment.h>
|
||||||
#include <../hal/halx86/include/halirq.h>
|
#include <../hal/halx86/include/halirq.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
|
||||||
|
#define BUILD_INTERRUPT_HANDLER(intnum) \
|
||||||
|
.global _KiUnexpectedInterrupt##intnum; \
|
||||||
|
_KiUnexpectedInterrupt##intnum:; \
|
||||||
|
pusha; \
|
||||||
|
movl $0x##intnum, %ebx; \
|
||||||
|
jmp _KiCommonInterrupt;
|
||||||
|
|
||||||
|
/* Interrupt handlers and declarations */
|
||||||
|
|
||||||
|
#define B(x,y) \
|
||||||
|
BUILD_INTERRUPT_HANDLER(x##y)
|
||||||
|
|
||||||
|
#define B16(x) \
|
||||||
|
B(x,0) B(x,1) B(x,2) B(x,3) \
|
||||||
|
B(x,4) B(x,5) B(x,6) B(x,7) \
|
||||||
|
B(x,8) B(x,9) B(x,A) B(x,B) \
|
||||||
|
B(x,C) B(x,D) B(x,E) B(x,F)
|
||||||
|
|
||||||
|
_KiCommonInterrupt:
|
||||||
|
cld
|
||||||
|
pushl %ds
|
||||||
|
pushl %es
|
||||||
|
pushl %fs
|
||||||
|
pushl %gs
|
||||||
|
movl $0xceafbeef,%eax
|
||||||
|
pushl %eax
|
||||||
|
movl $KERNEL_DS,%eax
|
||||||
|
movl %eax,%ds
|
||||||
|
movl %eax,%es
|
||||||
|
movl %eax,%gs
|
||||||
|
movl $PCR_SELECTOR,%eax
|
||||||
|
movl %eax,%fs
|
||||||
|
pushl %esp
|
||||||
|
pushl %ebx
|
||||||
|
call _KiInterruptDispatch
|
||||||
|
addl $0xC, %esp
|
||||||
|
popl %gs
|
||||||
|
popl %fs
|
||||||
|
popl %es
|
||||||
|
popl %ds
|
||||||
|
popa
|
||||||
|
iret
|
||||||
|
|
||||||
|
B16(3) B16(4) B16(5) B16(6)
|
||||||
|
B16(7) B16(8) B16(9) B16(A)
|
||||||
|
B16(B) B16(C) B16(D) B16(E)
|
||||||
|
B16(F)
|
||||||
|
|
||||||
|
#undef B
|
||||||
|
#undef B16
|
||||||
|
|
||||||
|
#else /* CONFIG_SMP */
|
||||||
|
|
||||||
.global _irq_handler_0
|
.global _irq_handler_0
|
||||||
_irq_handler_0:
|
_irq_handler_0:
|
||||||
cld
|
cld
|
||||||
|
@ -432,3 +487,5 @@ _irq_handler_15:
|
||||||
popl %ds
|
popl %ds
|
||||||
popa
|
popa
|
||||||
iret
|
iret
|
||||||
|
|
||||||
|
#endif /* CONFIG_SMP */
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<directory name="i386">
|
<directory name="i386">
|
||||||
<file first="true">main.S</file>
|
<file first="true">main.S</file>
|
||||||
<file>bios.c</file>
|
<file>bios.c</file>
|
||||||
<file>brkpoint.c</file>
|
<file>brkpoint.S</file>
|
||||||
<file>ctxswitch.S</file>
|
<file>ctxswitch.S</file>
|
||||||
<file>exp.c</file>
|
<file>exp.c</file>
|
||||||
<file>fpu.c</file>
|
<file>fpu.c</file>
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
<directory name="ex">
|
<directory name="ex">
|
||||||
<if property="ARCH" value="i386">
|
<if property="ARCH" value="i386">
|
||||||
<directory name="i386">
|
<directory name="i386">
|
||||||
<file>interlck.c</file>
|
<file>interlck.S</file>
|
||||||
</directory>
|
</directory>
|
||||||
</if>
|
</if>
|
||||||
<file>callback.c</file>
|
<file>callback.c</file>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue