\r
[Sources.Ia32, Sources.X64]\r
VbeShim.c\r
+ UnalignedIoGcc.c | GCC\r
+ UnalignedIoMsc.c | MSFT\r
+ UnalignedIoIcc.c | INTEL\r
+\r
+[Sources.IPF, Sources.EBC, Sources.ARM, Sources.AARCH64]\r
+ UnalignedIoUnsupported.c\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
--- /dev/null
+/** @file\r
+ Unaligned Port I/O. This file has compiler specifics for GCC as there is no\r
+ ANSI C standard for doing IO.\r
+\r
+ Based on IoLibGcc.c.\r
+\r
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include "UnalignedIoInternal.h"\r
+\r
+/**\r
+ Performs a 32-bit write to the specified, possibly unaligned I/O-type\r
+ address.\r
+\r
+ Writes the 32-bit I/O port specified by Port with the value specified by\r
+ Value and returns Value. This function must guarantee that all I/O read and\r
+ write operations are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port I/O port address\r
+ @param[in] Value 32-bit word to write\r
+\r
+ @return The value written to the I/O port.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoWrite32 (\r
+ IN UINTN Port,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ __asm__ __volatile__ ( "outl %0, %1" : : "a" (Value), "d" ((UINT16)Port) );\r
+ return Value;\r
+}\r
+\r
+/**\r
+ Reads a 32-bit word from the specified, possibly unaligned I/O-type address.\r
+\r
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is\r
+ returned. This function must guarantee that all I/O read and write operations\r
+ are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port The I/O port to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoRead32 (\r
+ IN UINTN Port\r
+ )\r
+{\r
+ UINT32 Data;\r
+ __asm__ __volatile__ ( "inl %1, %0" : "=a" (Data) : "d" ((UINT16)Port) );\r
+ return Data;\r
+}\r
+\r
--- /dev/null
+/** @file\r
+ Unaligned port I/O. This file has compiler specifics for ICC as there\r
+ is no ANSI C standard for doing IO.\r
+\r
+ Based on IoLibIcc.c.\r
+\r
+ Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include "UnalignedIoInternal.h"\r
+\r
+/**\r
+ Performs a 32-bit write to the specified, possibly unaligned I/O-type\r
+ address.\r
+\r
+ Writes the 32-bit I/O port specified by Port with the value specified by\r
+ Value and returns Value. This function must guarantee that all I/O read and\r
+ write operations are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port I/O port address\r
+ @param[in] Value 32-bit word to write\r
+\r
+ @return The value written to the I/O port.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoWrite32 (\r
+ IN UINTN Port,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ __asm {\r
+ mov eax, dword ptr [Value]\r
+ mov dx, word ptr [Port]\r
+ out dx, eax\r
+ }\r
+\r
+ return Value;\r
+}\r
+\r
+/**\r
+ Reads a 32-bit word from the specified, possibly unaligned I/O-type address.\r
+\r
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is\r
+ returned. This function must guarantee that all I/O read and write operations\r
+ are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port The I/O port to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoRead32 (\r
+ IN UINTN Port\r
+ )\r
+{\r
+ UINT32 Data;\r
+\r
+ __asm {\r
+ mov dx, word ptr [Port]\r
+ in eax, dx\r
+ mov dword ptr [Data], eax\r
+ }\r
+\r
+ return Data;\r
+}\r
--- /dev/null
+/** @file\r
+ Unaligned port I/O, with implementations for various x86 compilers and a\r
+ dummy for platforms which do not support unaligned port I/O.\r
+\r
+ Copyright (c) 2017, Phil Dennis-Jordan.<BR>\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _UNALIGNED_IO_INTERNAL_H_\r
+#define _UNALIGNED_IO_INTERNAL_H_\r
+\r
+/**\r
+ Performs a 32-bit write to the specified, possibly unaligned I/O-type address.\r
+\r
+ Writes the 32-bit I/O port specified by Port with the value specified by Value\r
+ and returns Value. This function must guarantee that all I/O read and write\r
+ operations are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port I/O port address\r
+ @param[in] Value 32-bit word to write\r
+\r
+ @return The value written to the I/O port.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoWrite32 (\r
+ IN UINTN Port,\r
+ IN UINT32 Value\r
+ );\r
+\r
+/**\r
+ Reads a 32-bit word from the specified, possibly unaligned I/O-type address.\r
+\r
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is\r
+ returned. This function must guarantee that all I/O read and write operations\r
+ are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port The I/O port to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoRead32 (\r
+ IN UINTN Port\r
+ );\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Unaligned port I/O. This file has compiler specifics for Microsoft C as there\r
+ is no ANSI C standard for doing IO.\r
+\r
+ Based on IoLibMsc.c\r
+\r
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include "UnalignedIoInternal.h"\r
+\r
+unsigned long _inpd (unsigned short port);\r
+unsigned long _outpd (unsigned short port, unsigned long dataword );\r
+void _ReadWriteBarrier (void);\r
+\r
+/**\r
+ Performs a 32-bit write to the specified, possibly unaligned I/O-type\r
+ address.\r
+\r
+ Writes the 32-bit I/O port specified by Port with the value specified by\r
+ Value and returns Value. This function must guarantee that all I/O read and\r
+ write operations are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port I/O port address\r
+ @param[in] Value 32-bit word to write\r
+\r
+ @return The value written to the I/O port.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoWrite32 (\r
+ IN UINTN Port,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ _ReadWriteBarrier ();\r
+ _outpd ((UINT16)Port, Value);\r
+ _ReadWriteBarrier ();\r
+ return Value;\r
+}\r
+\r
+/**\r
+ Reads a 32-bit word from the specified, possibly unaligned I/O-type address.\r
+\r
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is\r
+ returned. This function must guarantee that all I/O read and write operations\r
+ are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port The I/O port to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoRead32 (\r
+ IN UINTN Port\r
+ )\r
+{\r
+ UINT32 Value;\r
+\r
+ _ReadWriteBarrier ();\r
+ Value = _inpd ((UINT16)Port);\r
+ _ReadWriteBarrier ();\r
+ return Value;\r
+}\r
--- /dev/null
+/** @file\r
+ Unaligned port I/O dummy implementation for platforms which do not support it.\r
+\r
+ Copyright (c) 2017, Phil Dennis-Jordan.<BR>\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+\r
+#include <Library/DebugLib.h>\r
+#include "UnalignedIoInternal.h"\r
+\r
+/**\r
+ Performs a 32-bit write to the specified, possibly unaligned I/O-type\r
+ address.\r
+\r
+ Writes the 32-bit I/O port specified by Port with the value specified by\r
+ Value and returns Value. This function must guarantee that all I/O read and\r
+ write operations are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port I/O port address\r
+ @param[in] Value 32-bit word to write\r
+\r
+ @return The value written to the I/O port.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoWrite32 (\r
+ IN UINTN Port,\r
+ IN UINT32 Value\r
+ )\r
+{\r
+ ASSERT (FALSE);\r
+ return Value;\r
+}\r
+\r
+/**\r
+ Reads a 32-bit word from the specified, possibly unaligned I/O-type address.\r
+\r
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is\r
+ returned. This function must guarantee that all I/O read and write operations\r
+ are serialized.\r
+\r
+ If 32-bit unaligned I/O port operations are not supported, then ASSERT().\r
+\r
+ @param[in] Port The I/O port to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT32\r
+UnalignedIoRead32 (\r
+ IN UINTN Port\r
+ )\r
+{\r
+ ASSERT (FALSE);\r
+ return 0;\r
+}\r