add comments to function declarations and definitions and updated to match coding style document.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11505 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jcarsey
2011-04-05 20:55:45 +00:00
parent c5981e3c3d
commit a1d4bfcc3f
47 changed files with 3680 additions and 3361 deletions

View File

@ -1,7 +1,7 @@
/** @file
Implementation of various string and line routines
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
Copyright (TempVarC) 2005 - 2011, 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
@ -16,119 +16,15 @@
extern BOOLEAN HEditorMouseAction;
VOID
HEditorClearLine (
IN UINTN Row
)
/*++
Routine Description:
Clear line at Row
Arguments:
Row -- row number to be cleared ( start from 1 )
Returns:
EFI_SUCCESS
--*/
{
CHAR16 Line[200];
UINTN Index;
UINTN Limit;
UINTN StartCol;
if (HEditorMouseAction) {
Limit = 3 * 0x10;
StartCol = 10;
} else {
Limit = HMainEditor.ScreenSize.Column;
StartCol = 1;
}
//
// prepare a blank line
//
for (Index = 0; Index < Limit; Index++) {
Line[Index] = ' ';
}
if (Row == HMainEditor.ScreenSize.Row && Limit == HMainEditor.ScreenSize.Column) {
//
// if '\0' is still at position 80, it will cause first line error
//
Line[Limit - 1] = '\0';
} else {
Line[Limit] = '\0';
}
//
// print out the blank line
//
ShellPrintEx ((INT32)StartCol - 1, (INT32)Row - 1, Line);
}
HEFI_EDITOR_LINE *
HLineDup (
IN HEFI_EDITOR_LINE *Src
)
/*++
Routine Description:
Duplicate a line
Arguments:
Src -- line to be duplicated
Returns:
NULL -- wrong
Not NULL -- line created
--*/
{
HEFI_EDITOR_LINE *Dest;
//
// allocate for the line structure
//
Dest = AllocateZeroPool (sizeof (HEFI_EDITOR_LINE));
if (Dest == NULL) {
return NULL;
}
Dest->Signature = EFI_EDITOR_LINE_LIST;
Dest->Size = Src->Size;
CopyMem (Dest->Buffer, Src->Buffer, 0x10);
Dest->Link = Src->Link;
return Dest;
}
/**
Free a line and it's internal buffer.
@param[in] Src The line to be freed.
**/
VOID
HLineFree (
IN HEFI_EDITOR_LINE *Src
)
/*++
Routine Description:
Free a line and it's internal buffer
Arguments:
Src -- line to be freed
Returns:
None
--*/
{
if (Src == NULL) {
return ;
@ -138,26 +34,18 @@ Returns:
}
/**
Advance to the next Count lines.
@param[in] Count The line number to advance.
@retval NULL An error occured.
@return A pointer to the line after advance.
**/
HEFI_EDITOR_LINE *
_HLineAdvance (
HLineAdvance (
IN UINTN Count
)
/*++
Routine Description:
Advance to the next Count lines
Arguments:
Count -- line number to advance
Returns:
NULL -- wrong
Not NULL -- line after advance
--*/
{
UINTN Index;
HEFI_EDITOR_LINE *Line;
@ -181,26 +69,18 @@ Returns:
return Line;
}
/**
Retreat to the previous Count lines.
@param[in] Count The line number to retreat.
@retval NULL An error occured.
@return A pointer to the line after retreat.
**/
HEFI_EDITOR_LINE *
_HLineRetreat (
HLineRetreat (
IN UINTN Count
)
/*++
Routine Description:
Retreat to the previous Count lines
Arguments:
Count -- line number to retreat
Returns:
NULL -- wrong
Not NULL -- line after retreat
--*/
{
UINTN Index;
HEFI_EDITOR_LINE *Line;
@ -224,28 +104,20 @@ Returns:
return Line;
}
/**
Advance/Retreat lines.
@param[in] Count The line number to advance/retreat.
>0 : advance
<0: retreat
@retval NULL An error occured.
@return A pointer to the line after move.
**/
HEFI_EDITOR_LINE *
HMoveLine (
IN INTN Count
)
/*++
Routine Description:
Advance/Retreat lines
Arguments:
Count -- line number to advance/retreat
>0 : advance
<0: retreat
Returns:
NULL -- wrong
Not NULL -- line after advance
--*/
{
HEFI_EDITOR_LINE *Line;
UINTN AbsCount;
@ -257,37 +129,28 @@ Returns:
//
if (Count <= 0) {
AbsCount = (UINTN)ABS(Count);
Line = _HLineRetreat (AbsCount);
Line = HLineRetreat (AbsCount);
} else {
Line = _HLineAdvance ((UINTN)Count);
Line = HLineAdvance ((UINTN)Count);
}
return Line;
}
/**
Advance/Retreat lines and set CurrentLine in BufferImage to it.
@param[in] Count The line number to advance/retreat.
>0 : advance
<0: retreat
@retval NULL An error occured.
@return A pointer to the line after move.
**/
HEFI_EDITOR_LINE *
HMoveCurrentLine (
IN INTN Count
)
/*++
Routine Description:
Advance/Retreat lines and set CurrentLine in BufferImage to it
Arguments:
Count -- line number to advance/retreat
>0 : advance
<0: retreat
Returns:
NULL -- wrong
Not NULL -- line after advance
--*/
{
HEFI_EDITOR_LINE *Line;
UINTN AbsCount;
@ -298,9 +161,9 @@ Returns:
//
if (Count <= 0) {
AbsCount = (UINTN)ABS(Count);
Line = _HLineRetreat (AbsCount);
Line = HLineRetreat (AbsCount);
} else {
Line = _HLineAdvance ((UINTN)Count);
Line = HLineAdvance ((UINTN)Count);
}
if (Line == NULL) {
@ -313,34 +176,26 @@ Returns:
}
EFI_STATUS
HFreeLines (
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
)
/*++
Routine Description:
Free all the lines in HBufferImage
/**
Free all the lines in HBufferImage.
Fields affected:
Lines
CurrentLine
NumLines
ListHead
Arguments:
@param[in] ListHead The list head.
@param[in] Lines The lines.
ListHead - The list head
Lines - The lines
Returns:
EFI_SUCCESS
--*/
@retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
HFreeLines (
IN LIST_ENTRY *ListHead,
IN HEFI_EDITOR_LINE *Lines
)
{
LIST_ENTRY *Link;
LIST_ENTRY *Link;
HEFI_EDITOR_LINE *Line;
//
@ -363,83 +218,13 @@ Returns:
return EFI_SUCCESS;
}
UINTN
HStrStr (
IN CHAR16 *Str,
IN CHAR16 *Pat
)
/*++
/**
Get the X information for the mouse.
Routine Description:
Search Pat in Str
Arguments:
Str -- mother string
Pat -- search pattern
Returns:
0 : not found
>= 1 : found position + 1
--*/
{
INTN *Failure;
INTN i;
INTN j;
INTN Lenp;
INTN Lens;
//
// this function copies from some lib
//
Lenp = StrLen (Pat);
Lens = StrLen (Str);
Failure = AllocateZeroPool ((UINTN)(Lenp * sizeof (INTN)));
if (Failure == NULL) {
return 0;
}
Failure[0] = -1;
for (j = 1; j < Lenp; j++) {
i = Failure[j - 1];
while ((Pat[j] != Pat[i + 1]) && (i >= 0)) {
i = Failure[i];
}
if (Pat[j] == Pat[i + 1]) {
Failure[j] = i + 1;
} else {
Failure[j] = -1;
}
}
i = 0;
j = 0;
while (i < Lens && j < Lenp) {
if (Str[i] == Pat[j]) {
i++;
j++;
} else if (j == 0) {
i++;
} else {
j = Failure[j - 1] + 1;
}
}
FreePool (Failure);
//
// 0: not found
// >=1 : found position + 1
//
return ((j == Lenp) ? (i - Lenp) : -1) + 1;
}
@param[in] GuidX The change.
@return the new information.
**/
INT32
HGetTextX (
IN INT32 GuidX
@ -454,6 +239,13 @@ HGetTextX (
return Gap;
}
/**
Get the Y information for the mouse.
@param[in] GuidY The change.
@return the new information.
**/
INT32
HGetTextY (
IN INT32 GuidY
@ -468,77 +260,3 @@ HGetTextY (
return Gap;
}
EFI_STATUS
HXtoi (
IN CHAR16 *Str,
OUT UINTN *Value
)
/*++
Routine Description:
convert hex string to uint
Arguments:
Str - The string
Value - The value
Returns:
--*/
{
UINT64 u;
CHAR16 c;
UINTN Size;
Size = sizeof (UINTN);
//
// skip leading white space
//
while (*Str && *Str == ' ') {
Str += 1;
}
if (StrLen (Str) > Size * 2) {
return EFI_LOAD_ERROR;
}
//
// convert hex digits
//
u = 0;
c = *Str;
while (c) {
c = *Str;
Str++;
if (c == 0) {
break;
}
//
// not valid char
//
if (!((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || (c >= '0' && c <= '9') || (c == '\0'))) {
return EFI_LOAD_ERROR;
}
if (c >= 'a' && c <= 'f') {
c -= 'a' - 'A';
}
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
u = LShiftU64 (u, 4) + (c - (c >= 'A' ? 'A' - 10 : '0'));
} else {
//
// '\0'
//
break;
}
}
*Value = (UINTN) u;
return EFI_SUCCESS;
}