MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services
The commit places the check for MediaId at the beginning of Block IO
services:
RamDiskBlkIoReadBlocks and
RamDiskBlkIoWriteBlocks
This aligns with the Block IO protocol implementations for other
devices.
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 0feca62c7a
)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Produce EFI_BLOCK_IO_PROTOCOL on a RAM disk device.
|
Produce EFI_BLOCK_IO_PROTOCOL on a RAM disk device.
|
||||||
|
|
||||||
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@@ -137,6 +137,12 @@ RamDiskBlkIoReadBlocks (
|
|||||||
RAM_DISK_PRIVATE_DATA *PrivateData;
|
RAM_DISK_PRIVATE_DATA *PrivateData;
|
||||||
UINTN NumberOfBlocks;
|
UINTN NumberOfBlocks;
|
||||||
|
|
||||||
|
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
|
||||||
|
|
||||||
|
if (MediaId != PrivateData->Media.MediaId) {
|
||||||
|
return EFI_MEDIA_CHANGED;
|
||||||
|
}
|
||||||
|
|
||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
@@ -145,12 +151,6 @@ RamDiskBlkIoReadBlocks (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
|
|
||||||
|
|
||||||
if (MediaId != PrivateData->Media.MediaId) {
|
|
||||||
return EFI_MEDIA_CHANGED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((BufferSize % PrivateData->Media.BlockSize) != 0) {
|
if ((BufferSize % PrivateData->Media.BlockSize) != 0) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
@@ -212,14 +212,6 @@ RamDiskBlkIoWriteBlocks (
|
|||||||
RAM_DISK_PRIVATE_DATA *PrivateData;
|
RAM_DISK_PRIVATE_DATA *PrivateData;
|
||||||
UINTN NumberOfBlocks;
|
UINTN NumberOfBlocks;
|
||||||
|
|
||||||
if (Buffer == NULL) {
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BufferSize == 0) {
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
|
PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This);
|
||||||
|
|
||||||
if (MediaId != PrivateData->Media.MediaId) {
|
if (MediaId != PrivateData->Media.MediaId) {
|
||||||
@@ -230,6 +222,14 @@ RamDiskBlkIoWriteBlocks (
|
|||||||
return EFI_WRITE_PROTECTED;
|
return EFI_WRITE_PROTECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Buffer == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BufferSize == 0) {
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if ((BufferSize % PrivateData->Media.BlockSize) != 0) {
|
if ((BufferSize % PrivateData->Media.BlockSize) != 0) {
|
||||||
return EFI_BAD_BUFFER_SIZE;
|
return EFI_BAD_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user