The FIP006 NOR flash driver contains implementations of the block I/O
and disk I/O protocols, but never exposes them to other drivers (i.e.,
it never installs the protocol interfaces). So let's drop this code
altogether: the NOR flash is for code and variables, not for arbitrary
files.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf        |   3 -
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c | 138 
------------
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c        | 229 
++------------------
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h        |  51 +----
 Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c     |  40 ++--
 5 files changed, 37 insertions(+), 424 deletions(-)

diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
index bddb052c2dcc..b939aa689eef 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/Fip006Dxe.inf
@@ -24,7 +24,6 @@ [Defines]
   ENTRY_POINT                    = NorFlashInitialise
 
 [Sources]
-  NorFlashBlockIoDxe.c
   NorFlashDxe.c
   NorFlashFvbDxe.c
 
@@ -60,9 +59,7 @@ [Guids]
   gEfiVariableGuid
 
 [Protocols]
-  gEfiBlockIoProtocolGuid
   gEfiDevicePathProtocolGuid
-  gEfiDiskIoProtocolGuid
   gEfiFirmwareVolumeBlockProtocolGuid
 
 [FixedPcd]
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c
deleted file mode 100644
index b41f5003217c..000000000000
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashBlockIoDxe.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/** @file  NorFlashBlockIoDxe.c
-
-  Copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
-  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
-  Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
-
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD 
License
-  which accompanies this distribution.  The full text of the license may be 
found at
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include "NorFlashDxe.h"
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoReset (
-  IN EFI_BLOCK_IO_PROTOCOL  *This,
-  IN BOOLEAN                ExtendedVerification
-  )
-{
-  NOR_FLASH_INSTANCE *Instance;
-
-  Instance = INSTANCE_FROM_BLKIO_THIS(This);
-
-  DEBUG ((DEBUG_BLKIO, "NorFlashBlockIoReset(MediaId=0x%x)\n",
-    This->Media->MediaId));
-
-  return NorFlashReset (Instance);
-}
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoReadBlocks (
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,
-  IN  UINT32                  MediaId,
-  IN  EFI_LBA                 Lba,
-  IN  UINTN                   BufferSizeInBytes,
-  OUT VOID                    *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE  *Instance;
-  EFI_STATUS          Status;
-  EFI_BLOCK_IO_MEDIA  *Media;
-
-  if (This == NULL) {
-    return EFI_INVALID_PARAMETER;
-  }
-
-  Instance = INSTANCE_FROM_BLKIO_THIS(This);
-  Media = This->Media;
-
-  DEBUG ((DEBUG_BLKIO,
-    "NorFlashBlockIoReadBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes "
-    "(%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, 
Buffer));
-
-  if (!Media) {
-    Status = EFI_INVALID_PARAMETER;
-  } else if (!Media->MediaPresent) {
-    Status = EFI_NO_MEDIA;
-  } else if (Media->MediaId != MediaId) {
-    Status = EFI_MEDIA_CHANGED;
-  } else if ((Media->IoAlign > 2) &&
-             (((UINTN)Buffer & (Media->IoAlign - 1)) != 0)) {
-    Status = EFI_INVALID_PARAMETER;
-  } else {
-    Status = NorFlashReadBlocks (Instance, Lba, BufferSizeInBytes, Buffer);
-  }
-
-  return Status;
-}
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoWriteBlocks (
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,
-  IN  UINT32                  MediaId,
-  IN  EFI_LBA                 Lba,
-  IN  UINTN                   BufferSizeInBytes,
-  IN  VOID                    *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE  *Instance;
-  EFI_STATUS          Status;
-
-  Instance = INSTANCE_FROM_BLKIO_THIS(This);
-
-  DEBUG ((DEBUG_BLKIO,
-    "NorFlashBlockIoWriteBlocks(MediaId=0x%x, Lba=%ld, BufferSize=0x%x bytes "
-    "(%d kB), BufferPtr @ 0x%08x)\n", MediaId, Lba, BufferSizeInBytes, 
Buffer));
-
-  if( !This->Media->MediaPresent ) {
-    Status = EFI_NO_MEDIA;
-  } else if( This->Media->MediaId != MediaId ) {
-    Status = EFI_MEDIA_CHANGED;
-  } else if( This->Media->ReadOnly ) {
-    Status = EFI_WRITE_PROTECTED;
-  } else {
-    Status = NorFlashWriteBlocks (Instance,Lba,BufferSizeInBytes,Buffer);
-  }
-
-  return Status;
-}
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoFlushBlocks (
-  IN EFI_BLOCK_IO_PROTOCOL  *This
-  )
-{
-  // No Flush required for the NOR Flash driver
-  // because cache operations are not permitted.
-
-  DEBUG ((DEBUG_BLKIO,
-    "NorFlashBlockIoFlushBlocks: Function NOT IMPLEMENTED (not required).\n"));
-
-  // Nothing to do so just return without error
-  return EFI_SUCCESS;
-}
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c
index 98f3e4d5a012..e52ab52d8cf7 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.c
@@ -338,7 +338,7 @@ NorFlashEraseSingleBlock (
   //
   if (EfiAtRuntime()) {
     BlockAddress -= Instance->RegionBaseAddress;
-    BlockAddress += Instance->OffsetLba * Instance->Media.BlockSize;
+    BlockAddress += Instance->OffsetLba * Instance->BlockSize;
   }
 
   NorFlashSetHostCSDC (Instance, TRUE, mFip006NullCmdSeq);
@@ -520,10 +520,6 @@ NorFlashWriteBlocks (
     return EFI_INVALID_PARAMETER;
   }
 
-  if (Instance->Media.ReadOnly == TRUE) {
-    return EFI_WRITE_PROTECTED;
-  }
-
   // We must have some bytes to read
   DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BufferSizeInBytes=0x%x\n",
     BufferSizeInBytes));
@@ -533,19 +529,19 @@ NorFlashWriteBlocks (
 
   // The size of the buffer must be a multiple of the block size
   DEBUG ((DEBUG_BLKIO, "NorFlashWriteBlocks: BlockSize in bytes =0x%x\n",
-    Instance->Media.BlockSize));
-  if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
+    Instance->BlockSize));
+  if ((BufferSizeInBytes % Instance->BlockSize) != 0) {
     return EFI_BAD_BUFFER_SIZE;
   }
 
   // All blocks must be within the device
-  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
+  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize ;
 
   DEBUG ((DEBUG_BLKIO,
     "NorFlashWriteBlocks: NumBlocks=%d, LastBlock=%ld, Lba=%ld.\n", NumBlocks,
-    Instance->Media.LastBlock, Lba));
+    Instance->LastBlock, Lba));
 
-  if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
+  if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) {
     DEBUG ((DEBUG_ERROR,
       "NorFlashWriteBlocks: ERROR - Write will exceed last block.\n"));
     return EFI_INVALID_PARAMETER;
@@ -553,7 +549,7 @@ NorFlashWriteBlocks (
 
   ASSERT (((UINTN)Buffer % sizeof (UINT32)) == 0);
 
-  BlockSizeInWords = Instance->Media.BlockSize / 4;
+  BlockSizeInWords = Instance->BlockSize / 4;
 
   // Because the target *Buffer is a pointer to VOID, we must put
   // all the data into a pointer to a proper data type, so use *ReadBuffer
@@ -592,7 +588,7 @@ NorFlashReadBlocks (
 
   DEBUG ((DEBUG_BLKIO,
     "NorFlashReadBlocks: BufferSize=0x%xB BlockSize=0x%xB LastBlock=%ld, 
Lba=%ld.\n",
-    BufferSizeInBytes, Instance->Media.BlockSize, Instance->Media.LastBlock,
+    BufferSizeInBytes, Instance->BlockSize, Instance->LastBlock,
     Lba));
 
   // The buffer must be valid
@@ -606,14 +602,14 @@ NorFlashReadBlocks (
   }
 
   // The size of the buffer must be a multiple of the block size
-  if ((BufferSizeInBytes % Instance->Media.BlockSize) != 0) {
+  if ((BufferSizeInBytes % Instance->BlockSize) != 0) {
     return EFI_BAD_BUFFER_SIZE;
   }
 
   // All blocks must be within the device
-  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->Media.BlockSize ;
+  NumBlocks = ((UINT32)BufferSizeInBytes) / Instance->BlockSize ;
 
-  if ((Lba + NumBlocks) > (Instance->Media.LastBlock + 1)) {
+  if ((Lba + NumBlocks) > (Instance->LastBlock + 1)) {
     DEBUG ((DEBUG_ERROR,
       "NorFlashReadBlocks: ERROR - Read will exceed last block\n"));
     return EFI_INVALID_PARAMETER;
@@ -621,7 +617,7 @@ NorFlashReadBlocks (
 
   // Get the address to start reading from
   StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba,
-                                        Instance->Media.BlockSize);
+                                        Instance->BlockSize);
 
   // Put the device into Read Array mode
   NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B);
@@ -654,7 +650,7 @@ NorFlashRead (
     return EFI_SUCCESS;
   }
 
-  if (((Lba * Instance->Media.BlockSize) + Offset + BufferSizeInBytes) >
+  if (((Lba * Instance->BlockSize) + Offset + BufferSizeInBytes) >
       Instance->Size) {
     DEBUG ((DEBUG_ERROR,
       "NorFlashRead: ERROR - Read will exceed device size.\n"));
@@ -663,7 +659,7 @@ NorFlashRead (
 
   // Get the address to start reading from
   StartAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress, Lba,
-                                        Instance->Media.BlockSize);
+                                        Instance->BlockSize);
 
   // Put the device into Read Array mode
   NorFlashSetHostCommand (Instance, SPINOR_OP_READ_4B);
@@ -677,7 +673,7 @@ NorFlashRead (
 
 /*
   Write a full or portion of a block. It must not span block boundaries;
-  that is, Offset + *NumBytes <= Instance->Media.BlockSize.
+  that is, Offset + *NumBytes <= Instance->BlockSize.
 */
 EFI_STATUS
 NorFlashWriteSingleBlock (
@@ -711,16 +707,8 @@ NorFlashWriteSingleBlock (
     "NorFlashWriteSingleBlock(Parameters: Lba=%ld, Offset=0x%x, 
*NumBytes=0x%x, Buffer @ 0x%08x)\n",
     Lba, Offset, *NumBytes, Buffer));
 
-  // Detect WriteDisabled state
-  if (Instance->Media.ReadOnly == TRUE) {
-    DEBUG ((DEBUG_ERROR,
-      "NorFlashWriteSingleBlock: ERROR - Can not write: Device is in 
WriteDisabled state.\n"));
-    // It is in WriteDisabled state, return an error right away
-    return EFI_ACCESS_DENIED;
-  }
-
   // Cache the block size to avoid de-referencing pointers all the time
-  BlockSize = Instance->Media.BlockSize;
+  BlockSize = Instance->BlockSize;
 
   // The write must not span block boundaries.
   // We need to check each variable individually because adding two large
@@ -896,143 +884,6 @@ NorFlashWriteSingleBlock (
   return EFI_SUCCESS;
 }
 
-/*
-  Although DiskIoDxe will automatically install the DiskIO protocol whenever
-  we install the BlockIO protocol, its implementation is sub-optimal as it 
reads
-  and writes entire blocks using the BlockIO protocol. In fact we can access
-  NOR flash with a finer granularity than that, so we can improve performance
-  by directly producing the DiskIO protocol.
-*/
-
-/**
-  Read BufferSize bytes from Offset into Buffer.
-
-  @param  This                  Protocol instance pointer.
-  @param  MediaId               Id of the media, changes every time the media 
is
-                                replaced.
-  @param  Offset                The starting byte offset to read from
-  @param  BufferSize            Size of Buffer
-  @param  Buffer                Buffer containing read data
-
-  @retval EFI_SUCCESS           The data was read correctly from the device.
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing
-                                the read.
-  @retval EFI_NO_MEDIA          There is no media in the device.
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current 
device.
-  @retval EFI_INVALID_PARAMETER The read request contains device addresses that
-                                are not valid for the device.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-NorFlashDiskIoReadDisk (
-  IN EFI_DISK_IO_PROTOCOL         *This,
-  IN UINT32                       MediaId,
-  IN UINT64                       DiskOffset,
-  IN UINTN                        BufferSize,
-  OUT VOID                        *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE *Instance;
-  UINT32              BlockSize;
-  UINT32              BlockOffset;
-  EFI_LBA             Lba;
-
-  Instance = INSTANCE_FROM_DISKIO_THIS(This);
-
-  if (MediaId != Instance->Media.MediaId) {
-    return EFI_MEDIA_CHANGED;
-  }
-
-  BlockSize = Instance->Media.BlockSize;
-  Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
-
-  return NorFlashRead (Instance, Lba, BlockOffset, BufferSize, Buffer);
-}
-
-/**
-  Writes a specified number of bytes to a device.
-
-  @param  This       Indicates a pointer to the calling context.
-  @param  MediaId    ID of the medium to be written.
-  @param  Offset     The starting byte offset on the logical block I/O device 
to
-                     write.
-  @param  BufferSize The size in bytes of Buffer. The number of bytes to write
-                     to the device.
-  @param  Buffer     A pointer to the buffer containing the data to be written.
-
-  @retval EFI_SUCCESS           The data was written correctly to the device.
-  @retval EFI_WRITE_PROTECTED   The device can not be written to.
-  @retval EFI_DEVICE_ERROR      The device reported an error while performing
-                                the write.
-  @retval EFI_NO_MEDIA          There is no media in the device.
-  @retval EFI_MEDIA_CHNAGED     The MediaId does not matched the current 
device.
-  @retval EFI_INVALID_PARAMETER The write request contains device addresses 
that
-                                are not valid for the device.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-NorFlashDiskIoWriteDisk (
-  IN EFI_DISK_IO_PROTOCOL         *This,
-  IN UINT32                       MediaId,
-  IN UINT64                       DiskOffset,
-  IN UINTN                        BufferSize,
-  IN VOID                         *Buffer
-  )
-{
-  NOR_FLASH_INSTANCE *Instance;
-  UINT32              BlockSize;
-  UINT32              BlockOffset;
-  EFI_LBA             Lba;
-  UINTN               RemainingBytes;
-  UINTN               WriteSize;
-  EFI_STATUS          Status;
-
-  Instance = INSTANCE_FROM_DISKIO_THIS(This);
-
-  if (MediaId != Instance->Media.MediaId) {
-    return EFI_MEDIA_CHANGED;
-  }
-
-  BlockSize = Instance->Media.BlockSize;
-  Lba = (EFI_LBA) DivU64x32Remainder (DiskOffset, BlockSize, &BlockOffset);
-
-  RemainingBytes = BufferSize;
-
-  // Write either all the remaining bytes, or the number of bytes that bring
-  // us up to a block boundary, whichever is less.
-  // (DiskOffset | (BlockSize - 1)) + 1) rounds DiskOffset up to the next
-  // block boundary (even if it is already on one).
-  WriteSize = MIN (RemainingBytes,
-                   ((DiskOffset | (BlockSize - 1)) + 1) - DiskOffset);
-
-  do {
-    if (WriteSize == BlockSize) {
-      // Write a full block
-      Status = NorFlashWriteFullBlock (Instance, Lba, Buffer,
-                 BlockSize / sizeof (UINT32));
-    } else {
-      // Write a partial block
-      Status = NorFlashWriteSingleBlock (Instance, Lba, BlockOffset, 
&WriteSize,
-                 Buffer);
-    }
-    if (EFI_ERROR (Status)) {
-      return Status;
-    }
-    // Now continue writing either all the remaining bytes or single blocks.
-    RemainingBytes -= WriteSize;
-    Buffer = (UINT8 *) Buffer + WriteSize;
-    Lba++;
-    BlockOffset = 0;
-    WriteSize = MIN (RemainingBytes, BlockSize);
-  } while (RemainingBytes);
-
-  return Status;
-}
-
 STATIC CONST NOR_FLASH_INSTANCE mNorFlashInstanceTemplate = {
   NOR_FLASH_SIGNATURE, // Signature
   NULL, // Handle ... NEED TO BE FILLED
@@ -1044,37 +895,11 @@ STATIC CONST NOR_FLASH_INSTANCE 
mNorFlashInstanceTemplate = {
   0, // DeviceBaseAddress ... NEED TO BE FILLED
   0, // RegionBaseAddress ... NEED TO BE FILLED
   0, // Size ... NEED TO BE FILLED
+  0, // BlockSize
+  0, // LastBlock
   0, // StartLba
   0, // OffsetLba
 
-  {
-    EFI_BLOCK_IO_PROTOCOL_REVISION2,  // Revision
-    NULL,                             // Media ... NEED TO BE FILLED
-    NorFlashBlockIoReset,             // Reset;
-    NorFlashBlockIoReadBlocks,        // ReadBlocks
-    NorFlashBlockIoWriteBlocks,       // WriteBlocks
-    NorFlashBlockIoFlushBlocks        // FlushBlocks
-  }, // BlockIoProtocol
-
-  {
-    0, // MediaId ... NEED TO BE FILLED
-    FALSE, // RemovableMedia
-    TRUE, // MediaPresent
-    FALSE, // LogicalPartition
-    FALSE, // ReadOnly
-    FALSE, // WriteCaching;
-    0, // BlockSize ... NEED TO BE FILLED
-    4, //  IoAlign
-    0, // LastBlock ... NEED TO BE FILLED
-    0, // LowestAlignedLba
-    1, // LogicalBlocksPerPhysicalBlock
-  }, //Media;
-
-  {
-    EFI_DISK_IO_PROTOCOL_REVISION, // Revision
-    NorFlashDiskIoReadDisk,        // ReadDisk
-    NorFlashDiskIoWriteDisk        // WriteDisk
-  },
   {
     FvbGetAttributes, // GetAttributes
     FvbSetAttributes, // SetAttributes
@@ -1143,12 +968,10 @@ NorFlashCreateInstance (
   Instance->HostRegisterBaseAddress = HostRegisterBase;
   Instance->DeviceBaseAddress       = NorFlashDeviceBase;
   Instance->RegionBaseAddress       = NorFlashRegionBase;
-  Instance->Size = NorFlashSize;
+  Instance->Size                    = NorFlashSize;
+  Instance->BlockSize               = BlockSize;
+  Instance->LastBlock               = (NorFlashSize / BlockSize) - 1;
 
-  Instance->BlockIoProtocol.Media = &Instance->Media;
-  Instance->Media.MediaId = Index;
-  Instance->Media.BlockSize = BlockSize;
-  Instance->Media.LastBlock = (NorFlashSize / BlockSize) - 1;
   Instance->OffsetLba = (NorFlashRegionBase - NorFlashDeviceBase) / BlockSize;
 
   CopyGuid (&Instance->DevicePath.Vendor.Guid, &gEfiCallerIdGuid);
@@ -1263,16 +1086,6 @@ NorFlashVirtualNotifyEvent (
     EfiConvertPointer (0x0,
       (VOID**)&mNorFlashInstances[Index]->RegionBaseAddress);
 
-    // Convert BlockIo protocol
-    EfiConvertPointer (0x0,
-      (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.FlushBlocks);
-    EfiConvertPointer (0x0,
-      (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.ReadBlocks);
-    EfiConvertPointer (0x0,
-      (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.Reset);
-    EfiConvertPointer (0x0,
-      (VOID**)&mNorFlashInstances[Index]->BlockIoProtocol.WriteBlocks);
-
     // Convert Fvb
     EfiConvertPointer (0x0,
       (VOID**)&mNorFlashInstances[Index]->FvbProtocol.EraseBlocks);
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h
index ef1257a64904..20e74b0320ce 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashDxe.h
@@ -102,13 +102,11 @@ struct _NOR_FLASH_INSTANCE {
   UINTN                               DeviceBaseAddress;
   UINTN                               RegionBaseAddress;
   UINTN                               Size;
+  UINTN                               BlockSize;
+  UINTN                               LastBlock;
   EFI_LBA                             StartLba;
   EFI_LBA                             OffsetLba;
 
-  EFI_BLOCK_IO_PROTOCOL               BlockIoProtocol;
-  EFI_BLOCK_IO_MEDIA                  Media;
-  EFI_DISK_IO_PROTOCOL                DiskIoProtocol;
-
   EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL FvbProtocol;
   VOID*                               ShadowBuffer;
 
@@ -137,51 +135,6 @@ NorFlashWriteBuffer (
   IN UINT32                 *Buffer
   );
 
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.Reset
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoReset (
-  IN EFI_BLOCK_IO_PROTOCOL    *This,
-  IN BOOLEAN                  ExtendedVerification
-  );
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.ReadBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoReadBlocks (
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,
-  IN  UINT32                  MediaId,
-  IN  EFI_LBA                 Lba,
-  IN  UINTN                   BufferSizeInBytes,
-  OUT VOID                    *Buffer
-);
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.WriteBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoWriteBlocks (
-  IN  EFI_BLOCK_IO_PROTOCOL   *This,
-  IN  UINT32                  MediaId,
-  IN  EFI_LBA                 Lba,
-  IN  UINTN                   BufferSizeInBytes,
-  IN  VOID                    *Buffer
-);
-
-//
-// BlockIO Protocol function EFI_BLOCK_IO_PROTOCOL.FlushBlocks
-//
-EFI_STATUS
-EFIAPI
-NorFlashBlockIoFlushBlocks (
-  IN EFI_BLOCK_IO_PROTOCOL    *This
-);
-
 //
 // NorFlashFvbDxe.c
 //
diff --git a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c 
b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c
index ca3b1b5c34f8..776ec8a5437c 100644
--- a/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c
+++ b/Silicon/Socionext/SynQuacer/Drivers/Fip006Dxe/NorFlashFvbDxe.c
@@ -91,8 +91,8 @@ InitializeFvAndVariableStoreHeaders (
   FirmwareVolumeHeader->HeaderLength = sizeof(EFI_FIRMWARE_VOLUME_HEADER) +
                                        sizeof(EFI_FV_BLOCK_MAP_ENTRY);
   FirmwareVolumeHeader->Revision = EFI_FVH_REVISION;
-  FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->Media.LastBlock + 1;
-  FirmwareVolumeHeader->BlockMap[0].Length      = Instance->Media.BlockSize;
+  FirmwareVolumeHeader->BlockMap[0].NumBlocks = Instance->LastBlock + 1;
+  FirmwareVolumeHeader->BlockMap[0].Length      = Instance->BlockSize;
   FirmwareVolumeHeader->BlockMap[1].NumBlocks = 0;
   FirmwareVolumeHeader->BlockMap[1].Length      = 0;
   FirmwareVolumeHeader->Checksum = CalculateCheckSum16 (
@@ -223,14 +223,10 @@ FvbGetAttributes(
   Instance = INSTANCE_FROM_FVB_THIS(This);
 
   FlashFvbAttributes = EFI_FVB2_READ_ENABLED_CAP | EFI_FVB2_READ_STATUS |
+                       EFI_FVB2_WRITE_ENABLED_CAP | EFI_FVB2_WRITE_STATUS |
                        EFI_FVB2_STICKY_WRITE | EFI_FVB2_MEMORY_MAPPED |
                        EFI_FVB2_ERASE_POLARITY;
 
-  // Check if it is write protected
-  if (!Instance->Media.ReadOnly) {
-    FlashFvbAttributes |= EFI_FVB2_WRITE_STATUS | EFI_FVB2_WRITE_ENABLED_CAP;
-  }
-
   *Attributes = FlashFvbAttributes;
 
   DEBUG ((DEBUG_BLKIO, "FvbGetAttributes(0x%X)\n", *Attributes));
@@ -349,17 +345,17 @@ FvbGetBlockSize (
 
   DEBUG ((DEBUG_BLKIO,
     "FvbGetBlockSize(Lba=%ld, BlockSize=0x%x, LastBlock=%ld)\n", Lba,
-    Instance->Media.BlockSize, Instance->Media.LastBlock));
+    Instance->BlockSize, Instance->LastBlock));
 
-  if (Lba > Instance->Media.LastBlock) {
+  if (Lba > Instance->LastBlock) {
     DEBUG ((DEBUG_ERROR,
       "FvbGetBlockSize: ERROR - Parameter LBA %ld is beyond the last Lba 
(%ld).\n",
-      Lba, Instance->Media.LastBlock));
+      Lba, Instance->LastBlock));
     Status = EFI_INVALID_PARAMETER;
   } else {
     // This is easy because in this platform each NorFlash device has equal 
sized blocks.
-    *BlockSize = (UINTN) Instance->Media.BlockSize;
-    *NumberOfBlocks = (UINTN) (Instance->Media.LastBlock - Lba + 1);
+    *BlockSize = (UINTN) Instance->BlockSize;
+    *NumberOfBlocks = (UINTN) (Instance->LastBlock - Lba + 1);
 
     DEBUG ((DEBUG_BLKIO,
       "FvbGetBlockSize: *BlockSize=0x%x, *NumberOfBlocks=0x%x.\n", *BlockSize,
@@ -442,7 +438,7 @@ FvbRead (
   TempStatus = EFI_SUCCESS;
 
   // Cache the block size to avoid de-referencing pointers all the time
-  BlockSize = Instance->Media.BlockSize;
+  BlockSize = Instance->BlockSize;
 
   DEBUG ((DEBUG_BLKIO,
     "FvbRead: Check if (Offset=0x%x + NumBytes=0x%x) <= BlockSize=0x%x\n",
@@ -626,14 +622,6 @@ FvbEraseBlocks (
 
   Status = EFI_SUCCESS;
 
-  // Detect WriteDisabled state
-  if (Instance->Media.ReadOnly) {
-    // Firmware volume is in WriteDisabled state
-    DEBUG ((DEBUG_ERROR,
-      "FvbEraseBlocks: ERROR - Device is in WriteDisabled state.\n"));
-    return EFI_ACCESS_DENIED;
-  }
-
   // Before erasing, check the entire list of parameters to ensure
   // all specified blocks are valid
 
@@ -654,10 +642,10 @@ FvbEraseBlocks (
     // All blocks must be within range
     DEBUG ((DEBUG_BLKIO,
       "FvbEraseBlocks: Check if: ( StartingLba=%ld + NumOfLba=%d - 1 ) > 
LastBlock=%ld.\n",
-      Instance->StartLba + StartingLba, NumOfLba, Instance->Media.LastBlock));
+      Instance->StartLba + StartingLba, NumOfLba, Instance->LastBlock));
     if (NumOfLba == 0 ||
         (Instance->StartLba + StartingLba + NumOfLba - 1) >
-        Instance->Media.LastBlock) {
+        Instance->LastBlock) {
       VA_END (Args);
       DEBUG ((DEBUG_ERROR,
         "FvbEraseBlocks: ERROR - Lba range goes past the last Lba.\n"));
@@ -690,7 +678,7 @@ FvbEraseBlocks (
       // Get the physical address of Lba to erase
       BlockAddress = GET_NOR_BLOCK_ADDRESS (Instance->RegionBaseAddress,
                        Instance->StartLba + StartingLba,
-                       Instance->Media.BlockSize);
+                       Instance->BlockSize);
 
       // Erase it
       DEBUG ((DEBUG_BLKIO, "FvbEraseBlocks: Erasing Lba=%ld @ 0x%08x.\n",
@@ -747,7 +735,7 @@ NorFlashFvbInitialize (
 
   DEBUG ((DEBUG_BLKIO,"NorFlashFvbInitialize\n"));
 
-  BlockSize = Instance->Media.BlockSize;
+  BlockSize = Instance->BlockSize;
 
   // FirmwareVolumeHeader->FvLength is declared to have the Variable area
   // AND the FTW working area AND the FTW Spare contiguous.
@@ -798,7 +786,7 @@ NorFlashFvbInitialize (
     FvbNumLba = (PcdGet32(PcdFlashNvStorageVariableSize) +
                  PcdGet32(PcdFlashNvStorageFtwWorkingSize) +
                  PcdGet32(PcdFlashNvStorageFtwSpareSize)) /
-                Instance->Media.BlockSize;
+                Instance->BlockSize;
 
     Status = FvbEraseBlocks (&Instance->FvbProtocol, (EFI_LBA)0, FvbNumLba,
                EFI_LBA_LIST_TERMINATOR);
-- 
2.17.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to