mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
SecurityPkg OpalPassword: Remove old solution
Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Chao Zhang <chao.b.zhang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
parent
112e584ba0
commit
957024c1bc
@ -322,8 +322,6 @@
|
||||
#
|
||||
# Opal Password solution
|
||||
#
|
||||
SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalPasswordDxe.inf
|
||||
SecurityPkg/Tcg/Opal/OpalPasswordSmm/OpalPasswordSmm.inf
|
||||
SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
|
||||
SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordPei.inf
|
||||
|
||||
|
@ -1,398 +0,0 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for Opal driver.
|
||||
|
||||
Copyright (c) 2016, 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 "OpalDriver.h"
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName = {
|
||||
OpalEfiDriverComponentNameGetDriverName,
|
||||
OpalEfiDriverComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2 = {
|
||||
OpalEfiDriverComponentName2GetDriverName,
|
||||
OpalEfiDriverComponentName2GetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
/// The name of the driver in all the languages we support.
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOpalDriverNameTable[] = {
|
||||
{ LANGUAGE_RFC_3066_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },
|
||||
{ LANGUAGE_ISO_639_2_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
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
|
||||
OpalEfiDriverComponentNameGetDriverName(
|
||||
EFI_COMPONENT_NAME_PROTOCOL* This,
|
||||
CHAR8* Language,
|
||||
CHAR16** DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2(
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mOpalDriverNameTable,
|
||||
DriverName,
|
||||
TRUE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
OpalEfiDriverComponentName2GetDriverName(
|
||||
EFI_COMPONENT_NAME2_PROTOCOL* This,
|
||||
CHAR8* Language,
|
||||
CHAR16** DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2(
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mOpalDriverNameTable,
|
||||
DriverName,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
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 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
|
||||
GetControllerName(
|
||||
EFI_HANDLE ControllerHandle,
|
||||
EFI_HANDLE ChildHandle,
|
||||
CHAR8* Language,
|
||||
CHAR16** ControllerName
|
||||
)
|
||||
{
|
||||
if (Language == NULL || ControllerName == NULL || ControllerHandle == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
// don't support any controller or children names
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
OpalEfiDriverComponentNameGetControllerName(
|
||||
EFI_COMPONENT_NAME_PROTOCOL* This,
|
||||
EFI_HANDLE ControllerHandle,
|
||||
EFI_HANDLE ChildHandle,
|
||||
CHAR8* Language,
|
||||
CHAR16** ControllerName
|
||||
)
|
||||
{
|
||||
return (GetControllerName( ControllerHandle, ChildHandle, Language, ControllerName));
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
OpalEfiDriverComponentName2GetControllerName(
|
||||
EFI_COMPONENT_NAME2_PROTOCOL* This,
|
||||
EFI_HANDLE ControllerHandle,
|
||||
EFI_HANDLE ChildHandle,
|
||||
CHAR8* Language,
|
||||
CHAR16** ControllerName
|
||||
)
|
||||
{
|
||||
return (GetControllerName(ControllerHandle, ChildHandle, Language, ControllerName));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,412 +0,0 @@
|
||||
/** @file
|
||||
Values defined and used by the Opal UEFI Driver.
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_DRIVER_H_
|
||||
#define _OPAL_DRIVER_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/SmmCommunication.h>
|
||||
#include <Protocol/BlockIo.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
#include <Protocol/DevicePathToText.h>
|
||||
#include <Protocol/StorageSecurityCommand.h>
|
||||
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/UefiHiiServicesLib.h>
|
||||
#include <Library/TcgStorageOpalLib.h>
|
||||
#include <Library/OpalPasswordSupportLib.h>
|
||||
#include <Library/Tcg2PhysicalPresenceLib.h>
|
||||
|
||||
#define EFI_DRIVER_NAME_UNICODE L"1.0 UEFI Opal Driver"
|
||||
|
||||
// UEFI 2.1
|
||||
#define LANGUAGE_RFC_3066_ENGLISH ((CHAR8*)"en")
|
||||
|
||||
// UEFI/EFI < 2.1
|
||||
#define LANGUAGE_ISO_639_2_ENGLISH ((CHAR8*)"eng")
|
||||
|
||||
|
||||
#define UNLOCK_VAR_NAME (const CHAR16*)L"UNLOCK"
|
||||
#define OPAL_FILTER_DRIVER_VAR_NAME L"FILTER_DRIVER"
|
||||
|
||||
|
||||
#define CONCAT_(x, y) x ## y
|
||||
#define CONCAT(x, y) CONCAT_(x, y)
|
||||
|
||||
#define UNICODE_STR(x) CONCAT( L, x )
|
||||
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2;
|
||||
|
||||
/**
|
||||
Unloads UEFI Driver. Very useful for debugging and testing.
|
||||
|
||||
@param ImageHandle Image handle this driver.
|
||||
|
||||
@retval EFI_SUCCESS This function always complete successfully.
|
||||
@retval EFI_INVALID_PARAMETER The input ImageHandle is not valid.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDriverUnload(
|
||||
EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports Controller.
|
||||
|
||||
@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
|
||||
OpalEfiDriverBindingSupported(
|
||||
EFI_DRIVER_BINDING_PROTOCOL* This,
|
||||
EFI_HANDLE Controller,
|
||||
EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Enables Opal Management on a supported device if available.
|
||||
|
||||
The start function is designed to be called after the Opal UEFI Driver has confirmed the
|
||||
"controller", which is a child handle, contains the EF_STORAGE_SECURITY_COMMAND protocols.
|
||||
This function will complete the other necessary checks, such as verifying the device supports
|
||||
the correct version of Opal. Upon verification, it will add the device to the
|
||||
Opal HII list in order to expose Opal managmeent options.
|
||||
|
||||
@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 Opal management was enabled.
|
||||
@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 failed to start the device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
OpalEfiDriverBindingStart(
|
||||
EFI_DRIVER_BINDING_PROTOCOL* This,
|
||||
EFI_HANDLE Controller,
|
||||
EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stop this driver on Controller.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param Controller Handle of device to stop driver on
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed Controller.
|
||||
@retval other This driver could not be removed from this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
OpalEfiDriverBindingStop(
|
||||
EFI_DRIVER_BINDING_PROTOCOL* This,
|
||||
EFI_HANDLE Controller,
|
||||
UINTN NumberOfChildren,
|
||||
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
|
||||
OpalEfiDriverComponentNameGetDriverName(
|
||||
EFI_COMPONENT_NAME_PROTOCOL* This,
|
||||
CHAR8* Language,
|
||||
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
|
||||
OpalEfiDriverComponentNameGetControllerName(
|
||||
EFI_COMPONENT_NAME_PROTOCOL* This,
|
||||
EFI_HANDLE ControllerHandle,
|
||||
EFI_HANDLE ChildHandle,
|
||||
CHAR8* Language,
|
||||
CHAR16** ControllerName
|
||||
);
|
||||
|
||||
/**
|
||||
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
|
||||
OpalEfiDriverComponentName2GetDriverName(
|
||||
EFI_COMPONENT_NAME2_PROTOCOL* This,
|
||||
CHAR8* Language,
|
||||
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
|
||||
OpalEfiDriverComponentName2GetControllerName(
|
||||
EFI_COMPONENT_NAME2_PROTOCOL* This,
|
||||
EFI_HANDLE ControllerHandle,
|
||||
EFI_HANDLE ChildHandle,
|
||||
CHAR8* Language,
|
||||
CHAR16** ControllerName
|
||||
);
|
||||
|
||||
#endif //_OPAL_DRIVER_H_
|
@ -1,102 +0,0 @@
|
||||
/** @file
|
||||
Private structures and functions used within OPAL_DRIVER
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_DRIVER_PRIVATE_H_
|
||||
#define _OPAL_DRIVER_PRIVATE_H_
|
||||
#include "OpalDriver.h"
|
||||
|
||||
#define OPAL_MSID_LENGHT 128
|
||||
|
||||
#pragma pack(1)
|
||||
//
|
||||
// Structure that is used to represent an OPAL_DISK.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 MsidLength; // Byte length of MSID Pin for device
|
||||
UINT8 Msid[OPAL_MSID_LENGHT]; // MSID Pin for device
|
||||
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp;
|
||||
UINT32 MediaId; // MediaId is used by Ssc Protocol.
|
||||
EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
|
||||
UINT16 OpalBaseComId; // Opal SSC 1 base com id.
|
||||
OPAL_OWNER_SHIP Owner;
|
||||
OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
|
||||
TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature; // Locking Feature Descriptor retrieved from performing a Level 0 Discovery
|
||||
} OPAL_DISK;
|
||||
|
||||
//
|
||||
// Device with block IO protocol
|
||||
//
|
||||
typedef struct _OPAL_DRIVER_DEVICE OPAL_DRIVER_DEVICE;
|
||||
|
||||
struct _OPAL_DRIVER_DEVICE {
|
||||
OPAL_DRIVER_DEVICE *Next; ///< Linked list pointer
|
||||
EFI_HANDLE Handle; ///< Device handle
|
||||
OPAL_DISK OpalDisk; ///< User context
|
||||
CHAR16 *Name16; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
|
||||
CHAR8 *NameZ; ///< Allocated/freed by UEFI Filter Driver at device creation/removal
|
||||
UINT32 MediaId; ///< Required parameter for EFI_STORAGE_SECURITY_COMMAND_PROTOCOL, from BLOCK_IO_MEDIA
|
||||
|
||||
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp; /// Device protocols consumed
|
||||
EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
|
||||
};
|
||||
|
||||
//
|
||||
// Opal Driver UEFI Driver Model
|
||||
//
|
||||
typedef struct {
|
||||
EFI_HANDLE Handle; ///< Driver image handle
|
||||
OPAL_DRIVER_DEVICE *DeviceList; ///< Linked list of controllers owned by this Driver
|
||||
} OPAL_DRIVER;
|
||||
#pragma pack()
|
||||
|
||||
//
|
||||
// Retrieves a OPAL_DRIVER_DEVICE based on the pointer to its StorageSecurity protocol.
|
||||
//
|
||||
#define DRIVER_DEVICE_FROM_OPALDISK(OpalDiskPointer) (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))
|
||||
|
||||
/**
|
||||
Get devcie list info.
|
||||
|
||||
@retval return the device list pointer.
|
||||
**/
|
||||
OPAL_DRIVER_DEVICE*
|
||||
OpalDriverGetDeviceList(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Get devcie name through the component name protocol.
|
||||
|
||||
@param[in] Dev The device which need to get name.
|
||||
|
||||
@retval TRUE Find the name for this device.
|
||||
@retval FALSE Not found the name for this device.
|
||||
**/
|
||||
BOOLEAN
|
||||
OpalDriverGetDriverDeviceName(
|
||||
OPAL_DRIVER_DEVICE *Dev
|
||||
);
|
||||
|
||||
/**
|
||||
Get current device count.
|
||||
|
||||
@retval return the current created device count.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
GetDeviceCount (
|
||||
VOID
|
||||
);
|
||||
|
||||
#endif // _OPAL_DRIVER_P_H_
|
File diff suppressed because it is too large
Load Diff
@ -1,146 +0,0 @@
|
||||
/** @file
|
||||
Public Header file of HII library used by Opal UEFI Driver.
|
||||
Defines required callbacks of Opal HII library.
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_HII_H_
|
||||
#define _OPAL_HII_H_
|
||||
|
||||
#include <Library/OpalPasswordSupportLib.h>
|
||||
#include <OpalDriverPrivate.h>
|
||||
|
||||
#define DEFAULT_RESPONSE_SIZE 200
|
||||
|
||||
/**
|
||||
Get the driver image handle.
|
||||
|
||||
@retval the driver image handle.
|
||||
|
||||
**/
|
||||
EFI_HANDLE
|
||||
HiiGetDriverImageHandleCB(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Install the HII form and string packages.
|
||||
|
||||
@retval EFI_SUCCESS Install all the resources success.
|
||||
@retval EFI_OUT_OF_RESOURCES Out of resource error.
|
||||
**/
|
||||
EFI_STATUS
|
||||
OpalHiiAddPackages(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether enable feature or not.
|
||||
|
||||
@retval Return the disk number.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
HiiGetNumConfigRequiredOpalDisksCB(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the driver name.
|
||||
|
||||
@retval Returns the driver name.
|
||||
|
||||
**/
|
||||
CHAR16*
|
||||
HiiGetDriverNameCB(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the opaque pointer to a physical disk context.
|
||||
|
||||
@param DiskIndex Input the disk index.
|
||||
|
||||
@retval The device pointer.
|
||||
|
||||
**/
|
||||
OPAL_DISK*
|
||||
HiiGetOpalDiskCB(
|
||||
UINT8 DiskIndex
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the disk name.
|
||||
|
||||
@param DiskIndex Input the disk index.
|
||||
|
||||
@retval Returns the disk name.
|
||||
|
||||
**/
|
||||
CHAR8*
|
||||
HiiDiskGetNameCB(
|
||||
UINT8 DiskIndex
|
||||
);
|
||||
|
||||
/**
|
||||
Set a string Value in a form.
|
||||
|
||||
@param DestStringId The stringid which need to update.
|
||||
@param SrcAsciiStr The string nned to update.
|
||||
|
||||
@retval EFI_SUCCESS Do the required action success.
|
||||
@retval Others Other error occur.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiSetFormString(
|
||||
EFI_STRING_ID DestStringId,
|
||||
CHAR8 *SrcAsciiStr
|
||||
);
|
||||
|
||||
/**
|
||||
Install the HII related resources.
|
||||
|
||||
@retval EFI_SUCCESS Install all the resources success.
|
||||
@retval other Error occur when install the resources.
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiInstall(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Uninstall the HII capability.
|
||||
|
||||
@retval EFI_SUCCESS Uninstall all the resources success.
|
||||
@retval others Other errors occur when unistall the hii resource.
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiUninstall(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the Opal disk base on the hardware info get from device.
|
||||
|
||||
@param Dev The Opal device.
|
||||
|
||||
@retval EFI_SUCESS Initialize the device success.
|
||||
@retval EFI_DEVICE_ERROR Get info from device failed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
OpalDiskInitialize (
|
||||
IN OPAL_DRIVER_DEVICE *Dev
|
||||
);
|
||||
|
||||
#endif // _HII_H_
|
@ -1,221 +0,0 @@
|
||||
/** @file
|
||||
Callbacks required by the HII of the Opal UEFI Driver to help display
|
||||
Opal device information and to send password to SMM handler.
|
||||
|
||||
Copyright (c) 2016, 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 "OpalHii.h"
|
||||
#include "OpalDriver.h"
|
||||
#include "OpalDriverPrivate.h"
|
||||
|
||||
/**
|
||||
Get Opal var name.
|
||||
The return Value must be freed by caller if not NULL
|
||||
|
||||
@param OpalDisk The disk.
|
||||
@param Prefix The prefix string.
|
||||
|
||||
@retval The var name string.
|
||||
|
||||
**/
|
||||
CHAR16*
|
||||
OpalDriverGetOpalVarName(
|
||||
OPAL_DISK *OpalDisk,
|
||||
const CHAR16 *Prefix
|
||||
)
|
||||
{
|
||||
OPAL_DRIVER_DEVICE* Dev;
|
||||
UINTN PrefixLen;
|
||||
UINTN NameLen;
|
||||
UINTN VarNameLen;
|
||||
CHAR16* VarName;
|
||||
|
||||
Dev = DRIVER_DEVICE_FROM_OPALDISK(OpalDisk);
|
||||
if (Dev == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PrefixLen = StrLen(Prefix);
|
||||
|
||||
NameLen = 0;
|
||||
if (Dev->Name16 != NULL) {
|
||||
NameLen = StrLen(Dev->Name16);
|
||||
}
|
||||
|
||||
VarNameLen = PrefixLen + NameLen;
|
||||
|
||||
VarName = (CHAR16*)AllocateZeroPool((VarNameLen + 1) * sizeof(CHAR16));
|
||||
if (VarName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CopyMem(VarName, Prefix, PrefixLen * sizeof(CHAR16));
|
||||
if (Dev->Name16 != NULL) {
|
||||
CopyMem(VarName + PrefixLen, Dev->Name16, NameLen * sizeof(CHAR16));
|
||||
}
|
||||
VarName[VarNameLen] = 0;
|
||||
|
||||
return VarName;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the driver image handle.
|
||||
|
||||
@retval the driver image handle.
|
||||
|
||||
**/
|
||||
EFI_HANDLE
|
||||
HiiGetDriverImageHandleCB(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return gImageHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
Check whether enable feature or not.
|
||||
|
||||
@retval Return the disk number.
|
||||
|
||||
**/
|
||||
UINT8
|
||||
HiiGetNumConfigRequiredOpalDisksCB(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT8 NumDisks;
|
||||
UINT8 NumLockedOpalDisks;
|
||||
OPAL_DISK *OpalDisk;
|
||||
UINT8 Index;
|
||||
|
||||
NumLockedOpalDisks = 0;
|
||||
|
||||
NumDisks = GetDeviceCount();
|
||||
|
||||
for (Index = 0; Index < NumDisks; Index++) {
|
||||
OpalDisk = HiiGetOpalDiskCB(Index);
|
||||
|
||||
if (OpalDisk != NULL) {
|
||||
if (!OpalFeatureEnabled (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) {
|
||||
DEBUG ((DEBUG_INFO, "Ignoring disk %u because feature is disabled or health has already been inspected\n", Index));
|
||||
} else if (OpalDeviceLocked (&OpalDisk->SupportedAttributes, &OpalDisk->LockingFeature)) {
|
||||
NumLockedOpalDisks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NumLockedOpalDisks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns the opaque pointer to a physical disk context.
|
||||
|
||||
@param DiskIndex Input the disk index.
|
||||
|
||||
@retval The device pointer.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
HiiGetDiskContextCB(
|
||||
UINT8 DiskIndex
|
||||
)
|
||||
{
|
||||
OPAL_DRIVER_DEVICE* Dev;
|
||||
UINT8 CurrentDisk;
|
||||
|
||||
Dev = OpalDriverGetDeviceList();
|
||||
CurrentDisk = 0;
|
||||
|
||||
if (DiskIndex >= GetDeviceCount()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (Dev != NULL) {
|
||||
if (CurrentDisk == DiskIndex) {
|
||||
return Dev;
|
||||
} else {
|
||||
Dev = Dev->Next;
|
||||
CurrentDisk++;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the opaque pointer to a physical disk context.
|
||||
|
||||
@param DiskIndex Input the disk index.
|
||||
|
||||
@retval The device pointer.
|
||||
|
||||
**/
|
||||
OPAL_DISK*
|
||||
HiiGetOpalDiskCB(
|
||||
UINT8 DiskIndex
|
||||
)
|
||||
{
|
||||
VOID *Ctx;
|
||||
OPAL_DRIVER_DEVICE *Tmp;
|
||||
|
||||
Ctx = HiiGetDiskContextCB (DiskIndex);
|
||||
|
||||
if (Ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Tmp = (OPAL_DRIVER_DEVICE*) Ctx;
|
||||
|
||||
return &Tmp->OpalDisk;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the disk name.
|
||||
|
||||
@param DiskIndex Input the disk index.
|
||||
|
||||
@retval Returns the disk name.
|
||||
|
||||
**/
|
||||
CHAR8*
|
||||
HiiDiskGetNameCB(
|
||||
UINT8 DiskIndex
|
||||
)
|
||||
{
|
||||
OPAL_DRIVER_DEVICE* Ctx;
|
||||
|
||||
Ctx = (OPAL_DRIVER_DEVICE*) HiiGetDiskContextCB (DiskIndex);
|
||||
|
||||
if (Ctx != NULL) {
|
||||
if (Ctx->NameZ == NULL) {
|
||||
OpalDriverGetDriverDeviceName (Ctx);
|
||||
}
|
||||
return Ctx->NameZ;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the driver name.
|
||||
|
||||
@retval Returns the driver name.
|
||||
|
||||
**/
|
||||
CHAR16*
|
||||
HiiGetDriverNameCB(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return (CHAR16*)EFI_DRIVER_NAME_UNICODE;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// /** @file
|
||||
//
|
||||
// String definitions for Setup formset.
|
||||
//
|
||||
// Copyright (c) 2016, 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.
|
||||
//
|
||||
// **/
|
||||
|
||||
/=#
|
||||
///////////////////////////////// GENERIC DEFINITIONS /////////////////////////////////
|
||||
#langdef en-US "English"
|
||||
#string STR_NULL #language en-US " "
|
||||
|
||||
///////////////////////////////// FORM SET /////////////////////////////////
|
||||
#string STR_FORM_SET_HELP #language en-US "Manage Opal disks"
|
||||
|
||||
///////////////////////////////// MULTIPLE FORMS /////////////////////////////////
|
||||
#string STR_OPAL #language en-US "Opal"
|
||||
#string STR_MAIN_OPAL_VERSION #language en-US "Version 00.0.0.0000"
|
||||
|
||||
///////////////////////////////// MAIN MENU FORM /////////////////////////////////
|
||||
#string STR_MAIN_PHY_DISKS_LBL #language en-US "Physical Disks:"
|
||||
#string STR_MAIN_LOCKED_DISKS_LBL #language en-US "Locked Disks:"
|
||||
|
||||
#string STR_MAIN_GOTO_DISK_INFO_0 #language en-US " "
|
||||
#string STR_MAIN_GOTO_DISK_INFO_1 #language en-US " "
|
||||
#string STR_MAIN_GOTO_DISK_INFO_2 #language en-US " "
|
||||
#string STR_MAIN_GOTO_DISK_INFO_3 #language en-US " "
|
||||
#string STR_MAIN_GOTO_DISK_INFO_4 #language en-US " "
|
||||
#string STR_MAIN_GOTO_DISK_INFO_5 #language en-US " "
|
||||
|
||||
#string STR_MAIN_GOTO_DISK_INFO_HELP #language en-US "Select to see Opal disk actions"
|
||||
#string STR_MAIN_GOTO_DISK_HEALTH_HELP #language en-US "Select disk to unlock"
|
||||
|
||||
#string STR_MAIN_NO_DISKS_PRESENT_LBL #language en-US "No disks connected to system"
|
||||
|
||||
///////////////////////////////// DISK INFO MENU FORM /////////////////////////////////
|
||||
#string STR_DISK_INFO_SELECTED_DISK_NAME #language en-US " "
|
||||
|
||||
#string STR_DISK_INFO_LOCK #language en-US "Lock"
|
||||
#string STR_DISK_INFO_UNLOCK #language en-US "Unlock"
|
||||
#string STR_DISK_INFO_SET_ADMIN_PSWD #language en-US "Update Drive Admin Password"
|
||||
#string STR_DISK_INFO_SET_USER_PSWD #language en-US "Set Drive User Password"
|
||||
#string STR_DISK_INFO_SECURE_ERASE #language en-US "Secure Erase User Data"
|
||||
#string STR_DISK_INFO_PSID_REVERT #language en-US "PSID Revert to factory default"
|
||||
#string STR_DISK_INFO_REVERT #language en-US "Admin Revert to factory default and Disable"
|
||||
#string STR_DISK_INFO_DISABLE_USER #language en-US "Disable User"
|
||||
#string STR_DISK_INFO_ENABLE_FEATURE #language en-US "Enable Feature"
|
||||
#string STR_DISK_INFO_ENABLE_BLOCKSID #language en-US "TCG Storage Action"
|
||||
#string STR_ENABLED #language en-US "Enable BlockSID"
|
||||
#string STR_DISABLED #language en-US "Disable BlockSID"
|
||||
|
||||
#string STR_NONE #language en-US "None"
|
||||
#string STR_DISK_INFO_ENABLE_BLOCKSID_TRUE #language en-US "Require physical presence when remote enable BlockSID"
|
||||
#string STR_DISK_INFO_ENABLE_BLOCKSID_FALSE #language en-US "Not require physical presence when remote enable BlockSID"
|
||||
#string STR_DISK_INFO_DISABLE_BLOCKSID_TRUE #language en-US "Require physical presence when remote disable BlockSID"
|
||||
#string STR_DISK_INFO_DISABLE_BLOCKSID_FALSE #language en-US "Not require physical presence when remote disable BlockSID"
|
||||
|
||||
#string STR_BLOCKSID_STATUS_HELP #language en-US "BlockSID action change status"
|
||||
#string STR_BLOCKSID_STATUS #language en-US "Current BlockSID Status:"
|
||||
#string STR_BLOCKSID_STATUS1 #language en-US ""
|
||||
#string STR_BLOCKSID_STATUS2 #language en-US ""
|
||||
#string STR_BLOCKSID_STATUS3 #language en-US ""
|
||||
|
||||
#string STR_DISK_INFO_GOTO_LOCK_HELP #language en-US "Lock the disk"
|
||||
#string STR_DISK_INFO_GOTO_UNLOCK_HELP #language en-US "Unlock the disk"
|
||||
#string STR_DISK_INFO_GOTO_SET_ADMIN_PSWD_HELP #language en-US "Set password for the administrator"
|
||||
#string STR_DISK_INFO_GOTO_SET_USER_PSWD_HELP #language en-US "Set password for User 1"
|
||||
#string STR_DISK_INFO_GOTO_SECURE_ERASE_HELP #language en-US "Securely erase the disk"
|
||||
#string STR_DISK_INFO_GOTO_PSID_REVERT_HELP #language en-US "Revert the disk to factory defaults"
|
||||
#string STR_DISK_INFO_GOTO_DISABLE_USER_HELP #language en-US "Disable User"
|
||||
#string STR_DISK_INFO_GOTO_ENABLE_FEATURE_HELP #language en-US "Enable Feature"
|
||||
#string STR_DISK_INFO_GOTO_ENABLE_BLOCKSID_HELP #language en-US "Change BlockSID actions, includes enable or disable BlockSID, Require or not require physical presence when remote enable or disable BlockSID"
|
||||
|
||||
///////////////////////////////// DISK ACTION MENU FORM /////////////////////////////////
|
||||
#string STR_DISK_ACTION_LBL #language en-US " "
|
||||
|
||||
#string STR_PASSWORD_PROMPT #language en-US "Enter Password"
|
||||
#string STR_PASSWORD_HELP #language en-US "Password must be between 6 and 20 characters"
|
||||
|
||||
#string STR_REVERT_PROMPT #language en-US "Enter PSID"
|
||||
#string STR_REVERT_HELP #language en-US "PSID is a 32 character case sensitive value"
|
||||
#string STR_ACTION_STATUS #language en-US " "
|
||||
|
||||
#string STR_PASSWORD_SUBMIT #language en-US "Submit Password Changes"
|
||||
#string STR_PASSWORD_SUBMIT_HELP #language en-US "Submits Password Changes (new and update) after passwords have been entered"
|
||||
|
||||
#string STR_GOTO_HOME #language en-US "Main Menu"
|
||||
#string STR_GOTO_HOME_HELP #language en-US "Return to the main menu"
|
||||
|
||||
#string STR_KEEP_USER_DATA_PROMPT #language en-US "Keep User Data"
|
||||
#string STR_KEEP_USER_DATA_HELP #language en-US "Checkmark to keep user data, otherwise data will be lost"
|
||||
|
||||
#string STR_OK #language en-US "OK"
|
||||
|
@ -1,120 +0,0 @@
|
||||
/** @file
|
||||
Defines Opal HII form ids, structures and values.
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_HII_FORM_VALUES_H_
|
||||
#define _OPAL_HII_FORM_VALUES_H_
|
||||
|
||||
// Maximum Opal password Length
|
||||
#define MAX_PASSWORD_CHARACTER_LENGTH 0x14
|
||||
|
||||
// PSID Length
|
||||
#define PSID_CHARACTER_LENGTH 0x20
|
||||
#define PSID_CHARACTER_STRING_END_LENGTH 0x21
|
||||
|
||||
// ID's for various forms that will be used by HII
|
||||
#define FORMID_VALUE_MAIN_MENU 0x01
|
||||
#define FORMID_VALUE_DISK_INFO_FORM_MAIN 0x02
|
||||
#define FORMID_VALUE_DISK_ACTION_FORM 0x03
|
||||
|
||||
// Structure defining the OPAL_HII_CONFIGURATION
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
UINT8 NumDisks;
|
||||
UINT8 SelectedDiskIndex;
|
||||
UINT8 SelectedAction;
|
||||
UINT16 SelectedDiskAvailableActions;
|
||||
UINT16 SupportedDisks;
|
||||
UINT8 KeepUserData;
|
||||
UINT16 AvailableFields;
|
||||
UINT16 Password[MAX_PASSWORD_CHARACTER_LENGTH];
|
||||
UINT16 Psid[PSID_CHARACTER_STRING_END_LENGTH];
|
||||
UINT8 EnableBlockSid;
|
||||
} OPAL_HII_CONFIGURATION;
|
||||
#pragma pack()
|
||||
|
||||
/* Action Flags */
|
||||
#define HII_ACTION_NONE 0x0000
|
||||
#define HII_ACTION_LOCK 0x0001
|
||||
#define HII_ACTION_UNLOCK 0x0002
|
||||
#define HII_ACTION_SET_ADMIN_PWD 0x0004
|
||||
#define HII_ACTION_SET_USER_PWD 0x0008
|
||||
#define HII_ACTION_SECURE_ERASE 0x0010
|
||||
#define HII_ACTION_PSID_REVERT 0x0020
|
||||
#define HII_ACTION_DISABLE_USER 0x0040
|
||||
#define HII_ACTION_REVERT 0x0080
|
||||
#define HII_ACTION_DISABLE_FEATURE 0x0100
|
||||
#define HII_ACTION_ENABLE_FEATURE 0x0200
|
||||
|
||||
/* Flags for diskActionAvailableFields */
|
||||
#define HII_FIELD_PASSWORD 0x0001
|
||||
#define HII_FIELD_PSID 0x0002
|
||||
#define HII_FIELD_KEEP_USER_DATA 0x0004
|
||||
#define HII_FIELD_KEEP_USER_DATA_FORCED 0x0008
|
||||
|
||||
/* Number of bits allocated for each part of a unique key for an HII_ITEM
|
||||
* all bits together must be <= 16 (EFI_QUESTION_ID is UINT16)
|
||||
* 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
* | |-----------------------| |---------------------------|
|
||||
* FLG INDEX ID
|
||||
*/
|
||||
#define HII_KEY_ID_BITS 8
|
||||
#define HII_KEY_INDEX_BITS 7
|
||||
#define HII_KEY_FLAG_BITS 1
|
||||
|
||||
#define HII_KEY_FLAG 0x8000 // bit 15 (zero based)
|
||||
|
||||
/***********/
|
||||
/* Key IDs */
|
||||
/***********/
|
||||
|
||||
#define HII_KEY_ID_GOTO_MAIN_MENU 0
|
||||
#define HII_KEY_ID_GOTO_DISK_INFO 1
|
||||
#define HII_KEY_ID_GOTO_LOCK 2
|
||||
#define HII_KEY_ID_GOTO_UNLOCK 3
|
||||
#define HII_KEY_ID_GOTO_SET_ADMIN_PWD 4
|
||||
#define HII_KEY_ID_GOTO_SET_USER_PWD 5
|
||||
#define HII_KEY_ID_GOTO_SECURE_ERASE 6
|
||||
#define HII_KEY_ID_GOTO_PSID_REVERT 7
|
||||
#define HII_KEY_ID_GOTO_REVERT 8
|
||||
#define HII_KEY_ID_GOTO_DISABLE_USER 9
|
||||
#define HII_KEY_ID_GOTO_ENABLE_FEATURE 0xA //10
|
||||
#define HII_KEY_ID_GOTO_CONFIRM_TO_MAIN_MENU 0xB //11
|
||||
#define HII_KEY_ID_ENTER_PASSWORD 0xC //12
|
||||
#define HII_KEY_ID_ENTER_PSID 0xD //13
|
||||
#define HII_KEY_ID_VAR_SUPPORTED_DISKS 0xE //14
|
||||
#define HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS 0xF //15
|
||||
|
||||
#define HII_KEY_ID_BLOCKSID 0x17 //23
|
||||
#define HII_KEY_ID_MAX 0x17 //23 // !!Update each time a new ID is added!!
|
||||
|
||||
#define HII_KEY_WITH_INDEX(id, index) \
|
||||
( \
|
||||
HII_KEY_FLAG | \
|
||||
(id) | \
|
||||
((index) << HII_KEY_ID_BITS) \
|
||||
)
|
||||
|
||||
#define HII_KEY(id) HII_KEY_WITH_INDEX(id, 0)
|
||||
|
||||
#define PACKAGE_LIST_GUID { 0xf0308176, 0x9058, 0x4153, { 0x93, 0x3d, 0xda, 0x2f, 0xdc, 0xc8, 0x3e, 0x44 } }
|
||||
|
||||
/* {410483CF-F4F9-4ece-848A-1958FD31CEB7} */
|
||||
#define SETUP_FORMSET_GUID { 0x410483cf, 0xf4f9, 0x4ece, { 0x84, 0x8a, 0x19, 0x58, 0xfd, 0x31, 0xce, 0xb7 } }
|
||||
|
||||
// {BBF1ACD2-28D8-44ea-A291-58A237FEDF1A}
|
||||
#define SETUP_VARIABLE_GUID { 0xbbf1acd2, 0x28d8, 0x44ea, { 0xa2, 0x91, 0x58, 0xa2, 0x37, 0xfe, 0xdf, 0x1a } }
|
||||
|
||||
#endif //_HII_FORM_VALUES_H_
|
||||
|
@ -1,268 +0,0 @@
|
||||
/** @file
|
||||
Private functions and sturctures used by the Opal UEFI Driver.
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_HII_PRIVATE_H_
|
||||
#define _OPAL_HII_PRIVATE_H_
|
||||
|
||||
|
||||
|
||||
#include <Library/OpalPasswordSupportLib.h>
|
||||
#include <Protocol/HiiConfigAccess.h>
|
||||
|
||||
#include "OpalHii.h"
|
||||
#include "OpalHiiFormValues.h"
|
||||
|
||||
|
||||
#define OPAL_PASSWORD_CONFIG_GUID \
|
||||
{ \
|
||||
0x0d510a4f, 0xa81b, 0x473f, { 0x87, 0x07, 0xb7, 0xfd, 0xfb, 0xc0, 0x45, 0xba } \
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
UINT16 Id: HII_KEY_ID_BITS;
|
||||
UINT16 Index: HII_KEY_INDEX_BITS;
|
||||
UINT16 Flag: HII_KEY_FLAG_BITS;
|
||||
} KEY_BITS;
|
||||
|
||||
typedef union {
|
||||
UINT16 Raw;
|
||||
KEY_BITS KeyBits;
|
||||
} HII_KEY;
|
||||
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH VendorDevicePath;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} HII_VENDOR_DEVICE_PATH;
|
||||
|
||||
/**
|
||||
* Opal PSID Authority utilized for PSID revert
|
||||
*
|
||||
* The type indicates the structure of the PSID authority
|
||||
*/
|
||||
typedef struct {
|
||||
UINT8 Psid[PSID_CHARACTER_LENGTH];
|
||||
} TCG_PSID;
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param Configuration A null-terminated Unicode string in <ConfigResp>
|
||||
format.
|
||||
@param Progress A pointer to a string filled in with the offset of
|
||||
the most recent '&' before the first failing
|
||||
name/value pair (or the beginning of the string if
|
||||
the failure is in the first name/value pair) or
|
||||
the terminating NULL if all was successful.
|
||||
|
||||
@retval EFI_SUCCESS The Results is processed successfully.
|
||||
@retval EFI_INVALID_PARAMETER Configuration is NULL.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
RouteConfig(
|
||||
CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
CONST EFI_STRING Configuration,
|
||||
EFI_STRING *Progress
|
||||
);
|
||||
|
||||
/**
|
||||
This function allows a caller to extract the current configuration for one
|
||||
or more named elements from the target driver.
|
||||
|
||||
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param Request A null-terminated Unicode string in
|
||||
<ConfigRequest> format.
|
||||
@param Progress On return, points to a character in the Request
|
||||
string. Points to the string's null terminator if
|
||||
request was successful. Points to the most recent
|
||||
'&' before the first failing name/value pair (or
|
||||
the beginning of the string if the failure is in
|
||||
the first name/value pair) if the request was not
|
||||
successful.
|
||||
@param Results A null-terminated Unicode string in
|
||||
<ConfigAltResp> format which has all values filled
|
||||
in for the names in the Request string. String to
|
||||
be allocated by the called function.
|
||||
|
||||
@retval EFI_SUCCESS The Results is filled with the requested values.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
|
||||
@retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
|
||||
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this
|
||||
driver.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ExtractConfig(
|
||||
CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
||||
CONST EFI_STRING Request,
|
||||
EFI_STRING *Progress,
|
||||
EFI_STRING *Results
|
||||
);
|
||||
|
||||
/**
|
||||
This function processes the results of changes in configuration.
|
||||
|
||||
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
||||
@param Action Specifies the type of action taken by the browser.
|
||||
@param QuestionId A unique value which is sent to the original
|
||||
exporting driver so that it can identify the type
|
||||
of data to expect.
|
||||
@param Type The type of value for the question.
|
||||
@param Value A pointer to the data being sent to the original
|
||||
exporting driver.
|
||||
@param ActionRequest On return, points to the action requested by the
|
||||
callback function.
|
||||
|
||||
@retval EFI_SUCCESS The callback successfully handled the action.
|
||||
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
|
||||
variable and its data.
|
||||
@retval EFI_DEVICE_ERROR The variable could not be saved.
|
||||
@retval EFI_UNSUPPORTED The specified Action is not supported by the
|
||||
callback.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DriverCallback(
|
||||
CONST EFI_HII_CONFIG_ACCESS_PROTOCOL* This,
|
||||
EFI_BROWSER_ACTION Action,
|
||||
EFI_QUESTION_ID QuestionId,
|
||||
UINT8 Type,
|
||||
EFI_IFR_TYPE_VALUE* Value,
|
||||
EFI_BROWSER_ACTION_REQUEST* ActionRequest
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Pass the current system state to the bios via the hii_G_Configuration.
|
||||
|
||||
**/
|
||||
VOID
|
||||
OpalHiiSetBrowserData (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
Populate the hii_g_Configuraton with the browser Data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
OpalHiiGetBrowserData (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Draws the disk info form.
|
||||
|
||||
@retval EFI_SUCCESS Draw the disk info success.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiPopulateDiskInfoForm(
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Update the global Disk index info.
|
||||
|
||||
@param Index The input disk index info.
|
||||
|
||||
@retval EFI_SUCCESS Update the disk index info success.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiSelectDisk(
|
||||
UINT8 Index
|
||||
);
|
||||
|
||||
/**
|
||||
Use the input password to do the specified action.
|
||||
|
||||
@param Str The input password saved in.
|
||||
|
||||
@retval EFI_SUCCESS Do the required action success.
|
||||
@retval Others Other error occur.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiPasswordEntered(
|
||||
EFI_STRING_ID Str
|
||||
);
|
||||
|
||||
/**
|
||||
Update block sid info.
|
||||
|
||||
@param PpRequest Input the Pp Request.
|
||||
|
||||
@retval EFI_SUCCESS Do the required action success.
|
||||
@retval Others Other error occur.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiSetBlockSidAction (
|
||||
UINT32 PpRequest
|
||||
);
|
||||
|
||||
/**
|
||||
Reverts the Opal disk to factory default.
|
||||
|
||||
@param PsidStringId The string id for the PSID info.
|
||||
|
||||
@retval EFI_SUCCESS Do the required action success.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
HiiPsidRevert(
|
||||
EFI_STRING_ID PsidStringId
|
||||
);
|
||||
|
||||
/**
|
||||
Get disk name string id.
|
||||
|
||||
@param DiskIndex The input disk index info.
|
||||
|
||||
@retval The disk name string id.
|
||||
|
||||
**/
|
||||
EFI_STRING_ID
|
||||
GetDiskNameStringId(
|
||||
UINT8 DiskIndex
|
||||
);
|
||||
|
||||
/**
|
||||
Update the device info.
|
||||
|
||||
@param OpalDisk The Opal device.
|
||||
|
||||
@retval EFI_SUCESS Initialize the device success.
|
||||
@retval EFI_DEVICE_ERROR Get info from device failed.
|
||||
@retval EFI_INVALID_PARAMETER Not get Msid info before get ownership info.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
OpalDiskUpdateStatus (
|
||||
OPAL_DISK *OpalDisk
|
||||
);
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif // _HII_P_H_
|
@ -1,82 +0,0 @@
|
||||
## @file
|
||||
# This is a OpalPasswordDxe driver.
|
||||
#
|
||||
# This module is used to Management the Opal feature
|
||||
# for Opal supported devices.
|
||||
#
|
||||
#
|
||||
# Copyright (c) 2016, 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 = 0x00010007
|
||||
BASE_NAME = OpalPasswordDxe
|
||||
FILE_GUID = E3E4048D-6C0C-43E4-AE1C-FFB579D8EF41
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = EfiDriverEntryPoint
|
||||
UNLOAD_IMAGE = OpalEfiDriverUnload
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
OpalDriver.h
|
||||
OpalHii.c
|
||||
OpalHiiCallbacks.c
|
||||
OpalDriver.c
|
||||
OpalDriverPrivate.h
|
||||
OpalHii.h
|
||||
OpalHiiPrivate.h
|
||||
OpalHiiFormValues.h
|
||||
OpalPasswordForm.vfr
|
||||
OpalHiiFormStrings.uni
|
||||
ComponentName.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
SecurityPkg/SecurityPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
UefiHiiServicesLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
HiiLib
|
||||
PrintLib
|
||||
DevicePathLib
|
||||
OpalPasswordSupportLib
|
||||
UefiLib
|
||||
TcgStorageOpalLib
|
||||
Tcg2PhysicalPresenceLib
|
||||
|
||||
[Protocols]
|
||||
gEfiHiiConfigAccessProtocolGuid ## PRODUCES
|
||||
gEfiStorageSecurityCommandProtocolGuid ## CONSUMES
|
||||
gEfiComponentNameProtocolGuid ## PRODUCES
|
||||
gEfiComponentName2ProtocolGuid ## PRODUCES
|
||||
gEfiBlockIoProtocolGuid ## CONSUMES
|
||||
gEfiSmmCommunicationProtocolGuid ## PRODUCES
|
||||
gEfiPciIoProtocolGuid ## CONSUMES
|
||||
gEfiDevicePathToTextProtocolGuid ## CONSUMES
|
||||
|
||||
[Guids]
|
||||
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
|
||||
gOpalExtraInfoVariableGuid ## PRODUCES ## GUID
|
||||
|
||||
[Depex]
|
||||
gEfiSmmCommunicationProtocolGuid AND gEfiHiiStringProtocolGuid AND gEfiHiiDatabaseProtocolGuid
|
@ -1,350 +0,0 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2016, 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 "OpalHiiFormValues.h"
|
||||
|
||||
|
||||
#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \
|
||||
{ 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }
|
||||
|
||||
formset
|
||||
guid = SETUP_FORMSET_GUID,
|
||||
title = STRING_TOKEN(STR_OPAL),
|
||||
help = STRING_TOKEN(STR_FORM_SET_HELP),
|
||||
classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
|
||||
|
||||
// Define a Buffer Storage (EFI_IFR_VARSTORE) that will be filled
|
||||
// out initially through extractConfig call
|
||||
varstore OPAL_HII_CONFIGURATION, // This is the Data structure type
|
||||
name = OpalHiiConfig, // Define referenced name in vfr
|
||||
guid = SETUP_VARIABLE_GUID; // GUID of this Buffer storage
|
||||
|
||||
form formid = FORMID_VALUE_MAIN_MENU,
|
||||
title = STRING_TOKEN(STR_OPAL);
|
||||
|
||||
//CONFIG_VARIABLE(HII_KEY(HII_KEY_ID_VAR_SUPPORTED_DISKS), SupportedDisks, 0x0, 0xFFFF);
|
||||
suppressif TRUE;
|
||||
numeric
|
||||
name = SupportedDisks,
|
||||
varid = OpalHiiConfig.SupportedDisks,
|
||||
prompt = STRING_TOKEN(STR_NULL),
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x800E, //32782,
|
||||
minimum = 0x0,
|
||||
maximum = 0xFFFF,
|
||||
endnumeric;
|
||||
endif;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_MAIN_OPAL_VERSION);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_MAIN_PHY_DISKS_LBL);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
//DISK( 0 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x1 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_0 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8001; //32769
|
||||
endif;
|
||||
|
||||
//DISK( 1 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x2 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_1 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8101; //33025
|
||||
endif;
|
||||
|
||||
//DISK( 2 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x4 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_2 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8201; //33281
|
||||
endif;
|
||||
|
||||
//DISK( 3 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x8 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_3 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8301; // 33537
|
||||
endif;
|
||||
|
||||
//DISK( 4 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x10 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_4 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8401; // 33793
|
||||
endif;
|
||||
|
||||
//DISK( 5 );
|
||||
suppressif ( questionref(SupportedDisks) & ( 0x20 ) ) == 0;
|
||||
goto FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
prompt = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_5 ),
|
||||
help = STRING_TOKEN(STR_MAIN_GOTO_DISK_INFO_HELP),
|
||||
flags = INTERACTIVE, \
|
||||
key = 0x8501; // 34049
|
||||
endif;
|
||||
|
||||
//No disks on system
|
||||
suppressif ideqval OpalHiiConfig.NumDisks > 0;
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_MAIN_NO_DISKS_PRESENT_LBL);
|
||||
endif;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
grayoutif TRUE;
|
||||
text
|
||||
help = STRING_TOKEN(STR_BLOCKSID_STATUS_HELP),
|
||||
text = STRING_TOKEN(STR_BLOCKSID_STATUS);
|
||||
text
|
||||
help = STRING_TOKEN(STR_BLOCKSID_STATUS_HELP),
|
||||
text = STRING_TOKEN(STR_BLOCKSID_STATUS1);
|
||||
text
|
||||
help = STRING_TOKEN(STR_BLOCKSID_STATUS_HELP),
|
||||
text = STRING_TOKEN(STR_BLOCKSID_STATUS2);
|
||||
text
|
||||
help = STRING_TOKEN(STR_BLOCKSID_STATUS_HELP),
|
||||
text = STRING_TOKEN(STR_BLOCKSID_STATUS3);
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
endif;
|
||||
|
||||
oneof varid = OpalHiiConfig.EnableBlockSid,
|
||||
questionid = 0x8017, // 32791,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_ENABLE_BLOCKSID),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_ENABLE_BLOCKSID_HELP),
|
||||
flags = INTERACTIVE,
|
||||
option text = STRING_TOKEN(STR_NONE), value = 0, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_ENABLED), value = 1, flags = RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_DISABLED), value = 2, flags = RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_DISK_INFO_ENABLE_BLOCKSID_TRUE), value = 3, flags = RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_DISK_INFO_ENABLE_BLOCKSID_FALSE), value = 4, flags = RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_DISK_INFO_DISABLE_BLOCKSID_TRUE), value = 5, flags = RESET_REQUIRED;
|
||||
option text = STRING_TOKEN(STR_DISK_INFO_DISABLE_BLOCKSID_FALSE), value = 6, flags = RESET_REQUIRED;
|
||||
endoneof;
|
||||
|
||||
|
||||
|
||||
endform; // MAIN MENU FORM
|
||||
|
||||
//
|
||||
///////////////// DISK INFO FORM /////////////////
|
||||
//
|
||||
form formid = FORMID_VALUE_DISK_INFO_FORM_MAIN,
|
||||
title = STRING_TOKEN(STR_OPAL);
|
||||
|
||||
suppressif TRUE;
|
||||
numeric
|
||||
name = SelectedDiskAvailableActions,
|
||||
varid = OpalHiiConfig.SelectedDiskAvailableActions,
|
||||
prompt = STRING_TOKEN(STR_NULL),
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x800F, // 32783
|
||||
minimum = 0x0,
|
||||
maximum = 0xFFFF,
|
||||
endnumeric;
|
||||
endif;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_MAIN_OPAL_VERSION);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_DISK_INFO_SELECTED_DISK_NAME);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_LOCK ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_LOCK),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_LOCK_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8002; // 32770
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_UNLOCK ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_UNLOCK),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_UNLOCK_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8003; //32771;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_SET_ADMIN_PWD ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_SET_ADMIN_PSWD),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_SET_ADMIN_PSWD_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8004; //32772;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_SET_USER_PWD ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_SET_USER_PSWD),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_SET_USER_PSWD_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8005; //32773;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_SECURE_ERASE ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_SECURE_ERASE),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_SECURE_ERASE_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8006; //32774;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_REVERT ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_REVERT),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_PSID_REVERT_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8008; //32776;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_PSID_REVERT ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_PSID_REVERT),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_PSID_REVERT_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8007; //32775;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_DISABLE_USER ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_DISABLE_USER),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_DISABLE_USER_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8009; //32777;
|
||||
endif;
|
||||
|
||||
suppressif ( questionref(SelectedDiskAvailableActions) & HII_ACTION_ENABLE_FEATURE ) == 0;
|
||||
goto FORMID_VALUE_DISK_ACTION_FORM,
|
||||
prompt = STRING_TOKEN(STR_DISK_INFO_ENABLE_FEATURE),
|
||||
help = STRING_TOKEN(STR_DISK_INFO_GOTO_ENABLE_FEATURE_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x800A; //32778;
|
||||
endif;
|
||||
|
||||
endform; // DISK INFO FORM
|
||||
|
||||
//
|
||||
///////////////// DISK ACTION FORM /////////////////
|
||||
//
|
||||
form formid = FORMID_VALUE_DISK_ACTION_FORM,
|
||||
title = STRING_TOKEN(STR_OPAL);
|
||||
|
||||
suppressif TRUE;
|
||||
numeric
|
||||
name = AvailableFields,
|
||||
varid = OpalHiiConfig.AvailableFields,
|
||||
prompt = STRING_TOKEN(STR_NULL),
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8012, //32786,
|
||||
minimum = 0x0,
|
||||
maximum = 0xFFFF,
|
||||
endnumeric;
|
||||
endif;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_MAIN_OPAL_VERSION);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_DISK_INFO_SELECTED_DISK_NAME);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_DISK_ACTION_LBL);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
suppressif (questionref(AvailableFields) & HII_FIELD_KEEP_USER_DATA) == 0;
|
||||
grayoutif (questionref(AvailableFields) & HII_FIELD_KEEP_USER_DATA_FORCED) != 0;
|
||||
checkbox
|
||||
name = MyCheckbox,
|
||||
varid = OpalHiiConfig.KeepUserData,
|
||||
prompt = STRING_TOKEN(STR_KEEP_USER_DATA_PROMPT),
|
||||
help = STRING_TOKEN(STR_KEEP_USER_DATA_HELP),
|
||||
key = 0x8011, //32785,
|
||||
endcheckbox;
|
||||
|
||||
//EMPTY_LINE;
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_NULL);
|
||||
endif;
|
||||
endif;
|
||||
|
||||
suppressif (questionref(AvailableFields) & HII_FIELD_PASSWORD) == 0;
|
||||
password
|
||||
varid = OpalHiiConfig.Password,
|
||||
prompt = STRING_TOKEN(STR_PASSWORD_PROMPT),
|
||||
help = STRING_TOKEN(STR_PASSWORD_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x800C, //32780,
|
||||
minsize = 6,
|
||||
maxsize = 20,
|
||||
endpassword;
|
||||
endif;
|
||||
|
||||
suppressif (questionref(AvailableFields) & HII_FIELD_PSID) == 0;
|
||||
string
|
||||
varid = OpalHiiConfig.Psid,
|
||||
prompt = STRING_TOKEN(STR_REVERT_PROMPT),
|
||||
help = STRING_TOKEN(STR_REVERT_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x800D, //32781,
|
||||
minsize = PSID_CHARACTER_LENGTH,
|
||||
maxsize = PSID_CHARACTER_LENGTH,
|
||||
endstring;
|
||||
endif;
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
text
|
||||
help = STRING_TOKEN(STR_NULL),
|
||||
text = STRING_TOKEN(STR_ACTION_STATUS);
|
||||
|
||||
subtitle text = STRING_TOKEN(STR_NULL);
|
||||
|
||||
goto FORMID_VALUE_MAIN_MENU,
|
||||
prompt = STRING_TOKEN(STR_GOTO_HOME),
|
||||
help = STRING_TOKEN(STR_GOTO_HOME_HELP),
|
||||
flags = INTERACTIVE,
|
||||
key = 0x8000; //32768;
|
||||
|
||||
endform; // DISK ACTION FORM
|
||||
|
||||
endformset;
|
File diff suppressed because it is too large
Load Diff
@ -1,408 +0,0 @@
|
||||
/** @file
|
||||
Header file for AHCI mode of ATA host controller.
|
||||
|
||||
Copyright (c) 2016, 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 __OPAL_PASSWORD_AHCI_MODE_H__
|
||||
#define __OPAL_PASSWORD_AHCI_MODE_H__
|
||||
|
||||
//
|
||||
// OPAL LIBRARY CALLBACKS
|
||||
//
|
||||
#define ATA_COMMAND_TRUSTED_RECEIVE 0x5C
|
||||
#define ATA_COMMAND_TRUSTED_SEND 0x5E
|
||||
|
||||
//
|
||||
// ATA TRUSTED commands express transfer Length in 512 byte multiple
|
||||
//
|
||||
#define ATA_TRUSTED_TRANSFER_LENGTH_MULTIPLE 512
|
||||
#define ATA_DEVICE_LBA 0x40 ///< Set for commands with LBA (rather than CHS) addresses
|
||||
|
||||
|
||||
#define EFI_AHCI_BAR_INDEX 0x05
|
||||
|
||||
#define EFI_AHCI_CAPABILITY_OFFSET 0x0000
|
||||
#define EFI_AHCI_CAP_SAM BIT18
|
||||
#define EFI_AHCI_GHC_OFFSET 0x0004
|
||||
#define EFI_AHCI_GHC_RESET BIT0
|
||||
#define EFI_AHCI_GHC_IE BIT1
|
||||
#define EFI_AHCI_GHC_ENABLE BIT31
|
||||
#define EFI_AHCI_IS_OFFSET 0x0008
|
||||
#define EFI_AHCI_PI_OFFSET 0x000C
|
||||
|
||||
typedef struct {
|
||||
UINT32 Lower32;
|
||||
UINT32 Upper32;
|
||||
} DATA_32;
|
||||
|
||||
typedef union {
|
||||
DATA_32 Uint32;
|
||||
UINT64 Uint64;
|
||||
} DATA_64;
|
||||
|
||||
//
|
||||
// Each PRDT entry can point to a memory block up to 4M byte
|
||||
//
|
||||
#define EFI_AHCI_MAX_DATA_PER_PRDT 0x400000
|
||||
|
||||
#define EFI_AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
|
||||
#define EFI_AHCI_FIS_REGISTER_H2D_LENGTH 20
|
||||
#define EFI_AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_REGISTER_D2H_LENGTH 20
|
||||
#define EFI_AHCI_FIS_DMA_ACTIVATE 0x39 //DMA Activate FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_DMA_ACTIVATE_LENGTH 4
|
||||
#define EFI_AHCI_FIS_DMA_SETUP 0x41 //DMA Setup FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_DMA_SETUP_LENGTH 28
|
||||
#define EFI_AHCI_FIS_DATA 0x46 //Data FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_BIST 0x58 //BIST Activate FIS - Bi-directional
|
||||
#define EFI_AHCI_FIS_BIST_LENGTH 12
|
||||
#define EFI_AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_PIO_SETUP_LENGTH 20
|
||||
#define EFI_AHCI_FIS_SET_DEVICE 0xA1 //Set Device Bits FIS - Device to Host
|
||||
#define EFI_AHCI_FIS_SET_DEVICE_LENGTH 8
|
||||
|
||||
#define EFI_AHCI_D2H_FIS_OFFSET 0x40
|
||||
#define EFI_AHCI_DMA_FIS_OFFSET 0x00
|
||||
#define EFI_AHCI_PIO_FIS_OFFSET 0x20
|
||||
#define EFI_AHCI_SDB_FIS_OFFSET 0x58
|
||||
#define EFI_AHCI_FIS_TYPE_MASK 0xFF
|
||||
#define EFI_AHCI_U_FIS_OFFSET 0x60
|
||||
|
||||
//
|
||||
// Port register
|
||||
//
|
||||
#define EFI_AHCI_PORT_START 0x0100
|
||||
#define EFI_AHCI_PORT_REG_WIDTH 0x0080
|
||||
#define EFI_AHCI_PORT_CLB 0x0000
|
||||
#define EFI_AHCI_PORT_CLBU 0x0004
|
||||
#define EFI_AHCI_PORT_FB 0x0008
|
||||
#define EFI_AHCI_PORT_FBU 0x000C
|
||||
#define EFI_AHCI_PORT_IS 0x0010
|
||||
#define EFI_AHCI_PORT_IS_DHRS BIT0
|
||||
#define EFI_AHCI_PORT_IS_PSS BIT1
|
||||
#define EFI_AHCI_PORT_IS_SSS BIT2
|
||||
#define EFI_AHCI_PORT_IS_SDBS BIT3
|
||||
#define EFI_AHCI_PORT_IS_UFS BIT4
|
||||
#define EFI_AHCI_PORT_IS_DPS BIT5
|
||||
#define EFI_AHCI_PORT_IS_PCS BIT6
|
||||
#define EFI_AHCI_PORT_IS_DIS BIT7
|
||||
#define EFI_AHCI_PORT_IS_PRCS BIT22
|
||||
#define EFI_AHCI_PORT_IS_IPMS BIT23
|
||||
#define EFI_AHCI_PORT_IS_OFS BIT24
|
||||
#define EFI_AHCI_PORT_IS_INFS BIT26
|
||||
#define EFI_AHCI_PORT_IS_IFS BIT27
|
||||
#define EFI_AHCI_PORT_IS_HBDS BIT28
|
||||
#define EFI_AHCI_PORT_IS_HBFS BIT29
|
||||
#define EFI_AHCI_PORT_IS_TFES BIT30
|
||||
#define EFI_AHCI_PORT_IS_CPDS BIT31
|
||||
#define EFI_AHCI_PORT_IS_CLEAR 0xFFFFFFFF
|
||||
#define EFI_AHCI_PORT_IS_FIS_CLEAR 0x0000000F
|
||||
|
||||
#define EFI_AHCI_PORT_IE 0x0014
|
||||
#define EFI_AHCI_PORT_CMD 0x0018
|
||||
#define EFI_AHCI_PORT_CMD_ST_MASK 0xFFFFFFFE
|
||||
#define EFI_AHCI_PORT_CMD_ST BIT0
|
||||
#define EFI_AHCI_PORT_CMD_SUD BIT1
|
||||
#define EFI_AHCI_PORT_CMD_POD BIT2
|
||||
#define EFI_AHCI_PORT_CMD_COL BIT3
|
||||
#define EFI_AHCI_PORT_CMD_CR BIT15
|
||||
#define EFI_AHCI_PORT_CMD_FRE BIT4
|
||||
#define EFI_AHCI_PORT_CMD_FR BIT14
|
||||
#define EFI_AHCI_PORT_CMD_MASK ~(EFI_AHCI_PORT_CMD_ST | EFI_AHCI_PORT_CMD_FRE | EFI_AHCI_PORT_CMD_COL)
|
||||
#define EFI_AHCI_PORT_CMD_PMA BIT17
|
||||
#define EFI_AHCI_PORT_CMD_HPCP BIT18
|
||||
#define EFI_AHCI_PORT_CMD_MPSP BIT19
|
||||
#define EFI_AHCI_PORT_CMD_CPD BIT20
|
||||
#define EFI_AHCI_PORT_CMD_ESP BIT21
|
||||
#define EFI_AHCI_PORT_CMD_ATAPI BIT24
|
||||
#define EFI_AHCI_PORT_CMD_DLAE BIT25
|
||||
#define EFI_AHCI_PORT_CMD_ALPE BIT26
|
||||
#define EFI_AHCI_PORT_CMD_ASP BIT27
|
||||
#define EFI_AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
|
||||
#define EFI_AHCI_PORT_CMD_ACTIVE (1 << 28 )
|
||||
#define EFI_AHCI_PORT_TFD 0x0020
|
||||
#define EFI_AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
|
||||
#define EFI_AHCI_PORT_TFD_BSY BIT7
|
||||
#define EFI_AHCI_PORT_TFD_DRQ BIT3
|
||||
#define EFI_AHCI_PORT_TFD_ERR BIT0
|
||||
#define EFI_AHCI_PORT_TFD_ERR_MASK 0x00FF00
|
||||
#define EFI_AHCI_PORT_SIG 0x0024
|
||||
#define EFI_AHCI_PORT_SSTS 0x0028
|
||||
#define EFI_AHCI_PORT_SSTS_DET_MASK 0x000F
|
||||
#define EFI_AHCI_PORT_SSTS_DET 0x0001
|
||||
#define EFI_AHCI_PORT_SSTS_DET_PCE 0x0003
|
||||
#define EFI_AHCI_PORT_SSTS_SPD_MASK 0x00F0
|
||||
#define EFI_AHCI_PORT_SCTL 0x002C
|
||||
#define EFI_AHCI_PORT_SCTL_DET_MASK 0x000F
|
||||
#define EFI_AHCI_PORT_SCTL_MASK (~EFI_AHCI_PORT_SCTL_DET_MASK)
|
||||
#define EFI_AHCI_PORT_SCTL_DET_INIT 0x0001
|
||||
#define EFI_AHCI_PORT_SCTL_DET_PHYCOMM 0x0003
|
||||
#define EFI_AHCI_PORT_SCTL_SPD_MASK 0x00F0
|
||||
#define EFI_AHCI_PORT_SCTL_IPM_MASK 0x0F00
|
||||
#define EFI_AHCI_PORT_SCTL_IPM_INIT 0x0300
|
||||
#define EFI_AHCI_PORT_SCTL_IPM_PSD 0x0100
|
||||
#define EFI_AHCI_PORT_SCTL_IPM_SSD 0x0200
|
||||
#define EFI_AHCI_PORT_SERR 0x0030
|
||||
#define EFI_AHCI_PORT_SERR_RDIE BIT0
|
||||
#define EFI_AHCI_PORT_SERR_RCE BIT1
|
||||
#define EFI_AHCI_PORT_SERR_TDIE BIT8
|
||||
#define EFI_AHCI_PORT_SERR_PCDIE BIT9
|
||||
#define EFI_AHCI_PORT_SERR_PE BIT10
|
||||
#define EFI_AHCI_PORT_SERR_IE BIT11
|
||||
#define EFI_AHCI_PORT_SERR_PRC BIT16
|
||||
#define EFI_AHCI_PORT_SERR_PIE BIT17
|
||||
#define EFI_AHCI_PORT_SERR_CW BIT18
|
||||
#define EFI_AHCI_PORT_SERR_BDE BIT19
|
||||
#define EFI_AHCI_PORT_SERR_DE BIT20
|
||||
#define EFI_AHCI_PORT_SERR_CRCE BIT21
|
||||
#define EFI_AHCI_PORT_SERR_HE BIT22
|
||||
#define EFI_AHCI_PORT_SERR_LSE BIT23
|
||||
#define EFI_AHCI_PORT_SERR_TSTE BIT24
|
||||
#define EFI_AHCI_PORT_SERR_UFT BIT25
|
||||
#define EFI_AHCI_PORT_SERR_EX BIT26
|
||||
#define EFI_AHCI_PORT_ERR_CLEAR 0xFFFFFFFF
|
||||
#define EFI_AHCI_PORT_SACT 0x0034
|
||||
#define EFI_AHCI_PORT_CI 0x0038
|
||||
#define EFI_AHCI_PORT_SNTF 0x003C
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
//
|
||||
// Command List structure includes total 32 entries.
|
||||
// The entry Data structure is listed at the following.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciCmdCfl:5; //Command FIS Length
|
||||
UINT32 AhciCmdA:1; //ATAPI
|
||||
UINT32 AhciCmdW:1; //Write
|
||||
UINT32 AhciCmdP:1; //Prefetchable
|
||||
UINT32 AhciCmdR:1; //Reset
|
||||
UINT32 AhciCmdB:1; //BIST
|
||||
UINT32 AhciCmdC:1; //Clear Busy upon R_OK
|
||||
UINT32 AhciCmdRsvd:1;
|
||||
UINT32 AhciCmdPmp:4; //Port Multiplier Port
|
||||
UINT32 AhciCmdPrdtl:16; //Physical Region Descriptor Table Length
|
||||
UINT32 AhciCmdPrdbc; //Physical Region Descriptor Byte Count
|
||||
UINT32 AhciCmdCtba; //Command Table Descriptor Base Address
|
||||
UINT32 AhciCmdCtbau; //Command Table Descriptor Base Address Upper 32-BITs
|
||||
UINT32 AhciCmdRsvd1[4];
|
||||
} EFI_AHCI_COMMAND_LIST;
|
||||
|
||||
//
|
||||
// This is a software constructed FIS.
|
||||
// For Data transfer operations, this is the H2D Register FIS format as
|
||||
// specified in the Serial ATA Revision 2.6 specification.
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 AhciCFisType;
|
||||
UINT8 AhciCFisPmNum:4;
|
||||
UINT8 AhciCFisRsvd:1;
|
||||
UINT8 AhciCFisRsvd1:1;
|
||||
UINT8 AhciCFisRsvd2:1;
|
||||
UINT8 AhciCFisCmdInd:1;
|
||||
UINT8 AhciCFisCmd;
|
||||
UINT8 AhciCFisFeature;
|
||||
UINT8 AhciCFisSecNum;
|
||||
UINT8 AhciCFisClyLow;
|
||||
UINT8 AhciCFisClyHigh;
|
||||
UINT8 AhciCFisDevHead;
|
||||
UINT8 AhciCFisSecNumExp;
|
||||
UINT8 AhciCFisClyLowExp;
|
||||
UINT8 AhciCFisClyHighExp;
|
||||
UINT8 AhciCFisFeatureExp;
|
||||
UINT8 AhciCFisSecCount;
|
||||
UINT8 AhciCFisSecCountExp;
|
||||
UINT8 AhciCFisRsvd3;
|
||||
UINT8 AhciCFisControl;
|
||||
UINT8 AhciCFisRsvd4[4];
|
||||
UINT8 AhciCFisRsvd5[44];
|
||||
} EFI_AHCI_COMMAND_FIS;
|
||||
|
||||
//
|
||||
// ACMD: ATAPI command (12 or 16 bytes)
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 AtapiCmd[0x10];
|
||||
} EFI_AHCI_ATAPI_COMMAND;
|
||||
|
||||
//
|
||||
// Physical Region Descriptor Table includes up to 65535 entries
|
||||
// The entry Data structure is listed at the following.
|
||||
// the actual entry number comes from the PRDTL field in the command
|
||||
// list entry for this command slot.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 AhciPrdtDba; //Data Base Address
|
||||
UINT32 AhciPrdtDbau; //Data Base Address Upper 32-BITs
|
||||
UINT32 AhciPrdtRsvd;
|
||||
UINT32 AhciPrdtDbc:22; //Data Byte Count
|
||||
UINT32 AhciPrdtRsvd1:9;
|
||||
UINT32 AhciPrdtIoc:1; //Interrupt on Completion
|
||||
} EFI_AHCI_COMMAND_PRDT;
|
||||
|
||||
//
|
||||
// Command table Data strucute which is pointed to by the entry in the command list
|
||||
//
|
||||
typedef struct {
|
||||
EFI_AHCI_COMMAND_FIS CommandFis; // A software constructed FIS.
|
||||
EFI_AHCI_ATAPI_COMMAND AtapiCmd; // 12 or 16 bytes ATAPI cmd.
|
||||
UINT8 Reserved[0x30];
|
||||
EFI_AHCI_COMMAND_PRDT PrdtTable; // The scatter/gather list for Data transfer
|
||||
} EFI_AHCI_COMMAND_TABLE;
|
||||
|
||||
//
|
||||
// Received FIS structure
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 AhciDmaSetupFis[0x1C]; // Dma Setup Fis: offset 0x00
|
||||
UINT8 AhciDmaSetupFisRsvd[0x04];
|
||||
UINT8 AhciPioSetupFis[0x14]; // Pio Setup Fis: offset 0x20
|
||||
UINT8 AhciPioSetupFisRsvd[0x0C];
|
||||
UINT8 AhciD2HRegisterFis[0x14]; // D2H Register Fis: offset 0x40
|
||||
UINT8 AhciD2HRegisterFisRsvd[0x04];
|
||||
UINT64 AhciSetDeviceBitsFis; // Set Device Bits Fix: offset 0x58
|
||||
UINT8 AhciUnknownFis[0x40]; // Unkonwn Fis: offset 0x60
|
||||
UINT8 AhciUnknownFisRsvd[0x60];
|
||||
} EFI_AHCI_RECEIVED_FIS;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
EFI_AHCI_RECEIVED_FIS *AhciRFis;
|
||||
EFI_AHCI_COMMAND_LIST *AhciCmdList;
|
||||
EFI_AHCI_COMMAND_TABLE *AhciCommandTable;
|
||||
} EFI_AHCI_REGISTERS;
|
||||
|
||||
extern EFI_AHCI_REGISTERS mAhciRegisters;
|
||||
extern UINT32 mAhciBar;
|
||||
|
||||
/**
|
||||
Send Buffer cmd to specific device.
|
||||
|
||||
@param AhciRegisters The pointer to the EFI_AHCI_REGISTERS.
|
||||
@param Port The number of port.
|
||||
@param PortMultiplier The timeout Value of stop.
|
||||
@param Buffer The Data Buffer to store IDENTIFY PACKET Data.
|
||||
|
||||
@retval EFI_DEVICE_ERROR The cmd abort with error occurs.
|
||||
@retval EFI_TIMEOUT The operation is time out.
|
||||
@retval EFI_UNSUPPORTED The device is not ready for executing.
|
||||
@retval EFI_SUCCESS The cmd executes successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AhciIdentify (
|
||||
IN EFI_AHCI_REGISTERS *AhciRegisters,
|
||||
IN UINT8 Port,
|
||||
IN UINT8 PortMultiplier,
|
||||
IN OUT ATA_IDENTIFY_DATA *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
Get AHCI mode base address registers' Value.
|
||||
|
||||
@param[in] Bus The bus number of ata host controller.
|
||||
@param[in] Device The device number of ata host controller.
|
||||
@param[in] Function The function number of ata host controller.
|
||||
|
||||
@retval EFI_UNSUPPORTED Return this Value when the BARs is not IO type
|
||||
@retval EFI_SUCCESS Get the Base address successfully
|
||||
@retval Other Read the pci configureation Data error
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetAhciBaseAddress (
|
||||
IN UINTN Bus,
|
||||
IN UINTN Device,
|
||||
IN UINTN Function
|
||||
);
|
||||
|
||||
/**
|
||||
Allocate transfer-related Data struct which is used at AHCI mode.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCE The allocation is failure.
|
||||
@retval EFI_SUCCESS Successful to allocate memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AhciAllocateResource (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Free allocated transfer-related Data struct which is used at AHCI mode.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
AhciFreeResource (
|
||||
VOID
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize ATA host controller at AHCI mode.
|
||||
|
||||
The function is designed to initialize ATA host controller.
|
||||
|
||||
@param[in] Port The port number to do initialization.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AhciModeInitialize (
|
||||
UINT8 Port
|
||||
);
|
||||
|
||||
/**
|
||||
Start a PIO Data transfer on specific port.
|
||||
|
||||
@param AhciRegisters The pointer to the EFI_AHCI_REGISTERS.
|
||||
@param Port The number of port.
|
||||
@param PortMultiplier The timeout Value of stop.
|
||||
@param AtapiCommand The atapi command will be used for the transfer.
|
||||
@param AtapiCommandLength The Length of the atapi command.
|
||||
@param Read The transfer direction.
|
||||
@param AtaCommandBlock The EFI_ATA_COMMAND_BLOCK Data.
|
||||
@param AtaStatusBlock The EFI_ATA_STATUS_BLOCK Data.
|
||||
@param MemoryAddr The pointer to the Data Buffer.
|
||||
@param DataCount The Data count to be transferred.
|
||||
@param Timeout The timeout Value of non Data transfer.
|
||||
|
||||
@retval EFI_DEVICE_ERROR The PIO Data transfer abort with error occurs.
|
||||
@retval EFI_TIMEOUT The operation is time out.
|
||||
@retval EFI_UNSUPPORTED The device is not ready for transfer.
|
||||
@retval EFI_SUCCESS The PIO Data transfer executes successfully.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AhciPioTransfer (
|
||||
IN EFI_AHCI_REGISTERS *AhciRegisters,
|
||||
IN UINT8 Port,
|
||||
IN UINT8 PortMultiplier,
|
||||
IN EFI_AHCI_ATAPI_COMMAND *AtapiCommand OPTIONAL,
|
||||
IN UINT8 AtapiCommandLength,
|
||||
IN BOOLEAN Read,
|
||||
IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
|
||||
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
|
||||
IN OUT VOID *MemoryAddr,
|
||||
IN UINT32 DataCount,
|
||||
IN UINT64 Timeout
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,767 +0,0 @@
|
||||
/** @file
|
||||
This driver is used for Opal Password Feature support at IDE mode.
|
||||
|
||||
Copyright (c) 2016, 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 "OpalPasswordSmm.h"
|
||||
|
||||
/**
|
||||
Write multiple words of Data to the IDE Data port.
|
||||
Call the IO abstraction once to do the complete read,
|
||||
not one word at a time
|
||||
|
||||
@param Port IO port to read
|
||||
@param Count No. of UINT16's to read
|
||||
@param Buffer Pointer to the Data Buffer for read
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
IdeWritePortWMultiple (
|
||||
IN UINT16 Port,
|
||||
IN UINTN Count,
|
||||
IN UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
IoWrite16 (Port, Buffer[Index]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Reads multiple words of Data from the IDE Data port.
|
||||
Call the IO abstraction once to do the complete read,
|
||||
not one word at a time
|
||||
|
||||
@param Port IO port to read
|
||||
@param Count Number of UINT16's to read
|
||||
@param Buffer Pointer to the Data Buffer for read
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
IdeReadPortWMultiple (
|
||||
IN UINT16 Port,
|
||||
IN UINTN Count,
|
||||
IN UINT16 *Buffer
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
Buffer[Count] = IoRead16 (Port);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to analyze the Status Register and print out
|
||||
some debug information and if there is ERR bit set in the Status
|
||||
Register, the Error Register's Value is also be parsed and print out.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
DumpAllIdeRegisters (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters
|
||||
)
|
||||
{
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
if ((IoRead8 (IdeRegisters->CmdOrStatus) & ATA_STSREG_DWF) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Write Fault\n", IoRead8 (IdeRegisters->CmdOrStatus)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->CmdOrStatus) & ATA_STSREG_CORR) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Corrected Data\n", IoRead8 (IdeRegisters->CmdOrStatus)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->CmdOrStatus) & ATA_STSREG_ERR) != 0) {
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_BBK) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Bad Block Detected\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_UNC) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Uncorrectable Data\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_MC) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Media Change\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_ABRT) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Abort\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_TK0NF) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Track 0 Not Found\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
|
||||
if ((IoRead8 (IdeRegisters->ErrOrFeature) & ATA_ERRREG_AMNF) != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "CheckRegisterStatus()-- %02x : Error : Address Mark Not Found\n", IoRead8 (IdeRegisters->ErrOrFeature)));
|
||||
}
|
||||
}
|
||||
DEBUG_CODE_END ();
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to analyze the Status Register and print out
|
||||
some debug information and if there is ERR bit set in the Status
|
||||
Register, the Error Register's Value is also be parsed and print out.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
|
||||
@retval EFI_SUCCESS No err information in the Status Register.
|
||||
@retval EFI_DEVICE_ERROR Any err information in the Status Register.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CheckStatusRegister (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 StatusRegister;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
StatusRegister = IoRead8 (IdeRegisters->CmdOrStatus);
|
||||
|
||||
if ((StatusRegister & (ATA_STSREG_ERR | ATA_STSREG_DWF | ATA_STSREG_CORR)) == 0) {
|
||||
Status = EFI_SUCCESS;
|
||||
} else {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to poll for the DRQ bit clear in the Status
|
||||
Register. DRQ is cleared when the device is finished transferring Data.
|
||||
So this function is called after Data transfer is finished.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS DRQ bit clear within the time out.
|
||||
@retval EFI_TIMEOUT DRQ bit not clear within the time out.
|
||||
|
||||
@note
|
||||
Read Status Register will clear interrupt status.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DRQClear (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
UINT32 Delay;
|
||||
UINT8 StatusRegister;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
do {
|
||||
StatusRegister = IoRead8 (IdeRegisters->CmdOrStatus);
|
||||
|
||||
//
|
||||
// wait for BSY == 0 and DRQ == 0
|
||||
//
|
||||
if ((StatusRegister & ATA_STSREG_BSY) == 0) {
|
||||
|
||||
if ((StatusRegister & ATA_STSREG_DRQ) == ATA_STSREG_DRQ) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
/**
|
||||
This function is used to poll for the DRQ bit clear in the Alternate
|
||||
Status Register. DRQ is cleared when the device is finished
|
||||
transferring Data. So this function is called after Data transfer
|
||||
is finished.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS DRQ bit clear within the time out.
|
||||
|
||||
@retval EFI_TIMEOUT DRQ bit not clear within the time out.
|
||||
@note Read Alternate Status Register will not clear interrupt status.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DRQClear2 (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
UINT32 Delay;
|
||||
UINT8 AltRegister;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
do {
|
||||
AltRegister = IoRead8 (IdeRegisters->AltOrDev);
|
||||
|
||||
//
|
||||
// wait for BSY == 0 and DRQ == 0
|
||||
//
|
||||
if ((AltRegister & ATA_STSREG_BSY) == 0) {
|
||||
if ((AltRegister & ATA_STSREG_DRQ) == ATA_STSREG_DRQ) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
} else {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is used to poll for the DRQ bit set in the Alternate Status Register.
|
||||
DRQ is set when the device is ready to transfer Data. So this function is called after
|
||||
the command is sent to the device and before required Data is transferred.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS DRQ bit set within the time out.
|
||||
@retval EFI_TIMEOUT DRQ bit not set within the time out.
|
||||
@retval EFI_ABORTED DRQ bit not set caused by the command abort.
|
||||
@note Read Alternate Status Register will not clear interrupt status.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
DRQReady2 (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
UINT32 Delay;
|
||||
UINT8 AltRegister;
|
||||
UINT8 ErrorRegister;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
|
||||
do {
|
||||
//
|
||||
// Read Alternate Status Register will not clear interrupt status
|
||||
//
|
||||
AltRegister = IoRead8 (IdeRegisters->AltOrDev);
|
||||
//
|
||||
// BSY == 0 , DRQ == 1
|
||||
//
|
||||
if ((AltRegister & ATA_STSREG_BSY) == 0) {
|
||||
if ((AltRegister & ATA_STSREG_ERR) == ATA_STSREG_ERR) {
|
||||
ErrorRegister = IoRead8 (IdeRegisters->ErrOrFeature);
|
||||
|
||||
if ((ErrorRegister & ATA_ERRREG_ABRT) == ATA_ERRREG_ABRT) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
if ((AltRegister & ATA_STSREG_DRQ) == ATA_STSREG_DRQ) {
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to poll for the BSY bit clear in the Status Register. BSY
|
||||
is clear when the device is not busy. Every command must be sent after device is not busy.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS BSY bit clear within the time out.
|
||||
@retval EFI_TIMEOUT BSY bit not clear within the time out.
|
||||
|
||||
@note Read Status Register will clear interrupt status.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
WaitForBSYClear (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
UINT32 Delay;
|
||||
UINT8 StatusRegister;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
|
||||
Delay = (UINT32) (DivU64x32(Timeout, 1000) + 1);
|
||||
do {
|
||||
StatusRegister = IoRead8 (IdeRegisters->CmdOrStatus);
|
||||
|
||||
if ((StatusRegister & ATA_STSREG_BSY) == 0x00) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Stall for 100 microseconds.
|
||||
//
|
||||
MicroSecondDelay (100);
|
||||
|
||||
Delay--;
|
||||
|
||||
} while (Delay > 0);
|
||||
|
||||
return EFI_TIMEOUT;
|
||||
}
|
||||
|
||||
/**
|
||||
Get IDE i/o port registers' base addresses by mode.
|
||||
|
||||
In 'Compatibility' mode, use fixed addresses.
|
||||
In Native-PCI mode, get base addresses from BARs in the PCI IDE controller's
|
||||
Configuration Space.
|
||||
|
||||
The steps to get IDE i/o port registers' base addresses for each channel
|
||||
as follows:
|
||||
|
||||
1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
|
||||
controller's Configuration Space to determine the operating mode.
|
||||
|
||||
2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
|
||||
___________________________________________
|
||||
| | Command Block | Control Block |
|
||||
| Channel | Registers | Registers |
|
||||
|___________|_______________|_______________|
|
||||
| Primary | 1F0h - 1F7h | 3F6h - 3F7h |
|
||||
|___________|_______________|_______________|
|
||||
| Secondary | 170h - 177h | 376h - 377h |
|
||||
|___________|_______________|_______________|
|
||||
|
||||
Table 1. Compatibility resource mappings
|
||||
|
||||
b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
|
||||
in IDE controller's PCI Configuration Space, shown in the Table 2 below.
|
||||
___________________________________________________
|
||||
| | Command Block | Control Block |
|
||||
| Channel | Registers | Registers |
|
||||
|___________|___________________|___________________|
|
||||
| Primary | BAR at offset 0x10| BAR at offset 0x14|
|
||||
|___________|___________________|___________________|
|
||||
| Secondary | BAR at offset 0x18| BAR at offset 0x1C|
|
||||
|___________|___________________|___________________|
|
||||
|
||||
Table 2. BARs for Register Mapping
|
||||
|
||||
@param[in] Bus The bus number of ata host controller.
|
||||
@param[in] Device The device number of ata host controller.
|
||||
@param[in] Function The function number of ata host controller.
|
||||
@param[in, out] IdeRegisters Pointer to EFI_IDE_REGISTERS which is used to
|
||||
store the IDE i/o port registers' base addresses
|
||||
|
||||
@retval EFI_UNSUPPORTED Return this Value when the BARs is not IO type
|
||||
@retval EFI_SUCCESS Get the Base address successfully
|
||||
@retval Other Read the pci configureation Data error
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetIdeRegisterIoAddr (
|
||||
IN UINTN Bus,
|
||||
IN UINTN Device,
|
||||
IN UINTN Function,
|
||||
IN OUT EFI_IDE_REGISTERS *IdeRegisters
|
||||
)
|
||||
{
|
||||
UINT16 CommandBlockBaseAddr;
|
||||
UINT16 ControlBlockBaseAddr;
|
||||
UINT8 ClassCode;
|
||||
UINT32 BaseAddress[4];
|
||||
|
||||
if (IdeRegisters == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ClassCode = PciRead8 (PCI_LIB_ADDRESS (Bus, Device, Function, 0x9));
|
||||
BaseAddress[0] = PciRead32 (PCI_LIB_ADDRESS (Bus, Device, Function, 0x10));
|
||||
BaseAddress[1] = PciRead32 (PCI_LIB_ADDRESS (Bus, Device, Function, 0x14));
|
||||
BaseAddress[2] = PciRead32 (PCI_LIB_ADDRESS (Bus, Device, Function, 0x18));
|
||||
BaseAddress[3] = PciRead32 (PCI_LIB_ADDRESS (Bus, Device, Function, 0x1C));
|
||||
|
||||
if ((ClassCode & IDE_PRIMARY_OPERATING_MODE) == 0) {
|
||||
CommandBlockBaseAddr = 0x1f0;
|
||||
ControlBlockBaseAddr = 0x3f6;
|
||||
} else {
|
||||
//
|
||||
// The BARs should be of IO type
|
||||
//
|
||||
if ((BaseAddress[0] & BIT0) == 0 ||
|
||||
(BaseAddress[1] & BIT0) == 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CommandBlockBaseAddr = (UINT16) (BaseAddress[0] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16) ((BaseAddress[1] & 0x0000fffc) + 2);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate IDE primary channel I/O register base address.
|
||||
//
|
||||
IdeRegisters[EfiIdePrimary].Data = CommandBlockBaseAddr;
|
||||
IdeRegisters[EfiIdePrimary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdePrimary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdePrimary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdePrimary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdePrimary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdePrimary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdePrimary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdePrimary].AltOrDev = ControlBlockBaseAddr;
|
||||
|
||||
if ((ClassCode & IDE_SECONDARY_OPERATING_MODE) == 0) {
|
||||
CommandBlockBaseAddr = 0x170;
|
||||
ControlBlockBaseAddr = 0x376;
|
||||
} else {
|
||||
//
|
||||
// The BARs should be of IO type
|
||||
//
|
||||
if ((BaseAddress[2] & BIT0) == 0 ||
|
||||
(BaseAddress[3] & BIT0) == 0) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
CommandBlockBaseAddr = (UINT16) (BaseAddress[2] & 0x0000fff8);
|
||||
ControlBlockBaseAddr = (UINT16) ((BaseAddress[3] & 0x0000fffc) + 2);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate IDE secondary channel I/O register base address.
|
||||
//
|
||||
IdeRegisters[EfiIdeSecondary].Data = CommandBlockBaseAddr;
|
||||
IdeRegisters[EfiIdeSecondary].ErrOrFeature = (UINT16) (CommandBlockBaseAddr + 0x01);
|
||||
IdeRegisters[EfiIdeSecondary].SectorCount = (UINT16) (CommandBlockBaseAddr + 0x02);
|
||||
IdeRegisters[EfiIdeSecondary].SectorNumber = (UINT16) (CommandBlockBaseAddr + 0x03);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderLsb = (UINT16) (CommandBlockBaseAddr + 0x04);
|
||||
IdeRegisters[EfiIdeSecondary].CylinderMsb = (UINT16) (CommandBlockBaseAddr + 0x05);
|
||||
IdeRegisters[EfiIdeSecondary].Head = (UINT16) (CommandBlockBaseAddr + 0x06);
|
||||
IdeRegisters[EfiIdeSecondary].CmdOrStatus = (UINT16) (CommandBlockBaseAddr + 0x07);
|
||||
IdeRegisters[EfiIdeSecondary].AltOrDev = ControlBlockBaseAddr;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Send ATA Ext command into device with NON_DATA protocol.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS Reading succeed
|
||||
@retval EFI_DEVICE_ERROR Error executing commands on this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AtaIssueCommand (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT8 DeviceHead;
|
||||
UINT8 AtaCommand;
|
||||
|
||||
ASSERT (IdeRegisters != NULL);
|
||||
ASSERT (AtaCommandBlock != NULL);
|
||||
|
||||
DeviceHead = AtaCommandBlock->AtaDeviceHead;
|
||||
AtaCommand = AtaCommandBlock->AtaCommand;
|
||||
|
||||
Status = WaitForBSYClear (IdeRegisters, Timeout);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Select device (bit4), set LBA mode(bit6) (use 0xe0 for compatibility)
|
||||
//
|
||||
IoWrite8 (IdeRegisters->Head, (UINT8) (0xe0 | DeviceHead));
|
||||
|
||||
//
|
||||
// set all the command parameters
|
||||
// Before write to all the following registers, BSY and DRQ must be 0.
|
||||
//
|
||||
Status = DRQClear2 (IdeRegisters, Timeout);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill the feature register, which is a two-byte FIFO. Need write twice.
|
||||
//
|
||||
IoWrite8 (IdeRegisters->ErrOrFeature, AtaCommandBlock->AtaFeaturesExp);
|
||||
IoWrite8 (IdeRegisters->ErrOrFeature, AtaCommandBlock->AtaFeatures);
|
||||
|
||||
//
|
||||
// Fill the sector count register, which is a two-byte FIFO. Need write twice.
|
||||
//
|
||||
IoWrite8 (IdeRegisters->SectorCount, AtaCommandBlock->AtaSectorCountExp);
|
||||
IoWrite8 (IdeRegisters->SectorCount, AtaCommandBlock->AtaSectorCount);
|
||||
|
||||
//
|
||||
// Fill the start LBA registers, which are also two-byte FIFO
|
||||
//
|
||||
IoWrite8 (IdeRegisters->SectorNumber, AtaCommandBlock->AtaSectorNumberExp);
|
||||
IoWrite8 (IdeRegisters->SectorNumber, AtaCommandBlock->AtaSectorNumber);
|
||||
|
||||
IoWrite8 (IdeRegisters->CylinderLsb, AtaCommandBlock->AtaCylinderLowExp);
|
||||
IoWrite8 (IdeRegisters->CylinderLsb, AtaCommandBlock->AtaCylinderLow);
|
||||
|
||||
IoWrite8 (IdeRegisters->CylinderMsb, AtaCommandBlock->AtaCylinderHighExp);
|
||||
IoWrite8 (IdeRegisters->CylinderMsb, AtaCommandBlock->AtaCylinderHigh);
|
||||
|
||||
//
|
||||
// Send command via Command Register
|
||||
//
|
||||
IoWrite8 (IdeRegisters->CmdOrStatus, AtaCommand);
|
||||
|
||||
//
|
||||
// Stall at least 400 microseconds.
|
||||
//
|
||||
MicroSecondDelay (400);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to send out ATA commands conforms to the PIO Data In Protocol.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Buffer A pointer to the source Buffer for the Data.
|
||||
@param ByteCount The Length of the Data.
|
||||
@param Read Flag used to determine the Data transfer direction.
|
||||
Read equals 1, means Data transferred from device to host;
|
||||
Read equals 0, means Data transferred from host to device.
|
||||
@param AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK Data structure.
|
||||
@param AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS send out the ATA command and device send required Data successfully.
|
||||
@retval EFI_DEVICE_ERROR command sent failed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AtaPioDataInOut (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN OUT VOID *Buffer,
|
||||
IN UINT64 ByteCount,
|
||||
IN BOOLEAN Read,
|
||||
IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
|
||||
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
|
||||
IN UINT64 Timeout
|
||||
)
|
||||
{
|
||||
UINTN WordCount;
|
||||
UINTN Increment;
|
||||
UINT16 *Buffer16;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((IdeRegisters == NULL) || (Buffer == NULL) || (AtaCommandBlock == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Issue ATA command
|
||||
//
|
||||
Status = AtaIssueCommand (IdeRegisters, AtaCommandBlock, Timeout);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
Buffer16 = (UINT16 *) Buffer;
|
||||
|
||||
//
|
||||
// According to PIO Data in protocol, host can perform a series of reads to
|
||||
// the Data register after each time device set DRQ ready;
|
||||
// The Data Size of "a series of read" is command specific.
|
||||
// For most ATA command, Data Size received from device will not exceed
|
||||
// 1 sector, hence the Data Size for "a series of read" can be the whole Data
|
||||
// Size of one command request.
|
||||
// For ATA command such as Read Sector command, the Data Size of one ATA
|
||||
// command request is often larger than 1 sector, according to the
|
||||
// Read Sector command, the Data Size of "a series of read" is exactly 1
|
||||
// sector.
|
||||
// Here for simplification reason, we specify the Data Size for
|
||||
// "a series of read" to 1 sector (256 words) if Data Size of one ATA command
|
||||
// request is larger than 256 words.
|
||||
//
|
||||
Increment = 256;
|
||||
|
||||
//
|
||||
// used to record bytes of currently transfered Data
|
||||
//
|
||||
WordCount = 0;
|
||||
|
||||
while (WordCount < RShiftU64(ByteCount, 1)) {
|
||||
//
|
||||
// Poll DRQ bit set, Data transfer can be performed only when DRQ is ready
|
||||
//
|
||||
Status = DRQReady2 (IdeRegisters, Timeout);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the byte count for one series of read
|
||||
//
|
||||
if ((WordCount + Increment) > RShiftU64(ByteCount, 1)) {
|
||||
Increment = (UINTN)(RShiftU64(ByteCount, 1) - WordCount);
|
||||
}
|
||||
|
||||
if (Read) {
|
||||
IdeReadPortWMultiple (
|
||||
IdeRegisters->Data,
|
||||
Increment,
|
||||
Buffer16
|
||||
);
|
||||
} else {
|
||||
IdeWritePortWMultiple (
|
||||
IdeRegisters->Data,
|
||||
Increment,
|
||||
Buffer16
|
||||
);
|
||||
}
|
||||
|
||||
Status = CheckStatusRegister (IdeRegisters);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
WordCount += Increment;
|
||||
Buffer16 += Increment;
|
||||
}
|
||||
|
||||
Status = DRQClear (IdeRegisters, Timeout);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
Exit:
|
||||
//
|
||||
// Dump All Ide registers to ATA_STATUS_BLOCK
|
||||
//
|
||||
DumpAllIdeRegisters (IdeRegisters);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Sends out an ATA Identify Command to the specified device.
|
||||
|
||||
This function sends out the ATA Identify Command to the
|
||||
specified device. Only ATA device responses to this command. If
|
||||
the command succeeds, it returns the Identify Data structure which
|
||||
contains information about the device. This function extracts the
|
||||
information it needs to fill the IDE_BLK_IO_DEV Data structure,
|
||||
including device type, media block Size, media capacity, and etc.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Channel The channel number of device.
|
||||
@param Device The device number of device.
|
||||
@param Buffer A pointer to Data Buffer which is used to contain IDENTIFY Data.
|
||||
|
||||
@retval EFI_SUCCESS Identify ATA device successfully.
|
||||
@retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
|
||||
@retval EFI_OUT_OF_RESOURCES Allocate memory failed.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AtaIdentify (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT8 Channel,
|
||||
IN UINT8 Device,
|
||||
IN OUT ATA_IDENTIFY_DATA *Buffer
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_ATA_COMMAND_BLOCK AtaCommandBlock;
|
||||
|
||||
ZeroMem (&AtaCommandBlock, sizeof (EFI_ATA_COMMAND_BLOCK));
|
||||
|
||||
AtaCommandBlock.AtaCommand = ATA_CMD_IDENTIFY_DRIVE;
|
||||
AtaCommandBlock.AtaDeviceHead = (UINT8)(Device << 0x4);
|
||||
|
||||
Status = AtaPioDataInOut (
|
||||
IdeRegisters,
|
||||
Buffer,
|
||||
sizeof (ATA_IDENTIFY_DATA),
|
||||
TRUE,
|
||||
&AtaCommandBlock,
|
||||
NULL,
|
||||
ATA_TIMEOUT
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,173 +0,0 @@
|
||||
/** @file
|
||||
Header file for IDE mode of ATA host controller.
|
||||
|
||||
Copyright (c) 2016, 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 __OPAL_PASSWORD_IDE_MODE_H__
|
||||
#define __OPAL_PASSWORD_IDE_MODE_H__
|
||||
|
||||
typedef enum {
|
||||
EfiIdePrimary = 0,
|
||||
EfiIdeSecondary = 1,
|
||||
EfiIdeMaxChannel = 2
|
||||
} EFI_IDE_CHANNEL;
|
||||
|
||||
typedef enum {
|
||||
EfiIdeMaster = 0,
|
||||
EfiIdeSlave = 1,
|
||||
EfiIdeMaxDevice = 2
|
||||
} EFI_IDE_DEVICE;
|
||||
|
||||
//
|
||||
// IDE registers set
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Data;
|
||||
UINT16 ErrOrFeature;
|
||||
UINT16 SectorCount;
|
||||
UINT16 SectorNumber;
|
||||
UINT16 CylinderLsb;
|
||||
UINT16 CylinderMsb;
|
||||
UINT16 Head;
|
||||
UINT16 CmdOrStatus;
|
||||
UINT16 AltOrDev;
|
||||
} EFI_IDE_REGISTERS;
|
||||
|
||||
//
|
||||
// Bit definitions in Programming Interface byte of the Class Code field
|
||||
// in PCI IDE controller's Configuration Space
|
||||
//
|
||||
#define IDE_PRIMARY_OPERATING_MODE BIT0
|
||||
#define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
|
||||
#define IDE_SECONDARY_OPERATING_MODE BIT2
|
||||
#define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
|
||||
|
||||
/**
|
||||
Get IDE i/o port registers' base addresses by mode.
|
||||
|
||||
In 'Compatibility' mode, use fixed addresses.
|
||||
In Native-PCI mode, get base addresses from BARs in the PCI IDE controller's
|
||||
Configuration Space.
|
||||
|
||||
The steps to get IDE i/o port registers' base addresses for each channel
|
||||
as follows:
|
||||
|
||||
1. Examine the Programming Interface byte of the Class Code fields in PCI IDE
|
||||
controller's Configuration Space to determine the operating mode.
|
||||
|
||||
2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
|
||||
___________________________________________
|
||||
| | Command Block | Control Block |
|
||||
| Channel | Registers | Registers |
|
||||
|___________|_______________|_______________|
|
||||
| Primary | 1F0h - 1F7h | 3F6h - 3F7h |
|
||||
|___________|_______________|_______________|
|
||||
| Secondary | 170h - 177h | 376h - 377h |
|
||||
|___________|_______________|_______________|
|
||||
|
||||
Table 1. Compatibility resource mappings
|
||||
|
||||
b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs
|
||||
in IDE controller's PCI Configuration Space, shown in the Table 2 below.
|
||||
___________________________________________________
|
||||
| | Command Block | Control Block |
|
||||
| Channel | Registers | Registers |
|
||||
|___________|___________________|___________________|
|
||||
| Primary | BAR at offset 0x10| BAR at offset 0x14|
|
||||
|___________|___________________|___________________|
|
||||
| Secondary | BAR at offset 0x18| BAR at offset 0x1C|
|
||||
|___________|___________________|___________________|
|
||||
|
||||
Table 2. BARs for Register Mapping
|
||||
|
||||
@param[in] Bus The bus number of ata host controller.
|
||||
@param[in] Device The device number of ata host controller.
|
||||
@param[in] Function The function number of ata host controller.
|
||||
@param[in, out] IdeRegisters Pointer to EFI_IDE_REGISTERS which is used to
|
||||
store the IDE i/o port registers' base addresses
|
||||
|
||||
@retval EFI_UNSUPPORTED Return this Value when the BARs is not IO type
|
||||
@retval EFI_SUCCESS Get the Base address successfully
|
||||
@retval Other Read the pci configureation Data error
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetIdeRegisterIoAddr (
|
||||
IN UINTN Bus,
|
||||
IN UINTN Device,
|
||||
IN UINTN Function,
|
||||
IN OUT EFI_IDE_REGISTERS *IdeRegisters
|
||||
);
|
||||
|
||||
/**
|
||||
Sends out an ATA Identify Command to the specified device.
|
||||
|
||||
This function sends out the ATA Identify Command to the
|
||||
specified device. Only ATA device responses to this command. If
|
||||
the command succeeds, it returns the Identify Data structure which
|
||||
contains information about the device. This function extracts the
|
||||
information it needs to fill the IDE_BLK_IO_DEV Data structure,
|
||||
including device type, media block Size, media capacity, and etc.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Channel The channel number of device.
|
||||
@param Device The device number of device.
|
||||
@param Buffer A pointer to Data Buffer which is used to contain IDENTIFY Data.
|
||||
|
||||
@retval EFI_SUCCESS Identify ATA device successfully.
|
||||
@retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.
|
||||
@retval EFI_OUT_OF_RESOURCES Allocate memory failed.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AtaIdentify (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN UINT8 Channel,
|
||||
IN UINT8 Device,
|
||||
IN OUT ATA_IDENTIFY_DATA *Buffer
|
||||
);
|
||||
|
||||
/**
|
||||
This function is used to send out ATA commands conforms to the PIO Data In Protocol.
|
||||
|
||||
@param IdeRegisters A pointer to EFI_IDE_REGISTERS Data structure.
|
||||
@param Buffer A pointer to the source Buffer for the Data.
|
||||
@param ByteCount The Length of the Data.
|
||||
@param Read Flag used to determine the Data transfer direction.
|
||||
Read equals 1, means Data transferred from device to host;
|
||||
Read equals 0, means Data transferred from host to device.
|
||||
@param AtaCommandBlock A pointer to EFI_ATA_COMMAND_BLOCK Data structure.
|
||||
@param AtaStatusBlock A pointer to EFI_ATA_STATUS_BLOCK Data structure.
|
||||
@param Timeout The time to complete the command.
|
||||
|
||||
@retval EFI_SUCCESS send out the ATA command and device send required Data successfully.
|
||||
@retval EFI_DEVICE_ERROR command sent failed.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AtaPioDataInOut (
|
||||
IN EFI_IDE_REGISTERS *IdeRegisters,
|
||||
IN OUT VOID *Buffer,
|
||||
IN UINT64 ByteCount,
|
||||
IN BOOLEAN Read,
|
||||
IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock,
|
||||
IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock,
|
||||
IN UINT64 Timeout
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,456 +0,0 @@
|
||||
/** @file
|
||||
Header file for NVMe function definitions
|
||||
|
||||
Copyright (c) 2016, 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 __OPAL_PASSWORD_NVME_MODE_H__
|
||||
#define __OPAL_PASSWORD_NVME_MODE_H__
|
||||
|
||||
|
||||
#include "OpalNvmeReg.h"
|
||||
|
||||
#define NVME_MAX_SECTORS 0x10000
|
||||
//
|
||||
// QueueId
|
||||
//
|
||||
#define NVME_ADMIN_QUEUE 0x00
|
||||
#define NVME_IO_QUEUE 0x01
|
||||
|
||||
typedef struct {
|
||||
UINT8 Opcode;
|
||||
UINT8 FusedOperation;
|
||||
#define NORMAL_CMD 0x00
|
||||
#define FUSED_FIRST_CMD 0x01
|
||||
#define FUSED_SECOND_CMD 0x02
|
||||
UINT16 Cid;
|
||||
} NVME_CDW0;
|
||||
|
||||
typedef struct {
|
||||
NVME_CDW0 Cdw0;
|
||||
UINT8 Flags;
|
||||
#define CDW10_VALID 0x01
|
||||
#define CDW11_VALID 0x02
|
||||
#define CDW12_VALID 0x04
|
||||
#define CDW13_VALID 0x08
|
||||
#define CDW14_VALID 0x10
|
||||
#define CDW15_VALID 0x20
|
||||
UINT32 Nsid;
|
||||
UINT32 Cdw10;
|
||||
UINT32 Cdw11;
|
||||
UINT32 Cdw12;
|
||||
UINT32 Cdw13;
|
||||
UINT32 Cdw14;
|
||||
UINT32 Cdw15;
|
||||
} NVM_EXPRESS_COMMAND;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Cdw0;
|
||||
UINT32 Cdw1;
|
||||
UINT32 Cdw2;
|
||||
UINT32 Cdw3;
|
||||
} NVM_EXPRESS_RESPONSE;
|
||||
|
||||
typedef struct {
|
||||
UINT64 CommandTimeout;
|
||||
UINT64 TransferBuffer;
|
||||
UINT32 TransferLength;
|
||||
UINT64 MetadataBuffer;
|
||||
UINT32 MetadataLength;
|
||||
UINT8 QueueId;
|
||||
NVM_EXPRESS_COMMAND *NvmeCmd;
|
||||
NVM_EXPRESS_RESPONSE *NvmeResponse;
|
||||
} NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
// Internal fields
|
||||
typedef enum {
|
||||
NvmeStatusUnknown,
|
||||
NvmeStatusInit,
|
||||
NvmeStatusInuse,
|
||||
NvmeStatusMax,
|
||||
} NVME_STATUS;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Nbar;
|
||||
UINT32 BaseMem;
|
||||
BOOLEAN PollCancellation;
|
||||
UINT16 NvmeInitWaitTime;
|
||||
|
||||
NVME_STATUS State;
|
||||
UINT8 BusID;
|
||||
UINT8 DeviceID;
|
||||
UINT8 FuncID;
|
||||
UINTN PciBase;
|
||||
|
||||
UINT32 Nsid;
|
||||
UINT64 Nsuuid;
|
||||
UINT32 BlockSize;
|
||||
EFI_LBA LastBlock;
|
||||
|
||||
//
|
||||
// Pointers to 4kB aligned submission & completion queues.
|
||||
//
|
||||
NVME_SQ *SqBuffer[NVME_MAX_IO_QUEUES];
|
||||
NVME_CQ *CqBuffer[NVME_MAX_IO_QUEUES];
|
||||
UINT16 Cid[NVME_MAX_IO_QUEUES];
|
||||
|
||||
//
|
||||
// Submission and completion queue indices.
|
||||
//
|
||||
NVME_SQTDBL SqTdbl[NVME_MAX_IO_QUEUES];
|
||||
NVME_CQHDBL CqHdbl[NVME_MAX_IO_QUEUES];
|
||||
UINT8 Pt[NVME_MAX_IO_QUEUES];
|
||||
|
||||
UINTN SqeCount[NVME_MAX_IO_QUEUES];
|
||||
|
||||
//
|
||||
// Nvme controller capabilities
|
||||
//
|
||||
NVME_CAP Cap;
|
||||
|
||||
//
|
||||
// pointer to identify controller Data
|
||||
//
|
||||
NVME_ADMIN_CONTROLLER_DATA *ControllerData;
|
||||
NVME_ADMIN_NAMESPACE_DATA *NamespaceData;
|
||||
} NVME_CONTEXT;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
Transfer MMIO Data to memory.
|
||||
|
||||
@param[in,out] MemBuffer - Destination: Memory address
|
||||
@param[in] MmioAddr - Source: MMIO address
|
||||
@param[in] Size - Size for read
|
||||
|
||||
@retval EFI_SUCCESS - MMIO read sucessfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeMmioRead (
|
||||
IN OUT VOID *MemBuffer,
|
||||
IN UINTN MmioAddr,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
Transfer memory Data to MMIO.
|
||||
|
||||
@param[in,out] MmioAddr - Destination: MMIO address
|
||||
@param[in] MemBuffer - Source: Memory address
|
||||
@param[in] Size - Size for write
|
||||
|
||||
@retval EFI_SUCCESS - MMIO write sucessfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeMmioWrite (
|
||||
IN OUT UINTN MmioAddr,
|
||||
IN VOID *MemBuffer,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
Transfer memory data to MMIO.
|
||||
|
||||
@param[in,out] MmioAddr - Destination: MMIO address
|
||||
@param[in] MemBuffer - Source: Memory address
|
||||
@param[in] Size - Size for write
|
||||
|
||||
@retval EFI_SUCCESS - MMIO write sucessfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
OpalPciWrite (
|
||||
IN OUT UINTN MmioAddr,
|
||||
IN VOID *MemBuffer,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
Transfer MMIO data to memory.
|
||||
|
||||
@param[in,out] MemBuffer - Destination: Memory address
|
||||
@param[in] MmioAddr - Source: MMIO address
|
||||
@param[in] Size - Size for read
|
||||
|
||||
@retval EFI_SUCCESS - MMIO read sucessfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
OpalPciRead (
|
||||
IN OUT VOID *MemBuffer,
|
||||
IN UINTN MmioAddr,
|
||||
IN UINTN Size
|
||||
);
|
||||
|
||||
/**
|
||||
Allocate transfer-related Data struct which is used at Nvme.
|
||||
|
||||
@param[in] ImageHandle Image handle for this driver image
|
||||
@param[in] Nvme The pointer to the NVME_CONTEXT Data structure.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCE The allocation is failure.
|
||||
@retval EFI_SUCCESS Successful to allocate memory.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
NvmeAllocateResource (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN NVME_CONTEXT *Nvme
|
||||
);
|
||||
|
||||
/**
|
||||
Free allocated transfer-related Data struct which is used at NVMe.
|
||||
|
||||
@param[in] Nvme The pointer to the NVME_CONTEXT Data structure.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
NvmeFreeResource (
|
||||
IN NVME_CONTEXT *Nvme
|
||||
);
|
||||
|
||||
/**
|
||||
Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports
|
||||
both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the nonblocking
|
||||
I/O functionality is optional.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] NamespaceId - Is a 32 bit Namespace ID to which the Express HCI command packet will be sent.
|
||||
A Value of 0 denotes the NVM Express controller, a Value of all 0FFh in the namespace
|
||||
ID specifies that the command packet should be sent to all valid namespaces.
|
||||
@param[in] NamespaceUuid - Is a 64 bit Namespace UUID to which the Express HCI command packet will be sent.
|
||||
A Value of 0 denotes the NVM Express controller, a Value of all 0FFh in the namespace
|
||||
UUID specifies that the command packet should be sent to all valid namespaces.
|
||||
@param[in,out] Packet - A pointer to the NVM Express HCI Command Packet to send to the NVMe namespace specified
|
||||
by NamespaceId.
|
||||
|
||||
@retval EFI_SUCCESS - The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred
|
||||
to, or from DataBuffer.
|
||||
@retval EFI_NOT_READY - The NVM Express Command Packet could not be sent because the controller is not ready. The caller
|
||||
may retry again later.
|
||||
@retval EFI_DEVICE_ERROR - A device error occurred while attempting to send the NVM Express Command Packet.
|
||||
@retval EFI_INVALID_PARAMETER - Namespace, or the contents of NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM
|
||||
Express Command Packet was not sent, so no additional status information is available.
|
||||
@retval EFI_UNSUPPORTED - The command described by the NVM Express Command Packet is not supported by the host adapter.
|
||||
The NVM Express Command Packet was not sent, so no additional status information is available.
|
||||
@retval EFI_TIMEOUT - A timeout occurred while waiting for the NVM Express Command Packet to execute.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmePassThru (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT32 NamespaceId,
|
||||
IN UINT64 NamespaceUuid,
|
||||
IN OUT NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet
|
||||
);
|
||||
|
||||
/**
|
||||
Waits until all NVME commands completed.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] Qid - Queue index
|
||||
|
||||
@retval EFI_SUCCESS - All NVME commands have completed
|
||||
@retval EFI_TIMEOUT - Timeout occured
|
||||
@retval EFI_NOT_READY - Not all NVME commands have completed
|
||||
@retval others - Error occurred on device side.
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeWaitAllComplete (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT8 Qid
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the Nvm Express controller.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
|
||||
@retval EFI_SUCCESS - The NVM Express Controller is initialized successfully.
|
||||
@retval Others - A device error occurred while initializing the controller.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeControllerInit (
|
||||
IN NVME_CONTEXT *Nvme
|
||||
);
|
||||
|
||||
/**
|
||||
Un-initialize the Nvm Express controller.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
|
||||
@retval EFI_SUCCESS - The NVM Express Controller is un-initialized successfully.
|
||||
@retval Others - A device error occurred while un-initializing the controller.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeControllerExit (
|
||||
IN NVME_CONTEXT *Nvme
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether there are available command slots.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] Qid - Queue index
|
||||
|
||||
@retval EFI_SUCCESS - Available command slot is found
|
||||
@retval EFI_NOT_READY - No available command slot is found
|
||||
@retval EFI_DEVICE_ERROR - Error occurred on device side.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeHasFreeCmdSlot (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT8 Qid
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether all command slots are clean.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] Qid - Queue index
|
||||
|
||||
@retval EFI_SUCCESS - All command slots are clean
|
||||
@retval EFI_NOT_READY - Not all command slots are clean
|
||||
@retval EFI_DEVICE_ERROR - Error occurred on device side.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeIsAllCmdSlotClean (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT8 Qid
|
||||
);
|
||||
|
||||
/**
|
||||
Read sector Data from the NVMe device.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in,out] Buffer - The Buffer used to store the Data read from the device.
|
||||
@param[in] Lba - The start block number.
|
||||
@param[in] Blocks - Total block number to be read.
|
||||
|
||||
@retval EFI_SUCCESS - Datum are read from the device.
|
||||
@retval Others - Fail to read all the datum.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeReadSectors (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN OUT UINT64 Buffer,
|
||||
IN UINT64 Lba,
|
||||
IN UINT32 Blocks
|
||||
);
|
||||
|
||||
/**
|
||||
Write sector Data to the NVMe device.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] Buffer - The Buffer to be written into the device.
|
||||
@param[in] Lba - The start block number.
|
||||
@param[in] Blocks - Total block number to be written.
|
||||
|
||||
@retval EFI_SUCCESS - Datum are written into the Buffer.
|
||||
@retval Others - Fail to write all the datum.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeWriteSectors (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT64 Buffer,
|
||||
IN UINT64 Lba,
|
||||
IN UINT32 Blocks
|
||||
);
|
||||
|
||||
/**
|
||||
Flushes all modified Data to the device.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
|
||||
@retval EFI_SUCCESS - Datum are written into the Buffer.
|
||||
@retval Others - Fail to write all the datum.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeFlush (
|
||||
IN NVME_CONTEXT *Nvme
|
||||
);
|
||||
|
||||
/**
|
||||
Read some blocks from the device.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[out] Buffer - The Buffer used to store the Data read from the device.
|
||||
@param[in] Lba - The start block number.
|
||||
@param[in] Blocks - Total block number to be read.
|
||||
|
||||
@retval EFI_SUCCESS - Datum are read from the device.
|
||||
@retval Others - Fail to read all the datum.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeRead (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
OUT UINT64 Buffer,
|
||||
IN UINT64 Lba,
|
||||
IN UINTN Blocks
|
||||
);
|
||||
|
||||
/**
|
||||
Write some blocks to the device.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] Buffer - The Buffer to be written into the device.
|
||||
@param[in] Lba - The start block number.
|
||||
@param[in] Blocks - Total block number to be written.
|
||||
|
||||
@retval EFI_SUCCESS - Datum are written into the Buffer.
|
||||
@retval Others - Fail to write all the datum.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeWrite (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN UINT64 Buffer,
|
||||
IN UINT64 Lba,
|
||||
IN UINTN Blocks
|
||||
);
|
||||
|
||||
/**
|
||||
Security send and receive commands.
|
||||
|
||||
@param[in] Nvme - The pointer to the NVME_CONTEXT Data structure.
|
||||
@param[in] SendCommand - The flag to indicate the command type, TRUE for Send command and FALSE for receive command
|
||||
@param[in] SecurityProtocol - Security Protocol
|
||||
@param[in] SpSpecific - Security Protocol Specific
|
||||
@param[in] TransferLength - Transfer Length of Buffer (in bytes) - always a multiple of 512
|
||||
@param[in,out] TransferBuffer - Address of Data to transfer
|
||||
|
||||
@return EFI_SUCCESS - Successfully create io submission queue.
|
||||
@return others - Fail to send/receive commands.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
NvmeSecuritySendReceive (
|
||||
IN NVME_CONTEXT *Nvme,
|
||||
IN BOOLEAN SendCommand,
|
||||
IN UINT8 SecurityProtocol,
|
||||
IN UINT16 SpSpecific,
|
||||
IN UINTN TransferLength,
|
||||
IN OUT VOID *TransferBuffer
|
||||
);
|
||||
|
||||
#endif
|
@ -1,814 +0,0 @@
|
||||
/** @file
|
||||
Header file for Registers and Structure definitions
|
||||
|
||||
Copyright (c) 2016, 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 __OPAL_PASSWORD_NVME_REG_H__
|
||||
#define __OPAL_PASSWORD_NVME_REG_H__
|
||||
|
||||
//
|
||||
// PCI Header for PCIe root port configuration
|
||||
//
|
||||
#define NVME_PCIE_PCICMD 0x04
|
||||
#define NVME_PCIE_BNUM 0x18
|
||||
#define NVME_PCIE_SEC_BNUM 0x19
|
||||
#define NVME_PCIE_IOBL 0x1C
|
||||
#define NVME_PCIE_MBL 0x20
|
||||
#define NVME_PCIE_PMBL 0x24
|
||||
#define NVME_PCIE_PMBU32 0x28
|
||||
#define NVME_PCIE_PMLU32 0x2C
|
||||
#define NVME_PCIE_INTR 0x3C
|
||||
|
||||
//
|
||||
// NVMe related definitions
|
||||
//
|
||||
#define PCI_CLASS_MASS_STORAGE_NVM 0x08 // mass storage sub-class non-volatile memory.
|
||||
#define PCI_IF_NVMHCI 0x02 // mass storage programming interface NVMHCI.
|
||||
|
||||
#define NVME_ASQ_SIZE 1 // Number of admin submission queue entries, which is 0-based
|
||||
#define NVME_ACQ_SIZE 1 // Number of admin completion queue entries, which is 0-based
|
||||
|
||||
#define NVME_CSQ_SIZE 63 // Number of I/O submission queue entries, which is 0-based
|
||||
#define NVME_CCQ_SIZE 63 // Number of I/O completion queue entries, which is 0-based
|
||||
|
||||
#define NVME_MAX_IO_QUEUES 2 // Number of I/O queues supported by the driver, 1 for AQ, 1 for CQ
|
||||
|
||||
#define NVME_CSQ_DEPTH (NVME_CSQ_SIZE+1)
|
||||
#define NVME_CCQ_DEPTH (NVME_CCQ_SIZE+1)
|
||||
#define NVME_PRP_SIZE (4) // Pages of PRP list
|
||||
|
||||
#define NVME_CONTROLLER_ID 0
|
||||
|
||||
//
|
||||
// Time out Value for Nvme transaction execution
|
||||
//
|
||||
#define NVME_GENERIC_TIMEOUT 5000000 ///< us
|
||||
#define NVME_CMD_WAIT 100 ///< us
|
||||
#define NVME_CMD_TIMEOUT 20000000 ///< us
|
||||
|
||||
|
||||
|
||||
#define NVME_MEM_MAX_SIZE \
|
||||
(( \
|
||||
1 /* Controller Data */ + \
|
||||
1 /* Identify Data */ + \
|
||||
1 /* ASQ */ + \
|
||||
1 /* ACQ */ + \
|
||||
1 /* SQs */ + \
|
||||
1 /* CQs */ + \
|
||||
NVME_PRP_SIZE * NVME_CSQ_DEPTH /* PRPs */ \
|
||||
) * EFI_PAGE_SIZE)
|
||||
|
||||
|
||||
//
|
||||
// controller register offsets
|
||||
//
|
||||
#define NVME_CAP_OFFSET 0x0000 // Controller Capabilities
|
||||
#define NVME_VER_OFFSET 0x0008 // Version
|
||||
#define NVME_INTMS_OFFSET 0x000c // Interrupt Mask Set
|
||||
#define NVME_INTMC_OFFSET 0x0010 // Interrupt Mask Clear
|
||||
#define NVME_CC_OFFSET 0x0014 // Controller Configuration
|
||||
#define NVME_CSTS_OFFSET 0x001c // Controller Status
|
||||
#define NVME_AQA_OFFSET 0x0024 // Admin Queue Attributes
|
||||
#define NVME_ASQ_OFFSET 0x0028 // Admin Submission Queue Base Address
|
||||
#define NVME_ACQ_OFFSET 0x0030 // Admin Completion Queue Base Address
|
||||
#define NVME_SQ0_OFFSET 0x1000 // Submission Queue 0 (admin) Tail Doorbell
|
||||
#define NVME_CQ0_OFFSET 0x1004 // Completion Queue 0 (admin) Head Doorbell
|
||||
|
||||
//
|
||||
// These register offsets are defined as 0x1000 + (N * (4 << CAP.DSTRD))
|
||||
// Get the doorbell stride bit shift Value from the controller capabilities.
|
||||
//
|
||||
#define NVME_SQTDBL_OFFSET(QID, DSTRD) 0x1000 + ((2 * (QID)) * (4 << (DSTRD))) // Submission Queue y (NVM) Tail Doorbell
|
||||
#define NVME_CQHDBL_OFFSET(QID, DSTRD) 0x1000 + (((2 * (QID)) + 1) * (4 << (DSTRD))) // Completion Queue y (NVM) Head Doorbell
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
//
|
||||
// 3.1.1 Offset 00h: CAP - Controller Capabilities
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Mqes; // Maximum Queue Entries Supported
|
||||
UINT8 Cqr:1; // Contiguous Queues Required
|
||||
UINT8 Ams:2; // Arbitration Mechanism Supported
|
||||
UINT8 Rsvd1:5;
|
||||
UINT8 To; // Timeout
|
||||
UINT16 Dstrd:4;
|
||||
UINT16 Rsvd2:1;
|
||||
UINT16 Css:4; // Command Sets Supported
|
||||
UINT16 Rsvd3:7;
|
||||
UINT8 Mpsmin:4;
|
||||
UINT8 Mpsmax:4;
|
||||
UINT8 Rsvd4;
|
||||
} NVME_CAP;
|
||||
|
||||
//
|
||||
// 3.1.2 Offset 08h: VS - Version
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Mnr; // Minor version number
|
||||
UINT16 Mjr; // Major version number
|
||||
} NVME_VER;
|
||||
|
||||
//
|
||||
// 3.1.5 Offset 14h: CC - Controller Configuration
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 En:1; // Enable
|
||||
UINT16 Rsvd1:3;
|
||||
UINT16 Css:3; // Command Set Selected
|
||||
UINT16 Mps:4; // Memory Page Size
|
||||
UINT16 Ams:3; // Arbitration Mechanism Selected
|
||||
UINT16 Shn:2; // Shutdown Notification
|
||||
UINT8 Iosqes:4; // I/O Submission Queue Entry Size
|
||||
UINT8 Iocqes:4; // I/O Completion Queue Entry Size
|
||||
UINT8 Rsvd2;
|
||||
} NVME_CC;
|
||||
|
||||
//
|
||||
// 3.1.6 Offset 1Ch: CSTS - Controller Status
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Rdy:1; // Ready
|
||||
UINT32 Cfs:1; // Controller Fatal Status
|
||||
UINT32 Shst:2; // Shutdown Status
|
||||
UINT32 Nssro:1; // NVM Subsystem Reset Occurred
|
||||
UINT32 Rsvd1:27;
|
||||
} NVME_CSTS;
|
||||
|
||||
//
|
||||
// 3.1.8 Offset 24h: AQA - Admin Queue Attributes
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Asqs:12; // Submission Queue Size
|
||||
UINT16 Rsvd1:4;
|
||||
UINT16 Acqs:12; // Completion Queue Size
|
||||
UINT16 Rsvd2:4;
|
||||
} NVME_AQA;
|
||||
|
||||
//
|
||||
// 3.1.9 Offset 28h: ASQ - Admin Submission Queue Base Address
|
||||
//
|
||||
#define NVME_ASQ UINT64
|
||||
|
||||
//
|
||||
// 3.1.10 Offset 30h: ACQ - Admin Completion Queue Base Address
|
||||
//
|
||||
#define NVME_ACQ UINT64
|
||||
|
||||
//
|
||||
// 3.1.11 Offset (1000h + ((2y) * (4 << CAP.DSTRD))): SQyTDBL - Submission Queue y Tail Doorbell
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Sqt;
|
||||
UINT16 Rsvd1;
|
||||
} NVME_SQTDBL;
|
||||
|
||||
//
|
||||
// 3.1.12 Offset (1000h + ((2y + 1) * (4 << CAP.DSTRD))): CQyHDBL - Completion Queue y Head Doorbell
|
||||
//
|
||||
typedef struct {
|
||||
UINT16 Cqh;
|
||||
UINT16 Rsvd1;
|
||||
} NVME_CQHDBL;
|
||||
|
||||
//
|
||||
// NVM command set structures
|
||||
//
|
||||
// Read Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10, 11
|
||||
//
|
||||
UINT64 Slba; /* Starting Sector Address */
|
||||
//
|
||||
// CDW 12
|
||||
//
|
||||
UINT16 Nlb; /* Number of Sectors */
|
||||
UINT16 Rsvd1:10;
|
||||
UINT16 Prinfo:4; /* Protection Info Check */
|
||||
UINT16 Fua:1; /* Force Unit Access */
|
||||
UINT16 Lr:1; /* Limited Retry */
|
||||
//
|
||||
// CDW 13
|
||||
//
|
||||
UINT32 Af:4; /* Access Frequency */
|
||||
UINT32 Al:2; /* Access Latency */
|
||||
UINT32 Sr:1; /* Sequential Request */
|
||||
UINT32 In:1; /* Incompressible */
|
||||
UINT32 Rsvd2:24;
|
||||
//
|
||||
// CDW 14
|
||||
//
|
||||
UINT32 Eilbrt; /* Expected Initial Logical Block Reference Tag */
|
||||
//
|
||||
// CDW 15
|
||||
//
|
||||
UINT16 Elbat; /* Expected Logical Block Application Tag */
|
||||
UINT16 Elbatm; /* Expected Logical Block Application Tag Mask */
|
||||
} NVME_READ;
|
||||
|
||||
//
|
||||
// Write Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10, 11
|
||||
//
|
||||
UINT64 Slba; /* Starting Sector Address */
|
||||
//
|
||||
// CDW 12
|
||||
//
|
||||
UINT16 Nlb; /* Number of Sectors */
|
||||
UINT16 Rsvd1:10;
|
||||
UINT16 Prinfo:4; /* Protection Info Check */
|
||||
UINT16 Fua:1; /* Force Unit Access */
|
||||
UINT16 Lr:1; /* Limited Retry */
|
||||
//
|
||||
// CDW 13
|
||||
//
|
||||
UINT32 Af:4; /* Access Frequency */
|
||||
UINT32 Al:2; /* Access Latency */
|
||||
UINT32 Sr:1; /* Sequential Request */
|
||||
UINT32 In:1; /* Incompressible */
|
||||
UINT32 Rsvd2:24;
|
||||
//
|
||||
// CDW 14
|
||||
//
|
||||
UINT32 Ilbrt; /* Initial Logical Block Reference Tag */
|
||||
//
|
||||
// CDW 15
|
||||
//
|
||||
UINT16 Lbat; /* Logical Block Application Tag */
|
||||
UINT16 Lbatm; /* Logical Block Application Tag Mask */
|
||||
} NVME_WRITE;
|
||||
|
||||
//
|
||||
// Flush
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Flush; /* Flush */
|
||||
} NVME_FLUSH;
|
||||
|
||||
//
|
||||
// Write Uncorrectable command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10, 11
|
||||
//
|
||||
UINT64 Slba; /* Starting LBA */
|
||||
//
|
||||
// CDW 12
|
||||
//
|
||||
UINT32 Nlb:16; /* Number of Logical Blocks */
|
||||
UINT32 Rsvd1:16;
|
||||
} NVME_WRITE_UNCORRECTABLE;
|
||||
|
||||
//
|
||||
// Write Zeroes command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10, 11
|
||||
//
|
||||
UINT64 Slba; /* Starting LBA */
|
||||
//
|
||||
// CDW 12
|
||||
//
|
||||
UINT16 Nlb; /* Number of Logical Blocks */
|
||||
UINT16 Rsvd1:10;
|
||||
UINT16 Prinfo:4; /* Protection Info Check */
|
||||
UINT16 Fua:1; /* Force Unit Access */
|
||||
UINT16 Lr:1; /* Limited Retry */
|
||||
//
|
||||
// CDW 13
|
||||
//
|
||||
UINT32 Rsvd2;
|
||||
//
|
||||
// CDW 14
|
||||
//
|
||||
UINT32 Ilbrt; /* Initial Logical Block Reference Tag */
|
||||
//
|
||||
// CDW 15
|
||||
//
|
||||
UINT16 Lbat; /* Logical Block Application Tag */
|
||||
UINT16 Lbatm; /* Logical Block Application Tag Mask */
|
||||
} NVME_WRITE_ZEROES;
|
||||
|
||||
//
|
||||
// Compare command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10, 11
|
||||
//
|
||||
UINT64 Slba; /* Starting LBA */
|
||||
//
|
||||
// CDW 12
|
||||
//
|
||||
UINT16 Nlb; /* Number of Logical Blocks */
|
||||
UINT16 Rsvd1:10;
|
||||
UINT16 Prinfo:4; /* Protection Info Check */
|
||||
UINT16 Fua:1; /* Force Unit Access */
|
||||
UINT16 Lr:1; /* Limited Retry */
|
||||
//
|
||||
// CDW 13
|
||||
//
|
||||
UINT32 Rsvd2;
|
||||
//
|
||||
// CDW 14
|
||||
//
|
||||
UINT32 Eilbrt; /* Expected Initial Logical Block Reference Tag */
|
||||
//
|
||||
// CDW 15
|
||||
//
|
||||
UINT16 Elbat; /* Expected Logical Block Application Tag */
|
||||
UINT16 Elbatm; /* Expected Logical Block Application Tag Mask */
|
||||
} NVME_COMPARE;
|
||||
|
||||
typedef union {
|
||||
NVME_READ Read;
|
||||
NVME_WRITE Write;
|
||||
NVME_FLUSH Flush;
|
||||
NVME_WRITE_UNCORRECTABLE WriteUncorrectable;
|
||||
NVME_WRITE_ZEROES WriteZeros;
|
||||
NVME_COMPARE Compare;
|
||||
} NVME_CMD;
|
||||
|
||||
typedef struct {
|
||||
UINT16 Mp; /* Maximum Power */
|
||||
UINT8 Rsvd1; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 Mps:1; /* Max Power Scale */
|
||||
UINT8 Nops:1; /* Non-Operational State */
|
||||
UINT8 Rsvd2:6; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT32 Enlat; /* Entry Latency */
|
||||
UINT32 Exlat; /* Exit Latency */
|
||||
UINT8 Rrt:5; /* Relative Read Throughput */
|
||||
UINT8 Rsvd3:3; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 Rrl:5; /* Relative Read Leatency */
|
||||
UINT8 Rsvd4:3; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 Rwt:5; /* Relative Write Throughput */
|
||||
UINT8 Rsvd5:3; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 Rwl:5; /* Relative Write Leatency */
|
||||
UINT8 Rsvd6:3; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 Rsvd7[16]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
} NVME_PSDESCRIPTOR;
|
||||
|
||||
//
|
||||
// Identify Controller Data
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// Controller Capabilities and Features 0-255
|
||||
//
|
||||
UINT16 Vid; /* PCI Vendor ID */
|
||||
UINT16 Ssvid; /* PCI sub-system vendor ID */
|
||||
UINT8 Sn[20]; /* Produce serial number */
|
||||
|
||||
UINT8 Mn[40]; /* Proeduct model number */
|
||||
UINT8 Fr[8]; /* Firmware Revision */
|
||||
UINT8 Rab; /* Recommended Arbitration Burst */
|
||||
UINT8 Ieee_oiu[3]; /* Organization Unique Identifier */
|
||||
UINT8 Cmic; /* Multi-interface Capabilities */
|
||||
UINT8 Mdts; /* Maximum Data Transfer Size */
|
||||
UINT8 Cntlid[2]; /* Controller ID */
|
||||
UINT8 Rsvd1[176]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
//
|
||||
// Admin Command Set Attributes
|
||||
//
|
||||
UINT16 Oacs; /* Optional Admin Command Support */
|
||||
UINT8 Acl; /* Abort Command Limit */
|
||||
UINT8 Aerl; /* Async Event Request Limit */
|
||||
UINT8 Frmw; /* Firmware updates */
|
||||
UINT8 Lpa; /* Log Page Attributes */
|
||||
UINT8 Elpe; /* Error Log Page Entries */
|
||||
UINT8 Npss; /* Number of Power States Support */
|
||||
UINT8 Avscc; /* Admin Vendor Specific Command Configuration */
|
||||
UINT8 Apsta; /* Autonomous Power State Transition Attributes */
|
||||
UINT8 Rsvd2[246]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
//
|
||||
// NVM Command Set Attributes
|
||||
//
|
||||
UINT8 Sqes; /* Submission Queue Entry Size */
|
||||
UINT8 Cqes; /* Completion Queue Entry Size */
|
||||
UINT16 Rsvd3; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT32 Nn; /* Number of Namespaces */
|
||||
UINT16 Oncs; /* Optional NVM Command Support */
|
||||
UINT16 Fuses; /* Fused Operation Support */
|
||||
UINT8 Fna; /* Format NVM Attributes */
|
||||
UINT8 Vwc; /* Volatile Write Cache */
|
||||
UINT16 Awun; /* Atomic Write Unit Normal */
|
||||
UINT16 Awupf; /* Atomic Write Unit Power Fail */
|
||||
UINT8 Nvscc; /* NVM Vendor Specific Command Configuration */
|
||||
UINT8 Rsvd4; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT16 Acwu; /* Atomic Compare & Write Unit */
|
||||
UINT16 Rsvd5; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT32 Sgls; /* SGL Support */
|
||||
UINT8 Rsvd6[164]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
//
|
||||
// I/O Command set Attributes
|
||||
//
|
||||
UINT8 Rsvd7[1344]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
//
|
||||
// Power State Descriptors
|
||||
//
|
||||
NVME_PSDESCRIPTOR PsDescriptor[32];
|
||||
|
||||
UINT8 VendorData[1024]; /* Vendor specific Data */
|
||||
} NVME_ADMIN_CONTROLLER_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT16 Security : 1; /* supports security send/receive commands */
|
||||
UINT16 Format : 1; /* supports format nvm command */
|
||||
UINT16 Firmware : 1; /* supports firmware activate/download commands */
|
||||
UINT16 Oacs_rsvd : 13;
|
||||
} OACS; // optional admin command support: NVME_ADMIN_CONTROLLER_DATA.Oacs
|
||||
|
||||
typedef struct {
|
||||
UINT16 Ms; /* Metadata Size */
|
||||
UINT8 Lbads; /* LBA Data Size */
|
||||
UINT8 Rp:2; /* Relative Performance */
|
||||
#define LBAF_RP_BEST 00b
|
||||
#define LBAF_RP_BETTER 01b
|
||||
#define LBAF_RP_GOOD 10b
|
||||
#define LBAF_RP_DEGRADED 11b
|
||||
UINT8 Rsvd1:6; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
} NVME_LBAFORMAT;
|
||||
|
||||
//
|
||||
// Identify Namespace Data
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// NVM Command Set Specific
|
||||
//
|
||||
UINT64 Nsze; /* Namespace Size (total number of blocks in formatted namespace) */
|
||||
UINT64 Ncap; /* Namespace Capacity (max number of logical blocks) */
|
||||
UINT64 Nuse; /* Namespace Utilization */
|
||||
UINT8 Nsfeat; /* Namespace Features */
|
||||
UINT8 Nlbaf; /* Number of LBA Formats */
|
||||
UINT8 Flbas; /* Formatted LBA Size */
|
||||
UINT8 Mc; /* Metadata Capabilities */
|
||||
UINT8 Dpc; /* End-to-end Data Protection capabilities */
|
||||
UINT8 Dps; /* End-to-end Data Protection Type Settings */
|
||||
UINT8 Nmic; /* Namespace Multi-path I/O and Namespace Sharing Capabilities */
|
||||
UINT8 Rescap; /* Reservation Capabilities */
|
||||
UINT8 Rsvd1[88]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT64 Eui64; /* IEEE Extended Unique Identifier */
|
||||
//
|
||||
// LBA Format
|
||||
//
|
||||
NVME_LBAFORMAT LbaFormat[16];
|
||||
|
||||
UINT8 Rsvd2[192]; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT8 VendorData[3712]; /* Vendor specific Data */
|
||||
} NVME_ADMIN_NAMESPACE_DATA;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Identify Cmd
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Cns:2;
|
||||
UINT32 Rsvd1:30;
|
||||
} NVME_ADMIN_IDENTIFY;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Create I/O Completion Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Qid:16; /* Queue Identifier */
|
||||
UINT32 Qsize:16; /* Queue Size */
|
||||
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Pc:1; /* Physically Contiguous */
|
||||
UINT32 Ien:1; /* Interrupts Enabled */
|
||||
UINT32 Rsvd1:14; /* reserved as of Nvm Express 1.1 Spec */
|
||||
UINT32 Iv:16; /* Interrupt Vector */
|
||||
} NVME_ADMIN_CRIOCQ;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Create I/O Submission Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Qid:16; /* Queue Identifier */
|
||||
UINT32 Qsize:16; /* Queue Size */
|
||||
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Pc:1; /* Physically Contiguous */
|
||||
UINT32 Qprio:2; /* Queue Priority */
|
||||
UINT32 Rsvd1:13; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
UINT32 Cqid:16; /* Completion Queue ID */
|
||||
} NVME_ADMIN_CRIOSQ;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Delete I/O Completion Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT16 Qid;
|
||||
UINT16 Rsvd1;
|
||||
} NVME_ADMIN_DEIOCQ;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Delete I/O Submission Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT16 Qid;
|
||||
UINT16 Rsvd1;
|
||||
} NVME_ADMIN_DEIOSQ;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Security Send
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Resv:8; /* Reserve */
|
||||
UINT32 Spsp:16; /* SP Specific */
|
||||
UINT32 Secp:8; /* Security Protocol */
|
||||
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Tl; /* Transfer Length */
|
||||
} NVME_ADMIN_SECSEND;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Abort Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Sqid:16; /* Submission Queue identifier */
|
||||
UINT32 Cid:16; /* Command Identifier */
|
||||
} NVME_ADMIN_ABORT;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Firmware Activate Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Fs:3; /* Submission Queue identifier */
|
||||
UINT32 Aa:2; /* Command Identifier */
|
||||
UINT32 Rsvd1:27;
|
||||
} NVME_ADMIN_FIRMWARE_ACTIVATE;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Firmware Image Download Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Numd; /* Number of Dwords */
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Ofst; /* Offset */
|
||||
} NVME_ADMIN_FIRMWARE_IMAGE_DOWNLOAD;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Get Features Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Fid:8; /* Feature Identifier */
|
||||
UINT32 Sel:3; /* Select */
|
||||
UINT32 Rsvd1:21;
|
||||
} NVME_ADMIN_GET_FEATURES;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Get Log Page Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Lid:8; /* Log Page Identifier */
|
||||
#define LID_ERROR_INFO
|
||||
#define LID_SMART_INFO
|
||||
#define LID_FW_SLOT_INFO
|
||||
UINT32 Rsvd1:8;
|
||||
UINT32 Numd:12; /* Number of Dwords */
|
||||
UINT32 Rsvd2:4; /* Reserved as of Nvm Express 1.1 Spec */
|
||||
} NVME_ADMIN_GET_LOG_PAGE;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Set Features Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Fid:8; /* Feature Identifier */
|
||||
UINT32 Rsvd1:23;
|
||||
UINT32 Sv:1; /* Save */
|
||||
} NVME_ADMIN_SET_FEATURES;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Format NVM Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Lbaf:4; /* LBA Format */
|
||||
UINT32 Ms:1; /* Metadata Settings */
|
||||
UINT32 Pi:3; /* Protection Information */
|
||||
UINT32 Pil:1; /* Protection Information Location */
|
||||
UINT32 Ses:3; /* Secure Erase Settings */
|
||||
UINT32 Rsvd1:20;
|
||||
} NVME_ADMIN_FORMAT_NVM;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Security Receive Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Rsvd1:8;
|
||||
UINT32 Spsp:16; /* SP Specific */
|
||||
UINT32 Secp:8; /* Security Protocol */
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Al; /* Allocation Length */
|
||||
} NVME_ADMIN_SECURITY_RECEIVE;
|
||||
|
||||
//
|
||||
// NvmExpress Admin Security Send Command
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 10
|
||||
//
|
||||
UINT32 Rsvd1:8;
|
||||
UINT32 Spsp:16; /* SP Specific */
|
||||
UINT32 Secp:8; /* Security Protocol */
|
||||
//
|
||||
// CDW 11
|
||||
//
|
||||
UINT32 Tl; /* Transfer Length */
|
||||
} NVME_ADMIN_SECURITY_SEND;
|
||||
|
||||
typedef union {
|
||||
NVME_ADMIN_IDENTIFY Identify;
|
||||
NVME_ADMIN_CRIOCQ CrIoCq;
|
||||
NVME_ADMIN_CRIOSQ CrIoSq;
|
||||
NVME_ADMIN_DEIOCQ DeIoCq;
|
||||
NVME_ADMIN_DEIOSQ DeIoSq;
|
||||
NVME_ADMIN_ABORT Abort;
|
||||
NVME_ADMIN_FIRMWARE_ACTIVATE Activate;
|
||||
NVME_ADMIN_FIRMWARE_IMAGE_DOWNLOAD FirmwareImageDownload;
|
||||
NVME_ADMIN_GET_FEATURES GetFeatures;
|
||||
NVME_ADMIN_GET_LOG_PAGE GetLogPage;
|
||||
NVME_ADMIN_SET_FEATURES SetFeatures;
|
||||
NVME_ADMIN_FORMAT_NVM FormatNvm;
|
||||
NVME_ADMIN_SECURITY_RECEIVE SecurityReceive;
|
||||
NVME_ADMIN_SECURITY_SEND SecuritySend;
|
||||
} NVME_ADMIN_CMD;
|
||||
|
||||
typedef struct {
|
||||
UINT32 Cdw10;
|
||||
UINT32 Cdw11;
|
||||
UINT32 Cdw12;
|
||||
UINT32 Cdw13;
|
||||
UINT32 Cdw14;
|
||||
UINT32 Cdw15;
|
||||
} NVME_RAW;
|
||||
|
||||
typedef union {
|
||||
NVME_ADMIN_CMD Admin; // Union of Admin commands
|
||||
NVME_CMD Nvm; // Union of Nvm commands
|
||||
NVME_RAW Raw;
|
||||
} NVME_PAYLOAD;
|
||||
|
||||
//
|
||||
// Submission Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 0, Common to all comnmands
|
||||
//
|
||||
UINT8 Opc; // Opcode
|
||||
UINT8 Fuse:2; // Fused Operation
|
||||
UINT8 Rsvd1:5;
|
||||
UINT8 Psdt:1; // PRP or SGL for Data Transfer
|
||||
UINT16 Cid; // Command Identifier
|
||||
|
||||
//
|
||||
// CDW 1
|
||||
//
|
||||
UINT32 Nsid; // Namespace Identifier
|
||||
|
||||
//
|
||||
// CDW 2,3
|
||||
//
|
||||
UINT64 Rsvd2;
|
||||
|
||||
//
|
||||
// CDW 4,5
|
||||
//
|
||||
UINT64 Mptr; // Metadata Pointer
|
||||
|
||||
//
|
||||
// CDW 6-9
|
||||
//
|
||||
UINT64 Prp[2]; // First and second PRP entries
|
||||
|
||||
NVME_PAYLOAD Payload;
|
||||
|
||||
} NVME_SQ;
|
||||
|
||||
//
|
||||
// Completion Queue
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// CDW 0
|
||||
//
|
||||
UINT32 Dword0;
|
||||
//
|
||||
// CDW 1
|
||||
//
|
||||
UINT32 Rsvd1;
|
||||
//
|
||||
// CDW 2
|
||||
//
|
||||
UINT16 Sqhd; // Submission Queue Head Pointer
|
||||
UINT16 Sqid; // Submission Queue Identifier
|
||||
//
|
||||
// CDW 3
|
||||
//
|
||||
UINT16 Cid; // Command Identifier
|
||||
UINT16 Pt:1; // Phase Tag
|
||||
UINT16 Sc:8; // Status Code
|
||||
UINT16 Sct:3; // Status Code Type
|
||||
UINT16 Rsvd2:2;
|
||||
UINT16 Mo:1; // More
|
||||
UINT16 Dnr:1; // Retry
|
||||
} NVME_CQ;
|
||||
|
||||
//
|
||||
// Nvm Express Admin cmd opcodes
|
||||
//
|
||||
#define NVME_ADMIN_DELIOSQ_OPC 0
|
||||
#define NVME_ADMIN_CRIOSQ_OPC 1
|
||||
#define NVME_ADMIN_DELIOCQ_OPC 4
|
||||
#define NVME_ADMIN_CRIOCQ_OPC 5
|
||||
#define NVME_ADMIN_IDENTIFY_OPC 6
|
||||
#define NVME_ADMIN_SECURITY_SEND_OPC 0x81
|
||||
#define NVME_ADMIN_SECURITY_RECV_OPC 0x82
|
||||
|
||||
#define NVME_IO_FLUSH_OPC 0
|
||||
#define NVME_IO_WRITE_OPC 1
|
||||
#define NVME_IO_READ_OPC 2
|
||||
|
||||
//
|
||||
// Offset from the beginning of private Data queue Buffer
|
||||
//
|
||||
#define NVME_ASQ_BUF_OFFSET EFI_PAGE_SIZE
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,299 +0,0 @@
|
||||
/** @file
|
||||
Opal password smm driver which is used to support Opal security feature at s3 path.
|
||||
|
||||
Copyright (c) 2016, 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 _OPAL_PASSWORD_SMM_H_
|
||||
#define _OPAL_PASSWORD_SMM_H_
|
||||
|
||||
#include <PiSmm.h>
|
||||
#include <IndustryStandard/Atapi.h>
|
||||
|
||||
#include <Protocol/SmmSwDispatch2.h>
|
||||
#include <Protocol/SmmSxDispatch2.h>
|
||||
#include <Protocol/AtaPassThru.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/SmmReadyToLock.h>
|
||||
#include <Protocol/SmmVariable.h>
|
||||
#include <Protocol/VariableLock.h>
|
||||
#include <Protocol/SmmEndOfDxe.h>
|
||||
#include <Protocol/StorageSecurityCommand.h>
|
||||
|
||||
#include <Library/OpalPasswordSupportLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
#include <Library/TimerLib.h>
|
||||
#include <Library/PciLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/SmmServicesTableLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/S3BootScriptLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/SmmIoLib.h>
|
||||
|
||||
#include <IndustryStandard/Pci22.h>
|
||||
|
||||
#include <Guid/OpalPasswordExtraInfoVariable.h>
|
||||
|
||||
#include "OpalAhciMode.h"
|
||||
#include "OpalIdeMode.h"
|
||||
#include "OpalNvmeMode.h"
|
||||
|
||||
//
|
||||
// Time out Value for ATA pass through protocol
|
||||
//
|
||||
#define ATA_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
|
||||
|
||||
//
|
||||
// The payload Length of HDD related ATA commands
|
||||
//
|
||||
#define HDD_PAYLOAD 512
|
||||
//
|
||||
// According to ATA spec, the max Length of hdd password is 32 bytes
|
||||
//
|
||||
#define OPAL_PASSWORD_MAX_LENGTH 32
|
||||
|
||||
extern VOID *mBuffer;
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
UINT32 Address;
|
||||
S3_BOOT_SCRIPT_LIB_WIDTH Width;
|
||||
} OPAL_HC_PCI_REGISTER_SAVE;
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT32 SegNum;
|
||||
UINT32 BusNum;
|
||||
UINT32 DevNum;
|
||||
UINT32 FuncNum;
|
||||
} PCI_DEVICE;
|
||||
|
||||
/**
|
||||
* Opal I/O Type utilized by the Trusted IO callback
|
||||
*
|
||||
* The type indicates if the I/O is a send or receive
|
||||
*/
|
||||
typedef enum {
|
||||
//
|
||||
// I/O is a TCG Trusted Send command
|
||||
//
|
||||
OpalSend,
|
||||
|
||||
//
|
||||
// I/O is a TCG Trusted Receive command
|
||||
//
|
||||
OpalRecv
|
||||
} OPAL_IO_TYPE;
|
||||
|
||||
|
||||
#define OPAL_SMM_DEVICE_SIGNATURE SIGNATURE_32 ('o', 's', 'd', 's')
|
||||
|
||||
typedef struct {
|
||||
UINTN Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL Sscp;
|
||||
|
||||
UINT32 SegNum;
|
||||
UINT32 BusNum;
|
||||
UINT32 DevNum;
|
||||
UINT32 FuncNum;
|
||||
|
||||
UINT8 DeviceType;
|
||||
|
||||
UINT32 SataPort;
|
||||
UINT32 SataPortMultiplierPort;
|
||||
|
||||
UINT32 NvmeNamespaceId;
|
||||
|
||||
UINT8 Password[32];
|
||||
UINT8 PasswordLength;
|
||||
|
||||
UINT32 Length;
|
||||
PCI_DEVICE *PciBridgeNode;
|
||||
|
||||
UINT16 OpalBaseComId;
|
||||
} OPAL_SMM_DEVICE;
|
||||
|
||||
#define OPAL_SMM_DEVICE_FROM_THIS(a) CR (a, OPAL_SMM_DEVICE, Sscp, OPAL_SMM_DEVICE_SIGNATURE)
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
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
|
||||
SecurityReceiveData (
|
||||
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
|
||||
SecuritySendData (
|
||||
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 // _OPAL_PASSWORD_SMM_H_
|
||||
|
@ -1,77 +0,0 @@
|
||||
## @file
|
||||
# This is a Opal Password Smm driver.
|
||||
#
|
||||
# Copyright (c) 2016, 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 = OpalPasswordSmm
|
||||
FILE_GUID = 7D24A234-A8C2-4718-BF60-A2EF070F414E
|
||||
MODULE_TYPE = DXE_SMM_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
PI_SPECIFICATION_VERSION = 0x0001000A
|
||||
ENTRY_POINT = OpalPasswordSmmInit
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources]
|
||||
OpalPasswordSmm.c
|
||||
OpalPasswordSmm.h
|
||||
OpalAhciMode.c
|
||||
OpalAhciMode.h
|
||||
OpalIdeMode.c
|
||||
OpalIdeMode.h
|
||||
OpalNvmeMode.c
|
||||
OpalNvmeMode.h
|
||||
OpalNvmeReg.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
SecurityPkg/SecurityPkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
UefiBootServicesTableLib
|
||||
UefiDriverEntryPoint
|
||||
UefiRuntimeServicesTableLib
|
||||
DebugLib
|
||||
IoLib
|
||||
PciLib
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
SmmServicesTableLib
|
||||
MemoryAllocationLib
|
||||
UefiLib
|
||||
TimerLib
|
||||
S3BootScriptLib
|
||||
DxeServicesTableLib
|
||||
DevicePathLib
|
||||
OpalPasswordSupportLib
|
||||
SmmIoLib
|
||||
|
||||
[Guids]
|
||||
gOpalExtraInfoVariableGuid ## CONSUMES ## GUID
|
||||
|
||||
[Protocols]
|
||||
gEfiSmmSwDispatch2ProtocolGuid ## CONSUMES
|
||||
gEfiAtaPassThruProtocolGuid ## CONSUMES
|
||||
gEfiPciIoProtocolGuid ## CONSUMES
|
||||
gEfiSmmSxDispatch2ProtocolGuid ## CONSUMES
|
||||
gEfiSmmVariableProtocolGuid ## CONSUMES
|
||||
gEfiStorageSecurityCommandProtocolGuid ## CONSUMES
|
||||
|
||||
[Depex]
|
||||
gEfiSmmSwDispatch2ProtocolGuid AND
|
||||
gEfiSmmSxDispatch2ProtocolGuid AND
|
||||
gEfiSmmVariableProtocolGuid
|
Loading…
x
Reference in New Issue
Block a user