2011-09-02 09:49:32 +02:00
|
|
|
/** @file
|
|
|
|
The module entry point for Tcg configuration module.
|
|
|
|
|
2018-06-27 15:13:09 +02:00
|
|
|
Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:06:56 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2011-09-02 09:49:32 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "TcgConfigImpl.h"
|
2013-09-18 07:31:18 +02:00
|
|
|
#include <Guid/TpmInstance.h>
|
2011-09-02 09:49:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
The entry point for Tcg configuration driver.
|
|
|
|
|
|
|
|
@param[in] ImageHandle The image handle of the driver.
|
|
|
|
@param[in] SystemTable The system table.
|
|
|
|
|
|
|
|
@retval EFI_ALREADY_STARTED The driver already exists in system.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of resources.
|
2019-10-09 09:20:15 +02:00
|
|
|
@retval EFI_SUCCESS All the related protocols are installed on the driver.
|
2011-09-02 09:49:32 +02:00
|
|
|
@retval Others Fail to install protocols as indicated.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
TcgConfigDriverEntryPoint (
|
2021-12-05 23:54:12 +01:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
2011-09-02 09:49:32 +02:00
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:12 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
TCG_CONFIG_PRIVATE_DATA *PrivateData;
|
|
|
|
EFI_TCG_PROTOCOL *TcgProtocol;
|
2011-09-02 09:49:32 +02:00
|
|
|
|
2021-12-05 23:54:12 +01:00
|
|
|
if (!CompareGuid (PcdGetPtr (PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceTpm12Guid)) {
|
2021-11-17 04:21:36 +01:00
|
|
|
DEBUG ((DEBUG_ERROR, "No TPM12 instance required!\n"));
|
2013-09-18 07:31:18 +02:00
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2016-01-21 20:29:35 +01:00
|
|
|
Status = Tpm12RequestUseTpm ();
|
2011-09-02 09:49:32 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2021-11-17 04:21:36 +01:00
|
|
|
DEBUG ((DEBUG_ERROR, "TPM not detected!\n"));
|
2011-09-02 09:49:32 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2021-12-05 23:54:12 +01:00
|
|
|
Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);
|
2011-09-02 09:49:32 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
TcgProtocol = NULL;
|
|
|
|
}
|
2018-06-27 15:13:09 +02:00
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ImageHandle,
|
2011-09-18 14:25:27 +02:00
|
|
|
&gEfiCallerIdGuid,
|
2011-09-02 09:49:32 +02:00
|
|
|
NULL,
|
|
|
|
ImageHandle,
|
|
|
|
ImageHandle,
|
|
|
|
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
return EFI_ALREADY_STARTED;
|
|
|
|
}
|
2018-06-27 15:13:09 +02:00
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
//
|
|
|
|
// Create a private data structure.
|
|
|
|
//
|
|
|
|
PrivateData = AllocateCopyPool (sizeof (TCG_CONFIG_PRIVATE_DATA), &mTcgConfigPrivateDateTemplate);
|
|
|
|
if (PrivateData == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2016-02-22 06:51:53 +01:00
|
|
|
|
|
|
|
PrivateData->Configuration = AllocatePool (sizeof (TCG_CONFIGURATION));
|
|
|
|
if (PrivateData->Configuration == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto ErrorExit;
|
|
|
|
}
|
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
PrivateData->TcgProtocol = TcgProtocol;
|
2016-02-22 06:51:53 +01:00
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
//
|
|
|
|
// Install TCG configuration form
|
|
|
|
//
|
|
|
|
Status = InstallTcgConfigForm (PrivateData);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ErrorExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Install private GUID.
|
2018-06-27 15:13:09 +02:00
|
|
|
//
|
2011-09-02 09:49:32 +02:00
|
|
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
|
|
&ImageHandle,
|
2011-09-18 14:25:27 +02:00
|
|
|
&gEfiCallerIdGuid,
|
2011-09-02 09:49:32 +02:00
|
|
|
PrivateData,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto ErrorExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
|
|
|
ErrorExit:
|
|
|
|
if (PrivateData != NULL) {
|
|
|
|
UninstallTcgConfigForm (PrivateData);
|
2018-06-27 15:13:09 +02:00
|
|
|
}
|
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Unload the Tcg configuration form.
|
|
|
|
|
|
|
|
@param[in] ImageHandle The driver's image handle.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Tcg configuration form is unloaded.
|
|
|
|
@retval Others Failed to unload the form.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
TcgConfigDriverUnload (
|
|
|
|
IN EFI_HANDLE ImageHandle
|
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:12 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
TCG_CONFIG_PRIVATE_DATA *PrivateData;
|
2011-09-02 09:49:32 +02:00
|
|
|
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
ImageHandle,
|
2011-09-18 14:25:27 +02:00
|
|
|
&gEfiCallerIdGuid,
|
2021-12-05 23:54:12 +01:00
|
|
|
(VOID **)&PrivateData
|
2018-06-27 15:13:09 +02:00
|
|
|
);
|
2011-09-02 09:49:32 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2018-06-27 15:13:09 +02:00
|
|
|
return Status;
|
2011-09-02 09:49:32 +02:00
|
|
|
}
|
2018-06-27 15:13:09 +02:00
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
ASSERT (PrivateData->Signature == TCG_CONFIG_PRIVATE_DATA_SIGNATURE);
|
|
|
|
|
|
|
|
gBS->UninstallMultipleProtocolInterfaces (
|
2019-09-07 00:50:42 +02:00
|
|
|
ImageHandle,
|
2011-09-18 14:25:27 +02:00
|
|
|
&gEfiCallerIdGuid,
|
2011-09-02 09:49:32 +02:00
|
|
|
PrivateData,
|
|
|
|
NULL
|
|
|
|
);
|
2018-06-27 15:13:09 +02:00
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
UninstallTcgConfigForm (PrivateData);
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|