diff --git a/reactos/boot/freeldr/freeldr/arch/i386/portio.c b/reactos/boot/freeldr/freeldr/arch/i386/portio.c deleted file mode 100644 index 6169c5bea46..00000000000 --- a/reactos/boot/freeldr/freeldr/arch/i386/portio.c +++ /dev/null @@ -1,219 +0,0 @@ -/* $Id$ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: ntoskrnl/hal/x86/portio.c - * PURPOSE: Port I/O functions - * PROGRAMMER: Eric Kohl - * UPDATE HISTORY: - * Created 18/10/99 - */ - -//#include -#include - - -/* FUNCTIONS ****************************************************************/ - -/* - * This file contains the definitions for the x86 IO instructions - * inb/inw/inl/outb/outw/outl and the "string versions" of the same - * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing" - * versions of the single-IO instructions (inb_p/inw_p/..). - * - * This file is not meant to be obfuscating: it's just complicated - * to (a) handle it all in a way that makes gcc able to optimize it - * as well as possible and (b) trying to avoid writing the same thing - * over and over again with slight variations and possibly making a - * mistake somewhere. - */ - -/* - * Thanks to James van Artsdalen for a better timing-fix than - * the two short jumps: using outb's to a nonexistent port seems - * to guarantee better timings even on fast machines. - * - * On the other hand, I'd like to be sure of a non-existent port: - * I feel a bit unsafe about using 0x80 (should be safe, though) - * - * Linus - */ - -#ifdef SLOW_IO_BY_JUMPING -#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:") -#else -#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80") -#endif - -#ifdef REALLY_SLOW_IO -#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; } -#else -#define SLOW_DOWN_IO __SLOW_DOWN_IO -#endif - -#undef READ_PORT_BUFFER_UCHAR -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_UCHAR (PUCHAR Port, - PUCHAR Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; insb\n\t" - : "=D" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef READ_PORT_BUFFER_USHORT -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_USHORT (USHORT* Port, - USHORT* Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; insw" - : "=D" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef READ_PORT_BUFFER_ULONG -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_ULONG (ULONG* Port, - ULONG* Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; insl" - : "=D" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef READ_PORT_UCHAR -NTHALAPI -UCHAR -DDKAPI -READ_PORT_UCHAR (PUCHAR Port) -{ - UCHAR Value; - - __asm__("inb %w1, %0\n\t" - : "=a" (Value) - : "d" (Port)); - SLOW_DOWN_IO; - return(Value); -} - -#undef READ_PORT_USHORT -NTHALAPI -USHORT -DDKAPI -READ_PORT_USHORT (USHORT* Port) -{ - USHORT Value; - - __asm__("inw %w1, %0\n\t" - : "=a" (Value) - : "d" (Port)); - SLOW_DOWN_IO; - return(Value); -} - -#undef READ_PORT_ULONG -NTHALAPI -ULONG -DDKAPI -READ_PORT_ULONG (ULONG* Port) -{ - ULONG Value; - - __asm__("inl %w1, %0\n\t" - : "=a" (Value) - : "d" (Port)); - SLOW_DOWN_IO; - return(Value); -} - -#undef WRITE_PORT_BUFFER_UCHAR -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, - PUCHAR Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; outsb" - : "=S" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef WRITE_PORT_BUFFER_USHORT -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_USHORT (USHORT* Port, - USHORT* Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; outsw" - : "=S" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef WRITE_PORT_BUFFER_ULONG -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_ULONG (ULONG* Port, - ULONG* Buffer, - ULONG Count) -{ - __asm__ __volatile__ ("cld ; rep ; outsl" - : "=S" (Buffer), "=c" (Count) - : "d" (Port),"0" (Buffer),"1" (Count)); -} - -#undef WRITE_PORT_UCHAR -NTHALAPI -VOID -DDKAPI -WRITE_PORT_UCHAR (PUCHAR Port, - UCHAR Value) -{ - __asm__("outb %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); - SLOW_DOWN_IO; -} - -#undef WRITE_PORT_USHORT -NTHALAPI -VOID -DDKAPI -WRITE_PORT_USHORT (USHORT* Port, - USHORT Value) -{ - __asm__("outw %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); - SLOW_DOWN_IO; -} - -#undef WRITE_PORT_ULONG -NTHALAPI -VOID -DDKAPI -WRITE_PORT_ULONG (ULONG* Port, - ULONG Value) -{ - __asm__("outl %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); - SLOW_DOWN_IO; -} - -/* EOF */ diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c index 9ae21bc2158..45358cf5336 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c @@ -152,7 +152,7 @@ static struct * Data block read and write commands */ #define IDEReadBlock(Address, Buffer, Count) \ - (READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2)) + (__inwordstring(((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2)) #define IDEWriteBlock(Address, Buffer, Count) \ (WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2)) diff --git a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild index fe5bc10fae9..07ba521e418 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild @@ -26,7 +26,6 @@ pcmem.c pcrtc.c pcvideo.c - portio.c machxbox.c xboxcons.c xboxdisk.c diff --git a/reactos/boot/freeldr/freeldr/include/freeldr.h b/reactos/boot/freeldr/freeldr/include/freeldr.h index eadd57b55f3..3461355e97f 100644 --- a/reactos/boot/freeldr/freeldr/include/freeldr.h +++ b/reactos/boot/freeldr/freeldr/include/freeldr.h @@ -28,6 +28,7 @@ #define NTOSAPI #define printf TuiPrintf #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include /* NDK, needed for ReactOS/Windows loaders */ #include diff --git a/reactos/boot/freeldr/freeldr/include/portio.h b/reactos/boot/freeldr/freeldr/include/portio.h deleted file mode 100644 index 2f12179a5ed..00000000000 --- a/reactos/boot/freeldr/freeldr/include/portio.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * FreeLoader - * Copyright (C) 2001 Brian Palmer - * Copyright (C) 2001 Eric Kohl - * Copyright (C) 2001 Emanuele Aliberti - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __PORTIO_H -#define __PORTIO_H - -/* - * Port I/O functions - */ - -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count); - -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count); - -NTHALAPI -VOID -DDKAPI -READ_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count); - -NTHALAPI -UCHAR -DDKAPI -READ_PORT_UCHAR (PUCHAR Port); - -NTHALAPI -ULONG -DDKAPI -READ_PORT_ULONG (ULONG* Port); - -NTHALAPI -USHORT -DDKAPI -READ_PORT_USHORT (USHORT* Port); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_UCHAR (PUCHAR Port, PUCHAR Value, ULONG Count); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_ULONG (ULONG* Port, ULONG* Value, ULONG Count); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_BUFFER_USHORT (USHORT* Port, USHORT* Value, ULONG Count); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_UCHAR (PUCHAR Port, UCHAR Value); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_ULONG (ULONG* Port, ULONG Value); - -NTHALAPI -VOID -DDKAPI -WRITE_PORT_USHORT (USHORT* Port, USHORT Value); - - -#endif // defined __PORTIO_H diff --git a/reactos/include/ddk/ioaccess.h b/reactos/include/ddk/ioaccess.h new file mode 100755 index 00000000000..547422246aa --- /dev/null +++ b/reactos/include/ddk/ioaccess.h @@ -0,0 +1,70 @@ +/* + * ioaccess.h + * + * Windows Device Driver Kit + * + * This file is part of the w32api package. + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ +#ifndef __IOACCESS_H +#define __IOACCESS_H + +#if __GNUC__ >= 3 +#pragma GCC system_header +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define H2I(p) PtrToUshort(p) + +#ifndef NO_PORT_MACROS + +#if defined(_X86_) +#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR *)(r)) +#define READ_REGISTER_USHORT(r) (*(volatile USHORT *)(r)) +#define READ_REGISTER_ULONG(r) (*(volatile ULONG *)(r)) +#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR *)(r) = (v)) +#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT *)(r) = (v)) +#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG *)(r) = (v)) +#define READ_PORT_UCHAR(p) (UCHAR)(__inbyte H2I(p)) +#define READ_PORT_USHORT(p) (USHORT)(__inword H2I(p)) +#define READ_PORT_ULONG(p) (ULONG)(__indword H2I(p)) +#define WRITE_PORT_UCHAR(p, v) __outbyte (H2I(p), (v)) +#define WRITE_PORT_USHORT(p, v) __outword (H2I(p), (v)) +#define WRITE_PORT_ULONG(p, v) __outdword (H2I(p), (v)) + +#elif defined(_PPC_) || defined(_MIPS_) || defined(_ARM_) + +#define READ_REGISTER_UCHAR(r) (*(volatile UCHAR * const)(r)) +#define READ_REGISTER_USHORT(r) (*(volatile USHORT * const)(r)) +#define READ_REGISTER_ULONG(r) (*(volatile ULONG * const)(r)) +#define WRITE_REGISTER_UCHAR(r, v) (*(volatile UCHAR * const)(r) = (v)) +#define WRITE_REGISTER_USHORT(r, v) (*(volatile USHORT * const)(r) = (v)) +#define WRITE_REGISTER_ULONG(r, v) (*(volatile ULONG * const)(r) = (v)) +#define READ_PORT_UCHAR(r) READ_REGISTER_UCHAR(r) +#define READ_PORT_USHORT(r) READ_REGISTER_USHORT(r) +#define READ_PORT_ULONG(r) READ_REGISTER_ULONG(r) +#define WRITE_PORT_UCHAR(p, v) WRITE_REGISTER_UCHAR(p, (UCHAR) (v)) +#define WRITE_PORT_USHORT(p, v) WRITE_REGISTER_USHORT(p, (USHORT) (v)) +#define WRITE_PORT_ULONG(p, v) WRITE_REGISTER_ULONG(p, (ULONG) (v)) + +#else + +#error Unsupported architecture + +#endif + +#endif /* NO_PORT_MACROS */ +#endif /* __IOACCESS_H */