/* Find the top of screen menu base on the current menu. */
LIST_ENTRY* FindTopOfScreenMenu(IN LIST_ENTRY *CurPos, IN UINTN Rows, OUT UINTN *SkipValue)
/* Find the top of screen menu base on the current menu. */
LIST_ENTRY* FindTopOfScreenMenu(IN LIST_ENTRY *CurPos, IN UINTN Rows, OUT UINTN *SkipValue)
{
  LIST_ENTRY      *Link;
  LIST_ENTRY      *TopOfScreen;
  UI_MENU_OPTION  *PreviousMenuOption;
  Link               = CurPos;
  PreviousMenuOption = NULL;
  while (Link->BackLink != &gMenuOption) {
    Link               = Link->BackLink;
    PreviousMenuOption = MENU_OPTION_FROM_LINK (Link);
    if (PreviousMenuOption->Row == 0) {
      UpdateOptionSkipLines (PreviousMenuOption);
    }
    if (Rows <= PreviousMenuOption->Skip) {
      break;
    }
    Rows = Rows - PreviousMenuOption->Skip;
  }
  if (Link->BackLink == &gMenuOption) {
    TopOfScreen = gMenuOption.ForwardLink;
    if ((PreviousMenuOption != NULL) && (Rows < PreviousMenuOption->Skip)) {
      *SkipValue = PreviousMenuOption->Skip - Rows;
    } else {
      *SkipValue = 0;
    }
  } else {
    TopOfScreen = Link;
    *SkipValue  = PreviousMenuOption->Skip - Rows;
  }
  return TopOfScreen;
}