]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkNorthCluster/Smm/DxeSmm/QncSmmDispatcher/QNC/QNCSmmSw.c
QuarkSocPkg/QncSmmDispatcher: Fix context passed to SMI handlers
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / Smm / DxeSmm / QncSmmDispatcher / QNC / QNCSmmSw.c
CommitLineData
9b6bbcdb
MK
1/** @file\r
2File to contain all the hardware specific stuff for the Smm Sw dispatch protocol.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14\r
15**/\r
16\r
17//\r
18// Include common header file for this module.\r
19//\r
20#include "CommonHeader.h"\r
21\r
22#include "QNCSmmHelpers.h"\r
23\r
24EFI_SMM_CPU_PROTOCOL *mSmmCpu = NULL;\r
25\r
26CONST QNC_SMM_SOURCE_DESC SW_SOURCE_DESC = {\r
27 QNC_SMM_NO_FLAGS,\r
28 {\r
29 {\r
30 {GPE_ADDR_TYPE, {R_QNC_GPE0BLK_SMIE}}, S_QNC_GPE0BLK_SMIE, N_QNC_GPE0BLK_SMIE_APM\r
31 },\r
32 NULL_BIT_DESC_INITIALIZER\r
33 },\r
34 {\r
35 {\r
36 {GPE_ADDR_TYPE, {R_QNC_GPE0BLK_SMIS}}, S_QNC_GPE0BLK_SMIS, N_QNC_GPE0BLK_SMIS_APM\r
37 }\r
38 }\r
39};\r
40\r
41VOID\r
42SwGetContext(\r
43 IN DATABASE_RECORD *Record,\r
44 OUT QNC_SMM_CONTEXT *Context\r
45 )\r
46{\r
47 Context->Sw.SwSmiInputValue = IoRead8 (R_APM_CNT);\r
48}\r
49\r
50BOOLEAN\r
51SwCmpContext (\r
52 IN QNC_SMM_CONTEXT *Context1,\r
53 IN QNC_SMM_CONTEXT *Context2\r
54 )\r
55{\r
56 return (BOOLEAN)( Context1->Sw.SwSmiInputValue == Context2->Sw.SwSmiInputValue );\r
57}\r
58\r
59VOID\r
60SwGetBuffer (\r
61 IN DATABASE_RECORD * Record\r
62 )\r
63{\r
64 EFI_STATUS Status;\r
65 UINTN Index;\r
66 UINTN CpuIndex;\r
67 EFI_SMM_SAVE_STATE_IO_INFO IoState;\r
68\r
69 //\r
70 // Locate SMM CPU protocol to retrieve the CPU save state\r
71 //\r
72 if (mSmmCpu == NULL) {\r
73 Status = gSmst->SmmLocateProtocol (&gEfiSmmCpuProtocolGuid, NULL, (VOID **) &mSmmCpu);\r
74 ASSERT_EFI_ERROR (Status);\r
75 }\r
76\r
77 //\r
78 // Find the CPU which generated the software SMI\r
79 //\r
80 CpuIndex = 0;\r
81 for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {\r
82 Status = mSmmCpu->ReadSaveState (\r
83 mSmmCpu,\r
84 sizeof (EFI_SMM_SAVE_STATE_IO_INFO),\r
85 EFI_SMM_SAVE_STATE_REGISTER_IO,\r
86 Index,\r
87 &IoState\r
88 );\r
89 if (!EFI_ERROR (Status) && (IoState.IoPort == R_APM_CNT)) {\r
90 CpuIndex = Index;\r
91 break;\r
92 }\r
93 }\r
94\r
95 Record->CommBuffer.Sw.SwSmiCpuIndex = CpuIndex;\r
96}\r