/* Return and update the access record in entry. */
UINT64 GetAndUpdateAccNum(IN OUT UINT64 *Entry)
/* Return and update the access record in entry. */
UINT64 GetAndUpdateAccNum(IN OUT UINT64 *Entry)
{
  UINT64  Acc;
  Acc = GetAccNum (Entry);
  if ((*Entry & IA32_PG_A) != 0) {
    *Entry &= ~(UINT64)(UINTN)IA32_PG_A;
    SetAccNum (Entry, 0x7);
    return (0x7 + ACC_MAX_BIT);
  } else {
    if (Acc != 0) {
      SetAccNum (Entry, Acc - 1);
    }
  }
  return Acc;
}