/** @file
  VFR file used by the TCG2 configuration component.

Copyright (c) 2015 - 2017, 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 "Tcg2ConfigNvData.h"

formset
  guid      = TCG2_CONFIG_FORM_SET_GUID,
  title     = STRING_TOKEN(STR_TCG2_TITLE),
  help      = STRING_TOKEN(STR_TCG2_HELP),
  classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
  
  efivarstore TCG2_CONFIGURATION_INFO,
    varid = TCG2_CONFIGURATION_INFO_VARSTORE_ID,
    attribute = 0x02,  // EFI variable attribures  EFI_VARIABLE_BOOTSERVICE_ACCESS
    name  = TCG2_CONFIGURATION_INFO,
    guid  = TCG2_CONFIG_FORM_SET_GUID;

  efivarstore TCG2_CONFIGURATION,
    varid = TCG2_CONFIGURATION_VARSTORE_ID,
    attribute = 0x03,  // EFI variable attribures  EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE
    name  = TCG2_CONFIGURATION,
    guid  = TCG2_CONFIG_FORM_SET_GUID;

  form formid = TCG2_CONFIGURATION_FORM_ID,
    title = STRING_TOKEN(STR_TCG2_TITLE);

    subtitle text = STRING_TOKEN(STR_NULL);

    text
      help   = STRING_TOKEN(STR_TCG2_DEVICE_STATE_HELP),
      text   = STRING_TOKEN(STR_TCG2_DEVICE_STATE_PROMPT),
        text   = STRING_TOKEN(STR_TCG2_DEVICE_STATE_CONTENT);

    oneof varid  = TCG2_CONFIGURATION.TpmDevice,
          questionid = KEY_TPM_DEVICE,
          prompt = STRING_TOKEN(STR_TCG2_DEVICE_PROMPT),
          help   = STRING_TOKEN(STR_TCG2_DEVICE_HELP),
          flags  = INTERACTIVE,
            option text = STRING_TOKEN(STR_TCG2_TPM_1_2),          value = TPM_DEVICE_1_2,          flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_TPM_2_0_DTPM),     value = TPM_DEVICE_2_0_DTPM,     flags = RESET_REQUIRED;
    endoneof;

    suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2;

    subtitle text = STRING_TOKEN(STR_NULL);

    text
      help   = STRING_TOKEN(STR_TPM2_ACPI_HID_HELP),
      text   = STRING_TOKEN(STR_TPM2_ACPI_HID_PROMPT),
        text   = STRING_TOKEN(STR_TPM2_ACPI_HID_CONTENT);

    text
      help   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_HELP),
      text   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT),
        text   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT);

    text
      help   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_CAPABILITY_HELP),
      text   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_CAPABILITY_PROMPT),
        text   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_CAPABILITY_CONTENT);

    suppressif ideqval TCG2_CONFIGURATION_INFO.TpmDeviceInterfacePtpFifoSupported == 0
            OR ideqval TCG2_CONFIGURATION_INFO.TpmDeviceInterfacePtpCrbSupported == 0;
    oneof varid  = TCG2_CONFIGURATION_INFO.TpmDeviceInterfaceAttempt,
          questionid = KEY_TPM_DEVICE_INTERFACE,
          prompt = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_PROMPT),
          help   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_HELP),
          flags  = INTERACTIVE,
            option text = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_TIS),          value = TPM_DEVICE_INTERFACE_TIS,          flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_PTP_FIFO),     value = TPM_DEVICE_INTERFACE_PTP_FIFO,     flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_PTP_CRB),      value = TPM_DEVICE_INTERFACE_PTP_CRB,      flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
    endoneof;
    endif;

    endif;

    subtitle text = STRING_TOKEN(STR_NULL);

    suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2;
    text
      help   = STRING_TOKEN(STR_TPM2_ACTIVE_HASH_ALGO_HELP),
      text   = STRING_TOKEN(STR_TPM2_ACTIVE_HASH_ALGO),
        text   = STRING_TOKEN(STR_TPM2_ACTIVE_HASH_ALGO_CONTENT);
    text
      help   = STRING_TOKEN(STR_TPM2_SUPPORTED_HASH_ALGO_HELP),
      text   = STRING_TOKEN(STR_TPM2_SUPPORTED_HASH_ALGO),
        text   = STRING_TOKEN(STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT);
    text
      help   = STRING_TOKEN(STR_BIOS_HASH_ALGO_HELP),
      text   = STRING_TOKEN(STR_BIOS_HASH_ALGO),
        text   = STRING_TOKEN(STR_BIOS_HASH_ALGO_CONTENT);

    subtitle text = STRING_TOKEN(STR_NULL);
    subtitle text = STRING_TOKEN(STR_TCG2_PP_OPERATION);

    oneof name = Tpm2Operation,
          questionid = KEY_TPM2_OPERATION,
          prompt = STRING_TOKEN(STR_TCG2_OPERATION),
          help   = STRING_TOKEN(STR_TCG2_OPERATION_HELP),
          flags  = INTERACTIVE | NUMERIC_SIZE_1,
            option text = STRING_TOKEN(STR_TCG2_NO_ACTION), value = TCG2_PHYSICAL_PRESENCE_NO_ACTION, flags = DEFAULT | MANUFACTURING | RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_ENABLE), value = TCG2_PHYSICAL_PRESENCE_ENABLE, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_DISABLE), value = TCG2_PHYSICAL_PRESENCE_DISABLE, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_CLEAR), value = TCG2_PHYSICAL_PRESENCE_CLEAR, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_SET_PCD_BANKS), value = TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_CHANGE_EPS), value = TCG2_PHYSICAL_PRESENCE_CHANGE_EPS, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_LOG_ALL_DIGESTS), value = TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS, flags = RESET_REQUIRED;
            option text = STRING_TOKEN(STR_TCG2_DISABLE_ENDORSEMENT_ENABLE_STORAGE_HIERARCHY), value = TCG2_PHYSICAL_PRESENCE_DISABLE_ENDORSEMENT_ENABLE_STORAGE_HIERARCHY, flags = RESET_REQUIRED;
    endoneof;
    
    suppressif NOT questionref(Tpm2Operation) == TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS;
    numeric name = Tpm2OperationParameter,
            questionid = KEY_TPM2_OPERATION_PARAMETER,
            prompt  = STRING_TOKEN(STR_TCG2_OPERATION_PARAMETER),
            help    = STRING_TOKEN(STR_TCG2_OPERATION_PARAMETER_HELP),
            flags   = DISPLAY_UINT_HEX | INTERACTIVE | NUMERIC_SIZE_4,
            minimum = 0,
            maximum = 0xFFFFFFFF,
            step    = 0,
            default = 0,
    endnumeric;
    endif;

    subtitle text = STRING_TOKEN(STR_NULL);
    subtitle text = STRING_TOKEN(STR_TCG2_CONFIGURATION);

    text
      help   = STRING_TOKEN(STR_TCG2_SUPPORTED_EVENT_LOG_FORMAT_HELP),
      text   = STRING_TOKEN(STR_TCG2_SUPPORTED_EVENT_LOG_FORMAT),
        text   = STRING_TOKEN(STR_TCG2_SUPPORTED_EVENT_LOG_FORMAT_CONTENT);

    text
      help   = STRING_TOKEN(STR_TCG2_HASH_ALGO_BITMAP_HELP),
      text   = STRING_TOKEN(STR_TCG2_HASH_ALGO_BITMAP),
        text   = STRING_TOKEN(STR_TCG2_HASH_ALGO_BITMAP_CONTENT);

    text
      help   = STRING_TOKEN(STR_TCG2_NUMBER_OF_PCR_BANKS_HELP),
      text   = STRING_TOKEN(STR_TCG2_NUMBER_OF_PCR_BANKS),
        text   = STRING_TOKEN(STR_TCG2_NUMBER_OF_PCR_BANKS_CONTENT);

    text
      help   = STRING_TOKEN(STR_TCG2_ACTIVE_PCR_BANKS_HELP),
      text   = STRING_TOKEN(STR_TCG2_ACTIVE_PCR_BANKS),
        text   = STRING_TOKEN(STR_TCG2_ACTIVE_PCR_BANKS_CONTENT);

    subtitle text = STRING_TOKEN(STR_NULL);

  suppressif ideqval TCG2_CONFIGURATION_INFO.Sha1Supported == 0;
    checkbox name = TCG2ActivatePCRBank0,
            questionid = KEY_TPM2_PCR_BANKS_REQUEST_0,
            prompt     = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA1),
            help       = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA1_HELP),
            flags      = INTERACTIVE | RESET_REQUIRED,
            default    = 1,
    endcheckbox;
  endif;

  suppressif ideqval TCG2_CONFIGURATION_INFO.Sha256Supported == 0;
    checkbox name = TCG2ActivatePCRBank1,
            questionid = KEY_TPM2_PCR_BANKS_REQUEST_1,
            prompt     = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA256),
            help       = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA256_HELP),
            flags      = INTERACTIVE | RESET_REQUIRED,
            default    = 0,
    endcheckbox;
  endif;

  suppressif ideqval TCG2_CONFIGURATION_INFO.Sha384Supported == 0;
    checkbox name = TCG2ActivatePCRBank2,
            questionid = KEY_TPM2_PCR_BANKS_REQUEST_2,
            prompt     = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA384),
            help       = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA384_HELP),
            flags      = INTERACTIVE | RESET_REQUIRED,
            default    = 0,
    endcheckbox;
  endif;

  suppressif ideqval TCG2_CONFIGURATION_INFO.Sha512Supported == 0;
    checkbox name = TCG2ActivatePCRBank3,
            questionid = KEY_TPM2_PCR_BANKS_REQUEST_3,
            prompt     = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA512),
            help       = STRING_TOKEN(STR_TCG2_PCR_BANK_SHA512_HELP),
            flags      = INTERACTIVE | RESET_REQUIRED,
            default    = 0,
    endcheckbox;
  endif;

  suppressif ideqval TCG2_CONFIGURATION_INFO.Sm3Supported == 0;
    checkbox name = TCG2ActivatePCRBank4,
            questionid = KEY_TPM2_PCR_BANKS_REQUEST_4,
            prompt     = STRING_TOKEN(STR_TCG2_PCR_BANK_SM3_256),
            help       = STRING_TOKEN(STR_TCG2_PCR_BANK_SM3_256_HELP),
            flags      = INTERACTIVE | RESET_REQUIRED,
            default    = 0,
    endcheckbox;
  endif;

    endif;

  endform;

endformset;