2023年12月9日發(fā)(作者:朗文英語)

todo高通AndroidUEFI中的LCD分析(1):啟動(dòng)流程分析
背景
之前學(xué)習(xí)的lk階段點(diǎn)亮LCD的流程算是比較經(jīng)典,但是高通已經(jīng)推出了很多種基于UEFI方案的啟動(dòng)架構(gòu)。
所以需要對(duì)這塊比較新的技術(shù)進(jìn)行學(xué)習(xí)。
同事遇到了一個(gè)UEFI階段LCD顯示異常,而kernel正常的問題;但我解決不了。
分析
在高通UEFI架構(gòu)中,通過Protocol來調(diào)用對(duì)應(yīng)的功能。因此實(shí)際上的函數(shù)調(diào)用并不是顯式的,而是包裹在Protocol中進(jìn)行。
高通UEFI顯示有關(guān)的文件有:
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/DisplayDxe.c
.4.1/boot_images/QcomPkg/Application/QcomChargerApp/QcomChargerAppDisplay.c
.4.1/boot_images/QcomPkg/Application/QcomChargerApp/QcomChargerAppDisplay.h
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/DisplayDxe.c
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/DisplayDxe.h
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/DisplayPwrCtrlProtocol.c
.4.1/boot_images/QcomPkg/Drivers/DisplayDxe/DisplayPwrProtocol.c
.4.1/boot_images/QcomPkg/Include/Library/BootDisplay.h
.4.1/boot_images/QcomPkg/Include/Library/DisplayLib.h
.4.1/boot_images/QcomPkg/Include/Library/DisplayUtils.h
.4.1/boot_images/QcomPkg/Include/Library/ExternalDisplayDriver.h
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwr.h
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwrCtrl.h
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayUtils.h
.4.1/boot_images/QcomPkg/Library/BootDisplayLib/BootDisplay.c
.4.1/boot_images/QcomPkg/Library/BootDisplayLib/
.4.1/boot_images/QcomPkg/Library/DisplayLib/DisplayLib.c
.4.1/boot_images/QcomPkg/Library/DisplayLib/
.4.1/boot_images/QcomPkg/Library/ExternalDisplayLib/ExtDisplay_driver.c
.4.1/boot_images/QcomPkg/Library/ExternalDisplayLib/
.4.1/boot_images/QcomPkg/Library/ExternalDisplayLib/
.4.1/boot_images/QcomPkg/Library/ExternalDisplayLib/
.4.1/boot_images/QcomPkg/Include/Library/HALMDPLib.h
.4.1/boot_images/QcomPkg/Include/Library/MDPLib.h
.4.1/boot_images/QcomPkg/Include/Library/MDPPeripherals.h
.4.1/boot_images/QcomPkg/Include/Library/MDPPlatformLib.h
.4.1/boot_images/QcomPkg/Include/Library/MDPSystem.h
.4.1/boot_images/QcomPkg/Include/Library/MDPTypes.h
.4.1/boot_images/QcomPkg/Library/MDPLib/DisplayUtils.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPClocks.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPClocksBoot.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPConfig.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPEDID.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPLib.c
.4.1/boot_images/QcomPkg/Library/MDPLib/
.4.1/boot_images/QcomPkg/Library/MDPLib/
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPLib_i.h
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPPanel.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPPeripherals.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPSystem.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPSystemBoot.c
.4.1/boot_images/QcomPkg/Library/MDPLib/MDPVersion.c
.4.1/boot_images/QcomPkg/Library/NullLibs/MDPPlatformLibNull/MDPPlatformLibNull.c
.4.1/boot_images/QcomPkg/Library/NullLibs/MDPPlatformLibNull/
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLib/MDPPlatformLib.c
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLib/
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLib/MDPPlatformLibPanelCommon.c
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLib/MDPPlatformLibPanelCommon.h
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLib/MDPPlatformLibPanelConfig.h
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLibBoot/MDPPlatformLib.c
.4.1/boot_images/QcomPkg/SocPkg/AgattiPkg/Library/MDPPlatformLibBoot/
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLib/MDPPlatformLib.c
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLib/
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLib/MDPPlatformLibPanelCommon.c
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLib/MDPPlatformLibPanelCommon.h
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLib/MDPPlatformLibPanelConfig.h
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLibBoot/MDPPlatformLib.c
.4.1/boot_images/QcomPkg/SocPkg/KamortaPkg/Library/MDPPlatformLibBoot/對(duì)外的Protocol
有關(guān)文件:
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwr.h
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwrCtrl.h
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayUtils.h
Protocol接口
學(xué)習(xí)UEFI,比較關(guān)鍵的是:
0、了解UEFI是如何實(shí)現(xiàn)的
1、了解
XXX_PROTOCOL
定義中有什么接口可以使用:方便我們找到實(shí)現(xiàn)的原型
2、找到對(duì)應(yīng)的
XXX_PROTOCOL_GUID
是多少:方便我們找到哪里調(diào)用了對(duì)應(yīng)的接口
EFIDisplayPwr.h
路徑:
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwr.h
聲明了對(duì)應(yīng)的EFI_DISPLAY_POWER_PROTOCOL_GUID,但沒有調(diào)用。
/* Protocol GUID definition */
/** @ingroup efi_displayPwr_protocol */
#define EFI_DISPLAY_POWER_PROTOCOL_GUID
{0xf352021d, 0x9593, 0x4432, {0xbf, 0x4, 0x67, 0xb9, 0xf3, 0xb7, 0x60, 0x8}}
/*===========================================================================
PROTOCOL INTERFACE
===========================================================================*/
/** @ingroup efi_displayUtils_protocol
@par Summary
Qualcomm Display Utils Protocol interface.
@par Parameters
@inputprotoparams{}
*/
struct _EFI_QCOM_DISPLAY_UTILS_PROTOCOL
{
UINT64 Revision;
EFI_DISPLAY_UTILS_SET_PROPERTY DisplayUtilsSetProperty;
EFI_DISPLAY_UTILS_GET_PROPERTY DisplayUtilsGetProperty;
EFI_DISPLAY_UTILS_RENDER_LOGO DisplayUtilsRenderLogo;
EFI_DISPLAY_UTILS_SET_MODE DisplayUtilsSetMode;
EFI_DISPLAY_UTILS_SET_VARIABLE DisplayUtilsSetVariable;
EFI_DISPLAY_UTILS_GET_VARIABLE DisplayUtilsGetVariable;
};
EFIDisplayPwrCtrl.h
路徑:
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayPwrCtrl.h
這里的接口并沒有被AP側(cè)調(diào)用,甚至都沒有聲明。
/* Protocol GUID definition */
/** @ingroup efi_displayPwrCtrl_protocol */
#define EFI_DISPLAYPWRCTRL_PROTOCOL_GUID
{0x7bfa4293, 0x7aa4, 0x4375, {0xb6, 0x3c, 0xb6, 0xaa, 0xb7, 0x86, 0xc4, 0x3c}}
// {68C3B70D-0F96-4006-99F6-0FD211F5F2B2}
#define EFI_UI_ACTIVE_EVENT_GUID
{ 0x68c3b70d, 0xf96, 0x4006, { 0x99, 0xf6, 0xf, 0xd2, 0x11, 0xf5, 0xf2, 0xb2 } };
// {30D39942-9556-4887-A943-BC63805D9D43}
#define EFI_UI_IDLE_EVENT_GUID
{0x30d39942, 0x9556, 0x4887, { 0xa9, 0x43, 0xbc, 0x63, 0x80, 0x5d, 0x9d, 0x43 }};
/*===========================================================================
PROTOCOL INTERFACE
===========================================================================*/
/** @ingroup efi_displayPwrCtrl_protocol
@par Summary
Qualcomm Display Power Control Protocol interface.
@par Parameters
@inputprotoparams{}
*/
struct _EFI_QCOM_DISPLAY_PWR_CTRL_PROTOCOL{
UINT64 Revision;
EFI_DISPLAY_PANEL_POWER_CONTROL DisplayPanelPowerControl;
EFI_DISPLAY_PANEL_POWER_STATUS DisplayPanelPowerStatus;
EFI_DISPLAY_BACKLIGHT_BRIGHTNESS_LEVEL_CONTROL DisplayBacklightBrightnessLevelControl;
EFI_DISPLAY_BACKLIGHT_BRIGHTNESS_LEVEL_STATUS DisplayBacklightBrightnessLevelStatus;
};
EFIDisplayUtils.h
路徑:
.4.1/boot_images/QcomPkg/Include/Protocol/EFIDisplayUtils.h
/* Protocol GUID definition */
/** @ingroup efi_displayUtils_protocol */
// {c0dd69ac-76ba-11e6-ab24-1fc7f5575f19}
#define EFI_DISPLAYUTILS_PROTOCOL_GUID
{0xc0dd69ac, 0x76ba, 0x11e6, {0xab, 0x24, 0x1f, 0xc7, 0xf5, 0x57, 0x5f, 0x19}}
/**
Protocol declaration.
*/
typedef struct _EFI_QCOM_DISPLAY_UTILS_PROTOCOL EFI_QCOM_DISPLAY_UTILS_PROTOCOL;
/**
Display Utils property types
*/
typedef enum
{
EFI_DISPLAY_UTILS_DEVICE_TREE_ADDR = 0x0, /**< Device tree ba address: (Type: VOID*) */
EFI_DISPLAY_UTILS_PANEL_OVERRIDE, /**< Panel override string (Type: CHAR8*) */
EFI_DISPLAY_UTILS_SUPPORTED_PANELS, /**< Newline parated list of supported panels (Type: CHAR16*) */
EFI_DISPLAY_UTILS_PANEL_CONFIG, /**< Panel raw configuration */
EFI_DISPLAY_UTILS_DYNAMIC_REFRESH, /**< Dynamic refresh ttings (Type: UINT32*) */
} EFI_DISPLAY_UTILS_PROPERTY_TYPE;
/*===========================================================================
PROTOCOL INTERFACE
===========================================================================*/
/** @ingroup efi_displayUtils_protocol
@par Summary
Qualcomm Display Utils Protocol interface.
@par Parameters
@inputprotoparams{}
*/
struct _EFI_QCOM_DISPLAY_UTILS_PROTOCOL
{
UINT64 Revision;
EFI_DISPLAY_UTILS_SET_PROPERTY DisplayUtilsSetProperty;
EFI_DISPLAY_UTILS_GET_PROPERTY DisplayUtilsGetProperty;
EFI_DISPLAY_UTILS_RENDER_LOGO DisplayUtilsRenderLogo;
EFI_DISPLAY_UTILS_SET_MODE DisplayUtilsSetMode;
EFI_DISPLAY_UTILS_SET_VARIABLE DisplayUtilsSetVariable;
EFI_DISPLAY_UTILS_GET_VARIABLE DisplayUtilsGetVariable;
};
EFI_DISPLAYUTILS_PROTOCOL_GUID
在AP側(cè)中的FASTBOOT模式被調(diào)用了,用于判斷是否支持顯示畫面。
bootable/bootloader/edk2/QcomModulePkg/Library/FastbootLib/FastbootCmds.c
STATIC UINT8
is_display_supported ( VOID )
{
EFI_STATUS Status = EFI_SUCCESS;
EfiQcomDisplayUtilsProtocol *pDisplayUtilProtocol;
EFI_GUID DisplayUtilGUID = EFI_DISPLAYUTILS_PROTOCOL_GUID;
EFI_DISPLAY_UTILS_PANEL_CONFIG_PARAMS PanelConfig;
UINT32 Index = 0;
UINT32 ParamSize = sizeof (PanelConfig);
Index = Index;
if (EFI_SUCCESS == gBS->LocateProtocol (&DisplayUtilGUID,
NULL,
(VOID **)&pDisplayUtilProtocol)) {
Status = pDisplayUtilProtocol->DisplayUtilsGetProperty (
EFI_DISPLAY_UTILS_PANEL_CONFIG,
(VOID*)&PanelConfig, &ParamSize);
if ( Status == EFI_NOT_FOUND ) {
DEBUG ((EFI_D_VERBOSE, "Display is not supportedn"));
return 0;
}
} DEBUG ((EFI_D_VERBOSE, "Display is enabledn"));
return 1;
}
對(duì)應(yīng)接口的實(shí)現(xiàn)
下面我們具體看看
EFI_QCOM_DISPLAY_UTILS_PROTOCOL
這個(gè)實(shí)現(xiàn)。
.4.1/boot_images/QcomPkg/Library/MDPLib/DisplayUtils.c
/* Display Utils Protocol Implementation
*/
EFI_QCOM_DISPLAY_UTILS_PROTOCOL gQcomDisplayUtilsProtocolImplementation =
{
DISPLAY_UTILS_REVISION,
Display_Utils_SetProperty,
Display_Utils_GetProperty,
Display_Utils_RenderLogo,
Display_Utils_SetMode,
Display_Utils_SetVariable,
Display_Utils_GetVariable
};
執(zhí)行流程
DisplayDxeInitialize
顯示驅(qū)動(dòng)執(zhí)環(huán)境的初始化
.4.1boot_imagesQcomPkgDriversDisplayDxeDisplayDxe.c
/**********************************************************************************************************************
Public APIs
**/
/**
Initialize the state information for the Display Dxe
@param ImageHandle of the loaded driver
@param SystemTable Pointer to the System Table
@retval EFI_SUCCESS Protocol registered
@retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
@retval EFI_DEVICE_ERROR Hardware problems
**/
EFI_STATUS
EFIAPI
DisplayDxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS eStatus = EFI_SUCCESS;
EFI_GUID sOutputGUID = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
EFI_HANDLE hUEFIDisplayHandle = NULL;
MDP_InitParamsType sInitParam;
EFI_GUID UIActiveEventGuid = EFI_UI_ACTIVE_EVENT_GUID;
EFI_GUID UIIdleEventGuid = EFI_UI_IDLE_EVENT_GUID;
// Clear out global structures
MDP_OSAL_MEMZERO(&gModeInfo, sizeof(DisplayDxe_ModeInfo));
MDP_OSAL_MEMZERO(&sInitParam, sizeof(MDP_InitParamsType));
/* Register for an ExitBootServicesEvent */
// 創(chuàng)建了一些事件(略): 創(chuàng)建一個(gè)事件,然后設(shè)定一個(gè)條件,使得條件滿足的時(shí)候就執(zhí)行這個(gè)事件
// ...
// 初始化有關(guān)的 時(shí)鐘、電源
if (EFI_SUCCESS != DisplayPwr_InitLPMSupport(TRUE))
{
DEBUG((EFI_D_WARN, "DisplayDxe: Failed to register LPM CB!n"));
}
// Initialize Apps BootLoader (ABL) interface
// It checks for panel override, if any, t by ABL and ts up parameters which will be ud by MDPInit
if (MDP_STATUS_OK != MDPSetProperty(MDP_DISPLAY_PRIMARY, MDP_DISPLAY_PROPERTY_ABL_INTERFACE_INIT, NULL))
{
DEBUG((EFI_D_INFO, "DisplayDxe: Failed to initialize ABL!n"));
}
// Initialize the MDP
if (MDP_STATUS_OK != MDPInit(&sInitParam, MDP_INIT_FLAG_MMU_INIT)) { DEBUG ((EFI_D_INFO, "DisplayDxe: MDP init failed!n"));
eStatus = EFI_DEVICE_ERROR; } el { MDP_PowerParamsType sPowerParams; MDP_DetectParamType sDetectParams; MDP_PropertiesParamType sDisplayProp; MDP_OSAL_MEMZERO(&sDisplayProp, sizeof(MDP_PropertiesParamType)); MDP_OSAL_MEMZERO(&sPowerParams, sizeof(MDP_PowerParamsType)); On = TRUE; ayPwrState = TRUE; ////////////////// // Main Display // ////////////////// // If the primary is supported initialize it if (TRUE == rtedDisplays[MDP_DISPLAY_PRIMARY]) { if (MDP_STATUS_OK != MDPPower(MDP_DISPLAY_PRIMARY, &sPowerParams, 0x0)) { DEBUG ((EFI_D_INFO, "DisplayDxe: Primary panel power up failed!n"));
} el { MDP_OSAL_MEMZERO(&sDetectParams, sizeof(MDP_DetectParamType)); // Default reporting of primary display if (MDP_STATUS_OK != MDPDetect(MDP_DISPLAY_PRIMARY, &sDetectParams, 0x0)) { eStatus = EFI_DEVICE_ERROR; } el if (TRUE == ayDetected) { eStatus = DisplayDxeSelectMode(MDP_DISPLAY_PRIMARY, &sDetectParams); // Set the primary display to on
if (MDP_STATUS_OK != MDPSetProperty(MDP_DISPLAY_PRIMARY, MDP_DISPLAY_PROPERTY_POWER_STATE, &sDisplayProp)) { eStatus = EFI_DEVICE_ERROR;
} } } }
// If we not have detected a valid mode on both primary and external display report error if ((0 == des[MDP_DISPLAY_PRIMARY]) && (0 == des[MDP_DISPLAY_EXTERNAL])) { eStatus = EFI_DEVICE_ERROR; } el { // Default at some dummy mode n = GRAPHICS_OUTPUT_PROTOCOL_REVISION; ormat = DISPLAYDXE_DEFAULT_PIXEL_FORMAT; ntalResolution = 0; alResolution = 0; k = DISPLAYDXE_RED_MASK; ask = DISPLAYDXE_GREEN_MASK; sk = DISPLAYDXE_BLUE_MASK; edMask = DISPLAYDXE_ALPHA_MASK; PerScanLine = 0; // Setup the protocol information, t the current mode to an invalid mode forcing a t mode e = 1; = (UINT32)-1; Info = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION); = &ntModeInfo; pported = rtedDisplays[MDP_DISPLAY_EXTERNAL]; // Install display protocols only if panel is detected. // Make a new handle with EFI Graphics Protocol if (EFI_SUCCESS != (eStatus = gBS->InstallMultipleProtocolInterfaces (&hUEFIDisplayHandle, &gEfiDevicePathProtocolGuid, &DisplayDevicePath, &sOutputGUID, &gDisplayDxeOutputProtocol, &gQcomDisplayPwrCtrlProtocolGuid, &gDisplayPwrCtrlProtocolImplementation, &gEfiDisplayPowerStateProtocolGuid, &gDisplayPwrProtocolImplementation, &gQcomDisplayUtilsProtocolGuid, &gQcomDisplayUtilsProtocolImplementation, NULL))) { DEBUG ((EFI_D_INFO, "DisplayDxe: InstallMultipleProtocolInterfaces failed!n")); } }
} if (eStatus == EFI_SUCCESS) { if(EFI_SUCCESS != GetConfigValue ("EnableDisplayThread", &Threadded)) { Threadded = 0; } // Spawn off thread to enable mode t if we are in a threadded environment if (Threadded ) { InitLock ("DispInit", &ock); if(InitLock == NULL) { // If single CPU core is configured, the priority of this thread should be higher than UEFI dxe thread if (NULL != (hread = ThreadCreate ("Disp", &SetModeThread, 0, UEFI_THREAD_PRIORITY + 1, DEFAULT_STACK_SIZE * 3))) {
if (MDP_STATUS_OK != MDP_SetMultiThreadState(TRUE)) { DEBUG ((EFI_D_WARN, "DisplayDxe: Failed to t multiThread state to be enabled!n"));
// Disable multi threadding Threadded = 0; } el { ThreadDetach (hread); ThreadResume (hread); } } el { // Disable multi threadding Threadded = 0; } } el { // Disable multi threadding Threadded = 0; } } } return eStatus;}todo
本文發(fā)布于:2023-12-09 21:34:54,感謝您對(duì)本站的認(rèn)可!
本文鏈接:http://www.newhan.cn/zhishi/a/1702128894116505.html
版權(quán)聲明:本站內(nèi)容均來自互聯(lián)網(wǎng),僅供演示用,請(qǐng)勿用于商業(yè)和其他非法用途。如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除。
本文word下載地址:todo高通AndroidUEFI中的LCD分析(1):啟動(dòng)流程分析.doc
本文 PDF 下載地址:todo高通AndroidUEFI中的LCD分析(1):啟動(dòng)流程分析.pdf
| 留言與評(píng)論(共有 0 條評(píng)論) |