bce776a MdeModulePkg/DxeMain: Fix BSP interrupts reenabled in ExitBootServices

Authored and Committed by Hao Wu 6 years ago
    MdeModulePkg/DxeMain: Fix BSP interrupts reenabled in ExitBootServices
    
    Within function CoreExitBootServices(), this commit will move the call
    of:
    
    MemoryProtectionExitBootServicesCallback();
    
    before:
    
    SaveAndSetDebugTimerInterrupt (FALSE);
    and
    gCpu->DisableInterrupt (gCpu);
    
    The reason is that, within MemoryProtectionExitBootServicesCallback(),
    APIs like RaiseTpl and RestoreTpl maybe called. An example will be:
    
    DebugLib (using PeiDxeDebugLibReportStatusCode instance)
     |
     v
    ReportStatusCodeLib (using DxeReportStatusCodeLib instance)
     |
     v
    Raise/RestoreTpl
    
    The call of Raise/RestoreTpl APIs will re-enable BSP interrupts. Hence,
    this commit refine the calling sequence to ensure BSP interrupts before
    leaving CoreExitBootServices().
    
    Cc: Jian J Wang <jian.j.wang@intel.com>
    Cc: Star Zeng <star.zeng@intel.com>
    Cc: Eric Dong <eric.dong@intel.com>
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Hao Wu <hao.a.wu@intel.com>
    Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
    Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>