-/*++\r
+/** @file\r
+ ISA Floppy Disk UEFI Driver conforming to the UEFI driver model\r
\r
- Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
- IsaFloppy.c\r
-\r
-Abstract:\r
-\r
- ISA Floppy Driver\r
1. Support two types diskette drive \r
1.44M drive and 2.88M drive (and now only support 1.44M)\r
- 2. Support two diskette drives\r
+ 2. Support two diskette drives per floppy disk controller\r
3. Use DMA channel 2 to transfer data\r
4. Do not use interrupt\r
5. Support diskette change line signal and write protect\r
\r
- conforming to EFI driver model\r
+Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
\r
-Revision History:\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
---*/\r
+**/\r
\r
#include "IsaFloppy.h"\r
\r
-LIST_ENTRY gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);\r
+LIST_ENTRY mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);\r
\r
//\r
// ISA Floppy Driver Binding Protocol\r
\r
\r
/**\r
- The user Entry Point for module IsaFloppy. The user code starts with this function.\r
+ The main Entry Point for this driver.\r
\r
- @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
- @param[in] SystemTable A pointer to the EFI System Table.\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
\r
- @retval EFI_SUCCESS The entry point is executed successfully.\r
- @retval other Some error occurs when executing this entry point.\r
-\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
**/\r
EFI_STATUS\r
EFIAPI\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_STATUS Status;\r
+ EFI_STATUS Status;\r
\r
//\r
// Install driver model protocol(s).\r
//\r
- Status = EfiLibInstallAllDriverProtocols (\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
ImageHandle,\r
SystemTable,\r
&gFdcControllerDriver,\r
ImageHandle,\r
&gIsaFloppyComponentName,\r
- NULL,\r
- NULL\r
+ &gIsaFloppyComponentName2\r
);\r
ASSERT_EFI_ERROR (Status);\r
\r
-\r
return Status;\r
}\r
\r
-\r
+/**\r
+ Test if the controller is a floppy disk drive device\r
+ \r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. \r
+ @param[in] Controller The handle of the controller to test.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r
+ \r
+ @retval EFI_SUCCESS The device is supported by this driver.\r
+ @retval EFI_ALREADY_STARTED The device is already being managed by this driver.\r
+ @retval EFI_ACCESS_DENIED The device is already being managed by a different driver \r
+ or an application that requires exclusive access.\r
+ @retval EFI_UNSUPPORTED The device is is not supported by this driver.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FdcControllerDriverSupported (\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- ControllerDriver Protocol Method\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_ISA_IO_PROTOCOL *IsaIo;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
\r
-Arguments:\r
+ //\r
+ // Ignore the parameter RemainingDevicePath because this is a device driver.\r
+ //\r
\r
-Returns:\r
+ //\r
+ // Open the device path protocol\r
+ //\r
+ Status = gBS->OpenProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ (VOID **) &ParentDevicePath,\r
+ This->DriverBindingHandle,\r
+ Controller,\r
+ EFI_OPEN_PROTOCOL_BY_DRIVER\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: RemainingDevicePath - add argument and description to function comment\r
-{\r
- EFI_STATUS Status;\r
- EFI_ISA_IO_PROTOCOL *IsaIo;\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
\r
//\r
// Open the ISA I/O Protocol\r
return Status;\r
}\r
//\r
- // Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller\r
+ // Use the ISA I/O Protocol to see if Controller is a floppy disk drive device\r
//\r
Status = EFI_SUCCESS;\r
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {\r
return Status;\r
}\r
\r
+/**\r
+ Start this driver on Controller.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle The handle of the controller to start. This handle \r
+ must support a protocol interface that supplies \r
+ an I/O abstraction to the driver.\r
+ @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. \r
+ This parameter is ignored by device drivers, and is optional for bus drivers.\r
+\r
+ @retval EFI_SUCCESS The device was started.\r
+ @retval EFI_DEVICE_ERROR The device could not be started due to a device error.\r
+ Currently not implemented.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
+ @retval Others The driver failded to start the device.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FdcControllerDriverStart (\r
IN EFI_HANDLE Controller,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Arguments:\r
-\r
-Returns:\r
-\r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: RemainingDevicePath - add argument and description to function comment\r
{\r
- EFI_STATUS Status;\r
- FDC_BLK_IO_DEV *FdcDev;\r
- EFI_ISA_IO_PROTOCOL *IsaIo;\r
- UINTN Index;\r
- LIST_ENTRY *List;\r
- BOOLEAN Found;\r
- EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
+ EFI_STATUS Status;\r
+ FDC_BLK_IO_DEV *FdcDev;\r
+ EFI_ISA_IO_PROTOCOL *IsaIo;\r
+ UINTN Index;\r
+ LIST_ENTRY *List;\r
+ BOOLEAN Found;\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
\r
FdcDev = NULL;\r
IsaIo = NULL;\r
goto Done;\r
}\r
//\r
- // Allocate the Floppy Disk Controller's Device structure\r
+ // Allocate the floppy device's Device structure\r
//\r
FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));\r
if (FdcDev == NULL) {\r
goto Done;\r
}\r
//\r
- // Initialize the Floppy Disk Controller's Device structure\r
+ // Initialize the floppy device's device structure\r
//\r
FdcDev->Signature = FDC_BLK_IO_DEV_SIGNATURE;\r
FdcDev->Handle = Controller;\r
FdcDev->ControllerState = NULL;\r
FdcDev->DevicePath = ParentDevicePath;\r
\r
- ADD_FLOPPY_NAME (FdcDev);\r
+ FdcDev->ControllerNameTable = NULL;\r
+ AddName (FdcDev);\r
\r
//\r
- // Look up the base address of the Floppy Disk Controller\r
+ // Look up the base address of the Floppy Disk Controller which controls this floppy device\r
//\r
for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {\r
if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {\r
}\r
}\r
//\r
- // Maintain the list of controller list\r
+ // Maintain the list of floppy disk controllers\r
//\r
Found = FALSE;\r
- List = gControllerHead.ForwardLink;\r
- while (List != &gControllerHead) {\r
+ List = mControllerHead.ForwardLink;\r
+ while (List != &mControllerHead) {\r
FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);\r
if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {\r
Found = TRUE;\r
\r
if (!Found) {\r
//\r
- // The Controller is new\r
+ // A new floppy disk controller controlling this floppy disk drive is found\r
//\r
FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));\r
if (FdcDev->ControllerState == NULL) {\r
FdcDev->ControllerState->BaseAddress = FdcDev->BaseAddress;\r
FdcDev->ControllerState->NumberOfDrive = 0;\r
\r
- InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);\r
+ InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);\r
}\r
//\r
- // Create a timer event for each Floppd Disk Controller.\r
+ // Create a timer event for each floppy disk drive device.\r
// This timer event is used to control the motor on and off\r
//\r
Status = gBS->CreateEvent (\r
&FdcDev->BlkIo,\r
NULL\r
);\r
-\r
- FdcDev->ControllerState->NumberOfDrive++;\r
+ if (!EFI_ERROR (Status)) {\r
+ FdcDev->ControllerState->NumberOfDrive++;\r
+ }\r
\r
Done:\r
if (EFI_ERROR (Status)) {\r
);\r
\r
//\r
- // Close the device path protocol\r
+ // If a floppy drive device structure was allocated, then free it\r
//\r
- gBS->CloseProtocol (\r
- Controller,\r
- &gEfiDevicePathProtocolGuid,\r
- This->DriverBindingHandle,\r
- Controller\r
- );\r
+ if (FdcDev != NULL) {\r
+ if (FdcDev->Event != NULL) {\r
+ //\r
+ // Close the event for turning the motor off\r
+ //\r
+ gBS->CloseEvent (FdcDev->Event);\r
+ }\r
+\r
+ FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
+ FreePool (FdcDev);\r
+ }\r
\r
//\r
// Close the ISA I/O Protocol\r
Controller\r
);\r
}\r
+\r
//\r
- // If a Floppy Disk Controller Device structure was allocated, then free it\r
+ // Close the device path protocol\r
//\r
- if (FdcDev != NULL) {\r
- if (FdcDev->Event != NULL) {\r
- //\r
- // Close the event for turning the motor off\r
- //\r
- gBS->CloseEvent (FdcDev->Event);\r
- }\r
-\r
- FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
- gBS->FreePool (FdcDev);\r
- }\r
+ gBS->CloseProtocol (\r
+ Controller,\r
+ &gEfiDevicePathProtocolGuid,\r
+ This->DriverBindingHandle,\r
+ Controller\r
+ );\r
}\r
\r
return Status;\r
}\r
\r
+/**\r
+ Stop this driver on ControllerHandle.\r
+\r
+ @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
+ @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
+ support a bus specific I/O protocol for the driver \r
+ to use to stop the device.\r
+ @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
+ @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
+ if NumberOfChildren is 0.\r
+\r
+ @retval EFI_SUCCESS The device was stopped.\r
+ @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FdcControllerDriverStop (\r
IN UINTN NumberOfChildren,\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
-\r
- Arguments:\r
-\r
- Returns:\r
-\r
---*/\r
-// GC_TODO: This - add argument and description to function comment\r
-// GC_TODO: Controller - add argument and description to function comment\r
-// GC_TODO: NumberOfChildren - add argument and description to function comment\r
-// GC_TODO: ChildHandleBuffer - add argument and description to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_STATUS Status;\r
EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
FDC_BLK_IO_DEV *FdcDev;\r
\r
+ //\r
+ // Ignore NumberOfChildren since this is a device driver\r
+ //\r
+\r
//\r
// Get the Block I/O Protocol on Controller\r
//\r
return Status;\r
}\r
//\r
- // Get the Floppy Disk Controller's Device structure\r
+ // Get the floppy drive device's Device structure\r
//\r
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);\r
\r
FdcDev->DevicePath\r
);\r
\r
- //\r
- // Turn the motor off on the Floppy Disk Controller\r
- //\r
- FddTimerProc (FdcDev->Event, FdcDev);\r
-\r
//\r
// Uninstall the Block I/O Protocol\r
//\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
+ //\r
+ // Close the event for turning the motor off\r
+ //\r
+ gBS->CloseEvent (FdcDev->Event);\r
+\r
+ //\r
+ // Turn the motor off on the floppy drive device\r
+ //\r
+ FddTimerProc (FdcDev->Event, FdcDev);\r
+\r
//\r
// Close the device path protocol\r
//\r
//\r
FdcDev->ControllerState->NumberOfDrive--;\r
\r
- //\r
- // Close the event for turning the motor off\r
- //\r
- gBS->CloseEvent (FdcDev->Event);\r
-\r
//\r
// Free the cache if one was allocated\r
//\r
FdcFreeCache (FdcDev);\r
\r
//\r
- // Free the Floppy Disk Controller's Device structure\r
+ // Free the floppy drive device's device structure\r
//\r
FreeUnicodeStringTable (FdcDev->ControllerNameTable);\r
- gBS->FreePool (FdcDev);\r
+ FreePool (FdcDev);\r
\r
return EFI_SUCCESS;\r
}\r
+\r