搜尋此網誌

2012年8月7日 星期二

(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;
}

沒有留言:

張貼留言