搜尋此網誌

顯示具有 EFI/UEFI Hii(Human Interface Infrstructure) 標籤的文章。 顯示所有文章
顯示具有 EFI/UEFI Hii(Human Interface Infrstructure) 標籤的文章。 顯示所有文章

2016年8月5日 星期五

Create a Pop Up box in Hii(Human Interface Infrstructure)

u16 i;
EFI_INPUT_KEY                   Key;
DEBUG_PRINT (("Key scan.........\n"));
do {
    CreatePopUp (
        EFI_LIGHTGRAY | EFI_BACKGROUND_RED,
        &Key,
        L"",
        L"Would you like to create this virtual disk?",
        L"         [Yes]               [No]         ",
        L"",
        NULL
    );
    DEBUG_PRINT (("Unicode=0x%x, ScanCode=0x%x <%c>\n", Key.UnicodeChar, Key.ScanCode, Key.UnicodeChar));
} while ((Key.ScanCode != SCAN_ESC) && (Key.UnicodeChar != CHAR_CARRIAGE_RETURN));

Print Messages:
Unicode=0x79, ScanCode=0x0
Unicode=0x59, ScanCode=0x0
Unicode=0x6E, ScanCode=0x0
Unicode=0x4E, ScanCode=0x0

ScanCode=0x0(SCAN_NULL)

//
// EFI Console Colours
//
#define EFI_BLACK                 0x00
#define EFI_BLUE                  0x01
#define EFI_GREEN                 0x02
#define EFI_CYAN                  (EFI_BLUE | EFI_GREEN)
#define EFI_RED                   0x04
#define EFI_MAGENTA               (EFI_BLUE | EFI_RED)
#define EFI_BROWN                 (EFI_GREEN | EFI_RED)
#define EFI_LIGHTGRAY             (EFI_BLUE | EFI_GREEN | EFI_RED)
#define EFI_BRIGHT                0x08
#define EFI_DARKGRAY              (EFI_BRIGHT)
#define EFI_LIGHTBLUE             (EFI_BLUE | EFI_BRIGHT)
#define EFI_LIGHTGREEN            (EFI_GREEN | EFI_BRIGHT)
#define EFI_LIGHTCYAN             (EFI_CYAN | EFI_BRIGHT)
#define EFI_LIGHTRED              (EFI_RED | EFI_BRIGHT)
#define EFI_LIGHTMAGENTA          (EFI_MAGENTA | EFI_BRIGHT)
#define EFI_YELLOW                (EFI_BROWN | EFI_BRIGHT)
#define EFI_WHITE                 (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)

#define EFI_TEXT_ATTR(f, b)       ((f) | ((b) << 4))

#define EFI_BACKGROUND_BLACK      0x00
#define EFI_BACKGROUND_BLUE       0x10
#define EFI_BACKGROUND_GREEN      0x20
#define EFI_BACKGROUND_CYAN       (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
#define EFI_BACKGROUND_RED        0x40
#define EFI_BACKGROUND_MAGENTA    (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_BROWN      (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
#define EFI_BACKGROUND_LIGHTGRAY  (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)

//
// EFI Scan codes
//
#define SCAN_NULL       0x0000
#define SCAN_UP         0x0001
#define SCAN_DOWN       0x0002
#define SCAN_RIGHT      0x0003
#define SCAN_LEFT       0x0004
#define SCAN_HOME       0x0005
#define SCAN_END        0x0006
#define SCAN_INSERT     0x0007
#define SCAN_DELETE     0x0008
#define SCAN_PAGE_UP    0x0009
#define SCAN_PAGE_DOWN  0x000A
#define SCAN_F1         0x000B
#define SCAN_F2         0x000C
#define SCAN_F3         0x000D
#define SCAN_F4         0x000E
#define SCAN_F5         0x000F
#define SCAN_F6         0x0010
#define SCAN_F7         0x0011
#define SCAN_F8         0x0012
#define SCAN_F9         0x0013
#define SCAN_F10        0x0014
#define SCAN_F11        0x0015
#define SCAN_F12        0x0016

#define SCAN_ESC        0x0017

2012年10月15日 星期一

The definitions is about Hii DriverCallback() function

The description of Hii DriverCallback() is for EDK II.


typedef UINTN EFI_BROWSER_ACTION;

#define EFI_BROWSER_ACTION_CHANGING   0
#define EFI_BROWSER_ACTION_CHANGED    1
#define EFI_BROWSER_ACTION_RETRIEVE   2
#define EFI_BROWSER_ACTION_FORM_OPEN  3
#define EFI_BROWSER_ACTION_FORM_CLOSE 4
#define EFI_BROWSER_ACTION_DEFAULT_STANDARD      0x1000
#define EFI_BROWSER_ACTION_DEFAULT_MANUFACTURING 0x1001
#define EFI_BROWSER_ACTION_DEFAULT_SAFE          0x1002
#define EFI_BROWSER_ACTION_DEFAULT_PLATFORM      0x2000
#define EFI_BROWSER_ACTION_DEFAULT_HARDWARE      0x3000
#define EFI_BROWSER_ACTION_DEFAULT_FIRMWARE      0x4000

//
// Types of the option's value.
//
#define EFI_IFR_TYPE_NUM_SIZE_8        0x00
#define EFI_IFR_TYPE_NUM_SIZE_16       0x01
#define EFI_IFR_TYPE_NUM_SIZE_32       0x02
#define EFI_IFR_TYPE_NUM_SIZE_64       0x03
#define EFI_IFR_TYPE_BOOLEAN           0x04
#define EFI_IFR_TYPE_TIME              0x05
#define EFI_IFR_TYPE_DATE              0x06
#define EFI_IFR_TYPE_STRING            0x07
#define EFI_IFR_TYPE_OTHER             0x08
#define EFI_IFR_TYPE_UNDEFINED         0x09
#define EFI_IFR_TYPE_ACTION            0x0A
#define EFI_IFR_TYPE_BUFFER            0x0B
#define EFI_IFR_TYPE_REF               0x0C

#define EFI_IFR_OPTION_DEFAULT         0x10
#define EFI_IFR_OPTION_DEFAULT_MFG     0x20


typedef struct {
  UINT8 Hour;
  UINT8 Minute;
  UINT8 Second;
} EFI_HII_TIME;

typedef struct {
  UINT16 Year;
  UINT8  Month;
  UINT8  Day;
} EFI_HII_DATE;

typedef union {
  UINT8           u8;
  UINT16          u16;
  UINT32          u32;
  UINT64          u64;
  BOOLEAN         b;
  EFI_HII_TIME    time;
  EFI_HII_DATE    date;
  EFI_STRING_ID   string;
} EFI_IFR_TYPE_VALUE;

// The operand (first byte) of this Statement or Question
#define EFI_IFR_FORM_OP                0x01
#define EFI_IFR_SUBTITLE_OP            0x02
#define EFI_IFR_TEXT_OP                0x03
#define EFI_IFR_IMAGE_OP               0x04
#define EFI_IFR_ONE_OF_OP              0x05
#define EFI_IFR_CHECKBOX_OP            0x06
#define EFI_IFR_NUMERIC_OP             0x07
#define EFI_IFR_PASSWORD_OP            0x08
#define EFI_IFR_ONE_OF_OPTION_OP       0x09
#define EFI_IFR_SUPPRESS_IF_OP         0x0A
#define EFI_IFR_LOCKED_OP              0x0B
#define EFI_IFR_ACTION_OP              0x0C
#define EFI_IFR_RESET_BUTTON_OP        0x0D
#define EFI_IFR_FORM_SET_OP            0x0E
#define EFI_IFR_REF_OP                 0x0F
#define EFI_IFR_NO_SUBMIT_IF_OP        0x10
#define EFI_IFR_INCONSISTENT_IF_OP     0x11
#define EFI_IFR_EQ_ID_VAL_OP           0x12
#define EFI_IFR_EQ_ID_ID_OP            0x13
#define EFI_IFR_EQ_ID_LIST_OP          0x14
#define EFI_IFR_AND_OP                 0x15
#define EFI_IFR_OR_OP                  0x16
#define EFI_IFR_NOT_OP                 0x17
#define EFI_IFR_RULE_OP                0x18
#define EFI_IFR_GRAY_OUT_IF_OP         0x19
#define EFI_IFR_DATE_OP                0x1A
#define EFI_IFR_TIME_OP                0x1B
#define EFI_IFR_STRING_OP              0x1C
#define EFI_IFR_REFRESH_OP             0x1D
#define EFI_IFR_DISABLE_IF_OP          0x1E
#define EFI_IFR_TO_LOWER_OP            0x20
#define EFI_IFR_TO_UPPER_OP            0x21
#define EFI_IFR_ORDERED_LIST_OP        0x23
#define EFI_IFR_VARSTORE_OP            0x24
#define EFI_IFR_VARSTORE_NAME_VALUE_OP 0x25
#define EFI_IFR_VARSTORE_EFI_OP        0x26
#define EFI_IFR_VARSTORE_DEVICE_OP     0x27
#define EFI_IFR_VERSION_OP             0x28
#define EFI_IFR_END_OP                 0x29
#define EFI_IFR_MATCH_OP               0x2A
#define EFI_IFR_EQUAL_OP               0x2F
#define EFI_IFR_NOT_EQUAL_OP           0x30
#define EFI_IFR_GREATER_THAN_OP        0x31
#define EFI_IFR_GREATER_EQUAL_OP       0x32
#define EFI_IFR_LESS_THAN_OP           0x33
#define EFI_IFR_LESS_EQUAL_OP          0x34
#define EFI_IFR_BITWISE_AND_OP         0x35
#define EFI_IFR_BITWISE_OR_OP          0x36
#define EFI_IFR_BITWISE_NOT_OP         0x37
#define EFI_IFR_SHIFT_LEFT_OP          0x38
#define EFI_IFR_SHIFT_RIGHT_OP         0x39
#define EFI_IFR_ADD_OP                 0x3A
#define EFI_IFR_SUBTRACT_OP            0x3B
#define EFI_IFR_MULTIPLY_OP            0x3C
#define EFI_IFR_DIVIDE_OP              0x3D
#define EFI_IFR_MODULO_OP              0x3E
#define EFI_IFR_RULE_REF_OP            0x3F
#define EFI_IFR_QUESTION_REF1_OP       0x40
#define EFI_IFR_QUESTION_REF2_OP       0x41
#define EFI_IFR_UINT8_OP               0x42
#define EFI_IFR_UINT16_OP              0x43
#define EFI_IFR_UINT32_OP              0x44
#define EFI_IFR_UINT64_OP              0x45
#define EFI_IFR_TRUE_OP                0x46
#define EFI_IFR_FALSE_OP               0x47
#define EFI_IFR_TO_UINT_OP             0x48
#define EFI_IFR_TO_STRING_OP           0x49
#define EFI_IFR_TO_BOOLEAN_OP          0x4A
#define EFI_IFR_MID_OP                 0x4B
#define EFI_IFR_FIND_OP                0x4C
#define EFI_IFR_TOKEN_OP               0x4D
#define EFI_IFR_STRING_REF1_OP         0x4E
#define EFI_IFR_STRING_REF2_OP         0x4F
#define EFI_IFR_CONDITIONAL_OP         0x50
#define EFI_IFR_QUESTION_REF3_OP       0x51
#define EFI_IFR_ZERO_OP                0x52
#define EFI_IFR_ONE_OP                 0x53
#define EFI_IFR_ONES_OP                0x54
#define EFI_IFR_UNDEFINED_OP           0x55
#define EFI_IFR_LENGTH_OP              0x56
#define EFI_IFR_DUP_OP                 0x57
#define EFI_IFR_THIS_OP                0x58
#define EFI_IFR_SPAN_OP                0x59
#define EFI_IFR_VALUE_OP               0x5A
#define EFI_IFR_DEFAULT_OP             0x5B
#define EFI_IFR_DEFAULTSTORE_OP        0x5C
#define EFI_IFR_CATENATE_OP            0x5E
#define EFI_IFR_GUID_OP                0x5F

typedef struct _EFI_IFR_OP_HEADER {
  UINT8                    OpCode;
  UINT8                    Length:7;
  UINT8                    Scope:1;
} EFI_IFR_OP_HEADER;

2012年8月22日 星期三

Visual Forms Representation(VFR) - checkbox


[checkbox]
布林值的詢問,這些允許抉擇真(1)或假(0)。
這詢問值是布林代數。一般而言,為了構成詢問以致於提示文字要求得到在‘yes/enabled/on’為‘true’與‘no/disabled/off’為‘false’。
布林值的詢問可能被顯示如同一個"Check box"、無線按鈕、選擇表、選單、下拉選單。

語法:
checkbox
    [ name = identifier , ]
    [ varid = storage-id , ]
    [ questionid = uint , ]
    prompt = string ,
    help = string ,
    [ flags = check-box-flags , ]
    [ key = uint , ]
 question-option-list
endcheckbox ;
checkbox-flags := checkbox-flags | checkbox-flag |
                  checkbox-flag |
                 
checkbox-flag  := uint8 |
                  CHECKBOX_DEFAULT |
                  CHECKBOX_DEFAULT_MFG |
                  READ_ONLY |
                  INTERACTIVE |
                  OPTIONS_ONLY |
                  RESET_REQUIRED

屬性:
questionid:此唯一值得識別碼在這個系統上。在表單排版範圍內。這詢問識別符號,在裝置路徑以外與排版識別符號唯一識別的分析在系統範圍內。此預設值為0。
prompt:詢問提示字串。
help: 顯示輔助操作字串。
flag:零或更多關鍵字、整數區隔藉由'|'符號。後面緊接著關鍵字描述:
CHECKBOX_DEFAULT:是否被標明,這標準定義是'TRUE'對於'Check Box'.否則它將會是'FALSE'。如果這裡有一套疊項目(option)或定義(default)它是標準定義值對於'Check Box'的詢問,此外此flag是被忽略。
CHECKBOX_DEFAULT_MFG:是否被標明,這製造商的定義是'TRUE'對於'Check Box'.否則它將會是'FALSE'。如果這裡有一套疊項目(option)或定義(default)它是製造商的定義值對於'Check Box'的詢問,此外此flag是被忽略。
READ_ONLY: 唯讀,此值將不能被改變與選擇。
INTERACTIVE: 關聯的函式程式,將被呼叫。
OPTIONS_ONLY: 只有此值明確說明經由相互套疊選項操作能被使用者選擇。
RESET_REQUIRED: 一個系統重置被依照次序要求去改變,當這詢問值生效。

描述:
建立一個布林checkbox的詢問與增加它到當前的表單。此checkbox有兩個值:FALSE當這個匣沒被查核與TRUE是有。
這裡有三個方法明確說明定義對於詢問:在Flags區(最低優先權),一個或多個疊項目(option)運算元或一個疊定義(default)運算元(最高優先權)。
一個圖像可能被關聯與一個詢問使用一個疊圖像運算。
這運算式符合IFR EFI_IFR_CHECKBOX。

2012年8月16日 星期四

Visual Forms Representation(VFR) - AND/OR/NOT

[and]


[or]

[not]
反相

範例:
suppressif NOT ideqval NVData.DeviceEn_0 == 0x1
    AND NOT ideqval NVData.DeviceEn_1 == 0x1
    AND NOT ideqval NVData.DeviceEn_2 == 0x1
    OR ideqval NVData.SupportDevChoice == 0x0
    OR ideqval NVData.DeviceTypeInput == 0x5;
        oneof varid  = NVData.Conf,                

                prompt      =    STRING_TOKEN(MV_STR_OPTION_TEST_STR),
                help        = STRING_TOKEN(MV_STR_DEVICE_TYPE_SLECT_HELP),
                option text = STRING_TOKEN(MV_STR_OPTION_NO_STRING), value = 0x1001, flags = DEFAULT | INTERACTIVE;
                option text = STRING_TOKEN(MV_STR_OPTION_YES_STRING), value =
0x1002, flags = INTERACTIVE;
            endoneof;

endif;

Visual Forms Representation(VFR) - catenate

[catenate]
語法:

catenate ( expression0 , expression1 )

參數:
expression0, expression1 字串或緩衝區表示。

描述:
  • 如果第一與第二表示不能被鑑定如同一串字串或一個緩衝區,回傳未下定義。
  • 如果第一與第二表示是屬於不同型態,回傳未下定義。
  • 如果第一與第二表示是字串,回傳一串新字串,它包含第一串字串內容(沒有NULL終止符號)接在第二串字串內容。
  • 如果第一與第二表示是緩衝區,回傳一個新緩衝區,它包含第一個緩衝區內容接在第二個緩衝區內容。
這運算式符合EFI_IFR_CATENATE。

Visual Forms Representation(VFR) - banner

[banner]
語法:
banner
   title = string , line uint16 , align align-flags ;
   title = string , timeout = uint16 ;

align-flags := left | center | right

描述:
此運算式不符合任何IFR運算和被Forms Browser忽略。

範例:
banner
  title = STRING_TOKEN(STR_BANNER_TEXT),
  line 1,
  align left;

banner
  timeout = 100;

Visual Forms Representation(VFR) - boolval

[boolval]
轉換無號整數、字串或緩衝區表示成一個布林值。

語法:
boolval ( expression )

參數:
expression     表示轉換

描述:
此運算式轉換(expression)到一個布林值。如果(expression)鑑定為未定義,然後它將回傳未下定義。
  • 如果轉換從一個無號整數表示,零將被轉換為FALSE與任何其他值將被轉換成TRUE。
  • 如果轉換從一個字串,如果此字串(沒有大小寫之分)是"true",然後回傳TRUE。如果此字串(沒有大小寫之分)是"false",然後回傳FALSE。否則它將回傳未下定義。
  • 如果轉換從一個緩衝區,如果此緩衝區是全為零,將回傳是FALSE,否則將回傳是TRUE。
  • 如果轉換從任何其他資料型態,將回傳未下定義。

這運算式符合IFR EFI_IFR_TO_BOOLEAN。

Visual Forms Representation(VFR) - bitwisenot

[bitwisenot]
Bitwise NOT (~)運算元屬於一個無號整數符號。

語法:
bitwisenot ( expression )

參數:
expression     表示求一個無號整數的數值。

描述:
此運算元執行一個bitwise NOT屬於一個無號整數符號。
如果此符號不能被鑑定當作一個無號整數,回傳未下定義,否則,將零延伸至64-bits無號整數,bitwise-NOT它與回傳它。
這運算式符合IFR EFI_IFR_BITWISE_NOT。

2012年8月14日 星期二

Visual Forms Representation(VFR) - action


[action]
[Action Button]是按鈕,它會造成一個預先定義配置字串立即去處理。這按鈕沒有儲存直接的關聯。

語法:
action
   [ name = identifier , ]
   [ questionid = uint , ]
   prompt = STRING_TOKEN(string) ,
   help = STRING_TOKEN(string),
   [ flags = action-flags , ]
   config = STRING_TOKEN(string),
   question-tag-list
endaction ;

參數:
action-flag = READ_ONLY |
                INTERACTIVE |
                OPTIONS_ONLY |
                RESET_REQUIRED

questionid:一個無號16-bit整數,唯一識別碼在此系統上。
prompt:詢問提示字串。
help: 顯示輔助操作字串。

READ_ONLY: 唯讀,此值將不能被改變與選擇。
INTERACTIVE: 關聯的函式程式,將被呼叫。
OPTIONS_ONLY: 只有此值明確說明經由相互套疊選項操作能被使用者選擇。
RESET_REQUIRED: 一個系統重置被依照次序要求去改變,當這詢問值生效。

描述:
操作建立一個作用詢問。當這個詢問被選擇,它的配置字串將被處理,相關訊息經由config詳細指明。如果config沒有指示任何訊息,當沒有配置字串,那就不會有任何處理。
這是有效的當只使用[action button]作為回訪使用。

如果這個詢問被標記成read-only,他將不能被選擇。
這運算式符合IFR EFI_IFR_ACTION。


範例:
action 
  prompt = STRING_TOKEN(STR_ACTION_TEXT), 
  help = STRING_TOKEN(STR_ACTION_HELP), 
  flags = INTERACTIVE
 config = STRING_TOKEN(STR_ACTION_CONFIG), 
endaction;

2012年8月7日 星期二

Visual Forms Representation(VFR) commands Table


You could refer to: Visual Forms Representation File Format
/*
 * EfiVfrParser: P a r s e r  S u p p o r t
 *
 * Generated from: C:\Edk\Sample\Tools\Source\UefiVfrCompile\VfrSyntax.g
 */
const ANTLRChar *EfiVfrParser::tokenName(int tok)   { return _token_tbl[tok]; }

const ANTLRChar *EfiVfrParser::_token_tbl[]={
/* 00 */ "Invalid",
/* 01 */ "@",
/* 02 */ "TheString",
/* 03 */ "~[\\n]*",
/* 04 */ "\\n",
/* 05 */ "//",
/* 06 */ "[\\ \\t]",
/* 07 */ "\\n",
/* 08 */ "extern",
/* 09 */ "formpkgtype",
/* 10 */ "{",
/* 11 */ "}",
/* 12 */ "(",
/* 13 */ ")",
/* 14 */ "[",
/* 15 */ "]",
/* 16 */ "LineDefinition",
/* 17 */ "devicepath",
/* 18 */ "formset",
/* 19 */ "formsetid",
/* 20 */ "endformset",
/* 21 */ "title",
/* 22 */ "formid",
/* 23 */ "oneof",
/* 24 */ "endoneof",
/* 25 */ "prompt",
/* 26 */ "orderedlist",
/* 27 */ "maxcontainers",
/* 28 */ "endlist",
/* 29 */ "endform",
/* 30 */ "form",
/* 31 */ "subtitle",
/* 32 */ "help",
/* 33 */ "text",
/* 34 */ "option",
/* 35 */ "flags",
/* 36 */ "date",
/* 37 */ "enddate",
/* 38 */ "year",
/* 39 */ "month",
/* 40 */ "day",
/* 41 */ "time",
/* 42 */ "endtime",
/* 43 */ "hour",
/* 44 */ "minute",
/* 45 */ "second",
/* 46 */ "grayoutif",
/* 47 */ "label",
/* 48 */ "timeout",
/* 49 */ "inventory",
/* 50 */ "_NON_NV_DATA_MAP",
/* 51 */ "struct",
/* 52 */ "BOOLEAN",
/* 53 */ "UINT64",
/* 54 */ "UINT32",
/* 55 */ "UINT16",
/* 56 */ "CHAR16",
/* 57 */ "UINT8",
/* 58 */ "guid",
/* 59 */ "checkbox",
/* 60 */ "endcheckbox",
/* 61 */ "numeric",
/* 62 */ "endnumeric",
/* 63 */ "minimum",
/* 64 */ "maximum",
/* 65 */ "step",
/* 66 */ "default",
/* 67 */ "password",
/* 68 */ "endpassword",
/* 69 */ "string",
/* 70 */ "endstring",
/* 71 */ "minsize",
/* 72 */ "maxsize",
/* 73 */ "encoding",
/* 74 */ "suppressif",
/* 75 */ "disableif",
/* 76 */ "hidden",
/* 77 */ "goto",
/* 78 */ "formsetguid",
/* 79 */ "inconsistentif",
/* 80 */ "nosubmitif",
/* 81 */ "endif",
/* 82 */ "key",
/* 83 */ "DEFAULT",
/* 84 */ "MANUFACTURING",
/* 85 */ "INTERACTIVE", /*The callback associated with this form will be called.*/
/* 86 */ "NV_ACCESS",
/* 87 */ "RESET_REQUIRED", /*A system reset is required in order for changes in this question's value to take effect.*/
/* 88 */ "LATE_CHECK",
/* 89 */ "READ_ONLY", /*The question is read-only. The value cannot be changed and cannot be selected.*/
/* 90 */ "OPTIONS_ONLY", /*Only the values specified by nested option operators can be selected by the user.*/
/* 91 */ "class",
/* 92 */ "subclass",
/* 93 */ "classguid",
/* 94 */ "typedef",
/* 95 */ "restore",
/* 96 */ "save",
/* 97 */ "defaults",
/* 98 */ "banner",
/* 99 */ "align",
/* 100 */ "left",
/* 101 */ "right",
/* 102 */ "center",
/* 103 */ "line",
/* 104 */ "name",
/* 105 */ "varid",
/* 106 */ "question",
/* 107 */ "questionid",
/* 108 */ "image",
/* 109 */ "locked",
/* 110 */ "rule",
/* 111 */ "endrule",
/* 112 */ "value",
/* 113 */ "resetbutton",
/* 114 */ "endresetbutton",
/* 115 */ "defaultstore",
/* 116 */ "attribute",
/* 117 */ "varstore",
/* 118 */ "efivarstore",
/* 119 */ "varsize",
/* 120 */ "namevaluevarstore",
/* 121 */ "action",
/* 122 */ "config",
/* 123 */ "endaction",
/* 124 */ "refresh",
/* 125 */ "interval",
/* 126 */ "varstoredevice",
/* 127 */ "NONDEVICE",
/* 128 */ "DISK_DEVICE",
/* 129 */ "VIDEO_DEVICE",
/* 130 */ "NETWORK_DEVICE",
/* 131 */ "INPUT_DEVICE",
/* 132 */ "ONBOARD_DEVICE",
/* 133 */ "OTHER_DEVICE",
/* 134 */ "SETUP_APPLICATION",
/* 135 */ "GENERAL_APPLICATION",
/* 136 */ "FRONT_PAGE",
/* 137 */ "SINGLE_USE",
/* 138 */ "show",
/* 139 */ "push",
/* 140 */ "pop",
/* 141 */ ",",
/* 142 */ "string identifier",
/* 143 */ "numeric value",
/* 144 */ "\\#pragma",
/* 145 */ "pack",
/* 146 */ ";",
/* 147 */ "EFI_STRING_ID",
/* 148 */ "EFI_HII_DATE",
/* 149 */ "EFI_HII_TIME",
/* 150 */ "=",
/* 151 */ "STRING_TOKEN",
/* 152 */ "\\|",
/* 153 */ ".",
/* 154 */ "TRUE",
/* 155 */ "FALSE",
/* 156 */ "ONE",
/* 157 */ "ONES",
/* 158 */ "ZERO",
/* 159 */ ":",
/* 160 */ "/",
/* 161 */ "HORIZONTAL",
/* 162 */ "CHECKBOX_DEFAULT",
/* 163 */ "CHECKBOX_DEFAULT_MFG",
/* 164 */ "YEAR_SUPPRESS",
/* 165 */ "MONTH_SUPPRESS",
/* 166 */ "DAY_SUPPRESS",
/* 167 */ "STORAGE_NORMAL",
/* 168 */ "STORAGE_TIME",
/* 169 */ "STORAGE_WAKEUP",
/* 170 */ "NUMERIC_SIZE_1",
/* 171 */ "NUMERIC_SIZE_2",
/* 172 */ "NUMERIC_SIZE_4",
/* 173 */ "NUMERIC_SIZE_8",
/* 174 */ "DISPLAY_INT_DEC",
/* 175 */ "DISPLAY_UINT_DEC",
/* 176 */ "DISPLAY_UINT_HEX",
/* 177 */ "MULTI_LINE",
/* 178 */ "UNIQUE",
/* 179 */ "NOEMPTY",
/* 180 */ "HOUR_SUPPRESS",
/* 181 */ "MINUTE_SUPPRESS",
/* 182 */ "SECOND_SUPPRESS",
/* 183 */ "IMAGE_TOKEN",
/* 184 */ "OPTION_DEFAULT",
/* 185 */ "OPTION_DEFAULT_MFG",
/* 186 */ "dup",
/* 187 */ "vareqval",
/* 188 */ "var",
/* 189 */ "ideqval",
/* 190 */ "ideqid",
/* 191 */ "ideqvallist",
/* 192 */ "questionref",
/* 193 */ "ruleref",
/* 194 */ "stringref",
/* 195 */ "pushthis",
/* 196 */ "UNDEFINED",
/* 197 */ "VERSOPM",
/* 198 */ "length",
/* 199 */ "AND",
/* 200 */ "OR",
/* 201 */ "NOT",
/* 202 */ "~",
/* 203 */ "boolval",
/* 204 */ "stringval",
/* 205 */ "unintval",
/* 206 */ "toupper",
/* 207 */ "tolower",
/* 208 */ "match",
/* 209 */ "catenate",
/* 210 */ "questionrefval",
/* 211 */ "stringrefval",
/* 212 */ "&",
/* 213 */ "==",
/* 214 */ "!=",
/* 215 */ "<",
/* 216 */ "<=",
/* 217 */ ">",
/* 218 */ ">=",
/* 219 */ "\\<<",
/* 220 */ "\\>>",
/* 221 */ "\\+",
/* 222 */ "\\-",
/* 223 */ "\\*",
/* 224 */ "%",
/* 225 */ "Path",
/* 226 */ "Format",
/* 227 */ "cond",
/* 228 */ "find",
/* 229 */ "mid",
/* 230 */ "token",
/* 231 */ "span",
/* 232 */ "?",
/* 233 */ "SENSITIVE",
/* 234 */ "INSENSITIVE",
/* 235 */ "LAST_NON_MATCH",
/* 236 */ "FIRST_NON_MATCH"
};


/*The source code is from EFI Dev Kit(EDk).*/


(EFI_STRING Request)Append OFFSET/WIDTH/VALUE items at the beginning of string.


/*The source code is from EFI Dev Kit(EDk).*/
/*It will append a request string with string. and its layout as below:*/


Word(2bytes)
Length
Description
0
8 Words(16 Bytes)
“&OFFSET=”
8
L1 Words(L1 x 2 Bytes)
Offset Length
8 + L1
7 Words(14 Bytes)
“&WIDTH=”
15 + L1
L2 Words(L2 x 2 Bytes)
Width Length
15 + L1 + L2
7 Words(14 Bytes)
“&VALUE=”
22 + L1 + L2
L3 Words(L2 x 3 Bytes)
Value Length


UINTN
AppendOffsetWidthValue (
  IN OUT CHAR16               *String,
  IN UINTN                    Offset,
  IN UINTN                    Width,
  IN UINT8                    *Block
  )
/*++
Routine Description:
  Append OFFSET/WIDTH/VALUE items at the beginning of string.

Arguments:
  String -         Point to the position should be appended.
  Offset -         Offset value.
  Width  -         Width value.
  Block  -         Point to data buffer.

Returns:
  The count of unicode character was appended.
--*/
{
  CHAR16                      *OriString;

  OriString = String;

  StrCpy (String, L"&OFFSET=");
  String += StrLen (L"&OFFSET=");
  String += SPrint (String, 0, L"%x", Offset);

  StrCpy (String,L"&WIDTH=");
  String += StrLen (L"&WIDTH=");
  String += SPrint (String, 0, L"%x", Width);

  if (Block != NULL) {
    StrCpy (String,L"&VALUE=");
    String += StrLen (L"&VALUE=");
    while ((Width--) != 0) {
      String += SPrint (String, 0, L"%x", Block[Width]);
    }
  }

  return String - OriString;
}

(EFI_STRING Request)Construct using routing information GUID/NAME/PATH.


/*The source code is from EFI Dev Kit(EDk).*/
/*It will make a string. and its layout as below:*/

Word(2bytes)
Length
Description
0
5 Words(10 Bytes)
“GUID=”
5
16 Words(32 Bytes)
EFI_GUID
21
6 Words(12 Bytes)
“&NAME=”
27
00 + “??”=2Words x L1(L1 x 4 = 4L1 Bytes)
00??, 00??, 00??.....
27 + 2L1
6 Words(12 Bytes)
“&PATH=”
33 + 2L1
Word(2 bytes) x L2 = 2L2bytes
Device Path Size
(33 + 2L1 + L2)Last Word
1 Words(2 Bytes)
00


CHAR16 *
ConstructConfigHdr (
  IN EFI_GUID                *Guid,
  IN CHAR16                  *Name,
  IN EFI_HANDLE              DriverHandle
  )
/*++

Routine Description:
  Construct using routing information GUID/NAME/PATH.

Arguments:
  Guid          - Routing information: GUID.
  Name          - Routing information: NAME.
  DriverHandle  - Driver handle which contains the routing information: PATH.

Returns:
  NULL  - Fails.
  Other - Pointer to configHdr string.

--*/
{
  EFI_STATUS                 Status;
  CHAR16                     *ConfigHdr;
  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
  CHAR16                     *String;
  CHAR16                     *UpperString;
  UINTN                      Index;
  UINT8                      *Buffer;
  UINTN                      DevicePathLength;
  UINTN                      NameLength;

  //
  // Get the device path from handle installed EFI HII Config Access protocol
  //
  Status = BS->HandleProtocol (
                 DriverHandle,
                 &gEfiDevicePathProtocolGuid,
                 (VOID **) &DevicePath
                 );
  if (EFI_ERROR (Status)) {
    return NULL;
  }

  DevicePathLength = DevicePathSize (DevicePath);
  NameLength = StrLen (Name);
  ConfigHdr = AllocateZeroPool ((5 + sizeof (EFI_GUID) * 2 + 6 + NameLength * 4 + 6 + DevicePathLength * 2 + 1) * sizeof (CHAR16));
  if (ConfigHdr == NULL) {
    return NULL;
  } 

  String = ConfigHdr;
  StrCpy (String, L"GUID=");
  String += StrLen (L"GUID=");

  //
  // Append Guid converted to 32
  //
  UpperString = String;
  for (Index = 0, Buffer = (UINT8 *)Guid; Index < sizeof (EFI_GUID); Index++) {
    String += SPrint (String, 0, L"%02x", *Buffer++);
  }
  *String = 0;
  StrLwr (UpperString);

  //
  // Append L"&NAME="
  //
  StrCpy (String, L"&NAME=");
  String += StrLen (L"&NAME=");
  UpperString = String;
  for (Index = 0; Index < NameLength ; Index++) {
    String += SPrint (String, 0, L"00%x", Name[Index]);
  }
  *String = 0;
  StrLwr (UpperString);
  
  //
  // Append L"&PATH="
  //
  StrCpy (String, L"&PATH=");
  String += StrLen (L"&PATH=");
  UpperString = String;
  for (Index = 0, Buffer = (UINT8 *) DevicePath; Index < DevicePathLength; Index++) {
    String += SPrint (String, 0, L"%02x", *Buffer++);
  }
  *String = 0;
  StrLwr (UpperString);

  return ConfigHdr;
}

2012年8月2日 星期四

Return number of ASCii string

int
strlen(
    IN const char * s
)
/*++
Routine Description:
  This function returns the number of ASCii characters in the ASCii string s.
 Arguments: 
  Str     - Pointer to the null-terminated string to get length            str will hold the trimmed string. 
Returns:
--*/

{
const char *sc;

for (sc = s; *sc != '\0'; ++sc)
/* nothing */;
return (int)((unsigned long long)sc - (unsigned long long)s);
}

Convert the ASCII string <=> a UNICODE string


/************************************************************/
CHAR16 *
AsciiStrToUnicodeStr (
  IN  CHAR8   *Source,
  OUT CHAR16  *Destination
  )
/*++
Routine Description:
  Convert the ASCII string into a UNICODE string.
Arguments:
  Source      - The ASCII string.
  Destination - The storage to return the UNICODE string.
Returns:
  Pointer to the UNICODE string.
--*/
{
  ASSERT (Destination != NULL);
  ASSERT (Source != NULL);

  while (*Source != '\0') {
    *(Destination++) = (CHAR16) *(Source++);
  }

  *Destination = '\0';

  return Destination;
}
/************************************************************/

/************************************************************/
CHAR8 *
UnicodeStrToAsciiStr (
  IN  CHAR16   *Source,
  OUT  CHAR8  *Destination
  )
/*++
Routine Description:
  Convert the UNICODE string into a ASCII  string.
Arguments:
  Source      - The storage to return the UNICODE string.
  Destination - The ASCII string.
Returns:
  Pointer to the UNICODE string.
--*/

{
  ASSERT (Destination != NULL);
  ASSERT (Source != NULL);

  while (*Source != '\0') {
    *(Destination++) = (CHAR8) *(Source++);
  }

  *Destination = '\0';

  return Destination;
}

/************************************************************/