From 791441683613ee25d5ef9cdbdce60bfa00be41b8 Mon Sep 17 00:00:00 2001
From: Olivier Martin <olivier.martin@arm.com>
Date: Mon, 10 Feb 2014 15:14:33 +0000
Subject: [PATCH] MdeModulePkg/DiskIo: Introduced 'PcdDiskIoDataBufferBlockNum'

PcdDiskIoDataBufferBlockNum replaced the hardcoded value into
the Disk I/O driver.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
---
 MdeModulePkg/MdeModulePkg.dec                       | 5 +++++
 MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h      | 6 +++---
 MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf | 4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index a557466..4f8a8fe 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -602,6 +602,11 @@
   ## Progress Code for S3 Suspend end.
   #  PROGRESS_CODE_S3_SUSPEND_END   = (EFI_SOFTWARE_SMM_DRIVER | (EFI_OEM_SPECIFIC | 0x00000001))    = 0x03078001
   gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd|0x03078001|UINT32|0x30001033
+  
+  ## Disk I/O - Number of Data Buffer block
+  # Define the size in block of the pre-allocated buffer. It provide better
+  # performance for large Disk I/O requests
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDiskIoDataBufferBlockNum|64|UINT32|0x30001039
 
 [PcdsFixedAtBuild,PcdsPatchableInModule]
   ## VPD type PCD allow developer point an absoluted physical address PcdVpdBaseAddress
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
index a08d4df..864bf02 100644
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
+++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.h
@@ -31,11 +31,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>
 
 //
-// Pre-allocate an aligned buffer of 64 blocks so very large Disk I/O requests
-// will be broken up into 64 * BlockSize chunks to provide better performance
+// Pre-allocate an aligned buffer of N blocks so very large Disk I/O requests
+// will be broken up into N * BlockSize chunks to provide better performance
 // than allocating an aligned 1 block buffer.
 //
-#define DATA_BUFFER_BLOCK_NUM             64
+#define DATA_BUFFER_BLOCK_NUM             FixedPcdGet32 (PcdDiskIoDataBufferBlockNum)
 
 #define DISK_IO_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('d', 's', 'k', 'I')
 typedef struct {
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
index 8cf2595..b5f4c49 100644
--- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
+++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
@@ -45,7 +45,7 @@
 
 [Packages]
   MdePkg/MdePkg.dec
-
+  MdeModulePkg/MdeModulePkg.dec
 
 [LibraryClasses]
   UefiBootServicesTableLib
@@ -63,3 +63,5 @@
   gEfiBlockIoProtocolGuid                       ## TO_START
   gEfiBlockIo2ProtocolGuid                      ## TO_START
 
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdDiskIoDataBufferBlockNum
-- 
1.8.5

