3 Copyright (c) 2013-2015 Intel Corporation.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 // Include common header file for this module.
19 #include "CommonHeader.h"
22 #include "QNCSmmHelpers.h"
25 // #define BIT_ZERO 0x00000001
27 CONST UINT32 BIT_ZERO
= 0x00000001;
30 // /////////////////////////////////////////////////////////////////////////////
31 // SUPPORT / HELPER FUNCTIONS (QNC version-independent)
35 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
36 CONST IN QNC_SMM_SOURCE_DESC
*Src2
42 GC_TODO: Add function description
46 Src1 - GC_TODO: add argument description
47 Src2 - GC_TODO: add argument description
51 GC_TODO: add return values
59 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
61 // It's okay to compare a NULL bit description to a non-NULL bit description.
62 // They are unequal and these tests will generate the correct result.
64 if (Src1
->En
[loopvar
].Bit
!= Src2
->En
[loopvar
].Bit
||
65 Src1
->En
[loopvar
].Reg
.Type
!= Src2
->En
[loopvar
].Reg
.Type
||
66 Src1
->En
[loopvar
].Reg
.Data
.raw
!= Src2
->En
[loopvar
].Reg
.Data
.raw
81 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
82 CONST IN QNC_SMM_SOURCE_DESC
*Src2
88 GC_TODO: Add function description
92 Src1 - GC_TODO: add argument description
93 Src2 - GC_TODO: add argument description
97 GC_TODO: add return values
106 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
108 // It's okay to compare a NULL bit description to a non-NULL bit description.
109 // They are unequal and these tests will generate the correct result.
111 if (Src1
->Sts
[loopvar
].Bit
!= Src2
->Sts
[loopvar
].Bit
||
112 Src1
->Sts
[loopvar
].Reg
.Type
!= Src2
->Sts
[loopvar
].Reg
.Type
||
113 Src1
->Sts
[loopvar
].Reg
.Data
.raw
!= Src2
->Sts
[loopvar
].Reg
.Data
.raw
128 CONST IN QNC_SMM_SOURCE_DESC
*Src1
,
129 CONST IN QNC_SMM_SOURCE_DESC
*Src2
135 GC_TODO: Add function description
139 Src1 - GC_TODO: add argument description
140 Src2 - GC_TODO: add argument description
144 GC_TODO: add return values
148 return (BOOLEAN
) (CompareEnables (Src1
, Src2
) && CompareStatuses (Src1
, Src2
));
153 CONST IN QNC_SMM_SOURCE_DESC
*Src
159 GC_TODO: Add function description
163 Src - GC_TODO: add argument description
167 GC_TODO: add return values
178 SciEn
= QNCSmmGetSciEn ();
180 if ((Src
->Flags
& QNC_SMM_SCI_EN_DEPENDENT
) && (SciEn
)) {
182 // This source is dependent on SciEn, and SciEn == 1. An ACPI OS is present,
183 // so we shouldn't do anything w/ this source until SciEn == 0.
189 // Read each bit desc from hardware and make sure it's a one
191 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
193 if (!IS_BIT_DESC_NULL (Src
->En
[loopvar
])) {
195 if (ReadBitDesc (&Src
->En
[loopvar
]) == 0) {
208 // Read each bit desc from hardware and make sure it's a one
210 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
212 if (!IS_BIT_DESC_NULL (Src
->Sts
[loopvar
])) {
214 if (ReadBitDesc (&Src
->Sts
[loopvar
]) == 0) {
232 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
238 GC_TODO: Add function description
242 SrcDesc - GC_TODO: add argument description
246 GC_TODO: add return values
253 // Set enables to 1 by writing a 1
255 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
256 if (!IS_BIT_DESC_NULL (SrcDesc
->En
[loopvar
])) {
257 WriteBitDesc (&SrcDesc
->En
[loopvar
], 1);
261 QNCSmmClearSource (SrcDesc
);
266 QNCSmmDisableSource (
267 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
273 GC_TODO: Add function description
277 SrcDesc - GC_TODO: add argument description
281 GC_TODO: add return values
287 for (loopvar
= 0; loopvar
< NUM_EN_BITS
; loopvar
++) {
288 if (!IS_BIT_DESC_NULL (SrcDesc
->En
[loopvar
])) {
289 WriteBitDesc (&SrcDesc
->En
[loopvar
], 0);
296 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
302 GC_TODO: Add function description
306 SrcDesc - GC_TODO: add argument description
310 GC_TODO: add return values
315 BOOLEAN ValueToWrite
;
318 ((SrcDesc
->Flags
& QNC_SMM_CLEAR_WITH_ZERO
) == 0) ? TRUE
: FALSE
;
320 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
321 if (!IS_BIT_DESC_NULL (SrcDesc
->Sts
[loopvar
])) {
322 WriteBitDesc (&SrcDesc
->Sts
[loopvar
], ValueToWrite
);
328 QNCSmmClearSourceAndBlock (
329 CONST QNC_SMM_SOURCE_DESC
*SrcDesc
331 // GC_TODO: function comment should start with '/*++'
333 Sets the source to a 1 or 0 and then waits for it to clear.
334 Be very careful when calling this function -- it will not
335 ASSERT. An acceptable case to call the function is when
336 waiting for the NEWCENTURY_STS bit to clear (which takes
339 // GC_TODO: function comment should end with '--*/'
340 // GC_TODO: function comment is missing 'Routine Description:'
341 // GC_TODO: function comment is missing 'Arguments:'
342 // GC_TODO: function comment is missing 'Returns:'
343 // GC_TODO: SrcDesc - add argument and description to function comment
347 BOOLEAN ValueToWrite
;
350 ((SrcDesc
->Flags
& QNC_SMM_CLEAR_WITH_ZERO
) == 0) ? TRUE
: FALSE
;
352 for (loopvar
= 0; loopvar
< NUM_STS_BITS
; loopvar
++) {
354 if (!IS_BIT_DESC_NULL (SrcDesc
->Sts
[loopvar
])) {
358 WriteBitDesc (&SrcDesc
->Sts
[loopvar
], ValueToWrite
);
361 // Don't return until the bit actually clears.
365 IsSet
= ReadBitDesc (&SrcDesc
->Sts
[loopvar
]);
367 // IsSet will eventually clear -- or else we'll have