summaryrefslogtreecommitdiff
path: root/EDK/MiniSetup/uefi2.1/FormBrowser2.c
blob: 700bcc2d50b83f3f531efbcb19dea79659af8146 (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
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
//**********************************************************************
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2013, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**     5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//*****************************************************************//
// $Archive: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.c $
//
// $Author: Premkumara $
//
// $Revision: 35 $
//
// $Date: 8/28/14 12:24p $
//
//*****************************************************************//
//*****************************************************************//
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/AMITSE2_0/AMITSE/Uefi2.1/FormBrowser2.c $
// 
// 35    8/28/14 12:24p Premkumara
// [TAG] 	EIP175017
// [Category] Bug Fix
// [Severity:] Normal
// [Symptom:] Setup hangs when sendform called from oemdriverhealth module
// [Solution] 	TSE installs timer to read the keys in conin availability.
// This timer stopped in PostManagerHandshake but if mainsetuploop called
// from sendform then this timer not stopped so hang happened in different
// stages.So stopping timer properly resolves the issue.
// [Files] 	FormBrowser2.c
// 
// 34    2/11/14 8:50p Arunsb
// [TAG]	EIP147816
// [Category]	Bug Fix
// [Symptom]	Having same two formset with two different handles, confirm
// checkbox is grayed out in one formset not in other
// [Root Cause]	During BrowserCallback, the current context
// [gCurrVarHandle and gCurrVarIndex] is lost due to multiple pack updates
// within a single callback.
// [Solution]	Maintain a stack to preserve the current context values for
// (gCurrVarHandle and gCurrVarIndex) during BrowserCallback
// [Files]	FormBrowser2.c
// 
// 33    12/04/13 3:43p Premkumara
// [TAG]	EIP144581
// [Category]	Bug Fix
// [Severity:]	Important
// [Symptom:]	TSE gets Hangs when HiiLibSetBrowserData try to update
// LegacyDevOrder
// [Root Cause]	LegacyBootData is setting irrespective of valid options
// [Solution]	Validating LegacyBootData for valid options and save valid
// options.
// [Files]	FormBrowser2.c
// 
// 32    5/15/13 4:50a Premkumara
// [TAG]  		EIP123312 
// [Category]  	Bug Fix
// [Severity]  	Important
// [Symptom]  	Build error when token  TSE_DEBUG_MESSAGE is enabled
// [RootCause]  	Parameter missed to pass to a function  WriteDataToFile()
// [Solution]  	Passed valid parameter to WriteDataToFile()
// [Files]  		FormBrowser2.c
// 
// 31    4/18/13 2:23a Arunsb
// [TAG]  		EIP113266
// [Category]  	Improvement
// [Description]  	gBrowserCallbackEnabled variable moved to boot only
// module
// [Files]  		boot.c and FormBrowser2.c
// 
// 30    2/25/13 10:57a Blaines
// [TAG] - EIP 104273
// [Category] - Action Item
// [Description] -  Provide ability to dump the Hii Pack from the Setup as
// part TSE debug Infrastructure. It should dump the Pack updates on Hii
// notification also.
// So it can be used to debug the issue.
// [Files] - ForBrowser2.c,  Hii.c,  HiiNotificationHandler.c,
// UefiWapper.c,  TseUefiHii.h
// 
// 29    10/18/12 6:04a Arunsb
// Updated for 2.16.1235 QA submission
// 
// 12    10/10/12 12:41p Arunsb
// Synched the source for v2.16.1232, backup with Aptio
// 
// 27    9/20/12 11:15a Arunsb
// SendForm will operate only with SETUP_FORM_BROWSER_SUPPORT token
// enabled.
// 
// 26    5/29/12 3:10a Premkumara
// Added missing version-23 (EIP-90895) changes
// 
// 25    5/28/12 9:55a Premkumara
// Added missing version-23 (EIP-90895) changes
// 
// 24    5/28/12 5:56a Premkumara
// [TAG]  		EIP75236
// [Category]  	Improvement
// [Description]  	Add the support to control the GOP dependency in TSE
// notification.
// [Files]  		AMITSE.sdl, CommonHelper.c, Notify.c, Minisetup.h,
// Minisetup.sdl, protocol.c, FormBrowser.c, FormBrowser2.c
// 
// 23    5/26/12 5:35a Arunsb
// [TAG]  		EIP90895
// [Category]  	Bug Fix
// [Severity]  	Normal
// [Symptom]  	Setup hangs when retrieve callback produces
// add/remove/update forms
// [RootCause]  	Callback with retrieve action produces add/remove/update
// form
// [Solution]  	If retrieve callback produces add/remove/update form then
// TSE will print debug messages and assert.
// [Files]  		HiiNotificationHandler.c, HiiCallback.c and FormBrowser2.c
// 
// 22    2/03/12 1:31p Arunsb
// [TAG]  		EIP81617 
// [Category]  	Improvement
// [Description]  	Avoiding memory leaks in TSE
// [Files]  		hiistring21.c, CommonHelper.c, notify.c and formbrowser2.c
// 
// 21    1/20/12 5:33a Rajashakerg
// [TAG]  		EIP75567
// [Category]  	Improvement
// [Description]  	Provide ActionRequest in SendForm function
// [Files]  		FormBrowser2.c
// 
// 20    12/07/11 3:31p Arunsb
// [TAG]  		EIP75588
// [Category]  	New Feature
// [Description]  	Support for queuing UpdatePack notifications
// [Files]  		frame.c, page.c, formbrowser2.c, hii.c, hiicallback.c,
// hiinotificationhandler.c, tseuefihii.h and uefi21wapper.c
// 
// 19    12/07/11 8:12a Rajashakerg
// [TAG]  		EIP75118 
// [Category]  	Improvement
// [Description]  	xtractConfig() fail since BrowserCallback() cannot find
// the variable to process
// [Files]  		FormBrowser2.c, FormBrowser2.h, HiiCallback.c,
// Uefi21Wapper.c, PopupSel.c
// 
// 18    12/05/11 5:53a Rajashakerg
// [TAG]  		EIP76381 
// [Category]  	Improvement
// [Description]  	Performance: Improving variable data load and usage
// [Files]  		callback.c, minisetupext.c, variable.c, variable.h,
// minisetup.h, Hii.c, FormBrowser2.c
// 
// 17    11/30/11 1:37p Premkumara
// [TAG]  		EIP75352
// [Category]  	Improvement
// [Description]  	Suppress the warnings from static code analyzer
// [Files]  		Boot.c, bbs.c, TseAdvanced.c, Special.c, Variable.c,
// TseLiteHelper.c, PopupSel.c, AddBootOption.c, Hii.c, FormBrowser2.c
// 
// 16    11/28/11 2:27a Premkumara
// [TAG]  		EIP75384 
// [Category]  	Improvement
// [Description]  	Suppress the warnings from static code analyzer
// [Files]  		UefiWapper.c, Hii.c, Expression.c, CtrlCond.c, PopupSel.c,
// Minisetupext.c, Menu.c, Date.c, Ezport\Stylecommon.c,
// EzportPlus\StyleCommon.c,
// 
// 15    11/23/11 5:13a Rajashakerg
// [TAG]  		EIP75473 
// [Category]  	Improvement
// [Description]  	System Time is not updated every second
// [Files]  		variable.h, variable.c, FormBrowser2.c, TseUefiHii.h,
// Uefi21Wapper.c, hii.h, uefi20Wapper.c
// 
// 14    11/21/11 5:55a Rajashakerg
// [TAG]  		EIP74591
// [Category]  	Improvement
// [Description]  	Make MainSetupLoop as board module hook
// [Files]  		AMITSE.sdl, CommonHelper.c, protocol.c, minisetup.h,
// FormBrowser.c, FormBrowser2.c
// 
// 13    11/14/11 2:43p Blaines
// [TAG] - EIP 75481
// [Category]- Function Request
// [Synopsis]- TSE debug print infrastructure.
// [Description]- Add TSE debug print info for basic functions such as
// Hiiparsing, HiiNotifications, HiiCallbacks. Variables, and Ifrforms
// data. 
// [Files]
// AMITSE.sdl, AmiTSEStr.uni,  CommonHelper.c, commonoem.c, FakeTokens.c
// Globals.c, Minisetup.cif, Minisetup.h, print.c, FormBrowser2.c, Hii.c,
// HiiCallback.c, HiiNotificationHandler.c, Parse.c, TseUefiHii.h,
// Uefi21Wrapper.c, setupdbg.h
// 
// 12    11/08/11 4:50a Rajashakerg
// Lowered the TPL to Application level and invoked
// StyleUpdateVersionString() function to update the copy right string in
// the SendForm() function.
// 
// 11    6/30/11 11:55a Arunsb
// Adding config header in config string is controlled by
// EDKVersion_1_05_RetrieveData wrapper function.
// 
// 10    6/30/11 4:16a Arunsb
// [TAG]           EIP57661
// [Category]      New Feature
// [Description]   Boot manager algorithm for interaction with Driver
// Health protocol.
//                 gFSetGuid added to compare in parseform.
// [Files]         amitse.cif, amitse.sdl, faketokens.c, amitsestr.uni,
//                 commonhelper.c, uefisetup.ini, tsedrvhealth.h,
// amivfr.h, minisetupbin.mak,
//                 hiistring21.c, hiistring20.c, tseadvanced.c, special.c,
// special.h, boot.h, minisetup.h,
//                 uefi20wapper.c, formbrowser2.c, hii.c, parse.c and
// uefi21wapper.c.
// 
// 9     3/28/11 6:00p Madhans
// [TAG]  		EIP56247 
// [Category]  	Improvement
// [Description]  	To support BrowserCallback with ResultData=NULL.
// To to add EDK_1_05_RETRIEVE_DATA SDL on by default for UEFI OptionROM
// cards to work.
// Need Core changes if EDK_1_05_RETRIEVE_DATA=1. 
// EDK_1_05_RETRIEVE_DATA=0 May cause UEFI Option ROM card to not work ok.
// 
// [Files]  		Uefi21.sdl
// FormBrowser2.c
// 
// 8     12/02/10 5:51p Madhans
// [TAG] - EIP 48169    
// [Category]- Improvment.
// [Severity]- Mordarate
// [Symptom]- To do the Workaround for ConfigtoBlock issues and Fix issues
// with Retirive config.
// [Solution]- Fix done formBrowser2.c and uefi21wrapper.c 
// [Files] - formBrowser2.c and uefi21wrapper.c 
// 
// 7     9/16/10 8:38p Madhans
// Update for TSE 2.10. Refer Changelog.log for more details.
// 
// 9     9/15/10 1:55p Madhans
// To fix the issue with TSE when SetBrowser data is called. Without this
// fix always lastbyte of set browser data is missed.
// 
// 8     6/17/10 2:58p Madhans
// Exit safely when sendform is not supported.
// 
// 7     3/11/10 5:42p Madhans
// Coding Standards Update
//
// 6     2/26/10 6:57p Madhans
// To validate the Hii Handle before trying to process it.
//
// 5     2/19/10 8:35p Madhans
// Function header fix
//
// 4     1/12/10 11:10a Presannar
// Modified code to return BrowserCallback String according to either EDK
// browser or spec
//
// 3     1/08/10 4:43p Presannar
// Fixed BrowserCallback to return EFI_INVALID_PARAMETER when ResultsData
// is NULL and *ResultsDataSize != 0
//
// 2     11/19/09 5:28p Presannar
// Updated TSE include file name to not clash with CORE file
//
// 1     7/24/09 6:54p Presannar
//
// 3     3/31/09 4:15p Madhans
// UEFI Wrapper improvments.
//
// 2     1/29/09 6:06p Presannar
// Added Function Header Comments
//
// 1     1/09/09 2:38p Presannar
// UEFI 2.1 Hii Related Code - Initial Drop
//
// 1     12/29/08 4:46p Presannar
// FormBrowser2 protocol Send Form and BrowserCallback initial draft
//
//*************************************************************************
//<AMI_FHDR_START>
//
// Name:          FormBrowser2.C
//
// Description:
//
//<AMI_FHDR_END>
//*************************************************************************

//----------------------------------------------------------------------------
#include "Minisetup.h"
#include "FormBrowser2.h"
#include "TseUefiHii.h"
//----------------------------------------------------------------------------
extern BOOLEAN gPackUpdatePending;
extern BOOLEAN gEnableDrvNotification; //TRUE if allow notification function to process action, FALSE to ignore the notification
extern UINTN HpkFileCount;
//---------------------------------------------------------------------------
// Variables
//---------------------------------------------------------------------------
BOOLEAN gRequireSysReboot = FALSE; //EIP 75567 :If TRUE, ACTION_REQUEST_RESET will be returned from SendForm, else ignore reboot
VOID    **gSfHandles;
UINTN   gSfHandleCount;
EFI_GUID *gFSetGuid = NULL;
UINT8 *gSfNvMap;
extern BOOLEAN gBrowserCallbackEnabled; //EIP113266 Allow external drivers to change ASL cache only if it's TRUE; ignore browser callback otherwise
extern BOOLEAN gEnterSetup;
extern EFI_EVENT gKeyTimer;
EFI_BROWSER_ACTION gBrowserCallbackAction = 0 ;//Contains the BrowserCallback action when a callback is in progress.
//static CONTROL_INFO *gCallbackControl = NULL; unused
static EFI_HANDLE gCurrVarHandle = (EFI_HANDLE)NULL;
static UINT32 gCurrVarIndex = 0;
#define BROWSERCALLBACK_MAX_ENTRIES 10
static EFI_HANDLE  gCallBackHandleStack[BROWSERCALLBACK_MAX_ENTRIES]; //EIP-147816
static UINT32 gCallBackVarIndexStack[BROWSERCALLBACK_MAX_ENTRIES];//EIP-147816

EFI_GUID gEfiFormBrowser2ProtocolGuid = EFI_FORM_BROWSER2_PROTOCOL_GUID;

//---------------------------------------------------------------------------
// Structure
//---------------------------------------------------------------------------
EFI_FORM_BROWSER2_PROTOCOL FormBrowser2 =
{
  SendForm,
  BrowserCallback
};

//---------------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------------
EFI_STATUS _StorageToConfigResp(VARIABLE_INFO *VariableInfo, VOID *Buffer, CHAR16 *ConfigHdr, CHAR16 **ConfigResp);
EFI_STATUS _ConfigRespToStorage(VARIABLE_INFO *varInfo, UINT8 **buffer, UINTN *Size, EFI_STRING configResp);
BOOLEAN EDKVersion_1_05_RetrieveData (VOID);
EFI_STATUS CleanNotificationQueue (VOID);
//---------------------------------------------------------------------------
// Function Implementation
//---------------------------------------------------------------------------

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:	SetCallBackControlInfo
//
// Description:	Set the variable inforamtion
//
// Parameter:	EFI_HANDLE VarHandle - Variable handle to process
//              UINT32 VarIndex - Variable index in the gVariables->VariableList
//
// Return value:VOID
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID SetCallBackControlInfo(EFI_HANDLE VarHandle, UINT32 VarIndex)
{
    static int ContextVar=0;
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] Entering SetCallBackControlInfo, HIIHandle =%x \n\n", VarHandle ); 
    if(VarHandle != NULL){ //If the varaible handle is valid, set handle and variable index
        if(ContextVar >= BROWSERCALLBACK_MAX_ENTRIES)
        {
            SETUP_DEBUG_TSE ("\n[TSE] Too many nested Browser Callbacks!\n\n");
            ASSERT (0);    
        }
        gCurrVarHandle = VarHandle;
        gCurrVarIndex = VarIndex;
        //EIP-147816
        //Use Stack to manage gCurrVarHandle and gCurrVarIndex
        gCallBackHandleStack[ContextVar] = gCurrVarHandle;
        gCallBackVarIndexStack[ContextVar] = gCurrVarIndex;
        ContextVar++;
        
    } else{ //Else reset global the varaible handle and variable index
	
        if(ContextVar == 0)
            return;
                    
        ContextVar--;
        
        if(ContextVar == 0)
        {
            gCurrVarHandle = (EFI_HANDLE)NULL;
            gCurrVarIndex = 0;
        }else{
            //EIP-147816
            //Reset gCurrVarHandle and gCurrVarIndex to previous stack entry
            gCurrVarHandle = gCallBackHandleStack[ContextVar-1] ;
            gCurrVarIndex = gCallBackVarIndexStack[ContextVar-1] ;
        }
            
    }
    
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] Exiting SetCallBackControlInfo HIIHandle =%x \n\n", VarHandle ); 
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:	InstallFormBrowserProtocol
//
// Description:	Install FormBrowser Protocol
//
// Parameter:	EFI_HANDLE Handle
//
// Return value:EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS InstallFormBrowserProtocol(EFI_HANDLE Handle)
{
  EFI_STATUS status = EFI_SUCCESS;

  UnInstallFormBrowserProtocol(Handle);
  status = gBS->InstallMultipleProtocolInterfaces (
                  &Handle,
                  &gEfiFormBrowser2ProtocolGuid,
                  &FormBrowser2,
                  NULL
                  );

  return status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
//
// Procedure:	UnInstallFormBrowserProtocol
//
// Description:	UnInstall FormBrowser Protocol
//
// Parameter:	EFI_HANDLE Handle
//
// Return value:VOID
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
VOID UnInstallFormBrowserProtocol(EFI_HANDLE Handle)
{
  EFI_STATUS status = EFI_SUCCESS;
  EFI_HANDLE handle;
  VOID *iface;
  UINTN size = 0;

  status = gBS->LocateHandle (
                    ByProtocol,
                    &gEfiFormBrowser2ProtocolGuid,
                    NULL,
                    &size,
                    &handle
                    );
  if(status == EFI_BUFFER_TOO_SMALL)
  {
    handle = EfiLibAllocateZeroPool(size);
    if (handle == NULL)
    {
      status = EFI_OUT_OF_RESOURCES;
      goto DONE;
    }

    status = gBS->LocateHandle (
                      ByProtocol,
                      &gEfiFormBrowser2ProtocolGuid,
                      NULL,
                      &size,
                      &handle
                      );
  }

  if(EFI_ERROR(status))
  {
    goto DONE;
  }
  status = gBS->LocateProtocol (
                    &gEfiFormBrowser2ProtocolGuid,
                    NULL,
                    &iface
                    );
  if(EFI_ERROR(status))
  {
    goto DONE;
  }
  status = gBS->UninstallMultipleProtocolInterfaces (
                  handle,
                  &gEfiFormBrowser2ProtocolGuid,
                  iface,
                  NULL
                  );

  if(EFI_ERROR(status))
  {
    goto DONE;
  }

DONE:
  return;
}

//<AMI_PHDR_START>
//---------------------------------------------------------------------------
// Procedure:   SendForm
//
// Description: This is the routine which an external caller uses to direct
//				the browser where to obtain it's information.
//
// Input:	EFI_FORM_BROWSER2_PROTOCOL *This - The Form Browser protocol instanse.
//          EFI_HII_HANDLE *Handles - A pointer to an array of Handles. If
//                  HandleCount > 1 we display a list of the formsets for the
//                  handles specified.
//          UINTN HandleCount - The number of Handles specified in Handle.
//          EFI_GUID *FormSetGuid [OPTIONAL] - This field points to the EFI_GUID
//                  which must match the Guid field in the EFI_IFR_FORM_SET
//                  op-code for the specified forms-based package. If
//                  FormSetGuid is NULL, then this function will display the
//                  first found forms package.
//          UINT16 FormId [OPTIONAL] - This field specifies which EFI_IFR_FORM
//                  to render as the first displayable page. If this field has
//                  a value of 0x0000, then the forms browser will render the
//                  specified forms in their encoded order.
//          EFI_SCREEN_DESCRIPTOR *ScreenDimenions [OPTIONAL] - Points to
//                  recommended form dimensions, including any non-content
//                  area, in characters. This allows the browser to be called
//                  so that it occupies a portion of the physical screen
//                  instead of dynamically determining the screen dimensions.
//          EFI_BROWSER_ACTION_REQUEST *ActionRequest [OPTIONAL] - Points to
//                  the action recommended by the form.
//
// Output:	EFI_STATUS status - EFI_SUCCESS, The function completed successfully.
//			EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
//			EFI_NOT_FOUND - No valid forms could be found to display.
//---------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS
EFIAPI
SendForm (
  IN  CONST EFI_FORM_BROWSER2_PROTOCOL *This,
  IN  EFI_HII_HANDLE                   *Handles,
  IN  UINTN                            HandleCount,
  IN  EFI_GUID                         *FormSetGuid, OPTIONAL
  IN  UINT16                           FormId, OPTIONAL
  IN  CONST EFI_SCREEN_DESCRIPTOR      *ScreenDimensions, OPTIONAL
  OUT EFI_BROWSER_ACTION_REQUEST       *ActionRequest  OPTIONAL
  )
{
	EFI_STATUS Status = EFI_SUCCESS;
	UINTN i;
	BOOLEAN BackUpgEnterSetup = FALSE;

#if !SETUP_FORM_BROWSER_SUPPORT
	SETUP_DEBUG_TSE ("[TSE] SendForm not supported with SETUP_FORM_BROWSER_SUPPORT token disabled\n");
	return EFI_UNSUPPORTED;
#endif

	if(gApp != NULL || gSetupContextActive)
	{
		// Inside Setup. Setupdata contexts valid.
		UINT8 Sel=0;
		
		AMI_POST_MANAGER_PROTOCOL 	*PostMgr = NULL;
		    	
		Status = gBS->LocateProtocol(&gAmiPostManagerProtocolGuid, NULL,(void**) &PostMgr);
		if(Status == EFI_SUCCESS)
		{
			//PostManagerDisplayMsgBox (L"SendForm Unsupported",L"SendForm Not suppored Nestedly or from Valid Setup Context!",MSGBOX_TYPE_OK,&Sel);
			PostMgr->DisplayMsgBox(  L"SendForm Unsupported",  L"SendForm Not suppored Nestedly or from Valid Setup Context!", MSGBOX_TYPE_OK,NULL);
		}
		return EFI_UNSUPPORTED;
	}

	if( Handles == NULL || HandleCount == 0 )
	{
		Status = EFI_INVALID_PARAMETER;
		goto DONE;
	}

#ifndef STANDALONE_APPLICATION
    if ( ! gConsoleControl )
    {
        //All necessary protocols are not available yet.
        //We can still proceed if Uga Draw is the only protocol not available yet.
        ActivateApplication();

			if (!IsDelayLogoTillInputSupported())	//EIP-75236
				ActivateInput();
    }
#endif

	//Initialize send form global variables
	if(HandleCount)
	{
		gSfHandles = EfiLibAllocateZeroPool( HandleCount * sizeof(VOID*));
		gSfHandleCount = 0;
        gFSetGuid = FormSetGuid;
		for(i=0;i<HandleCount;i++)
		{
			UINT8 *FormSet = NULL;
			UINTN Length = 0;

			// Check if the Handle Has Forms to Display
			FormSet = HiiGetForm( Handles[i], 0, &Length);
			if( FormSet != NULL )
			{
				gSfHandles[gSfHandleCount] = (VOID*)(UINTN)Handles[i];
				MemFreePointer( &FormSet );
				gSfHandleCount++;
			}
		}
		if( gSfHandleCount == 0 )
		{
			MemFreePointer( (VOID**)&gSfHandles );
			Status = EFI_NOT_FOUND;
			goto DONE;
		}
	}
	gSfNvMap = NULL;//NvMapOverride;

    if(!gVariableList)
	{
	    CleanTempNvramVariableList();//EIP 76381 : Reset to read the variable from NVRAM
        VarLoadVariables( (VOID **)&gVariableList, NULL );
	}
	// this *MUST* be run a EFI_TPL_APPLICATION
	gBS->RaiseTPL( EFI_TPL_HIGH_LEVEL );	// guarantees that RestoreTPL won't ASSERT
	gBS->RestoreTPL( EFI_TPL_APPLICATION );

	StyleUpdateVersionString();

	//Show forms
	Status = gST->ConIn->Reset( gST->ConIn, FALSE );
	BackUpgEnterSetup = gEnterSetup; //EIP-175017
	if (gKeyTimer)
	{
		TimerStopTimer( &gKeyTimer );
	}
	Status = MainSetupLoopHook();//EIP74591 : Modified MainSetupLoop as board module hook
	gEnterSetup = BackUpgEnterSetup;

	//Reset send form global variables
	//gSfHandles = (VOID**)NULL;
	MemFreePointer( (VOID**)&gSfHandles );
	gSfHandles = NULL;

	gSfHandleCount = 0;
	gSfNvMap = NULL;

DONE:

	if(gRequireSysReboot){ //EIP 75567 : If system reboot was set, return ACTION_REQUEST_RESET
		if(ActionRequest)
			*ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;
		gRequireSysReboot = FALSE; //EIP 75567  :Reset system reboot variable
	}
	if(gPackUpdatePending) //If IFR notifications are pending clear the queue before exiting SendForm
	{
		CleanNotificationQueue();
	}
	gPackUpdatePending = FALSE;
	CleanTempNvramVariableList();//EIP 76381 : Reset to read the variable from NVRAM
	return Status;
}

//<AMI_PHDR_START>
//---------------------------------------------------------------------------
// Procedure:   BrowserCallback
//
// Description: This function is called by a callback handler to retrieve
//              uncommitted state data from the browser.
//
// Input:   
//          IN CONST EFI_FORM_BROWSER2_PROTOCOL *This - A pointer to the
//                  EFI_FORM_BROWSER2_PROTOCOL instance.
//          IN OUT UINTN *ResultsDataSize - A pointer to the size of the
//                  buffer associated with ResultsData.
//          IN OUT EFI_STRING ResultsData - A string returned from an IFR
//                  browser or equivalent. The results string will have no
//                  routing information in them.
//          IN BOOLEAN RetrieveData - A BOOLEAN field which allows an agent
//                  to retrieve (if RetrieveData = TRUE) data from the
//                  uncommitted browser state information or set 
//                  (if RetrieveData = FALSE) data in the uncommitted browser
//                  state information.
//          IN CONST EFI_GUID *VariableGuid, OPTIONAL - An optional field to
//                  indicate the target variable GUID name to use.
//          IN CONST CHAR16 *VariableName  OPTIONAL - An optional field to
//                  indicate the target human-readable variable name.
//
// Output:  EFI_STATUS status - EFI_SUCCESS, The results have been distributed
//                          or are awaiting distribution.
//                              EFI_BUFFER_TOO_SMALL, The ResultsDataSize
//                          specified was too small to contain the results data.
//---------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS
EFIAPI
BrowserCallback (
  IN CONST EFI_FORM_BROWSER2_PROTOCOL  *This,
  IN OUT UINTN                         *ResultsDataSize,
  IN OUT EFI_STRING                    ResultsData,
  IN BOOLEAN                           RetrieveData,
  IN CONST EFI_GUID                    *VariableGuid, OPTIONAL
  IN CONST CHAR16                      *VariableName  OPTIONAL
  )
{
  EFI_STATUS    status = EFI_SUCCESS;
  CONTROL_INFO  *ctrlInfo = NULL;
  VARIABLE_INFO *varInfo = NULL;
  BOOLEAN       found;
  CHAR16        *configResp = NULL;
  CHAR16        *strPtr = NULL;
  CHAR16        *configHdr = NULL;
  UINT8         *buffer = NULL;
  UINTN         bufferSize;
  UINTN         size = 0;
  UINTN         length = 0;
  UINT32         varIndex = 0;
  UINT32         index = 0;
  UINT16		CurrentBootOption = 0;

	if((gBrowserCallbackEnabled == FALSE) && (gEnableDrvNotification == FALSE)) { 	//Allow Browser callback for AMI ExecuteCallback/AccessConfig/RouteConfig calls
		status = EFI_UNSUPPORTED;
		goto DONE;
	}

	if(ResultsDataSize == NULL || (*ResultsDataSize && ResultsData == NULL))
	{
		status = EFI_INVALID_PARAMETER;
		goto DONE;
	}
	
	SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Entering BrowserCallback()\n\n" );

  //
  // Find target storage
  //
  if(VariableGuid != NULL)
  {
    //
    // Try to find target storage
    //
    found = FALSE;
    for(index = 0; index < gVariables->VariableCount; index++)
    {
		varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(index);
		//EIP-75352 Suppress the warnings from static code analyzer
		if(NULL == varInfo){
			continue;
		}
      if(EfiCompareGuid(&varInfo->VariableGuid, (EFI_GUID *)VariableGuid))
      {
        if(((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE) != VARIABLE_ATTRIBUTE_EFI_VARSTORE) &&
          ((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) != VARIABLE_ATTRIBUTE_NAMEVALUE))
        {
          //
          // Buffer storage require both GUID and Name
          //
          if (VariableName == NULL)
          {
            status = EFI_NOT_FOUND;
            goto DONE;
          }

          if (EfiStrCmp (varInfo->VariableName, (CHAR16 *)VariableName) == 0)
          {
				found = TRUE;
				varIndex = index;
				SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Comparing gCurrVarHandle = %x to variableHandle %x\n\n", gCurrVarHandle, varInfo->VariableHandle  );
				if (varInfo->VariableHandle == gCurrVarHandle)					//Checking for same variable names for two different handles, if match not found continue with default
				{
	            break;
				}
          }
        }
      }
    }

    if (!found)
    {
      status = EFI_NOT_FOUND;
      goto DONE;
    }
	else						//If gCurrVarHandle is not matched then varInfo will have last index data so again filling VarInfo
	{
		//Updating the varinfo with the varIndex
		varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(varIndex);
	}	
  } else
  {
    // GUID/Name is not specified, store variable index
    varIndex = gCurrVarIndex;
    varInfo = (VARIABLE_INFO *)VarGetVariableInfoIndex(varIndex);
  }
	//EIP-75352 Suppress the warnings from static code analyzer
	if (NULL == varInfo){
		goto DONE;
	}


  if((varInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_EFI_VARSTORE) == VARIABLE_ATTRIBUTE_EFI_VARSTORE)
  {
    status = EFI_INVALID_PARAMETER;
    goto DONE;
  }

  //
  //  Retrive NVRam Buffer
  //
  buffer = (UINT8 *)VarGetVariable(varIndex, &size);
  if(buffer == NULL)
  {
    goto DONE;
  }

  //
  // Generate <ConfigHdr>
  //
  SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] GetConfigHeader()\n" );  
  status = GetConfigHeader(varInfo, &configHdr, &length);
  SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] GetConfigHeader retuned,  status = 0x%x \n\n" , status );    
	if(EFI_ERROR(status) || (NULL == configHdr))//EIP-75384 Static code
	{
		goto DONE;
	}

  if(RetrieveData)
  {
    //
    // Generate <ConfigResp>
    //
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] _StorageToConfigResp()\n" );  
    status = _StorageToConfigResp(varInfo, buffer, configHdr, &configResp);
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] _StorageToConfigResp returned,  status = 0x%x \n\n" , status ); 
    if (EFI_ERROR(status))
    {
       goto DONE;
    }

    //
    // Skip <ConfigHdr> and '&' to point to <ConfigBody>
    //
    if (EDKVersion_1_05_RetrieveData ())
    {
        strPtr = configResp + EfiStrLen (configHdr) + 1;
    }
    else
    {
        strPtr = configResp;
    }
    bufferSize = EfiStrSize (strPtr);
    if (*ResultsDataSize < bufferSize)
    {
      *ResultsDataSize = bufferSize;

     // gBS->FreePool (configResp);
      status = EFI_BUFFER_TOO_SMALL;
      goto DONE;
    }

    *ResultsDataSize = bufferSize;
    EfiCopyMem (ResultsData, strPtr, bufferSize);

    SETUP_DEBUG_UEFI_CALLBACK ( "[TSE] Displaying Retrieve Data Buffer, VariableName: %s, VariableHandle: 0x%x\n\n", varInfo->VariableName, varInfo->VariableHandle  );

#if TSE_DEBUG_MESSAGES
    DebugShowBufferContent(bufferSize, ResultsData);
#endif

    //gBS->FreePool(configResp);
  } else
  {
    //
    // Prepare <configResp>
    //

#if TSE_DEBUG_MESSAGES
	{
		CHAR16 BrowserCallbackFilename[50];		
		CHAR16 BrowserCallbackContent[200];
		CHAR16 *BrowserCallbackBuffer = NULL ;
		UINTN Len=0;
	
  		
		SPrint(BrowserCallbackFilename,50,L"BROWSERCALLBACK_%s_%03d.txt", varInfo->VariableName, HpkFileCount);
		SPrint(BrowserCallbackContent, 200, L"VariableName: %s\nVariableGuid: %g\nResultsDataSize: 0x%x\n", VariableName, &VariableGuid, *ResultsDataSize);
		Len = (EfiStrLen (BrowserCallbackContent) + EfiStrLen (ResultsData) + 1) * sizeof (CHAR16);
		BrowserCallbackBuffer = EfiLibAllocateZeroPool (Len);

		if (BrowserCallbackBuffer != NULL)
		{
			EfiStrCpy (BrowserCallbackBuffer, BrowserCallbackContent);
			EfiStrCat (BrowserCallbackBuffer, ResultsData);

    		status = WriteDataToFile(BrowserCallbackFilename, BrowserCallbackBuffer, Len,0) ;//EIP-123312 resolve build issue
			if (!EFI_ERROR (status))
			{
				HpkFileCount++ ;
			}

			MemFreePointer(&BrowserCallbackBuffer);
		}
	}
#endif

	
    bufferSize = (EfiStrLen (ResultsData) + EfiStrLen (configHdr) + 2) * sizeof (CHAR16);
    configResp = EfiLibAllocateZeroPool (bufferSize);
    ASSERT (configResp != NULL);

    EfiStrCpy (configResp, configHdr);
    EfiStrCat (configResp, L"&");
    EfiStrCat (configResp, ResultsData);

    //
    // Update Browser uncommited data
    //
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] _ConfigRespToStorage()\n" );  
    status = _ConfigRespToStorage (varInfo, &buffer, &size, configResp);
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] _ConfigRespToStorage returned,   status = 0x%x \n\n" , status );
    
    if (EFI_ERROR (status))
    {
		goto DONE;
    }

    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] Displaying Browser Uncommited Data Buffer, VariableName: %s, VariableHandle: 0x%x\n\n", varInfo->VariableName, varInfo->VariableHandle  );

#if TSE_DEBUG_MESSAGES
    DebugShowBufferContent(size, buffer);
#endif

    SETUP_DEBUG_UEFI_CALLBACK (  "\n[TSE] Updating Browser Uncommited Data\n" );
    if (varIndex == VARIABLE_ID_BBS_ORDER)
    {
		if(gCurrLegacyBootData)
		{
			UINT16 CurLegBootDataValid = 0;
			UINT32 i;
			for (i = 0; i < gBootOptionCount; i++ )
			{
				if ( &gBootData[i] == gCurrLegacyBootData )
					CurLegBootDataValid = 1;
			}
			if(CurLegBootDataValid)
				CurrentBootOption = gCurrLegacyBootData->Option;
			else
				gCurrLegacyBootData = NULL;
		}
		gCurrLegacyBootData = BootGetBootData(CurrentBootOption);
		if(gCurrLegacyBootData)
			status = VarSetValue(varIndex, 0, size, buffer);
    }
    else
    status = VarSetValue(varIndex, 0, size, buffer);
    SETUP_DEBUG_UEFI_CALLBACK (  "[TSE] Updating Browser Uncommited Data returned,  status = 0x%x \n\n" , status );
  }
DONE:
//MEMFREE
  if(configResp)
  {
    MemFreePointer(&configResp);
  }

  if(buffer)
  {
    MemFreePointer(&buffer);
  }

  if(configHdr)
  {
    MemFreePointer(&configHdr);
  }
  
  SETUP_DEBUG_UEFI_CALLBACK ( "\n[TSE] Exiting BrowserCallback(),  status = 0x%x \n\n" , status );  
      
  return status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	_StorageToConfigResp
//
// Description:
//
// Parameter:	VARIABLE_INFO *VariableInfo
//				VOID *Buffer
//				CHAR16 *ConfigHdr
//				CHAR16 **ConfigResp
//
// Return value:EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS _StorageToConfigResp(VARIABLE_INFO *VariableInfo, VOID *Buffer, CHAR16 *ConfigHdr, CHAR16 **ConfigResp)
{
  EFI_STATUS status = EFI_SUCCESS;
  EFI_STRING  Progress;
  CHAR16  *configHdr = NULL;
  UINTN   length = 0;

  length  = EfiStrLen(ConfigHdr) * sizeof(CHAR16);
  configHdr = (CHAR16*)EfiLibAllocateZeroPool(length + 2);
  if(configHdr == NULL)
  {
    status = EFI_OUT_OF_RESOURCES;
    goto DONE;
  }

  MemCopy(configHdr, ConfigHdr, length);

  //
  // Generate <BlockName>
  //
  status = GetBlockName(&configHdr, &length, VAR_ZERO_OFFSET, VariableInfo->VariableSize);
  if(EFI_ERROR(status))
  {
    goto DONE;
  }

  if((VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) == VARIABLE_ATTRIBUTE_NAMEVALUE)
  {
    status = EFI_UNSUPPORTED;
    goto DONE;
  }else
  {
    //
    //  VARIABLE_ATTRIBUTE_VARSTORE
    //
    status = HiiInitializeProtocol();
    if(EFI_ERROR(status))
    {
      goto DONE;
    }

    status = gHiiConfigRouting->BlockToConfig(gHiiConfigRouting, configHdr, Buffer,
      VariableInfo->VariableSize, ConfigResp, &Progress);
  }

DONE:
  if(configHdr)			//EIP81617
  {
    MemFreePointer(&configHdr);
  }
  return status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure:	_ConfigRespToStorage
//
// Description:
//
// Parameter:	VARIABLE_INFO *VariableInfo
//				VOID **Buffer
//				UINTN *Size
//				EFI_STRING ConfigResp
//
// Return value:EFI_STATUS
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS _ConfigRespToStorage(VARIABLE_INFO *VariableInfo, UINT8 **Buffer, UINTN *Size, EFI_STRING ConfigResp)
{
  EFI_STATUS status = EFI_SUCCESS;

  if((VariableInfo->ExtendedAttibutes & VARIABLE_ATTRIBUTE_NAMEVALUE) == VARIABLE_ATTRIBUTE_NAMEVALUE)
  {
    status = EFI_UNSUPPORTED;
    goto DONE;
  }else
  {
    EFI_STRING stringPtr = NULL;
    EFI_STRING tempPtr = NULL;
    UINTN length = 0;
    UINT16 *sizeBuf = NULL;

    stringPtr = ConfigResp;
    //
    // Get Buffer data Size
    //
    for(stringPtr = ConfigResp; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&WIDTH=", EfiStrLen(L"&WIDTH=")) != 0; stringPtr++);
    stringPtr += EfiStrLen(L"&WIDTH=");
    tempPtr = stringPtr;
    for(; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&VALUE=", EfiStrLen(L"&VALUE=")) != 0; length++, stringPtr++);
    sizeBuf = (CHAR16*)EfiLibAllocateZeroPool(length + 1);
    if(sizeBuf == NULL)
	{
      status = EFI_OUT_OF_RESOURCES;
	  goto DONE;
	}
    EfiCopyMem(sizeBuf, tempPtr, length);
	status = GetHexStringAsBuffer(Buffer, sizeBuf);
    MemFreePointer(&sizeBuf);
    if(EFI_ERROR(status))
    {
      *Size = 0;
      goto DONE;
    }
    //
    //  Get Buffer Data
    //
    for(; *stringPtr != 0 && EfiStrnCmp(stringPtr, L"&VALUE=", EfiStrLen(L"&VALUE=")) != 0; stringPtr++);
    stringPtr += EfiStrLen(L"&VALUE=");
    status = GetHexStringAsBuffer(Buffer, stringPtr);
  }

DONE:
  return status;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure	:	FormBrowserHandleValid
//
// Description	:	return True Browser is showing forms from SendForm interface.
//
// Input		:	none
//
// Output		:	BOOLEAN
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
BOOLEAN FormBrowserHandleValid(VOID)
{
#if SETUP_FORM_BROWSER_SUPPORT
	if(gSfHandles)
		return TRUE;
#endif
	return FALSE;
}

//<AMI_PHDR_START>
//----------------------------------------------------------------------------
// Procedure	:	FormBrowserLocateSetupHandles
//
// Description	:	return Handles and count that is passed to SendForm interface.
//
// Input		:	OUT handleBuffer and count
//
// Output		:	Status
//
//----------------------------------------------------------------------------
//<AMI_PHDR_END>
EFI_STATUS FormBrowserLocateSetupHandles(VOID*	**handleBuffer,UINT16 *count)
{
  EFI_STATUS status = EFI_SUCCESS;

#if SETUP_FORM_BROWSER_SUPPORT
  if(gSfHandles)
  {
    *handleBuffer = (VOID**)gSfHandles;
    *count = (UINT16)gSfHandleCount;
  }
  else
  {
    status =  EFI_NOT_FOUND;
  }
#else
  status = EFI_UNSUPPORTED;
#endif
  return status;
}
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2013, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**     5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************