summaryrefslogtreecommitdiff
path: root/ReferenceCode/Haswell/Txt/TxtInit/Dxe/TxtDxeOem.c
blob: bed83ec949d00c6534bd28a4c4d20a6c95b402fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/** @file
  This file contain OEM/Platform implementation for TXT in DXE phase.  It represents an abstract outline of the
  steps required during DXE for enabling TXT.  Each individual step is further
  abstracted behind a function call interface.  This is intended to minimize
  the need to modify this file when porting TXT to future platforms.

@copyright
  Copyright (c) 1999 - 2012 Intel Corporation. All rights reserved
  This software and associated documentation (if any) is furnished
  under a license and may only be used or copied in accordance
  with the terms of the license. Except as permitted by such
  license, no part of this software or documentation may be
  reproduced, stored in a retrieval system, or transmitted in any
  form or by any means without the express written consent of
  Intel Corporation.

  This file contains a 'Sample Driver' and is licensed as such
  under the terms of your license agreement with Intel or your
  vendor.  This file may be modified by the user, subject to
  the additional terms of the license agreement
**/

///
/// External include files do NOT need to be explicitly specified in real EDKII
/// environment
///
#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000)
#include "EdkIIGlueDxe.h"
#include "Txt.h"
#include "TxtDxeLib.h"
#endif

/**
  This function gets called before/after run the SCHECK function, intend to avoid platform specific SMIs to interfere in BIOS POST
  if BIOS SMM MP services or synchonization code is not well considered that some of APs are not waken up from Wait-for-SIPI state.
  Function should preserve original SMI enabling setting in augument is TRUE, and then restore it in augurment is FALSE.
  The caller is DisableSmiSources() in TxtDxeLib.c

  @param[in] TxtDxeCtx        - Point to TXT_DXE_LIB_CONTEXT structure
  @param[in] Operation        = TRUE    - Calling before SCHECK to saved and disable platform specific SMIs setting
                   = FALSE   - Calling after SCHECK to restore platform specific SMIs setting

  @retval EFI_SUCCESS   - Always.

  **/
EFI_STATUS
EFIAPI
TxtDxeOemDisableSmi (
  IN TXT_DXE_LIB_CONTEXT *TxtDxeCtx,
  IN BOOLEAN             Operation
  )
{
  static UINT16 SavedSmiControlDev29;
  static UINT16 SavedSmiControlDev26;

  if (Operation == TRUE) {
    ///
    /// Save and disable OEM/Platform specific SMIs
    ///
    /// Disable EHCI SMIs before giving control to TXT ACM. EHCI controller generating SMI during TXT ACM results in USB kbd issue
    ///
    SavedSmiControlDev26  = MmioRead16 (MmPciAddress (0, 0, 0, 0x1A, 0x6C));
    SavedSmiControlDev29  = MmioRead16 (MmPciAddress (0, 0, 0, 0x1D, 0x6C));

    MmioWrite16 (MmPciAddress (0, 0, 0, 0x1A, 0x6C), 0);
    MmioWrite16 (MmPciAddress (0, 0, 0, 0x1D, 0x6C), 0);
  } else {
    ///
    /// Restore or re-enable OEM/Platform specific SMIs
    ///
    /// Enable EHCI SMIs before giving control to TXT ACM.
    ///
    MmioWrite16 (MmPciAddress (0, 0, 0, 0x1A, 0x6C), SavedSmiControlDev26);
    MmioWrite16 (MmPciAddress (0, 0, 0, 0x1D, 0x6C), SavedSmiControlDev29);
  }

  return EFI_SUCCESS;
}