MdeModulePkg/SdMmc: Add EDKII SD/MMC stack
This stack includes: 1. Dxe phase support by: 1) SdMmcPciHcDxe driver to consume PciIo and produce SdMmcPassThru. 2) SdDxe driver to consume SdMmcPassThru to produce BlkIo1/BlkIo2. 3) EmmcDxe driver to consume SdMmcPassThru to produce BlkIo1/BlkIo2/SSP. 2. Pei phase support 1) SdBlockIoPei driver to consume SdMmcHostController Ppi and produce VirutalBlkIo1&2. 2) EmmcBlockIoPei driver to consume SdMmcHostController Ppi and produce VirutalBlkIo1&2. 3) SdMmcPciHcPei driver to produce SdMmcHostController Ppi. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian <feng.tian@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
This commit is contained in:
241
MdeModulePkg/Bus/Sd/EmmcDxe/ComponentName.c
Normal file
241
MdeModulePkg/Bus/Sd/EmmcDxe/ComponentName.c
Normal file
@@ -0,0 +1,241 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for EmmcDxe driver.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#include "EmmcDxe.h"
|
||||
|
||||
//
|
||||
// Driver name table
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmmcDxeDriverNameTable[] = {
|
||||
{ "eng;en", L"Edkii Emmc Device Driver" },
|
||||
{ NULL , NULL }
|
||||
};
|
||||
|
||||
//
|
||||
// Controller name table
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mEmmcDxeControllerNameTable[] = {
|
||||
{ "eng;en", L"Edkii Emmc Host Controller" },
|
||||
{ NULL , NULL }
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gEmmcDxeComponentName = {
|
||||
EmmcDxeComponentNameGetDriverName,
|
||||
EmmcDxeComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmmcDxeComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmmcDxeComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmmcDxeComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
This function retrieves the user readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param Language[in] 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 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param DriverName[out] 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
|
||||
EmmcDxeComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mEmmcDxeDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gEmmcDxeComponentName)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param ControllerHandle[in] The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
||||
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[in] 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 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param ControllerName[out] 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 NULL.
|
||||
|
||||
@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
|
||||
EmmcDxeComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
||||
EMMC_DEVICE *Device;
|
||||
EMMC_PARTITION *Partition;
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
|
||||
//
|
||||
// Make sure this driver is currently managing ControllHandle
|
||||
//
|
||||
Status = EfiTestManagedDevice (
|
||||
ControllerHandle,
|
||||
gEmmcDxeDriverBinding.DriverBindingHandle,
|
||||
&gEfiSdMmcPassThruProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ControllerNameTable = mEmmcDxeControllerNameTable;
|
||||
if (ChildHandle != NULL) {
|
||||
Status = EfiTestChildHandle (
|
||||
ControllerHandle,
|
||||
ChildHandle,
|
||||
&gEfiSdMmcPassThruProtocolGuid
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
//
|
||||
// Get the child context
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiBlockIoProtocolGuid,
|
||||
(VOID **) &BlockIo,
|
||||
gEmmcDxeDriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Partition = EMMC_PARTITION_DATA_FROM_BLKIO (BlockIo);
|
||||
Device = Partition->Device;
|
||||
ControllerNameTable = Device->ControllerNameTable;
|
||||
}
|
||||
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
ControllerNameTable,
|
||||
ControllerName,
|
||||
(BOOLEAN)(This == &gEmmcDxeComponentName)
|
||||
);}
|
||||
|
1591
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c
Normal file
1591
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c
Normal file
File diff suppressed because it is too large
Load Diff
466
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.h
Normal file
466
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.h
Normal file
@@ -0,0 +1,466 @@
|
||||
/** @file
|
||||
Header file for EmmcDxe Driver.
|
||||
|
||||
This file defines common data structures, macro definitions and some module
|
||||
internal function header files.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EMMC_BLOCK_IO_H_
|
||||
#define _EMMC_BLOCK_IO_H_
|
||||
|
||||
/**
|
||||
Reset the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
|
||||
not be reset.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcReset (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId Id of the media, changes every time the media is replaced.
|
||||
@param Lba The starting Logical Block Address to read from
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the destination buffer for the data. The caller is
|
||||
responsible for either having implicit or explicit ownership of the buffer.
|
||||
|
||||
@retval EFI_SUCCESS The data was read correctly from the device.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcReadBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId The media ID that the write request is for.
|
||||
@param Lba The starting logical block address to be written. The caller is
|
||||
responsible for writing to only legitimate locations.
|
||||
@param BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param Buffer A pointer to the source buffer for the data.
|
||||
|
||||
@retval EFI_SUCCESS The data was written correctly to the device.
|
||||
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcWriteBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
|
||||
@retval EFI_SUCCESS All outstanding data was written to the device
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while writing back the data
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcFlushBlocks (
|
||||
IN EFI_BLOCK_IO_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Reset the Block Device.
|
||||
|
||||
@param[in] This Indicates a pointer to the calling context.
|
||||
@param[in] ExtendedVerification Driver may perform diagnostics on reset.
|
||||
|
||||
@retval EFI_SUCCESS The device was reset.
|
||||
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
|
||||
not be reset.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcResetEx (
|
||||
IN EFI_BLOCK_IO2_PROTOCOL *This,
|
||||
IN BOOLEAN ExtendedVerification
|
||||
);
|
||||
|
||||
/**
|
||||
Read BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param[in] This Indicates a pointer to the calling context.
|
||||
@param[in] MediaId Id of the media, changes every time the media is replaced.
|
||||
@param[in] Lba The starting Logical Block Address to read from.
|
||||
@param[in, out] Token A pointer to the token associated with the transaction.
|
||||
@param[in] BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param[out] Buffer A pointer to the destination buffer for the data. The caller is
|
||||
responsible for either having implicit or explicit ownership of the buffer.
|
||||
|
||||
@retval EFI_SUCCESS The read request was queued if Event is not NULL.
|
||||
The data was read correctly from the device if
|
||||
the Event is NULL.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing
|
||||
the read.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
||||
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the
|
||||
intrinsic block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
|
||||
of resources.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcReadBlocksEx (
|
||||
IN EFI_BLOCK_IO2_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
|
||||
IN UINTN BufferSize,
|
||||
OUT VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Write BufferSize bytes from Lba into Buffer.
|
||||
|
||||
@param[in] This Indicates a pointer to the calling context.
|
||||
@param[in] MediaId The media ID that the write request is for.
|
||||
@param[in] Lba The starting logical block address to be written. The
|
||||
caller is responsible for writing to only legitimate
|
||||
locations.
|
||||
@param[in, out] Token A pointer to the token associated with the transaction.
|
||||
@param[in] BufferSize Size of Buffer, must be a multiple of device block size.
|
||||
@param[in] Buffer A pointer to the source buffer for the data.
|
||||
|
||||
@retval EFI_SUCCESS The data was written correctly to the device.
|
||||
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
||||
@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
|
||||
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
|
||||
or the buffer is not on proper alignment.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcWriteBlocksEx (
|
||||
IN EFI_BLOCK_IO2_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN EFI_LBA Lba,
|
||||
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
|
||||
IN UINTN BufferSize,
|
||||
IN VOID *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Flush the Block Device.
|
||||
|
||||
@param[in] This Indicates a pointer to the calling context.
|
||||
@param[in, out] Token A pointer to the token associated with the transaction.
|
||||
|
||||
@retval EFI_SUCCESS All outstanding data was written to the device
|
||||
@retval EFI_DEVICE_ERROR The device reported an error while writing back the data
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcFlushBlocksEx (
|
||||
IN EFI_BLOCK_IO2_PROTOCOL *This,
|
||||
IN OUT EFI_BLOCK_IO2_TOKEN *Token
|
||||
);
|
||||
|
||||
/**
|
||||
Send a security protocol command to a device that receives data and/or the result
|
||||
of one or more commands sent by SendData.
|
||||
|
||||
The ReceiveData function sends a security protocol command to the given MediaId.
|
||||
The security protocol command sent is defined by SecurityProtocolId and contains
|
||||
the security protocol specific data SecurityProtocolSpecificData. The function
|
||||
returns the data from the security protocol command in PayloadBuffer.
|
||||
|
||||
For devices supporting the SCSI command set, the security protocol command is sent
|
||||
using the SECURITY PROTOCOL IN command defined in SPC-4.
|
||||
|
||||
For devices supporting the ATA command set, the security protocol command is sent
|
||||
using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
|
||||
is non-zero.
|
||||
|
||||
If the PayloadBufferSize is zero, the security protocol command is sent using the
|
||||
Trusted Non-Data command defined in ATA8-ACS.
|
||||
|
||||
If PayloadBufferSize is too small to store the available data from the security
|
||||
protocol command, the function shall copy PayloadBufferSize bytes into the
|
||||
PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
|
||||
|
||||
If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
|
||||
the function shall return EFI_INVALID_PARAMETER.
|
||||
|
||||
If the given MediaId does not support security protocol commands, the function shall
|
||||
return EFI_UNSUPPORTED. If there is no media in the device, the function returns
|
||||
EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
|
||||
the function returns EFI_MEDIA_CHANGED.
|
||||
|
||||
If the security protocol fails to complete within the Timeout period, the function
|
||||
shall return EFI_TIMEOUT.
|
||||
|
||||
If the security protocol command completes without an error, the function shall
|
||||
return EFI_SUCCESS. If the security protocol command completes with an error, the
|
||||
function shall return EFI_DEVICE_ERROR.
|
||||
|
||||
@param[in] This Indicates a pointer to the calling context.
|
||||
@param[in] MediaId ID of the medium to receive data from.
|
||||
@param[in] Timeout The timeout, in 100ns units, to use for the execution
|
||||
of the security protocol command. A Timeout value of 0
|
||||
means that this function will wait indefinitely for the
|
||||
security protocol command to execute. If Timeout is greater
|
||||
than zero, then this function will return EFI_TIMEOUT
|
||||
if the time required to execute the receive data command
|
||||
is greater than Timeout.
|
||||
@param[in] SecurityProtocolId The value of the "Security Protocol" parameter of
|
||||
the security protocol command to be sent.
|
||||
@param[in] SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
|
||||
of the security protocol command to be sent.
|
||||
@param[in] PayloadBufferSize Size in bytes of the payload data buffer.
|
||||
@param[out] PayloadBuffer A pointer to a destination buffer to store the security
|
||||
protocol command specific payload data for the security
|
||||
protocol command. The caller is responsible for having
|
||||
either implicit or explicit ownership of the buffer.
|
||||
@param[out] PayloadTransferSize A pointer to a buffer to store the size in bytes of the
|
||||
data written to the payload data buffer.
|
||||
@param[in] IsRead Indicates it is a read or write operation.
|
||||
|
||||
@retval EFI_SUCCESS The security protocol command completed successfully.
|
||||
@retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
|
||||
data from the device. The PayloadBuffer contains the truncated data.
|
||||
@retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
|
||||
@retval EFI_DEVICE_ERROR The security protocol command completed with an error.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
||||
@retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
|
||||
PayloadBufferSize is non-zero.
|
||||
@retval EFI_TIMEOUT A timeout occurred while waiting for the security
|
||||
protocol command to execute.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcSecurityProtocolInOut (
|
||||
IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN UINT64 Timeout,
|
||||
IN UINT8 SecurityProtocolId,
|
||||
IN UINT16 SecurityProtocolSpecificData,
|
||||
IN UINTN PayloadBufferSize,
|
||||
OUT VOID *PayloadBuffer,
|
||||
OUT UINTN *PayloadTransferSize,
|
||||
IN BOOLEAN IsRead
|
||||
);
|
||||
|
||||
/**
|
||||
Send a security protocol command to a device that receives data and/or the result
|
||||
of one or more commands sent by SendData.
|
||||
|
||||
The ReceiveData function sends a security protocol command to the given MediaId.
|
||||
The security protocol command sent is defined by SecurityProtocolId and contains
|
||||
the security protocol specific data SecurityProtocolSpecificData. The function
|
||||
returns the data from the security protocol command in PayloadBuffer.
|
||||
|
||||
For devices supporting the SCSI command set, the security protocol command is sent
|
||||
using the SECURITY PROTOCOL IN command defined in SPC-4.
|
||||
|
||||
For devices supporting the ATA command set, the security protocol command is sent
|
||||
using one of the TRUSTED RECEIVE commands defined in ATA8-ACS if PayloadBufferSize
|
||||
is non-zero.
|
||||
|
||||
If the PayloadBufferSize is zero, the security protocol command is sent using the
|
||||
Trusted Non-Data command defined in ATA8-ACS.
|
||||
|
||||
If PayloadBufferSize is too small to store the available data from the security
|
||||
protocol command, the function shall copy PayloadBufferSize bytes into the
|
||||
PayloadBuffer and return EFI_WARN_BUFFER_TOO_SMALL.
|
||||
|
||||
If PayloadBuffer or PayloadTransferSize is NULL and PayloadBufferSize is non-zero,
|
||||
the function shall return EFI_INVALID_PARAMETER.
|
||||
|
||||
If the given MediaId does not support security protocol commands, the function shall
|
||||
return EFI_UNSUPPORTED. If there is no media in the device, the function returns
|
||||
EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the device,
|
||||
the function returns EFI_MEDIA_CHANGED.
|
||||
|
||||
If the security protocol fails to complete within the Timeout period, the function
|
||||
shall return EFI_TIMEOUT.
|
||||
|
||||
If the security protocol command completes without an error, the function shall
|
||||
return EFI_SUCCESS. If the security protocol command completes with an error, the
|
||||
function shall return EFI_DEVICE_ERROR.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId ID of the medium to receive data from.
|
||||
@param Timeout The timeout, in 100ns units, to use for the execution
|
||||
of the security protocol command. A Timeout value of 0
|
||||
means that this function will wait indefinitely for the
|
||||
security protocol command to execute. If Timeout is greater
|
||||
than zero, then this function will return EFI_TIMEOUT
|
||||
if the time required to execute the receive data command
|
||||
is greater than Timeout.
|
||||
@param SecurityProtocolId The value of the "Security Protocol" parameter of
|
||||
the security protocol command to be sent.
|
||||
@param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
|
||||
of the security protocol command to be sent.
|
||||
@param PayloadBufferSize Size in bytes of the payload data buffer.
|
||||
@param PayloadBuffer A pointer to a destination buffer to store the security
|
||||
protocol command specific payload data for the security
|
||||
protocol command. The caller is responsible for having
|
||||
either implicit or explicit ownership of the buffer.
|
||||
@param PayloadTransferSize A pointer to a buffer to store the size in bytes of the
|
||||
data written to the payload data buffer.
|
||||
|
||||
@retval EFI_SUCCESS The security protocol command completed successfully.
|
||||
@retval EFI_WARN_BUFFER_TOO_SMALL The PayloadBufferSize was too small to store the available
|
||||
data from the device. The PayloadBuffer contains the truncated data.
|
||||
@retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
|
||||
@retval EFI_DEVICE_ERROR The security protocol command completed with an error.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
||||
@retval EFI_INVALID_PARAMETER The PayloadBuffer or PayloadTransferSize is NULL and
|
||||
PayloadBufferSize is non-zero.
|
||||
@retval EFI_TIMEOUT A timeout occurred while waiting for the security
|
||||
protocol command to execute.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcSecurityProtocolIn (
|
||||
IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN UINT64 Timeout,
|
||||
IN UINT8 SecurityProtocolId,
|
||||
IN UINT16 SecurityProtocolSpecificData,
|
||||
IN UINTN PayloadBufferSize,
|
||||
OUT VOID *PayloadBuffer,
|
||||
OUT UINTN *PayloadTransferSize
|
||||
);
|
||||
|
||||
/**
|
||||
Send a security protocol command to a device.
|
||||
|
||||
The SendData function sends a security protocol command containing the payload
|
||||
PayloadBuffer to the given MediaId. The security protocol command sent is
|
||||
defined by SecurityProtocolId and contains the security protocol specific data
|
||||
SecurityProtocolSpecificData. If the underlying protocol command requires a
|
||||
specific padding for the command payload, the SendData function shall add padding
|
||||
bytes to the command payload to satisfy the padding requirements.
|
||||
|
||||
For devices supporting the SCSI command set, the security protocol command is sent
|
||||
using the SECURITY PROTOCOL OUT command defined in SPC-4.
|
||||
|
||||
For devices supporting the ATA command set, the security protocol command is sent
|
||||
using one of the TRUSTED SEND commands defined in ATA8-ACS if PayloadBufferSize
|
||||
is non-zero. If the PayloadBufferSize is zero, the security protocol command is
|
||||
sent using the Trusted Non-Data command defined in ATA8-ACS.
|
||||
|
||||
If PayloadBuffer is NULL and PayloadBufferSize is non-zero, the function shall
|
||||
return EFI_INVALID_PARAMETER.
|
||||
|
||||
If the given MediaId does not support security protocol commands, the function
|
||||
shall return EFI_UNSUPPORTED. If there is no media in the device, the function
|
||||
returns EFI_NO_MEDIA. If the MediaId is not the ID for the current media in the
|
||||
device, the function returns EFI_MEDIA_CHANGED.
|
||||
|
||||
If the security protocol fails to complete within the Timeout period, the function
|
||||
shall return EFI_TIMEOUT.
|
||||
|
||||
If the security protocol command completes without an error, the function shall return
|
||||
EFI_SUCCESS. If the security protocol command completes with an error, the function
|
||||
shall return EFI_DEVICE_ERROR.
|
||||
|
||||
@param This Indicates a pointer to the calling context.
|
||||
@param MediaId ID of the medium to receive data from.
|
||||
@param Timeout The timeout, in 100ns units, to use for the execution
|
||||
of the security protocol command. A Timeout value of 0
|
||||
means that this function will wait indefinitely for the
|
||||
security protocol command to execute. If Timeout is greater
|
||||
than zero, then this function will return EFI_TIMEOUT
|
||||
if the time required to execute the receive data command
|
||||
is greater than Timeout.
|
||||
@param SecurityProtocolId The value of the "Security Protocol" parameter of
|
||||
the security protocol command to be sent.
|
||||
@param SecurityProtocolSpecificData The value of the "Security Protocol Specific" parameter
|
||||
of the security protocol command to be sent.
|
||||
@param PayloadBufferSize Size in bytes of the payload data buffer.
|
||||
@param PayloadBuffer A pointer to a destination buffer to store the security
|
||||
protocol command specific payload data for the security
|
||||
protocol command.
|
||||
|
||||
@retval EFI_SUCCESS The security protocol command completed successfully.
|
||||
@retval EFI_UNSUPPORTED The given MediaId does not support security protocol commands.
|
||||
@retval EFI_DEVICE_ERROR The security protocol command completed with an error.
|
||||
@retval EFI_NO_MEDIA There is no media in the device.
|
||||
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
|
||||
@retval EFI_INVALID_PARAMETER The PayloadBuffer is NULL and PayloadBufferSize is non-zero.
|
||||
@retval EFI_TIMEOUT A timeout occurred while waiting for the security
|
||||
protocol command to execute.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcSecurityProtocolOut (
|
||||
IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
|
||||
IN UINT32 MediaId,
|
||||
IN UINT64 Timeout,
|
||||
IN UINT8 SecurityProtocolId,
|
||||
IN UINT16 SecurityProtocolSpecificData,
|
||||
IN UINTN PayloadBufferSize,
|
||||
IN VOID *PayloadBuffer
|
||||
);
|
||||
|
||||
#endif
|
||||
|
1175
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
Normal file
1175
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.c
Normal file
File diff suppressed because it is too large
Load Diff
495
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.h
Normal file
495
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.h
Normal file
@@ -0,0 +1,495 @@
|
||||
/** @file
|
||||
Header file for EmmcDxe Driver.
|
||||
|
||||
This file defines common data structures, macro definitions and some module
|
||||
internal function header files.
|
||||
|
||||
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _EMMC_DXE_H_
|
||||
#define _EMMC_DXE_H_
|
||||
|
||||
#include <Uefi.h>
|
||||
#include <IndustryStandard/Emmc.h>
|
||||
|
||||
#include <Protocol/SdMmcPassThru.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/BlockIo2.h>
|
||||
#include <Protocol/StorageSecurityCommand.h>
|
||||
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
|
||||
#include "EmmcBlockIo.h"
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gEmmcDxeDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gEmmcDxeComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gEmmcDxeComponentName2;
|
||||
|
||||
#define EMMC_PARTITION_SIGNATURE SIGNATURE_32 ('E', 'm', 'm', 'P')
|
||||
|
||||
#define EMMC_PARTITION_DATA_FROM_BLKIO(a) \
|
||||
CR(a, EMMC_PARTITION, BlockIo, EMMC_PARTITION_SIGNATURE)
|
||||
|
||||
#define EMMC_PARTITION_DATA_FROM_BLKIO2(a) \
|
||||
CR(a, EMMC_PARTITION, BlockIo2, EMMC_PARTITION_SIGNATURE)
|
||||
|
||||
#define EMMC_PARTITION_DATA_FROM_SSP(a) \
|
||||
CR(a, EMMC_PARTITION, StorageSecurity, EMMC_PARTITION_SIGNATURE)
|
||||
|
||||
//
|
||||
// Take 2.5 seconds as generic time out value, 1 microsecond as unit.
|
||||
//
|
||||
#define EMMC_GENERIC_TIMEOUT 2500 * 1000
|
||||
|
||||
#define EMMC_REQUEST_SIGNATURE SIGNATURE_32 ('E', 'm', 'R', 'e')
|
||||
|
||||
typedef struct _EMMC_DEVICE EMMC_DEVICE;
|
||||
typedef struct _EMMC_DRIVER_PRIVATE_DATA EMMC_DRIVER_PRIVATE_DATA;
|
||||
|
||||
//
|
||||
// Asynchronous I/O request.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
|
||||
EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
|
||||
EFI_SD_MMC_PASS_THRU_COMMAND_PACKET Packet;
|
||||
|
||||
BOOLEAN IsEnd;
|
||||
|
||||
EFI_BLOCK_IO2_TOKEN *Token;
|
||||
EFI_EVENT Event;
|
||||
} EMMC_REQUEST;
|
||||
|
||||
#define EMMC_REQUEST_FROM_LINK(a) \
|
||||
CR(a, EMMC_REQUEST, Link, EMMC_REQUEST_SIGNATURE)
|
||||
|
||||
typedef struct {
|
||||
UINT32 Signature;
|
||||
BOOLEAN Enable;
|
||||
EMMC_PARTITION_TYPE PartitionType;
|
||||
EFI_HANDLE Handle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
EFI_BLOCK_IO_PROTOCOL BlockIo;
|
||||
EFI_BLOCK_IO2_PROTOCOL BlockIo2;
|
||||
EFI_BLOCK_IO_MEDIA BlockMedia;
|
||||
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL StorageSecurity;
|
||||
|
||||
LIST_ENTRY Queue;
|
||||
|
||||
EMMC_DEVICE *Device;
|
||||
} EMMC_PARTITION;
|
||||
|
||||
//
|
||||
// Up to 6 slots per EMMC PCI host controller
|
||||
//
|
||||
#define EMMC_MAX_DEVICES 6
|
||||
//
|
||||
// Up to 8 partitions per EMMC device.
|
||||
//
|
||||
#define EMMC_MAX_PARTITIONS 8
|
||||
#define EMMC_MODEL_NAME_MAX_LEN 32
|
||||
|
||||
struct _EMMC_DEVICE {
|
||||
EFI_HANDLE Handle;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINT8 Slot;
|
||||
BOOLEAN SectorAddressing;
|
||||
|
||||
EMMC_PARTITION Partition[EMMC_MAX_PARTITIONS];
|
||||
EMMC_CSD Csd;
|
||||
EMMC_CID Cid;
|
||||
EMMC_EXT_CSD ExtCsd;
|
||||
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
|
||||
//
|
||||
// The model name consists of three fields in CID register
|
||||
// 1) OEM/Application ID (2 bytes)
|
||||
// 2) Product Name (5 bytes)
|
||||
// 3) Product Serial Number (4 bytes)
|
||||
// The delimiters of these fields are whitespace.
|
||||
//
|
||||
CHAR16 ModelName[EMMC_MODEL_NAME_MAX_LEN];
|
||||
EMMC_DRIVER_PRIVATE_DATA *Private;
|
||||
} ;
|
||||
|
||||
//
|
||||
// EMMC DXE driver private data structure
|
||||
//
|
||||
struct _EMMC_DRIVER_PRIVATE_DATA {
|
||||
EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;
|
||||
EFI_HANDLE Controller;
|
||||
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
|
||||
EFI_HANDLE DriverBindingHandle;
|
||||
|
||||
EMMC_DEVICE Device[EMMC_MAX_DEVICES];
|
||||
} ;
|
||||
|
||||
/**
|
||||
Tests to see if this driver supports a given controller. If a child device is provided,
|
||||
it further tests to see if this driver supports creating a handle for the specified child device.
|
||||
|
||||
This function checks to see if the driver specified by This supports the device specified by
|
||||
ControllerHandle. Drivers will typically use the device path attached to
|
||||
ControllerHandle and/or the services from the bus I/O abstraction attached to
|
||||
ControllerHandle to determine if the driver supports ControllerHandle. This function
|
||||
may be called many times during platform initialization. In order to reduce boot times, the tests
|
||||
performed by this function must be very small, and take as little time as possible to execute. This
|
||||
function must not change the state of any hardware devices, and this function must be aware that the
|
||||
device specified by ControllerHandle may already be managed by the same driver or a
|
||||
different driver. This function must match its calls to AllocatePages() with FreePages(),
|
||||
AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
|
||||
Since ControllerHandle may have been previously started by the same driver, if a protocol is
|
||||
already in the opened state, then it must not be closed with CloseProtocol(). This is required
|
||||
to guarantee the state of ControllerHandle is not modified by this function.
|
||||
|
||||
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
||||
@param[in] ControllerHandle The handle of the controller to test. This handle
|
||||
must support a protocol interface that supplies
|
||||
an I/O abstraction to the driver.
|
||||
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
||||
parameter is ignored by device drivers, and is optional for bus
|
||||
drivers. For bus drivers, if this parameter is not NULL, then
|
||||
the bus driver must determine if the bus controller specified
|
||||
by ControllerHandle and the child controller specified
|
||||
by RemainingDevicePath are both supported by this
|
||||
bus driver.
|
||||
|
||||
@retval EFI_SUCCESS The device specified by ControllerHandle and
|
||||
RemainingDevicePath is supported by the driver specified by This.
|
||||
@retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
|
||||
RemainingDevicePath is already being managed by the driver
|
||||
specified by This.
|
||||
@retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
|
||||
RemainingDevicePath is already being managed by a different
|
||||
driver or an application that requires exclusive access.
|
||||
Currently not implemented.
|
||||
@retval EFI_UNSUPPORTED The device specified by ControllerHandle and
|
||||
RemainingDevicePath is not supported by the driver specified by This.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcDxeDriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
The Start() function is designed to be invoked from the EFI boot service ConnectController().
|
||||
As a result, much of the error checking on the parameters to Start() has been moved into this
|
||||
common boot service. It is legal to call Start() from other locations,
|
||||
but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
||||
1. ControllerHandle must be a valid EFI_HANDLE.
|
||||
2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
|
||||
EFI_DEVICE_PATH_PROTOCOL.
|
||||
3. Prior to calling Start(), the Supported() function for the driver specified by This must
|
||||
have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
|
||||
|
||||
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
||||
@param[in] ControllerHandle The handle of the controller to start. This handle
|
||||
must support a protocol interface that supplies
|
||||
an I/O abstraction to the driver.
|
||||
@param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
|
||||
parameter is ignored by device drivers, and is optional for bus
|
||||
drivers. For a bus driver, if this parameter is NULL, then handles
|
||||
for all the children of Controller are created by this driver.
|
||||
If this parameter is not NULL and the first Device Path Node is
|
||||
not the End of Device Path Node, then only the handle for the
|
||||
child device specified by the first Device Path Node of
|
||||
RemainingDevicePath is created by this driver.
|
||||
If the first Device Path Node of RemainingDevicePath is
|
||||
the End of Device Path Node, no child handle is created by this
|
||||
driver.
|
||||
|
||||
@retval EFI_SUCCESS The device was started.
|
||||
@retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
||||
@retval Others The driver failded to start the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcDxeDriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
|
||||
As a result, much of the error checking on the parameters to Stop() has been moved
|
||||
into this common boot service. It is legal to call Stop() from other locations,
|
||||
but the following calling restrictions must be followed or the system behavior will not be deterministic.
|
||||
1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
|
||||
same driver's Start() function.
|
||||
2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
|
||||
EFI_HANDLE. In addition, all of these handles must have been created in this driver's
|
||||
Start() function, and the Start() function must have called OpenProtocol() on
|
||||
ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
|
||||
|
||||
@param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
|
||||
@param[in] ControllerHandle A handle to the device being stopped. The handle must
|
||||
support a bus specific I/O protocol for the driver
|
||||
to use to stop the device.
|
||||
@param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
|
||||
@param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
|
||||
if NumberOfChildren is 0.
|
||||
|
||||
@retval EFI_SUCCESS The device was stopped.
|
||||
@retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EmmcDxeDriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
This function retrieves the user readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param Language[in] 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 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param DriverName[out] 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
|
||||
EmmcDxeComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param ControllerHandle[in] The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
||||
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[in] 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 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param ControllerName[out] 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 NULL.
|
||||
|
||||
@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
|
||||
EmmcDxeComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
/**
|
||||
Send command SELECT to the device to select/deselect the device.
|
||||
|
||||
@param[in] Device A pointer to the EMMC_DEVICE instance.
|
||||
@param[in] Rca The relative device address to use.
|
||||
|
||||
@retval EFI_SUCCESS The request is executed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be executed due to a lack of resources.
|
||||
@retval Others The request could not be executed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EmmcSelect (
|
||||
IN EMMC_DEVICE *Device,
|
||||
IN UINT16 Rca
|
||||
);
|
||||
|
||||
/**
|
||||
Send command SEND_STATUS to the device to get device status.
|
||||
|
||||
@param[in] Device A pointer to the EMMC_DEVICE instance.
|
||||
@param[in] Rca The relative device address to use.
|
||||
@param[out] DevStatus The buffer to store the device status.
|
||||
|
||||
@retval EFI_SUCCESS The request is executed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be executed due to a lack of resources.
|
||||
@retval Others The request could not be executed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EmmcSendStatus (
|
||||
IN EMMC_DEVICE *Device,
|
||||
IN UINT16 Rca,
|
||||
OUT UINT32 *DevStatus
|
||||
);
|
||||
|
||||
/**
|
||||
Send command SEND_CSD to the device to get the CSD register data.
|
||||
|
||||
@param[in] Device A pointer to the EMMC_DEVICE instance.
|
||||
@param[in] Rca The relative device address to use.
|
||||
@param[out] Csd The buffer to store the EMMC_CSD register data.
|
||||
|
||||
@retval EFI_SUCCESS The request is executed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be executed due to a lack of resources.
|
||||
@retval Others The request could not be executed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EmmcGetCsd (
|
||||
IN EMMC_DEVICE *Device,
|
||||
IN UINT16 Rca,
|
||||
OUT EMMC_CSD *Csd
|
||||
);
|
||||
|
||||
/**
|
||||
Send command SEND_CID to the device to get the CID register data.
|
||||
|
||||
@param[in] Device A pointer to the EMMC_DEVICE instance.
|
||||
@param[in] Rca The relative device address to use.
|
||||
@param[out] Csd The buffer to store the EMMC_CSD register data.
|
||||
|
||||
@retval EFI_SUCCESS The request is executed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be executed due to a lack of resources.
|
||||
@retval Others The request could not be executed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EmmcGetCid (
|
||||
IN EMMC_DEVICE *Device,
|
||||
IN UINT16 Rca,
|
||||
OUT EMMC_CID *Cid
|
||||
);
|
||||
|
||||
/**
|
||||
Send command SEND_EXT_CSD to the device to get the EXT_CSD register data.
|
||||
|
||||
@param[in] Device A pointer to the EMMC_DEVICE instance.
|
||||
@param[out] ExtCsd The buffer to store the EXT_CSD register data.
|
||||
|
||||
@retval EFI_SUCCESS The request is executed successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES The request could not be executed due to a lack of resources.
|
||||
@retval Others The request could not be executed successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EmmcGetExtCsd (
|
||||
IN EMMC_DEVICE *Device,
|
||||
OUT EMMC_EXT_CSD *ExtCsd
|
||||
);
|
||||
|
||||
#endif
|
||||
|
66
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
Normal file
66
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
Normal file
@@ -0,0 +1,66 @@
|
||||
## @file
|
||||
# EmmcDxe driver is used to manage the EMMC device.
|
||||
#
|
||||
# It produces BlockIo, BlockIo2 and StorageSecurity protocols to allow upper layer
|
||||
# access the EMMC device.
|
||||
#
|
||||
# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# 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]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = EmmcDxe
|
||||
MODULE_UNI_FILE = EmmcDxe.uni
|
||||
FILE_GUID = 2145F72F-E6F1-4440-A828-59DC9AAB5F89
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = InitializeEmmcDxe
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
# DRIVER_BINDING = gEmmcDxeDriverBinding
|
||||
# COMPONENT_NAME = gEmmcDxeComponentName
|
||||
# COMPONENT_NAME2 = gEmmcDxeComponentName2
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
ComponentName.c
|
||||
EmmcDxe.c
|
||||
EmmcDxe.h
|
||||
EmmcBlockIo.c
|
||||
EmmcBlockIo.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
DevicePathLib
|
||||
UefiBootServicesTableLib
|
||||
MemoryAllocationLib
|
||||
BaseMemoryLib
|
||||
UefiLib
|
||||
BaseLib
|
||||
UefiDriverEntryPoint
|
||||
DebugLib
|
||||
|
||||
[Protocols]
|
||||
gEfiSdMmcPassThruProtocolGuid ## TO_START
|
||||
gEfiBlockIoProtocolGuid ## BY_START
|
||||
gEfiBlockIo2ProtocolGuid ## BY_START
|
||||
gEfiStorageSecurityCommandProtocolGuid ## SOMETIMES_PRODUCES
|
||||
## TO_START
|
||||
## BY_START
|
||||
gEfiDevicePathProtocolGuid
|
||||
|
20
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.uni
Normal file
20
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.uni
Normal file
@@ -0,0 +1,20 @@
|
||||
// /** @file
|
||||
// EMMC device driver to manage the EMMC device and provide interface for upper layer
|
||||
// access.
|
||||
//
|
||||
// Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// **/
|
||||
|
||||
|
||||
#string STR_MODULE_ABSTRACT #language en-US "EMMC device driver to manage the EMMC device and provide interface for upper layer access"
|
||||
|
||||
#string STR_MODULE_DESCRIPTION #language en-US "This driver follows the UEFI driver model and layers on the SdMmcPassThru protocol. It installs BlockIo/BlockIo2/StorageSecurity protocols for the EMMC device partitions."
|
||||
|
19
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxeExtra.uni
Normal file
19
MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxeExtra.uni
Normal file
@@ -0,0 +1,19 @@
|
||||
// /** @file
|
||||
// EmmcDxe Localized Strings and Content
|
||||
//
|
||||
// Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// **/
|
||||
|
||||
#string STR_PROPERTIES_MODULE_NAME
|
||||
#language en-US
|
||||
"EMMC Device Driver"
|
||||
|
||||
|
Reference in New Issue
Block a user