]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Vlv2TbltDevicePkg/Include/Library/FlashDeviceLib.h
Upload BSD-licensed Vlv2TbltDevicePkg and Vlv2DeviceRefCodePkg to
[mirror_edk2.git] / Vlv2TbltDevicePkg / Include / Library / FlashDeviceLib.h
diff --git a/Vlv2TbltDevicePkg/Include/Library/FlashDeviceLib.h b/Vlv2TbltDevicePkg/Include/Library/FlashDeviceLib.h
new file mode 100644 (file)
index 0000000..bddc1f8
--- /dev/null
@@ -0,0 +1,127 @@
+/*++\r
+\r
+  Copyright (c) 2004  - 2014, Intel Corporation. All rights reserved.<BR>\r
+                                                                                   \r\r
+  This program and the accompanying materials are licensed and made available under\r\r
+  the terms and conditions of the BSD License that accompanies this distribution.  \r\r
+  The full text of the license may be found at                                     \r\r
+  http://opensource.org/licenses/bsd-license.php.                                  \r\r
+                                                                                   \r\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,            \r\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.    \r\r
+                                                                                   \r\r
+\r
+\r
+  Flash device library class header file.\r
+\r
+  Flash Device Library common type, MACRO and API definition. The basic idea for\r
+  this library is to provide API to abstract the different between flash\r
+  technology (SPI, FWH etc..), flash controller (SPI host controller on\r
+  ICH, MMIO type access for FWH), flash chip (programming command, method\r
+  of status checking). This library class can be consumed by drivers or applications\r
+  such as Firmware Volume Block driver, Flash Update application. These driver\r
+  can be written in a generic manner so that they are more easy to be\r
+  ported to other platforms.\r
+\r
+  This library can be build on a set of APIs which can touch flash controller, flash\r
+  chip directly for a platform with simple flash device configuration.\r
+\r
+  For a platform with complex flash device configuration, this library can be built\r
+  on the Flash Device Operate Library. Please see the header file for that library\r
+  class for detailed usage.\r
+\r
+**/\r
+\r
+#ifndef __FLASHDEVICE_LIB_H__\r
+#define __FLASHDEVICE_LIB_H__\r
+\r
+/**\r
+  Read NumBytes bytes of data from the address specified by\r
+  PAddress into Buffer.\r
+\r
+  @param[in]      PAddress    The starting physical address of the read.\r
+  @param[in,out]  NumBytes    On input, the number of bytes to read. On output, the number\r
+                              of bytes actually read.\r
+  @param[out]     Buffer      The destination data buffer for the read.\r
+\r
+  @retval EFI_SUCCESS.        Opertion is successful.\r
+  @retval EFI_DEVICE_ERROR    If there is any device errors.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibFvbFlashDeviceRead (\r
+  IN      UINTN                           PAddress,\r
+  IN  OUT UINTN                           *NumBytes,\r
+      OUT UINT8                           *Buffer\r
+  );\r
+\r
+/**\r
+  Write NumBytes bytes of data from Buffer to the address specified by\r
+  PAddresss.\r
+\r
+  @param[in]      PAddress The starting physical address of the write.\r
+  @param[in,out]  NumBytes On input, the number of bytes to write. On output,\r
+                           the actual number of bytes written.\r
+  @param[in]      Buffer   The source data buffer for the write.\r
+\r
+  @retval EFI_SUCCESS.            Opertion is successful.\r
+  @retval EFI_DEVICE_ERROR        If there is any device errors.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibFvbFlashDeviceWrite (\r
+  IN        UINTN                           PAddress,\r
+  IN OUT    UINTN                           *NumBytes,\r
+  IN        UINT8                           *Buffer\r
+  );\r
+\r
+/**\r
+  Erase the block staring at PAddress.\r
+\r
+  @param[in]  PAddress The starting physical address of the region to be erased.\r
+  @param[in]  LbaLength   The length of the region to be erased. This parameter is necessary\r
+                       as the physical block size on a flash device could be different than\r
+                       the logical block size of Firmware Volume Block protocol. Erase on\r
+                       flash chip is always performed block by block. Therefore, the ERASE\r
+                       operation to a logical block is converted a number of ERASE operation\r
+                       (or a partial erase) on the hardware.\r
+\r
+  @retval EFI_SUCCESS.            Opertion is successful.\r
+  @retval EFI_DEVICE_ERROR        If there is any device errors.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibFvbFlashDeviceBlockErase (\r
+  IN    UINTN                      PAddress,\r
+  IN    UINTN                      LbaLength\r
+);\r
+\r
+/**\r
+  Lock or unlock the block staring at PAddress.\r
+\r
+  @param[in]  PAddress The starting physical address of region to be (un)locked.\r
+  @param[in]  LbaLength   The length of the region to be (un)locked. This parameter is necessary\r
+                       as the physical block size on a flash device could be different than\r
+                       the logical block size of Firmware Volume Block protocol. (Un)Lock on\r
+                       flash chip is always performed block by block. Therefore, the (Un)Lock\r
+                       operation to a logical block is converted a number of (Un)Lock operation\r
+                       (or a partial erase) on the hardware.\r
+  @param[in]  Lock     TRUE to lock. FALSE to unlock.\r
+\r
+  @retval EFI_SUCCESS. Opertion is successful.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+LibFvbFlashDeviceBlockLock (\r
+  IN    UINTN                          PAddress,\r
+  IN    UINTN                          LbaLength,\r
+  IN    BOOLEAN                        Lock\r
+);\r
+\r
+#endif\r
+\r
+\r