pdated code per coding standard. Changed comments, converted all \ to / and removed the extra generated files by merging them into existing files.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2736 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
AJFISH
2007-06-26 00:32:26 +00:00
parent cf61682357
commit b9575d6030
18 changed files with 996 additions and 1063 deletions

View File

@@ -1,26 +1,16 @@
/*++
/** @file
UEFI Component Name protocol for DiskIo driver.
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
Copyright (c) 2006, 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.
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:
ComponentName.c
Abstract:
--*/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
**/
#include "DiskIo.h"
@@ -44,6 +34,44 @@ static EFI_UNICODE_STRING_TABLE mDiskIoDriverNameTable[] = {
}
};
/**
Retrieves a Unicode string that is the user readable name of
the EFI Driver.
@param This A pointer to the
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller
is requesting, and it must match one of the
languages specified in SupportedLanguages.
The number of languages supported by a
driver is up to the driver writer. Language
is specified in RFC 3066 language code
format.
@param DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the
Driver specified by This and the
language specified by Language
was returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This
does not support the language
specified by Language.
**/
EFI_STATUS
EFIAPI
DiskIoComponentNameGetDriverName (
@@ -51,32 +79,6 @@ DiskIoComponentNameGetDriverName (
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,
@@ -86,6 +88,78 @@ DiskIoComponentNameGetDriverName (
);
}
/**
Retrieves a Unicode string that is the user readable name of
the controller that is being managed by an EFI Driver.
@param This A pointer to the
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle The handle of a controller that the
driver specified by This is managing.
This handle specifies the controller
whose name is to be returned.
@param ChildHandle 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.
@param Language A pointer to a Null-terminated ASCII
string array indicating the language.
This is the language of the driver
name that the caller is requesting,
and it must match one of the
languages specified in
SupportedLanguages. The number of
languages supported by a driver is up
to the driver writer. Language is
specified in RFC 3066 language code
format.
@param 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.
@retval 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.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it
is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is
not currently managing the
controller specified by
ControllerHandle and
ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This
does not support the language
specified by Language.
**/
EFI_STATUS
EFIAPI
DiskIoComponentNameGetControllerName (
@@ -95,50 +169,6 @@ DiskIoComponentNameGetControllerName (
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.
--*/
{
return EFI_UNSUPPORTED;
}

View File

@@ -1,32 +1,38 @@
/*++
/** @file
DiskIo driver that layers it's self on every Block IO protocol in the system.
DiskIo converts a block oriented device to a byte oriented device.
Copyright (c) 2006, 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.
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
Module Name:
DiskIo.h
Abstract:
Private Data definition for Disk IO driver
--*/
#ifndef _DISK_IO_H
#define _DISK_IO_H
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Protocol/BlockIo.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/DiskIo.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
//
// Include common header file for this module.
// Driver Binding Externs
//
#include "CommonHeader.h"
extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;
#define DISK_IO_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('d', 's', 'k', 'I')
@@ -119,4 +125,3 @@ DiskIoComponentNameGetControllerName (
OUT CHAR16 **ControllerName
);
#endif

View File

@@ -1,13 +1,12 @@
#/** @file
# Component description file for DiskIo module.
#
# DiskIo driver that layers it's self on every Block IO protocol in the system.
# Copyright (c) 2006 - 2007, Intel Corporation
# Component description file for DiskIo module.
#
# 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.
#
@@ -49,8 +48,6 @@
ComponentName.c
DiskIo.h
diskio.c
CommonHeader.h
EntryPoint.c
################################################################################
@@ -61,7 +58,7 @@
################################################################################
[Includes]
$(WORKSPACE)/MdePkg\Include/Library
$(WORKSPACE)/MdePkg/Include/Library
################################################################################
#
@@ -71,8 +68,8 @@
################################################################################
[Packages]
$(WORKSPACE)\MdeModulePkg/MdeModulePkg.dec
$(WORKSPACE)\MdePkg/MdePkg.dec
$(WORKSPACE)/MdeModulePkg/MdeModulePkg.dec
$(WORKSPACE)/MdePkg/MdePkg.dec
################################################################################

View File

@@ -1,39 +1,24 @@
/*++
Copyright (c) 2006, 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.
Module Name:
DiskIo.c
Abstract:
/** @file
DiskIo driver that layers it's self on every Block IO protocol in the system.
DiskIo converts a block oriented device to a byte oriented device.
ReadDisk may have to do reads that are not aligned on sector boundaries.
There are three cases:
UnderRun - The first byte is not on a sector boundary or the read request is
less than a sector in length.
Aligned - A read of N contiguous sectors.
OverRun - The last byte is not on a sector boundary.
--*/
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
//
// Include common header file for this module.
//
#include "CommonHeader.h"
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "DiskIo.h"
@@ -56,6 +41,20 @@ DISK_IO_PRIVATE_DATA gDiskIoPrivateDataTemplate = {
NULL
};
/**
Test to see if this driver supports ControllerHandle.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to test
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver supports this device
@retval EFI_ALREADY_STARTED This driver is already running on this device
@retval other This driver does not support this device
**/
EFI_STATUS
EFIAPI
DiskIoDriverBindingSupported (
@@ -63,23 +62,6 @@ DiskIoDriverBindingSupported (
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Test to see if this driver supports ControllerHandle. Any ControllerHandle
than contains a BlockIo protocol can be supported.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to test.
RemainingDevicePath - Not used.
Returns:
EFI_SUCCESS - This driver supports this device.
EFI_ALREADY_STARTED - This driver is already running on this device.
other - This driver does not support this device.
--*/
{
EFI_STATUS Status;
EFI_BLOCK_IO_PROTOCOL *BlockIo;
@@ -98,6 +80,7 @@ DiskIoDriverBindingSupported (
if (EFI_ERROR (Status)) {
return Status;
}
//
// Close the I/O Abstraction(s) used to perform the supported test.
//
@@ -110,6 +93,21 @@ DiskIoDriverBindingSupported (
return EFI_SUCCESS;
}
/**
Start this driver on ControllerHandle by opening a Block IO protocol and
installing a Disk IO protocol on ControllerHandle.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to bind driver to
@param RemainingDevicePath Optional parameter use to pick a specific child
device to start.
@retval EFI_SUCCESS This driver is added to ControllerHandle
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
@retval other This driver does not support this device
**/
EFI_STATUS
EFIAPI
DiskIoDriverBindingStart (
@@ -117,23 +115,6 @@ DiskIoDriverBindingStart (
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
/*++
Routine Description:
Start this driver on ControllerHandle by opening a Block IO protocol and
installing a Disk IO protocol on ControllerHandle.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to bind driver to.
RemainingDevicePath - Not used, always produce all possible children.
Returns:
EFI_SUCCESS - This driver is added to ControllerHandle.
EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
other - This driver does not support this device.
--*/
{
EFI_STATUS Status;
DISK_IO_PRIVATE_DATA *Private;
@@ -154,6 +135,7 @@ DiskIoDriverBindingStart (
if (EFI_ERROR (Status)) {
return Status;
}
//
// Initialize the Disk IO device instance.
//
@@ -162,6 +144,7 @@ DiskIoDriverBindingStart (
Status = EFI_OUT_OF_RESOURCES;
goto ErrorExit;
}
//
// Install protocol interfaces for the Disk IO device.
//
@@ -190,6 +173,21 @@ ErrorExit:
return Status;
}
/**
Stop this driver on ControllerHandle by removing Disk IO protocol and closing
the Block IO protocol on ControllerHandle.
@param This Protocol instance pointer.
@param ControllerHandle Handle of device to stop driver on
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed ControllerHandle
@retval other This driver was not removed from this device
**/
EFI_STATUS
EFIAPI
DiskIoDriverBindingStop (
@@ -198,24 +196,6 @@ DiskIoDriverBindingStop (
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
/*++
Routine Description:
Stop this driver on ControllerHandle by removing Disk IO protocol and closing
the Block IO protocol on ControllerHandle.
Arguments:
This - Protocol instance pointer.
ControllerHandle - Handle of device to stop driver on.
NumberOfChildren - Not used.
ChildHandleBuffer - Not used.
Returns:
EFI_SUCCESS - This driver is removed ControllerHandle.
other - This driver was not removed from this device.
EFI_UNSUPPORTED
--*/
{
EFI_STATUS Status;
EFI_DISK_IO_PROTOCOL *DiskIo;
@@ -260,6 +240,31 @@ DiskIoDriverBindingStop (
return Status;
}
/**
Read BufferSize bytes from Offset into Buffer.
Reads may support reads that are not aligned on
sector boundaries. There are three cases:
UnderRun - The first byte is not on a sector boundary or the read request is
less than a sector in length.
Aligned - A read of N contiguous sectors.
OverRun - The last byte is not on a sector boundary.
@param This Protocol instance pointer.
@param MediaId Id of the media, changes every time the media is replaced.
@param Offset The starting byte offset to read from
@param BufferSize Size of Buffer
@param Buffer Buffer containing read data
@retval EFI_SUCCESS The data was read correctly from the device.
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
valid for the device.
**/
EFI_STATUS
EFIAPI
DiskIoReadDisk (
@@ -269,39 +274,6 @@ DiskIoReadDisk (
IN UINTN BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
Read BufferSize bytes from Offset into Buffer.
Reads may support reads that are not aligned on
sector boundaries. There are three cases:
UnderRun - The first byte is not on a sector boundary or the read request is
less than a sector in length.
Aligned - A read of N contiguous sectors.
OverRun - The last byte is not on a sector boundary.
Arguments:
This - Protocol instance pointer.
MediaId - Id of the media, changes every time the media is replaced.
Offset - The starting byte offset to read from.
BufferSize - Size of Buffer.
Buffer - Buffer containing read data.
Returns:
EFI_SUCCESS - The data was read correctly from the device.
EFI_DEVICE_ERROR - The device reported an error while performing the read.
EFI_NO_MEDIA - There is no media in the device.
EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
EFI_INVALID_PARAMETER - The read request contains device addresses that are not
valid for the device.
EFI_OUT_OF_RESOURCES
--*/
{
EFI_STATUS Status;
DISK_IO_PRIVATE_DATA *Private;
@@ -485,6 +457,32 @@ Done:
return Status;
}
/**
Read BufferSize bytes from Offset into Buffer.
Writes may require a read modify write to support writes that are not
aligned on sector boundaries. There are three cases:
UnderRun - The first byte is not on a sector boundary or the write request
is less than a sector in length. Read modify write is required.
Aligned - A write of N contiguous sectors.
OverRun - The last byte is not on a sector boundary. Read modified write
required.
@param This Protocol instance pointer.
@param MediaId Id of the media, changes every time the media is replaced.
@param Offset The starting byte offset to read from
@param BufferSize Size of Buffer
@param Buffer Buffer containing read data
@retval EFI_SUCCESS The data was written correctly to the device.
@retval EFI_WRITE_PROTECTED The device can not be written to.
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
@retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
valid for the device.
**/
EFI_STATUS
EFIAPI
DiskIoWriteDisk (
@@ -494,40 +492,6 @@ DiskIoWriteDisk (
IN UINTN BufferSize,
IN VOID *Buffer
)
/*++
Routine Description:
Read BufferSize bytes from Offset into Buffer.
Writes may require a read modify write to support writes that are not
aligned on sector boundaries. There are three cases:
UnderRun - The first byte is not on a sector boundary or the write request
is less than a sector in length. Read modify write is required.
Aligned - A write of N contiguous sectors.
OverRun - The last byte is not on a sector boundary. Read modified write
required.
Arguments:
This - Protocol instance pointer.
MediaId - Id of the media, changes every time the media is replaced.
Offset - The starting byte offset to read from.
BufferSize - Size of Buffer.
Buffer - Buffer containing read data.
Returns:
EFI_SUCCESS - The data was written correctly to the device.
EFI_WRITE_PROTECTED - The device can not be written to.
EFI_DEVICE_ERROR - The device reported an error while performing the write.
EFI_NO_MEDIA - There is no media in the device.
EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
EFI_INVALID_PARAMETER - The write request contains device addresses that are not
valid for the device.
EFI_OUT_OF_RESOURCES
--*/
{
EFI_STATUS Status;
DISK_IO_PRIVATE_DATA *Private;
@@ -732,3 +696,42 @@ Done:
return Status;
}
/**
The user Entry Point for module DiskIo. 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
InitializeDiskIo (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
//
// Install driver model protocol(s).
//
Status = EfiLibInstallAllDriverProtocols (
ImageHandle,
SystemTable,
&gDiskIoDriverBinding,
ImageHandle,
&gDiskIoComponentName,
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}