Some codes have been altered and replaced by functions of memory allocation library.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7072 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jji4 2008-12-18 05:28:26 +00:00
parent d0cca731c3
commit 9b38ff3499
2 changed files with 23 additions and 39 deletions

View File

@ -433,7 +433,7 @@ SCSIBusDriverBindingStart (
ErrorExit: ErrorExit:
if (ScsiBusDev != NULL) { if (ScsiBusDev != NULL) {
gBS->FreePool (ScsiBusDev); FreePool (ScsiBusDev);
} }
if (ExtScsiSupport) { if (ExtScsiSupport) {
@ -854,13 +854,9 @@ ScsiExecuteSCSICommand (
); );
} else { } else {
Status = gBS->AllocatePool ( mWorkingBuffer = AllocatePool (sizeof(EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET));
EfiBootServicesData,
sizeof(EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET),
(VOID**)&mWorkingBuffer
);
if (EFI_ERROR (Status)) { if (mWorkingBuffer == NULL) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
@ -900,7 +896,7 @@ ScsiExecuteSCSICommand (
); );
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
gBS->FreePool(mWorkingBuffer); FreePool(mWorkingBuffer);
gBS->CloseEvent(PacketEvent); gBS->CloseEvent(PacketEvent);
return Status; return Status;
} }
@ -1047,7 +1043,7 @@ ScsiScanCreateDevice (
NULL NULL
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (ScsiIoDevice); FreePool (ScsiIoDevice);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} else { } else {
if (ScsiBusDev->ExtScsiSupport) { if (ScsiBusDev->ExtScsiSupport) {

View File

@ -25,6 +25,7 @@ EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding = {
NULL NULL
}; };
/** /**
The user Entry Point for module ScsiDisk. The user Entry Point for module ScsiDisk.
@ -160,17 +161,11 @@ ScsiDiskDriverBindingStart (
UINT8 MaxRetry; UINT8 MaxRetry;
BOOLEAN NeedRetry; BOOLEAN NeedRetry;
Status = gBS->AllocatePool ( ScsiDiskDevice = (SCSI_DISK_DEV *) AllocateZeroPool (sizeof (SCSI_DISK_DEV));
EfiBootServicesData, if (ScsiDiskDevice == NULL) {
sizeof (SCSI_DISK_DEV), return EFI_OUT_OF_RESOURCES;
(VOID **) &ScsiDiskDevice
);
if (EFI_ERROR (Status)) {
return Status;
} }
ZeroMem (ScsiDiskDevice, sizeof (SCSI_DISK_DEV));
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
Controller, Controller,
&gEfiScsiIoProtocolGuid, &gEfiScsiIoProtocolGuid,
@ -180,7 +175,7 @@ ScsiDiskDriverBindingStart (
EFI_OPEN_PROTOCOL_BY_DRIVER EFI_OPEN_PROTOCOL_BY_DRIVER
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (ScsiDiskDevice); FreePool (ScsiDiskDevice);
return Status; return Status;
} }
@ -207,27 +202,20 @@ ScsiDiskDriverBindingStart (
// The Sense Data Array's initial size is 6 // The Sense Data Array's initial size is 6
// //
ScsiDiskDevice->SenseDataNumber = 6; ScsiDiskDevice->SenseDataNumber = 6;
Status = gBS->AllocatePool ( ScsiDiskDevice->SenseData = (EFI_SCSI_SENSE_DATA *) AllocateZeroPool (
EfiBootServicesData, sizeof (EFI_SCSI_SENSE_DATA) * ScsiDiskDevice->SenseDataNumber
sizeof (EFI_SCSI_SENSE_DATA) * ScsiDiskDevice->SenseDataNumber,
(VOID **) &(ScsiDiskDevice->SenseData)
); );
if (EFI_ERROR (Status)) { if (ScsiDiskDevice->SenseData == NULL) {
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
&gEfiScsiIoProtocolGuid, &gEfiScsiIoProtocolGuid,
This->DriverBindingHandle, This->DriverBindingHandle,
Controller Controller
); );
gBS->FreePool (ScsiDiskDevice); FreePool (ScsiDiskDevice);
return Status; return EFI_OUT_OF_RESOURCES;
} }
ZeroMem (
ScsiDiskDevice->SenseData,
sizeof (EFI_SCSI_SENSE_DATA) * ScsiDiskDevice->SenseDataNumber
);
// //
// Retrieve device information // Retrieve device information
// //
@ -239,14 +227,14 @@ ScsiDiskDriverBindingStart (
} }
if (!NeedRetry) { if (!NeedRetry) {
gBS->FreePool (ScsiDiskDevice->SenseData); FreePool (ScsiDiskDevice->SenseData);
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
&gEfiScsiIoProtocolGuid, &gEfiScsiIoProtocolGuid,
This->DriverBindingHandle, This->DriverBindingHandle,
Controller Controller
); );
gBS->FreePool (ScsiDiskDevice); FreePool (ScsiDiskDevice);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
} }
@ -265,14 +253,14 @@ ScsiDiskDriverBindingStart (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (ScsiDiskDevice->SenseData); FreePool (ScsiDiskDevice->SenseData);
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
&gEfiScsiIoProtocolGuid, &gEfiScsiIoProtocolGuid,
This->DriverBindingHandle, This->DriverBindingHandle,
Controller Controller
); );
gBS->FreePool (ScsiDiskDevice); FreePool (ScsiDiskDevice);
return Status; return Status;
} }
@ -2187,7 +2175,7 @@ ReleaseScsiDiskDeviceResources (
} }
if (ScsiDiskDevice->SenseData != NULL) { if (ScsiDiskDevice->SenseData != NULL) {
gBS->FreePool (ScsiDiskDevice->SenseData); FreePool (ScsiDiskDevice->SenseData);
ScsiDiskDevice->SenseData = NULL; ScsiDiskDevice->SenseData = NULL;
} }
@ -2196,7 +2184,7 @@ ReleaseScsiDiskDeviceResources (
ScsiDiskDevice->ControllerNameTable = NULL; ScsiDiskDevice->ControllerNameTable = NULL;
} }
gBS->FreePool (ScsiDiskDevice); FreePool (ScsiDiskDevice);
ScsiDiskDevice = NULL; ScsiDiskDevice = NULL;
} }