]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | Ui.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Implementation for UI.\r | |
19 | \r | |
20 | Revision History\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
24 | #include "Setup.h"\r | |
25 | #include "Ui.h"\r | |
26 | #include "Colors.h"\r | |
27 | \r | |
28 | //\r | |
29 | // Implementation\r | |
30 | //\r | |
31 | VOID\r | |
32 | SetUnicodeMem (\r | |
33 | IN VOID *Buffer,\r | |
34 | IN UINTN Size,\r | |
35 | IN CHAR16 Value\r | |
36 | )\r | |
37 | /*++\r | |
38 | \r | |
39 | Routine Description:\r | |
40 | \r | |
41 | Set Buffer to Value for Size bytes.\r | |
42 | \r | |
43 | Arguments:\r | |
44 | \r | |
45 | Buffer - Memory to set.\r | |
46 | \r | |
47 | Size - Number of bytes to set\r | |
48 | \r | |
49 | Value - Value of the set operation.\r | |
50 | \r | |
51 | Returns:\r | |
52 | \r | |
53 | None\r | |
54 | \r | |
55 | --*/\r | |
56 | {\r | |
57 | CHAR16 *Ptr;\r | |
58 | \r | |
59 | Ptr = Buffer;\r | |
60 | while (Size--) {\r | |
61 | *(Ptr++) = Value;\r | |
62 | }\r | |
63 | }\r | |
64 | \r | |
65 | VOID\r | |
66 | UiInitMenu (\r | |
67 | VOID\r | |
68 | )\r | |
69 | /*++\r | |
70 | \r | |
71 | Routine Description:\r | |
72 | Initialize Menu option list.\r | |
73 | \r | |
74 | Arguments:\r | |
75 | \r | |
76 | Returns:\r | |
77 | \r | |
78 | --*/\r | |
79 | {\r | |
80 | InitializeListHead (&Menu);\r | |
81 | }\r | |
82 | \r | |
83 | VOID\r | |
84 | UiInitMenuList (\r | |
85 | VOID\r | |
86 | )\r | |
87 | /*++\r | |
88 | \r | |
89 | Routine Description:\r | |
90 | Initialize Menu option list.\r | |
91 | \r | |
92 | Arguments:\r | |
93 | \r | |
94 | Returns:\r | |
95 | \r | |
96 | --*/\r | |
97 | {\r | |
98 | InitializeListHead (&gMenuList);\r | |
99 | }\r | |
100 | \r | |
101 | VOID\r | |
102 | UiRemoveMenuListEntry (\r | |
103 | IN UI_MENU_OPTION *Selection,\r | |
104 | OUT UI_MENU_OPTION **PreviousSelection\r | |
105 | )\r | |
106 | /*++\r | |
107 | \r | |
108 | Routine Description:\r | |
109 | Remove Menu option list.\r | |
110 | \r | |
111 | Arguments:\r | |
112 | \r | |
113 | Returns:\r | |
114 | \r | |
115 | --*/\r | |
116 | {\r | |
117 | UI_MENU_LIST *UiMenuList;\r | |
118 | \r | |
119 | *PreviousSelection = AllocateZeroPool (sizeof (UI_MENU_OPTION));\r | |
120 | ASSERT (*PreviousSelection != NULL);\r | |
121 | \r | |
122 | if (!IsListEmpty (&gMenuList)) {\r | |
123 | UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);\r | |
124 | (*PreviousSelection)->IfrNumber = UiMenuList->Selection.IfrNumber;\r | |
125 | (*PreviousSelection)->FormId = UiMenuList->Selection.FormId;\r | |
126 | (*PreviousSelection)->Tags = UiMenuList->Selection.Tags;\r | |
127 | (*PreviousSelection)->ThisTag = UiMenuList->Selection.ThisTag;\r | |
128 | (*PreviousSelection)->Handle = UiMenuList->Selection.Handle;\r | |
129 | gEntryNumber = UiMenuList->FormerEntryNumber;\r | |
130 | RemoveEntryList (&UiMenuList->MenuLink);\r | |
131 | gBS->FreePool (UiMenuList);\r | |
132 | }\r | |
133 | }\r | |
134 | \r | |
135 | VOID\r | |
136 | UiFreeMenuList (\r | |
137 | VOID\r | |
138 | )\r | |
139 | /*++\r | |
140 | \r | |
141 | Routine Description:\r | |
142 | Free Menu option linked list.\r | |
143 | \r | |
144 | Arguments:\r | |
145 | \r | |
146 | Returns:\r | |
147 | \r | |
148 | --*/\r | |
149 | {\r | |
150 | UI_MENU_LIST *UiMenuList;\r | |
151 | \r | |
152 | while (!IsListEmpty (&gMenuList)) {\r | |
153 | UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);\r | |
154 | RemoveEntryList (&UiMenuList->MenuLink);\r | |
155 | gBS->FreePool (UiMenuList);\r | |
156 | }\r | |
157 | }\r | |
158 | \r | |
159 | VOID\r | |
160 | UiAddMenuListEntry (\r | |
161 | IN UI_MENU_OPTION *Selection\r | |
162 | )\r | |
163 | /*++\r | |
164 | \r | |
165 | Routine Description:\r | |
166 | Add one menu entry to the linked lst\r | |
167 | \r | |
168 | Arguments:\r | |
169 | \r | |
170 | Returns:\r | |
171 | \r | |
172 | --*/\r | |
173 | {\r | |
174 | UI_MENU_LIST *UiMenuList;\r | |
175 | \r | |
176 | UiMenuList = AllocateZeroPool (sizeof (UI_MENU_LIST));\r | |
177 | ASSERT (UiMenuList != NULL);\r | |
178 | \r | |
179 | UiMenuList->Signature = UI_MENU_LIST_SIGNATURE;\r | |
180 | CopyMem (&UiMenuList->Selection, Selection, sizeof (UI_MENU_OPTION));\r | |
181 | \r | |
182 | InsertHeadList (&gMenuList, &UiMenuList->MenuLink);\r | |
183 | }\r | |
184 | \r | |
185 | VOID\r | |
186 | UiFreeMenu (\r | |
187 | VOID\r | |
188 | )\r | |
189 | /*++\r | |
190 | \r | |
191 | Routine Description:\r | |
192 | Free Menu option linked list.\r | |
193 | \r | |
194 | Arguments:\r | |
195 | \r | |
196 | Returns:\r | |
197 | \r | |
198 | --*/\r | |
199 | {\r | |
200 | UI_MENU_OPTION *MenuOption;\r | |
201 | \r | |
202 | while (!IsListEmpty (&Menu)) {\r | |
203 | MenuOption = CR (Menu.ForwardLink, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
204 | RemoveEntryList (&MenuOption->Link);\r | |
205 | \r | |
206 | //\r | |
207 | // We allocated space for this description when we did a GetToken, free it here\r | |
208 | //\r | |
209 | gBS->FreePool (MenuOption->Description);\r | |
210 | gBS->FreePool (MenuOption);\r | |
211 | }\r | |
212 | }\r | |
213 | \r | |
214 | VOID\r | |
215 | UpdateDateAndTime (\r | |
216 | VOID\r | |
217 | )\r | |
218 | /*++\r | |
219 | \r | |
220 | Routine Description:\r | |
221 | Refresh screen with current date and/or time based on screen context\r | |
222 | \r | |
223 | Arguments:\r | |
224 | \r | |
225 | Returns:\r | |
226 | \r | |
227 | --*/\r | |
228 | {\r | |
229 | CHAR16 *OptionString;\r | |
230 | MENU_REFRESH_ENTRY *MenuRefreshEntry;\r | |
231 | UINTN Index;\r | |
232 | UINTN Loop;\r | |
233 | \r | |
234 | OptionString = NULL;\r | |
235 | \r | |
236 | if (gMenuRefreshHead != NULL) {\r | |
237 | \r | |
238 | MenuRefreshEntry = gMenuRefreshHead;\r | |
239 | \r | |
240 | do {\r | |
241 | gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute);\r | |
242 | ProcessOptions (MenuRefreshEntry->MenuOption, FALSE, MenuRefreshEntry->FileFormTagsHead, NULL, &OptionString);\r | |
243 | \r | |
244 | if (OptionString != NULL) {\r | |
245 | //\r | |
246 | // If leading spaces on OptionString - remove the spaces\r | |
247 | //\r | |
248 | for (Index = 0; OptionString[Index] == L' '; Index++)\r | |
249 | ;\r | |
250 | \r | |
251 | for (Loop = 0; OptionString[Index] != CHAR_NULL; Index++) {\r | |
252 | OptionString[Loop] = OptionString[Index];\r | |
253 | Loop++;\r | |
254 | }\r | |
255 | \r | |
256 | OptionString[Loop] = CHAR_NULL;\r | |
257 | \r | |
258 | PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, OptionString);\r | |
259 | }\r | |
260 | \r | |
261 | MenuRefreshEntry = MenuRefreshEntry->Next;\r | |
262 | \r | |
263 | } while (MenuRefreshEntry != NULL);\r | |
264 | }\r | |
265 | \r | |
266 | if (OptionString != NULL) {\r | |
267 | gBS->FreePool (OptionString);\r | |
268 | }\r | |
269 | }\r | |
270 | \r | |
271 | EFI_STATUS\r | |
272 | UiWaitForSingleEvent (\r | |
273 | IN EFI_EVENT Event,\r | |
274 | IN UINT64 Timeout OPTIONAL\r | |
275 | )\r | |
276 | /*++\r | |
277 | \r | |
278 | Routine Description:\r | |
279 | Wait for a given event to fire, or for an optional timeout to expire.\r | |
280 | \r | |
281 | Arguments:\r | |
282 | Event - The event to wait for\r | |
283 | \r | |
284 | Timeout - An optional timeout value in 100 ns units.\r | |
285 | \r | |
286 | Returns:\r | |
287 | \r | |
288 | EFI_SUCCESS - Event fired before Timeout expired.\r | |
289 | EFI_TIME_OUT - Timout expired before Event fired.\r | |
290 | \r | |
291 | --*/\r | |
292 | {\r | |
293 | EFI_STATUS Status;\r | |
294 | UINTN Index;\r | |
295 | EFI_EVENT TimerEvent;\r | |
296 | EFI_EVENT WaitList[2];\r | |
297 | \r | |
298 | if (Timeout) {\r | |
299 | //\r | |
300 | // Create a timer event\r | |
301 | //\r | |
302 | Status = gBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);\r | |
303 | if (!EFI_ERROR (Status)) {\r | |
304 | //\r | |
305 | // Set the timer event\r | |
306 | //\r | |
307 | gBS->SetTimer (\r | |
308 | TimerEvent,\r | |
309 | TimerRelative,\r | |
310 | Timeout\r | |
311 | );\r | |
312 | \r | |
313 | //\r | |
314 | // Wait for the original event or the timer\r | |
315 | //\r | |
316 | WaitList[0] = Event;\r | |
317 | WaitList[1] = TimerEvent;\r | |
318 | Status = gBS->WaitForEvent (2, WaitList, &Index);\r | |
319 | gBS->CloseEvent (TimerEvent);\r | |
320 | \r | |
321 | //\r | |
322 | // If the timer expired, change the return to timed out\r | |
323 | //\r | |
324 | if (!EFI_ERROR (Status) && Index == 1) {\r | |
325 | Status = EFI_TIMEOUT;\r | |
326 | }\r | |
327 | }\r | |
328 | } else {\r | |
329 | //\r | |
330 | // Update screen every second\r | |
331 | //\r | |
332 | Timeout = ONE_SECOND;\r | |
333 | \r | |
334 | do {\r | |
335 | Status = gBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);\r | |
336 | \r | |
337 | //\r | |
338 | // Set the timer event\r | |
339 | //\r | |
340 | gBS->SetTimer (\r | |
341 | TimerEvent,\r | |
342 | TimerRelative,\r | |
343 | Timeout\r | |
344 | );\r | |
345 | \r | |
346 | //\r | |
347 | // Wait for the original event or the timer\r | |
348 | //\r | |
349 | WaitList[0] = Event;\r | |
350 | WaitList[1] = TimerEvent;\r | |
351 | Status = gBS->WaitForEvent (2, WaitList, &Index);\r | |
352 | \r | |
353 | //\r | |
354 | // If the timer expired, update anything that needs a refresh and keep waiting\r | |
355 | //\r | |
356 | if (!EFI_ERROR (Status) && Index == 1) {\r | |
357 | Status = EFI_TIMEOUT;\r | |
358 | UpdateDateAndTime ();\r | |
359 | }\r | |
360 | \r | |
361 | gBS->CloseEvent (TimerEvent);\r | |
362 | } while (Status == EFI_TIMEOUT);\r | |
363 | }\r | |
364 | \r | |
365 | return Status;\r | |
366 | }\r | |
367 | \r | |
368 | VOID\r | |
369 | UiAddMenuOption (\r | |
370 | IN CHAR16 *String,\r | |
371 | IN EFI_HII_HANDLE Handle,\r | |
372 | IN EFI_TAG *Tags,\r | |
373 | IN VOID *FormBinary,\r | |
374 | IN UINTN IfrNumber\r | |
375 | )\r | |
376 | /*++\r | |
377 | \r | |
378 | Routine Description:\r | |
379 | Add one menu option by specified description and context.\r | |
380 | \r | |
381 | Arguments:\r | |
382 | String - String description for this option.\r | |
383 | Context - Context data for entry.\r | |
384 | \r | |
385 | Returns:\r | |
386 | \r | |
387 | --*/\r | |
388 | {\r | |
389 | UI_MENU_OPTION *MenuOption;\r | |
390 | \r | |
391 | MenuOption = AllocateZeroPool (sizeof (UI_MENU_OPTION));\r | |
392 | ASSERT (MenuOption);\r | |
393 | \r | |
394 | MenuOption->Signature = UI_MENU_OPTION_SIGNATURE;\r | |
395 | MenuOption->Description = String;\r | |
396 | MenuOption->Handle = Handle;\r | |
397 | MenuOption->FormBinary = FormBinary;\r | |
398 | MenuOption->IfrNumber = IfrNumber;\r | |
399 | MenuOption->Skip = 1;\r | |
400 | MenuOption->Tags = Tags;\r | |
401 | MenuOption->TagIndex = 0;\r | |
402 | MenuOption->ThisTag = &(MenuOption->Tags[MenuOption->TagIndex]);\r | |
403 | MenuOption->EntryNumber = (UINT16) IfrNumber;\r | |
404 | \r | |
405 | InsertTailList (&Menu, &MenuOption->Link);\r | |
406 | }\r | |
407 | \r | |
408 | VOID\r | |
409 | UiAddSubMenuOption (\r | |
410 | IN CHAR16 *String,\r | |
411 | IN EFI_HII_HANDLE Handle,\r | |
412 | IN EFI_TAG *Tags,\r | |
413 | IN UINTN TagIndex,\r | |
414 | IN UINT16 FormId,\r | |
415 | IN UINT16 MenuItemCount\r | |
416 | )\r | |
417 | /*++\r | |
418 | \r | |
419 | Routine Description:\r | |
420 | Add one menu option by specified description and context.\r | |
421 | \r | |
422 | Arguments:\r | |
423 | String - String description for this option.\r | |
424 | Context - Context data for entry.\r | |
425 | \r | |
426 | Returns:\r | |
427 | \r | |
428 | --*/\r | |
429 | {\r | |
430 | UI_MENU_OPTION *MenuOption;\r | |
431 | \r | |
432 | MenuOption = AllocateZeroPool (sizeof (UI_MENU_OPTION));\r | |
433 | ASSERT (MenuOption);\r | |
434 | \r | |
435 | MenuOption->Signature = UI_MENU_OPTION_SIGNATURE;\r | |
436 | MenuOption->Description = String;\r | |
437 | MenuOption->Handle = Handle;\r | |
438 | MenuOption->Skip = Tags[TagIndex].NumberOfLines;\r | |
439 | MenuOption->IfrNumber = gActiveIfr;\r | |
440 | MenuOption->Tags = Tags;\r | |
441 | MenuOption->TagIndex = TagIndex;\r | |
442 | MenuOption->ThisTag = &(MenuOption->Tags[MenuOption->TagIndex]);\r | |
443 | MenuOption->Consistency = Tags[TagIndex].Consistency;\r | |
444 | MenuOption->FormId = FormId;\r | |
445 | MenuOption->GrayOut = Tags[TagIndex].GrayOut;\r | |
446 | MenuOption->EntryNumber = MenuItemCount;\r | |
447 | \r | |
448 | InsertTailList (&Menu, &MenuOption->Link);\r | |
449 | }\r | |
450 | \r | |
451 | EFI_STATUS\r | |
452 | CreateDialog (\r | |
453 | IN UINTN NumberOfLines,\r | |
454 | IN BOOLEAN HotKey,\r | |
455 | IN UINTN MaximumStringSize,\r | |
456 | OUT CHAR16 *StringBuffer,\r | |
457 | OUT EFI_INPUT_KEY *KeyValue,\r | |
458 | IN CHAR16 *String,\r | |
459 | ...\r | |
460 | )\r | |
461 | /*++\r | |
462 | \r | |
463 | Routine Description:\r | |
464 | Routine used to abstract a generic dialog interface and return the selected key or string\r | |
465 | \r | |
466 | Arguments:\r | |
467 | NumberOfLines - The number of lines for the dialog box\r | |
468 | HotKey - Defines whether a single character is parsed (TRUE) and returned in KeyValue \r | |
469 | or a string is returned in StringBuffer. Two special characters are considered when entering a string, a SCAN_ESC and\r | |
470 | an CHAR_CARRIAGE_RETURN. SCAN_ESC terminates string input and returns\r | |
471 | MaximumStringSize - The maximum size in bytes of a typed in string (each character is a CHAR16) and the minimum string returned is two bytes\r | |
472 | StringBuffer - The passed in pointer to the buffer which will hold the typed in string if HotKey is FALSE\r | |
473 | KeyValue - The EFI_KEY value returned if HotKey is TRUE..\r | |
474 | String - Pointer to the first string in the list\r | |
475 | ... - A series of (quantity == NumberOfLines) text strings which will be used to construct the dialog box\r | |
476 | \r | |
477 | Returns:\r | |
478 | EFI_SUCCESS - Displayed dialog and received user interaction\r | |
479 | EFI_INVALID_PARAMETER - One of the parameters was invalid (e.g. (StringBuffer == NULL) && (HotKey == FALSE))\r | |
480 | EFI_DEVICE_ERROR - User typed in an ESC character to exit the routine\r | |
481 | \r | |
482 | --*/\r | |
483 | {\r | |
484 | VA_LIST Marker;\r | |
485 | UINTN Count;\r | |
486 | EFI_INPUT_KEY Key;\r | |
487 | UINTN LargestString;\r | |
488 | CHAR16 *TempString;\r | |
489 | CHAR16 *BufferedString;\r | |
490 | CHAR16 *StackString;\r | |
491 | CHAR16 KeyPad[2];\r | |
492 | UINTN Start;\r | |
493 | UINTN Top;\r | |
494 | UINTN Index;\r | |
495 | EFI_STATUS Status;\r | |
496 | BOOLEAN SelectionComplete;\r | |
497 | UINTN InputOffset;\r | |
498 | UINTN CurrentAttribute;\r | |
499 | UINTN DimensionsWidth;\r | |
500 | UINTN DimensionsHeight;\r | |
501 | \r | |
502 | DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;\r | |
503 | DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;\r | |
504 | \r | |
505 | SelectionComplete = FALSE;\r | |
506 | InputOffset = 0;\r | |
507 | TempString = AllocateZeroPool (MaximumStringSize * 2);\r | |
508 | BufferedString = AllocateZeroPool (MaximumStringSize * 2);\r | |
509 | CurrentAttribute = gST->ConOut->Mode->Attribute;\r | |
510 | \r | |
511 | ASSERT (TempString);\r | |
512 | ASSERT (BufferedString);\r | |
513 | \r | |
514 | VA_START (Marker, String);\r | |
515 | \r | |
516 | //\r | |
517 | // Zero the outgoing buffer\r | |
518 | //\r | |
519 | ZeroMem (StringBuffer, MaximumStringSize);\r | |
520 | \r | |
521 | if (HotKey) {\r | |
522 | if (KeyValue == NULL) {\r | |
523 | return EFI_INVALID_PARAMETER;\r | |
524 | }\r | |
525 | } else {\r | |
526 | if (StringBuffer == NULL) {\r | |
527 | return EFI_INVALID_PARAMETER;\r | |
528 | }\r | |
529 | }\r | |
530 | //\r | |
531 | // Disable cursor\r | |
532 | //\r | |
533 | gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r | |
534 | \r | |
535 | LargestString = (GetStringWidth (String) / 2);\r | |
536 | \r | |
537 | if (LargestString == L' ') {\r | |
538 | InputOffset = 1;\r | |
539 | }\r | |
540 | //\r | |
541 | // Determine the largest string in the dialog box\r | |
542 | // Notice we are starting with 1 since String is the first string\r | |
543 | //\r | |
544 | for (Count = 1; Count < NumberOfLines; Count++) {\r | |
545 | StackString = VA_ARG (Marker, CHAR16 *);\r | |
546 | \r | |
547 | if (StackString[0] == L' ') {\r | |
548 | InputOffset = Count + 1;\r | |
549 | }\r | |
550 | \r | |
551 | if ((GetStringWidth (StackString) / 2) > LargestString) {\r | |
552 | //\r | |
553 | // Size of the string visually and subtract the width by one for the null-terminator\r | |
554 | //\r | |
555 | LargestString = (GetStringWidth (StackString) / 2);\r | |
556 | }\r | |
557 | }\r | |
558 | \r | |
559 | Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;\r | |
560 | Top = ((DimensionsHeight - NumberOfLines - 2) / 2) + gScreenDimensions.TopRow - 1;\r | |
561 | \r | |
562 | Count = 0;\r | |
563 | \r | |
564 | //\r | |
565 | // Display the Popup\r | |
566 | //\r | |
567 | CreateSharedPopUp (LargestString, NumberOfLines, &String);\r | |
568 | \r | |
569 | //\r | |
570 | // Take the first key typed and report it back?\r | |
571 | //\r | |
572 | if (HotKey) {\r | |
573 | Status = WaitForKeyStroke (&Key);\r | |
574 | CopyMem (KeyValue, &Key, sizeof (EFI_INPUT_KEY));\r | |
575 | \r | |
576 | } else {\r | |
577 | do {\r | |
578 | Status = WaitForKeyStroke (&Key);\r | |
579 | \r | |
580 | switch (Key.UnicodeChar) {\r | |
581 | case CHAR_NULL:\r | |
582 | switch (Key.ScanCode) {\r | |
583 | case SCAN_ESC:\r | |
584 | gBS->FreePool (TempString);\r | |
585 | gBS->FreePool (BufferedString);\r | |
586 | gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r | |
587 | gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r | |
588 | return EFI_DEVICE_ERROR;\r | |
589 | \r | |
590 | default:\r | |
591 | break;\r | |
592 | }\r | |
593 | \r | |
594 | break;\r | |
595 | \r | |
596 | case CHAR_CARRIAGE_RETURN:\r | |
597 | SelectionComplete = TRUE;\r | |
598 | gBS->FreePool (TempString);\r | |
599 | gBS->FreePool (BufferedString);\r | |
600 | gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r | |
601 | gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r | |
602 | return EFI_SUCCESS;\r | |
603 | break;\r | |
604 | \r | |
605 | case CHAR_BACKSPACE:\r | |
606 | if (StringBuffer[0] != CHAR_NULL) {\r | |
607 | for (Index = 0; StringBuffer[Index] != CHAR_NULL; Index++) {\r | |
608 | TempString[Index] = StringBuffer[Index];\r | |
609 | }\r | |
610 | //\r | |
611 | // Effectively truncate string by 1 character\r | |
612 | //\r | |
613 | TempString[Index - 1] = CHAR_NULL;\r | |
614 | StrCpy (StringBuffer, TempString);\r | |
615 | }\r | |
616 | \r | |
617 | default:\r | |
618 | //\r | |
619 | // If it is the beginning of the string, don't worry about checking maximum limits\r | |
620 | //\r | |
621 | if ((StringBuffer[0] == CHAR_NULL) && (Key.UnicodeChar != CHAR_BACKSPACE)) {\r | |
622 | StrnCpy (StringBuffer, &Key.UnicodeChar, 1);\r | |
623 | StrnCpy (TempString, &Key.UnicodeChar, 1);\r | |
624 | } else if ((GetStringWidth (StringBuffer) < MaximumStringSize) && (Key.UnicodeChar != CHAR_BACKSPACE)) {\r | |
625 | KeyPad[0] = Key.UnicodeChar;\r | |
626 | KeyPad[1] = CHAR_NULL;\r | |
627 | StrCat (StringBuffer, KeyPad);\r | |
628 | StrCat (TempString, KeyPad);\r | |
629 | }\r | |
630 | //\r | |
631 | // If the width of the input string is now larger than the screen, we nee to\r | |
632 | // adjust the index to start printing portions of the string\r | |
633 | //\r | |
634 | SetUnicodeMem (BufferedString, LargestString, L' ');\r | |
635 | \r | |
636 | PrintStringAt (Start + 1, Top + InputOffset, BufferedString);\r | |
637 | \r | |
638 | if ((GetStringWidth (StringBuffer) / 2) > (DimensionsWidth - 2)) {\r | |
639 | Index = (GetStringWidth (StringBuffer) / 2) - DimensionsWidth + 2;\r | |
640 | } else {\r | |
641 | Index = 0;\r | |
642 | }\r | |
643 | \r | |
644 | for (Count = 0; Index + 1 < GetStringWidth (StringBuffer) / 2; Index++, Count++) {\r | |
645 | BufferedString[Count] = StringBuffer[Index];\r | |
646 | }\r | |
647 | \r | |
648 | PrintStringAt (Start + 1, Top + InputOffset, BufferedString);\r | |
649 | break;\r | |
650 | }\r | |
651 | } while (!SelectionComplete);\r | |
652 | }\r | |
653 | \r | |
654 | gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r | |
655 | gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r | |
656 | return EFI_SUCCESS;\r | |
657 | }\r | |
658 | \r | |
659 | VOID\r | |
660 | CreateSharedPopUp (\r | |
661 | IN UINTN RequestedWidth,\r | |
662 | IN UINTN NumberOfLines,\r | |
663 | IN CHAR16 **ArrayOfStrings\r | |
664 | )\r | |
665 | {\r | |
666 | UINTN Index;\r | |
667 | UINTN Count;\r | |
668 | CHAR16 Character;\r | |
669 | UINTN Start;\r | |
670 | UINTN End;\r | |
671 | UINTN Top;\r | |
672 | UINTN Bottom;\r | |
673 | CHAR16 *String;\r | |
674 | \r | |
675 | UINTN DimensionsWidth;\r | |
676 | UINTN DimensionsHeight;\r | |
677 | \r | |
678 | DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;\r | |
679 | DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;\r | |
680 | \r | |
681 | Count = 0;\r | |
682 | \r | |
683 | gST->ConOut->SetAttribute (gST->ConOut, POPUP_TEXT | POPUP_BACKGROUND);\r | |
684 | \r | |
685 | if ((RequestedWidth + 2) > DimensionsWidth) {\r | |
686 | RequestedWidth = DimensionsWidth - 2;\r | |
687 | }\r | |
688 | //\r | |
689 | // Subtract the PopUp width from total Columns, allow for one space extra on\r | |
690 | // each end plus a border.\r | |
691 | //\r | |
692 | Start = (DimensionsWidth - RequestedWidth - 2) / 2 + gScreenDimensions.LeftColumn + 1;\r | |
693 | End = Start + RequestedWidth + 1;\r | |
694 | \r | |
695 | Top = ((DimensionsHeight - NumberOfLines - 2) / 2) + gScreenDimensions.TopRow - 1;\r | |
696 | Bottom = Top + NumberOfLines + 2;\r | |
697 | \r | |
698 | Character = (CHAR16) BOXDRAW_DOWN_RIGHT;\r | |
699 | PrintCharAt (Start, Top, Character);\r | |
700 | Character = (CHAR16) BOXDRAW_HORIZONTAL;\r | |
701 | for (Index = Start; Index + 2 < End; Index++) {\r | |
702 | PrintChar (Character);\r | |
703 | }\r | |
704 | \r | |
705 | Character = (CHAR16) BOXDRAW_DOWN_LEFT;\r | |
706 | PrintChar (Character);\r | |
707 | Character = (CHAR16) BOXDRAW_VERTICAL;\r | |
708 | for (Index = Top; Index + 2 < Bottom; Index++) {\r | |
709 | String = ArrayOfStrings[Count];\r | |
710 | Count++;\r | |
711 | \r | |
712 | //\r | |
713 | // This will clear the background of the line - we never know who might have been\r | |
714 | // here before us. This differs from the next clear in that it used the non-reverse\r | |
715 | // video for normal printing.\r | |
716 | //\r | |
717 | if (GetStringWidth (String) / 2 > 1) {\r | |
718 | ClearLines (Start, End, Index + 1, Index + 1, POPUP_TEXT | POPUP_BACKGROUND);\r | |
719 | }\r | |
720 | //\r | |
721 | // Passing in a space results in the assumption that this is where typing will occur\r | |
722 | //\r | |
723 | if (String[0] == L' ') {\r | |
724 | ClearLines (Start + 1, End - 1, Index + 1, Index + 1, POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND);\r | |
725 | }\r | |
726 | //\r | |
727 | // Passing in a NULL results in a blank space\r | |
728 | //\r | |
729 | if (String[0] == CHAR_NULL) {\r | |
730 | ClearLines (Start, End, Index + 1, Index + 1, POPUP_TEXT | POPUP_BACKGROUND);\r | |
731 | }\r | |
732 | \r | |
733 | PrintStringAt (\r | |
734 | ((DimensionsWidth - GetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,\r | |
735 | Index + 1,\r | |
736 | String\r | |
737 | );\r | |
738 | gST->ConOut->SetAttribute (gST->ConOut, POPUP_TEXT | POPUP_BACKGROUND);\r | |
739 | PrintCharAt (Start, Index + 1, Character);\r | |
740 | PrintCharAt (End - 1, Index + 1, Character);\r | |
741 | }\r | |
742 | \r | |
743 | Character = (CHAR16) BOXDRAW_UP_RIGHT;\r | |
744 | PrintCharAt (Start, Bottom - 1, Character);\r | |
745 | Character = (CHAR16) BOXDRAW_HORIZONTAL;\r | |
746 | for (Index = Start; Index + 2 < End; Index++) {\r | |
747 | PrintChar (Character);\r | |
748 | }\r | |
749 | \r | |
750 | Character = (CHAR16) BOXDRAW_UP_LEFT;\r | |
751 | PrintChar (Character);\r | |
752 | }\r | |
753 | \r | |
754 | VOID\r | |
755 | CreatePopUp (\r | |
756 | IN UINTN RequestedWidth,\r | |
757 | IN UINTN NumberOfLines,\r | |
758 | IN CHAR16 *ArrayOfStrings,\r | |
759 | ...\r | |
760 | )\r | |
761 | {\r | |
762 | CreateSharedPopUp (RequestedWidth, NumberOfLines, &ArrayOfStrings);\r | |
763 | }\r | |
764 | \r | |
765 | VOID\r | |
766 | UpdateStatusBar (\r | |
767 | IN UINTN MessageType,\r | |
768 | IN UINT8 Flags,\r | |
769 | IN BOOLEAN State\r | |
770 | )\r | |
771 | {\r | |
772 | UINTN Index;\r | |
773 | STATIC BOOLEAN InputError;\r | |
774 | CHAR16 *NvUpdateMessage;\r | |
775 | CHAR16 *InputErrorMessage;\r | |
776 | \r | |
777 | NvUpdateMessage = GetToken (STRING_TOKEN (NV_UPDATE_MESSAGE), gHiiHandle);\r | |
778 | InputErrorMessage = GetToken (STRING_TOKEN (INPUT_ERROR_MESSAGE), gHiiHandle);\r | |
779 | \r | |
780 | switch (MessageType) {\r | |
781 | case INPUT_ERROR:\r | |
782 | if (State) {\r | |
783 | gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);\r | |
784 | PrintStringAt (\r | |
785 | gScreenDimensions.LeftColumn + gPromptBlockWidth,\r | |
786 | gScreenDimensions.BottomRow - 1,\r | |
787 | InputErrorMessage\r | |
788 | );\r | |
789 | InputError = TRUE;\r | |
790 | } else {\r | |
791 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_HIGHLIGHT);\r | |
792 | for (Index = 0; Index < (GetStringWidth (InputErrorMessage) - 2) / 2; Index++) {\r | |
793 | PrintAt (gScreenDimensions.LeftColumn + gPromptBlockWidth + Index, gScreenDimensions.BottomRow - 1, (CHAR16 *) L" ");\r | |
794 | }\r | |
795 | \r | |
796 | InputError = FALSE;\r | |
797 | }\r | |
798 | break;\r | |
799 | \r | |
800 | case NV_UPDATE_REQUIRED:\r | |
801 | if (gClassOfVfr != EFI_FRONT_PAGE_SUBCLASS) {\r | |
802 | if (State) {\r | |
803 | gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);\r | |
804 | PrintStringAt (\r | |
805 | gScreenDimensions.LeftColumn + gPromptBlockWidth + gOptionBlockWidth,\r | |
806 | gScreenDimensions.BottomRow - 1,\r | |
807 | NvUpdateMessage\r | |
808 | );\r | |
809 | gResetRequired = (BOOLEAN) (gResetRequired | (Flags & RESET_REQUIRED));\r | |
810 | \r | |
811 | gNvUpdateRequired = TRUE;\r | |
812 | } else {\r | |
813 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_HIGHLIGHT);\r | |
814 | for (Index = 0; Index < (GetStringWidth (NvUpdateMessage) - 2) / 2; Index++) {\r | |
815 | PrintAt (\r | |
816 | (gScreenDimensions.LeftColumn + gPromptBlockWidth + gOptionBlockWidth + Index),\r | |
817 | gScreenDimensions.BottomRow - 1,\r | |
818 | (CHAR16 *) L" "\r | |
819 | );\r | |
820 | }\r | |
821 | \r | |
822 | gNvUpdateRequired = FALSE;\r | |
823 | }\r | |
824 | }\r | |
825 | break;\r | |
826 | \r | |
827 | case REFRESH_STATUS_BAR:\r | |
828 | if (InputError) {\r | |
829 | UpdateStatusBar (INPUT_ERROR, Flags, TRUE);\r | |
830 | }\r | |
831 | \r | |
832 | if (gNvUpdateRequired) {\r | |
833 | UpdateStatusBar (NV_UPDATE_REQUIRED, Flags, TRUE);\r | |
834 | }\r | |
835 | break;\r | |
836 | \r | |
837 | default:\r | |
838 | break;\r | |
839 | }\r | |
840 | \r | |
841 | gBS->FreePool (InputErrorMessage);\r | |
842 | gBS->FreePool (NvUpdateMessage);\r | |
843 | return ;\r | |
844 | }\r | |
845 | \r | |
846 | VOID\r | |
847 | FreeData (\r | |
848 | IN EFI_FILE_FORM_TAGS *FileFormTagsHead,\r | |
849 | IN CHAR16 *FormattedString,\r | |
850 | IN CHAR16 *OptionString\r | |
851 | )\r | |
852 | /*++\r | |
853 | \r | |
854 | Routine Description:\r | |
855 | \r | |
856 | Used to remove the allocated data instances\r | |
857 | \r | |
858 | Arguments:\r | |
859 | \r | |
860 | Returns:\r | |
861 | \r | |
862 | --*/\r | |
863 | {\r | |
864 | EFI_FILE_FORM_TAGS *FileForm;\r | |
865 | EFI_FILE_FORM_TAGS *PreviousFileForm;\r | |
866 | EFI_FORM_TAGS *FormTags;\r | |
867 | EFI_FORM_TAGS *PreviousFormTags;\r | |
868 | EFI_IFR_BINARY *IfrBinary;\r | |
869 | EFI_IFR_BINARY *PreviousIfrBinary;\r | |
870 | EFI_INCONSISTENCY_DATA *Inconsistent;\r | |
871 | EFI_VARIABLE_DEFINITION *VariableDefinition;\r | |
872 | EFI_VARIABLE_DEFINITION *PreviousVariableDefinition;\r | |
873 | VOID *Buffer;\r | |
874 | UINTN Index;\r | |
875 | \r | |
876 | FileForm = FileFormTagsHead;\r | |
877 | \r | |
878 | if (FormattedString != NULL) {\r | |
879 | gBS->FreePool (FormattedString);\r | |
880 | }\r | |
881 | \r | |
882 | if (OptionString != NULL) {\r | |
883 | gBS->FreePool (OptionString);\r | |
884 | }\r | |
885 | \r | |
886 | for (; FileForm != NULL;) {\r | |
887 | PreviousFileForm = NULL;\r | |
888 | \r | |
889 | //\r | |
890 | // Advance FileForm to the last entry\r | |
891 | //\r | |
892 | for (; FileForm->NextFile != NULL; FileForm = FileForm->NextFile) {\r | |
893 | PreviousFileForm = FileForm;\r | |
894 | }\r | |
895 | \r | |
896 | FormTags = &FileForm->FormTags;\r | |
897 | \r | |
898 | for (; FormTags != NULL;) {\r | |
899 | FormTags = &FileForm->FormTags;\r | |
900 | PreviousFormTags = NULL;\r | |
901 | \r | |
902 | //\r | |
903 | // Advance FormTags to the last entry\r | |
904 | //\r | |
905 | for (; FormTags->Next != NULL; FormTags = FormTags->Next) {\r | |
906 | PreviousFormTags = FormTags;\r | |
907 | }\r | |
908 | //\r | |
909 | // Walk through each of the tags and free the IntList allocation\r | |
910 | //\r | |
911 | for (Index = 0; FormTags->Tags[Index].Operand != EFI_IFR_END_FORM_OP; Index++) {\r | |
912 | //\r | |
913 | // It is more than likely that the very last page will contain an end formset\r | |
914 | //\r | |
915 | if (FormTags->Tags[Index].Operand == EFI_IFR_END_FORM_SET_OP) {\r | |
916 | break;\r | |
917 | }\r | |
918 | \r | |
919 | if (FormTags->Tags[Index].IntList != NULL) {\r | |
920 | gBS->FreePool (FormTags->Tags[Index].IntList);\r | |
921 | }\r | |
922 | }\r | |
923 | \r | |
924 | if (PreviousFormTags != NULL) {\r | |
925 | gBS->FreePool (FormTags->Tags);\r | |
926 | FormTags = PreviousFormTags;\r | |
927 | gBS->FreePool (FormTags->Next);\r | |
928 | FormTags->Next = NULL;\r | |
929 | } else {\r | |
930 | gBS->FreePool (FormTags->Tags);\r | |
931 | FormTags = NULL;\r | |
932 | }\r | |
933 | }\r | |
934 | //\r | |
935 | // Last FileForm entry's Inconsistent database\r | |
936 | //\r | |
937 | Inconsistent = FileForm->InconsistentTags;\r | |
938 | \r | |
939 | //\r | |
940 | // Advance Inconsistent to the last entry\r | |
941 | //\r | |
942 | for (; Inconsistent->Next != NULL; Inconsistent = Inconsistent->Next)\r | |
943 | ;\r | |
944 | \r | |
945 | for (; Inconsistent != NULL;) {\r | |
946 | //\r | |
947 | // Preserve the Previous pointer\r | |
948 | //\r | |
949 | Buffer = (VOID *) Inconsistent->Previous;\r | |
950 | \r | |
951 | //\r | |
952 | // Free the current entry\r | |
953 | //\r | |
954 | gBS->FreePool (Inconsistent);\r | |
955 | \r | |
956 | //\r | |
957 | // Restore the Previous pointer\r | |
958 | //\r | |
959 | Inconsistent = (EFI_INCONSISTENCY_DATA *) Buffer;\r | |
960 | }\r | |
961 | \r | |
962 | VariableDefinition = FileForm->VariableDefinitions;\r | |
963 | \r | |
964 | for (; VariableDefinition != NULL;) {\r | |
965 | VariableDefinition = FileForm->VariableDefinitions;\r | |
966 | PreviousVariableDefinition = NULL;\r | |
967 | \r | |
968 | //\r | |
969 | // Advance VariableDefinitions to the last entry\r | |
970 | //\r | |
971 | for (; VariableDefinition->Next != NULL; VariableDefinition = VariableDefinition->Next) {\r | |
972 | PreviousVariableDefinition = VariableDefinition;\r | |
973 | }\r | |
974 | \r | |
975 | gBS->FreePool (VariableDefinition->VariableName);\r | |
976 | gBS->FreePool (VariableDefinition->NvRamMap);\r | |
977 | gBS->FreePool (VariableDefinition->FakeNvRamMap);\r | |
978 | \r | |
979 | if (PreviousVariableDefinition != NULL) {\r | |
980 | VariableDefinition = PreviousVariableDefinition;\r | |
981 | gBS->FreePool (VariableDefinition->Next);\r | |
982 | VariableDefinition->Next = NULL;\r | |
983 | } else {\r | |
984 | gBS->FreePool (VariableDefinition);\r | |
985 | VariableDefinition = NULL;\r | |
986 | }\r | |
987 | }\r | |
988 | \r | |
989 | if (PreviousFileForm != NULL) {\r | |
990 | FileForm = PreviousFileForm;\r | |
991 | gBS->FreePool (FileForm->NextFile);\r | |
992 | FileForm->NextFile = NULL;\r | |
993 | } else {\r | |
994 | gBS->FreePool (FileForm);\r | |
995 | FileForm = NULL;\r | |
996 | }\r | |
997 | }\r | |
998 | \r | |
999 | IfrBinary = gBinaryDataHead;\r | |
1000 | \r | |
1001 | for (; IfrBinary != NULL;) {\r | |
1002 | IfrBinary = gBinaryDataHead;\r | |
1003 | PreviousIfrBinary = NULL;\r | |
1004 | \r | |
1005 | //\r | |
1006 | // Advance IfrBinary to the last entry\r | |
1007 | //\r | |
1008 | for (; IfrBinary->Next != NULL; IfrBinary = IfrBinary->Next) {\r | |
1009 | PreviousIfrBinary = IfrBinary;\r | |
1010 | }\r | |
1011 | \r | |
1012 | gBS->FreePool (IfrBinary->IfrPackage);\r | |
1013 | \r | |
1014 | if (PreviousIfrBinary != NULL) {\r | |
1015 | IfrBinary = PreviousIfrBinary;\r | |
1016 | gBS->FreePool (IfrBinary->Next);\r | |
1017 | IfrBinary->Next = NULL;\r | |
1018 | } else {\r | |
1019 | gBS->FreePool (IfrBinary);\r | |
1020 | IfrBinary = NULL;\r | |
1021 | }\r | |
1022 | }\r | |
1023 | \r | |
1024 | gBS->FreePool (gPreviousValue);\r | |
1025 | gPreviousValue = NULL;\r | |
1026 | \r | |
1027 | //\r | |
1028 | // Free Browser Strings\r | |
1029 | //\r | |
1030 | gBS->FreePool (gPressEnter);\r | |
1031 | gBS->FreePool (gConfirmError);\r | |
1032 | gBS->FreePool (gConfirmPassword);\r | |
1033 | gBS->FreePool (gPromptForNewPassword);\r | |
1034 | gBS->FreePool (gPromptForPassword);\r | |
1035 | gBS->FreePool (gToggleCheckBox);\r | |
1036 | gBS->FreePool (gNumericInput);\r | |
1037 | gBS->FreePool (gMakeSelection);\r | |
1038 | gBS->FreePool (gMoveHighlight);\r | |
1039 | gBS->FreePool (gEscapeString);\r | |
1040 | gBS->FreePool (gEnterCommitString);\r | |
1041 | gBS->FreePool (gEnterString);\r | |
1042 | gBS->FreePool (gFunctionOneString);\r | |
1043 | gBS->FreePool (gFunctionTwoString);\r | |
1044 | gBS->FreePool (gFunctionNineString);\r | |
1045 | gBS->FreePool (gFunctionTenString);\r | |
1046 | return ;\r | |
1047 | }\r | |
1048 | \r | |
1049 | BOOLEAN\r | |
1050 | SelectionsAreValid (\r | |
1051 | IN UI_MENU_OPTION *MenuOption,\r | |
1052 | IN EFI_FILE_FORM_TAGS *FileFormTagsHead\r | |
1053 | )\r | |
1054 | /*++\r | |
1055 | \r | |
1056 | Routine Description:\r | |
1057 | Initiate late consistency checks against the current page. \r | |
1058 | \r | |
1059 | Arguments:\r | |
1060 | None\r | |
1061 | \r | |
1062 | Returns:\r | |
1063 | \r | |
1064 | --*/\r | |
1065 | {\r | |
1066 | LIST_ENTRY *Link;\r | |
1067 | EFI_TAG *Tag;\r | |
1068 | EFI_FILE_FORM_TAGS *FileFormTags;\r | |
1069 | CHAR16 *StringPtr;\r | |
1070 | CHAR16 NullCharacter;\r | |
1071 | EFI_STATUS Status;\r | |
1072 | UINTN Index;\r | |
1073 | UINT16 *NvRamMap;\r | |
1074 | STRING_REF PopUp;\r | |
1075 | EFI_INPUT_KEY Key;\r | |
1076 | EFI_VARIABLE_DEFINITION *VariableDefinition;\r | |
1077 | \r | |
1078 | StringPtr = (CHAR16 *) L"\0";\r | |
1079 | NullCharacter = CHAR_NULL;\r | |
1080 | \r | |
1081 | FileFormTags = FileFormTagsHead;\r | |
1082 | \r | |
1083 | for (Index = 0; Index < MenuOption->IfrNumber; Index++) {\r | |
1084 | FileFormTags = FileFormTags->NextFile;\r | |
1085 | }\r | |
1086 | \r | |
1087 | for (Link = Menu.ForwardLink; Link != &Menu; Link = Link->ForwardLink) {\r | |
1088 | MenuOption = CR (Link, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
1089 | \r | |
1090 | Tag = MenuOption->ThisTag;\r | |
1091 | \r | |
1092 | ExtractRequestedNvMap (FileFormTags, Tag->VariableNumber, &VariableDefinition);\r | |
1093 | NvRamMap = (UINT16 *) &VariableDefinition->NvRamMap[Tag->StorageStart];\r | |
1094 | \r | |
1095 | //\r | |
1096 | // If the op-code has a late check, ensure consistency checks are now applied\r | |
1097 | //\r | |
1098 | if (Tag->Flags & EFI_IFR_FLAG_LATE_CHECK) {\r | |
1099 | if (ValueIsNotValid (TRUE, 0, Tag, FileFormTags, &PopUp)) {\r | |
1100 | if (PopUp != 0x0000) {\r | |
1101 | StringPtr = GetToken (PopUp, MenuOption->Handle);\r | |
1102 | \r | |
1103 | CreatePopUp (GetStringWidth (StringPtr) / 2, 3, &NullCharacter, StringPtr, &NullCharacter);\r | |
1104 | \r | |
1105 | do {\r | |
1106 | Status = WaitForKeyStroke (&Key);\r | |
1107 | \r | |
1108 | switch (Key.UnicodeChar) {\r | |
1109 | \r | |
1110 | case CHAR_CARRIAGE_RETURN:\r | |
1111 | //\r | |
1112 | // Since the value can be one byte long or two bytes long, do a CopyMem based on StorageWidth\r | |
1113 | //\r | |
1114 | CopyMem (NvRamMap, &Tag->OldValue, Tag->StorageWidth);\r | |
1115 | gBS->FreePool (StringPtr);\r | |
1116 | break;\r | |
1117 | \r | |
1118 | default:\r | |
1119 | break;\r | |
1120 | }\r | |
1121 | } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r | |
1122 | }\r | |
1123 | \r | |
1124 | return FALSE;\r | |
1125 | }\r | |
1126 | }\r | |
1127 | }\r | |
1128 | \r | |
1129 | return TRUE;\r | |
1130 | }\r | |
1131 | \r | |
1132 | UINT16\r | |
1133 | GetWidth (\r | |
1134 | IN EFI_TAG *Tag,\r | |
1135 | IN EFI_HII_HANDLE Handle\r | |
1136 | )\r | |
1137 | /*++\r | |
1138 | \r | |
1139 | Routine Description:\r | |
1140 | Get the supported width for a particular op-code\r | |
1141 | \r | |
1142 | Arguments:\r | |
1143 | Tag - The Tag structure passed in.\r | |
1144 | Handle - The handle in the HII database being used\r | |
1145 | \r | |
1146 | Returns:\r | |
1147 | Returns the number of CHAR16 characters that is support.\r | |
1148 | \r | |
1149 | \r | |
1150 | --*/\r | |
1151 | {\r | |
1152 | CHAR16 *String;\r | |
1153 | UINTN Size;\r | |
1154 | \r | |
1155 | Size = 0x00;\r | |
1156 | \r | |
1157 | //\r | |
1158 | // See if the second text parameter is really NULL\r | |
1159 | //\r | |
1160 | if ((Tag->Operand == EFI_IFR_TEXT_OP) && (Tag->TextTwo != 0)) {\r | |
1161 | String = GetToken (Tag->TextTwo, Handle);\r | |
1162 | Size = StrLen (String);\r | |
1163 | gBS->FreePool (String);\r | |
1164 | }\r | |
1165 | \r | |
1166 | if ((Tag->Operand == EFI_IFR_SUBTITLE_OP) ||\r | |
1167 | (Tag->Operand == EFI_IFR_REF_OP) ||\r | |
1168 | (Tag->Operand == EFI_IFR_PASSWORD_OP) ||\r | |
1169 | (Tag->Operand == EFI_IFR_STRING_OP) ||\r | |
1170 | (Tag->Operand == EFI_IFR_INVENTORY_OP) ||\r | |
1171 | //\r | |
1172 | // Allow a wide display if text op-code and no secondary text op-code\r | |
1173 | //\r | |
1174 | ((Tag->Operand == EFI_IFR_TEXT_OP) && (Size == 0x0000))\r | |
1175 | ) {\r | |
1176 | return (UINT16) (gPromptBlockWidth + gOptionBlockWidth);\r | |
1177 | } else {\r | |
1178 | return (UINT16) gPromptBlockWidth;\r | |
1179 | }\r | |
1180 | }\r | |
1181 | \r | |
1182 | UINT16\r | |
1183 | GetLineByWidth (\r | |
1184 | IN CHAR16 *InputString,\r | |
1185 | IN UINT16 LineWidth,\r | |
1186 | IN OUT UINTN *Index,\r | |
1187 | OUT CHAR16 **OutputString\r | |
1188 | )\r | |
1189 | /*++\r | |
1190 | \r | |
1191 | Routine Description:\r | |
1192 | Will copy LineWidth amount of a string in the OutputString buffer and return the\r | |
1193 | number of CHAR16 characters that were copied into the OutputString buffer.\r | |
1194 | \r | |
1195 | Arguments:\r | |
1196 | InputString - String description for this option.\r | |
1197 | LineWidth - Width of the desired string to extract in CHAR16 characters\r | |
1198 | Index - Where in InputString to start the copy process\r | |
1199 | OutputString - Buffer to copy the string into\r | |
1200 | \r | |
1201 | Returns:\r | |
1202 | Returns the number of CHAR16 characters that were copied into the OutputString buffer.\r | |
1203 | \r | |
1204 | \r | |
1205 | --*/\r | |
1206 | {\r | |
1207 | static BOOLEAN Finished;\r | |
1208 | UINT16 Count;\r | |
1209 | UINT16 Count2;\r | |
1210 | \r | |
1211 | if (Finished) {\r | |
1212 | Finished = FALSE;\r | |
1213 | return (UINT16) 0;\r | |
1214 | }\r | |
1215 | \r | |
1216 | Count = LineWidth;\r | |
1217 | Count2 = 0;\r | |
1218 | \r | |
1219 | *OutputString = AllocateZeroPool (((UINTN) (LineWidth + 1) * 2));\r | |
1220 | \r | |
1221 | //\r | |
1222 | // Ensure we have got a valid buffer\r | |
1223 | //\r | |
1224 | if (*OutputString != NULL) {\r | |
1225 | //\r | |
1226 | // Fast-forward the string and see if there is a carriage-return in the string\r | |
1227 | //\r | |
1228 | for (; (InputString[*Index + Count2] != CHAR_CARRIAGE_RETURN) && (Count2 != LineWidth); Count2++)\r | |
1229 | ;\r | |
1230 | \r | |
1231 | //\r | |
1232 | // Copy the desired LineWidth of data to the output buffer.\r | |
1233 | // Also make sure that we don't copy more than the string.\r | |
1234 | // Also make sure that if there are linefeeds, we account for them.\r | |
1235 | //\r | |
1236 | if ((StrSize (&InputString[*Index]) <= ((UINTN) (LineWidth + 1) * 2)) &&\r | |
1237 | (StrSize (&InputString[*Index]) <= ((UINTN) (Count2 + 1) * 2))\r | |
1238 | ) {\r | |
1239 | //\r | |
1240 | // Convert to CHAR16 value and show that we are done with this operation\r | |
1241 | //\r | |
1242 | LineWidth = (UINT16) ((StrSize (&InputString[*Index]) - 2) / 2);\r | |
1243 | if (LineWidth != 0) {\r | |
1244 | Finished = TRUE;\r | |
1245 | }\r | |
1246 | } else {\r | |
1247 | if (Count2 == LineWidth) {\r | |
1248 | //\r | |
1249 | // Rewind the string from the maximum size until we see a space to break the line\r | |
1250 | //\r | |
1251 | for (; (InputString[*Index + LineWidth] != CHAR_SPACE) && (LineWidth != 0); LineWidth--)\r | |
1252 | ;\r | |
1253 | if (LineWidth == 0) {\r | |
1254 | LineWidth = Count;\r | |
1255 | }\r | |
1256 | } else {\r | |
1257 | LineWidth = Count2;\r | |
1258 | }\r | |
1259 | }\r | |
1260 | \r | |
1261 | CopyMem (*OutputString, &InputString[*Index], LineWidth * 2);\r | |
1262 | \r | |
1263 | //\r | |
1264 | // If currently pointing to a space, increment the index to the first non-space character\r | |
1265 | //\r | |
1266 | for (;\r | |
1267 | (InputString[*Index + LineWidth] == CHAR_SPACE) || (InputString[*Index + LineWidth] == CHAR_CARRIAGE_RETURN);\r | |
1268 | (*Index)++\r | |
1269 | )\r | |
1270 | ;\r | |
1271 | *Index = (UINT16) (*Index + LineWidth);\r | |
1272 | return LineWidth;\r | |
1273 | } else {\r | |
1274 | return (UINT16) 0;\r | |
1275 | }\r | |
1276 | }\r | |
1277 | \r | |
1278 | VOID\r | |
1279 | UpdateOptionSkipLines (\r | |
1280 | IN EFI_IFR_DATA_ARRAY *PageData,\r | |
1281 | IN UI_MENU_OPTION *MenuOption,\r | |
1282 | IN EFI_FILE_FORM_TAGS *FileFormTagsHead,\r | |
1283 | IN CHAR16 **OptionalString,\r | |
1284 | IN UINTN SkipValue\r | |
1285 | )\r | |
1286 | {\r | |
1287 | UINTN Index;\r | |
1288 | UINTN Loop;\r | |
1289 | UINT16 Width;\r | |
1290 | UINTN Row;\r | |
1291 | UINTN OriginalRow;\r | |
1292 | CHAR16 *OutputString;\r | |
1293 | CHAR16 *OptionString;\r | |
1294 | \r | |
1295 | Row = 0;\r | |
1296 | OptionString = *OptionalString;\r | |
1297 | OutputString = NULL;\r | |
1298 | \r | |
1299 | ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r | |
1300 | \r | |
1301 | if (OptionString != NULL) {\r | |
1302 | //\r | |
1303 | // If leading spaces on OptionString - remove the spaces\r | |
1304 | //\r | |
1305 | for (Index = 0; OptionString[Index] == L' '; Index++)\r | |
1306 | ;\r | |
1307 | \r | |
1308 | for (Loop = 0; OptionString[Index] != CHAR_NULL; Index++) {\r | |
1309 | OptionString[Loop] = OptionString[Index];\r | |
1310 | Loop++;\r | |
1311 | }\r | |
1312 | \r | |
1313 | OptionString[Loop] = CHAR_NULL;\r | |
1314 | \r | |
1315 | Width = (UINT16) gOptionBlockWidth;\r | |
1316 | \r | |
1317 | OriginalRow = Row;\r | |
1318 | \r | |
1319 | for (Index = 0; GetLineByWidth (OptionString, Width, &Index, &OutputString) != 0x0000;) {\r | |
1320 | //\r | |
1321 | // If there is more string to process print on the next row and increment the Skip value\r | |
1322 | //\r | |
1323 | if (StrLen (&OptionString[Index])) {\r | |
1324 | if (SkipValue == 0) {\r | |
1325 | Row++;\r | |
1326 | //\r | |
1327 | // Since the Number of lines for this menu entry may or may not be reflected accurately\r | |
1328 | // since the prompt might be 1 lines and option might be many, and vice versa, we need to do\r | |
1329 | // some testing to ensure we are keeping this in-sync.\r | |
1330 | //\r | |
1331 | // If the difference in rows is greater than or equal to the skip value, increase the skip value\r | |
1332 | //\r | |
1333 | if ((Row - OriginalRow) >= MenuOption->Skip) {\r | |
1334 | MenuOption->Skip++;\r | |
1335 | }\r | |
1336 | }\r | |
1337 | }\r | |
1338 | \r | |
1339 | gBS->FreePool (OutputString);\r | |
1340 | if (SkipValue != 0) {\r | |
1341 | SkipValue--;\r | |
1342 | }\r | |
1343 | }\r | |
1344 | \r | |
1345 | Row = OriginalRow;\r | |
1346 | }\r | |
1347 | \r | |
1348 | *OptionalString = OptionString;\r | |
1349 | }\r | |
1350 | //\r | |
1351 | // Search table for UiDisplayMenu()\r | |
1352 | //\r | |
1353 | SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation[] = {\r | |
1354 | { SCAN_UP, UiUp },\r | |
1355 | { SCAN_DOWN, UiDown },\r | |
1356 | { SCAN_PAGE_UP, UiPageUp },\r | |
1357 | { SCAN_PAGE_DOWN, UiPageDown},\r | |
1358 | { SCAN_ESC, UiReset},\r | |
1359 | { SCAN_F2, UiPrevious},\r | |
1360 | { SCAN_LEFT, UiLeft },\r | |
1361 | { SCAN_RIGHT, UiRight },\r | |
1362 | { SCAN_F9, UiDefault},\r | |
1363 | { SCAN_F10, UiSave }\r | |
1364 | };\r | |
1365 | \r | |
1366 | SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag[] = {\r | |
1367 | { UiNoOperation, CfUiNoOperation },\r | |
1368 | { UiDefault, CfUiDefault },\r | |
1369 | { UiSelect, CfUiSelect },\r | |
1370 | { UiUp, CfUiUp},\r | |
1371 | { UiDown, CfUiDown },\r | |
1372 | { UiLeft, CfUiLeft },\r | |
1373 | { UiRight, CfUiRight },\r | |
1374 | { UiReset, CfUiReset },\r | |
1375 | { UiSave, CfUiSave },\r | |
1376 | { UiPrevious, CfUiPrevious },\r | |
1377 | { UiPageUp, CfUiPageUp },\r | |
1378 | { UiPageDown, CfUiPageDown }\r | |
1379 | };\r | |
1380 | \r | |
1381 | UI_MENU_OPTION *\r | |
1382 | UiDisplayMenu (\r | |
1383 | IN BOOLEAN SubMenu,\r | |
1384 | IN EFI_FILE_FORM_TAGS *FileFormTagsHead,\r | |
1385 | OUT EFI_IFR_DATA_ARRAY *PageData\r | |
1386 | )\r | |
1387 | /*++\r | |
1388 | \r | |
1389 | Routine Description:\r | |
1390 | Display menu and wait for user to select one menu option, then return it.\r | |
1391 | If AutoBoot is enabled, then if user doesn't select any option,\r | |
1392 | after period of time, it will automatically return the first menu option.\r | |
1393 | \r | |
1394 | Arguments:\r | |
1395 | SubMenu - Indicate is sub menu.\r | |
1396 | FileFormTagsHead - A pointer to the EFI_FILE_FORM_TAGS structure.\r | |
1397 | PageData - A pointer to the EFI_IFR_DATA_ARRAY.\r | |
1398 | \r | |
1399 | Returns:\r | |
1400 | Return the pointer of the menu which selected, \r | |
1401 | otherwise return NULL.\r | |
1402 | \r | |
1403 | --*/\r | |
1404 | {\r | |
1405 | INTN SkipValue;\r | |
1406 | INTN Difference;\r | |
1407 | INTN OldSkipValue;\r | |
1408 | UINTN Row;\r | |
1409 | UINTN Col;\r | |
1410 | UINTN Temp;\r | |
1411 | UINTN Temp2;\r | |
1412 | UINTN TopRow;\r | |
1413 | UINTN BottomRow;\r | |
1414 | UINTN OriginalRow;\r | |
1415 | UINTN Index;\r | |
1416 | UINTN DataAndTimeLineNumberPad;\r | |
1417 | UINT32 Count;\r | |
1418 | INT16 OriginalTimeOut;\r | |
1419 | UINT8 *Location;\r | |
1420 | UINT16 Width;\r | |
1421 | CHAR16 *StringPtr;\r | |
1422 | CHAR16 *OptionString;\r | |
1423 | CHAR16 *OutputString;\r | |
1424 | CHAR16 *FormattedString;\r | |
1425 | CHAR16 YesResponse;\r | |
1426 | CHAR16 NoResponse;\r | |
1427 | BOOLEAN NewLine;\r | |
1428 | BOOLEAN Repaint;\r | |
1429 | BOOLEAN SavedValue;\r | |
1430 | EFI_STATUS Status;\r | |
1431 | UI_MENU_LIST *UiMenuList;\r | |
1432 | EFI_INPUT_KEY Key;\r | |
1433 | LIST_ENTRY *Link;\r | |
1434 | LIST_ENTRY *NewPos;\r | |
1435 | LIST_ENTRY *TopOfScreen;\r | |
1436 | LIST_ENTRY *SavedListEntry;\r | |
1437 | UI_MENU_OPTION *Selection;\r | |
1438 | UI_MENU_OPTION *MenuOption;\r | |
1439 | UI_MENU_OPTION *NextMenuOption;\r | |
1440 | UI_MENU_OPTION *SavedMenuOption;\r | |
1441 | UI_MENU_OPTION *PreviousMenuOption;\r | |
1442 | EFI_IFR_BINARY *IfrBinary;\r | |
1443 | UI_CONTROL_FLAG ControlFlag;\r | |
1444 | EFI_SCREEN_DESCRIPTOR LocalScreen;\r | |
1445 | EFI_FILE_FORM_TAGS *FileFormTags;\r | |
1446 | MENU_REFRESH_ENTRY *MenuRefreshEntry;\r | |
1447 | MENU_REFRESH_ENTRY *OldMenuRefreshEntry;\r | |
1448 | UI_SCREEN_OPERATION ScreenOperation;\r | |
1449 | EFI_VARIABLE_DEFINITION *VariableDefinition;\r | |
1450 | EFI_FORM_CALLBACK_PROTOCOL *FormCallback;\r | |
1451 | EFI_HII_VARIABLE_PACK_LIST *NvMapListHead;\r | |
1452 | EFI_HII_VARIABLE_PACK_LIST *NvMapListNode;\r | |
1453 | VOID *NvMap;\r | |
1454 | UINTN NvMapSize;\r | |
1455 | \r | |
1456 | CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));\r | |
1457 | \r | |
1458 | VariableDefinition = NULL;\r | |
1459 | Status = EFI_SUCCESS;\r | |
1460 | FormattedString = NULL;\r | |
1461 | OptionString = NULL;\r | |
1462 | ScreenOperation = UiNoOperation;\r | |
1463 | NewLine = TRUE;\r | |
1464 | FormCallback = NULL;\r | |
1465 | FileFormTags = NULL;\r | |
1466 | OutputString = NULL;\r | |
1467 | gUpArrow = FALSE;\r | |
1468 | gDownArrow = FALSE;\r | |
1469 | SkipValue = 0;\r | |
1470 | OldSkipValue = 0;\r | |
1471 | MenuRefreshEntry = gMenuRefreshHead;\r | |
1472 | OldMenuRefreshEntry = gMenuRefreshHead;\r | |
1473 | NextMenuOption = NULL;\r | |
1474 | PreviousMenuOption = NULL;\r | |
1475 | SavedMenuOption = NULL;\r | |
1476 | IfrBinary = NULL;\r | |
1477 | NvMap = NULL;\r | |
1478 | NvMapSize = 0;\r | |
1479 | \r | |
1480 | ZeroMem (&Key, sizeof (EFI_INPUT_KEY));\r | |
1481 | \r | |
1482 | if (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) {\r | |
1483 | TopRow = LocalScreen.TopRow + FRONT_PAGE_HEADER_HEIGHT + SCROLL_ARROW_HEIGHT;\r | |
1484 | Row = LocalScreen.TopRow + FRONT_PAGE_HEADER_HEIGHT + SCROLL_ARROW_HEIGHT;\r | |
1485 | } else {\r | |
1486 | TopRow = LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT + SCROLL_ARROW_HEIGHT;\r | |
1487 | Row = LocalScreen.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT + SCROLL_ARROW_HEIGHT;\r | |
1488 | }\r | |
1489 | \r | |
1490 | if (SubMenu) {\r | |
1491 | Col = LocalScreen.LeftColumn;\r | |
1492 | } else {\r | |
1493 | Col = LocalScreen.LeftColumn + LEFT_SKIPPED_COLUMNS;\r | |
1494 | }\r | |
1495 | \r | |
1496 | BottomRow = LocalScreen.BottomRow - STATUS_BAR_HEIGHT - FOOTER_HEIGHT - SCROLL_ARROW_HEIGHT - 1;\r | |
1497 | \r | |
1498 | TopOfScreen = Menu.ForwardLink;\r | |
1499 | Repaint = TRUE;\r | |
1500 | MenuOption = NULL;\r | |
1501 | \r | |
1502 | //\r | |
1503 | // Get user's selection\r | |
1504 | //\r | |
1505 | Selection = NULL;\r | |
1506 | NewPos = Menu.ForwardLink;\r | |
1507 | gST->ConOut->EnableCursor (gST->ConOut, FALSE);\r | |
1508 | \r | |
1509 | UpdateStatusBar (REFRESH_STATUS_BAR, (UINT8) 0, TRUE);\r | |
1510 | \r | |
1511 | ControlFlag = CfInitialization;\r | |
1512 | \r | |
1513 | while (TRUE) {\r | |
1514 | switch (ControlFlag) {\r | |
1515 | case CfInitialization:\r | |
1516 | ControlFlag = CfCheckSelection;\r | |
1517 | if (gExitRequired) {\r | |
1518 | ScreenOperation = UiReset;\r | |
1519 | ControlFlag = CfScreenOperation;\r | |
1520 | } else if (gSaveRequired) {\r | |
1521 | ScreenOperation = UiSave;\r | |
1522 | ControlFlag = CfScreenOperation;\r | |
1523 | } else if (IsListEmpty (&Menu)) {\r | |
1524 | ControlFlag = CfReadKey;\r | |
1525 | }\r | |
1526 | break;\r | |
1527 | \r | |
1528 | case CfCheckSelection:\r | |
1529 | if (Selection != NULL) {\r | |
1530 | ControlFlag = CfExit;\r | |
1531 | } else {\r | |
1532 | ControlFlag = CfRepaint;\r | |
1533 | }\r | |
1534 | \r | |
1535 | FileFormTags = FileFormTagsHead;\r | |
1536 | break;\r | |
1537 | \r | |
1538 | case CfRepaint:\r | |
1539 | ControlFlag = CfRefreshHighLight;\r | |
1540 | \r | |
1541 | if (Repaint) {\r | |
1542 | //\r | |
1543 | // Display menu\r | |
1544 | //\r | |
1545 | SavedMenuOption = MenuOption;\r | |
1546 | gDownArrow = FALSE;\r | |
1547 | gUpArrow = FALSE;\r | |
1548 | Row = TopRow;\r | |
1549 | \r | |
1550 | Temp = SkipValue;\r | |
1551 | Temp2 = SkipValue;\r | |
1552 | \r | |
1553 | ClearLines (\r | |
1554 | LocalScreen.LeftColumn,\r | |
1555 | LocalScreen.RightColumn,\r | |
1556 | TopRow - SCROLL_ARROW_HEIGHT,\r | |
1557 | BottomRow + SCROLL_ARROW_HEIGHT,\r | |
1558 | FIELD_TEXT | FIELD_BACKGROUND\r | |
1559 | );\r | |
1560 | \r | |
1561 | while (gMenuRefreshHead != NULL) {\r | |
1562 | OldMenuRefreshEntry = gMenuRefreshHead->Next;\r | |
1563 | \r | |
1564 | gBS->FreePool (gMenuRefreshHead);\r | |
1565 | \r | |
1566 | gMenuRefreshHead = OldMenuRefreshEntry;\r | |
1567 | }\r | |
1568 | \r | |
1569 | for (Link = TopOfScreen; Link != &Menu; Link = Link->ForwardLink) {\r | |
1570 | MenuOption = CR (Link, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
1571 | MenuOption->Row = Row;\r | |
1572 | OriginalRow = Row;\r | |
1573 | MenuOption->Col = Col;\r | |
1574 | MenuOption->OptCol = gPromptBlockWidth + 1 + LocalScreen.LeftColumn;\r | |
1575 | \r | |
1576 | if (SubMenu) {\r | |
1577 | if (MenuOption->ThisTag->GrayOut) {\r | |
1578 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_GRAYED | FIELD_BACKGROUND);\r | |
1579 | } else {\r | |
1580 | if (MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP) {\r | |
1581 | gST->ConOut->SetAttribute (gST->ConOut, SUBTITLE_TEXT | FIELD_BACKGROUND);\r | |
1582 | }\r | |
1583 | }\r | |
1584 | \r | |
1585 | Width = GetWidth (MenuOption->ThisTag, MenuOption->Handle);\r | |
1586 | \r | |
1587 | OriginalRow = Row;\r | |
1588 | \r | |
1589 | for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &Index, &OutputString) != 0x0000;) {\r | |
1590 | if ((Temp == 0) && (Row <= BottomRow)) {\r | |
1591 | PrintStringAt (Col, Row, OutputString);\r | |
1592 | }\r | |
1593 | //\r | |
1594 | // If there is more string to process print on the next row and increment the Skip value\r | |
1595 | //\r | |
1596 | if (StrLen (&MenuOption->Description[Index])) {\r | |
1597 | if (Temp == 0) {\r | |
1598 | Row++;\r | |
1599 | }\r | |
1600 | }\r | |
1601 | \r | |
1602 | gBS->FreePool (OutputString);\r | |
1603 | if (Temp != 0) {\r | |
1604 | Temp--;\r | |
1605 | }\r | |
1606 | }\r | |
1607 | \r | |
1608 | Temp = 0;\r | |
1609 | \r | |
1610 | Row = OriginalRow;\r | |
1611 | \r | |
1612 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1613 | ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r | |
1614 | \r | |
1615 | if (OptionString != NULL) {\r | |
1616 | //\r | |
1617 | // If leading spaces on OptionString - remove the spaces\r | |
1618 | //\r | |
1619 | for (Index = 0; OptionString[Index] == L' '; Index++) {\r | |
1620 | MenuOption->OptCol++;\r | |
1621 | }\r | |
1622 | \r | |
1623 | for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r | |
1624 | OptionString[Count] = OptionString[Index];\r | |
1625 | Count++;\r | |
1626 | }\r | |
1627 | \r | |
1628 | OptionString[Count] = CHAR_NULL;\r | |
1629 | \r | |
1630 | //\r | |
1631 | // If this is a date or time op-code and is used to reflect an RTC, register the op-code\r | |
1632 | //\r | |
1633 | if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP ||\r | |
1634 | MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP) &&\r | |
1635 | (MenuOption->ThisTag->StorageStart >= FileFormTags->FormTags.Tags[0].NvDataSize)) {\r | |
1636 | \r | |
1637 | if (gMenuRefreshHead == NULL) {\r | |
1638 | MenuRefreshEntry = AllocateZeroPool (sizeof (MENU_REFRESH_ENTRY));\r | |
1639 | ASSERT (MenuRefreshEntry != NULL);\r | |
1640 | MenuRefreshEntry->MenuOption = MenuOption;\r | |
1641 | MenuRefreshEntry->FileFormTagsHead = FileFormTagsHead;\r | |
1642 | MenuRefreshEntry->CurrentColumn = MenuOption->OptCol;\r | |
1643 | MenuRefreshEntry->CurrentRow = MenuOption->Row;\r | |
1644 | MenuRefreshEntry->CurrentAttribute = FIELD_TEXT | FIELD_BACKGROUND;\r | |
1645 | gMenuRefreshHead = MenuRefreshEntry;\r | |
1646 | } else {\r | |
1647 | //\r | |
1648 | // Advance to the last entry\r | |
1649 | //\r | |
1650 | for (MenuRefreshEntry = gMenuRefreshHead;\r | |
1651 | MenuRefreshEntry->Next != NULL;\r | |
1652 | MenuRefreshEntry = MenuRefreshEntry->Next\r | |
1653 | )\r | |
1654 | ;\r | |
1655 | MenuRefreshEntry->Next = AllocateZeroPool (sizeof (MENU_REFRESH_ENTRY));\r | |
1656 | ASSERT (MenuRefreshEntry->Next != NULL);\r | |
1657 | MenuRefreshEntry = MenuRefreshEntry->Next;\r | |
1658 | MenuRefreshEntry->MenuOption = MenuOption;\r | |
1659 | MenuRefreshEntry->FileFormTagsHead = FileFormTagsHead;\r | |
1660 | MenuRefreshEntry->CurrentColumn = MenuOption->OptCol;\r | |
1661 | MenuRefreshEntry->CurrentRow = MenuOption->Row;\r | |
1662 | MenuRefreshEntry->CurrentAttribute = FIELD_TEXT | FIELD_BACKGROUND;\r | |
1663 | }\r | |
1664 | }\r | |
1665 | \r | |
1666 | Width = (UINT16) gOptionBlockWidth;\r | |
1667 | \r | |
1668 | OriginalRow = Row;\r | |
1669 | \r | |
1670 | for (Index = 0; GetLineByWidth (OptionString, Width, &Index, &OutputString) != 0x0000;) {\r | |
1671 | if ((Temp2 == 0) && (Row <= BottomRow)) {\r | |
1672 | PrintStringAt (MenuOption->OptCol, Row, OutputString);\r | |
1673 | }\r | |
1674 | //\r | |
1675 | // If there is more string to process print on the next row and increment the Skip value\r | |
1676 | //\r | |
1677 | if (StrLen (&OptionString[Index])) {\r | |
1678 | if (Temp2 == 0) {\r | |
1679 | Row++;\r | |
1680 | //\r | |
1681 | // Since the Number of lines for this menu entry may or may not be reflected accurately\r | |
1682 | // since the prompt might be 1 lines and option might be many, and vice versa, we need to do\r | |
1683 | // some testing to ensure we are keeping this in-sync.\r | |
1684 | //\r | |
1685 | // If the difference in rows is greater than or equal to the skip value, increase the skip value\r | |
1686 | //\r | |
1687 | if ((Row - OriginalRow) >= MenuOption->Skip) {\r | |
1688 | MenuOption->Skip++;\r | |
1689 | }\r | |
1690 | }\r | |
1691 | }\r | |
1692 | \r | |
1693 | gBS->FreePool (OutputString);\r | |
1694 | if (Temp2 != 0) {\r | |
1695 | Temp2--;\r | |
1696 | }\r | |
1697 | }\r | |
1698 | \r | |
1699 | Temp2 = 0;\r | |
1700 | Row = OriginalRow;\r | |
1701 | }\r | |
1702 | //\r | |
1703 | // If this is a text op with secondary text information\r | |
1704 | //\r | |
1705 | if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP) && (MenuOption->ThisTag->TextTwo != 0)) {\r | |
1706 | StringPtr = GetToken (MenuOption->ThisTag->TextTwo, MenuOption->Handle);\r | |
1707 | \r | |
1708 | Width = (UINT16) gOptionBlockWidth;\r | |
1709 | \r | |
1710 | OriginalRow = Row;\r | |
1711 | \r | |
1712 | for (Index = 0; GetLineByWidth (StringPtr, Width, &Index, &OutputString) != 0x0000;) {\r | |
1713 | if ((Temp == 0) && (Row <= BottomRow)) {\r | |
1714 | PrintStringAt (MenuOption->OptCol, Row, OutputString);\r | |
1715 | }\r | |
1716 | //\r | |
1717 | // If there is more string to process print on the next row and increment the Skip value\r | |
1718 | //\r | |
1719 | if (StrLen (&StringPtr[Index])) {\r | |
1720 | if (Temp2 == 0) {\r | |
1721 | Row++;\r | |
1722 | //\r | |
1723 | // Since the Number of lines for this menu entry may or may not be reflected accurately\r | |
1724 | // since the prompt might be 1 lines and option might be many, and vice versa, we need to do\r | |
1725 | // some testing to ensure we are keeping this in-sync.\r | |
1726 | //\r | |
1727 | // If the difference in rows is greater than or equal to the skip value, increase the skip value\r | |
1728 | //\r | |
1729 | if ((Row - OriginalRow) >= MenuOption->Skip) {\r | |
1730 | MenuOption->Skip++;\r | |
1731 | }\r | |
1732 | }\r | |
1733 | }\r | |
1734 | \r | |
1735 | gBS->FreePool (OutputString);\r | |
1736 | if (Temp2 != 0) {\r | |
1737 | Temp2--;\r | |
1738 | }\r | |
1739 | }\r | |
1740 | \r | |
1741 | Row = OriginalRow;\r | |
1742 | gBS->FreePool (StringPtr);\r | |
1743 | }\r | |
1744 | } else {\r | |
1745 | //\r | |
1746 | // For now, assume left-justified 72 width max setup entries\r | |
1747 | //\r | |
1748 | PrintStringAt (Col, Row, MenuOption->Description);\r | |
1749 | }\r | |
1750 | //\r | |
1751 | // Tracker 6210 - need to handle the bottom of the display\r | |
1752 | //\r | |
1753 | if (MenuOption->Skip > 1) {\r | |
1754 | Row += MenuOption->Skip - SkipValue;\r | |
1755 | SkipValue = 0;\r | |
1756 | } else {\r | |
1757 | Row += MenuOption->Skip;\r | |
1758 | }\r | |
1759 | \r | |
1760 | if (Row > BottomRow) {\r | |
1761 | if (!ValueIsScroll (FALSE, Link)) {\r | |
1762 | gDownArrow = TRUE;\r | |
1763 | }\r | |
1764 | \r | |
1765 | Row = BottomRow + 1;\r | |
1766 | break;\r | |
1767 | }\r | |
1768 | }\r | |
1769 | \r | |
1770 | if (!ValueIsScroll (TRUE, TopOfScreen)) {\r | |
1771 | gUpArrow = TRUE;\r | |
1772 | }\r | |
1773 | \r | |
1774 | if (gUpArrow) {\r | |
1775 | gST->ConOut->SetAttribute (gST->ConOut, ARROW_TEXT | ARROW_BACKGROUND);\r | |
1776 | PrintAt (\r | |
1777 | LocalScreen.LeftColumn + gPromptBlockWidth + gOptionBlockWidth + 1,\r | |
1778 | TopRow - SCROLL_ARROW_HEIGHT,\r | |
1779 | (CHAR16 *) L"%c",\r | |
1780 | ARROW_UP\r | |
1781 | );\r | |
1782 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1783 | }\r | |
1784 | \r | |
1785 | if (gDownArrow) {\r | |
1786 | gST->ConOut->SetAttribute (gST->ConOut, ARROW_TEXT | ARROW_BACKGROUND);\r | |
1787 | PrintAt (\r | |
1788 | LocalScreen.LeftColumn + gPromptBlockWidth + gOptionBlockWidth + 1,\r | |
1789 | BottomRow + SCROLL_ARROW_HEIGHT,\r | |
1790 | (CHAR16 *) L"%c",\r | |
1791 | ARROW_DOWN\r | |
1792 | );\r | |
1793 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1794 | }\r | |
1795 | \r | |
1796 | if (SavedMenuOption != NULL) {\r | |
1797 | MenuOption = SavedMenuOption;\r | |
1798 | }\r | |
1799 | }\r | |
1800 | break;\r | |
1801 | \r | |
1802 | case CfRefreshHighLight:\r | |
1803 | ControlFlag = CfUpdateHelpString;\r | |
1804 | //\r | |
1805 | // Repaint flag is normally reset when finish processing CfUpdateHelpString. Temporarily\r | |
1806 | // reset Repaint flag because we may break halfway and skip CfUpdateHelpString processing.\r | |
1807 | //\r | |
1808 | SavedValue = Repaint;\r | |
1809 | Repaint = FALSE;\r | |
1810 | \r | |
1811 | if (NewPos != NULL) {\r | |
1812 | gST->ConOut->SetCursorPosition (gST->ConOut, MenuOption->Col, MenuOption->Row);\r | |
1813 | if (SubMenu) {\r | |
1814 | if (gLastOpr && (gEntryNumber != -1)) {\r | |
1815 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
1816 | if (gEntryNumber != MenuOption->EntryNumber) {\r | |
1817 | ScreenOperation = UiDown;\r | |
1818 | ControlFlag = CfScreenOperation;\r | |
1819 | break;\r | |
1820 | } else {\r | |
1821 | gLastOpr = FALSE;\r | |
1822 | }\r | |
1823 | }\r | |
1824 | \r | |
1825 | ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r | |
1826 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1827 | if (OptionString != NULL) {\r | |
1828 | //\r | |
1829 | // If leading spaces on OptionString - remove the spaces\r | |
1830 | //\r | |
1831 | for (Index = 0; OptionString[Index] == L' '; Index++)\r | |
1832 | ;\r | |
1833 | \r | |
1834 | for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r | |
1835 | OptionString[Count] = OptionString[Index];\r | |
1836 | Count++;\r | |
1837 | }\r | |
1838 | \r | |
1839 | OptionString[Count] = CHAR_NULL;\r | |
1840 | \r | |
1841 | Width = (UINT16) gOptionBlockWidth;\r | |
1842 | \r | |
1843 | OriginalRow = MenuOption->Row;\r | |
1844 | \r | |
1845 | for (Index = 0; GetLineByWidth (OptionString, Width, &Index, &OutputString) != 0x0000;) {\r | |
1846 | if (MenuOption->Row >= TopRow && MenuOption->Row <= BottomRow) {\r | |
1847 | PrintStringAt (MenuOption->OptCol, MenuOption->Row, OutputString);\r | |
1848 | }\r | |
1849 | //\r | |
1850 | // If there is more string to process print on the next row and increment the Skip value\r | |
1851 | //\r | |
1852 | if (StrLen (&OptionString[Index])) {\r | |
1853 | MenuOption->Row++;\r | |
1854 | }\r | |
1855 | \r | |
1856 | gBS->FreePool (OutputString);\r | |
1857 | }\r | |
1858 | \r | |
1859 | MenuOption->Row = OriginalRow;\r | |
1860 | } else {\r | |
1861 | if (NewLine) {\r | |
1862 | if (MenuOption->ThisTag->GrayOut) {\r | |
1863 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_GRAYED | FIELD_BACKGROUND);\r | |
1864 | } else {\r | |
1865 | if (MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP) {\r | |
1866 | gST->ConOut->SetAttribute (gST->ConOut, SUBTITLE_TEXT | FIELD_BACKGROUND);\r | |
1867 | }\r | |
1868 | }\r | |
1869 | \r | |
1870 | OriginalRow = MenuOption->Row;\r | |
1871 | Width = GetWidth (MenuOption->ThisTag, MenuOption->Handle);\r | |
1872 | \r | |
1873 | for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &Index, &OutputString) != 0x0000;) {\r | |
1874 | if (MenuOption->Row >= TopRow && MenuOption->Row <= BottomRow) {\r | |
1875 | PrintStringAt (Col, MenuOption->Row, OutputString);\r | |
1876 | }\r | |
1877 | //\r | |
1878 | // If there is more string to process print on the next row and increment the Skip value\r | |
1879 | //\r | |
1880 | if (StrLen (&MenuOption->Description[Index])) {\r | |
1881 | MenuOption->Row++;\r | |
1882 | }\r | |
1883 | \r | |
1884 | gBS->FreePool (OutputString);\r | |
1885 | }\r | |
1886 | \r | |
1887 | MenuOption->Row = OriginalRow;\r | |
1888 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1889 | }\r | |
1890 | }\r | |
1891 | } else {\r | |
1892 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
1893 | gST->ConOut->OutputString (gST->ConOut, MenuOption->Description);\r | |
1894 | }\r | |
1895 | \r | |
1896 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
1897 | \r | |
1898 | if ((gPriorMenuEntry != 0) && (MenuOption->EntryNumber != gPriorMenuEntry) && (NewPos->ForwardLink != &Menu)) {\r | |
1899 | ScreenOperation = UiDown;\r | |
1900 | ControlFlag = CfScreenOperation;\r | |
1901 | break;\r | |
1902 | } else {\r | |
1903 | gPriorMenuEntry = 0;\r | |
1904 | }\r | |
1905 | //\r | |
1906 | // This is only possible if we entered this page and the first menu option is\r | |
1907 | // a "non-menu" item. In that case, force it UiDown\r | |
1908 | //\r | |
1909 | if (MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || MenuOption->ThisTag->GrayOut) {\r | |
1910 | //\r | |
1911 | // If we previously hit an UP command and we are still sitting on a text operation\r | |
1912 | // we must continue going up\r | |
1913 | //\r | |
1914 | if (ScreenOperation == UiUp) {\r | |
1915 | ControlFlag = CfScreenOperation;\r | |
1916 | break;\r | |
1917 | } else {\r | |
1918 | ScreenOperation = UiDown;\r | |
1919 | ControlFlag = CfScreenOperation;\r | |
1920 | break;\r | |
1921 | }\r | |
1922 | }\r | |
1923 | //\r | |
1924 | // Set reverse attribute\r | |
1925 | //\r | |
1926 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT_HIGHLIGHT | FIELD_BACKGROUND_HIGHLIGHT);\r | |
1927 | gST->ConOut->SetCursorPosition (gST->ConOut, MenuOption->Col, MenuOption->Row);\r | |
1928 | \r | |
1929 | //\r | |
1930 | // Assuming that we have a refresh linked-list created, lets annotate the\r | |
1931 | // appropriate entry that we are highlighting with its new attribute. Just prior to this\r | |
1932 | // lets reset all of the entries' attribute so we do not get multiple highlights in he refresh\r | |
1933 | //\r | |
1934 | if (gMenuRefreshHead != NULL) {\r | |
1935 | for (MenuRefreshEntry = gMenuRefreshHead; MenuRefreshEntry != NULL; MenuRefreshEntry = MenuRefreshEntry->Next) {\r | |
1936 | MenuRefreshEntry->CurrentAttribute = FIELD_TEXT | FIELD_BACKGROUND;\r | |
1937 | if (MenuRefreshEntry->MenuOption == MenuOption) {\r | |
1938 | MenuRefreshEntry->CurrentAttribute = FIELD_TEXT_HIGHLIGHT | FIELD_BACKGROUND_HIGHLIGHT;\r | |
1939 | }\r | |
1940 | }\r | |
1941 | }\r | |
1942 | \r | |
1943 | if (SubMenu) {\r | |
1944 | ProcessOptions (MenuOption, FALSE, FileFormTagsHead, PageData, &OptionString);\r | |
1945 | if (OptionString != NULL) {\r | |
1946 | //\r | |
1947 | // If leading spaces on OptionString - remove the spaces\r | |
1948 | //\r | |
1949 | for (Index = 0; OptionString[Index] == L' '; Index++)\r | |
1950 | ;\r | |
1951 | \r | |
1952 | for (Count = 0; OptionString[Index] != CHAR_NULL; Index++) {\r | |
1953 | OptionString[Count] = OptionString[Index];\r | |
1954 | Count++;\r | |
1955 | }\r | |
1956 | \r | |
1957 | OptionString[Count] = CHAR_NULL;\r | |
1958 | \r | |
1959 | Width = (UINT16) gOptionBlockWidth;\r | |
1960 | \r | |
1961 | OriginalRow = MenuOption->Row;\r | |
1962 | \r | |
1963 | for (Index = 0; GetLineByWidth (OptionString, Width, &Index, &OutputString) != 0x0000;) {\r | |
1964 | if (MenuOption->Row >= TopRow && MenuOption->Row <= BottomRow) {\r | |
1965 | PrintStringAt (MenuOption->OptCol, MenuOption->Row, OutputString);\r | |
1966 | }\r | |
1967 | //\r | |
1968 | // If there is more string to process print on the next row and increment the Skip value\r | |
1969 | //\r | |
1970 | if (StrLen (&OptionString[Index])) {\r | |
1971 | MenuOption->Row++;\r | |
1972 | }\r | |
1973 | \r | |
1974 | gBS->FreePool (OutputString);\r | |
1975 | }\r | |
1976 | \r | |
1977 | MenuOption->Row = OriginalRow;\r | |
1978 | } else {\r | |
1979 | if (NewLine) {\r | |
1980 | OriginalRow = MenuOption->Row;\r | |
1981 | \r | |
1982 | Width = GetWidth (MenuOption->ThisTag, MenuOption->Handle);\r | |
1983 | \r | |
1984 | for (Index = 0; GetLineByWidth (MenuOption->Description, Width, &Index, &OutputString) != 0x0000;) {\r | |
1985 | if (MenuOption->Row >= TopRow && MenuOption->Row <= BottomRow) {\r | |
1986 | PrintStringAt (Col, MenuOption->Row, OutputString);\r | |
1987 | }\r | |
1988 | //\r | |
1989 | // If there is more string to process print on the next row and increment the Skip value\r | |
1990 | //\r | |
1991 | if (StrLen (&MenuOption->Description[Index])) {\r | |
1992 | MenuOption->Row++;\r | |
1993 | }\r | |
1994 | \r | |
1995 | gBS->FreePool (OutputString);\r | |
1996 | }\r | |
1997 | \r | |
1998 | MenuOption->Row = OriginalRow;\r | |
1999 | \r | |
2000 | }\r | |
2001 | }\r | |
2002 | \r | |
2003 | if (((NewPos->ForwardLink != &Menu) && (ScreenOperation == UiDown)) ||\r | |
2004 | ((NewPos->BackLink != &Menu) && (ScreenOperation == UiUp)) ||\r | |
2005 | (ScreenOperation == UiNoOperation)\r | |
2006 | ) {\r | |
2007 | UpdateKeyHelp (MenuOption, FALSE);\r | |
2008 | }\r | |
2009 | } else {\r | |
2010 | gST->ConOut->OutputString (gST->ConOut, MenuOption->Description);\r | |
2011 | }\r | |
2012 | //\r | |
2013 | // Clear reverse attribute\r | |
2014 | //\r | |
2015 | gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r | |
2016 | }\r | |
2017 | //\r | |
2018 | // Repaint flag will be used when process CfUpdateHelpString, so restore its value\r | |
2019 | // if we didn't break halfway when process CfRefreshHighLight.\r | |
2020 | //\r | |
2021 | Repaint = SavedValue;\r | |
2022 | break;\r | |
2023 | \r | |
2024 | case CfUpdateHelpString:\r | |
2025 | ControlFlag = CfPrepareToReadKey;\r | |
2026 | \r | |
2027 | if (SubMenu && \r | |
2028 | (Repaint || NewLine || \r | |
2029 | (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) ||\r | |
2030 | (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) && \r | |
2031 | !(gClassOfVfr == EFI_GENERAL_APPLICATION_SUBCLASS)) {\r | |
2032 | //\r | |
2033 | // Don't print anything if it is a NULL help token\r | |
2034 | //\r | |
2035 | if (MenuOption->ThisTag->Help == 0x00000000) {\r | |
2036 | StringPtr = (CHAR16 *) L"\0";\r | |
2037 | } else {\r | |
2038 | StringPtr = GetToken (MenuOption->ThisTag->Help, MenuOption->Handle);\r | |
2039 | }\r | |
2040 | \r | |
2041 | ProcessHelpString (StringPtr, &FormattedString, BottomRow - TopRow);\r | |
2042 | \r | |
2043 | gST->ConOut->SetAttribute (gST->ConOut, HELP_TEXT | FIELD_BACKGROUND);\r | |
2044 | \r | |
2045 | for (Index = 0; Index < BottomRow - TopRow; Index++) {\r | |
2046 | //\r | |
2047 | // Pad String with spaces to simulate a clearing of the previous line\r | |
2048 | //\r | |
2049 | for (; GetStringWidth (&FormattedString[Index * gHelpBlockWidth]) / 2 < gHelpBlockWidth;) {\r | |
2050 | StrCat (&FormattedString[Index * gHelpBlockWidth], (CHAR16 *) L" ");\r | |
2051 | }\r | |
2052 | \r | |
2053 | PrintStringAt (\r | |
2054 | LocalScreen.RightColumn - gHelpBlockWidth,\r | |
2055 | Index + TopRow,\r | |
2056 | &FormattedString[Index * gHelpBlockWidth]\r | |
2057 | );\r | |
2058 | }\r | |
2059 | }\r | |
2060 | //\r | |
2061 | // Reset this flag every time we finish using it.\r | |
2062 | //\r | |
2063 | Repaint = FALSE;\r | |
2064 | NewLine = FALSE;\r | |
2065 | break;\r | |
2066 | \r | |
2067 | case CfPrepareToReadKey:\r | |
2068 | ControlFlag = CfReadKey;\r | |
2069 | \r | |
2070 | for (Index = 0; Index < MenuOption->IfrNumber; Index++) {\r | |
2071 | FileFormTags = FileFormTags->NextFile;\r | |
2072 | }\r | |
2073 | \r | |
2074 | ScreenOperation = UiNoOperation;\r | |
2075 | \r | |
2076 | Status = gBS->HandleProtocol (\r | |
2077 | (VOID *) (UINTN) FileFormTags->FormTags.Tags[0].CallbackHandle,\r | |
2078 | &gEfiFormCallbackProtocolGuid,\r | |
2079 | (VOID **) &FormCallback\r | |
2080 | );\r | |
2081 | \r | |
2082 | break;\r | |
2083 | \r | |
2084 | case CfReadKey:\r | |
2085 | ControlFlag = CfScreenOperation;\r | |
2086 | \r | |
2087 | OriginalTimeOut = FrontPageTimeOutValue;\r | |
2088 | do {\r | |
2089 | if (FrontPageTimeOutValue >= 0 && (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) && FrontPageTimeOutValue != (INT16) -1) {\r | |
2090 | //\r | |
2091 | // Remember that if set to 0, must immediately boot an option\r | |
2092 | //\r | |
2093 | if (FrontPageTimeOutValue == 0) {\r | |
2094 | FrontPageTimeOutValue = 0xFFFF;\r | |
2095 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
2096 | if (EFI_ERROR (Status)) {\r | |
2097 | Status = EFI_TIMEOUT;\r | |
2098 | }\r | |
2099 | break;\r | |
2100 | }\r | |
2101 | \r | |
2102 | Status = UiWaitForSingleEvent (gST->ConIn->WaitForKey, ONE_SECOND);\r | |
2103 | if (Status == EFI_TIMEOUT) {\r | |
2104 | EFI_IFR_DATA_ENTRY *DataEntry;\r | |
2105 | \r | |
2106 | DataEntry = (EFI_IFR_DATA_ENTRY *) (PageData + 1);\r | |
2107 | \r | |
2108 | PageData->EntryCount = 1;\r | |
2109 | Count = (UINT32) ((OriginalTimeOut - FrontPageTimeOutValue) * 100 / OriginalTimeOut);\r | |
2110 | CopyMem (&DataEntry->Data, &Count, sizeof (UINT32));\r | |
2111 | \r | |
2112 | if ((FormCallback != NULL) && (FormCallback->Callback != NULL)) {\r | |
2113 | FormCallback->Callback (\r | |
2114 | FormCallback,\r | |
2115 | 0xFFFF,\r | |
2116 | (EFI_IFR_DATA_ARRAY *) PageData,\r | |
2117 | NULL\r | |
2118 | );\r | |
2119 | }\r | |
2120 | //\r | |
2121 | // Count down 1 second\r | |
2122 | //\r | |
2123 | FrontPageTimeOutValue--;\r | |
2124 | \r | |
2125 | } else {\r | |
2126 | ASSERT (!EFI_ERROR (Status));\r | |
2127 | PageData->EntryCount = 0;\r | |
2128 | if ((FormCallback != NULL) && (FormCallback->Callback != NULL)) {\r | |
2129 | FormCallback->Callback (\r | |
2130 | FormCallback,\r | |
2131 | 0xFFFE,\r | |
2132 | (EFI_IFR_DATA_ARRAY *) PageData,\r | |
2133 | NULL\r | |
2134 | );\r | |
2135 | }\r | |
2136 | \r | |
2137 | FrontPageTimeOutValue = 0xFFFF;\r | |
2138 | }\r | |
2139 | } else {\r | |
2140 | //\r | |
2141 | // Wait for user's selection, no auto boot\r | |
2142 | //\r | |
2143 | Status = UiWaitForSingleEvent (gST->ConIn->WaitForKey, 0);\r | |
2144 | }\r | |
2145 | } while (Status == EFI_TIMEOUT);\r | |
2146 | \r | |
2147 | if (gFirstIn) {\r | |
2148 | gFirstIn = FALSE;\r | |
2149 | gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r | |
2150 | DisableQuietBoot ();\r | |
2151 | }\r | |
2152 | \r | |
2153 | if (Status == EFI_TIMEOUT) {\r | |
2154 | Key.UnicodeChar = CHAR_CARRIAGE_RETURN;\r | |
2155 | } else {\r | |
2156 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
2157 | //\r | |
2158 | // if we encounter error, continue to read another key in.\r | |
2159 | //\r | |
2160 | if (EFI_ERROR (Status)) {\r | |
2161 | ControlFlag = CfReadKey;\r | |
2162 | continue;\r | |
2163 | }\r | |
2164 | }\r | |
2165 | \r | |
2166 | switch (Key.UnicodeChar) {\r | |
2167 | case CHAR_CARRIAGE_RETURN:\r | |
2168 | Selection = MenuOption;\r | |
2169 | ScreenOperation = UiSelect;\r | |
2170 | gDirection = 0;\r | |
2171 | break;\r | |
2172 | \r | |
2173 | //\r | |
2174 | // We will push the adjustment of these numeric values directly to the input handler\r | |
2175 | //\r | |
2176 | case '+':\r | |
2177 | case '-':\r | |
2178 | if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r | |
2179 | \r | |
2180 | if (Key.UnicodeChar == '+') {\r | |
2181 | gDirection = SCAN_RIGHT;\r | |
2182 | } else {\r | |
2183 | gDirection = SCAN_LEFT;\r | |
2184 | }\r | |
2185 | \r | |
2186 | Status = ProcessOptions (MenuOption, TRUE, FileFormTagsHead, NULL, &OptionString);\r | |
2187 | }\r | |
2188 | break;\r | |
2189 | \r | |
2190 | case '^':\r | |
2191 | ScreenOperation = UiUp;\r | |
2192 | break;\r | |
2193 | \r | |
2194 | case 'V':\r | |
2195 | case 'v':\r | |
2196 | ScreenOperation = UiDown;\r | |
2197 | break;\r | |
2198 | \r | |
2199 | case ' ':\r | |
2200 | if (gClassOfVfr != EFI_FRONT_PAGE_SUBCLASS) {\r | |
2201 | if (SubMenu) {\r | |
2202 | if (MenuOption->ThisTag->Operand == EFI_IFR_CHECKBOX_OP && !(MenuOption->ThisTag->GrayOut)) {\r | |
2203 | gST->ConOut->SetCursorPosition (gST->ConOut, MenuOption->Col, MenuOption->Row);\r | |
2204 | gST->ConOut->OutputString (gST->ConOut, MenuOption->Description);\r | |
2205 | Selection = MenuOption;\r | |
2206 | ScreenOperation = UiSelect;\r | |
2207 | }\r | |
2208 | }\r | |
2209 | }\r | |
2210 | break;\r | |
2211 | \r | |
2212 | case CHAR_NULL:\r | |
2213 | if (((Key.ScanCode == SCAN_F1) && ((gFunctionKeySetting & FUNCTION_ONE) != FUNCTION_ONE)) ||\r | |
2214 | ((Key.ScanCode == SCAN_F2) && ((gFunctionKeySetting & FUNCTION_TWO) != FUNCTION_TWO)) ||\r | |
2215 | ((Key.ScanCode == SCAN_F9) && ((gFunctionKeySetting & FUNCTION_NINE) != FUNCTION_NINE)) ||\r | |
2216 | ((Key.ScanCode == SCAN_F10) && ((gFunctionKeySetting & FUNCTION_TEN) != FUNCTION_TEN))\r | |
2217 | ) {\r | |
2218 | //\r | |
2219 | // If the function key has been disabled, just ignore the key.\r | |
2220 | //\r | |
2221 | } else {\r | |
2222 | for (Index = 0; Index < sizeof (gScanCodeToOperation) / sizeof (gScanCodeToOperation[0]); Index++) {\r | |
2223 | if (Key.ScanCode == gScanCodeToOperation[Index].ScanCode) {\r | |
2224 | if ((Key.ScanCode == SCAN_F9) || (Key.ScanCode == SCAN_F10)) {\r | |
2225 | if (SubMenu) {\r | |
2226 | ScreenOperation = gScanCodeToOperation[Index].ScreenOperation;\r | |
2227 | }\r | |
2228 | } else {\r | |
2229 | ScreenOperation = gScanCodeToOperation[Index].ScreenOperation;\r | |
2230 | }\r | |
2231 | }\r | |
2232 | }\r | |
2233 | }\r | |
2234 | break;\r | |
2235 | }\r | |
2236 | break;\r | |
2237 | \r | |
2238 | case CfScreenOperation:\r | |
2239 | IfrBinary = gBinaryDataHead;\r | |
2240 | \r | |
2241 | //\r | |
2242 | // Advance to the Ifr we are using\r | |
2243 | //\r | |
2244 | for (Index = 0; Index < gActiveIfr; Index++) {\r | |
2245 | IfrBinary = IfrBinary->Next;\r | |
2246 | }\r | |
2247 | \r | |
2248 | if (ScreenOperation != UiPrevious && ScreenOperation != UiReset) {\r | |
2249 | //\r | |
2250 | // If the screen has no menu items, and the user didn't select UiPrevious, or UiReset\r | |
2251 | // ignore the selection and go back to reading keys.\r | |
2252 | //\r | |
2253 | if (IsListEmpty (&Menu)) {\r | |
2254 | ControlFlag = CfReadKey;\r | |
2255 | break;\r | |
2256 | }\r | |
2257 | //\r | |
2258 | // if there is nothing logical to place a cursor on, just move on to wait for a key.\r | |
2259 | //\r | |
2260 | for (Link = Menu.ForwardLink; Link != &Menu; Link = Link->ForwardLink) {\r | |
2261 | NextMenuOption = CR (Link, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2262 | if (!(NextMenuOption->ThisTag->GrayOut) && (NextMenuOption->ThisTag->Operand != EFI_IFR_SUBTITLE_OP)) {\r | |
2263 | break;\r | |
2264 | }\r | |
2265 | }\r | |
2266 | \r | |
2267 | if (Link == &Menu) {\r | |
2268 | ControlFlag = CfPrepareToReadKey;\r | |
2269 | break;\r | |
2270 | }\r | |
2271 | }\r | |
2272 | \r | |
2273 | for (Index = 0;\r | |
2274 | Index < sizeof (gScreenOperationToControlFlag) / sizeof (gScreenOperationToControlFlag[0]);\r | |
2275 | Index++\r | |
2276 | ) {\r | |
2277 | if (ScreenOperation == gScreenOperationToControlFlag[Index].ScreenOperation) {\r | |
2278 | ControlFlag = gScreenOperationToControlFlag[Index].ControlFlag;\r | |
2279 | }\r | |
2280 | }\r | |
2281 | \r | |
2282 | break;\r | |
2283 | \r | |
2284 | case CfUiPrevious:\r | |
2285 | ControlFlag = CfCheckSelection;\r | |
2286 | //\r | |
2287 | // Check for tags that might have LATE_CHECK enabled. If they do, we can't switch pages or save NV data.\r | |
2288 | //\r | |
2289 | if (MenuOption != NULL) {\r | |
2290 | if (!SelectionsAreValid (MenuOption, FileFormTagsHead)) {\r | |
2291 | Selection = NULL;\r | |
2292 | Repaint = TRUE;\r | |
2293 | break;\r | |
2294 | }\r | |
2295 | }\r | |
2296 | \r | |
2297 | if (IsListEmpty (&gMenuList)) {\r | |
2298 | Selection = NULL;\r | |
2299 | if (IsListEmpty (&Menu)) {\r | |
2300 | ControlFlag = CfReadKey;\r | |
2301 | }\r | |
2302 | break;\r | |
2303 | }\r | |
2304 | \r | |
2305 | gLastOpr = TRUE;\r | |
2306 | \r | |
2307 | while (gMenuRefreshHead != NULL) {\r | |
2308 | OldMenuRefreshEntry = gMenuRefreshHead->Next;\r | |
2309 | \r | |
2310 | gBS->FreePool (gMenuRefreshHead);\r | |
2311 | \r | |
2312 | gMenuRefreshHead = OldMenuRefreshEntry;\r | |
2313 | }\r | |
2314 | //\r | |
2315 | // Remove the Cached page entry, free and init the menus, flag Selection as jumping to previous page and a valid Tag\r | |
2316 | //\r | |
2317 | if (SubMenu) {\r | |
2318 | UiRemoveMenuListEntry (MenuOption, &Selection);\r | |
2319 | Selection->Previous = TRUE;\r | |
2320 | UiFreeMenu ();\r | |
2321 | UiInitMenu ();\r | |
2322 | }\r | |
2323 | \r | |
2324 | gActiveIfr = Selection->IfrNumber;\r | |
2325 | return Selection;\r | |
2326 | \r | |
2327 | case CfUiSelect:\r | |
2328 | ControlFlag = CfCheckSelection;\r | |
2329 | \r | |
2330 | ExtractRequestedNvMap (FileFormTags, MenuOption->ThisTag->VariableNumber, &VariableDefinition);\r | |
2331 | \r | |
2332 | if (SubMenu) {\r | |
2333 | if ((MenuOption->ThisTag->Operand == EFI_IFR_TEXT_OP && \r | |
2334 | !(MenuOption->ThisTag->Flags & EFI_IFR_FLAG_INTERACTIVE)) ||\r | |
2335 | (MenuOption->ThisTag->GrayOut) ||\r | |
2336 | (MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) ||\r | |
2337 | (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r | |
2338 | Selection = NULL;\r | |
2339 | break;\r | |
2340 | }\r | |
2341 | \r | |
2342 | NewLine = TRUE;\r | |
2343 | UpdateKeyHelp (MenuOption, TRUE);\r | |
2344 | Status = ProcessOptions (MenuOption, TRUE, FileFormTagsHead, PageData, &OptionString);\r | |
2345 | \r | |
2346 | if (EFI_ERROR (Status)) {\r | |
2347 | Selection = NULL;\r | |
2348 | Repaint = TRUE;\r | |
2349 | break;\r | |
2350 | }\r | |
2351 | \r | |
2352 | if (OptionString != NULL) {\r | |
2353 | PrintStringAt (LocalScreen.LeftColumn + gPromptBlockWidth + 1, MenuOption->Row, OptionString);\r | |
2354 | }\r | |
2355 | \r | |
2356 | if (MenuOption->ThisTag->Flags & EFI_IFR_FLAG_INTERACTIVE) {\r | |
2357 | Selection = MenuOption;\r | |
2358 | }\r | |
2359 | \r | |
2360 | if (Selection == NULL) {\r | |
2361 | break;\r | |
2362 | }\r | |
2363 | \r | |
2364 | Location = (UINT8 *) &PageData->EntryCount;\r | |
2365 | \r | |
2366 | //\r | |
2367 | // If not a goto, dump single piece of data, otherwise dump everything\r | |
2368 | //\r | |
2369 | if (Selection->ThisTag->Operand == EFI_IFR_REF_OP) {\r | |
2370 | //\r | |
2371 | // Check for tags that might have LATE_CHECK enabled. If they do, we can't switch pages or save NV data.\r | |
2372 | //\r | |
2373 | if (!SelectionsAreValid (MenuOption, FileFormTagsHead)) {\r | |
2374 | Selection = NULL;\r | |
2375 | Repaint = TRUE;\r | |
2376 | break;\r | |
2377 | }\r | |
2378 | \r | |
2379 | UiAddMenuListEntry (Selection);\r | |
2380 | gPriorMenuEntry = 0;\r | |
2381 | \r | |
2382 | //\r | |
2383 | // Now that we added a menu entry specific to a goto, we can always go back when someone hits the UiPrevious\r | |
2384 | //\r | |
2385 | UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);\r | |
2386 | UiMenuList->FormerEntryNumber = MenuOption->EntryNumber;\r | |
2387 | \r | |
2388 | gLastOpr = FALSE;\r | |
2389 | \r | |
2390 | //\r | |
2391 | // Rewind to the beginning of the menu\r | |
2392 | //\r | |
2393 | for (; NewPos->BackLink != &Menu; NewPos = NewPos->BackLink)\r | |
2394 | ;\r | |
2395 | \r | |
2396 | //\r | |
2397 | // Get Total Count of Menu entries\r | |
2398 | //\r | |
2399 | for (Count = 1; NewPos->ForwardLink != &Menu; NewPos = NewPos->ForwardLink) {\r | |
2400 | Count++;\r | |
2401 | }\r | |
2402 | //\r | |
2403 | // Rewind to the beginning of the menu\r | |
2404 | //\r | |
2405 | for (; NewPos->BackLink != &Menu; NewPos = NewPos->BackLink)\r | |
2406 | ;\r | |
2407 | \r | |
2408 | //\r | |
2409 | // Copy the number of entries being described to the PageData location\r | |
2410 | //\r | |
2411 | CopyMem (&Location[0], &Count, sizeof (UINT32));\r | |
2412 | \r | |
2413 | for (Index = 4; NewPos->ForwardLink != &Menu; Index = Index + MenuOption->ThisTag->StorageWidth + 2) {\r | |
2414 | \r | |
2415 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2416 | Location[Index] = MenuOption->ThisTag->Operand;\r | |
2417 | Location[Index + 1] = (UINT8) (MenuOption->ThisTag->StorageWidth + 4);\r | |
2418 | CopyMem (\r | |
2419 | &Location[Index + 4],\r | |
2420 | &VariableDefinition->NvRamMap[MenuOption->ThisTag->StorageStart],\r | |
2421 | MenuOption->ThisTag->StorageWidth\r | |
2422 | );\r | |
2423 | NewPos = NewPos->ForwardLink;\r | |
2424 | }\r | |
2425 | } else {\r | |
2426 | \r | |
2427 | gPriorMenuEntry = MenuOption->EntryNumber;\r | |
2428 | \r | |
2429 | Count = 1;\r | |
2430 | \r | |
2431 | //\r | |
2432 | // Copy the number of entries being described to the PageData location\r | |
2433 | //\r | |
2434 | CopyMem (&Location[0], &Count, sizeof (UINT32));\r | |
2435 | \r | |
2436 | //\r | |
2437 | // Start at PageData[4] since the EntryCount is a UINT32\r | |
2438 | //\r | |
2439 | Index = 4;\r | |
2440 | \r | |
2441 | //\r | |
2442 | // Copy data to destination\r | |
2443 | //\r | |
2444 | Location[Index] = MenuOption->ThisTag->Operand;\r | |
2445 | Location[Index + 1] = (UINT8) (MenuOption->ThisTag->StorageWidth + 4);\r | |
2446 | CopyMem (\r | |
2447 | &Location[Index + 4],\r | |
2448 | &VariableDefinition->NvRamMap[MenuOption->ThisTag->StorageStart],\r | |
2449 | MenuOption->ThisTag->StorageWidth\r | |
2450 | );\r | |
2451 | }\r | |
2452 | }\r | |
2453 | break;\r | |
2454 | \r | |
2455 | case CfUiReset:\r | |
2456 | ControlFlag = CfCheckSelection;\r | |
2457 | gLastOpr = FALSE;\r | |
2458 | if (gClassOfVfr == EFI_FRONT_PAGE_SUBCLASS) {\r | |
2459 | break;\r | |
2460 | }\r | |
2461 | //\r | |
2462 | // If NV flag is up, prompt user\r | |
2463 | //\r | |
2464 | if (gNvUpdateRequired) {\r | |
2465 | Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r | |
2466 | \r | |
2467 | YesResponse = gYesResponse[0];\r | |
2468 | NoResponse = gNoResponse[0];\r | |
2469 | \r | |
2470 | do {\r | |
2471 | CreateDialog (3, TRUE, 0, NULL, &Key, gEmptyString, gAreYouSure, gEmptyString);\r | |
2472 | } while\r | |
2473 | (\r | |
2474 | (Key.ScanCode != SCAN_ESC) &&\r | |
2475 | ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&\r | |
2476 | ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))\r | |
2477 | );\r | |
2478 | \r | |
2479 | //\r | |
2480 | // If the user hits the YesResponse key\r | |
2481 | //\r | |
2482 | if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {\r | |
2483 | } else {\r | |
2484 | Repaint = TRUE;\r | |
2485 | NewLine = TRUE;\r | |
2486 | break;\r | |
2487 | }\r | |
2488 | }\r | |
2489 | //\r | |
2490 | // Check for tags that might have LATE_CHECK enabled. If they do, we can't switch pages or save NV data.\r | |
2491 | //\r | |
2492 | if (MenuOption != NULL) {\r | |
2493 | if (!SelectionsAreValid (MenuOption, FileFormTagsHead)) {\r | |
2494 | Selection = NULL;\r | |
2495 | Repaint = TRUE;\r | |
2496 | NewLine = TRUE;\r | |
2497 | break;\r | |
2498 | }\r | |
2499 | }\r | |
2500 | \r | |
2501 | gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r | |
2502 | gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r | |
2503 | \r | |
2504 | if (SubMenu) {\r | |
2505 | UiFreeMenuList ();\r | |
2506 | gST->ConOut->ClearScreen (gST->ConOut);\r | |
2507 | return NULL;\r | |
2508 | }\r | |
2509 | \r | |
2510 | UpdateStatusBar (INPUT_ERROR, MenuOption->ThisTag->Flags, FALSE);\r | |
2511 | UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, FALSE);\r | |
2512 | \r | |
2513 | if (IfrBinary->UnRegisterOnExit) {\r | |
2514 | Hii->RemovePack (Hii, MenuOption->Handle);\r | |
2515 | }\r | |
2516 | \r | |
2517 | UiFreeMenu ();\r | |
2518 | \r | |
2519 | //\r | |
2520 | // Clean up the allocated data buffers\r | |
2521 | //\r | |
2522 | FreeData (FileFormTagsHead, FormattedString, OptionString);\r | |
2523 | \r | |
2524 | gST->ConOut->ClearScreen (gST->ConOut);\r | |
2525 | return NULL;\r | |
2526 | \r | |
2527 | case CfUiLeft:\r | |
2528 | ControlFlag = CfCheckSelection;\r | |
2529 | if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r | |
2530 | if (MenuOption->Skip == 1) {\r | |
2531 | //\r | |
2532 | // In the tail of the Date/Time op-code set, go left.\r | |
2533 | //\r | |
2534 | NewPos = NewPos->BackLink;\r | |
2535 | } else {\r | |
2536 | //\r | |
2537 | // In the middle of the Data/Time op-code set, go left.\r | |
2538 | //\r | |
2539 | NextMenuOption = CR (NewPos->ForwardLink, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2540 | if (NextMenuOption->Skip == 1) {\r | |
2541 | NewPos = NewPos->BackLink;\r | |
2542 | }\r | |
2543 | }\r | |
2544 | }\r | |
2545 | break;\r | |
2546 | \r | |
2547 | case CfUiRight:\r | |
2548 | ControlFlag = CfCheckSelection;\r | |
2549 | if ((MenuOption->Skip == 0) &&\r | |
2550 | ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP))\r | |
2551 | ) {\r | |
2552 | //\r | |
2553 | // We are in the head or middle of the Date/Time op-code set, advance right.\r | |
2554 | //\r | |
2555 | NewPos = NewPos->ForwardLink;\r | |
2556 | }\r | |
2557 | break;\r | |
2558 | \r | |
2559 | case CfUiUp:\r | |
2560 | ControlFlag = CfCheckSelection;\r | |
2561 | \r | |
2562 | if (NewPos->BackLink != &Menu) {\r | |
2563 | NewLine = TRUE;\r | |
2564 | //\r | |
2565 | // Adjust Date/Time position before we advance forward.\r | |
2566 | //\r | |
2567 | AdjustDateAndTimePosition (TRUE, &NewPos);\r | |
2568 | \r | |
2569 | //\r | |
2570 | // Caution that we have already rewind to the top, don't go backward in this situation.\r | |
2571 | //\r | |
2572 | if (NewPos->BackLink != &Menu) {\r | |
2573 | NewPos = NewPos->BackLink;\r | |
2574 | }\r | |
2575 | \r | |
2576 | PreviousMenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2577 | \r | |
2578 | //\r | |
2579 | // Since the behavior of hitting the up arrow on a Date/Time op-code is intended\r | |
2580 | // to be one that back to the previous set of op-codes, we need to advance to the sencond\r | |
2581 | // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate\r | |
2582 | // checking can be done.\r | |
2583 | //\r | |
2584 | DataAndTimeLineNumberPad = AdjustDateAndTimePosition (TRUE, &NewPos);\r | |
2585 | \r | |
2586 | if (SubMenu) {\r | |
2587 | //\r | |
2588 | // If the previous MenuOption contains a display-only op-code, skip to the next one\r | |
2589 | //\r | |
2590 | if (PreviousMenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || PreviousMenuOption->ThisTag->GrayOut) {\r | |
2591 | //\r | |
2592 | // This is ok as long as not at the end of the list\r | |
2593 | //\r | |
2594 | if (NewPos->BackLink == &Menu) {\r | |
2595 | //\r | |
2596 | // If we are at the start of the list, then this list must start with a display only\r | |
2597 | // piece of data, so do not allow the backward motion\r | |
2598 | //\r | |
2599 | ScreenOperation = UiDown;\r | |
2600 | \r | |
2601 | if (PreviousMenuOption->Row <= TopRow) {\r | |
2602 | if (TopOfScreen->BackLink != &Menu) {\r | |
2603 | TopOfScreen = TopOfScreen->BackLink;\r | |
2604 | Repaint = TRUE;\r | |
2605 | }\r | |
2606 | }\r | |
2607 | \r | |
2608 | UpdateStatusBar (INPUT_ERROR, PreviousMenuOption->ThisTag->Flags, FALSE);\r | |
2609 | break;\r | |
2610 | }\r | |
2611 | }\r | |
2612 | }\r | |
2613 | //\r | |
2614 | // Check the previous menu entry to see if it was a zero-length advance. If it was,\r | |
2615 | // don't worry about a redraw.\r | |
2616 | //\r | |
2617 | if ((MenuOption->Row - PreviousMenuOption->Skip - DataAndTimeLineNumberPad < TopRow) ||\r | |
2618 | (PreviousMenuOption->Skip > MenuOption->Row)\r | |
2619 | ) {\r | |
2620 | do {\r | |
2621 | if (TopOfScreen->BackLink == &Menu) {\r | |
2622 | break;\r | |
2623 | }\r | |
2624 | \r | |
2625 | Repaint = TRUE;\r | |
2626 | \r | |
2627 | //\r | |
2628 | // Is the current top of screen a zero-advance op-code?\r | |
2629 | // If so, keep moving forward till we hit a >0 advance op-code\r | |
2630 | //\r | |
2631 | SavedMenuOption = CR (TopOfScreen->BackLink, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2632 | TopOfScreen = TopOfScreen->BackLink;\r | |
2633 | } while (SavedMenuOption->Skip == 0);\r | |
2634 | //\r | |
2635 | // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.\r | |
2636 | //\r | |
2637 | AdjustDateAndTimePosition (TRUE, &TopOfScreen);\r | |
2638 | }\r | |
2639 | \r | |
2640 | UpdateStatusBar (INPUT_ERROR, MenuOption->ThisTag->Flags, FALSE);\r | |
2641 | } else {\r | |
2642 | if (SubMenu) {\r | |
2643 | SavedMenuOption = MenuOption;\r | |
2644 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2645 | if (MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || MenuOption->ThisTag->GrayOut) {\r | |
2646 | //\r | |
2647 | // If we are at the end of the list and sitting on a text op, we need to more forward\r | |
2648 | //\r | |
2649 | ScreenOperation = UiDown;\r | |
2650 | ControlFlag = CfScreenOperation;\r | |
2651 | break;\r | |
2652 | }\r | |
2653 | \r | |
2654 | MenuOption = SavedMenuOption;\r | |
2655 | }\r | |
2656 | }\r | |
2657 | break;\r | |
2658 | \r | |
2659 | case CfUiPageUp:\r | |
2660 | ControlFlag = CfCheckSelection;\r | |
2661 | \r | |
2662 | SavedListEntry = NewPos;\r | |
2663 | Link = TopOfScreen;\r | |
2664 | for (Index = BottomRow; Index >= TopRow + 1; Index -= MenuOption->Skip) {\r | |
2665 | if (Link->BackLink == &Menu) {\r | |
2666 | TopOfScreen = Link;\r | |
2667 | Link = SavedListEntry;\r | |
2668 | MenuOption = CR (Link, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2669 | break;\r | |
2670 | }\r | |
2671 | \r | |
2672 | NewLine = TRUE;\r | |
2673 | Repaint = TRUE;\r | |
2674 | Link = Link->BackLink;\r | |
2675 | MenuOption = CR (Link, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2676 | TopOfScreen = Link;\r | |
2677 | SavedListEntry = Link;\r | |
2678 | }\r | |
2679 | \r | |
2680 | NewPos = Link;\r | |
2681 | \r | |
2682 | //\r | |
2683 | // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.\r | |
2684 | // Don't do this when we are already in the first page.\r | |
2685 | //\r | |
2686 | if (Repaint) {\r | |
2687 | AdjustDateAndTimePosition (TRUE, &TopOfScreen);\r | |
2688 | AdjustDateAndTimePosition (TRUE, &NewPos);\r | |
2689 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2690 | }\r | |
2691 | break;\r | |
2692 | \r | |
2693 | case CfUiPageDown:\r | |
2694 | ControlFlag = CfCheckSelection;\r | |
2695 | \r | |
2696 | SavedListEntry = NewPos;\r | |
2697 | Link = TopOfScreen;\r | |
2698 | NewPos = TopOfScreen;\r | |
2699 | for (Index = TopRow; Index <= BottomRow - 1; Index += MenuOption->Skip) {\r | |
2700 | if (NewPos->ForwardLink == &Menu) {\r | |
2701 | NewPos = SavedListEntry;\r | |
2702 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2703 | Link = TopOfScreen;\r | |
2704 | NewLine = FALSE;\r | |
2705 | Repaint = FALSE;\r | |
2706 | break;\r | |
2707 | }\r | |
2708 | \r | |
2709 | NewLine = TRUE;\r | |
2710 | Repaint = TRUE;\r | |
2711 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2712 | NewPos = NewPos->ForwardLink;\r | |
2713 | Link = NewPos;\r | |
2714 | }\r | |
2715 | \r | |
2716 | TopOfScreen = Link;\r | |
2717 | \r | |
2718 | //\r | |
2719 | // If we encounter a Date/Time op-code set, rewind to the first op-code of the set.\r | |
2720 | // Don't do this when we are already in the last page.\r | |
2721 | //\r | |
2722 | if (Repaint) {\r | |
2723 | AdjustDateAndTimePosition (TRUE, &TopOfScreen);\r | |
2724 | AdjustDateAndTimePosition (TRUE, &NewPos);\r | |
2725 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2726 | }\r | |
2727 | break;\r | |
2728 | \r | |
2729 | case CfUiDown:\r | |
2730 | ControlFlag = CfCheckSelection;\r | |
2731 | //\r | |
2732 | // Since the behavior of hitting the down arrow on a Date/Time op-code is intended\r | |
2733 | // to be one that progresses to the next set of op-codes, we need to advance to the last\r | |
2734 | // Date/Time op-code and leave the remaining logic in UiDown intact so the appropriate\r | |
2735 | // checking can be done. The only other logic we need to introduce is that if a Date/Time\r | |
2736 | // op-code is the last entry in the menu, we need to rewind back to the first op-code of\r | |
2737 | // the Date/Time op-code.\r | |
2738 | //\r | |
2739 | DataAndTimeLineNumberPad = AdjustDateAndTimePosition (FALSE, &NewPos);\r | |
2740 | \r | |
2741 | if (NewPos->ForwardLink != &Menu) {\r | |
2742 | NewLine = TRUE;\r | |
2743 | NewPos = NewPos->ForwardLink;\r | |
2744 | NextMenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2745 | \r | |
2746 | if (SubMenu) {\r | |
2747 | //\r | |
2748 | // If the next MenuOption contains a display-only op-code, skip to the next one\r | |
2749 | // Also if the next MenuOption is date or time,\r | |
2750 | //\r | |
2751 | if (NextMenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || NextMenuOption->ThisTag->GrayOut) {\r | |
2752 | //\r | |
2753 | // This is ok as long as not at the end of the list\r | |
2754 | //\r | |
2755 | if (NewPos == &Menu) {\r | |
2756 | //\r | |
2757 | // If we are at the end of the list, then this list must end with a display only\r | |
2758 | // piece of data, so do not allow the forward motion\r | |
2759 | //\r | |
2760 | UpdateStatusBar (INPUT_ERROR, NextMenuOption->ThisTag->Flags, FALSE);\r | |
2761 | NewPos = NewPos->BackLink;\r | |
2762 | ScreenOperation = UiUp;\r | |
2763 | break;\r | |
2764 | }\r | |
2765 | }\r | |
2766 | }\r | |
2767 | //\r | |
2768 | // An option might be multi-line, so we need to reflect that data in the overall skip value\r | |
2769 | //\r | |
2770 | UpdateOptionSkipLines (PageData, NextMenuOption, FileFormTagsHead, &OptionString, SkipValue);\r | |
2771 | \r | |
2772 | if (NextMenuOption->Skip > 1) {\r | |
2773 | Temp = MenuOption->Row + MenuOption->Skip + NextMenuOption->Skip - 1;\r | |
2774 | } else {\r | |
2775 | Temp = MenuOption->Row + MenuOption->Skip + DataAndTimeLineNumberPad;\r | |
2776 | }\r | |
2777 | //\r | |
2778 | // If we are going to scroll\r | |
2779 | //\r | |
2780 | if (Temp > BottomRow) {\r | |
2781 | do {\r | |
2782 | //\r | |
2783 | // Is the current top of screen a zero-advance op-code?\r | |
2784 | // If so, keep moving forward till we hit a >0 advance op-code\r | |
2785 | //\r | |
2786 | SavedMenuOption = CR (TopOfScreen, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2787 | \r | |
2788 | //\r | |
2789 | // If bottom op-code is more than one line or top op-code is more than one line\r | |
2790 | //\r | |
2791 | if ((NextMenuOption->Skip > 1) || (MenuOption->Skip > 1)) {\r | |
2792 | //\r | |
2793 | // Is the bottom op-code greater than or equal in size to the top op-code?\r | |
2794 | //\r | |
2795 | if ((Temp - BottomRow) >= (SavedMenuOption->Skip - OldSkipValue)) {\r | |
2796 | //\r | |
2797 | // Skip the top op-code\r | |
2798 | //\r | |
2799 | TopOfScreen = TopOfScreen->ForwardLink;\r | |
2800 | Difference = (Temp - BottomRow) - (SavedMenuOption->Skip - OldSkipValue);\r | |
2801 | \r | |
2802 | OldSkipValue = Difference;\r | |
2803 | \r | |
2804 | SavedMenuOption = CR (TopOfScreen, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2805 | \r | |
2806 | //\r | |
2807 | // If we have a remainder, skip that many more op-codes until we drain the remainder\r | |
2808 | //\r | |
2809 | for (;\r | |
2810 | Difference >= (INTN) SavedMenuOption->Skip;\r | |
2811 | Difference = Difference - (INTN) SavedMenuOption->Skip\r | |
2812 | ) {\r | |
2813 | //\r | |
2814 | // Since the Difference is greater than or equal to this op-code's skip value, skip it\r | |
2815 | //\r | |
2816 | TopOfScreen = TopOfScreen->ForwardLink;\r | |
2817 | SavedMenuOption = CR (TopOfScreen, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2818 | if (Difference < (INTN) SavedMenuOption->Skip) {\r | |
2819 | Difference = SavedMenuOption->Skip - Difference - 1;\r | |
2820 | break;\r | |
2821 | } else {\r | |
2822 | if (Difference == (INTN) SavedMenuOption->Skip) {\r | |
2823 | TopOfScreen = TopOfScreen->ForwardLink;\r | |
2824 | SavedMenuOption = CR (TopOfScreen, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2825 | Difference = SavedMenuOption->Skip - Difference;\r | |
2826 | break;\r | |
2827 | }\r | |
2828 | }\r | |
2829 | }\r | |
2830 | //\r | |
2831 | // Since we will act on this op-code in the next routine, and increment the\r | |
2832 | // SkipValue, set the skips to one less than what is required.\r | |
2833 | //\r | |
2834 | SkipValue = Difference - 1;\r | |
2835 | \r | |
2836 | } else {\r | |
2837 | //\r | |
2838 | // Since we will act on this op-code in the next routine, and increment the\r | |
2839 | // SkipValue, set the skips to one less than what is required.\r | |
2840 | //\r | |
2841 | SkipValue = OldSkipValue + (Temp - BottomRow) - 1;\r | |
2842 | }\r | |
2843 | } else {\r | |
2844 | if ((OldSkipValue + 1) == (INTN) SavedMenuOption->Skip) {\r | |
2845 | TopOfScreen = TopOfScreen->ForwardLink;\r | |
2846 | break;\r | |
2847 | } else {\r | |
2848 | SkipValue = OldSkipValue;\r | |
2849 | }\r | |
2850 | }\r | |
2851 | //\r | |
2852 | // If the op-code at the top of the screen is more than one line, let's not skip it yet\r | |
2853 | // Let's set a skip flag to smoothly scroll the top of the screen.\r | |
2854 | //\r | |
2855 | if (SavedMenuOption->Skip > 1) {\r | |
2856 | if (SavedMenuOption == NextMenuOption) {\r | |
2857 | SkipValue = 0;\r | |
2858 | } else {\r | |
2859 | SkipValue++;\r | |
2860 | }\r | |
2861 | } else {\r | |
2862 | SkipValue = 0;\r | |
2863 | TopOfScreen = TopOfScreen->ForwardLink;\r | |
2864 | }\r | |
2865 | } while (SavedMenuOption->Skip == 0);\r | |
2866 | \r | |
2867 | Repaint = TRUE;\r | |
2868 | OldSkipValue = SkipValue;\r | |
2869 | }\r | |
2870 | \r | |
2871 | UpdateStatusBar (INPUT_ERROR, MenuOption->ThisTag->Flags, FALSE);\r | |
2872 | \r | |
2873 | } else {\r | |
2874 | if (SubMenu) {\r | |
2875 | SavedMenuOption = MenuOption;\r | |
2876 | MenuOption = CR (NewPos, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
2877 | if (MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || MenuOption->ThisTag->GrayOut) {\r | |
2878 | //\r | |
2879 | // If we are at the end of the list and sitting on a text op, we need to more forward\r | |
2880 | //\r | |
2881 | ScreenOperation = UiUp;\r | |
2882 | ControlFlag = CfScreenOperation;\r | |
2883 | break;\r | |
2884 | }\r | |
2885 | \r | |
2886 | MenuOption = SavedMenuOption;\r | |
2887 | //\r | |
2888 | // If we are at the end of the list and sitting on a Date/Time op, rewind to the head.\r | |
2889 | //\r | |
2890 | AdjustDateAndTimePosition (TRUE, &NewPos);\r | |
2891 | }\r | |
2892 | }\r | |
2893 | break;\r | |
2894 | \r | |
2895 | case CfUiSave:\r | |
2896 | ControlFlag = CfCheckSelection;\r | |
2897 | //\r | |
2898 | // Check for tags that might have LATE_CHECK enabled. If they do, we can't switch pages or save NV data.\r | |
2899 | //\r | |
2900 | if (MenuOption != NULL) {\r | |
2901 | if (!SelectionsAreValid (MenuOption, FileFormTagsHead)) {\r | |
2902 | Selection = NULL;\r | |
2903 | Repaint = TRUE;\r | |
2904 | break;\r | |
2905 | }\r | |
2906 | }\r | |
2907 | //\r | |
2908 | // If callbacks are active, and the callback has a Write method, try to use it\r | |
2909 | //\r | |
2910 | if (FileFormTags->VariableDefinitions->VariableName == NULL) {\r | |
2911 | if ((FormCallback != NULL) && (FormCallback->NvWrite != NULL)) {\r | |
2912 | Status = FormCallback->NvWrite (\r | |
2913 | FormCallback,\r | |
2914 | (CHAR16 *) L"Setup",\r | |
2915 | &FileFormTags->FormTags.Tags[0].GuidValue,\r | |
2916 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
2917 | VariableDefinition->VariableSize,\r | |
2918 | (VOID *) VariableDefinition->NvRamMap,\r | |
2919 | &gResetRequired\r | |
2920 | );\r | |
2921 | \r | |
2922 | } else {\r | |
2923 | Status = gRT->SetVariable (\r | |
2924 | (CHAR16 *) L"Setup",\r | |
2925 | &FileFormTags->FormTags.Tags[0].GuidValue,\r | |
2926 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
2927 | VariableDefinition->VariableSize,\r | |
2928 | (VOID *) VariableDefinition->NvRamMap\r | |
2929 | );\r | |
2930 | }\r | |
2931 | } else {\r | |
2932 | VariableDefinition = FileFormTags->VariableDefinitions;\r | |
2933 | \r | |
2934 | for (; VariableDefinition != NULL; VariableDefinition = VariableDefinition->Next) {\r | |
2935 | if ((FormCallback != NULL) && (FormCallback->NvWrite != NULL)) {\r | |
2936 | Status = FormCallback->NvWrite (\r | |
2937 | FormCallback,\r | |
2938 | VariableDefinition->VariableName,\r | |
2939 | &VariableDefinition->Guid,\r | |
2940 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
2941 | VariableDefinition->VariableSize,\r | |
2942 | (VOID *) VariableDefinition->NvRamMap,\r | |
2943 | &gResetRequired\r | |
2944 | );\r | |
2945 | \r | |
2946 | } else {\r | |
2947 | Status = gRT->SetVariable (\r | |
2948 | VariableDefinition->VariableName,\r | |
2949 | &VariableDefinition->Guid,\r | |
2950 | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r | |
2951 | VariableDefinition->VariableSize,\r | |
2952 | (VOID *) VariableDefinition->NvRamMap\r | |
2953 | );\r | |
2954 | }\r | |
2955 | }\r | |
2956 | }\r | |
2957 | \r | |
2958 | UpdateStatusBar (INPUT_ERROR, MenuOption->ThisTag->Flags, FALSE);\r | |
2959 | UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, FALSE);\r | |
2960 | break;\r | |
2961 | \r | |
2962 | case CfUiDefault:\r | |
2963 | ControlFlag = CfCheckSelection;\r | |
2964 | \r | |
2965 | NvMapListHead = NULL;\r | |
2966 | \r | |
2967 | Status = Hii->GetDefaultImage (Hii, MenuOption->Handle, EFI_IFR_FLAG_DEFAULT, &NvMapListHead);\r | |
2968 | \r | |
2969 | if (!EFI_ERROR (Status)) {\r | |
2970 | ASSERT_EFI_ERROR (NULL != NvMapListHead);\r | |
2971 | \r | |
2972 | NvMapListNode = NvMapListHead;\r | |
2973 | \r | |
2974 | while (NULL != NvMapListNode) {\r | |
2975 | if (FileFormTags->VariableDefinitions->VariableId == NvMapListNode->VariablePack->VariableId) {\r | |
2976 | NvMap = (VOID *) ((CHAR8 *) NvMapListNode->VariablePack + sizeof (EFI_HII_VARIABLE_PACK) + NvMapListNode->VariablePack->VariableNameLength);\r | |
2977 | NvMapSize = NvMapListNode->VariablePack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - NvMapListNode->VariablePack->VariableNameLength;\r | |
2978 | break;\r | |
2979 | }\r | |
2980 | NvMapListNode = NvMapListNode->NextVariablePack;\r | |
2981 | }\r | |
2982 | \r | |
2983 | //\r | |
2984 | // Free the buffer that was allocated.\r | |
2985 | //\r | |
2986 | gBS->FreePool (FileFormTags->VariableDefinitions->NvRamMap);\r | |
2987 | gBS->FreePool (FileFormTags->VariableDefinitions->FakeNvRamMap);\r | |
2988 | \r | |
2989 | //\r | |
2990 | // Allocate, copy the NvRamMap.\r | |
2991 | //\r | |
2992 | FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize - FileFormTags->VariableDefinitions->VariableSize);\r | |
2993 | FileFormTags->VariableDefinitions->VariableSize = (UINT16) NvMapSize;\r | |
2994 | FileFormTags->VariableDefinitions->VariableFakeSize = (UINT16) (FileFormTags->VariableDefinitions->VariableFakeSize + FileFormTags->VariableDefinitions->VariableSize);\r | |
2995 | \r | |
2996 | FileFormTags->VariableDefinitions->NvRamMap = AllocateZeroPool (FileFormTags->VariableDefinitions->VariableSize);\r | |
2997 | FileFormTags->VariableDefinitions->FakeNvRamMap = AllocateZeroPool (NvMapSize + FileFormTags->VariableDefinitions->VariableFakeSize);\r | |
2998 | \r | |
2999 | CopyMem (FileFormTags->VariableDefinitions->NvRamMap, NvMap, NvMapSize);\r | |
3000 | gBS->FreePool (NvMapListHead);\r | |
3001 | }\r | |
3002 | \r | |
3003 | UpdateStatusBar (NV_UPDATE_REQUIRED, MenuOption->ThisTag->Flags, TRUE);\r | |
3004 | Repaint = TRUE;\r | |
3005 | //\r | |
3006 | // After the repaint operation, we should refresh the highlight.\r | |
3007 | //\r | |
3008 | NewLine = TRUE;\r | |
3009 | break;\r | |
3010 | \r | |
3011 | case CfUiNoOperation:\r | |
3012 | ControlFlag = CfCheckSelection;\r | |
3013 | break;\r | |
3014 | \r | |
3015 | case CfExit:\r | |
3016 | while (gMenuRefreshHead != NULL) {\r | |
3017 | OldMenuRefreshEntry = gMenuRefreshHead->Next;\r | |
3018 | \r | |
3019 | gBS->FreePool (gMenuRefreshHead);\r | |
3020 | \r | |
3021 | gMenuRefreshHead = OldMenuRefreshEntry;\r | |
3022 | }\r | |
3023 | \r | |
3024 | gST->ConOut->SetCursorPosition (gST->ConOut, 0, Row + 4);\r | |
3025 | gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r | |
3026 | gST->ConOut->OutputString (gST->ConOut, (CHAR16 *) L"\n");\r | |
3027 | \r | |
3028 | gActiveIfr = MenuOption->IfrNumber;\r | |
3029 | return Selection;\r | |
3030 | \r | |
3031 | default:\r | |
3032 | break;\r | |
3033 | }\r | |
3034 | }\r | |
3035 | }\r | |
3036 | \r | |
3037 | BOOLEAN\r | |
3038 | ValueIsScroll (\r | |
3039 | IN BOOLEAN Direction,\r | |
3040 | IN LIST_ENTRY *CurrentPos\r | |
3041 | )\r | |
3042 | /*++\r | |
3043 | \r | |
3044 | Routine Description:\r | |
3045 | Determine if the menu is the last menu that can be selected. \r | |
3046 | \r | |
3047 | Arguments:\r | |
3048 | Direction - the scroll direction. False is down. True is up.\r | |
3049 | \r | |
3050 | Returns:\r | |
3051 | FALSE -- the menu isn't the last menu that can be selected.\r | |
3052 | TRUE -- the menu is the last menu that can be selected.\r | |
3053 | --*/\r | |
3054 | {\r | |
3055 | LIST_ENTRY *Temp;\r | |
3056 | UI_MENU_OPTION *MenuOption;\r | |
3057 | MenuOption = NULL;\r | |
3058 | \r | |
3059 | Temp = Direction ? CurrentPos->BackLink : CurrentPos->ForwardLink;\r | |
3060 | \r | |
3061 | if (Temp == &Menu) {\r | |
3062 | return TRUE;\r | |
3063 | }\r | |
3064 | \r | |
3065 | for (; Temp != &Menu; Temp = Direction ? Temp->BackLink : Temp->ForwardLink) {\r | |
3066 | MenuOption = CR (Temp, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
3067 | if (!(MenuOption->ThisTag->Operand == EFI_IFR_SUBTITLE_OP || MenuOption->ThisTag->GrayOut)) {\r | |
3068 | return FALSE;\r | |
3069 | }\r | |
3070 | }\r | |
3071 | \r | |
3072 | return TRUE;\r | |
3073 | }\r | |
3074 | \r | |
3075 | UINTN\r | |
3076 | AdjustDateAndTimePosition (\r | |
3077 | IN BOOLEAN DirectionUp,\r | |
3078 | IN LIST_ENTRY **CurrentPosition\r | |
3079 | )\r | |
3080 | /*++\r | |
3081 | Routine Description:\r | |
3082 | Adjust Data and Time tag position accordingly.\r | |
3083 | Data format : [01/02/2004] [11:22:33]\r | |
3084 | Line number : 0 0 1 0 0 1\r | |
3085 | \r | |
3086 | Arguments:\r | |
3087 | Direction - the up or down direction. False is down. True is up.\r | |
3088 | CurrentPos - Current position.\r | |
3089 | \r | |
3090 | Returns:\r | |
3091 | Return line number to pad. It is possible that we stand on a zero-advance \r | |
3092 | data or time opcode, so pad one line when we judge if we are going to scroll outside.\r | |
3093 | --*/\r | |
3094 | {\r | |
3095 | UINTN Count;\r | |
3096 | LIST_ENTRY *NewPosition;\r | |
3097 | UI_MENU_OPTION *MenuOption;\r | |
3098 | UINTN PadLineNumber;\r | |
3099 | \r | |
3100 | PadLineNumber = 0;\r | |
3101 | NewPosition = *CurrentPosition;\r | |
3102 | MenuOption = CR (NewPosition, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
3103 | \r | |
3104 | if ((MenuOption->ThisTag->Operand == EFI_IFR_DATE_OP) || (MenuOption->ThisTag->Operand == EFI_IFR_TIME_OP)) {\r | |
3105 | //\r | |
3106 | // Calculate the distance from current position to the last Date/Time op-code.\r | |
3107 | //\r | |
3108 | Count = 0;\r | |
3109 | while (MenuOption->ThisTag->NumberOfLines == 0) {\r | |
3110 | Count++;\r | |
3111 | NewPosition = NewPosition->ForwardLink;\r | |
3112 | MenuOption = CR (NewPosition, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE);\r | |
3113 | PadLineNumber = 1;\r | |
3114 | }\r | |
3115 | \r | |
3116 | NewPosition = *CurrentPosition;\r | |
3117 | if (DirectionUp) {\r | |
3118 | //\r | |
3119 | // Since the behavior of hitting the up arrow on a Date/Time op-code is intended\r | |
3120 | // to be one that back to the previous set of op-codes, we need to advance to the first\r | |
3121 | // Date/Time op-code and leave the remaining logic in CfUiUp intact so the appropriate\r | |
3122 | // checking can be done.\r | |
3123 | //\r | |
3124 | while (Count++ < 2) {\r | |
3125 | NewPosition = NewPosition->BackLink;\r | |
3126 | }\r | |
3127 | } else {\r | |
3128 | //\r | |
3129 | // Since the behavior of hitting the down arrow on a Date/Time op-code is intended\r | |
3130 | // to be one that progresses to the next set of op-codes, we need to advance to the last\r | |
3131 | // Date/Time op-code and leave the remaining logic in CfUiDown intact so the appropriate\r | |
3132 | // checking can be done.\r | |
3133 | //\r | |
3134 | while (Count-- > 0) {\r | |
3135 | NewPosition = NewPosition->ForwardLink;\r | |
3136 | }\r | |
3137 | }\r | |
3138 | \r | |
3139 | *CurrentPosition = NewPosition;\r | |
3140 | }\r | |
3141 | \r | |
3142 | return PadLineNumber;\r | |
3143 | }\r |