Note: VFR with Dynamic Refresh

在 EDKII 的 DriverSampleDxe 中可以看到 VFR.vfr中有 下面一個Form3的宣告, 重點的地方用Color標示

form formid = 3, title = STRING_TOKEN(STR_FORM3_TITLE);  // note formid is a variable (for readability) (UINT16) – also added Form to the line to signify the Op-Code

  suppressif  ideqval MyEfiVar == 111;
    text
      help = STRING_TOKEN(STR_TEXT_HELP),
      text = STRING_TOKEN(STR_TEXT_TEXT_1);
  endif;

  goto 1,
    prompt = STRING_TOKEN(STR_GOTO_FORM1), //MainSetupPage
    help   = STRING_TOKEN(STR_GOTO_HELP);

  numeric varid   = MyIfrNVData.DynamicRefresh,
          prompt  = STRING_TOKEN(STR_NUMERIC_MANUAL_PROMPT),
          help    = STRING_TOKEN(STR_NUMERIC_HELP0),
         flags   = INTERACTIVE,
          key     = 0x5678,
          minimum = 0,
          maximum = 0xff,
          step    = 0,
          default = 0,
          refresh interval = 3             // Refresh interval in seconds
  endnumeric;

然後在 DriverSample.c 中可以找到對應的Callback function “DriverCallBack()”, 在Dxe Entry Point“DriverSampleInit()”時, 透過 EFI_HII_CONFIG_ACCESS_PROTOCOL 來建立 CallBack link.

在CallBack 中是透過 EFI_BROWSER_ACTION_CHANGING 通知要 Refersh 了,  如果是原本 EDKII 的code, 會發現畫面一直閃, 原因是它會動態插入 Exit Item, 所以整個Form 會重畫! 只要簡單移除該段插入的code就可以, 如下

    case 0x5678:
      //
      // We will reach here once the Question is refreshed
      //
    #if 0 // By KunYi , remove dynamic add Exit Item
      //
      // Initialize the container for dynamic opcodes
      //
      StartOpCodeHandle = HiiAllocateOpCodeHandle ();
      ASSERT (StartOpCodeHandle != NULL);

      //
      // Create Hii Extend Label OpCode as the start opcode
      //
      StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
      StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
      StartLabel->Number       = LABEL_UPDATE2;

      HiiCreateActionOpCode (
        StartOpCodeHandle,                // Container for dynamic created opcodes
        0x1237,                           // Question ID
        STRING_TOKEN(STR_EXIT_TEXT),      // Prompt text
        STRING_TOKEN(STR_EXIT_TEXT),      // Help text
        EFI_IFR_FLAG_CALLBACK,            // Question flag
        0                                 // Action String ID
      );

      HiiUpdateForm (
        PrivateData->HiiHandle[0],  // HII handle
        &mFormSetGuid,              // Formset GUID
        0x3,                        // Form ID
        StartOpCodeHandle,          // Label for where to insert opcodes
        NULL                        // Insert data
        );

      HiiFreeOpCodeHandle (StartOpCodeHandle);
    #endif
      //
      // Refresh the Question value
      //
      PrivateData->Configuration.DynamicRefresh++;
      Status = gRT->SetVariable(
                      VariableName,
                      &mFormSetGuid,
                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
                      sizeof (DRIVER_SAMPLE_CONFIGURATION),
                      &PrivateData->Configuration
                      );

      //
      // Change an EFI Variable storage (MyEfiVar) asynchronous, this will cause
      // the first statement in Form 3 be suppressed
      //
      MyVarSize = 1;
      MyVar = 111;
      Status = gRT->SetVariable(
                      L"MyVar",
                      &mFormSetGuid,
                      EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
                      MyVarSize,
                      &MyVar
                      );
      break;

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: