ArmPlatformPkg/Drivers/NorFlashDxe: Directly implement DiskIO protocol
[mirror_edk2.git] / ArmPlatformPkg / Drivers / NorFlashDxe / NorFlashDxe.h
index 6c8cea2..a6854aa 100644 (file)
@@ -22,6 +22,7 @@
 #include <Guid/EventGroup.h>\r
 \r
 #include <Protocol/BlockIo.h>\r
+#include <Protocol/DiskIo.h>\r
 #include <Protocol/FirmwareVolumeBlock.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #define NOR_FLASH_SIGNATURE                       SIGNATURE_32('n', 'o', 'r', '0')\r
 #define INSTANCE_FROM_FVB_THIS(a)                 CR(a, NOR_FLASH_INSTANCE, FvbProtocol, NOR_FLASH_SIGNATURE)\r
 #define INSTANCE_FROM_BLKIO_THIS(a)               CR(a, NOR_FLASH_INSTANCE, BlockIoProtocol, NOR_FLASH_SIGNATURE)\r
+#define INSTANCE_FROM_DISKIO_THIS(a)              CR(a, NOR_FLASH_INSTANCE, DiskIoProtocol, NOR_FLASH_SIGNATURE)\r
 \r
 typedef struct _NOR_FLASH_INSTANCE                NOR_FLASH_INSTANCE;\r
 \r
@@ -141,10 +143,11 @@ struct _NOR_FLASH_INSTANCE {
 \r
   EFI_BLOCK_IO_PROTOCOL               BlockIoProtocol;\r
   EFI_BLOCK_IO_MEDIA                  Media;\r
+  EFI_DISK_IO_PROTOCOL                DiskIoProtocol;\r
 \r
   BOOLEAN                             SupportFvb;\r
   EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol;\r
-  VOID*                               FvbBuffer;\r
+  VOID*                               ShadowBuffer;\r
 \r
   NOR_FLASH_DEVICE_PATH                      DevicePath;\r
 };\r
@@ -210,6 +213,31 @@ NorFlashBlockIoFlushBlocks (
   IN EFI_BLOCK_IO_PROTOCOL    *This\r
 );\r
 \r
+//\r
+// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.ReadDisk\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+NorFlashDiskIoReadDisk (\r
+  IN EFI_DISK_IO_PROTOCOL         *This,\r
+  IN UINT32                       MediaId,\r
+  IN UINT64                       Offset,\r
+  IN UINTN                        BufferSize,\r
+  OUT VOID                        *Buffer\r
+  );\r
+\r
+//\r
+// DiskIO Protocol function EFI_DISK_IO_PROTOCOL.WriteDisk\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+NorFlashDiskIoWriteDisk (\r
+  IN EFI_DISK_IO_PROTOCOL         *This,\r
+  IN UINT32                       MediaId,\r
+  IN UINT64                       Offset,\r
+  IN UINTN                        BufferSize,\r
+  IN VOID                         *Buffer\r
+  );\r
 \r
 //\r
 // NorFlashFvbDxe.c\r
@@ -290,10 +318,11 @@ NorFlashUnlockAndEraseSingleBlock (
 \r
 EFI_STATUS\r
 NorFlashWriteSingleBlock (\r
-  IN NOR_FLASH_INSTANCE     *Instance,\r
-  IN EFI_LBA                Lba,\r
-  IN UINT32                 *DataBuffer,\r
-  IN UINT32                 BlockSizeInWords\r
+  IN        NOR_FLASH_INSTANCE   *Instance,\r
+  IN        EFI_LBA               Lba,\r
+  IN        UINTN                 Offset,\r
+  IN OUT    UINTN                *NumBytes,\r
+  IN        UINT8                *Buffer\r
   );\r
 \r
 EFI_STATUS\r
@@ -304,13 +333,6 @@ NorFlashWriteBlocks (
   IN  VOID              *Buffer\r
   );\r
 \r
-EFI_STATUS\r
-NorFlashWriteSingleWord (\r
-  IN NOR_FLASH_INSTANCE     *Instance,\r
-  IN UINTN                  WordAddress,\r
-  IN UINT32                 WriteData\r
-  );\r
-\r
 EFI_STATUS\r
 NorFlashReadBlocks (\r
   IN NOR_FLASH_INSTANCE   *Instance,\r
@@ -328,6 +350,15 @@ NorFlashRead (
   OUT VOID                *Buffer\r
   );\r
 \r
+EFI_STATUS\r
+NorFlashWrite (\r
+  IN        NOR_FLASH_INSTANCE   *Instance,\r
+  IN        EFI_LBA               Lba,\r
+  IN        UINTN                 Offset,\r
+  IN OUT    UINTN                *NumBytes,\r
+  IN        UINT8                *Buffer\r
+  );\r
+\r
 EFI_STATUS\r
 NorFlashReset (\r
   IN  NOR_FLASH_INSTANCE *Instance\r