mirror of https://github.com/acidanthera/audk.git
Import IsaFloppy Dxe and Pei in IntelFrameworkModulePkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3168 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
cba9012a92
commit
11f43dfd8b
|
@ -0,0 +1,239 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
ComponentName.c
|
||||
|
||||
Abstract:
|
||||
|
||||
--*/
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName = {
|
||||
IsaFloppyComponentNameGetDriverName,
|
||||
IsaFloppyComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
STATIC EFI_UNICODE_STRING_TABLE mIsaFloppyDriverNameTable[] = {
|
||||
{
|
||||
"eng",
|
||||
L"ISA Floppy Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
IsaFloppyComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Retrieves a Unicode string that is the user readable name of the EFI Driver.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
Language - A pointer to a three character ISO 639-2 language identifier.
|
||||
This is the language of the driver name that that the caller
|
||||
is requesting, and it must match one of the languages specified
|
||||
in SupportedLanguages. The number of languages supported by a
|
||||
driver is up to the driver writer.
|
||||
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.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The Unicode string for the Driver specified by This
|
||||
and the language specified by Language was returned
|
||||
in DriverName.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - DriverName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gIsaFloppyComponentName.SupportedLanguages,
|
||||
mIsaFloppyDriverNameTable,
|
||||
DriverName
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by an EFI Driver.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
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.
|
||||
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 that wish to retrieve the name of the
|
||||
bus controller. It will not be NULL for a bus driver
|
||||
that wishes to retrieve the name of a child controller.
|
||||
Language - A pointer to a three character ISO 639-2 language
|
||||
identifier. This is the language of the controller name
|
||||
that that the caller is requesting, and it must match one
|
||||
of the languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up to the
|
||||
driver writer.
|
||||
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 Language from the point of view of the
|
||||
driver specified by This.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The Unicode string for the user readable name in the
|
||||
language specified by Language for the driver
|
||||
specified by This was returned in DriverName.
|
||||
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
|
||||
EFI_HANDLE.
|
||||
EFI_INVALID_PARAMETER - Language is NULL.
|
||||
EFI_INVALID_PARAMETER - ControllerName is NULL.
|
||||
EFI_UNSUPPORTED - The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
EFI_UNSUPPORTED - The driver specified by This does not support the
|
||||
language specified by Language.
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
EFI_ISA_IO_PROTOCOL *IsaIoProtocol;
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (Status != EFI_ALREADY_STARTED) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Get the Block I/O Protocol on Controller
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlkIo,
|
||||
gFdcControllerDriver.DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the Floppy Disk Controller's Device structure
|
||||
//
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
|
||||
|
||||
return LookupUnicodeString (
|
||||
Language,
|
||||
gIsaFloppyComponentName.SupportedLanguages,
|
||||
FdcDev->ControllerNameTable,
|
||||
ControllerName
|
||||
);
|
||||
}
|
||||
|
||||
VOID
|
||||
AddName (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Add the component name for the floppy device
|
||||
|
||||
Arguments:
|
||||
|
||||
FdcDev - A pointer to the FDC_BLK_IO_DEV instance.
|
||||
|
||||
Returns:
|
||||
|
||||
None
|
||||
|
||||
--*/
|
||||
{
|
||||
CHAR16 FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN + 1];
|
||||
|
||||
StrCpy (FloppyDriveName, FLOPPY_DRIVE_NAME);
|
||||
FloppyDriveName[FLOPPY_DRIVE_NAME_ASCII_LEN - 1] = (CHAR16) (L'0' + FdcDev->Disk);
|
||||
AddUnicodeString (
|
||||
"eng",
|
||||
gIsaFloppyComponentName.SupportedLanguages,
|
||||
&FdcDev->ControllerNameTable,
|
||||
FloppyDriveName
|
||||
);
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
Module Name:
|
||||
|
||||
ComponentName.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#ifndef _ISA_FLOPPY_COMPONENT_NAME_H
|
||||
#define _ISA_FLOPPY_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))
|
||||
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gIsaFloppyComponentName;
|
||||
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
IsaFloppyComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
This - GC_TODO: add argument description
|
||||
Language - GC_TODO: add argument description
|
||||
DriverName - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
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
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
This - GC_TODO: add argument description
|
||||
ControllerHandle - GC_TODO: add argument description
|
||||
ChildHandle - GC_TODO: add argument description
|
||||
Language - GC_TODO: add argument description
|
||||
ControllerName - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
VOID
|
||||
AddName (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
FdcDev - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,55 @@
|
|||
/**@file
|
||||
Entry Point Source file.
|
||||
|
||||
This file contains the user entry point
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation.
|
||||
All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
**/
|
||||
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
/**
|
||||
The user Entry Point for module IsaFloppy. The user code starts with this function.
|
||||
|
||||
@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.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
InitializeIsaFloppy(
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install driver model protocol(s).
|
||||
//
|
||||
Status = EfiLibInstallAllDriverProtocols (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gFdcControllerDriver,
|
||||
ImageHandle,
|
||||
&gIsaFloppyComponentName,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
|
@ -0,0 +1,451 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved. <BR>
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
Module Name:
|
||||
|
||||
IsaFloppy.c
|
||||
|
||||
Abstract:
|
||||
|
||||
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
|
||||
|
||||
conforming to EFI driver model
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
LIST_ENTRY gControllerHead = INITIALIZE_LIST_HEAD_VARIABLE(gControllerHead);
|
||||
|
||||
//
|
||||
// ISA Floppy Driver Binding Protocol
|
||||
//
|
||||
EFI_DRIVER_BINDING_PROTOCOL gFdcControllerDriver = {
|
||||
FdcControllerDriverSupported,
|
||||
FdcControllerDriverStart,
|
||||
FdcControllerDriverStop,
|
||||
0xa,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcControllerDriverSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
ControllerDriver Protocol Method
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: Controller - add argument and description to function comment
|
||||
// GC_TODO: RemainingDevicePath - add argument and description to function comment
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_ISA_IO_PROTOCOL *IsaIo;
|
||||
|
||||
//
|
||||
// Open the ISA I/O Protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
(VOID **) &IsaIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Use the ISA I/O Protocol to see if Controller is a Floppy Disk Controller
|
||||
//
|
||||
Status = EFI_SUCCESS;
|
||||
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
//
|
||||
// Close the ISA I/O Protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcControllerDriverStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: Controller - add argument and description to function comment
|
||||
// GC_TODO: RemainingDevicePath - add argument and description to function comment
|
||||
{
|
||||
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;
|
||||
|
||||
//
|
||||
// Open the device path protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &ParentDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Report enable progress code
|
||||
//
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_PROGRESS_CODE,
|
||||
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_ENABLE,
|
||||
ParentDevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Open the ISA I/O Protocol
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
(VOID **) &IsaIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Allocate the Floppy Disk Controller's Device structure
|
||||
//
|
||||
FdcDev = AllocateZeroPool (sizeof (FDC_BLK_IO_DEV));
|
||||
if (FdcDev == NULL) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Initialize the Floppy Disk Controller's Device structure
|
||||
//
|
||||
FdcDev->Signature = FDC_BLK_IO_DEV_SIGNATURE;
|
||||
FdcDev->Handle = Controller;
|
||||
FdcDev->IsaIo = IsaIo;
|
||||
FdcDev->Disk = (EFI_FDC_DISK) IsaIo->ResourceList->Device.UID;
|
||||
FdcDev->Cache = NULL;
|
||||
FdcDev->Event = NULL;
|
||||
FdcDev->ControllerState = NULL;
|
||||
FdcDev->DevicePath = ParentDevicePath;
|
||||
|
||||
ADD_FLOPPY_NAME (FdcDev);
|
||||
|
||||
//
|
||||
// Look up the base address of the Floppy Disk Controller
|
||||
//
|
||||
for (Index = 0; FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type != EfiIsaAcpiResourceEndOfList; Index++) {
|
||||
if (FdcDev->IsaIo->ResourceList->ResourceItem[Index].Type == EfiIsaAcpiResourceIo) {
|
||||
FdcDev->BaseAddress = (UINT16) FdcDev->IsaIo->ResourceList->ResourceItem[Index].StartRange;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Maintain the list of controller list
|
||||
//
|
||||
Found = FALSE;
|
||||
List = gControllerHead.ForwardLink;
|
||||
while (List != &gControllerHead) {
|
||||
FdcDev->ControllerState = FLOPPY_CONTROLLER_FROM_LIST_ENTRY (List);
|
||||
if (FdcDev->BaseAddress == FdcDev->ControllerState->BaseAddress) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
List = List->ForwardLink;
|
||||
}
|
||||
|
||||
if (!Found) {
|
||||
//
|
||||
// The Controller is new
|
||||
//
|
||||
FdcDev->ControllerState = AllocatePool (sizeof (FLOPPY_CONTROLLER_CONTEXT));
|
||||
if (FdcDev->ControllerState == NULL) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
FdcDev->ControllerState->Signature = FLOPPY_CONTROLLER_CONTEXT_SIGNATURE;
|
||||
FdcDev->ControllerState->FddResetPerformed = FALSE;
|
||||
FdcDev->ControllerState->NeedRecalibrate = FALSE;
|
||||
FdcDev->ControllerState->BaseAddress = FdcDev->BaseAddress;
|
||||
FdcDev->ControllerState->NumberOfDrive = 0;
|
||||
|
||||
InsertTailList (&gControllerHead, &FdcDev->ControllerState->Link);
|
||||
}
|
||||
//
|
||||
// Create a timer event for each Floppd Disk Controller.
|
||||
// This timer event is used to control the motor on and off
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
FddTimerProc,
|
||||
FdcDev,
|
||||
&FdcDev->Event
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Reset the Floppy Disk Controller
|
||||
//
|
||||
if (!FdcDev->ControllerState->FddResetPerformed) {
|
||||
FdcDev->ControllerState->FddResetPerformed = TRUE;
|
||||
FdcDev->ControllerState->FddResetStatus = FddReset (FdcDev);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (FdcDev->ControllerState->FddResetStatus)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_PROGRESS_CODE,
|
||||
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_PRESENCE_DETECT,
|
||||
ParentDevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Discover the Floppy Drive
|
||||
//
|
||||
Status = DiscoverFddDevice (FdcDev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Install protocol interfaces for the serial device.
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Controller,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
&FdcDev->BlkIo,
|
||||
NULL
|
||||
);
|
||||
|
||||
FdcDev->ControllerState->NumberOfDrive++;
|
||||
|
||||
Done:
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_ERROR_CODE | EFI_ERROR_MINOR,
|
||||
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_EC_CONTROLLER_ERROR,
|
||||
ParentDevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Close the device path protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Close the ISA I/O Protocol
|
||||
//
|
||||
if (IsaIo != NULL) {
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcControllerDriverStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Arguments:
|
||||
|
||||
Returns:
|
||||
|
||||
--*/
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: Controller - add argument and description to function comment
|
||||
// GC_TODO: NumberOfChildren - add argument and description to function comment
|
||||
// GC_TODO: ChildHandleBuffer - add argument and description to function comment
|
||||
// GC_TODO: EFI_SUCCESS - add return value to function comment
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BLOCK_IO_PROTOCOL *BlkIo;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
|
||||
//
|
||||
// Get the Block I/O Protocol on Controller
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlkIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the Floppy Disk Controller's Device structure
|
||||
//
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (BlkIo);
|
||||
|
||||
//
|
||||
// Report disable progress code
|
||||
//
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_PROGRESS_CODE,
|
||||
EFI_PERIPHERAL_REMOVABLE_MEDIA | EFI_P_PC_DISABLE,
|
||||
FdcDev->DevicePath
|
||||
);
|
||||
|
||||
//
|
||||
// Turn the motor off on the Floppy Disk Controller
|
||||
//
|
||||
FddTimerProc (FdcDev->Event, FdcDev);
|
||||
|
||||
//
|
||||
// Uninstall the Block I/O Protocol
|
||||
//
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
Controller,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
&FdcDev->BlkIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Close the device path protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Close the ISA I/O Protocol
|
||||
//
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiIsaIoProtocolGuid,
|
||||
This->DriverBindingHandle,
|
||||
Controller
|
||||
);
|
||||
|
||||
//
|
||||
// Free the controller list if needed
|
||||
//
|
||||
FdcDev->ControllerState->NumberOfDrive--;
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
FreeUnicodeStringTable (FdcDev->ControllerNameTable);
|
||||
gBS->FreePool (FdcDev);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,109 @@
|
|||
#/** @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
|
||||
# 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.
|
||||
#
|
||||
# All rights reserved.
|
||||
# This software and associated documentation (if any) is furnished
|
||||
# under a license and may only be used or copied in accordance
|
||||
# with the terms of the license. Except as permitted by such
|
||||
# license, no part of this software or documentation may be
|
||||
# reproduced, stored in a retrieval system, or transmitted in any
|
||||
# form or by any means without the express written consent of
|
||||
# Intel Corporation.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Defines Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = IsaFloppy
|
||||
FILE_GUID = 0abd8284-6da3-4616-971a-83a5148067ba
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = InitializeIsaFloppy
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
# DRIVER_BINDING = gFdcControllerDriver
|
||||
# COMPONENT_NAME = gIsaFloppyComponentName
|
||||
# Create Event Guid C Name: Event Type: EVENT_TYPE_PERIODIC_TIMER
|
||||
#
|
||||
#
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Sources Section - list of files that are required for the build to succeed.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Sources.common]
|
||||
ComponentName.c
|
||||
ComponentName.h
|
||||
IsaFloppyCtrl.c
|
||||
IsaFloppyBlock.c
|
||||
IsaFloppy.c
|
||||
IsaFloppy.h
|
||||
EntryPoint.c
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Package Dependency Section - list of Package files that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class Section - list of Library Classes that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[LibraryClasses]
|
||||
ReportStatusCodeLib
|
||||
UefiBootServicesTableLib
|
||||
MemoryAllocationLib
|
||||
BaseMemoryLib
|
||||
UefiLib
|
||||
BaseLib
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
TimerLib
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Protocol C Name Section - list of Protocol and Protocol Notify C Names
|
||||
# that this module uses or produces.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Protocols]
|
||||
gEfiIsaIoProtocolGuid # PROTOCOL TO_START
|
||||
gEfiBlockIoProtocolGuid # PROTOCOL BY_START
|
||||
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>IsaFloppy</ModuleName>
|
||||
<ModuleType>DXE_DRIVER</ModuleType>
|
||||
<GuidValue>0abd8284-6da3-4616-971a-83a5148067ba</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component description file for IsaFloppy module.</Abstract>
|
||||
<Description>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
|
||||
|
||||
Conforming to EFI driver model</Description>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
|
||||
<License>All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>IsaFloppy</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>TimerLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverModelLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiDriverEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>MemoryAllocationLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>UefiBootServicesTableLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>ReportStatusCodeLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>IsaFloppy.h</Filename>
|
||||
<Filename>IsaFloppy.c</Filename>
|
||||
<Filename>IsaFloppyBlock.c</Filename>
|
||||
<Filename>IsaFloppyCtrl.c</Filename>
|
||||
<Filename>ComponentName.h</Filename>
|
||||
<Filename>ComponentName.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
|
||||
</PackageDependencies>
|
||||
<Protocols>
|
||||
<Protocol Usage="TO_START">
|
||||
<ProtocolCName>gEfiDevicePathProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="BY_START">
|
||||
<ProtocolCName>gEfiBlockIoProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
<Protocol Usage="TO_START">
|
||||
<ProtocolCName>gEfiIsaIoProtocolGuid</ProtocolCName>
|
||||
</Protocol>
|
||||
</Protocols>
|
||||
<Events>
|
||||
<CreateEvents>
|
||||
<EventTypes Usage="ALWAYS_CONSUMED">
|
||||
<EventType>EVENT_TYPE_PERIODIC_TIMER</EventType>
|
||||
<HelpText>Timer event for each Floppd Disk Controller to control the motor on and off.</HelpText>
|
||||
</EventTypes>
|
||||
</CreateEvents>
|
||||
</Events>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<DriverBinding>gFdcControllerDriver</DriverBinding>
|
||||
<ComponentName>gIsaFloppyComponentName</ComponentName>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
|
@ -0,0 +1,458 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved. <BR>
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
Module Name:
|
||||
|
||||
IsaFloppyBlock.c
|
||||
|
||||
Abstract:
|
||||
|
||||
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
|
||||
|
||||
Implement the Block IO interface
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
|
||||
#include "IsaFloppy.h"
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcReset (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description: Reset the Floppy Logic Drive, call the FddReset function
|
||||
Parameters:
|
||||
This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
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
|
||||
Returns:
|
||||
EFI_SUCCESS: The Floppy Logic Drive is reset
|
||||
EFI_DEVICE_ERROR: The Floppy Logic Drive is not functioning correctly
|
||||
and can not be reset
|
||||
|
||||
--*/
|
||||
// GC_TODO: function comment is missing 'Arguments:'
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: ExtendedVerification - add argument and description to function comment
|
||||
{
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
|
||||
//
|
||||
// Reset the Floppy Disk Controller
|
||||
//
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (This);
|
||||
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_PROGRESS_CODE,
|
||||
EFI_P_PC_RESET | EFI_PERIPHERAL_REMOVABLE_MEDIA,
|
||||
FdcDev->DevicePath
|
||||
);
|
||||
|
||||
return FddReset (FdcDev);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FddFlushBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
Parameters:
|
||||
This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
Returns:
|
||||
EFI_SUCCESS:
|
||||
|
||||
--*/
|
||||
// GC_TODO: function comment is missing 'Arguments:'
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
{
|
||||
//
|
||||
// Not supported yet
|
||||
//
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
FddReportStatus (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN BOOLEAN Read
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
This - GC_TODO: add argument description
|
||||
Read - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (This);
|
||||
|
||||
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
|
||||
EFI_ERROR_CODE,
|
||||
((Read) ? EFI_P_EC_INPUT_ERROR : EFI_P_EC_OUTPUT_ERROR) | EFI_PERIPHERAL_REMOVABLE_MEDIA,
|
||||
FdcDev->DevicePath
|
||||
);
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FddReadBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description: Read the requested number of blocks from the device
|
||||
Parameters:
|
||||
This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
MediaId UINT32: The media id that the read request is for
|
||||
LBA EFI_LBA: The starting logic block address to read from on the device
|
||||
BufferSize UINTN: The size of the Buffer in bytes
|
||||
Buffer VOID *: A pointer to the destination buffer for the data
|
||||
Returns:
|
||||
EFI_SUCCESS: The data was read correctly from the device
|
||||
EFI_DEVICE_ERROR:The device reported an error while attempting to perform
|
||||
the read operation
|
||||
EFI_NO_MEDIA: There is no media in the device
|
||||
EFI_MEDIA_CHANGED: The MediaId is not for the current media
|
||||
EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
|
||||
intrinsic block size of the device
|
||||
EFI_INVALID_PARAMETER:The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment
|
||||
|
||||
--*/
|
||||
// GC_TODO: function comment is missing 'Arguments:'
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: MediaId - add argument and description to function comment
|
||||
// GC_TODO: LBA - add argument and description to function comment
|
||||
// GC_TODO: BufferSize - add argument and description to function comment
|
||||
// GC_TODO: Buffer - add argument and description to function comment
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, READ, Buffer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FddReportStatus (This, TRUE);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FddWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description: Write a specified number of blocks to the device
|
||||
Parameters:
|
||||
This EFI_BLOCK_IO *: A pointer to the Block I/O protocol interface
|
||||
MediaId UINT32: The media id that the write request is for
|
||||
LBA EFI_LBA: The starting logic block address to be written
|
||||
BufferSize UINTN: The size in bytes in Buffer
|
||||
Buffer VOID *: A pointer to the source buffer for the data
|
||||
Returns :
|
||||
EFI_SUCCESS: The data were written correctly to the device
|
||||
EFI_WRITE_PROTECTED: The device can not be written to
|
||||
EFI_NO_MEDIA: There is no media in the device
|
||||
EFI_MEDIA_CHANGED: The MediaId is not for the current media
|
||||
EFI_DEVICE_ERROR: The device reported an error while attempting to perform
|
||||
the write operation
|
||||
EFI_BAD_BUFFER_SIZE: The BufferSize parameter is not a multiple of the
|
||||
intrinsic block size of the device
|
||||
EFI_INVALID_PARAMETER:The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment
|
||||
|
||||
--*/
|
||||
// GC_TODO: function comment is missing 'Arguments:'
|
||||
// GC_TODO: function comment is missing 'Returns:'
|
||||
// GC_TODO: This - add argument and description to function comment
|
||||
// GC_TODO: MediaId - add argument and description to function comment
|
||||
// GC_TODO: LBA - add argument and description to function comment
|
||||
// GC_TODO: BufferSize - add argument and description to function comment
|
||||
// GC_TODO: Buffer - add argument and description to function comment
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = FddReadWriteBlocks (This, MediaId, LBA, BufferSize, WRITE, Buffer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FddReportStatus (This, FALSE);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
EFI_STATUS
|
||||
FddReadWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA LBA,
|
||||
IN UINTN BufferSize,
|
||||
IN BOOLEAN Operation,
|
||||
OUT VOID *Buffer
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
This - GC_TODO: add argument description
|
||||
MediaId - GC_TODO: add argument description
|
||||
LBA - GC_TODO: add argument description
|
||||
BufferSize - GC_TODO: add argument description
|
||||
Operation - GC_TODO: add argument description
|
||||
Buffer - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
EFI_NO_MEDIA - GC_TODO: Add description for return value
|
||||
EFI_MEDIA_CHANGED - GC_TODO: Add description for return value
|
||||
EFI_WRITE_PROTECTED - GC_TODO: Add description for return value
|
||||
EFI_BAD_BUFFER_SIZE - GC_TODO: Add description for return value
|
||||
EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
EFI_INVALID_PARAMETER - GC_TODO: Add description for return value
|
||||
EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
EFI_DEVICE_ERROR - GC_TODO: Add description for return value
|
||||
EFI_SUCCESS - GC_TODO: Add description for return value
|
||||
|
||||
--*/
|
||||
{
|
||||
EFI_BLOCK_IO_MEDIA *Media;
|
||||
FDC_BLK_IO_DEV *FdcDev;
|
||||
UINTN BlockSize;
|
||||
UINTN NumberOfBlocks;
|
||||
UINTN BlockCount;
|
||||
EFI_STATUS Status;
|
||||
//
|
||||
// EFI_STATUS CacheStatus;
|
||||
//
|
||||
EFI_LBA LBA0;
|
||||
UINT8 *Pointer;
|
||||
|
||||
//
|
||||
// Get the intrinsic block size
|
||||
//
|
||||
Media = This->Media;
|
||||
BlockSize = Media->BlockSize;
|
||||
FdcDev = FDD_BLK_IO_FROM_THIS (This);
|
||||
|
||||
if (Operation == WRITE) {
|
||||
if (LBA == 0) {
|
||||
FdcFreeCache (FdcDev);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check the Parameter is valid
|
||||
//
|
||||
if (Buffer == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (BufferSize == 0) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Set the drive motor on
|
||||
//
|
||||
Status = MotorOn (FdcDev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
//
|
||||
// Check to see if media can be detected
|
||||
//
|
||||
Status = DetectMedia (FdcDev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
MotorOff (FdcDev);
|
||||
FdcFreeCache (FdcDev);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
//
|
||||
// Check to see if media is present
|
||||
//
|
||||
if (!(Media->MediaPresent)) {
|
||||
MotorOff (FdcDev);
|
||||
FdcFreeCache (FdcDev);
|
||||
|
||||
/*
|
||||
if (FdcDev->Cache) {
|
||||
gBS->FreePool (FdcDev->Cache);
|
||||
FdcDev->Cache = NULL;
|
||||
}
|
||||
*/
|
||||
return EFI_NO_MEDIA;
|
||||
}
|
||||
//
|
||||
// Check to see if media has been changed
|
||||
//
|
||||
if (MediaId != Media->MediaId) {
|
||||
MotorOff (FdcDev);
|
||||
FdcFreeCache (FdcDev);
|
||||
return EFI_MEDIA_CHANGED;
|
||||
}
|
||||
|
||||
if (Operation == WRITE) {
|
||||
if (Media->ReadOnly) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_WRITE_PROTECTED;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Check the parameters for this read/write operation
|
||||
//
|
||||
if (BufferSize % BlockSize != 0) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
if (LBA > Media->LastBlock) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (((BufferSize / BlockSize) + LBA - 1) > Media->LastBlock) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Operation == READ) {
|
||||
//
|
||||
// See if the data that is being read is already in the cache
|
||||
//
|
||||
if (FdcDev->Cache) {
|
||||
if (LBA == 0 && BufferSize == BlockSize) {
|
||||
MotorOff (FdcDev);
|
||||
CopyMem ((UINT8 *) Buffer, (UINT8 *) FdcDev->Cache, BlockSize);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// Set up Floppy Disk Controller
|
||||
//
|
||||
Status = Setup (FdcDev);
|
||||
if (EFI_ERROR (Status)) {
|
||||
MotorOff (FdcDev);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
NumberOfBlocks = BufferSize / BlockSize;
|
||||
LBA0 = LBA;
|
||||
Pointer = Buffer;
|
||||
|
||||
//
|
||||
// read blocks in the same cylinder.
|
||||
// in a cylinder , there are 18 * 2 = 36 blocks
|
||||
//
|
||||
BlockCount = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);
|
||||
while ((BlockCount != 0) && !EFI_ERROR (Status)) {
|
||||
Status = ReadWriteDataSector (FdcDev, Buffer, LBA, BlockCount, Operation);
|
||||
if (EFI_ERROR (Status)) {
|
||||
MotorOff (FdcDev);
|
||||
FddReset (FdcDev);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
LBA += BlockCount;
|
||||
NumberOfBlocks -= BlockCount;
|
||||
Buffer = (VOID *) ((UINTN) Buffer + BlockCount * BlockSize);
|
||||
BlockCount = GetTransferBlockCount (FdcDev, LBA, NumberOfBlocks);
|
||||
}
|
||||
|
||||
Buffer = Pointer;
|
||||
|
||||
//
|
||||
// Turn the motor off
|
||||
//
|
||||
MotorOff (FdcDev);
|
||||
|
||||
if (Operation == READ) {
|
||||
//
|
||||
// Cache the data read
|
||||
//
|
||||
if (LBA0 == 0 && !FdcDev->Cache) {
|
||||
FdcDev->Cache = AllocateCopyPool (BlockSize, Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
VOID
|
||||
FdcFreeCache (
|
||||
IN FDC_BLK_IO_DEV *FdcDev
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
GC_TODO: Add function description
|
||||
|
||||
Arguments:
|
||||
|
||||
FdcDev - GC_TODO: add argument description
|
||||
|
||||
Returns:
|
||||
|
||||
GC_TODO: add return values
|
||||
|
||||
--*/
|
||||
{
|
||||
if (FdcDev->Cache) {
|
||||
gBS->FreePool (FdcDev->Cache);
|
||||
FdcDev->Cache = NULL;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,215 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
fdc.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Revision History
|
||||
--*/
|
||||
|
||||
#ifndef _PEI_RECOVERY_FDC_H
|
||||
#define _PEI_RECOVERY_FDC_H
|
||||
|
||||
//
|
||||
// FDC Registers
|
||||
//
|
||||
#define FDC_REGISTER_DOR 2 // 0x3F2 //Digital Output Register
|
||||
#define FDC_REGISTER_MSR 4 // 0x3F4 //Main Status Register
|
||||
#define FDC_REGISTER_DTR 5 // 0x3F5 //Data Register
|
||||
#define FDC_REGISTER_CCR 7 // 0x3F7 //Configuration Control Register(data rate select)
|
||||
#define FDC_REGISTER_DIR 7 // 0x3F7 //Digital Input Register(diskchange)
|
||||
//
|
||||
// FDC Register Bit Definitions
|
||||
//
|
||||
//
|
||||
// Digital Out Register(WO)
|
||||
//
|
||||
#define SELECT_DRV BIT0 // Select Drive: 0=A 1=B
|
||||
#define RESET_FDC BIT2 // Reset FDC
|
||||
#define INT_DMA_ENABLE BIT3 // Enable Int & DMA
|
||||
#define DRVA_MOTOR_ON BIT4 // Turn On Drive A Motor
|
||||
#define DRVB_MOTOR_ON BIT5 // Turn On Drive B Motor
|
||||
//
|
||||
// Main Status Register(RO)
|
||||
//
|
||||
#define MSR_DAB BIT0 // Drive A Busy
|
||||
#define MSR_DBB BIT1 // Drive B Busy
|
||||
#define MSR_CB BIT4 // FDC Busy
|
||||
#define MSR_NDM BIT5 // Non-DMA Mode
|
||||
#define MSR_DIO BIT6 // Data Input/Output
|
||||
#define MSR_RQM BIT7 // Request For Master
|
||||
//
|
||||
// Configuration Control Register(WO)
|
||||
//
|
||||
#define CCR_DRC (BIT0 | BIT1) // Data Rate select
|
||||
//
|
||||
// Digital Input Register(RO)
|
||||
//
|
||||
#define DIR_DCL BIT7 // Disk change line
|
||||
#define DRC_500KBS 0x0 // 500K
|
||||
#define DRC_300KBS 0x01 // 300K
|
||||
#define DRC_250KBS 0x02 // 250K
|
||||
//
|
||||
// FDC Command Code
|
||||
//
|
||||
#define READ_DATA_CMD 0x06
|
||||
#define SEEK_CMD 0x0F
|
||||
#define RECALIBRATE_CMD 0x07
|
||||
#define SENSE_INT_STATUS_CMD 0x08
|
||||
#define SPECIFY_CMD 0x03
|
||||
#define SENSE_DRV_STATUS_CMD 0x04
|
||||
|
||||
//
|
||||
// CMD_MT: Multi_Track Selector
|
||||
// when set , this flag selects the multi-track operating mode.
|
||||
// In this mode, the FDC treats a complete cylinder under head0 and 1 as a single track
|
||||
//
|
||||
#define CMD_MT BIT7
|
||||
|
||||
//
|
||||
// CMD_MFM: MFM/FM Mode Selector
|
||||
// A one selects the double density(MFM) mode
|
||||
// A zero selects single density (FM) mode
|
||||
//
|
||||
#define CMD_MFM BIT6
|
||||
|
||||
//
|
||||
// CMD_SK: Skip Flag
|
||||
// When set to 1, sectors containing a deleted data address mark will automatically be skipped
|
||||
// during the execution of Read Data.
|
||||
// When set to 0, the sector is read or written the same as the read and write commands.
|
||||
//
|
||||
#define CMD_SK BIT5
|
||||
|
||||
//
|
||||
// FDC Status Register Bit Definitions
|
||||
//
|
||||
//
|
||||
// Status Register 0
|
||||
//
|
||||
#define STS0_IC (BIT7 | BIT6) // Interrupt Code
|
||||
#define STS0_SE BIT5 // Seek End: the FDC completed a seek or recalibrate command
|
||||
#define STS0_EC BIT4 // Equipment Check
|
||||
#define STS0_NR BIT3 // Not Ready(unused), this bit is always 0
|
||||
#define STS0_HA BIT2 // Head Address: the current head address
|
||||
// STS0_US1 & STS0_US0: Drive Select(the current selected drive)
|
||||
//
|
||||
#define STS0_US1 BIT1 // Unit Select1
|
||||
#define STS0_US0 BIT0 // Unit Select0
|
||||
//
|
||||
// Status Register 1
|
||||
//
|
||||
#define STS1_EN BIT7 // End of Cylinder
|
||||
// BIT6 is unused
|
||||
//
|
||||
#define STS1_DE BIT5 // Data Error: The FDC detected a CRC error in either the ID field or data field of a sector
|
||||
#define STS1_OR BIT4 // Overrun/Underrun: Becomes set if FDC does not receive CPU or DMA service within the required time interval
|
||||
// BIT3 is unused
|
||||
//
|
||||
#define STS1_ND BIT2 // No data
|
||||
#define STS1_NW BIT1 // Not Writable
|
||||
#define STS1_MA BIT0 // Missing Address Mark
|
||||
//
|
||||
// Status Register 2
|
||||
//
|
||||
// BIT7 is unused
|
||||
//
|
||||
#define STS2_CM BIT6 // Control Mark
|
||||
#define STS2_DD BIT5 // Data Error in Data Field: The FDC detected a CRC error in the data field
|
||||
#define STS2_WC BIT4 // Wrong Cylinder: The track address from sector ID field is different from the track address maintained inside FDC
|
||||
// #define STS2_SH BIT3 // Scan Equal Hit
|
||||
// #define STS2_SN BIT2 // Scan Not Satisfied
|
||||
// BIT3 is unused
|
||||
// BIT2 is unused
|
||||
//
|
||||
#define STS2_BC BIT1 // Bad Cylinder
|
||||
#define STS2_MD BIT0 // Missing Address Mark in DataField
|
||||
// Status Register 3
|
||||
// #define STS3_FT BIT7 // Fault
|
||||
// BIT7 is unused
|
||||
//
|
||||
#define STS3_WP BIT6 // Write Protected
|
||||
// #define STS3_RDY BIT5 // Ready
|
||||
// BIT5 is unused
|
||||
//
|
||||
#define STS3_T0 BIT4 // Track 0
|
||||
// #define STS3_TS BIT3 // Two Side
|
||||
// BIT3 is unused
|
||||
//
|
||||
#define STS3_HD BIT2 // Head Address
|
||||
// STS3_US1 & STS3_US0 : Drive Select
|
||||
//
|
||||
#define STS3_US1 BIT1 // Unit Select1
|
||||
#define STS3_US0 BIT0 // Unit Select0
|
||||
//
|
||||
// Status Register 0 Interrupt Code Description
|
||||
//
|
||||
#define IC_NT 0x0 // Normal Termination of Command
|
||||
#define IC_AT 0x40 // Abnormal Termination of Command
|
||||
#define IC_IC 0x80 // Invalid Command
|
||||
#define IC_ATRC 0xC0 // Abnormal Termination caused by Polling
|
||||
typedef struct {
|
||||
UINT8 EOT; // End of track
|
||||
UINT8 GPL; // Gap length
|
||||
UINT8 DTL; // Data length
|
||||
UINT8 Number; // Number of bytes per sector
|
||||
UINT8 MaxTrackNum;
|
||||
UINT8 MotorStartTime;
|
||||
UINT8 MotorOffTime;
|
||||
UINT8 HeadSettlingTime;
|
||||
UINT8 DataTransferRate;
|
||||
} DISKET_PARA_TABLE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 CommandCode;
|
||||
UINT8 DiskHeadSel;
|
||||
UINT8 Cylinder;
|
||||
UINT8 Head;
|
||||
UINT8 Sector;
|
||||
UINT8 Number;
|
||||
UINT8 EndOfTrack;
|
||||
UINT8 GapLength;
|
||||
UINT8 DataLength;
|
||||
} FDC_COMMAND_PACKET1;
|
||||
|
||||
typedef struct {
|
||||
UINT8 CommandCode;
|
||||
UINT8 DiskHeadSel;
|
||||
} FDC_COMMAND_PACKET2;
|
||||
|
||||
typedef struct {
|
||||
UINT8 CommandCode;
|
||||
UINT8 SrtHut;
|
||||
UINT8 HltNd;
|
||||
} FDC_SPECIFY_CMD;
|
||||
|
||||
typedef struct {
|
||||
UINT8 CommandCode;
|
||||
UINT8 DiskHeadSel;
|
||||
UINT8 NewCylinder;
|
||||
} FDC_SEEK_CMD;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Status0;
|
||||
UINT8 Status1;
|
||||
UINT8 Status2;
|
||||
UINT8 C;
|
||||
UINT8 H;
|
||||
UINT8 S;
|
||||
UINT8 Number;
|
||||
} FDC_RESULT_PACKET;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,34 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006, Intel Corporation. All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
floppypeim.dxs
|
||||
|
||||
Abstract:
|
||||
|
||||
Dependency expression file for Status Code PEIM.
|
||||
|
||||
--*/
|
||||
|
||||
#include <PeimDepex.h>
|
||||
|
||||
DEPENDENCY_START
|
||||
EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID AND
|
||||
EFI_PEI_FV_FILE_LOADER_GUID AND
|
||||
EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI
|
||||
DEPENDENCY_END
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.
|
||||
|
||||
|
||||
Module Name:
|
||||
|
||||
FloppyPeim.h
|
||||
|
||||
Abstract:
|
||||
|
||||
|
||||
Revision History
|
||||
--*/
|
||||
|
||||
#ifndef _RECOVERY_FLOPPY_H
|
||||
#define _RECOVERY_FLOPPY_H
|
||||
|
||||
//
|
||||
// The package level header files this module uses
|
||||
//
|
||||
#include <PiPei.h>
|
||||
#include <FrameworkPei.h>
|
||||
|
||||
#include <Ppi/BlockIo.h>
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PeimEntryPoint.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
|
||||
#include "Fdc.h"
|
||||
//
|
||||
// define some macro
|
||||
//
|
||||
#define STALL_1_SECOND 1000000
|
||||
#define STALL_1_MSECOND 1000
|
||||
|
||||
#define DATA_IN 1
|
||||
#define DATA_OUT 0
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
|
||||
typedef enum {
|
||||
_360K_360K = 0,
|
||||
_360K_1200K,
|
||||
_1200K_1200K,
|
||||
_720K_720K,
|
||||
_720K_1440K,
|
||||
_1440K_1440K,
|
||||
_720K_2880K,
|
||||
_1440K_2880K,
|
||||
_2880K_2880K
|
||||
} FDC_DISKET_TYPE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 DevPos;
|
||||
UINT8 Pcn;
|
||||
BOOLEAN MotorOn;
|
||||
BOOLEAN NeedRecalibrate;
|
||||
FDC_DISKET_TYPE Type;
|
||||
EFI_PEI_BLOCK_IO_MEDIA MediaInfo;
|
||||
} PEI_FLOPPY_DEVICE_INFO;
|
||||
|
||||
#define FDC_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('F', 'b', 'i', 'o')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
EFI_PEI_RECOVERY_BLOCK_IO_PPI FdcBlkIo;
|
||||
EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;
|
||||
UINTN DeviceCount;
|
||||
PEI_FLOPPY_DEVICE_INFO DeviceInfo[2];
|
||||
} FDC_BLK_IO_DEV;
|
||||
|
||||
#define PEI_RECOVERY_FDC_FROM_BLKIO_THIS(a) CR (a, FDC_BLK_IO_DEV, FdcBlkIo, FDC_BLK_IO_DEV_SIGNATURE)
|
||||
|
||||
//
|
||||
// PEI Recovery Block I/O PPI
|
||||
//
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcGetNumberOfBlockDevices (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
|
||||
OUT UINTN *NumberBlockDevices
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcGetBlockDeviceMediaInfo (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
FdcReadBlocks (
|
||||
IN EFI_PEI_SERVICES **PeiServices,
|
||||
IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,
|
||||
IN UINTN DeviceIndex,
|
||||
IN EFI_PEI_LBA StartLba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
//
|
||||
// Internal function declare
|
||||
//
|
||||
UINT8
|
||||
FdcEnumeration (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FdcReset (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN UINT8 DevPos
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
DiscoverFdcDevice (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
|
||||
OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Recalibrate (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Seek (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
|
||||
IN EFI_PEI_LBA Lba
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MotorOn (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
MotorOff (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FdcWaitForBSYClear (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN UINT8 DevPos,
|
||||
IN UINTN TimeoutInSeconds
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
SenseIntStatus (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT UINT8 *sts0,
|
||||
IN OUT UINT8 *pcn
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Specify (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
DisketChanged (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
DataInByte (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT UINT8 *pt
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
DataOutByte (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN UINT8 *pt
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
FdcDRQReady (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN BOOLEAN Dio,
|
||||
IN UINTN TimeoutInSeconds
|
||||
);
|
||||
|
||||
UINTN
|
||||
GetTransferBlockCount (
|
||||
IN PEI_FLOPPY_DEVICE_INFO *Info,
|
||||
IN EFI_PEI_LBA LBA,
|
||||
IN UINTN NumberOfBlocks
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
ReadWriteDataSector (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info,
|
||||
IN VOID *Buffer,
|
||||
IN EFI_PEI_LBA Lba,
|
||||
IN UINTN NumberOfBlocks,
|
||||
IN BOOLEAN Read
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
SetDMA (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN VOID *Buffer,
|
||||
IN UINTN NumberOfBlocks,
|
||||
IN BOOLEAN Read
|
||||
);
|
||||
|
||||
VOID
|
||||
FillPara (
|
||||
IN PEI_FLOPPY_DEVICE_INFO *Info,
|
||||
IN EFI_PEI_LBA Lba,
|
||||
IN FDC_COMMAND_PACKET1 *Command
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
Setup (
|
||||
IN FDC_BLK_IO_DEV *FdcBlkIoDev,
|
||||
IN UINT8 DevPos
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
CheckResult (
|
||||
IN FDC_RESULT_PACKET *Result,
|
||||
IN OUT PEI_FLOPPY_DEVICE_INFO *Info
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,103 @@
|
|||
#/** @file
|
||||
# Floppy Peim to support Fv Recovery.
|
||||
#
|
||||
# This module detects Floppy devices. If found, it will install BlockIo PPI.
|
||||
# This module is only dispatched in Recovery Boot mode.
|
||||
# Copyright (c) 2006 - 2007, Intel Corporation.
|
||||
#
|
||||
# All rights reserved.
|
||||
# This software and associated documentation (if any) is furnished
|
||||
# under a license and may only be used or copied in accordance
|
||||
# with the terms of the license. Except as permitted by such
|
||||
# license, no part of this software or documentation may be
|
||||
# reproduced, stored in a retrieval system, or transmitted in any
|
||||
# form or by any means without the express written consent of
|
||||
# Intel Corporation.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Defines Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = FloppyPeim
|
||||
FILE_GUID = B7A5041B-78BA-48e3-B63B-44C7578113B6
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = FdcPeimEntry
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Sources Section - list of files that are required for the build to succeed.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Sources.common]
|
||||
FloppyPeim.c
|
||||
FloppyPeim.h
|
||||
Fdc.h
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Package Dependency Section - list of Package files that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class Section - list of Library Classes that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[LibraryClasses]
|
||||
IoLib
|
||||
TimerLib
|
||||
ReportStatusCodeLib
|
||||
BaseMemoryLib
|
||||
PeiServicesLib
|
||||
PeimEntryPoint
|
||||
DebugLib
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# PPI C Name Section - list of PPI and PPI Notify C Names that this module
|
||||
# uses or produces.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Ppis]
|
||||
gEfiPei144FloppyBlockIoPpiGuid # PPI ALWAYS_PRODUCED
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Dependency Expression Section - list of Dependency expressions that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Depex]
|
||||
gEfiPeiMemoryDiscoveredPpiGuid AND gEfiPeiFvFileLoaderPpiGuid AND gEfiPeiBootInRecoveryModePpiGuid
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xsi:schemaLocation="http://www.TianoCore.org/2006/Edk2.0 http://www.TianoCore.org/2006/Edk2.0/SurfaceArea.xsd" xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>FloppyPeim</ModuleName>
|
||||
<ModuleType>PEIM</ModuleType>
|
||||
<GuidValue>B7A5041B-78BA-48e3-B63B-44C7578113B6</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Floppy Peim to support Fv Recovery.</Abstract>
|
||||
<Description>This module detects Floppy devices. If found, it will install BlockIo PPI.
|
||||
This module is only dispatched in Recovery Boot mode.</Description>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
|
||||
<License>All rights reserved.
|
||||
This software and associated documentation (if any) is furnished
|
||||
under a license and may only be used or copied in accordance
|
||||
with the terms of the license. Except as permitted by such
|
||||
license, no part of this software or documentation may be
|
||||
reproduced, stored in a retrieval system, or transmitted in any
|
||||
form or by any means without the express written consent of
|
||||
Intel Corporation.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>FloppyPeim</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PeimEntryPoint</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PeiServicesLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseMemoryLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>ReportStatusCodeLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>TimerLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>IoLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>floppypeim.dxs</Filename>
|
||||
<Filename>fdc.h</Filename>
|
||||
<Filename>floppypeim.h</Filename>
|
||||
<Filename>FloppyPeim.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
<Package PackageGuid="bea835f9-fd62-464a-81ff-f3a806360c6b"/>
|
||||
</PackageDependencies>
|
||||
<PPIs>
|
||||
<Ppi Usage="ALWAYS_PRODUCED">
|
||||
<PpiCName>gEfiPeiBlockIoPpiGuid</PpiCName>
|
||||
</Ppi>
|
||||
</PPIs>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
<Extern>
|
||||
<ModuleEntryPoint>FdcPeimEntry</ModuleEntryPoint>
|
||||
</Extern>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
|
@ -176,6 +176,8 @@
|
|||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Pci/PciBus/Dxe/PciBus.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Pci/IdeBus/Dxe/IdeBus.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBus.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Dxe/IsaFloppy.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/IsaFloppy/Pei/FloppyPeim.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboard.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Bus/Isa/Ps2MouseDxe/Ps2Mouse.inf
|
||||
$(WORKSPACE)/IntelFrameworkModulePkg/Universal/DataHub/DataHub/Dxe/DataHub.inf
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,562 @@
|
|||
/** @file
|
||||
I/O Library.
|
||||
|
||||
Copyright (c) 2006, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
Module Name: IoLib.c
|
||||
|
||||
**/
|
||||
|
||||
//
|
||||
// The package level header files this module uses
|
||||
//
|
||||
#include <PiPei.h>
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
|
||||
/**
|
||||
Reads an 8-bit I/O port.
|
||||
|
||||
Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
|
||||
This function must guarantee that all I/O read and write operations are
|
||||
serialized.
|
||||
|
||||
If 8-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
IoRead8 (
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
|
||||
return CpuIo->IoRead8 (PeiServices, CpuIo, (UINT64) Port);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes an 8-bit I/O port.
|
||||
|
||||
Writes the 8-bit I/O port specified by Port with the value specified by Value
|
||||
and returns Value. This function must guarantee that all I/O read and write
|
||||
operations are serialized.
|
||||
|
||||
If 8-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to write.
|
||||
@param Value The value to write to the I/O port.
|
||||
|
||||
@return The value written the I/O port.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
IoWrite8 (
|
||||
IN UINTN Port,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
|
||||
CpuIo->IoWrite8 (PeiServices, CpuIo, (UINT64) Port, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 16-bit I/O port.
|
||||
|
||||
Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
|
||||
This function must guarantee that all I/O read and write operations are
|
||||
serialized.
|
||||
|
||||
If 16-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
IoRead16 (
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 16-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 1) == 0);
|
||||
return CpuIo->IoRead16 (PeiServices, CpuIo, (UINT64) Port);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 16-bit I/O port.
|
||||
|
||||
Writes the 16-bit I/O port specified by Port with the value specified by Value
|
||||
and returns Value. This function must guarantee that all I/O read and write
|
||||
operations are serialized.
|
||||
|
||||
If 16-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to write.
|
||||
@param Value The value to write to the I/O port.
|
||||
|
||||
@return The value written the I/O port.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
IoWrite16 (
|
||||
IN UINTN Port,
|
||||
IN UINT16 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 16-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 1) == 0);
|
||||
CpuIo->IoWrite16 (PeiServices, CpuIo, (UINT64) Port, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 32-bit I/O port.
|
||||
|
||||
Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
|
||||
This function must guarantee that all I/O read and write operations are
|
||||
serialized.
|
||||
|
||||
If 32-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
IoRead32 (
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 32-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 3) == 0);
|
||||
return CpuIo->IoRead32 (PeiServices, CpuIo, (UINT64) Port);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 32-bit I/O port.
|
||||
|
||||
Writes the 32-bit I/O port specified by Port with the value specified by Value
|
||||
and returns Value. This function must guarantee that all I/O read and write
|
||||
operations are serialized.
|
||||
|
||||
If 32-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to write.
|
||||
@param Value The value to write to the I/O port.
|
||||
|
||||
@return The value written the I/O port.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
IoWrite32 (
|
||||
IN UINTN Port,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 32-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 3) == 0);
|
||||
CpuIo->IoWrite32 (PeiServices, CpuIo, (UINT64) Port, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 64-bit I/O port.
|
||||
|
||||
Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
|
||||
This function must guarantee that all I/O read and write operations are
|
||||
serialized.
|
||||
|
||||
If 64-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
IoRead64 (
|
||||
IN UINTN Port
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 64-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 7) == 0);
|
||||
return CpuIo->IoRead64 (PeiServices, CpuIo, (UINT64) Port);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 64-bit I/O port.
|
||||
|
||||
Writes the 64-bit I/O port specified by Port with the value specified by Value
|
||||
and returns Value. This function must guarantee that all I/O read and write
|
||||
operations are serialized.
|
||||
|
||||
If 64-bit I/O port operations are not supported, then ASSERT().
|
||||
|
||||
@param Port The I/O port to write.
|
||||
@param Value The value to write to the I/O port.
|
||||
|
||||
@return The value written the I/O port.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
IoWrite64 (
|
||||
IN UINTN Port,
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Port is aligned on a 64-bit boundary.
|
||||
//
|
||||
ASSERT ((Port & 7) == 0);
|
||||
CpuIo->IoWrite64 (PeiServices, CpuIo, (UINT64) Port, Value);
|
||||
return Value;;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads an 8-bit MMIO register.
|
||||
|
||||
Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
|
||||
returned. This function must guarantee that all MMIO read and write
|
||||
operations are serialized.
|
||||
|
||||
If 8-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
MmioRead8 (
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
|
||||
return CpuIo->MemRead8 (PeiServices, CpuIo, (UINT64) Address);
|
||||
}
|
||||
|
||||
/**
|
||||
Writes an 8-bit MMIO register.
|
||||
|
||||
Writes the 8-bit MMIO register specified by Address with the value specified
|
||||
by Value and returns Value. This function must guarantee that all MMIO read
|
||||
and write operations are serialized.
|
||||
|
||||
If 8-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to write.
|
||||
@param Value The value to write to the MMIO register.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
MmioWrite8 (
|
||||
IN UINTN Address,
|
||||
IN UINT8 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
|
||||
CpuIo->MemWrite8 (PeiServices, CpuIo, (UINT64) Address, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 16-bit MMIO register.
|
||||
|
||||
Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
|
||||
returned. This function must guarantee that all MMIO read and write
|
||||
operations are serialized.
|
||||
|
||||
If 16-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
MmioRead16 (
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 16-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 1) == 0);
|
||||
return CpuIo->MemRead16 (PeiServices, CpuIo, (UINT64) Address);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 16-bit MMIO register.
|
||||
|
||||
Writes the 16-bit MMIO register specified by Address with the value specified
|
||||
by Value and returns Value. This function must guarantee that all MMIO read
|
||||
and write operations are serialized.
|
||||
|
||||
If 16-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to write.
|
||||
@param Value The value to write to the MMIO register.
|
||||
|
||||
**/
|
||||
UINT16
|
||||
EFIAPI
|
||||
MmioWrite16 (
|
||||
IN UINTN Address,
|
||||
IN UINT16 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 16-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 1) == 0);
|
||||
CpuIo->MemWrite16 (PeiServices, CpuIo, (UINT64) Address, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 32-bit MMIO register.
|
||||
|
||||
Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
|
||||
returned. This function must guarantee that all MMIO read and write
|
||||
operations are serialized.
|
||||
|
||||
If 32-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
MmioRead32 (
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 32-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 3) == 0);
|
||||
return CpuIo->MemRead32 (PeiServices, CpuIo, (UINT64) Address);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 32-bit MMIO register.
|
||||
|
||||
Writes the 32-bit MMIO register specified by Address with the value specified
|
||||
by Value and returns Value. This function must guarantee that all MMIO read
|
||||
and write operations are serialized.
|
||||
|
||||
If 32-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to write.
|
||||
@param Value The value to write to the MMIO register.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
MmioWrite32 (
|
||||
IN UINTN Address,
|
||||
IN UINT32 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 32-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 3) == 0);
|
||||
CpuIo->MemWrite32 (PeiServices, CpuIo, (UINT64) Address, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads a 64-bit MMIO register.
|
||||
|
||||
Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
|
||||
returned. This function must guarantee that all MMIO read and write
|
||||
operations are serialized.
|
||||
|
||||
If 64-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to read.
|
||||
|
||||
@return The value read.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
MmioRead64 (
|
||||
IN UINTN Address
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 64-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 7) == 0);
|
||||
return CpuIo->MemRead64 (PeiServices, CpuIo, (UINT64) Address);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Writes a 64-bit MMIO register.
|
||||
|
||||
Writes the 64-bit MMIO register specified by Address with the value specified
|
||||
by Value and returns Value. This function must guarantee that all MMIO read
|
||||
and write operations are serialized.
|
||||
|
||||
If 64-bit MMIO register operations are not supported, then ASSERT().
|
||||
|
||||
@param Address The MMIO register to write.
|
||||
@param Value The value to write to the MMIO register.
|
||||
|
||||
**/
|
||||
UINT64
|
||||
EFIAPI
|
||||
MmioWrite64 (
|
||||
IN UINTN Address,
|
||||
IN UINT64 Value
|
||||
)
|
||||
{
|
||||
EFI_PEI_SERVICES **PeiServices;
|
||||
EFI_PEI_CPU_IO_PPI *CpuIo;
|
||||
|
||||
PeiServices = GetPeiServicesTablePointer ();
|
||||
CpuIo = (*PeiServices)->CpuIo;
|
||||
ASSERT (CpuIo != NULL);
|
||||
//
|
||||
// Make sure Address is aligned on a 64-bit boundary.
|
||||
//
|
||||
ASSERT ((Address & 7) == 0);
|
||||
CpuIo->MemWrite64 (PeiServices, CpuIo, (UINT64) Address, Value);
|
||||
return Value;
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
/** @file
|
||||
I/O Library MMIO Buffer Functions.
|
||||
|
||||
Copyright (c) 2007, 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
//
|
||||
// The package level header files this module uses
|
||||
//
|
||||
#include <PiPei.h>
|
||||
//
|
||||
// The Library classes this module consumes
|
||||
//
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PeiServicesTablePointerLib.h>
|
||||
|
||||
/**
|
||||
Copy data from MMIO region to system memory by using 8-bit access.
|
||||
|
||||
Copy data from MMIO region specified by starting address StartAddress
|
||||
to system memory specified by Buffer by using 8-bit access. The total
|
||||
number of byte to be copied is specified by Length. Buffer is returned.
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||
|
||||
@return Buffer
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
EFIAPI
|
||||
MmioReadBuffer8 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
OUT UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
UINT8 *ReturnBuffer;
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ReturnBuffer = Buffer;
|
||||
|
||||
while (Length--) {
|
||||
*(Buffer++) = MmioRead8 (StartAddress++);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Copy data from MMIO region to system memory by using 16-bit access.
|
||||
|
||||
Copy data from MMIO region specified by starting address StartAddress
|
||||
to system memory specified by Buffer by using 16-bit access. The total
|
||||
number of byte to be copied is specified by Length. Buffer is returned.
|
||||
|
||||
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 16-bit boundary, then ASSERT().
|
||||
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||
|
||||
@return Buffer
|
||||
|
||||
**/
|
||||
UINT16 *
|
||||
EFIAPI
|
||||
MmioReadBuffer16 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
OUT UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
UINT16 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = Buffer;
|
||||
|
||||
while (Length) {
|
||||
*(Buffer++) = MmioRead16 (StartAddress);
|
||||
StartAddress += sizeof (UINT16);
|
||||
Length -= sizeof (UINT16);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Copy data from MMIO region to system memory by using 32-bit access.
|
||||
|
||||
Copy data from MMIO region specified by starting address StartAddress
|
||||
to system memory specified by Buffer by using 32-bit access. The total
|
||||
number of byte to be copied is specified by Length. Buffer is returned.
|
||||
|
||||
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 32-bit boundary, then ASSERT().
|
||||
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||
|
||||
@return Buffer
|
||||
|
||||
**/
|
||||
UINT32 *
|
||||
EFIAPI
|
||||
MmioReadBuffer32 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
OUT UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
UINT32 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = Buffer;
|
||||
|
||||
while (Length) {
|
||||
*(Buffer++) = MmioRead32 (StartAddress);
|
||||
StartAddress += sizeof (UINT32);
|
||||
Length -= sizeof (UINT32);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Copy data from MMIO region to system memory by using 64-bit access.
|
||||
|
||||
Copy data from MMIO region specified by starting address StartAddress
|
||||
to system memory specified by Buffer by using 64-bit access. The total
|
||||
number of byte to be copied is specified by Length. Buffer is returned.
|
||||
|
||||
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 64-bit boundary, then ASSERT().
|
||||
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied from.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer receiving the data read.
|
||||
|
||||
@return Buffer
|
||||
|
||||
**/
|
||||
UINT64 *
|
||||
EFIAPI
|
||||
MmioReadBuffer64 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
OUT UINT64 *Buffer
|
||||
)
|
||||
{
|
||||
UINT64 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = Buffer;
|
||||
|
||||
while (Length) {
|
||||
*(Buffer++) = MmioRead64 (StartAddress);
|
||||
StartAddress += sizeof (UINT64);
|
||||
Length -= sizeof (UINT64);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy data from system memory to MMIO region by using 8-bit access.
|
||||
|
||||
Copy data from system memory specified by Buffer to MMIO region specified
|
||||
by starting address StartAddress by using 8-bit access. The total number
|
||||
of byte to be copied is specified by Length. Buffer is returned.
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||
|
||||
@return Size in bytes of the copy.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
EFIAPI
|
||||
MmioWriteBuffer8 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
IN CONST UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
VOID* ReturnBuffer;
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ReturnBuffer = (UINT8 *) Buffer;
|
||||
|
||||
while (Length--) {
|
||||
MmioWrite8 (StartAddress++, *(Buffer++));
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Copy data from system memory to MMIO region by using 16-bit access.
|
||||
|
||||
Copy data from system memory specified by Buffer to MMIO region specified
|
||||
by starting address StartAddress by using 16-bit access. The total number
|
||||
of byte to be copied is specified by Length. Length is returned.
|
||||
|
||||
If StartAddress is not aligned on a 16-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 16-bit boundary, then ASSERT().
|
||||
|
||||
If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||
|
||||
@return Size in bytes of the copy.
|
||||
|
||||
**/
|
||||
UINT16 *
|
||||
EFIAPI
|
||||
MmioWriteBuffer16 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
IN CONST UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
UINT16 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT16) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT16) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT16) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = (UINT16 *) Buffer;
|
||||
|
||||
while (Length) {
|
||||
MmioWrite16 (StartAddress, *(Buffer++));
|
||||
|
||||
StartAddress += sizeof (UINT16);
|
||||
Length -= sizeof (UINT16);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy data from system memory to MMIO region by using 32-bit access.
|
||||
|
||||
Copy data from system memory specified by Buffer to MMIO region specified
|
||||
by starting address StartAddress by using 32-bit access. The total number
|
||||
of byte to be copied is specified by Length. Length is returned.
|
||||
|
||||
If StartAddress is not aligned on a 32-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 32-bit boundary, then ASSERT().
|
||||
|
||||
If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||
|
||||
@return Size in bytes of the copy.
|
||||
|
||||
**/
|
||||
UINT32 *
|
||||
EFIAPI
|
||||
MmioWriteBuffer32 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
IN CONST UINT32 *Buffer
|
||||
)
|
||||
{
|
||||
UINT32 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT32) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT32) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT32) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = (UINT32 *) Buffer;
|
||||
|
||||
while (Length) {
|
||||
MmioWrite32 (StartAddress, *(Buffer++));
|
||||
|
||||
StartAddress += sizeof (UINT32);
|
||||
Length -= sizeof (UINT32);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Copy data from system memory to MMIO region by using 64-bit access.
|
||||
|
||||
Copy data from system memory specified by Buffer to MMIO region specified
|
||||
by starting address StartAddress by using 64-bit access. The total number
|
||||
of byte to be copied is specified by Length. Length is returned.
|
||||
|
||||
If StartAddress is not aligned on a 64-bit boundary, then ASSERT().
|
||||
|
||||
If Length is greater than (MAX_ADDRESS - StartAddress + 1), then ASSERT().
|
||||
If Length is greater than (MAX_ADDRESS -Buffer + 1), then ASSERT().
|
||||
|
||||
If Length is not aligned on a 64-bit boundary, then ASSERT().
|
||||
|
||||
If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
||||
|
||||
@param StartAddress Starting address for the MMIO region to be copied to.
|
||||
@param Length Size in bytes of the copy.
|
||||
@param Buffer Pointer to a system memory buffer containing the data to write.
|
||||
|
||||
@return Size in bytes of the copy.
|
||||
|
||||
**/
|
||||
UINT64 *
|
||||
EFIAPI
|
||||
MmioWriteBuffer64 (
|
||||
IN UINTN StartAddress,
|
||||
IN UINTN Length,
|
||||
IN CONST UINT64 *Buffer
|
||||
)
|
||||
{
|
||||
UINT64 *ReturnBuffer;
|
||||
|
||||
ASSERT ((StartAddress & (sizeof (UINT64) - 1)) == 0);
|
||||
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - StartAddress));
|
||||
ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN) Buffer));
|
||||
|
||||
ASSERT ((Length & (sizeof (UINT64) - 1)) == 0);
|
||||
ASSERT (((UINTN) Buffer & (sizeof (UINT64) - 1)) == 0);
|
||||
|
||||
ReturnBuffer = (UINT64 *) Buffer;
|
||||
|
||||
while (Length) {
|
||||
MmioWrite64 (StartAddress, *(Buffer++));
|
||||
|
||||
StartAddress += sizeof (UINT64);
|
||||
Length -= sizeof (UINT64);
|
||||
}
|
||||
|
||||
return ReturnBuffer;
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#/** @file
|
||||
# Component description file for Cpu Io Pei Io Library
|
||||
#
|
||||
# I/O Library implementation that uses the CPU I/O PPI for I/O
|
||||
# and MMIO operations.
|
||||
# Copyright (c) 2006 - 2007, Intel Corporation.
|
||||
#
|
||||
# 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
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Defines Section - statements that will be processed to create a Makefile.
|
||||
#
|
||||
################################################################################
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PeiIoLibCpuIo
|
||||
FILE_GUID = b2585b69-fb63-4220-844a-8fbea8bf01af
|
||||
MODULE_TYPE = PEIM
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = IoLib|PEIM PEI_CORE
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Sources Section - list of files that are required for the build to succeed.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Sources.common]
|
||||
IoHighLevel.c
|
||||
IoLib.c
|
||||
IoLibMmioBuffer.c
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Package Dependency Section - list of Package files that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Library Class Section - list of Library Classes that are required for
|
||||
# this module.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
[LibraryClasses]
|
||||
PeiServicesTablePointerLib
|
||||
BaseLib
|
||||
DebugLib
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<MsaHeader>
|
||||
<ModuleName>PeiIoLibCpuIo</ModuleName>
|
||||
<ModuleType>PEIM</ModuleType>
|
||||
<GuidValue>b2585b69-fb63-4220-844a-8fbea8bf01af</GuidValue>
|
||||
<Version>1.0</Version>
|
||||
<Abstract>Component description file for Cpu Io Pei Io Library</Abstract>
|
||||
<Description>I/O Library implementation that uses the CPU I/O PPI for I/O
|
||||
and MMIO operations.</Description>
|
||||
<Copyright>Copyright (c) 2006 - 2007, Intel Corporation.</Copyright>
|
||||
<License>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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
|
||||
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
|
||||
</MsaHeader>
|
||||
<ModuleDefinitions>
|
||||
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
|
||||
<BinaryModule>false</BinaryModule>
|
||||
<OutputFileBasename>PeiIoLibCpuIo</OutputFileBasename>
|
||||
</ModuleDefinitions>
|
||||
<LibraryClassDefinitions>
|
||||
<LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="PEIM PEI_CORE">
|
||||
<Keyword>IoLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>DebugLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>BaseLib</Keyword>
|
||||
</LibraryClass>
|
||||
<LibraryClass Usage="ALWAYS_CONSUMED">
|
||||
<Keyword>PeiServicesTablePointerLib</Keyword>
|
||||
</LibraryClass>
|
||||
</LibraryClassDefinitions>
|
||||
<SourceFiles>
|
||||
<Filename>IoLibMmioBuffer.c</Filename>
|
||||
<Filename>IoLib.c</Filename>
|
||||
<Filename>IoHighLevel.c</Filename>
|
||||
</SourceFiles>
|
||||
<PackageDependencies>
|
||||
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
|
||||
</PackageDependencies>
|
||||
<Externs>
|
||||
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
|
||||
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
|
||||
</Externs>
|
||||
</ModuleSurfaceArea>
|
Loading…
Reference in New Issue