2009-07-01 07:48:44 +02:00
|
|
|
/** @file
|
|
|
|
ISA Floppy Disk UEFI Driver conforming to the UEFI driver model
|
|
|
|
|
2007-07-10 11:04:15 +02:00
|
|
|
1. Support two types diskette drive
|
|
|
|
1.44M drive and 2.88M drive (and now only support 1.44M)
|
2009-07-01 07:48:44 +02:00
|
|
|
2. Support two diskette drives per floppy disk controller
|
2007-07-10 11:04:15 +02:00
|
|
|
3. Use DMA channel 2 to transfer data
|
|
|
|
4. Do not use interrupt
|
|
|
|
5. Support diskette change line signal and write protect
|
|
|
|
|
2010-04-23 18:28:26 +02:00
|
|
|
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials
|
2007-07-20 11:34:04 +02:00
|
|
|
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
|
2007-07-10 11:04:15 +02:00
|
|
|
|
2007-07-20 11:34:04 +02:00
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-10 11:04:15 +02:00
|
|
|
|
2007-07-20 11:34:04 +02:00
|
|
|
**/
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
#include "IsaFloppy.h"
|
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
LIST_ENTRY mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// ISA Floppy Driver Binding Protocol
|
|
|
|
//
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {
|
|
|
|
FdcControllerDriverSupported,
|
|
|
|
FdcControllerDriverStart,
|
|
|
|
FdcControllerDriverStop,
|
|
|
|
0xa,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2007-07-10 11:24:34 +02:00
|
|
|
|
|
|
|
/**
|
2009-07-01 07:48:44 +02:00
|
|
|
The main Entry Point for this driver.
|
2007-07-10 11:24:34 +02:00
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
|
|
|
@param[in] SystemTable A pointer to the EFI System Table.
|
2007-07-10 11:24:34 +02:00
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
@retval EFI_SUCCESS The entry point is executed successfully.
|
|
|
|
@retval other Some error occurs when executing this entry point.
|
2007-07-10 11:24:34 +02:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializeIsaFloppy(
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2009-07-01 07:48:44 +02:00
|
|
|
EFI_STATUS Status;
|
2007-07-10 11:24:34 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Install driver model protocol(s).
|
|
|
|
//
|
2007-09-30 04:30:46 +02:00
|
|
|
Status = EfiLibInstallDriverBindingComponentName2 (
|
2007-07-10 11:24:34 +02:00
|
|
|
ImageHandle,
|
|
|
|
SystemTable,
|
|
|
|
&gFdcControllerDriver,
|
|
|
|
ImageHandle,
|
|
|
|
&gIsaFloppyComponentName,
|
2007-09-30 04:30:46 +02:00
|
|
|
&gIsaFloppyComponentName2
|
2007-07-10 11:24:34 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-04-14 05:12:57 +02:00
|
|
|
/**
|
2009-07-01 07:48:44 +02:00
|
|
|
Test if the controller is a floppy disk drive device
|
2008-04-14 05:12:57 +02:00
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
|
|
|
@param[in] Controller The handle of the controller to test.
|
|
|
|
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
|
2008-04-14 05:12:57 +02:00
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
@retval EFI_SUCCESS The device is supported by this driver.
|
|
|
|
@retval EFI_ALREADY_STARTED The device is already being managed by this driver.
|
|
|
|
@retval EFI_ACCESS_DENIED The device is already being managed by a different driver
|
|
|
|
or an application that requires exclusive access.
|
|
|
|
@retval EFI_UNSUPPORTED The device is is not supported by this driver.
|
2008-04-14 05:12:57 +02:00
|
|
|
**/
|
2007-07-10 11:04:15 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FdcControllerDriverSupported (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
)
|
|
|
|
{
|
2009-07-01 07:48:44 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_ISA_IO_PROTOCOL *IsaIo;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Ignore the parameter RemainingDevicePath because this is a device driver.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Open the device path protocol
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &ParentDevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Open the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
(VOID **) &IsaIo,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Use the ISA I/O Protocol to see if Controller is a floppy disk drive device
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
|
|
|
|
Status = EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Close the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-04-14 05:12:57 +02:00
|
|
|
/**
|
2009-07-01 07:48:44 +02:00
|
|
|
Start this driver on Controller.
|
|
|
|
|
|
|
|
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
|
|
|
@param[in] ControllerHandle The handle of the controller to start. This handle
|
|
|
|
must support a protocol interface that supplies
|
|
|
|
an I/O abstraction to the driver.
|
|
|
|
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
|
|
|
|
This parameter is ignored by device drivers, and is optional for bus drivers.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The device was started.
|
|
|
|
@retval EFI_DEVICE_ERROR The device could not be started due to a device error.
|
|
|
|
Currently not implemented.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
|
|
|
@retval Others The driver failded to start the device.
|
2008-04-14 05:12:57 +02:00
|
|
|
**/
|
2007-07-10 11:04:15 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FdcControllerDriverStart (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
|
|
|
)
|
|
|
|
{
|
2009-07-01 07:48:44 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
FDC_BLK_IO_DEV *FdcDev;
|
|
|
|
EFI_ISA_IO_PROTOCOL *IsaIo;
|
|
|
|
UINTN Index;
|
|
|
|
LIST_ENTRY *List;
|
|
|
|
BOOLEAN Found;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
FdcDev = NULL;
|
|
|
|
IsaIo = NULL;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Open the device path protocol
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
(VOID **) &ParentDevicePath,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Report enable progress code
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,
|
|
|
|
ParentDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Open the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
(VOID **) &IsaIo,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller,
|
|
|
|
EFI_OPEN_PROTOCOL_BY_DRIVER
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Allocate the floppy device's Device structure
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));
|
|
|
|
if (FdcDev == NULL) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Initialize the floppy device's device structure
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
FdcDev->Signature = FDC_BLK_IO_DEV_SIGNATURE;
|
|
|
|
FdcDev->Handle = Controller;
|
|
|
|
FdcDev->IsaIo = IsaIo;
|
|
|
|
FdcDev->Disk = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;
|
|
|
|
FdcDev->Cache = NULL;
|
|
|
|
FdcDev->Event = NULL;
|
|
|
|
FdcDev->ControllerState = NULL;
|
|
|
|
FdcDev->DevicePath = ParentDevicePath;
|
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
FdcDev->ControllerNameTable = NULL;
|
|
|
|
AddName (FdcDev);
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Look up the base address of the Floppy Disk Controller which controls this floppy device
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
|
|
|
|
if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {
|
|
|
|
FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Maintain the list of floppy disk controllers
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
Found = FALSE;
|
2009-07-01 07:48:44 +02:00
|
|
|
List = mControllerHead.ForwardLink;
|
|
|
|
while (List != &mControllerHead) {
|
2007-07-10 11:04:15 +02:00
|
|
|
FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);
|
|
|
|
if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {
|
|
|
|
Found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
List = List->ForwardLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Found) {
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// A new floppy disk controller controlling this floppy disk drive is found
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));
|
|
|
|
if (FdcDev->ControllerState == NULL) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
FdcDev->ControllerState->Signature = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;
|
|
|
|
FdcDev->ControllerState->FddResetPerformed = FALSE;
|
|
|
|
FdcDev->ControllerState->NeedRecalibrate = FALSE;
|
|
|
|
FdcDev->ControllerState->BaseAddress = FdcDev->BaseAddress;
|
|
|
|
FdcDev->ControllerState->NumberOfDrive = 0;
|
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);
|
2007-07-10 11:04:15 +02:00
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Create a timer event for each floppy disk drive device.
|
2007-07-10 11:04:15 +02:00
|
|
|
// This timer event is used to control the motor on and off
|
|
|
|
//
|
|
|
|
Status = gBS->CreateEvent (
|
|
|
|
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
|
|
|
TPL_NOTIFY,
|
|
|
|
FddTimerProc,
|
|
|
|
FdcDev,
|
|
|
|
&FdcDev->Event
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Reset the Floppy Disk Controller
|
|
|
|
//
|
|
|
|
if (!FdcDev->ControllerState->FddResetPerformed) {
|
|
|
|
FdcDev->ControllerState->FddResetPerformed = TRUE;
|
|
|
|
FdcDev->ControllerState->FddResetStatus = FddReset (FdcDev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {
|
|
|
|
Status = EFI_DEVICE_ERROR;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,
|
|
|
|
ParentDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Discover the Floppy Drive
|
|
|
|
//
|
|
|
|
Status = DiscoverFddDevice (FdcDev);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
Status = EFI_DEVICE_ERROR;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Install protocol interfaces for the serial device.
|
|
|
|
//
|
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
|
|
&Controller,
|
|
|
|
&gEfiBlockIoProtocolGuid,
|
|
|
|
&FdcDev->BlkIo,
|
|
|
|
NULL
|
|
|
|
);
|
2009-07-01 07:48:44 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
FdcDev->ControllerState->NumberOfDrive++;
|
|
|
|
}
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
Done:
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
|
|
|
|
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
|
|
|
EFI_ERROR_CODE | EFI_ERROR_MINOR,
|
|
|
|
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,
|
|
|
|
ParentDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// If a floppy drive device structure was allocated, then free it
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
if (FdcDev != NULL) {
|
|
|
|
if (FdcDev->Event != NULL) {
|
|
|
|
//
|
|
|
|
// Close the event for turning the motor off
|
|
|
|
//
|
|
|
|
gBS->CloseEvent (FdcDev->Event);
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
|
|
|
FreePool (FdcDev);
|
|
|
|
}
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Close the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
if (IsaIo != NULL) {
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
|
|
|
}
|
2009-07-01 07:48:44 +02:00
|
|
|
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Close the device path protocol
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
2007-07-10 11:04:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-04-14 05:12:57 +02:00
|
|
|
/**
|
2009-07-01 07:48:44 +02:00
|
|
|
Stop this driver on ControllerHandle.
|
|
|
|
|
|
|
|
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
|
|
|
@param[in] ControllerHandle A handle to the device being stopped. The handle must
|
|
|
|
support a bus specific I/O protocol for the driver
|
|
|
|
to use to stop the device.
|
|
|
|
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
|
|
|
|
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
|
|
|
|
if NumberOfChildren is 0.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The device was stopped.
|
|
|
|
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
2008-04-14 05:12:57 +02:00
|
|
|
**/
|
2007-07-10 11:04:15 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FdcControllerDriverStop (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE Controller,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
|
|
|
FDC_BLK_IO_DEV *FdcDev;
|
|
|
|
|
2009-07-01 07:48:44 +02:00
|
|
|
//
|
|
|
|
// Ignore NumberOfChildren since this is a device driver
|
|
|
|
//
|
|
|
|
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
// Get the Block I/O Protocol on Controller
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiBlockIoProtocolGuid,
|
|
|
|
(VOID **) &BlkIo,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Get the floppy drive device's Device structure
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Report disable progress code
|
|
|
|
//
|
|
|
|
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
|
|
|
EFI_PROGRESS_CODE,
|
|
|
|
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,
|
|
|
|
FdcDev->DevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Uninstall the Block I/O Protocol
|
|
|
|
//
|
|
|
|
Status = gBS->UninstallProtocolInterface (
|
|
|
|
Controller,
|
|
|
|
&gEfiBlockIoProtocolGuid,
|
|
|
|
&FdcDev->BlkIo
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2009-07-01 07:48:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Close the event for turning the motor off
|
|
|
|
//
|
|
|
|
gBS->CloseEvent (FdcDev->Event);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Turn the motor off on the floppy drive device
|
|
|
|
//
|
|
|
|
FddTimerProc (FdcDev->Event, FdcDev);
|
|
|
|
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
// Close the device path protocol
|
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Close the ISA I/O Protocol
|
|
|
|
//
|
|
|
|
gBS->CloseProtocol (
|
|
|
|
Controller,
|
|
|
|
&gEfiIsaIoProtocolGuid,
|
|
|
|
This->DriverBindingHandle,
|
|
|
|
Controller
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the controller list if needed
|
|
|
|
//
|
|
|
|
FdcDev->ControllerState->NumberOfDrive--;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Free the cache if one was allocated
|
|
|
|
//
|
|
|
|
FdcFreeCache (FdcDev);
|
|
|
|
|
|
|
|
//
|
2009-07-01 07:48:44 +02:00
|
|
|
// Free the floppy drive device's device structure
|
2007-07-10 11:04:15 +02:00
|
|
|
//
|
|
|
|
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
2009-07-01 07:48:44 +02:00
|
|
|
FreePool (FdcDev);
|
2007-07-10 11:04:15 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-04-14 05:12:57 +02:00
|
|
|
|