+ Initialize all the text modes which the graphics console supports.\r
+\r
+ It returns information for available text modes that the graphics can support.\r
+\r
+ @param[in] HorizontalResolution The size of video screen in pixels in the X dimension.\r
+ @param[in] VerticalResolution The size of video screen in pixels in the Y dimension.\r
+ @param[in] GopModeNumber The graphics mode number which graphis console is based on.\r
+ @param[out] TextModeCount The total number of text modes that graphics console supports.\r
+ @param[out] TextModeData The buffer to the text modes column and row information.\r
+ Caller is responsible to free it when it's non-NULL.\r
+\r
+ @retval EFI_SUCCESS The supporting mode information is returned.\r
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+InitializeGraphicsConsoleTextMode (\r
+ IN UINT32 HorizontalResolution,\r
+ IN UINT32 VerticalResolution,\r
+ IN UINT32 GopModeNumber,\r
+ OUT UINTN *TextModeCount,\r
+ OUT GRAPHICS_CONSOLE_MODE_DATA **TextModeData\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINTN Count;\r
+ GRAPHICS_CONSOLE_MODE_DATA *ModeBuffer;\r
+ GRAPHICS_CONSOLE_MODE_DATA *NewModeBuffer;\r
+ UINTN ValidCount;\r
+ UINTN ValidIndex;\r
+ UINTN MaxColumns;\r
+ UINTN MaxRows; \r
+ \r
+ if ((TextModeCount == NULL) || (TextModeData == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ Count = sizeof (mGraphicsConsoleModeData) / sizeof (GRAPHICS_CONSOLE_MODE_DATA);\r
+\r
+ //\r
+ // Compute the maximum number of text Rows and Columns that this current graphics mode can support.\r
+ // To make graphics console work well, MaxColumns and MaxRows should not be zero.\r
+ //\r
+ MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;\r
+ MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;\r
+\r
+ //\r
+ // According to UEFI spec, all output devices support at least 80x25 text mode.\r
+ //\r
+ ASSERT ((MaxColumns >= 80) && (MaxRows >= 25));\r
+\r
+ //\r
+ // Add full screen mode to the last entry.\r
+ //\r
+ mGraphicsConsoleModeData[Count - 1].Columns = MaxColumns;\r
+ mGraphicsConsoleModeData[Count - 1].Rows = MaxRows;\r
+\r
+ //\r
+ // Get defined mode buffer pointer.\r
+ //\r
+ ModeBuffer = mGraphicsConsoleModeData;\r
+\r
+ //\r
+ // Here we make sure that the final mode exposed does not include the duplicated modes,\r
+ // and does not include the invalid modes which exceed the max column and row.\r
+ // Reserve 2 modes for 80x25, 80x50 of graphics console.\r
+ //\r
+ NewModeBuffer = AllocateZeroPool (sizeof (GRAPHICS_CONSOLE_MODE_DATA) * (Count + 2));\r
+ ASSERT (NewModeBuffer != NULL);\r
+\r
+ //\r
+ // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.\r
+ //\r
+ ValidCount = 0; \r
+\r
+ NewModeBuffer[ValidCount].Columns = 80;\r
+ NewModeBuffer[ValidCount].Rows = 25;\r
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;\r
+ NewModeBuffer[ValidCount].GopHeight = VerticalResolution;\r
+ NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;\r
+ NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;\r
+ NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1; \r
+ ValidCount++;\r
+\r
+ if ((MaxColumns >= 80) && (MaxRows >= 50)) {\r
+ NewModeBuffer[ValidCount].Columns = 80;\r
+ NewModeBuffer[ValidCount].Rows = 50;\r
+ NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;\r
+ NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1; \r
+ }\r
+ NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;\r
+ NewModeBuffer[ValidCount].GopHeight = VerticalResolution;\r
+ NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;\r
+ ValidCount++;\r