本文主要是介绍BIOS实战之显示logo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
先写一个简单的,这个是EDK自带的一个函数,就是如下这个GetSectionFromAnyFv函数
Status = GetSectionFromAnyFv (LogoFile, EFI_SECTION_RAW, 0, (VOID **) &ImageData, &ImageSize);
使用UEFI tool的都有了解过,UEFI tool是一个更换logo的工具,要更换logo,那么首先就要找到logo所在的section raw,这个函数就是给我们找到这一块的数据,有了图像的数据,我们直接就可以通过转换进行图片的显示:
Status = ConvertBmpToGopBlt (ImageData,ImageSize,(VOID **)&Blt,&BltSize,&Height,&Width);Status = GraphicsOutput->Blt (GraphicsOutput,Blt,EfiBltBufferToVideo,0,0,(UINTN) (SizeOfX - Width) / 2,(UINTN) (SizeOfY - Height) / 2,Width,Height,Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
第二种方式就需要了解FV,也就是前文FDF文件说明提到的:
GetLogoBuffer ((UINT8 *)(UINTN)PcdGet64(PcdLogoBaseAddress),&Buffer);FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Buffer;//compare FV system GUIDif(!CompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid)){Status = EFI_UNSUPPORTED;goto ProcExit;}
//save logo guid to LogoFileGUID
for(Index=0;Index<4;Index++){LogoFileGUID[Index] = (LogoFile->Data1 >> (Index * 8)) & 0xFF;
}
LogoFileGUID[4] = LogoFile->Data2 & 0xFF;
LogoFileGUID[5] = (LogoFile->Data2 >>8) & 0xFF;
LogoFileGUID[6] = LogoFile->Data3 & 0xFF;
LogoFileGUID[7] = (LogoFile->Data3 >>8) & 0xFF;
for(Index=0;Index<8;Index++){LogoFileGUID[8+Index] = LogoFile->Data4[Index];
}//find logo guid address
for(Index=0;Index<FwVolHeader->FvLength;Index++){for (LogoGUIDIndex = 0; LogoGUIDIndex<16; LogoGUIDIndex++){if (Buffer[Index + LogoGUIDIndex] != LogoFileGUID[LogoGUIDIndex]){LogoGUIDFindFlag = 0;break;}}if (LogoGUIDIndex == 16){ //find the logo GUIDLogoGUIDOffset = Index;LogoGUIDFindFlag = 1;break;}
}if (LogoGUIDFindFlag == 0){ //can not find the logo GUID, return Status = EFI_UNSUPPORTED;goto ProcExit;}//logo ROM layout header:logo guid 16 byte + (Checksum Type Attributes size State 8 byte) + raw data size 3 byte + type 1 byte + logo raw data//get logo size 16+8 = 24ImageSize = Buffer[LogoGUIDOffset + 24] + (Buffer[LogoGUIDOffset + 25] << 8) + (Buffer[LogoGUIDOffset + 26] << 16);LogoRawdataOffset = LogoGUIDOffset + 16 + 8 + 3 + 1;ImageSize = ImageSize -4;//reduce raw data size 3 byte + type 1 byteif(ImageSize == 0){ //logo size is 0, returnStatus = EFI_UNSUPPORTED;goto ProcExit;}ImageData = Buffer+LogoRawdataOffset;Status = TranslateBmpToGopBlt (ImageData,ImageSize,&Blt,&BltSize,&Height,&Width);Status = GraphicsOutput->Blt (GraphicsOutput,Blt,EfiBltBufferToVideo,0,0,(UINTN) (SizeOfX - Width) / 2,(UINTN) (SizeOfY - Height) / 2,Width,Height,Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
代码先写在这里,第一种方式就不怎么介绍了,重点说下第二种:
(待写)
额外的话题:做过联想的笔记本,用的是Phoenix的代码,他家的代码可以根据屏幕的分辨率对应相同分辨率的图片,这一点我觉得很不错,其实国产也可以这样做,我们可以读取分辨率,然后进行判断,是哪个分辨率的就加载哪张图片。。。
这篇关于BIOS实战之显示logo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!