3 Copyright (c) 2013-2015 Intel Corporation.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 // Include common header file for this module.
13 #include "CommonHeader.h"
16 #include "QNCSmmHelpers.h"
19 // #define BIT_ZERO 0x00000001
21 CONST UINT32 BIT_ZERO
= 0x00000001;
24 // /////////////////////////////////////////////////////////////////////////////
25 // SUPPORT / HELPER FUNCTIONS (QNC version-independent)
29 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
30 CONST IN QNC_SMM_SOURCE_DESC
*Src2
36 GC_TODO: Add function description
40 Src1 - GC_TODO: add argument description
41 Src2 - GC_TODO: add argument description
45 GC_TODO: add return values
53 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
55 // It's okay to compare a NULL bit description to a non-NULL bit description.
56 // They are unequal and these tests will generate the correct result.
58 if (Src1
->En
[loopvar
].Bit
!= Src2
->En
[loopvar
].Bit
||
59 Src1
->En
[loopvar
].Reg
.Type
!= Src2
->En
[loopvar
].Reg
.Type
||
60 Src1
->En
[loopvar
].Reg
.Data
.raw
!= Src2
->En
[loopvar
].Reg
.Data
.raw
75 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
76 CONST IN QNC_SMM_SOURCE_DESC
*Src2
82 GC_TODO: Add function description
86 Src1 - GC_TODO: add argument description
87 Src2 - GC_TODO: add argument description
91 GC_TODO: add return values
100 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
102 // It's okay to compare a NULL bit description to a non-NULL bit description.
103 // They are unequal and these tests will generate the correct result.
105 if (Src1
->Sts
[loopvar
].Bit
!= Src2
->Sts
[loopvar
].Bit
||
106 Src1
->Sts
[loopvar
].Reg
.Type
!= Src2
->Sts
[loopvar
].Reg
.Type
||
107 Src1
->Sts
[loopvar
].Reg
.Data
.raw
!= Src2
->Sts
[loopvar
].Reg
.Data
.raw
122 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
123 CONST IN QNC_SMM_SOURCE_DESC
*Src2
129 GC_TODO: Add function description
133 Src1 - GC_TODO: add argument description
134 Src2 - GC_TODO: add argument description
138 GC_TODO: add return values
142 return (BOOLEAN
) (CompareEnables (Src1
, Src2
) && CompareStatuses (Src1
, Src2
));
147 CONST IN QNC_SMM_SOURCE_DESC
*Src
153 GC_TODO: Add function description
157 Src - GC_TODO: add argument description
161 GC_TODO: add return values
172 SciEn
= QNCSmmGetSciEn ();
174 if ((Src
->Flags
& QNC_SMM_SCI_EN_DEPENDENT
) && (SciEn
)) {
176 // This source is dependent on SciEn, and SciEn == 1. An ACPI OS is present,
177 // so we shouldn't do anything w/ this source until SciEn == 0.
183 // Read each bit desc from hardware and make sure it's a one
185 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
187 if (!IS_BIT_DESC_NULL (Src
->En
[loopvar
])) {
189 if (ReadBitDesc (&Src
->En
[loopvar
]) == 0) {
202 // Read each bit desc from hardware and make sure it's a one
204 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
206 if (!IS_BIT_DESC_NULL (Src
->Sts
[loopvar
])) {
208 if (ReadBitDesc (&Src
->Sts
[loopvar
]) == 0) {
226 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
232 GC_TODO: Add function description
236 SrcDesc - GC_TODO: add argument description
240 GC_TODO: add return values
247 // Set enables to 1 by writing a 1
249 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
250 if (!IS_BIT_DESC_NULL (SrcDesc
->En
[loopvar
])) {
251 WriteBitDesc (&SrcDesc
->En
[loopvar
], 1);
255 QNCSmmClearSource (SrcDesc
);
260 QNCSmmDisableSource (
261 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
267 GC_TODO: Add function description
271 SrcDesc - GC_TODO: add argument description
275 GC_TODO: add return values
281 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
282 if (!IS_BIT_DESC_NULL (SrcDesc
->En
[loopvar
])) {
283 WriteBitDesc (&SrcDesc
->En
[loopvar
], 0);
290 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
296 GC_TODO: Add function description
300 SrcDesc - GC_TODO: add argument description
304 GC_TODO: add return values
309 BOOLEAN ValueToWrite
;
312 ((SrcDesc
->Flags
& QNC_SMM_CLEAR_WITH_ZERO
) == 0) ? TRUE
: FALSE
;
314 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
315 if (!IS_BIT_DESC_NULL (SrcDesc
->Sts
[loopvar
])) {
316 WriteBitDesc (&SrcDesc
->Sts
[loopvar
], ValueToWrite
);
322 QNCSmmClearSourceAndBlock (
323 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
325 // GC_TODO: function comment should start with '/*++'
327 Sets the source to a 1 or 0 and then waits for it to clear.
328 Be very careful when calling this function -- it will not
329 ASSERT. An acceptable case to call the function is when
330 waiting for the NEWCENTURY_STS bit to clear (which takes
333 // GC_TODO: function comment should end with '--*/'
334 // GC_TODO: function comment is missing 'Routine Description:'
335 // GC_TODO: function comment is missing 'Arguments:'
336 // GC_TODO: function comment is missing 'Returns:'
337 // GC_TODO: SrcDesc - add argument and description to function comment
341 BOOLEAN ValueToWrite
;
344 ((SrcDesc
->Flags
& QNC_SMM_CLEAR_WITH_ZERO
) == 0) ? TRUE
: FALSE
;
346 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
348 if (!IS_BIT_DESC_NULL (SrcDesc
->Sts
[loopvar
])) {
352 WriteBitDesc (&SrcDesc
->Sts
[loopvar
], ValueToWrite
);
355 // Don't return until the bit actually clears.
359 IsSet
= ReadBitDesc (&SrcDesc
->Sts
[loopvar
]);
361 // IsSet will eventually clear -- or else we'll have