]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseIoLibIntrinsic/IoLib.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseIoLibIntrinsic / IoLib.c
index 1e8cb666b30b55ff746dc7d51af8b0f22db3006a..577c44c3af38025253619d37e01d47b047854b32 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common I/O Library routines.\r
 \r
-  Copyright (c) 2006, Intel Corporation<BR>\r
+  Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
   All rights reserved. This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -66,3 +66,252 @@ IoWrite64 (
   return 0;\r
 }\r
 \r
+\r
+/**\r
+  Reads an 8-bit MMIO register.\r
+\r
+  Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioRead8 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT8                             Value;\r
+\r
+  MemoryFence ();\r
+  Value = *(volatile UINT8*)Address;\r
+  MemoryFence ();\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes an 8-bit MMIO register.\r
+\r
+  Writes the 8-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 8-bit MMIO register operations are not supported, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+  \r
+  @return Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+MmioWrite8 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  MemoryFence ();\r
+  *(volatile UINT8*)Address = Value;\r
+  MemoryFence ();\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 16-bit MMIO register.\r
+\r
+  Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioRead16 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT16                            Value;\r
+\r
+  ASSERT ((Address & 1) == 0);\r
+\r
+  MemoryFence ();\r
+  Value = *(volatile UINT16*)Address;\r
+  MemoryFence ();\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 16-bit MMIO register.\r
+\r
+  Writes the 16-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 16-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+  \r
+  @return Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+MmioWrite16 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT16                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 1) == 0);\r
+\r
+  MemoryFence ();\r
+  *(volatile UINT16*)Address = Value;\r
+  MemoryFence ();\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 32-bit MMIO register.\r
+\r
+  Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioRead32 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT32                            Value;\r
+\r
+  ASSERT ((Address & 3) == 0);\r
+  \r
+  MemoryFence ();\r
+  Value = *(volatile UINT32*)Address;\r
+  MemoryFence ();\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 32-bit MMIO register.\r
+\r
+  Writes the 32-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 32-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 32-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+  \r
+  @return Value.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+MmioWrite32 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT32                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 3) == 0);\r
+  \r
+  MemoryFence ();\r
+  *(volatile UINT32*)Address = Value;\r
+  MemoryFence ();\r
+  \r
+  return Value;\r
+}\r
+\r
+/**\r
+  Reads a 64-bit MMIO register.\r
+\r
+  Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r
+  returned. This function must guarantee that all MMIO read and write\r
+  operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to read.\r
+\r
+  @return The value read.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioRead64 (\r
+  IN      UINTN                     Address\r
+  )\r
+{\r
+  UINT64                            Value;\r
+\r
+  ASSERT ((Address & 7) == 0);\r
+  \r
+  MemoryFence ();\r
+  Value = *(volatile UINT64*)Address;\r
+  MemoryFence ();\r
+\r
+  return Value;\r
+}\r
+\r
+/**\r
+  Writes a 64-bit MMIO register.\r
+\r
+  Writes the 64-bit MMIO register specified by Address with the value specified\r
+  by Value and returns Value. This function must guarantee that all MMIO read\r
+  and write operations are serialized.\r
+\r
+  If 64-bit MMIO register operations are not supported, then ASSERT().\r
+  If Address is not aligned on a 64-bit boundary, then ASSERT().\r
+\r
+  @param  Address The MMIO register to write.\r
+  @param  Value   The value to write to the MMIO register.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+MmioWrite64 (\r
+  IN      UINTN                     Address,\r
+  IN      UINT64                    Value\r
+  )\r
+{\r
+  ASSERT ((Address & 7) == 0);\r
+  \r
+  MemoryFence ();\r
+  *(volatile UINT64*)Address = Value;\r
+  MemoryFence ();\r
+  \r
+  return Value;\r
+}\r
+\r