Author: ion
Date: Tue Nov 7 17:44:32 2006
New Revision: 24699
URL:
http://svn.reactos.org/svn/reactos?rev=24699&view=rev
Log:
- Remove WRITE/READ_REG_XXX functions written in C and write them in optimized assembly
(no stack usage).
- Also flush posted write buffers during WRITE_XXX operations.
Added:
trunk/reactos/ntoskrnl/ex/i386/ioport.S
Removed:
trunk/reactos/ntoskrnl/rtl/regio.c
Modified:
trunk/reactos/ntoskrnl/ntoskrnl.rbuild
Added: trunk/reactos/ntoskrnl/ex/i386/ioport.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/i386/ioport.S?…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/i386/ioport.S (added)
+++ trunk/reactos/ntoskrnl/ex/i386/ioport.S Tue Nov 7 17:44:32 2006
@@ -1,0 +1,220 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS kernel
+ * FILE: ntoskrnl/ex/i386/ioport.S
+ * PURPOSE: FASTCALL Interlocked Functions
+ * PROGRAMMERS: Alex Ionescu (alex(a)relsoft.net)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <ndk/asm.h>
+.intel_syntax noprefix
+
+/* 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
+
+/* FUNCTIONS *****************************************************************/
+
+.func READ_REGISTER_UCHAR@4
+_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 eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+4]
+ mov edi, [esp+8]
+ rep movsb
+
+ /* Restore volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+.func READ_REGISTER_BUFFER_USHORT@12
+_READ_REGISTER_BUFFER_USHORT@12:
+
+ /* Save volatiles */
+ mov eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+4]
+ mov edi, [esp+8]
+ rep movsw
+
+ /* Restore volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+.func READ_REGISTER_BUFFER_ULONG@12
+_READ_REGISTER_BUFFER_ULONG@12:
+
+ /* Save volatiles */
+ mov eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+4]
+ mov edi, [esp+8]
+ rep movsd
+
+ /* Restore volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+.func WRITE_REGISTER_UCHAR@8
+_WRITE_REGISTER_UCHAR@8:
+
+ /* Write to memory */
+ mov edx, [esp+4]
+ mov al, [esp+8]
+ mov [edx], al
+
+ /* 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 */
+ mov edx, [esp+4]
+ mov eax, [esp+8]
+ mov [edx], ax
+
+ /* 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 */
+ mov edx, [esp+4]
+ mov eax, [esp+8]
+ mov [edx], eax
+
+ /* 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 eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+8]
+ mov edi, [esp+4]
+ rep movsb
+
+ /* Flush posted write buffers */
+ lock or [esp+4], ecx
+
+ /* Restole volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+.func WRITE_REGISTER_BUFFER_USHORT@12
+_WRITE_REGISTER_BUFFER_USHORT@12:
+
+ /* Save volatiles */
+ mov eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+8]
+ mov edi, [esp+4]
+ rep movsw
+
+ /* Flush posted write buffers */
+ lock or [esp+4], ecx
+
+ /* Restole volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+.func WRITE_REGISTER_BUFFER_ULONG@12
+_WRITE_REGISTER_BUFFER_ULONG@12:
+
+ /* Save volatiles */
+ mov eax, esi
+ mov edx, edi
+
+ /* Do the transfer */
+ mov ecx, [esp+12]
+ mov esi, [esp+8]
+ mov edi, [esp+4]
+ rep movsd
+
+ /* Flush posted write buffers */
+ lock or [esp+4], ecx
+
+ /* Restole volatiles and return */
+ mov edi, edx
+ mov esi, eax
+ ret 12
+.endfunc
+
+/* EOF */
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Tue Nov 7 17:44:32 2006
@@ -125,6 +125,7 @@
<directory name="i386">
<file>interlck_asm.S</file>
<file>fastinterlck_asm.S</file>
+ <file>ioport.S</file>
</directory>
</if>
<file>atom.c</file>
@@ -333,7 +334,6 @@
</if>
<file>libsupp.c</file>
<file>misc.c</file>
- <file>regio.c</file>
<file>strtok.c</file>
</directory>
<directory name="se">
Removed: trunk/reactos/ntoskrnl/rtl/regio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/regio.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/regio.c (original)
+++ trunk/reactos/ntoskrnl/rtl/regio.c (removed)
@@ -1,190 +1,0 @@
-/* $Id$
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * FILE: ntoskrnl/rtl/regio.c
- * PURPOSE: Register io functions
- *
- * PROGRAMMERS: Eric Kohl (ekohl(a)abo.rhein-zeitung.de)
- */
-
-#include <ntoskrnl.h>
-
-
-/* FUNCTIONS ***************************************************************/
-
-UCHAR
-STDCALL
-READ_REGISTER_UCHAR (
- PUCHAR Register
- )
-{
- return *Register;
-}
-
-/*
- * @implemented
- */
-USHORT
-STDCALL
-READ_REGISTER_USHORT (
- PUSHORT Register
- )
-{
- return *Register;
-}
-
-/*
- * @implemented
- */
-ULONG
-STDCALL
-READ_REGISTER_ULONG (
- PULONG Register
- )
-{
- return *Register;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-READ_REGISTER_BUFFER_UCHAR (
- PUCHAR Register,
- PUCHAR Buffer,
- ULONG Count
- )
-{
- while (Count--)
- {
- *Buffer++ = *Register++;
- }
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-READ_REGISTER_BUFFER_USHORT (
- PUSHORT Register,
- PUSHORT Buffer,
- ULONG Count
- )
-{
- while (Count--)
- {
- *Buffer++ = *Register++;
- }
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-READ_REGISTER_BUFFER_ULONG (
- PULONG Register,
- PULONG Buffer,
- ULONG Count
- )
-{
- while (Count--)
- {
- *Buffer++ = *Register++;
- }
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_UCHAR (
- PUCHAR Register,
- UCHAR Value
- )
-{
- *Register = Value;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_USHORT (
- PUSHORT Register,
- USHORT Value
- )
-{
- *Register = Value;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_ULONG (
- PULONG Register,
- ULONG Value
- )
-{
- *Register = Value;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_BUFFER_UCHAR (
- PUCHAR Register,
- PUCHAR Buffer,
- ULONG Count
- )
-{
- while (Count--)
- {
- *Register++ = *Buffer++;
- }
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_BUFFER_USHORT (
- PUSHORT Register,
- PUSHORT Buffer,
- ULONG Count
- )
-{
- while (Count--)
- {
- *Register++ = *Buffer++;
- }
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-WRITE_REGISTER_BUFFER_ULONG (
- PULONG Register,
- PULONG Buffer,
- ULONG Count
-)
-{
- while (Count--)
- {
- *Register++ = *Buffer++;
- }
-}
-
-/* EOF */