synchronous requests and EFI_BLOCK_IO_PROTOCOL for now.\r
\r
Copyright (C) 2012, Red Hat, Inc.\r
+ Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials are licensed and made available\r
under the terms and conditions of the BSD License which accompanies this\r
(BufferSize == 0 ? VIRTIO_BLK_T_FLUSH : VIRTIO_BLK_T_OUT) :\r
VIRTIO_BLK_T_IN;\r
Request.IoPrio = 0;\r
- Request.Sector = Lba * (BlockSize / 512);\r
+ Request.Sector = MultU64x32(Lba, BlockSize / 512);\r
\r
VirtioPrepare (&Dev->Ring, &Indices);\r
\r
goto Failed;\r
}\r
if (BlockSize == 0 || BlockSize % 512 != 0 ||\r
- NumSectors % (BlockSize / 512) != 0) {\r
+ ModU64x32 (NumSectors, BlockSize / 512) != 0) {\r
//\r
// We can only handle a logical block consisting of whole sectors,\r
// and only a disk composed of whole logical blocks.\r
Dev->BlockIoMedia.WriteCaching = !!(Features & VIRTIO_BLK_F_FLUSH);\r
Dev->BlockIoMedia.BlockSize = BlockSize;\r
Dev->BlockIoMedia.IoAlign = 0;\r
- Dev->BlockIoMedia.LastBlock = NumSectors / (BlockSize / 512) - 1;\r
+ Dev->BlockIoMedia.LastBlock = DivU64x32 (NumSectors,\r
+ BlockSize / 512) - 1;\r
return EFI_SUCCESS;\r
\r
ReleaseQueue:\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
{\r
- VBLK_DEV *Dev;\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
+ VBLK_DEV *Dev;\r
\r
- Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);\r
+ Status = gBS->OpenProtocol (\r
+ DeviceHandle, // candidate device\r
+ &gEfiBlockIoProtocolGuid, // retrieve the BlockIo iface\r
+ (VOID **)&BlockIo, // target pointer\r
+ This->DriverBindingHandle, // requestor driver identity\r
+ DeviceHandle, // requesting lookup for dev.\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (BlockIo);\r
\r
//\r
- // If DriverBindingStop() is called with the driver instance still in use,\r
- // or any of the parameters are invalid, we've caught a bug.\r
+ // Handle Stop() requests for in-use driver instances gracefully.\r
//\r
Status = gBS->UninstallProtocolInterface (DeviceHandle,\r
&gEfiBlockIoProtocolGuid, &Dev->BlockIo);\r
- ASSERT (Status == EFI_SUCCESS);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
VirtioBlkUninit (Dev);\r
\r
// for unambiguous identification.\r
//\r
\r
-STATIC GLOBAL_REMOVE_IF_UNREFERENCED\r
+STATIC\r
EFI_UNICODE_STRING_TABLE mDriverNameTable[] = {\r
{ "eng;en", L"Virtio Block Driver" },\r
{ NULL, NULL }\r
};\r
\r
-STATIC GLOBAL_REMOVE_IF_UNREFERENCED\r
+STATIC\r
EFI_COMPONENT_NAME_PROTOCOL gComponentName;\r
\r
EFI_STATUS\r
return EFI_UNSUPPORTED;\r
}\r
\r
-STATIC GLOBAL_REMOVE_IF_UNREFERENCED\r
+STATIC\r
EFI_COMPONENT_NAME_PROTOCOL gComponentName = {\r
&VirtioBlkGetDriverName,\r
&VirtioBlkGetDeviceName,\r
"eng" // SupportedLanguages, ISO 639-2 language codes\r
};\r
\r
-STATIC GLOBAL_REMOVE_IF_UNREFERENCED\r
+STATIC\r
EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {\r
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &VirtioBlkGetDriverName,\r
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &VirtioBlkGetDeviceName,\r