26#define LOGO_BOTTOM_PADDING 20
27#define PROGRESS_BLOCK_HEIGHT 10
37UINTN mPreviousProgress = 100;
49UINTN mBlockHeight = 0;
102BOOLEAN mGraphicsGood =
FALSE;
138 DEBUG ((DEBUG_ERROR,
"No GOP found. No progress bar support. \n"));
145 Status =
gBS->LocateProtocol (
146 &gEdkiiBootLogo2ProtocolGuid,
150 if ((BootLogo ==
NULL) || (EFI_ERROR (Status))) {
151 DEBUG ((DEBUG_ERROR,
"Failed to locate gEdkiiBootLogo2ProtocolGuid Status = %r. No Progress bar support. \n", Status));
158 Status = BootLogo->GetBootLogo (
166 if (EFI_ERROR (Status)) {
167 DEBUG ((DEBUG_ERROR,
"Failed to Get Boot Logo Status = %r. No Progress bar support. \n", Status));
180 for (LogoX = 0, LogoStartX = Width; LogoX < LogoStartX; LogoX++) {
182 for (LogoY = 0; LogoY < (
INTN)Height; LogoY++) {
183 if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
189 DEBUG ((DEBUG_INFO,
"StartX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
193 Pixel = Pixel + Width;
200 for (LogoX = Width - 1; LogoX >= LogoEndX; LogoX--) {
202 for (LogoY = 0; LogoY < (
INTN)Height; LogoY++) {
203 if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
205 DEBUG ((DEBUG_INFO,
"EndX found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
209 Pixel = Pixel + Width;
216 mBlockWidth = ((LogoEndX - LogoStartX) + 99) / 100;
221 mStartX = LogoStartX + OffsetX - (((mBlockWidth * 100) - (LogoEndX - LogoStartX)) / 2);
222 DEBUG ((DEBUG_INFO,
"mBlockWidth set to 0x%X\n", mBlockWidth));
223 DEBUG ((DEBUG_INFO,
"mStartX set to 0x%X\n", mStartX));
228 for (LogoY = 0, LogoStartY = Height; LogoY < LogoStartY; LogoY++) {
230 for (LogoX = 0; LogoX < (
INTN)Width; LogoX++) {
232 if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
235 DEBUG ((DEBUG_INFO,
"StartY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
246 for (LogoY = Height - 1; LogoY >= LogoEndY; LogoY--) {
248 for (LogoX = 0; LogoX < (
INTN)Width; LogoX++) {
249 if ((Pixel->Raw & mLogoDetectionColorMask.Raw) != 0x0) {
251 DEBUG ((DEBUG_INFO,
"EndY found at (%d, %d) Color is: 0x%X \n", LogoX, LogoY, Pixel->Raw));
262 mStartY = (((LogoEndY - LogoStartY) * LOGO_BOTTOM_PADDING) / 100) + LogoEndY + OffsetY;
267 mBlockHeight = (((LogoEndY - LogoStartY) * PROGRESS_BLOCK_HEIGHT) / 100);
269 DEBUG ((DEBUG_INFO,
"mBlockHeight set to 0x%X\n", mBlockHeight));
275 if (mProgressBarBackground ==
NULL) {
276 DEBUG ((DEBUG_ERROR,
"Failed to allocate progress bar background\n"));
284 mProgressBarBackground,
286 mProgressBarBackgroundColor.Raw
293 if (mBlockBitmap ==
NULL) {
295 DEBUG ((DEBUG_ERROR,
"Failed to allocate block\n"));
302 if ((mBlockHeight > Height) || (mBlockWidth > Width) || (mBlockHeight < 1) || (mBlockWidth < 1)) {
303 DEBUG ((DEBUG_ERROR,
"DisplayUpdateProgressLib - Progress - Failed to get valid width and height.\n"));
304 DEBUG ((DEBUG_ERROR,
"DisplayUpdateProgressLib - Progress - mBlockHeight: 0x%X mBlockWidth: 0x%X.\n", mBlockHeight, mBlockWidth));
310 mGraphicsGood =
TRUE;
349 if (Completion > 100) {
350 return EFI_INVALID_PARAMETER;
356 if (Completion == mPreviousProgress) {
364 Status =
gBS->HandleProtocol (
366 &gEfiGraphicsOutputProtocolGuid,
369 if (EFI_ERROR (Status)) {
370 Status =
gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid,
NULL, (VOID **)&mGop);
371 if (EFI_ERROR (Status)) {
373 DEBUG ((DEBUG_ERROR,
"Show Progress Function could not locate GOP. Status = %r\n", Status));
374 return EFI_NOT_READY;
387 if (!mGraphicsGood) {
388 DEBUG ((DEBUG_INFO,
"Graphics Not Good. Not doing any onscreen visual display\n"));
389 return EFI_NOT_READY;
395 if (mPreviousProgress == 100) {
401 mProgressBarBackground,
415 (Color ==
NULL) ? mProgressBarDefaultColor.Raw : Color->Raw
424 (Color ==
NULL) ? mProgressBarDefaultColor.Raw : Color->Raw
430 mPreviousProgress = 0;
436 if (Completion < mPreviousProgress) {
437 DEBUG ((DEBUG_WARN,
"WARNING: Completion (%d) should not be lesss than Previous (%d)!!!\n", Completion, mPreviousProgress));
438 return EFI_INVALID_PARAMETER;
441 PreX = ((mPreviousProgress * mBlockWidth) + mStartX);
442 for (Index = 0; Index < (Completion - mPreviousProgress); Index++) {
461 mPreviousProgress = Completion;
VOID *EFIAPI SetMem32(OUT VOID *Buffer, IN UINTN Length, IN UINT32 Value)
EFI_STATUS EFIAPI DisplayUpdateProgress(IN UINTN Completion, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *Color OPTIONAL)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_HANDLE ConsoleOutHandle