summaryrefslogtreecommitdiff
path: root/Chipset/SB/SmmChildDispatchProtocol.c
blob: b56d9254bb3ea02232da639050515d6dacbde21c (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//*************************************************************************
// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher/SmmChildDispatchProtocol.c 2     4/25/12 9:35a Victortu $
//
// $Revision: 2 $
//
// $Date: 4/25/12 9:35a $
//*************************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SmmChildDispatcher/SmmChildDispatchProtocol.c $
// 
// 2     4/25/12 9:35a Victortu
// [TAG]         None
// [Category]    Improvement
// [Description] Reprogram SMM ChildDispatcher drivers.
// [Files]       SmiHandlerGeneric.c; SmiHandlerPorting.c;
// SmiHandlerGeneric2.c; SmmChildDispatch2Main.c; SmmChildDispatcher2.mak;
// SmmChildDispatcher2.sdl; SmmChildDispatch.h; SmmChildDispatchMain.c;
// SmmChildDispatchProtocol.c; SmmChildDispatcher.dxs;
// PchSmiDispatcher.sdl
// 
// 1     2/08/12 8:27a Yurenlai
// Intel Lynx Point/SB eChipset initially releases.
// 
//*************************************************************************
//<AMI_FHDR_START>
//
// Name:        SmmChildDispatchProtocol.c
//
// Description: This file contains SMM Child dispatcher Protocols
//
//<AMI_FHDR_END>
//*************************************************************************

//---------------------------------------------------------------------------
// Include(s)
//---------------------------------------------------------------------------

#include <Token.h>
#include <AmiDxeLib.h>
#include "SmmChildDispatch.h"
#include "SmmChildDispatchProtocol.h"

//---------------------------------------------------------------------------
// Constant, Macro and Type Definition(s)
//---------------------------------------------------------------------------
// Constant Definition(s)

// Macro Definition(s)

// Type Definition(s)

// Function Prototype(s)

//---------------------------------------------------------------------------
// Variable and External Declaration(s)
//---------------------------------------------------------------------------
// Variable Declaration(s)

#if INTEL_RC_SMI_DISPATCHER_SUPPORT == 0
SMM_CHILD_DISPATCHER SmmHandler[] = { 
                                // SwSmmHandler 
                                EfiSmmSwSmi,
                                { SmmSwAddHandler,
                                  SmmSwRemoveHandler,
                                  SmmSwVerifyContext,
                                  SmmSwGetContext,
                                  SmmSwDispatchSmi },
                                { 0, NULL, NULL },

                                // SxSmmHandler
                                EfiSmmSxSmi,
                                { SmmSxAddHandler,
                                  SmmSxRemoveHandler,
                                  SmmSxVerifyContext,
                                  SmmSxGetContext,
                                  SmmSxDispatchSmi },
                                { 0, NULL, NULL },

                                // PeriodicTimerSmmHandler
                                EfiSmmPeriodicTimerSmi,
                                { SmmTimerAddHandler,
                                  SmmTimerRemoveHandler,
                                  SmmTimerVerifyContext,
                                  SmmTimerGetContext,
                                  SmmTimerDispatchSmi },
                                { 0, NULL, NULL },

                                // UsbSmmHandler
                                EfiSmmUsbSmi,
                                { SmmUsbAddHandler,
                                  SmmUsbRemoveHandler,
                                  SmmUsbVerifyContext,
                                  SmmUsbGetContext,
                                  SmmUsbDispatchSmi },
                                { 0, NULL, NULL },

                                // GpiSmmHandler
                                EfiSmmGpiSmi,
                                { SmmGpiAddHandler,
                                  SmmGpiRemoveHandler,
                                  SmmGpiVerifyContext,
                                  SmmGpiGetContext,
                                  SmmGpiDispatchSmi },
                                { 0, NULL, NULL },

                                // SButtonSmmHandler
                                EfiSmmStandbyButtonSmi,
                                { SmmSButtonAddHandler,
                                  SmmSButtonRemoveHandler,
                                  SmmSButtonVerifyContext,
                                  SmmSButtonGetContext,
                                  SmmSButtonDispatchSmi },
                                { 0, NULL, NULL },

                                // PButtonSmmHandler
                                EfiSmmPowerButtonSmi,
                                { SmmPButtonAddHandler,
                                  SmmPButtonRemoveHandler,
                                  SmmPButtonVerifyContext,
                                  SmmPButtonGetContext,
                                  SmmPButtonDispatchSmi },
                                { 0, NULL, NULL },

                                // TcoSmmHandler
                                EfiSmmTcoSmi,
                                { SmmTcoAddHandler,
                                  SmmTcoRemoveHandler,
                                  SmmTcoVerifyContext,
                                  SmmTcoGetContext,
                                  SmmTcoDispatchSmi },
                                { 0, NULL, NULL },

                                // IoTrapSmmHandler
                                EfiSmmIoTrapSmi,
                                { SmmIoTrapAddHandler,
                                  SmmIoTrapRemoveHandler,
                                  SmmIoTrapVerifyContext,
                                  SmmIoTrapGetContext,
                                  SmmIoTrapDispatchSmi },
                                { 0, NULL, NULL },

//********************** PUT ADDITIONAL HANDLERS HERE ***********************
//********************** PUT ADDITIONAL HANDLERS HERE ***********************
//********************** PUT ADDITIONAL HANDLERS HERE ***********************

                                        // Terminator record
                                        EfiSmmMaxSmi,
                                        { NULL, NULL, NULL, NULL, NULL },
                                        { 0, NULL, NULL }
};
#else
SMM_CHILD_DISPATCHER SmmHandler[] = { 
                                // SwSmmHandler 
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // SxSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // PeriodicTimerSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // UsbSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // GpiSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // SButtonSmmHandler
                                EfiSmmStandbyButtonSmi,
                                { SmmSButtonAddHandler,
                                  SmmSButtonRemoveHandler,
                                  SmmSButtonVerifyContext,
                                  SmmSButtonGetContext,
                                  SmmSButtonDispatchSmi },
                                { 0, NULL, NULL },

                                // PButtonSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // TcoSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

                                // IoTrapSmmHandler
                                (EfiSmmMaxSmi + 1),
                                { NULL,
                                  NULL,
                                  NULL,
                                  NULL,
                                  NULL },
                                { 0, NULL, NULL },

//********************** PUT ADDITIONAL HANDLERS HERE ***********************
//********************** PUT ADDITIONAL HANDLERS HERE ***********************
//********************** PUT ADDITIONAL HANDLERS HERE ***********************

                                        // Terminator record
                                        EfiSmmMaxSmi,
                                        { NULL, NULL, NULL, NULL, NULL },
                                        { 0, NULL, NULL }
};
#endif

EFI_SMM_SW_DISPATCH_PROTOCOL gEfiSmmSwDispatchProtocol = \
                                                { EfiSmmSwRegister, \
                                                  EfiSmmSwUnregister, \
                                                  MAX_SW_SMI_INPUT_VALUE };

EFI_SMM_SX_DISPATCH_PROTOCOL gEfiSmmSxDispatchProtocol = \
                                    { EfiSmmSxRegister, EfiSmmSxUnregister };

EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL gEfiSmmPeriodicTimerDispatchProtocol=
                                        { EfiSmmTimerRegister, \
                                          EfiSmmTimerUnregister, \
                                          EfiSmmTimerGetNextShorterInterval };

EFI_SMM_USB_DISPATCH_PROTOCOL gEfiSmmUsbDispatchProtocol = \
                                  { EfiSmmUsbRegister, EfiSmmUsbUnregister };

EFI_SMM_GPI_DISPATCH_PROTOCOL gEfiSmmGpiDispatchProtocol = \
                                                    { EfiSmmGpiRegister, \
                                                      EfiSmmGpiUnregister, \
                                                      SUPPORTED_GPIS };

EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL gEfiSmmStandbyButtonDispatchProtocol=
                            { EfiSmmSButtonRegister, EfiSmmSButtonUnregister };

EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL gEfiSmmPowerButonDispatchProtocol = \
                          { EfiSmmPButtonRegister, EfiSmmPButtonUnregister };

EFI_SMM_TCO_DISPATCH_PROTOCOL gEfiSmmTcoDispatchProtocol = \
                                  { EfiSmmTcoRegister, EfiSmmTcoUnregister };

EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL gEfiSmmIoTrapDispatchProtocol = \
                             { EfiSmmIoTrapRegister, EfiSmmIoTrapUnregister };

// GUID Definition(s)

// Protocol Definition(s)

// External Declaration(s)

extern UINT64 gSupportedIntervals[];

// Function Definition(s)

//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSwRegister
//
// Description: EFI_SMM_SW_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_SW_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSwRegister (
    IN EFI_SMM_SW_DISPATCH_PROTOCOL *This,
    IN EFI_SMM_SW_DISPATCH          Function,
    IN EFI_SMM_SW_DISPATCH_CONTEXT  *Context,
    OUT EFI_HANDLE                  *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmSwSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_SW_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_NOT_FOUND;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSwUnregister
//
// Description: EFI_SMM_SW_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_SW_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSwUnregister (
    IN  EFI_SMM_SW_DISPATCH_PROTOCOL        *This,
    IN  EFI_HANDLE                          Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmSwSmi, Handle );
    return EFI_NOT_FOUND;
}

//---------------------------------------------------------------------------
//                         Sleep SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSxRegister
//
// Description: EFI_SMM_SX_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_SX_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSxRegister (
    IN EFI_SMM_SX_DISPATCH_PROTOCOL *This,
    IN EFI_SMM_SX_DISPATCH          Function,
    IN EFI_SMM_SX_DISPATCH_CONTEXT  *Context,
    OUT EFI_HANDLE                  *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmSxSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_SX_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_NOT_FOUND;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSxUnregister
//
// Description: EFI_SMM_SW_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_SX_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSxUnregister (
    IN EFI_SMM_SX_DISPATCH_PROTOCOL *This,
    IN EFI_HANDLE                   Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmSxSmi, Handle );
    return EFI_NOT_FOUND;
}

//---------------------------------------------------------------------------
//                  Periodic timer SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmTimerRegister
//
// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmTimerRegister (
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH          Function,
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT  *Context,
    OUT EFI_HANDLE                              *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmPeriodicTimerSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_NOT_FOUND;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmTimerUnregister
//
// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the 
//                       EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmTimerUnregister (
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
    IN EFI_HANDLE                               Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmPeriodicTimerSmi, Handle );
    return EFI_NOT_FOUND;;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmTimerGetNextShorterInterval
//
// Description: EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              GetNextShorterInterval function. 
//
// Input:       *This             - Pointer to the
//                                  EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              **SmiTickInterval - Pointer to store pointer to next interval
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmTimerGetNextShorterInterval (
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
    IN OUT UINT64                               **SmiTickInterval )
{
    UINT64 *Result = *SmiTickInterval;

    if (Result == NULL) {
        Result = gSupportedIntervals;
    } else {
        Result++;
    }
    *SmiTickInterval = (*Result == 0) ? NULL : Result;

    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmGetPeriodicTimerSourcesStatus
//
// Description: Gets Periodic Timer sources status.
//
// Input:       None
//
// Output:      BOOLEAN
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

BOOLEAN EfiSmmGetPeriodicTimerSourcesStatus (VOID)
{
//#### Use Intel RC    HANDLER_LINK *Handler = (HANDLER_LINK *)\
//#### Use Intel RC                 SmmHandler[EfiSmmPeriodicTimerSmi].RegisteredCallbacks.pHead;
//#### Use Intel RC    EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *TimerContext;

//#### Use Intel RC    while (Handler != NULL) {
//#### Use Intel RC            TimerContext = \
//#### Use Intel RC                 (EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *)Handler->Context;
//#### Use Intel RC            if (TimerContext->TimerEnabled) return TRUE;

//#### Use Intel RC        Handler = (HANDLER_LINK *)Handler->Link.pNext;
//#### Use Intel RC    }
    return FALSE;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmPeriodicTimerEnable
//
// Description: Enables Periodic Timer SMI.
//
// Input:       *This  - Pointer to the
//                       EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              Handle - Handle to enable
//
// Output:      EFI_STATUS
//                  EFI_NOT_FOUND - The specific handle is not found.
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmPeriodicTimerEnable (
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
    IN EFI_HANDLE                               Handle )
{
//#### Use Intel RC    HANDLER_LINK *Handler = (HANDLER_LINK *)\
//#### Use Intel RC                 SmmHandler[EfiSmmPeriodicTimerSmi].RegisteredCallbacks.pHead;
//#### Use Intel RC    EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *TimerContext;

//#### Use Intel RC    while (Handler != NULL) {
//#### Use Intel RC        if (Handler == Handle) {
//#### Use Intel RC            TimerContext = \
//#### Use Intel RC                 (EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *)Handler->Context;
//#### Use Intel RC            TimerContext->TimerEnabled = TRUE;
//#### Use Intel RC            TimerSmiClear();
//#### Use Intel RC            TimerSmiEnable();
//#### Use Intel RC            return EFI_SUCCESS;
//#### Use Intel RC        }

//#### Use Intel RC        Handler = (HANDLER_LINK *)Handler->Link.pNext;
//#### Use Intel RC    }
    return EFI_NOT_FOUND;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmPeriodicTimerDisable
//
// Description: Disables Periodic Timer SMI.
//
// Input:       *This  - Pointer to the
//                       EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL
//              Handle - Handle to disable
//
// Output:      EFI_STATUS
//                  EFI_NOT_FOUND - The specific handle is not found.
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmPeriodicTimerDisable (
    IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
    IN EFI_HANDLE                               Handle )
{
//#### Use Intel RC    HANDLER_LINK *Handler = (HANDLER_LINK *)\
//#### Use Intel RC                 SmmHandler[EfiSmmPeriodicTimerSmi].RegisteredCallbacks.pHead;
//#### Use Intel RC    EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *TimerContext;

//#### Use Intel RC    while (Handler != NULL) {
//#### Use Intel RC        if (Handler == Handle) {
//#### Use Intel RC            TimerContext = \
//#### Use Intel RC                 (EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT *)Handler->Context;
//#### Use Intel RC            TimerContext->TimerEnabled = FALSE;
//#### Use Intel RC            if (!EfiSmmGetPeriodicTimerSourcesStatus())
//#### Use Intel RC                TimerSmiDisable();
//#### Use Intel RC            return EFI_SUCCESS;
//#### Use Intel RC        }

//#### Use Intel RC        Handler = (HANDLER_LINK *)Handler->Link.pNext;
//#### Use Intel RC    }
    return EFI_NOT_FOUND;
}

//---------------------------------------------------------------------------
//                         USB SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmUsbRegister
//
// Description: EFI_SMM_USB_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_USB_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmUsbRegister (
    IN EFI_SMM_USB_DISPATCH_PROTOCOL    *This,
    IN EFI_SMM_USB_DISPATCH             Function,
    IN EFI_SMM_USB_DISPATCH_CONTEXT     *Context,
    OUT EFI_HANDLE                      *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmUsbSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_USB_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_NOT_FOUND;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmUsbUnregister
//
// Description: EFI_SMM_USB_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_USB_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmUsbUnregister (
    IN EFI_SMM_USB_DISPATCH_PROTOCOL    *This,
    IN EFI_HANDLE                       Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmUsbSmi, Handle );
    return EFI_SUCCESS;
}

//---------------------------------------------------------------------------
//                         GPI SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmGpiRegister
//
// Description: EFI_SMM_GPI_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_GPI_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmGpiRegister (
    IN EFI_SMM_GPI_DISPATCH_PROTOCOL    *This,
    IN EFI_SMM_GPI_DISPATCH             Function,
    IN EFI_SMM_GPI_DISPATCH_CONTEXT     *Context,
    OUT EFI_HANDLE                      *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmGpiSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context,  \
//#### Use Intel RC                            sizeof(EFI_SMM_GPI_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmGpiUnregister
//
// Description: EFI_SMM_GPI_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_GPI_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmGpiUnregister (
    IN EFI_SMM_GPI_DISPATCH_PROTOCOL    *This,
    IN EFI_HANDLE                       Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmGpiSmi, Handle );
    return EFI_SUCCESS;
}

//---------------------------------------------------------------------------
//                    Standby button SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSButtonRegister
//
// Description: EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSButtonRegister (
    IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL *This,
    IN EFI_SMM_STANDBY_BUTTON_DISPATCH          Function,
    IN EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT  *Context,
    OUT EFI_HANDLE                              *Handle )
{
    return RegisterHandler( EfiSmmStandbyButtonSmi, \
                            Function, \
                            Context, \
                            sizeof(EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT), \
                            Handle );
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmSButtonUnregister
//
// Description: EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the
//                       EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmSButtonUnregister (
    IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL *This,
    IN EFI_HANDLE                               Handle )
{
    return UnregisterHandler( EfiSmmStandbyButtonSmi, Handle );
}

//---------------------------------------------------------------------------
//                    Power button SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmPButtonRegister
//
// Description: EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmPButtonRegister (
    IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL   *This,
    IN EFI_SMM_POWER_BUTTON_DISPATCH            Function,
    IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT    *Context,
    OUT EFI_HANDLE                              *Handle )
{
#if INTEL_RC_SMI_DISPATCHER_SUPPORT == 0
    return RegisterHandler( EfiSmmPowerButtonSmi,
                            Function,
                            Context,
                            sizeof(EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT),
                            Handle );
#else
    return EFI_UNSUPPORTED;
#endif
}
//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmPButtonUnregister
//
// Description: EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmPButtonUnregister (
    IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL   *This,
    IN EFI_HANDLE                               Handle )
{
#if INTEL_RC_SMI_DISPATCHER_SUPPORT == 0
    return UnregisterHandler( EfiSmmPowerButtonSmi, Handle );
#else
    return EFI_UNSUPPORTED;
#endif
}

//---------------------------------------------------------------------------
//                         TCO SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmTcoRegister
//
// Description: EFI_SMM_TCO_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_TCO_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmTcoRegister (
    IN EFI_SMM_TCO_DISPATCH_PROTOCOL    *This,
    IN EFI_SMM_TCO_DISPATCH             Function,
    IN EFI_SMM_TCO_DISPATCH_CONTEXT     *Context,
    OUT EFI_HANDLE                      *Handle )
{
//#### Use Intel RC    return RegisterHandler( EfiSmmTcoSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_TCO_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmTcoUnregister
//
// Description: EFI_SMM_TCO_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_TCO_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmTcoUnregister (
    IN EFI_SMM_TCO_DISPATCH_PROTOCOL    *This,
    IN EFI_HANDLE                       Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmTcoSmi, Handle );
    return EFI_SUCCESS;
}

//---------------------------------------------------------------------------
//                       I/O Trap SMI Handler functions
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmIoTrapRegister
//
// Description: EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL Register function.
//
// Input:       *This    - Pointer to EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL
//              Function - Pointer to callback function
//              *Context - Pointer to callback context
//              *Handle  - Pointer to store registered handle
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmIoTrapRegister (
    IN EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL    *This,
    IN EFI_SMM_IO_TRAP_DISPATCH             Function,
    IN EFI_SMM_IO_TRAP_DISPATCH_CONTEXT     *Context,
    OUT EFI_HANDLE                          *Handle )
{
//#### Use Intel RC     return RegisterHandler( EfiSmmIoTrapSmi, \
//#### Use Intel RC                            Function, \
//#### Use Intel RC                            Context, \
//#### Use Intel RC                            sizeof(EFI_SMM_IO_TRAP_DISPATCH_CONTEXT), \
//#### Use Intel RC                            Handle );
    return EFI_SUCCESS;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:   EfiSmmIoTrapUnregister
//
// Description: EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL Unregister function.
//
// Input:       *This  - Pointer to the EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL
//              Handle - Handle to unregister
//
// Output:      EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>

EFI_STATUS EfiSmmIoTrapUnregister (
    IN EFI_SMM_IO_TRAP_DISPATCH_PROTOCOL    *This,
    IN EFI_HANDLE                           Handle )
{
//#### Use Intel RC    return UnregisterHandler( EfiSmmIoTrapSmi, Handle );
    return EFI_SUCCESS;
}

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