]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/DxeSmbusLib/SmbusLib.c
Add inf files for PeiSmbusLibSmbus2, PeiDxePostCodeLibReportStatusCode, PeiMemoryLib...
[mirror_edk2.git] / MdePkg / Library / DxeSmbusLib / SmbusLib.c
index e71f11bef81b7c535b1222197eebc9952f5cf037..ad92ea0b8e56466b2bfe2d2e509b24dd5481c836 100644 (file)
@@ -2,13 +2,13 @@
 Implementation of SmBusLib class library for PEI phase.\r
 \r
 Copyright (c) 2006, 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
-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
+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
+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
 Module Name: SmbusLib.c\r
@@ -189,7 +189,7 @@ SmBusReadDataByte (
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);\r
-  \r
+\r
   return Byte;\r
 }\r
 \r
@@ -228,7 +228,7 @@ SmBusWriteDataByte (
 \r
   Byte = Value;\r
   InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);\r
-  \r
+\r
   return Value;\r
 }\r
 \r
@@ -241,7 +241,7 @@ SmBusWriteDataByte (
   If Status is not NULL, then the status of the executed command is returned in Status.\r
   If Length in SmBusAddress is not zero, then ASSERT().\r
   If any reserved bits of SmBusAddress are set, then ASSERT().\r
-  \r
+\r
   @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
                           SMBUS Command, SMBUS Data Length, and PEC.\r
   @param  Status          Return status for the executed command.\r
@@ -263,7 +263,7 @@ SmBusReadDataWord (
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);\r
-  \r
+\r
   return Word;\r
 }\r
 \r
@@ -338,7 +338,7 @@ SmBusProcessCall (
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
   InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);\r
-  \r
+\r
   return Value;\r
 }\r
 \r
@@ -350,7 +350,7 @@ SmBusProcessCall (
   Bytes are read from the SMBUS and stored in Buffer.\r
   The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
   If Status is not NULL, then the status of the executed command is returned in Status.\r
-  It is the caller¡¯s responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
   SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
   If Length in SmBusAddress is not zero, then ASSERT().\r
   If Buffer is NULL, then ASSERT().\r
@@ -387,7 +387,7 @@ SmBusReadBlock (
   The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
   Bytes are written to the SMBUS from Buffer.\r
   The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
-  If Status is not NULL, then the status of the executed command is returned in Status.  \r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
   If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
   If Buffer is NULL, then ASSERT().\r
   If any reserved bits of SmBusAddress are set, then ASSERT().\r
@@ -412,9 +412,11 @@ SmBusWriteBlock (
   UINTN  Length;\r
 \r
   ASSERT (Buffer != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  Length = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
   return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);\r
 }\r
 \r
@@ -423,19 +425,19 @@ SmBusWriteBlock (
 \r
   Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
   The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
-  Bytes are written to the SMBUS from OutBuffer.  Bytes are then read from the SMBUS into InBuffer.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
   If Status is not NULL, then the status of the executed command is returned in Status.\r
-  It is the caller¡¯s responsibility to make sure InBuffer is large enough for the total number of bytes read.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
   SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
-  If OutBuffer is NULL, then ASSERT().\r
-  If InBuffer is NULL, then ASSERT().\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
   If any reserved bits of SmBusAddress are set, then ASSERT().\r
 \r
-\r
   @param  SmBusAddress    Address that encodes the SMBUS Slave Address,\r
                           SMBUS Command, SMBUS Data Length, and PEC.\r
-  @param  OutBuffer       Pointer to the buffer of bytes to write to the SMBUS.\r
-  @param  InBuffer        Pointer to the buffer of bytes to read from the SMBUS.\r
+  @param  WriteBuffer     Pointer to the buffer of bytes to write to the SMBUS.\r
+  @param  ReadBuffer      Pointer to the buffer of bytes to read from the SMBUS.\r
   @param  Status          Return status for the executed command.\r
                           This is an optional parameter and may be NULL.\r
 \r
@@ -446,21 +448,23 @@ UINTN
 EFIAPI\r
 SmBusBlockProcessCall (\r
   IN  UINTN          SmBusAddress,\r
-  IN  VOID           *OutBuffer,\r
-  OUT VOID           *InBuffer,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
   OUT RETURN_STATUS  *Status        OPTIONAL\r
   )\r
 {\r
   UINTN   Length;\r
 \r
-  ASSERT (InBuffer  != NULL);\r
-  ASSERT (OutBuffer != NULL);\r
+  ASSERT (WriteBuffer != NULL);\r
+  ASSERT (ReadBuffer  != NULL);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);\r
+  ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);\r
   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);\r
 \r
-  Length   = SMBUS_LIB_LENGTH (SmBusAddress) + 1;\r
+  Length = SMBUS_LIB_LENGTH (SmBusAddress);\r
   //\r
-  // Assuming that InBuffer is large enough to save another memory copy.\r
+  // Assuming that ReadBuffer is large enough to save another memory copy.\r
   //\r
-  InBuffer = CopyMem (InBuffer, OutBuffer, Length);\r
-  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, InBuffer, Status);\r
+  ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);\r
+  return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);\r
 }\r