EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c

Go to the documentation of this file.
00001 /*++
00002 
00003 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
00004 This program and the accompanying materials                          
00005 are licensed and made available under the terms and conditions of the BSD License         
00006 which accompanies this distribution.  The full text of the license may be found at        
00007 http://opensource.org/licenses/bsd-license.php                                            
00008                                                                                           
00009 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
00010 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.  
00011 
00012 
00013 Module Name:
00014 
00015   DxeSmbus.c
00016   
00017 Abstract: 
00018 
00019   Dxe Smbus Lib Interfaces
00020 
00021 --*/
00022 
00023 #include "DxeSmbusLibInternal.h"
00024 
00042 VOID
00043 EFIAPI
00044 SmBusQuickRead (
00045   IN  UINTN                     SmBusAddress,
00046   OUT RETURN_STATUS             *Status       OPTIONAL
00047   )
00048 {
00049   ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
00050   ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);
00051   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00052   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00053 
00054   InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);
00055 }
00056 
00074 VOID
00075 EFIAPI
00076 SmBusQuickWrite (
00077   IN  UINTN                     SmBusAddress,
00078   OUT RETURN_STATUS             *Status       OPTIONAL
00079   )
00080 {
00081   ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
00082   ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);
00083   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00084   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00085 
00086   InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);
00087 }
00088 
00108 UINT8
00109 EFIAPI
00110 SmBusReceiveByte (
00111   IN  UINTN          SmBusAddress,
00112   OUT RETURN_STATUS  *Status        OPTIONAL
00113   )
00114 {
00115   UINT8   Byte;
00116 
00117   ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
00118   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)  == 0);
00119   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00120 
00121   InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);
00122 
00123   return Byte;
00124 }
00125 
00146 UINT8
00147 EFIAPI
00148 SmBusSendByte (
00149   IN  UINTN          SmBusAddress,
00150   IN  UINT8          Value,
00151   OUT RETURN_STATUS  *Status        OPTIONAL
00152   )
00153 {
00154   UINT8   Byte;
00155 
00156   ASSERT (SMBUS_LIB_COMMAND (SmBusAddress)   == 0);
00157   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00158   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00159 
00160   Byte   = Value;
00161   InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);
00162 
00163   return Value;
00164 }
00165 
00184 UINT8
00185 EFIAPI
00186 SmBusReadDataByte (
00187   IN  UINTN          SmBusAddress,
00188   OUT RETURN_STATUS  *Status        OPTIONAL
00189   )
00190 {
00191   UINT8   Byte;
00192 
00193   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00194   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00195 
00196   InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);
00197   
00198   return Byte;
00199 }
00200 
00221 UINT8
00222 EFIAPI
00223 SmBusWriteDataByte (
00224   IN  UINTN          SmBusAddress,
00225   IN  UINT8          Value,
00226   OUT RETURN_STATUS  *Status        OPTIONAL
00227   )
00228 {
00229   UINT8   Byte;
00230 
00231   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00232   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00233 
00234   Byte = Value;
00235   InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);
00236   
00237   return Value;
00238 }
00239 
00258 UINT16
00259 EFIAPI
00260 SmBusReadDataWord (
00261   IN  UINTN          SmBusAddress,
00262   OUT RETURN_STATUS  *Status        OPTIONAL
00263   )
00264 {
00265   UINT16  Word;
00266 
00267   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00268   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00269 
00270   InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
00271   
00272   return Word;
00273 }
00274 
00295 UINT16
00296 EFIAPI
00297 SmBusWriteDataWord (
00298   IN  UINTN          SmBusAddress,
00299   IN  UINT16         Value,
00300   OUT RETURN_STATUS  *Status        OPTIONAL
00301   )
00302 {
00303   UINT16  Word;
00304 
00305   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00306   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00307 
00308   Word = Value;
00309   InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);
00310 
00311   return Value;
00312 }
00313 
00334 UINT16
00335 EFIAPI
00336 SmBusProcessCall (
00337   IN  UINTN          SmBusAddress,
00338   IN  UINT16         Value,
00339   OUT RETURN_STATUS  *Status        OPTIONAL
00340   )
00341 {
00342   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00343   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00344 
00345   InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);
00346   
00347   return Value;
00348 }
00349 
00373 UINTN
00374 EFIAPI
00375 SmBusReadBlock (
00376   IN  UINTN          SmBusAddress,
00377   OUT VOID           *Buffer,
00378   OUT RETURN_STATUS  *Status        OPTIONAL
00379   )
00380 {
00381   ASSERT (Buffer != NULL);
00382   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress)    == 0);
00383   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00384 
00385   return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);
00386 }
00387 
00409 UINTN
00410 EFIAPI
00411 SmBusWriteBlock (
00412   IN  UINTN          SmBusAddress,
00413   OUT VOID           *Buffer,
00414   OUT RETURN_STATUS  *Status        OPTIONAL
00415   )
00416 {
00417   UINTN  Length;
00418 
00419   ASSERT (Buffer != NULL);
00420   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
00421   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
00422   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00423 
00424   Length = SMBUS_LIB_LENGTH (SmBusAddress);
00425   return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);
00426 }
00427 
00452 UINTN
00453 EFIAPI
00454 SmBusBlockProcessCall (
00455   IN  UINTN          SmBusAddress,
00456   IN  VOID           *WriteBuffer,
00457   OUT VOID           *ReadBuffer,
00458   OUT RETURN_STATUS  *Status        OPTIONAL
00459   )
00460 {
00461   UINTN   Length;
00462 
00463   ASSERT (WriteBuffer != NULL);
00464   ASSERT (ReadBuffer  != NULL);
00465   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
00466   ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
00467   ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
00468 
00469   Length = SMBUS_LIB_LENGTH (SmBusAddress);
00470   //
00471   // Assuming that ReadBuffer is large enough to save another memory copy.
00472   //
00473   ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);
00474   return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);
00475 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines