mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
Isa Floppy driver code scrub.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8697 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b63f669a8a
commit
d6321d6ef9
@ -1,6 +1,7 @@
|
||||
/**@file
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for Isa Floppy driver.
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -53,10 +54,9 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@ -64,23 +64,18 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param DriverName[out] A pointer to the Unicode string to return.
|
||||
@param[out] DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -112,15 +107,13 @@ IsaFloppyComponentNameGetDriverName (
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param ControllerHandle[in] The handle of a controller that the driver
|
||||
@param[in] ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
||||
@param[in] ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
@ -128,8 +121,7 @@ IsaFloppyComponentNameGetDriverName (
|
||||
controller. It will not be NULL for a bus
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@ -137,8 +129,7 @@ IsaFloppyComponentNameGetDriverName (
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param ControllerName[out] A pointer to the Unicode string to return.
|
||||
@param[out] ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
@ -149,72 +140,55 @@ IsaFloppyComponentNameGetDriverName (
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
IsaFloppyComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
|
||||
EFI_STATUS Status;
|
||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
|
||||
if (Language == NULL || ControllerName == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// This is a device driver, so ChildHandle must be NULL.
|
||||
//
|
||||
if (ChildHandle != NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Check Controller's handle
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
(VOID **) &IsaIoProtocol,
|
||||
gFdcControllerDriver.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gBS->CloseProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
gFdcControllerDriver.DriverBindingHandle,
|
||||
ControllerHandle
|
||||
);
|
||||
|
||||
return EFI_UNSUPPORTED;
|
||||
//
|
||||
// Check if this driver is currently managing ControllerHandle
|
||||
//
|
||||
Status = EfiTestManagedDevice (
|
||||
ControllerHandle,
|
||||
gFdcControllerDriver.DriverBindingHandle,
|
||||
&gEfiIsaIoProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Status != EFI_ALREADY_STARTED) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Get the Block I/O Protocol on Controller
|
||||
// Get the device context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
@ -227,9 +201,7 @@ IsaFloppyComponentNameGetControllerName (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the Floppy Disk Controller's Device structure
|
||||
//
|
||||
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
@ -244,33 +216,34 @@ IsaFloppyComponentNameGetControllerName (
|
||||
/**
|
||||
Add the component name for the floppy device
|
||||
|
||||
@param FdcDev - A pointer to the FDC_BLK_IO_DEV instance.
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
AddName (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
|
||||
{
|
||||
CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN + 1];
|
||||
CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_LEN + 1];
|
||||
|
||||
StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);
|
||||
FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);
|
||||
AddUnicodeString2 (
|
||||
"eng",
|
||||
gIsaFloppyComponentName.SupportedLanguages,
|
||||
&FdcDev->ControllerNameTable,
|
||||
FloppyDriveName,
|
||||
TRUE
|
||||
);
|
||||
AddUnicodeString2 (
|
||||
"en",
|
||||
gIsaFloppyComponentName2.SupportedLanguages,
|
||||
&FdcDev->ControllerNameTable,
|
||||
FloppyDriveName,
|
||||
FALSE
|
||||
);
|
||||
if (!(FeaturePcdGet(PcdComponentNameDisable) && FeaturePcdGet(PcdComponentName2Disable))) {
|
||||
StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);
|
||||
FloppyDriveName[FLOPPY_DRIVE_NAME_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);
|
||||
|
||||
AddUnicodeString2 (
|
||||
"eng",
|
||||
gIsaFloppyComponentName.SupportedLanguages,
|
||||
&FdcDev->ControllerNameTable,
|
||||
FloppyDriveName,
|
||||
TRUE
|
||||
);
|
||||
AddUnicodeString2 (
|
||||
"en",
|
||||
gIsaFloppyComponentName2.SupportedLanguages,
|
||||
&FdcDev->ControllerNameTable,
|
||||
FloppyDriveName,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/**@file
|
||||
/** @file
|
||||
Header file for implementation of UEFI Component Name(2) protocol.
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -11,19 +12,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _ISA_FLOPPY_COMPONENT_NAME_H
|
||||
#define _ISA_FLOPPY_COMPONENT_NAME_H
|
||||
#ifndef _COMPONENT_NAME_H_
|
||||
#define _COMPONENT_NAME_H_
|
||||
|
||||
#define FLOPPY_DRIVE_NAME L"ISA Floppy Drive # "
|
||||
#define FLOPPY_DRIVE_NAME_ASCII_LEN (sizeof ("ISA Floppy Drive # ") - 1)
|
||||
#define ADD_FLOPPY_NAME(x) AddName ((x))
|
||||
#define FLOPPY_DRIVE_NAME L"ISA Floppy Drive # "
|
||||
#define FLOPPY_DRIVE_NAME_LEN ((sizeof (FLOPPY_DRIVE_NAME) / sizeof (CHAR16)) - 1)
|
||||
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -34,10 +31,9 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@ -45,23 +41,18 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param DriverName[out] A pointer to the Unicode string to return.
|
||||
@param[out] DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -85,15 +76,13 @@ IsaFloppyComponentNameGetDriverName (
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param ControllerHandle[in] The handle of a controller that the driver
|
||||
@param[in] ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
||||
@param[in] ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
@ -101,8 +90,7 @@ IsaFloppyComponentNameGetDriverName (
|
||||
controller. It will not be NULL for a bus
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@ -110,8 +98,7 @@ IsaFloppyComponentNameGetDriverName (
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param ControllerName[out] A pointer to the Unicode string to return.
|
||||
@param[out] ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
@ -122,54 +109,38 @@ IsaFloppyComponentNameGetDriverName (
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
IsaFloppyComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
VOID
|
||||
AddName (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
/**
|
||||
Add the component name for the floppy device
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
FdcDev - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV instance.
|
||||
|
||||
**/
|
||||
;
|
||||
VOID
|
||||
AddName (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
/**@file
|
||||
ISA Floppy Driver
|
||||
/** @file
|
||||
ISA Floppy Disk UEFI Driver conforming to the UEFI driver model
|
||||
|
||||
1. Support two types diskette drive
|
||||
1.44M drive and 2.88M drive (and now only support 1.44M)
|
||||
2. Support two diskette drives
|
||||
2. Support two diskette drives per floppy disk controller
|
||||
3. Use DMA channel 2 to transfer data
|
||||
4. Do not use interrupt
|
||||
5. Support diskette change line signal and write protect
|
||||
|
||||
conforming to EFI driver model
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -22,7 +21,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
LIST_ENTRY gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);
|
||||
LIST_ENTRY mControllerHead = INITIALIZE_LIST_HEAD_VARIABLE (mControllerHead);
|
||||
|
||||
//
|
||||
// ISA Floppy Driver Binding Protocol
|
||||
@ -38,14 +37,13 @@ EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {
|
||||
|
||||
|
||||
/**
|
||||
The user Entry Point for module IsaFloppy. The user code starts with this function.
|
||||
The main Entry Point for this driver.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -54,7 +52,7 @@ InitializeIsaFloppy(
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
@ -69,19 +67,21 @@ InitializeIsaFloppy(
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Test controller is a Floppy Disk Controller
|
||||
Test if the controller is a floppy disk drive device
|
||||
|
||||
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
|
||||
@param Controller driver's controller
|
||||
@param RemainingDevicePath children device path
|
||||
@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.
|
||||
|
||||
@retval EFI_UNSUPPORTED controller is not floppy disk
|
||||
@retval EFI_SUCCESS controller is floppy disk
|
||||
@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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -91,8 +91,35 @@ FdcControllerDriverSupported (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_ISA_IO_PROTOCOL *IsaIo;
|
||||
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
|
||||
);
|
||||
|
||||
//
|
||||
// Open the ISA I/O Protocol
|
||||
@ -109,7 +136,7 @@ FdcControllerDriverSupported (
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller
|
||||
// Use the ISA I/O Protocol to see if Controller is a floppy disk drive device
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
|
||||
@ -129,13 +156,20 @@ FdcControllerDriverSupported (
|
||||
}
|
||||
|
||||
/**
|
||||
Create floppy control instance on controller.
|
||||
|
||||
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
|
||||
@param Controller driver controller handle
|
||||
@param RemainingDevicePath Children's device path
|
||||
|
||||
@retval whether success to create floppy control instance.
|
||||
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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -145,13 +179,13 @@ FdcControllerDriverStart (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
|
||||
FdcDev = NULL;
|
||||
IsaIo = NULL;
|
||||
@ -194,14 +228,14 @@ FdcControllerDriverStart (
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Allocate the Floppy Disk Controller's Device structure
|
||||
// Allocate the floppy device's Device structure
|
||||
//
|
||||
FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));
|
||||
if (FdcDev == NULL) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Initialize the Floppy Disk Controller's Device structure
|
||||
// Initialize the floppy device's device structure
|
||||
//
|
||||
FdcDev->Signature = FDC_BLK_IO_DEV_SIGNATURE;
|
||||
FdcDev->Handle = Controller;
|
||||
@ -212,10 +246,11 @@ FdcControllerDriverStart (
|
||||
FdcDev->ControllerState = NULL;
|
||||
FdcDev->DevicePath = ParentDevicePath;
|
||||
|
||||
ADD_FLOPPY_NAME (FdcDev);
|
||||
FdcDev->ControllerNameTable = NULL;
|
||||
AddName (FdcDev);
|
||||
|
||||
//
|
||||
// Look up the base address of the Floppy Disk Controller
|
||||
// Look up the base address of the Floppy Disk Controller which controls this floppy device
|
||||
//
|
||||
for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
|
||||
if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {
|
||||
@ -223,11 +258,11 @@ FdcControllerDriverStart (
|
||||
}
|
||||
}
|
||||
//
|
||||
// Maintain the list of controller list
|
||||
// Maintain the list of floppy disk controllers
|
||||
//
|
||||
Found = FALSE;
|
||||
List = gControllerHead.ForwardLink;
|
||||
while (List != &gControllerHead) {
|
||||
List = mControllerHead.ForwardLink;
|
||||
while (List != &mControllerHead) {
|
||||
FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);
|
||||
if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {
|
||||
Found = TRUE;
|
||||
@ -239,7 +274,7 @@ FdcControllerDriverStart (
|
||||
|
||||
if (!Found) {
|
||||
//
|
||||
// The Controller is new
|
||||
// A new floppy disk controller controlling this floppy disk drive is found
|
||||
//
|
||||
FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));
|
||||
if (FdcDev->ControllerState == NULL) {
|
||||
@ -252,10 +287,10 @@ FdcControllerDriverStart (
|
||||
FdcDev->ControllerState->BaseAddress = FdcDev->BaseAddress;
|
||||
FdcDev->ControllerState->NumberOfDrive = 0;
|
||||
|
||||
InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);
|
||||
InsertTailList (&mControllerHead, &FdcDev->ControllerState->Link);
|
||||
}
|
||||
//
|
||||
// Create a timer event for each Floppd Disk Controller.
|
||||
// Create a timer event for each floppy disk drive device.
|
||||
// This timer event is used to control the motor on and off
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
@ -304,8 +339,9 @@ FdcControllerDriverStart (
|
||||
&FdcDev->BlkIo,
|
||||
NULL
|
||||
);
|
||||
|
||||
FdcDev->ControllerState->NumberOfDrive++;
|
||||
if (!EFI_ERROR (Status)) {
|
||||
FdcDev->ControllerState->NumberOfDrive++;
|
||||
}
|
||||
|
||||
Done:
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -317,14 +353,19 @@ Done:
|
||||
);
|
||||
|
||||
//
|
||||
// Close the device path protocol
|
||||
// If a floppy drive device structure was allocated, then free it
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
if (FdcDev != NULL) {
|
||||
if (FdcDev->Event != NULL) {
|
||||
//
|
||||
// Close the event for turning the motor off
|
||||
//
|
||||
gBS->CloseEvent (FdcDev->Event);
|
||||
}
|
||||
|
||||
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
||||
FreePool (FdcDev);
|
||||
}
|
||||
|
||||
//
|
||||
// Close the ISA I/O Protocol
|
||||
@ -337,38 +378,34 @@ Done:
|
||||
Controller
|
||||
);
|
||||
}
|
||||
//
|
||||
// If a Floppy Disk Controller Device structure was allocated, then free it
|
||||
//
|
||||
if (FdcDev != NULL) {
|
||||
if (FdcDev->Event != NULL) {
|
||||
//
|
||||
// Close the event for turning the motor off
|
||||
//
|
||||
gBS->CloseEvent (FdcDev->Event);
|
||||
}
|
||||
|
||||
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
||||
gBS->FreePool (FdcDev);
|
||||
}
|
||||
//
|
||||
// Close the device path protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. Support stoping any child handles
|
||||
created by this driver.
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param Controller Handle of device to stop driver on
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
||||
@retval other This driver was not removed from this device
|
||||
@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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -383,6 +420,10 @@ FdcControllerDriverStop (
|
||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
|
||||
//
|
||||
// Ignore NumberOfChildren since this is a device driver
|
||||
//
|
||||
|
||||
//
|
||||
// Get the Block I/O Protocol on Controller
|
||||
//
|
||||
@ -398,7 +439,7 @@ FdcControllerDriverStop (
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the Floppy Disk Controller's Device structure
|
||||
// Get the floppy drive device's Device structure
|
||||
//
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
|
||||
|
||||
@ -411,11 +452,6 @@ FdcControllerDriverStop (
|
||||
FdcDev->DevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Turn the motor off on the Floppy Disk Controller
|
||||
//
|
||||
FddTimerProc (FdcDev->Event, FdcDev);
|
||||
|
||||
//
|
||||
// Uninstall the Block I/O Protocol
|
||||
//
|
||||
@ -427,6 +463,17 @@ FdcControllerDriverStop (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// Close the device path protocol
|
||||
//
|
||||
@ -452,21 +499,16 @@ FdcControllerDriverStop (
|
||||
//
|
||||
FdcDev->ControllerState->NumberOfDrive--;
|
||||
|
||||
//
|
||||
// Close the event for turning the motor off
|
||||
//
|
||||
gBS->CloseEvent (FdcDev->Event);
|
||||
|
||||
//
|
||||
// Free the cache if one was allocated
|
||||
//
|
||||
FdcFreeCache (FdcDev);
|
||||
|
||||
//
|
||||
// Free the Floppy Disk Controller's Device structure
|
||||
// Free the floppy drive device's device structure
|
||||
//
|
||||
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
||||
gBS->FreePool (FdcDev);
|
||||
FreePool (FdcDev);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
/**@file
|
||||
Include for ISA Floppy Driver
|
||||
Define the data structure and so on
|
||||
/** @file
|
||||
Include file for ISA Floppy Driver
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -13,15 +12,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _ISA_FLOPPY_H
|
||||
#define _ISA_FLOPPY_H
|
||||
#ifndef _ISA_FLOPPY_H_
|
||||
#define _ISA_FLOPPY_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
#include <FrameworkPei.h>
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/IsaIo.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Guid/StatusCodeDataTypeId.h>
|
||||
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
@ -32,16 +31,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
//
|
||||
// Driver Binding Externs
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;
|
||||
|
||||
//
|
||||
// define some value
|
||||
//
|
||||
#define STALL_1_SECOND 1000000
|
||||
#define STALL_1_MSECOND 1000
|
||||
|
||||
@ -57,14 +50,14 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gIsaFloppyComponentName2;
|
||||
#define FLOPPY_CONTROLLER_CONTEXT_SIGNATURE SIGNATURE_32 ('F', 'D', 'C', 'C')
|
||||
|
||||
typedef enum {
|
||||
FDC_DISK0 = 0,
|
||||
FDC_DISK1 = 1,
|
||||
FDC_MAX_DISK= 2
|
||||
FdcDisk0 = 0,
|
||||
FdcDisk1 = 1,
|
||||
FdcMaxDisk = 2
|
||||
} EFI_FDC_DISK;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
LIST_ENTRY Link;
|
||||
BOOLEAN FddResetPerformed;
|
||||
EFI_STATUS FddResetStatus;
|
||||
BOOLEAN NeedRecalibrate;
|
||||
@ -97,11 +90,11 @@ typedef struct {
|
||||
|
||||
#define FDD_BLK_IO_FROM_THIS(a) CR (a, FDC_BLK_IO_DEV, BlkIo, FDC_BLK_IO_DEV_SIGNATURE)
|
||||
#define FLOPPY_CONTROLLER_FROM_LIST_ENTRY(a) \
|
||||
CR (a, \
|
||||
FLOPPY_CONTROLLER_CONTEXT, \
|
||||
Link, \
|
||||
FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \
|
||||
)
|
||||
CR (a, \
|
||||
FLOPPY_CONTROLLER_CONTEXT, \
|
||||
Link, \
|
||||
FLOPPY_CONTROLLER_CONTEXT_SIGNATURE \
|
||||
)
|
||||
|
||||
#define DISK_1440K_EOT 0x12
|
||||
#define DISK_1440K_GPL 0x1b
|
||||
@ -154,9 +147,9 @@ typedef struct {
|
||||
UINT8 Status0;
|
||||
UINT8 Status1;
|
||||
UINT8 Status2;
|
||||
UINT8 C;
|
||||
UINT8 H;
|
||||
UINT8 S;
|
||||
UINT8 Cylinder;
|
||||
UINT8 Head;
|
||||
UINT8 Sector;
|
||||
UINT8 Number;
|
||||
} FDD_RESULT_PACKET;
|
||||
|
||||
@ -164,32 +157,31 @@ typedef struct {
|
||||
// FDC Registers
|
||||
//
|
||||
//
|
||||
// 0x3F2 Digital Output Register
|
||||
// Digital Output Register address offset
|
||||
//
|
||||
#define FDC_REGISTER_DOR 2
|
||||
|
||||
//
|
||||
// 0x3F4 Main Status Register
|
||||
// Main Status Register address offset
|
||||
//
|
||||
#define FDC_REGISTER_MSR 4
|
||||
|
||||
//
|
||||
// 0x3F5 Data Register
|
||||
// Data Register address offset
|
||||
//
|
||||
#define FDC_REGISTER_DTR 5
|
||||
|
||||
//
|
||||
// 0x3F7 Configuration Control Register(data rate select)
|
||||
// Configuration Control Register(data rate select) address offset
|
||||
//
|
||||
#define FDC_REGISTER_CCR 7
|
||||
|
||||
//
|
||||
// 0x3F7 Digital Input Register(diskchange)
|
||||
// Digital Input Register(diskchange) address offset
|
||||
//
|
||||
#define FDC_REGISTER_DIR 7
|
||||
|
||||
|
||||
|
||||
//
|
||||
// FDC Register Bit Definitions
|
||||
//
|
||||
@ -484,23 +476,21 @@ typedef struct {
|
||||
//
|
||||
#define IC_ATRC 0xC0
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver;
|
||||
|
||||
//
|
||||
// EFI Driver Binding Protocol Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Test controller is a Floppy Disk Controller
|
||||
Test controller is a floppy disk drive device
|
||||
|
||||
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
|
||||
@param Controller driver's controller
|
||||
@param RemainingDevicePath children device path
|
||||
@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.
|
||||
|
||||
@retval EFI_UNSUPPORTED controller is not floppy disk
|
||||
@retval EFI_SUCCESS controller is floppy disk
|
||||
@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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -511,13 +501,20 @@ FdcControllerDriverSupported (
|
||||
);
|
||||
|
||||
/**
|
||||
Create floppy control instance on controller.
|
||||
|
||||
@param This Pointer of EFI_DRIVER_BINDING_PROTOCOL
|
||||
@param Controller driver controller handle
|
||||
@param RemainingDevicePath Children's device path
|
||||
|
||||
@retval whether success to create floppy control instance.
|
||||
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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -528,18 +525,18 @@ FdcControllerDriverStart (
|
||||
);
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. Support stoping any child handles
|
||||
created by this driver.
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param Controller Handle of device to stop driver on
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
||||
@retval other This driver was not removed from this device
|
||||
@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.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -553,8 +550,9 @@ FdcControllerDriverStop (
|
||||
//
|
||||
// EFI Block I/O Protocol Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Reset the Floppy Logic Drive, call the FddReset function
|
||||
Reset the Floppy Logic Drive, call the FddReset function.
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more
|
||||
@ -573,7 +571,7 @@ FdcReset (
|
||||
);
|
||||
|
||||
/**
|
||||
Flush block via fdd controller
|
||||
Flush block via fdd controller.
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@return EFI_SUCCESS
|
||||
@ -586,11 +584,11 @@ FddFlushBlocks (
|
||||
);
|
||||
|
||||
/**
|
||||
Read the requested number of blocks from the device
|
||||
Read the requested number of blocks from the device.
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param MediaId UINT32: The media id that the read request is for
|
||||
@param LBA EFI_LBA: The starting logic block address to read from on the device
|
||||
@param Lba EFI_LBA: The starting logic block address to read from on the device
|
||||
@param BufferSize UINTN: The size of the Buffer in bytes
|
||||
@param Buffer VOID *: A pointer to the destination buffer for the data
|
||||
|
||||
@ -610,17 +608,17 @@ EFIAPI
|
||||
FddReadBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Write a specified number of blocks to the device
|
||||
Write a specified number of blocks to the device.
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param MediaId UINT32: The media id that the write request is for
|
||||
@param LBA EFI_LBA: The starting logic block address to be written
|
||||
@param Lba EFI_LBA: The starting logic block address to be written
|
||||
@param BufferSize UINTN: The size in bytes in Buffer
|
||||
@param Buffer VOID *: A pointer to the source buffer for the data
|
||||
|
||||
@ -640,7 +638,7 @@ EFIAPI
|
||||
FddWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
@ -650,7 +648,7 @@ FddWriteBlocks (
|
||||
//
|
||||
/**
|
||||
|
||||
Detect the floppy drive is presented or not
|
||||
Detect the floppy drive is presented or not.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@retval EFI_SUCCESS Drive is presented
|
||||
@ -664,8 +662,8 @@ DiscoverFddDevice (
|
||||
|
||||
/**
|
||||
|
||||
Do recalibrate and see the drive is presented or not
|
||||
Set the media parameters
|
||||
Do recalibrate and see the drive is presented or not.
|
||||
Set the media parameters.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@return the drive is presented or not
|
||||
@ -678,7 +676,7 @@ FddIdentify (
|
||||
|
||||
/**
|
||||
|
||||
Reset the Floppy Logic Drive
|
||||
Reset the Floppy Logic Drive.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@ -694,8 +692,8 @@ FddReset (
|
||||
|
||||
/**
|
||||
|
||||
Turn the drive's motor on
|
||||
The drive's motor must be on before any command can be executed
|
||||
Turn the drive's motor on.
|
||||
The drive's motor must be on before any command can be executed.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@ -711,7 +709,7 @@ MotorOn (
|
||||
|
||||
/**
|
||||
|
||||
Set a Timer and when Timer goes off, turn the motor off
|
||||
Set a Timer and when Timer goes off, turn the motor off.
|
||||
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@ -726,7 +724,7 @@ MotorOff (
|
||||
);
|
||||
|
||||
/**
|
||||
Detect the disk in the drive is changed or not
|
||||
Detect the disk in the drive is changed or not.
|
||||
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@ -744,7 +742,7 @@ DisketChanged (
|
||||
/**
|
||||
Do the Specify command, this command sets DMA operation
|
||||
and the initial values for each of the three internal
|
||||
times: HUT, SRT and HLT
|
||||
times: HUT, SRT and HLT.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
|
||||
@ -758,7 +756,7 @@ Specify (
|
||||
);
|
||||
|
||||
/**
|
||||
Set the head of floppy drive to track 0
|
||||
Set the head of floppy drive to track 0.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@retval EFI_SUCCESS: Execute the Recalibrate operation successfully
|
||||
@ -771,7 +769,7 @@ Recalibrate (
|
||||
);
|
||||
|
||||
/**
|
||||
Set the head of floppy drive to the new cylinder
|
||||
Set the head of floppy drive to the new cylinder.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Lba EFI_LBA : The logic block address want to seek
|
||||
@ -787,8 +785,7 @@ Seek (
|
||||
);
|
||||
|
||||
/**
|
||||
Do the Sense Interrupt Status command, this command
|
||||
resets the interrupt signal
|
||||
Do the Sense Interrupt Status command, this command resets the interrupt signal.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC
|
||||
@ -807,7 +804,7 @@ SenseIntStatus (
|
||||
);
|
||||
|
||||
/**
|
||||
Do the Sense Drive Status command
|
||||
Do the Sense Drive Status command.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Lba EFI_LBA : Logic block address
|
||||
@ -824,8 +821,7 @@ SenseDrvStatus (
|
||||
);
|
||||
|
||||
/**
|
||||
Update the disk media properties and if necessary
|
||||
reinstall Block I/O interface
|
||||
Update the disk media properties and if necessary reinstall Block I/O interface.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@ -839,7 +835,7 @@ DetectMedia (
|
||||
);
|
||||
|
||||
/**
|
||||
Set the data rate and so on
|
||||
Set the data rate and so on.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@ -851,7 +847,7 @@ Setup (
|
||||
);
|
||||
|
||||
/**
|
||||
Read or Write a number of blocks in the same cylinder
|
||||
Read or Write a number of blocks in the same cylinder.
|
||||
|
||||
@param FdcDev A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param HostAddress device address
|
||||
@ -872,7 +868,7 @@ ReadWriteDataSector (
|
||||
);
|
||||
|
||||
/**
|
||||
Fill in FDD command's parameter
|
||||
Fill in FDD command's parameter.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Lba The starting logic block address to read from on the device
|
||||
@ -887,24 +883,23 @@ FillPara (
|
||||
);
|
||||
|
||||
/**
|
||||
Read result byte from Data Register of FDC
|
||||
Read result byte from Data Register of FDC.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer UINT8 *: Be used to save result byte read from FDC
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer Buffer to store the byte read from FDC
|
||||
|
||||
|
||||
@retval EFI_SUCCESS: Read result byte from FDC successfully
|
||||
@retval EFI_DEVICE_ERROR: The FDC is not ready to be read
|
||||
@retval EFI_SUCCESS Read result byte from FDC successfully
|
||||
@retval EFI_DEVICE_ERROR The FDC is not ready to be read
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DataInByte (
|
||||
IN FDC_BLK_IO_DEV *FdcDev,
|
||||
IN UINT8 *Pointer
|
||||
IN FDC_BLK_IO_DEV *FdcDev,
|
||||
OUT UINT8 *Pointer
|
||||
);
|
||||
|
||||
/**
|
||||
Write command byte to Data Register of FDC
|
||||
Write command byte to Data Register of FDC.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer Be used to save command byte written to FDC
|
||||
@ -920,8 +915,7 @@ DataOutByte (
|
||||
);
|
||||
|
||||
/**
|
||||
Detect the specified floppy logic drive is busy or
|
||||
not within a period of time
|
||||
Detect the specified floppy logic drive is busy or not within a period of time.
|
||||
|
||||
@param FdcDev Indicate it is drive A or drive B
|
||||
@param TimeoutInSeconds the time period for waiting
|
||||
@ -938,8 +932,7 @@ FddWaitForBSYClear (
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Routine Description: Determine whether FDC is ready to write or read
|
||||
Determine whether FDC is ready to write or read.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Dio BOOLEAN: Indicate the FDC is waiting to write or read
|
||||
@ -957,8 +950,7 @@ FddDRQReady (
|
||||
);
|
||||
|
||||
/**
|
||||
Set FDC control structure's attribute according to
|
||||
result
|
||||
Set FDC control structure's attribute according to result.
|
||||
|
||||
@param Result Point to result structure
|
||||
@param FdcDev FDC control structure
|
||||
@ -976,7 +968,7 @@ CheckResult (
|
||||
);
|
||||
|
||||
/**
|
||||
Check the drive status information
|
||||
Check the drive status information.
|
||||
|
||||
@param StatusRegister3 the value of Status Register 3
|
||||
|
||||
@ -990,26 +982,25 @@ CheckStatus3 (
|
||||
);
|
||||
|
||||
/**
|
||||
Calculate the number of block in the same cylinder
|
||||
according to LBA
|
||||
Calculate the number of block in the same cylinder according to Lba.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param LBA EFI_LBA: The starting logic block address
|
||||
@param Lba EFI_LBA: The starting logic block address
|
||||
@param NumberOfBlocks UINTN: The number of blocks
|
||||
|
||||
@return The number of blocks in the same cylinder which the starting
|
||||
logic block address is LBA
|
||||
logic block address is Lba
|
||||
|
||||
**/
|
||||
UINTN
|
||||
GetTransferBlockCount (
|
||||
IN FDC_BLK_IO_DEV *FdcDev,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN NumberOfBlocks
|
||||
);
|
||||
|
||||
/**
|
||||
When the Timer(2s) off, turn the drive's motor off
|
||||
When the Timer(2s) off, turn the drive's motor off.
|
||||
|
||||
@param Event EFI_EVENT: Event(the timer) whose notification function is being
|
||||
invoked
|
||||
@ -1024,7 +1015,7 @@ FddTimerProc (
|
||||
);
|
||||
|
||||
/**
|
||||
Read I/O port for FDC
|
||||
Read I/O port for FDC.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Offset The offset address of port
|
||||
@ -1037,7 +1028,7 @@ FdcReadPort (
|
||||
);
|
||||
|
||||
/**
|
||||
Write I/O port for FDC
|
||||
Write I/O port for FDC.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Offset The offset address of port
|
||||
@ -1052,11 +1043,11 @@ FdcWritePort (
|
||||
);
|
||||
|
||||
/**
|
||||
Read or Write a number of blocks to floppy device
|
||||
Read or Write a number of blocks to floppy device.
|
||||
|
||||
@param This Pointer to instance of EFI_BLOCK_IO_PROTOCOL
|
||||
@param MediaId The media id of read/write request
|
||||
@param LBA The starting logic block address to read from on the device
|
||||
@param Lba The starting logic block address to read from on the device
|
||||
@param BufferSize The size of the Buffer in bytes
|
||||
@param Operation - GC_TODO: add argument description
|
||||
@param Buffer - GC_TODO: add argument description
|
||||
@ -1081,14 +1072,14 @@ EFI_STATUS
|
||||
FddReadWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN BOOLEAN Operation,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Common interface for free cache
|
||||
Common interface for free cache.
|
||||
|
||||
@param FdcDev Pointer of FDC_BLK_IO_DEV instance
|
||||
|
||||
|
@ -1,15 +1,7 @@
|
||||
/**@file
|
||||
ISA Floppy Driver
|
||||
1. Support two types diskette drive
|
||||
1.44M drive and 2.88M drive (and now only support 1.44M)
|
||||
2. Support two diskette drives
|
||||
3. Use DMA channel 2 to transfer data
|
||||
4. Do not use interrupt
|
||||
5. Support diskette change line signal and write protect
|
||||
/** @file
|
||||
Implementation of the EFI Block IO Protocol for ISA Floppy driver
|
||||
|
||||
Implement the Block IO interface
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -20,20 +12,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
/**
|
||||
Reset the Floppy Logic Drive, call the FddReset function
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param ExtendedVerification BOOLEAN: Indicate that the driver may perform a more
|
||||
exhaustive verification operation of the device during
|
||||
reset, now this par is ignored in this driver
|
||||
@retval EFI_SUCCESS: The Floppy Logic Drive is reset
|
||||
@retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly
|
||||
and can not be reset
|
||||
Reset the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
|
||||
not be reset.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
@ -59,10 +48,13 @@ FdcReset (
|
||||
}
|
||||
|
||||
/**
|
||||
Flush block via fdd controller
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@return EFI_SUCCESS
|
||||
Flush the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
|
||||
@retval EFI_SUCCESS All outstanding data was written to the device
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while writting back the data
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
@ -78,10 +70,10 @@ FddFlushBlocks (
|
||||
}
|
||||
|
||||
/**
|
||||
Common report status code interface
|
||||
Common report status code interface.
|
||||
|
||||
@param This Pointer of FDC_BLK_IO_DEV instance
|
||||
@param Read Error type: read or write?
|
||||
@param Read Read or write operation when error occurrs
|
||||
**/
|
||||
VOID
|
||||
FddReportStatus (
|
||||
@ -101,23 +93,22 @@ FddReportStatus (
|
||||
}
|
||||
|
||||
/**
|
||||
Read the requested number of blocks from the device
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param MediaId UINT32: The media id that the read request is for
|
||||
@param LBA EFI_LBA: The starting logic block address to read from on the device
|
||||
@param BufferSize UINTN: The size of the Buffer in bytes
|
||||
@param Buffer VOID *: A pointer to the destination buffer for the data
|
||||
|
||||
@retval EFI_SUCCESS: The data was read correctly from the device
|
||||
@retval EFI_DEVICE_ERROR:The device reported an error while attempting to perform
|
||||
the read operation
|
||||
@retval EFI_NO_MEDIA: There is no media in the device
|
||||
@retval EFI_MEDIA_CHANGED: The MediaId is not for the current media
|
||||
@retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
|
||||
intrinsic block size of the device
|
||||
@retval EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId Id of the media, changes every time the media is replaced.
|
||||
@param Lba The starting Logical Block Address to read from
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the destination buffer for the data. The caller is
|
||||
responsible for either having implicit or explicit ownership of the buffer.
|
||||
|
||||
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
@ -125,14 +116,14 @@ EFIAPI
|
||||
FddReadBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, READ, Buffer);
|
||||
Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, READ, Buffer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FddReportStatus (This, TRUE);
|
||||
@ -142,38 +133,38 @@ FddReadBlocks (
|
||||
}
|
||||
|
||||
/**
|
||||
Write a specified number of blocks to the device
|
||||
|
||||
@param This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
@param MediaId UINT32: The media id that the write request is for
|
||||
@param LBA EFI_LBA: The starting logic block address to be written
|
||||
@param BufferSize UINTN: The size in bytes in Buffer
|
||||
@param Buffer VOID *: A pointer to the source buffer for the data
|
||||
|
||||
@retval EFI_SUCCESS: The data were written correctly to the device
|
||||
@retval EFI_WRITE_PROTECTED: The device can not be written to
|
||||
@retval EFI_NO_MEDIA: There is no media in the device
|
||||
@retval EFI_MEDIA_CHANGED: The MediaId is not for the current media
|
||||
@retval EFI_DEVICE_ERROR: The device reported an error while attempting to perform
|
||||
the write operation
|
||||
@retval EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
|
||||
intrinsic block size of the device
|
||||
@retval EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId The media ID that the write request is for.
|
||||
@param Lba The starting logical block address to be written. The caller is
|
||||
responsible for writing to only legitimate locations.
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the source buffer for the data.
|
||||
|
||||
@retval EFI_SUCCESS The data was written correctly to the device.
|
||||
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FddWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, WRITE, Buffer);
|
||||
Status = FddReadWriteBlocks (This, MediaId, Lba, BufferSize, WRITE, Buffer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FddReportStatus (This, FALSE);
|
||||
@ -183,36 +174,31 @@ FddWriteBlocks (
|
||||
}
|
||||
|
||||
/**
|
||||
Read or Write a number of blocks to floppy device
|
||||
Read or Write a number of blocks to floppy disk
|
||||
|
||||
@param This Pointer to instance of EFI_BLOCK_IO_PROTOCOL
|
||||
@param MediaId The media id of read/write request
|
||||
@param LBA The starting logic block address to read from on the device
|
||||
@param BufferSize The size of the Buffer in bytes
|
||||
@param Operation - GC_TODO: add argument description
|
||||
@param Buffer - GC_TODO: add argument description
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId Id of the media, changes every time the media is replaced.
|
||||
@param Lba The starting Logical Block Address to read from
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Operation Specifies the read or write operation.
|
||||
@param Buffer A pointer to the destination buffer for the data. The caller is
|
||||
responsible for either having implicit or explicit ownership of the buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
@retval EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
@retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
@retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
@retval EFI_NO_MEDIA - GC_TODO: Add description for return value
|
||||
@retval EFI_MEDIA_CHANGED - GC_TODO: Add description for return value
|
||||
@retval EFI_WRITE_PROTECTED - GC_TODO: Add description for return value
|
||||
@retval EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value
|
||||
@retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
@retval EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
@retval EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
@retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
@retval EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
@retval EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
FddReadWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN BOOLEAN Operation,
|
||||
OUT VOID *Buffer
|
||||
@ -224,10 +210,7 @@ FddReadWriteBlocks (
|
||||
UINTN NumberOfBlocks;
|
||||
UINTN BlockCount;
|
||||
EFI_STATUS Status;
|
||||
//
|
||||
// EFI_STATUS CacheStatus;
|
||||
//
|
||||
EFI_LBA LBA0;
|
||||
EFI_LBA Lba0;
|
||||
UINT8 *Pointer;
|
||||
|
||||
//
|
||||
@ -238,7 +221,7 @@ FddReadWriteBlocks (
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (This);
|
||||
|
||||
if (Operation == WRITE) {
|
||||
if (LBA == 0) {
|
||||
if (Lba == 0) {
|
||||
FdcFreeCache (FdcDev);
|
||||
}
|
||||
}
|
||||
@ -274,13 +257,6 @@ FddReadWriteBlocks (
|
||||
if (!(Media->MediaPresent)) {
|
||||
MotorOff (FdcDev);
|
||||
FdcFreeCache (FdcDev);
|
||||
|
||||
/*
|
||||
if (FdcDev->Cache) {
|
||||
gBS->FreePool (FdcDev->Cache);
|
||||
FdcDev->Cache = NULL;
|
||||
}
|
||||
*/
|
||||
return EFI_NO_MEDIA;
|
||||
}
|
||||
//
|
||||
@ -306,12 +282,12 @@ FddReadWriteBlocks (
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (LBA > Media->LastBlock) {
|
||||
if (Lba > Media->LastBlock) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (((BufferSize / BlockSize) + LBA - 1) > Media->LastBlock) {
|
||||
if (((BufferSize / BlockSize) + Lba - 1) > Media->LastBlock) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -320,8 +296,8 @@ FddReadWriteBlocks (
|
||||
//
|
||||
// See if the data that is being read is already in the cache
|
||||
//
|
||||
if (FdcDev->Cache) {
|
||||
if (LBA == 0 && BufferSize == BlockSize) {
|
||||
if (FdcDev->Cache != NULL) {
|
||||
if (Lba == 0 && BufferSize == BlockSize) {
|
||||
MotorOff (FdcDev);
|
||||
CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);
|
||||
return EFI_SUCCESS;
|
||||
@ -338,26 +314,26 @@ FddReadWriteBlocks (
|
||||
}
|
||||
|
||||
NumberOfBlocks = BufferSize / BlockSize;
|
||||
LBA0 = LBA;
|
||||
Lba0 = Lba;
|
||||
Pointer = Buffer;
|
||||
|
||||
//
|
||||
// read blocks in the same cylinder.
|
||||
// in a cylinder , there are 18 * 2 = 36 blocks
|
||||
//
|
||||
BlockCount = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);
|
||||
BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);
|
||||
while ((BlockCount != 0) && !EFI_ERROR (Status)) {
|
||||
Status = ReadWriteDataSector (FdcDev, Buffer, LBA, BlockCount, Operation);
|
||||
Status = ReadWriteDataSector (FdcDev, Buffer, Lba, BlockCount, Operation);
|
||||
if (EFI_ERROR (Status)) {
|
||||
MotorOff (FdcDev);
|
||||
FddReset (FdcDev);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
LBA += BlockCount;
|
||||
Lba += BlockCount;
|
||||
NumberOfBlocks -= BlockCount;
|
||||
Buffer = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);
|
||||
BlockCount = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);
|
||||
BlockCount = GetTransferBlockCount (FdcDev, Lba, NumberOfBlocks);
|
||||
}
|
||||
|
||||
Buffer = Pointer;
|
||||
@ -371,7 +347,7 @@ FddReadWriteBlocks (
|
||||
//
|
||||
// Cache the data read
|
||||
//
|
||||
if (LBA0 == 0 && !FdcDev->Cache) {
|
||||
if (Lba0 == 0 && FdcDev->Cache == NULL) {
|
||||
FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);
|
||||
}
|
||||
}
|
||||
@ -381,18 +357,18 @@ FddReadWriteBlocks (
|
||||
}
|
||||
|
||||
/**
|
||||
Common interface for free cache
|
||||
Free cache for a floppy disk.
|
||||
|
||||
@param FdcDev Pointer of FDC_BLK_IO_DEV instance
|
||||
@param FdcDev A Pointer to FDC_BLK_IO_DEV instance
|
||||
|
||||
**/
|
||||
VOID
|
||||
FdcFreeCache (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
{
|
||||
if (FdcDev->Cache) {
|
||||
gBS->FreePool (FdcDev->Cache);
|
||||
if (FdcDev->Cache != NULL) {
|
||||
FreePool (FdcDev->Cache);
|
||||
FdcDev->Cache = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
/**@file
|
||||
ISA Floppy Driver
|
||||
1. Support two types diskette drive
|
||||
1.44M drive and 2.88M drive (and now only support 1.44M)
|
||||
2. Support two diskette drives
|
||||
3. Use DMA channel 2 to transfer data
|
||||
4. Do not use interrupt
|
||||
5. Support diskette change line signal and write protect
|
||||
|
||||
The internal function for the floppy driver
|
||||
/** @file
|
||||
Internal floppy disk controller programming functions for the floppy driver.
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.<BR>
|
||||
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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
|
||||
@ -23,13 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
/**
|
||||
|
||||
Detect the floppy drive is presented or not
|
||||
Detect whether a floppy drive is present or not.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@retval EFI_SUCCESS Drive is presented
|
||||
@retval EFI_NOT_FOUND Drive is not presented
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS The floppy disk drive is present
|
||||
@retval EFI_NOT_FOUND The floppy disk drive is not present
|
||||
**/
|
||||
EFI_STATUS
|
||||
DiscoverFddDevice (
|
||||
@ -40,9 +31,6 @@ DiscoverFddDevice (
|
||||
|
||||
FdcDev->BlkIo.Media = &FdcDev->BlkMedia;
|
||||
|
||||
//
|
||||
// Call FddIndentify subroutine
|
||||
//
|
||||
Status = FddIdentify (FdcDev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
@ -59,13 +47,13 @@ DiscoverFddDevice (
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Do recalibrate and see the drive is presented or not
|
||||
Set the media parameters
|
||||
Do recalibrate and check if the drive is present or not
|
||||
and set the media parameters if the driver is present.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@return the drive is presented or not
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS The floppy disk drive is present
|
||||
@retval EFI_DEVICE_ERROR The floppy disk drive is not present
|
||||
**/
|
||||
EFI_STATUS
|
||||
FddIdentify (
|
||||
@ -94,9 +82,6 @@ FddIdentify (
|
||||
//
|
||||
FdcDev->BlkIo.Media->RemovableMedia = TRUE;
|
||||
FdcDev->BlkIo.Media->MediaPresent = TRUE;
|
||||
//
|
||||
// investigate
|
||||
//
|
||||
FdcDev->BlkIo.Media->MediaId = 0;
|
||||
|
||||
//
|
||||
@ -137,10 +122,9 @@ FddIdentify (
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reset the Floppy Logic Drive
|
||||
Reset the Floppy Logic Drive.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: The Floppy Logic Drive is reset
|
||||
@retval EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly and
|
||||
@ -152,7 +136,7 @@ FddReset (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
{
|
||||
UINT8 data;
|
||||
UINT8 Data;
|
||||
UINT8 StatusRegister0;
|
||||
UINT8 PresentCylinderNumber;
|
||||
UINTN Index;
|
||||
@ -179,9 +163,9 @@ FddReset (
|
||||
// use bit0 & bit1 to select the logic drive
|
||||
// write "0" to bit2
|
||||
//
|
||||
data = 0x0;
|
||||
data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);
|
||||
Data = 0x0;
|
||||
Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
|
||||
|
||||
//
|
||||
// wait some time,at least 120us
|
||||
@ -193,8 +177,8 @@ FddReset (
|
||||
// write "1" to bit2
|
||||
// write "1" to bit3 : enable DMA
|
||||
//
|
||||
data |= 0x0C;
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);
|
||||
Data |= 0x0C;
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
|
||||
|
||||
//
|
||||
// Experience value
|
||||
@ -236,16 +220,13 @@ FddReset (
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Turn the drive's motor on
|
||||
The drive's motor must be on before any command can be executed
|
||||
Turn the floppy disk drive's motor on.
|
||||
The drive's motor must be on before any command can be executed.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: Turn the drive's motor on successfully
|
||||
@retval EFI_DEVICE_ERROR: The drive is busy, so can not turn motor on
|
||||
@retval EFI_INVALID_PARAMETER: Fail to Set timer(Cancel timer)
|
||||
|
||||
@retval EFI_SUCCESS The drive's motor was turned on successfully
|
||||
@retval EFI_DEVICE_ERROR The drive is busy, so can not turn motor on
|
||||
**/
|
||||
EFI_STATUS
|
||||
MotorOn (
|
||||
@ -253,7 +234,7 @@ MotorOn (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 data;
|
||||
UINT8 DorData;
|
||||
|
||||
//
|
||||
// Control of the floppy drive motors is a big pain. If motor is off, you have
|
||||
@ -269,17 +250,15 @@ MotorOn (
|
||||
// Cancel the timer
|
||||
//
|
||||
Status = gBS->SetTimer (FdcDev->Event, TimerCancel, 0);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// Get the motor status
|
||||
//
|
||||
data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
|
||||
DorData = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
|
||||
|
||||
if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) == 0x10)) ||
|
||||
((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) == 0x21))
|
||||
if (((FdcDev->Disk == FdcDisk0) && ((DorData & 0x10) == 0x10)) ||
|
||||
((FdcDev->Disk == FdcDisk1) && ((DorData & 0x21) == 0x21))
|
||||
) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -293,21 +272,21 @@ MotorOn (
|
||||
//
|
||||
// for drive A: 1CH, drive B: 2DH
|
||||
//
|
||||
data = 0x0C;
|
||||
data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));
|
||||
if (FdcDev->Disk == FDC_DISK0) {
|
||||
DorData = 0x0C;
|
||||
DorData = (UINT8) (DorData | (SELECT_DRV & FdcDev->Disk));
|
||||
if (FdcDev->Disk == FdcDisk0) {
|
||||
//
|
||||
// drive A
|
||||
//
|
||||
data |= DRVA_MOTOR_ON;
|
||||
DorData |= DRVA_MOTOR_ON;
|
||||
} else {
|
||||
//
|
||||
// drive B
|
||||
//
|
||||
data |= DRVB_MOTOR_ON;
|
||||
DorData |= DRVB_MOTOR_ON;
|
||||
}
|
||||
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, DorData);
|
||||
|
||||
//
|
||||
// Experience value
|
||||
@ -318,15 +297,12 @@ MotorOn (
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Set a Timer and when Timer goes off, turn the motor off
|
||||
Set a Timer and when Timer goes off, turn the motor off.
|
||||
|
||||
@param[in] FdcDev A pointer to the FDC_BLK_IO_DEV
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV * : A pointer to the Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: Set the Timer successfully
|
||||
@retval EFI_INVALID_PARAMETER: Fail to Set the timer
|
||||
|
||||
@retval EFI_SUCCESS Set the Timer successfully
|
||||
@retval EFI_INVALID_PARAMETER Fail to Set the timer
|
||||
**/
|
||||
EFI_STATUS
|
||||
MotorOff (
|
||||
@ -340,15 +316,14 @@ MotorOff (
|
||||
}
|
||||
|
||||
/**
|
||||
Detect the disk in the drive is changed or not
|
||||
Detect whether the disk in the drive is changed or not.
|
||||
|
||||
@param[in] FdcDev A pointer to FDC_BLK_IO_DEV
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: No disk media change
|
||||
@retval EFI_DEVICE_ERROR: Fail to do the recalibrate or seek operation
|
||||
@retval EFI_NO_MEDIA: No disk in the drive
|
||||
@retval EFI_MEDIA_CHANGED: There is a new disk in the drive
|
||||
@retval EFI_SUCCESS No disk media change
|
||||
@retval EFI_DEVICE_ERROR Fail to do the recalibrate or seek operation
|
||||
@retval EFI_NO_MEDIA No disk in the drive
|
||||
@retval EFI_MEDIA_CHANGED There is a new disk in the drive
|
||||
**/
|
||||
EFI_STATUS
|
||||
DisketChanged (
|
||||
@ -356,19 +331,19 @@ DisketChanged (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 data;
|
||||
UINT8 Data;
|
||||
|
||||
//
|
||||
// Check change line
|
||||
//
|
||||
data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
|
||||
Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
|
||||
|
||||
//
|
||||
// Io delay
|
||||
//
|
||||
MicroSecondDelay (50);
|
||||
|
||||
if ((data & DIR_DCL) == 0x80) {
|
||||
if ((Data & DIR_DCL) == 0x80) {
|
||||
//
|
||||
// disk change line is active
|
||||
//
|
||||
@ -386,14 +361,14 @@ DisketChanged (
|
||||
//
|
||||
}
|
||||
|
||||
data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
|
||||
Data = FdcReadPort (FdcDev, FDC_REGISTER_DIR);
|
||||
|
||||
//
|
||||
// Io delay
|
||||
//
|
||||
MicroSecondDelay (50);
|
||||
|
||||
if ((data & DIR_DCL) == 0x80) {
|
||||
if ((Data & DIR_DCL) == 0x80) {
|
||||
return EFI_NO_MEDIA;
|
||||
}
|
||||
|
||||
@ -406,13 +381,12 @@ DisketChanged (
|
||||
/**
|
||||
Do the Specify command, this command sets DMA operation
|
||||
and the initial values for each of the three internal
|
||||
times: HUT, SRT and HLT
|
||||
times: HUT, SRT and HLT.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param[in] FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: Execute the Specify command successfully
|
||||
@retval EFI_DEVICE_ERROR: Fail to execute the command
|
||||
|
||||
@retval EFI_SUCCESS Execute the Specify command successfully
|
||||
@retval EFI_DEVICE_ERROR Fail to execute the command
|
||||
**/
|
||||
EFI_STATUS
|
||||
Specify (
|
||||
@ -447,9 +421,9 @@ Specify (
|
||||
}
|
||||
|
||||
/**
|
||||
Set the head of floppy drive to track 0
|
||||
Set the head of floppy drive to track 0.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
@retval EFI_SUCCESS: Execute the Recalibrate operation successfully
|
||||
@retval EFI_DEVICE_ERROR: Fail to execute the Recalibrate operation
|
||||
|
||||
@ -474,7 +448,7 @@ Recalibrate (
|
||||
//
|
||||
// drive select
|
||||
//
|
||||
if (FdcDev->Disk == FDC_DISK0) {
|
||||
if (FdcDev->Disk == FdcDisk0) {
|
||||
Command.DiskHeadSel = 0;
|
||||
//
|
||||
// 0
|
||||
@ -521,9 +495,9 @@ Recalibrate (
|
||||
}
|
||||
|
||||
/**
|
||||
Set the head of floppy drive to the new cylinder
|
||||
Set the head of floppy drive to the new cylinder.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
@param Lba EFI_LBA : The logic block address want to seek
|
||||
|
||||
@retval EFI_SUCCESS: Execute the Seek operation successfully
|
||||
@ -573,7 +547,7 @@ Seek (
|
||||
|
||||
ZeroMem (&Command, sizeof (FDD_SEEK_CMD));
|
||||
Command.CommandCode = SEEK_CMD;
|
||||
if (FdcDev->Disk == FDC_DISK0) {
|
||||
if (FdcDev->Disk == FdcDisk0) {
|
||||
Command.DiskHeadSel = 0;
|
||||
//
|
||||
// 0
|
||||
@ -625,9 +599,9 @@ Seek (
|
||||
|
||||
/**
|
||||
Do the Sense Interrupt Status command, this command
|
||||
resets the interrupt signal
|
||||
resets the interrupt signal.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
@param StatusRegister0 UINT8 *: Be used to save Status Register 0 read from FDC
|
||||
@param PresentCylinderNumber UINT8 *: Be used to save present cylinder number
|
||||
read from FDC
|
||||
@ -643,10 +617,10 @@ SenseIntStatus (
|
||||
IN OUT UINT8 *PresentCylinderNumber
|
||||
)
|
||||
{
|
||||
UINT8 command;
|
||||
UINT8 Command;
|
||||
|
||||
command = SENSE_INT_STATUS_CMD;
|
||||
if (EFI_ERROR (DataOutByte (FdcDev, &command))) {
|
||||
Command = SENSE_INT_STATUS_CMD;
|
||||
if (EFI_ERROR (DataOutByte (FdcDev, &Command))) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
@ -662,9 +636,9 @@ SenseIntStatus (
|
||||
}
|
||||
|
||||
/**
|
||||
Do the Sense Drive Status command
|
||||
Do the Sense Drive Status command.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
@param Lba EFI_LBA : Logic block address
|
||||
|
||||
@retval EFI_SUCCESS: Execute the Sense Drive Status command successfully
|
||||
@ -693,7 +667,7 @@ SenseDrvStatus (
|
||||
ZeroMem (&Command, sizeof (FDD_COMMAND_PACKET2));
|
||||
Command.CommandCode = SENSE_DRV_STATUS_CMD;
|
||||
|
||||
if (FdcDev->Disk == FDC_DISK0) {
|
||||
if (FdcDev->Disk == FdcDisk0) {
|
||||
Command.DiskHeadSel = 0;
|
||||
} else {
|
||||
Command.DiskHeadSel = 1;
|
||||
@ -725,10 +699,9 @@ SenseDrvStatus (
|
||||
}
|
||||
|
||||
/**
|
||||
Update the disk media properties and if necessary
|
||||
reinstall Block I/O interface
|
||||
Update the disk media properties and if necessary reinstall Block I/O interface.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS: Do the operation successfully
|
||||
@retval EFI_DEVICE_ERROR: Fail to the operation
|
||||
@ -740,13 +713,13 @@ DetectMedia (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOLEAN bReset;
|
||||
BOOLEAN bReadOnlyLastTime;
|
||||
BOOLEAN bMediaPresentLastTime;
|
||||
BOOLEAN Reset;
|
||||
BOOLEAN ReadOnlyLastTime;
|
||||
BOOLEAN MediaPresentLastTime;
|
||||
|
||||
bReset = FALSE;
|
||||
bReadOnlyLastTime = FdcDev->BlkIo.Media->ReadOnly;
|
||||
bMediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;
|
||||
Reset = FALSE;
|
||||
ReadOnlyLastTime = FdcDev->BlkIo.Media->ReadOnly;
|
||||
MediaPresentLastTime = FdcDev->BlkIo.Media->MediaPresent;
|
||||
|
||||
//
|
||||
// Check disk change
|
||||
@ -756,7 +729,7 @@ DetectMedia (
|
||||
if (Status == EFI_MEDIA_CHANGED) {
|
||||
FdcDev->BlkIo.Media->MediaId++;
|
||||
FdcDev->BlkIo.Media->MediaPresent = TRUE;
|
||||
bReset = TRUE;
|
||||
Reset = TRUE;
|
||||
} else if (Status == EFI_NO_MEDIA) {
|
||||
FdcDev->BlkIo.Media->MediaPresent = FALSE;
|
||||
} else if (Status != EFI_SUCCESS) {
|
||||
@ -779,15 +752,15 @@ DetectMedia (
|
||||
}
|
||||
}
|
||||
|
||||
if (FdcDev->BlkIo.Media->MediaPresent && (bReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {
|
||||
bReset = TRUE;
|
||||
if (FdcDev->BlkIo.Media->MediaPresent && (ReadOnlyLastTime != FdcDev->BlkIo.Media->ReadOnly)) {
|
||||
Reset = TRUE;
|
||||
}
|
||||
|
||||
if (bMediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {
|
||||
bReset = TRUE;
|
||||
if (MediaPresentLastTime != FdcDev->BlkIo.Media->MediaPresent) {
|
||||
Reset = TRUE;
|
||||
}
|
||||
|
||||
if (bReset) {
|
||||
if (Reset) {
|
||||
Status = gBS->ReinstallProtocolInterface (
|
||||
FdcDev->Handle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
@ -804,9 +777,9 @@ DetectMedia (
|
||||
}
|
||||
|
||||
/**
|
||||
Set the data rate and so on
|
||||
Set the data rate and so on.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev A pointer to FDC_BLK_IO_DEV
|
||||
|
||||
@retval EFI_SUCCESS success to set the data rate
|
||||
**/
|
||||
@ -837,9 +810,9 @@ Setup (
|
||||
}
|
||||
|
||||
/**
|
||||
Read or Write a number of blocks in the same cylinder
|
||||
Read or Write a number of blocks in the same cylinder.
|
||||
|
||||
@param FdcDev A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev A pointer to FDC_BLK_IO_DEV
|
||||
@param HostAddress device address
|
||||
@param Lba The starting logic block address to read from on the device
|
||||
@param NumberOfBlocks The number of block wanted to be read or write
|
||||
@ -952,7 +925,7 @@ ReadWriteDataSector (
|
||||
|
||||
MicroSecondDelay (50);
|
||||
Times = Times - 1;
|
||||
} while (Times);
|
||||
} while (Times >= 0);
|
||||
|
||||
if (Times == 0) {
|
||||
return EFI_TIMEOUT;
|
||||
@ -987,7 +960,7 @@ ReadWriteDataSector (
|
||||
}
|
||||
|
||||
/**
|
||||
Fill in FDD command's parameter
|
||||
Fill in FDD command's parameter.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Lba The starting logic block address to read from on the device
|
||||
@ -1011,7 +984,7 @@ FillPara (
|
||||
//
|
||||
// Fill the command parameter
|
||||
//
|
||||
if (FdcDev->Disk == FDC_DISK0) {
|
||||
if (FdcDev->Disk == FdcDisk0) {
|
||||
Command->DiskHeadSel = 0;
|
||||
} else {
|
||||
Command->DiskHeadSel = 1;
|
||||
@ -1028,23 +1001,22 @@ FillPara (
|
||||
}
|
||||
|
||||
/**
|
||||
Read result byte from Data Register of FDC
|
||||
Read result byte from Data Register of FDC.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer UINT8 *: Be used to save result byte read from FDC
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer Buffer to store the byte read from FDC
|
||||
|
||||
|
||||
@retval EFI_SUCCESS: Read result byte from FDC successfully
|
||||
@retval EFI_DEVICE_ERROR: The FDC is not ready to be read
|
||||
@retval EFI_SUCCESS Read result byte from FDC successfully
|
||||
@retval EFI_DEVICE_ERROR The FDC is not ready to be read
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
DataInByte (
|
||||
IN FDC_BLK_IO_DEV *FdcDev,
|
||||
IN OUT UINT8 *Pointer
|
||||
IN FDC_BLK_IO_DEV *FdcDev,
|
||||
OUT UINT8 *Pointer
|
||||
)
|
||||
{
|
||||
UINT8 data;
|
||||
UINT8 Data;
|
||||
|
||||
//
|
||||
// wait for 1ms and detect the FDC is ready to be read
|
||||
@ -1056,19 +1028,19 @@ DataInByte (
|
||||
//
|
||||
}
|
||||
|
||||
data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);
|
||||
Data = FdcReadPort (FdcDev, FDC_REGISTER_DTR);
|
||||
|
||||
//
|
||||
// Io delay
|
||||
//
|
||||
MicroSecondDelay (50);
|
||||
|
||||
*Pointer = data;
|
||||
*Pointer = Data;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Write command byte to Data Register of FDC
|
||||
Write command byte to Data Register of FDC.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Pointer Be used to save command byte written to FDC
|
||||
@ -1083,21 +1055,21 @@ DataOutByte (
|
||||
IN UINT8 *Pointer
|
||||
)
|
||||
{
|
||||
UINT8 data;
|
||||
UINT8 Data;
|
||||
|
||||
//
|
||||
// wait for 1ms and detect the FDC is ready to be written
|
||||
//
|
||||
if (EFI_ERROR (FddDRQReady (FdcDev, DATA_OUT, 1))) {
|
||||
//
|
||||
// Not ready
|
||||
//
|
||||
return EFI_DEVICE_ERROR;
|
||||
//
|
||||
// is not ready
|
||||
//
|
||||
}
|
||||
|
||||
data = *Pointer;
|
||||
Data = *Pointer;
|
||||
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DTR, data);
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DTR, Data);
|
||||
|
||||
//
|
||||
// Io delay
|
||||
@ -1108,8 +1080,7 @@ DataOutByte (
|
||||
}
|
||||
|
||||
/**
|
||||
Detect the specified floppy logic drive is busy or
|
||||
not within a period of time
|
||||
Detect the specified floppy logic drive is busy or not within a period of time.
|
||||
|
||||
@param FdcDev Indicate it is drive A or drive B
|
||||
@param TimeoutInSeconds the time period for waiting
|
||||
@ -1139,7 +1110,7 @@ FddWaitForBSYClear (
|
||||
//
|
||||
// set mask: for drive A set bit0 & bit4; for drive B set bit1 & bit4
|
||||
//
|
||||
Mask = (UINT8) ((FdcDev->Disk == FDC_DISK0 ? MSR_DAB : MSR_DBB) | MSR_CB);
|
||||
Mask = (UINT8) ((FdcDev->Disk == FdcDisk0 ? MSR_DAB : MSR_DBB) | MSR_CB);
|
||||
|
||||
Delay = ((TimeoutInSeconds * STALL_1_MSECOND) / 50) + 1;
|
||||
do {
|
||||
@ -1153,7 +1124,7 @@ FddWaitForBSYClear (
|
||||
|
||||
MicroSecondDelay (50);
|
||||
Delay = Delay - 1;
|
||||
} while (Delay);
|
||||
} while (Delay >= 0);
|
||||
|
||||
if (Delay == 0) {
|
||||
return EFI_TIMEOUT;
|
||||
@ -1164,7 +1135,7 @@ FddWaitForBSYClear (
|
||||
|
||||
/**
|
||||
|
||||
Routine Description: Determine whether FDC is ready to write or read
|
||||
Routine Description: Determine whether FDC is ready to write or read.
|
||||
|
||||
@param FdcDev Pointer to instance of FDC_BLK_IO_DEV
|
||||
@param Dio BOOLEAN: Indicate the FDC is waiting to write or read
|
||||
@ -1213,7 +1184,7 @@ FddDRQReady (
|
||||
// Stall for 50 us
|
||||
//
|
||||
Delay = Delay - 1;
|
||||
} while (Delay);
|
||||
} while (Delay >= 0);
|
||||
|
||||
if (Delay == 0) {
|
||||
return EFI_NOT_READY;
|
||||
@ -1226,8 +1197,7 @@ FddDRQReady (
|
||||
}
|
||||
|
||||
/**
|
||||
Set FDC control structure's attribute according to
|
||||
result
|
||||
Set FDC control structure's attribute according to result.
|
||||
|
||||
@param Result Point to result structure
|
||||
@param FdcDev FDC control structure
|
||||
@ -1261,14 +1231,14 @@ CheckResult (
|
||||
//
|
||||
// Check Status Register1
|
||||
//
|
||||
if (Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) {
|
||||
if ((Result->Status1 & (STS1_EN | STS1_DE | STS1_OR | STS1_ND | STS1_NW | STS1_MA)) != 0) {
|
||||
FdcDev->ControllerState->NeedRecalibrate = TRUE;
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
//
|
||||
// Check Status Register2
|
||||
//
|
||||
if (Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) {
|
||||
if ((Result->Status2 & (STS2_CM | STS2_DD | STS2_WC | STS2_BC | STS2_MD)) != 0) {
|
||||
FdcDev->ControllerState->NeedRecalibrate = TRUE;
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -1277,7 +1247,7 @@ CheckResult (
|
||||
}
|
||||
|
||||
/**
|
||||
Check the drive status information
|
||||
Check the drive status information.
|
||||
|
||||
@param StatusRegister3 the value of Status Register 3
|
||||
|
||||
@ -1290,7 +1260,7 @@ CheckStatus3 (
|
||||
IN UINT8 StatusRegister3
|
||||
)
|
||||
{
|
||||
if (StatusRegister3 & STS3_WP) {
|
||||
if ((StatusRegister3 & STS3_WP) != 0) {
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
|
||||
@ -1298,10 +1268,9 @@ CheckStatus3 (
|
||||
}
|
||||
|
||||
/**
|
||||
Calculate the number of block in the same cylinder
|
||||
according to LBA
|
||||
Calculate the number of block in the same cylinder according to LBA.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to FDC_BLK_IO_DEV
|
||||
@param LBA EFI_LBA: The starting logic block address
|
||||
@param NumberOfBlocks UINTN: The number of blocks
|
||||
|
||||
@ -1335,7 +1304,7 @@ GetTransferBlockCount (
|
||||
}
|
||||
|
||||
/**
|
||||
When the Timer(2s) off, turn the drive's motor off
|
||||
When the Timer(2s) off, turn the drive's motor off.
|
||||
|
||||
@param Event EFI_EVENT: Event(the timer) whose notification function is being
|
||||
invoked
|
||||
@ -1350,35 +1319,36 @@ FddTimerProc (
|
||||
)
|
||||
{
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
UINT8 data;
|
||||
UINT8 Data;
|
||||
|
||||
FdcDev = (FDC_BLK_IO_DEV *) Context;
|
||||
|
||||
//
|
||||
// Get the motor status
|
||||
//
|
||||
data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
|
||||
Data = FdcReadPort (FdcDev, FDC_REGISTER_DOR);
|
||||
|
||||
if (((FdcDev->Disk == FDC_DISK0) && ((data & 0x10) != 0x10)) ||
|
||||
((FdcDev->Disk == FDC_DISK1) && ((data & 0x21) != 0x21))
|
||||
if (((FdcDev->Disk == FdcDisk0) && ((Data & 0x10) != 0x10)) ||
|
||||
((FdcDev->Disk == FdcDisk1) && ((Data & 0x21) != 0x21))
|
||||
) {
|
||||
return ;
|
||||
}
|
||||
//
|
||||
// the motor is on, so need motor off
|
||||
//
|
||||
data = 0x0C;
|
||||
data = (UINT8) (data | (SELECT_DRV & FdcDev->Disk));
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, data);
|
||||
Data = 0x0C;
|
||||
Data = (UINT8) (Data | (SELECT_DRV & FdcDev->Disk));
|
||||
FdcWritePort (FdcDev, FDC_REGISTER_DOR, Data);
|
||||
MicroSecondDelay (500);
|
||||
}
|
||||
|
||||
/**
|
||||
Read I/O port for FDC
|
||||
Read an I/O port of FDC.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Offset The offset address of port
|
||||
@param[in] FdcDev A pointer to FDC_BLK_IO_DEV.
|
||||
@param[in] Offset The address offset of the I/O port.
|
||||
|
||||
@retval 8-bit data read from the I/O port.
|
||||
**/
|
||||
UINT8
|
||||
FdcReadPort (
|
||||
@ -1386,29 +1356,27 @@ FdcReadPort (
|
||||
IN UINT32 Offset
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 Data;
|
||||
|
||||
//
|
||||
// Call IsaIo
|
||||
//
|
||||
FdcDev->IsaIo->Io.Read (
|
||||
FdcDev->IsaIo,
|
||||
EfiIsaIoWidthUint8,
|
||||
FdcDev->BaseAddress + Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
Status = FdcDev->IsaIo->Io.Read (
|
||||
FdcDev->IsaIo,
|
||||
EfiIsaIoWidthUint8,
|
||||
FdcDev->BaseAddress + Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
/**
|
||||
Write I/O port for FDC
|
||||
Write an I/O port of FDC.
|
||||
|
||||
@param FdcDev FDC_BLK_IO_DEV *: A pointer to Data Structure FDC_BLK_IO_DEV
|
||||
@param Offset The offset address of port
|
||||
@param Data Value written to port
|
||||
|
||||
@param[in] FdcDev A pointer to FDC_BLK_IO_DEV
|
||||
@param[in] Offset The address offset of the I/O port
|
||||
@param[in] Data 8-bit Value written to the I/O port
|
||||
**/
|
||||
VOID
|
||||
FdcWritePort (
|
||||
@ -1417,16 +1385,15 @@ FdcWritePort (
|
||||
IN UINT8 Data
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Call IsaIo
|
||||
//
|
||||
FdcDev->IsaIo->Io.Write (
|
||||
FdcDev->IsaIo,
|
||||
EfiIsaIoWidthUint8,
|
||||
FdcDev->BaseAddress + Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
Status = FdcDev->IsaIo->Io.Write (
|
||||
FdcDev->IsaIo,
|
||||
EfiIsaIoWidthUint8,
|
||||
FdcDev->BaseAddress + Offset,
|
||||
1,
|
||||
&Data
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
#/** @file
|
||||
# Component description file for IsaFloppy module.
|
||||
#
|
||||
# ISA Floppy Driver
|
||||
# 1. Support two types diskette drive
|
||||
# 1.44M drive and 2.88M drive (and now only support 1.44M)
|
||||
# 2. Support two diskette drives
|
||||
# ISA Floppy Disk UEFI Driver conforming to the UEFI driver model
|
||||
#
|
||||
# 1. Support two types diskette drive
|
||||
# 1.44M drive and 2.88M drive (and now only support 1.44M)
|
||||
# 2. Support two diskette drives per floppy disk controller
|
||||
# 3. Use DMA channel 2 to transfer data
|
||||
# 4. Do not use interrupt
|
||||
# 5. Support diskette change line signal and write protect
|
||||
#
|
||||
# Conforming to EFI driver model
|
||||
#
|
||||
# Copyright (c) 2007 - 2009, Intel Corporation
|
||||
#
|
||||
@ -61,10 +60,13 @@
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
TimerLib
|
||||
PcdLib
|
||||
|
||||
[Protocols]
|
||||
gEfiIsaIoProtocolGuid # PROTOCOL TO_START
|
||||
gEfiBlockIoProtocolGuid # PROTOCOL BY_START
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
|
||||
|
||||
|
||||
[FeaturePcd.common]
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable # CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable # CONSUMES
|
||||
|
Loading…
x
Reference in New Issue
Block a user