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

MdePkg/Library/PeiIoLibCpuIo/IoLibMmioBuffer.c

Go to the documentation of this file.
00001 
00017 #include <PiPei.h>
00018 
00019 #include <Library/IoLib.h>
00020 #include <Library/DebugLib.h>
00021 #include <Library/BaseLib.h>
00022 #include <Library/PeiServicesTablePointerLib.h>
00023 
00042 UINT8 *
00043 EFIAPI
00044 MmioReadBuffer8 (
00045   IN  UINTN       StartAddress,
00046   IN  UINTN       Length,
00047   OUT UINT8       *Buffer
00048   )
00049 {
00050   UINT8   *ReturnBuffer;
00051 
00052   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00053   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00054  
00055   ReturnBuffer = Buffer;
00056   
00057   while (Length-- != 0) {
00058     *(Buffer++) = MmioRead8 (StartAddress++);
00059   }
00060 
00061   return ReturnBuffer;
00062 }
00063 
00086 UINT16 *
00087 EFIAPI
00088 MmioReadBuffer16 (
00089   IN  UINTN       StartAddress,
00090   IN  UINTN       Length,
00091   OUT UINT16      *Buffer
00092   )
00093 {
00094   UINT16    *ReturnBuffer;
00095 
00096   ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
00097   
00098   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00099   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00100 
00101   ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
00102   ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
00103  
00104   ReturnBuffer = Buffer;
00105   
00106   while (Length != 0) {
00107     *(Buffer++) = MmioRead16 (StartAddress);
00108     StartAddress += sizeof (UINT16);
00109     Length -= sizeof (UINT16);
00110   }
00111 
00112   return ReturnBuffer;
00113 }
00114 
00137 UINT32 *
00138 EFIAPI
00139 MmioReadBuffer32 (
00140   IN  UINTN       StartAddress,
00141   IN  UINTN       Length,
00142   OUT UINT32      *Buffer
00143   )
00144 {
00145   UINT32    *ReturnBuffer;
00146 
00147   ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
00148   
00149   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00150   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00151 
00152   ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
00153   ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
00154  
00155   ReturnBuffer = Buffer;
00156   
00157   while (Length != 0) {
00158     *(Buffer++) = MmioRead32 (StartAddress);
00159     StartAddress += sizeof (UINT32);
00160     Length -= sizeof (UINT32);
00161   }
00162 
00163   return ReturnBuffer;
00164 }
00165 
00188 UINT64 *
00189 EFIAPI
00190 MmioReadBuffer64 (
00191   IN  UINTN       StartAddress,
00192   IN  UINTN       Length,
00193   OUT UINT64      *Buffer
00194   )
00195 {
00196   UINT64    *ReturnBuffer;
00197 
00198   ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
00199   
00200   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00201   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00202 
00203   ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
00204   ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
00205  
00206   ReturnBuffer = Buffer;
00207   
00208   while (Length != 0) {
00209     *(Buffer++) = MmioRead64 (StartAddress);
00210     StartAddress += sizeof (UINT64);
00211     Length -= sizeof (UINT64);
00212   }
00213 
00214   return ReturnBuffer;
00215 }
00216 
00217 
00236 UINT8 *
00237 EFIAPI
00238 MmioWriteBuffer8 (
00239   IN  UINTN         StartAddress,
00240   IN  UINTN         Length,
00241   IN  CONST UINT8   *Buffer
00242   )
00243 {
00244   VOID* ReturnBuffer;
00245 
00246   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00247   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00248  
00249   ReturnBuffer = (UINT8 *) Buffer;
00250   
00251   while (Length-- != 0) {
00252      MmioWrite8 (StartAddress++, *(Buffer++));
00253   }
00254 
00255   return ReturnBuffer;
00256  
00257 }
00258 
00282 UINT16 *
00283 EFIAPI
00284 MmioWriteBuffer16 (
00285   IN  UINTN        StartAddress,
00286   IN  UINTN        Length,
00287   IN  CONST UINT16 *Buffer
00288   )
00289 {
00290   UINT16    *ReturnBuffer;
00291 
00292   ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
00293   
00294   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00295   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00296 
00297   ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
00298   ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
00299 
00300   ReturnBuffer = (UINT16 *) Buffer;
00301   
00302   while (Length != 0) {
00303     MmioWrite16 (StartAddress, *(Buffer++));
00304     
00305     StartAddress += sizeof (UINT16);
00306     Length -= sizeof (UINT16);
00307   }
00308 
00309   return ReturnBuffer;
00310 }
00311 
00312 
00336 UINT32 *
00337 EFIAPI
00338 MmioWriteBuffer32 (
00339   IN  UINTN        StartAddress,
00340   IN  UINTN        Length,
00341   IN  CONST UINT32 *Buffer
00342   )
00343 {
00344   UINT32    *ReturnBuffer;
00345 
00346   ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
00347   
00348   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00349   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00350 
00351   ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
00352   ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
00353 
00354   ReturnBuffer = (UINT32 *) Buffer;
00355   
00356   while (Length != 0) {
00357     MmioWrite32 (StartAddress, *(Buffer++));
00358     
00359     StartAddress += sizeof (UINT32);
00360     Length -= sizeof (UINT32);
00361   }
00362 
00363   return ReturnBuffer;
00364 }
00365 
00389 UINT64 *
00390 EFIAPI
00391 MmioWriteBuffer64 (
00392   IN  UINTN        StartAddress,
00393   IN  UINTN        Length,
00394   IN  CONST UINT64 *Buffer
00395   )
00396 {
00397   UINT64    *ReturnBuffer;
00398 
00399   ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
00400   
00401   ASSERT ((Length - 1) <=  (MAX_ADDRESS - StartAddress));
00402   ASSERT ((Length - 1) <=  (MAX_ADDRESS - (UINTN) Buffer));
00403 
00404   ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
00405   ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
00406 
00407   ReturnBuffer = (UINT64 *) Buffer;
00408   
00409   while (Length != 0) {
00410     MmioWrite64 (StartAddress, *(Buffer++));
00411     
00412     StartAddress += sizeof (UINT64);
00413     Length -= sizeof (UINT64);
00414   }
00415 
00416   return ReturnBuffer;
00417 }
00418 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines