+/**\r
+ Insert one pre-fetched key into the FIFO buffer.\r
+\r
+ @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
+ @param Input The key will be input.\r
+\r
+ @retval TRUE If insert successfully.\r
+ @retval FALSE If FIFO buffer is full before key insertion,\r
+ and the key is lost.\r
+\r
+**/\r
+BOOLEAN\r
+EfiKeyFiFoForNotifyInsertOneKey (\r
+ EFI_KEY_FIFO *EfiKeyFiFo,\r
+ EFI_INPUT_KEY *Input\r
+ )\r
+{\r
+ UINT8 Tail;\r
+\r
+ Tail = EfiKeyFiFo->Tail;\r
+\r
+ if (IsEfiKeyFiFoForNotifyFull (EfiKeyFiFo)) {\r
+ //\r
+ // FIFO is full\r
+ //\r
+ return FALSE;\r
+ }\r
+\r
+ CopyMem (&EfiKeyFiFo->Data[Tail], Input, sizeof (EFI_INPUT_KEY));\r
+\r
+ EfiKeyFiFo->Tail = (UINT8) ((Tail + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+/**\r
+ Remove one pre-fetched key out of the FIFO buffer.\r
+\r
+ @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
+ @param Output The key will be removed.\r
+\r
+ @retval TRUE If remove successfully.\r
+ @retval FALSE If FIFO buffer is empty before remove operation.\r
+\r
+**/\r
+BOOLEAN\r
+EfiKeyFiFoForNotifyRemoveOneKey (\r
+ EFI_KEY_FIFO *EfiKeyFiFo,\r
+ EFI_INPUT_KEY *Output\r
+ )\r
+{\r
+ UINT8 Head;\r
+\r
+ Head = EfiKeyFiFo->Head;\r
+ ASSERT (Head < FIFO_MAX_NUMBER + 1);\r
+\r
+ if (IsEfiKeyFiFoForNotifyEmpty (EfiKeyFiFo)) {\r
+ //\r
+ // FIFO is empty\r
+ //\r
+ Output->ScanCode = SCAN_NULL;\r
+ Output->UnicodeChar = 0;\r
+ return FALSE;\r
+ }\r
+\r
+ CopyMem (Output, &EfiKeyFiFo->Data[Head], sizeof (EFI_INPUT_KEY));\r
+\r
+ EfiKeyFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 1));\r
+\r
+ return TRUE;\r
+}\r
+\r
+/**\r
+ Clarify whether FIFO buffer is empty.\r
+\r
+ @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
+\r
+ @retval TRUE If FIFO buffer is empty.\r
+ @retval FALSE If FIFO buffer is not empty.\r
+\r
+**/\r
+BOOLEAN\r
+IsEfiKeyFiFoForNotifyEmpty (\r
+ EFI_KEY_FIFO *EfiKeyFiFo\r
+ )\r
+{\r
+ if (EfiKeyFiFo->Head == EfiKeyFiFo->Tail) {\r
+ return TRUE;\r
+ } else {\r
+ return FALSE;\r
+ }\r
+}\r
+\r
+/**\r
+ Clarify whether FIFO buffer is full.\r
+\r
+ @param EfiKeyFiFo Pointer to instance of EFI_KEY_FIFO.\r
+\r
+ @retval TRUE If FIFO buffer is full.\r
+ @retval FALSE If FIFO buffer is not full.\r
+\r
+**/\r
+BOOLEAN\r
+IsEfiKeyFiFoForNotifyFull (\r
+ EFI_KEY_FIFO *EfiKeyFiFo\r
+ )\r
+{\r
+ UINT8 Tail;\r
+ UINT8 Head;\r
+\r
+ Tail = EfiKeyFiFo->Tail;\r
+ Head = EfiKeyFiFo->Head;\r
+\r
+ if (((Tail + 1) % (FIFO_MAX_NUMBER + 1)) == Head) {\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r