summaryrefslogtreecommitdiff
path: root/Board/EM/FIT/Dxe/BootGuardDxe.c
blob: 4c4ccb082847cef6fd6e50c55df7f545ea1aa5d0 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2013, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/FIT/Dxe/BootGuardDxe.c 1     2/25/13 1:11a Bensonlai $
//
// $Revision: 1 $
//
// $Date: 2/25/13 1:11a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/FIT/Dxe/BootGuardDxe.c $
// 
// 1     2/25/13 1:11a Bensonlai
// [TAG]  		EIP114386
// [Category]  	Spec Update
// [Severity]  	Important
// [Description]  	[SBY] Ultrabook for Shark Bay Platform - : Boot Guard
// for 4th Gen Intel Core Processor based on Mobile U-Processor Line -
// BIOS Writer's Guide - Rev 0.8.1
// [Files]  		BootGuardDxe.cif
// BootGuardDxe.c
// BootGuardDxe.h
// BootGuardDxe.sdl
// BootGuardDxe.dxs
// BootGuardDxe.mak
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name: BootGuardDxe.c
//
// Description: Chain of trust for Dxe
//
//<AMI_FHDR_END>
//**********************************************************************

#include "BootGuardDxe.h"

VOID
BootGuardDxeCallback (
    IN EFI_EVENT Event,
    IN VOID      *Context
)
{
    EFI_INPUT_KEY           Key;
    EFI_STATUS              Status;

    gST->ConOut->ClearScreen (gST->ConOut);

    gST->ConOut->OutputString (
        gST->ConOut,
        L"Anchor Cove verified DXE that is fail\n\r"
    );

    gST->ConOut->OutputString (
        gST->ConOut,
        L"System will shutdown\n\r"
    );

    gST->ConOut->OutputString (
        gST->ConOut,
        L"Press any key\n\r"
    );

    do {
        Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
    } while (Status != EFI_SUCCESS);

    gRT->ResetSystem (EfiResetShutdown, EFI_SUCCESS, 0, NULL);
    EFI_DEADLOOP ();

    gBS->CloseEvent (Event);
}

VOID
BootGuardDxeRegisterCallBack (
    VOID
)
{
    EFI_EVENT   Event;
    VOID        *NotifyReg;
    EFI_STATUS  Status;

    Status = gBS->CreateEvent (
                 EFI_EVENT_NOTIFY_SIGNAL,
                 EFI_TPL_CALLBACK,
                 BootGuardDxeCallback,
                 NULL,
                 &Event
             );

    if ( EFI_ERROR(Status) ) {
        ASSERT_EFI_ERROR (Status);
        return;
    }

    Status = gBS->RegisterProtocolNotify (
                 &gNotifyProtocolGuid ,
                 Event,
                 &NotifyReg
             );

    if ( EFI_ERROR(Status) ) {
        ASSERT_EFI_ERROR (Status);
        return;
    }

    return;
}

EFI_STATUS
BootGuardDxeEntryPoint (
    IN EFI_HANDLE       ImageHandle,
    IN EFI_SYSTEM_TABLE *SystemTable
)
{
    EFI_GUID                      AmiBootGuardHobGuid = AMI_ANCHOR_COVE_HOB_GUID;
    AMI_ANCHOR_COVE_HOB           *AmiBootGuardHobPtr;
    PCH_SERIES                    PchSeries = GetPchSeries();
    EFI_BOOT_MODE                 BootMode;
    EFI_PEI_HOB_POINTERS          HobList;

    if ( PchSeries != PchLp ) {
        return   EFI_SUCCESS;
    }

    if ( IsBootGuardSupported() == FALSE ) {
        return   EFI_SUCCESS;
    }

    DEBUG ((EFI_D_INFO, "[BootGuardDxe.c] : Entry Point...\n"));

    //
    // Check Boot Type
    //
    EfiGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &HobList.Raw);
    if (HobList.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
        DEBUG ((EFI_D_ERROR, "[BootGuardDxe.c] : Get HOB fail\n"));
        return EFI_SUCCESS;
    }

    BootMode  = HobList.HandoffInformationTable->BootMode;
    if ( BootMode == BOOT_IN_RECOVERY_MODE ) {
        DEBUG ((EFI_D_ERROR, "[BootGuardDxe.c] : In the BOOT_IN_RECOVERY_MODE\n"));
        return   EFI_SUCCESS;
    }

    AmiBootGuardHobPtr = GetFirstGuidHob (&AmiBootGuardHobGuid);
    if (AmiBootGuardHobPtr == NULL) {
        DEBUG ((EFI_D_ERROR, "[BootGuardDxe.c] : AmiBootGuard DXE Hob not available\n"));
        return   EFI_NOT_FOUND;
    }

    if ( AmiBootGuardHobPtr->AmiBootGuardVerificationforPEItoDXEFlag == 0 ) {
        BootGuardDxeRegisterCallBack();
    }

    DEBUG ((EFI_D_INFO, "[BootGuardDxe.c] : Entry End...\n"));

    return   EFI_SUCCESS;
}

//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2013, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093        **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************