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
|
/** @file
Provide the ResetSystem AP
@copyright
Copyright (c) 2011 - 2013 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 an 'Intel Peripheral Driver' and uniquely
identified as "Intel Reference Module" and is
licensed for Intel CPUs and chipsets under the terms of your
license agreement with Intel or your vendor. This file may
be modified by the user, subject to additional terms of the
license agreement
**/
#include "PlatformReset.h"
#include "MeLib.h"
PCH_RESET_PROTOCOL *mPchReset;
/**
Reset the system
@param[in] ResetType Warm or cold
@param[in] ResetStatus Possible cause of reset
@param[in] DataSize Size of ResetData in bytes
@param[in] ResetData Optional Unicode string
@retval Does not return if the reset takes place.
**/
VOID
EFIAPI
PlatformResetSystem (
IN EFI_RESET_TYPE ResetType,
IN EFI_STATUS ResetStatus,
IN UINTN DataSize,
IN CHAR16 *ResetData OPTIONAL
)
{
EFI_STATUS Status;
ME_PLATFORM_GET_RESET_TYPE_PROTOCOL *MePlatformGetResetType;
PCH_RESET_TYPE OverridePchResetType;
PCH_RESET_TYPE PchResetType;
UINTN NumberMePlatformGetResetHandles;
EFI_HANDLE *MePlatformGetResetHandles;
UINTN Index;
PchResetType = ResetType;
OverridePchResetType = ResetType;
if (!EfiAtRuntime ()) {
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gMePlatformGetResetTypeGuid,
NULL,
&NumberMePlatformGetResetHandles,
&MePlatformGetResetHandles
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < NumberMePlatformGetResetHandles; Index++) {
Status = gBS->HandleProtocol (
MePlatformGetResetHandles[Index],
&gMePlatformGetResetTypeGuid,
(VOID **) &MePlatformGetResetType
);
if (!EFI_ERROR (Status)) {
PchResetType = MePlatformGetResetType->GetResetType (ResetType);
DEBUG ((EFI_D_INFO, "Returned Pch ResetType is: %x\n", PchResetType));
if (PchResetType >= MaxRestReq) {
DEBUG ((EFI_D_ERROR, "Platform Reset failed, invalid parameter\n"));
ASSERT (FALSE);
}
if (OverridePchResetType < PchResetType) {
DEBUG ((EFI_D_INFO, "Previous Pch ResetType is: %x\n", OverridePchResetType));
OverridePchResetType = PchResetType;
}
DEBUG ((EFI_D_INFO, "Current Pch ResetType is: %x\n", OverridePchResetType));
}
}
}
PchResetType = OverridePchResetType;
if ((PchResetType == GlobalReset) || (PchResetType == GlobalResetWithEc)) {
///
/// Let ME do global reset if Me Fw is available
///
Status = HeciSendCbmResetRequest (CBM_RR_REQ_ORIGIN_BIOS_POST, CBM_HRR_GLOBAL_RESET);
if (!EFI_ERROR (Status)) {
///
/// ME Global Reset should fail after EOP is sent.
/// Go to use PCH Reset
///
gBS->Stall (1000000);
}
}
}
mPchReset->Reset (mPchReset, PchResetType);
ASSERT (FALSE);
}
/**
Entry point of Platform Reset driver.
@param[in] ImageHandle Standard entry point parameter
@param[in] SystemTable Standard entry point parameter
@retval EFI_SUCCESS Reset RT protocol installed
@retval All other error conditions encountered result in an ASSERT
**/
EFI_STATUS
InitializePlatformReset (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_HANDLE Handle;
EFI_STATUS Status;
Status = gBS->LocateProtocol (&gPchResetProtocolGuid, NULL, (VOID **) &mPchReset);
ASSERT_EFI_ERROR (Status);
///
/// Make sure the Reset Architectural Protocol is not already installed in the system
///
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);
///
/// Hook the runtime service table
///
SystemTable->RuntimeServices->ResetSystem = PlatformResetSystem;
///
/// Now install the Reset RT AP on a new handle
///
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiResetArchProtocolGuid,
NULL,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status;
}
/**
Fixup internal data pointers so that the services can be called in virtual mode.
@param[in] Event The event registered.
@param[in] Context Event context. Not used in this event handler.
@retval None
**/
EFI_RUNTIMESERVICE
VOID
PchResetVirtualddressChangeEvent (
IN EFI_EVENT Event,
IN VOID *Context
)
{
gRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID *) &mPchReset);
}
|