1 /** @file
2   Extension Form Browser Protocol provides the services that can be used to
3   register the different hot keys for the standard Browser actions described in UEFI specification.
4 
5 Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10 
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #ifndef __FORM_BROWSER_EXTENSION_H__
17 #define __FORM_BROWSER_EXTENSION_H__
18 
19 #define FORM_BROWSER_EXTENSION_PROTOCOL_GUID  \
20   { 0x1f73b18d, 0x4630, 0x43c1, { 0xa1, 0xde, 0x6f, 0x80, 0x85, 0x5d, 0x7d, 0xa4 } }
21 
22 typedef struct _EFI_FORM_BROWSER_EXTENSION_PROTOCOL   EFI_FORM_BROWSER_EXTENSION_PROTOCOL;
23 
24 //
25 // Return value of SAVE_REMINDER() that describes whether the changed data is saved or discarded.
26 //
27 #define BROWSER_NO_CHANGES          0
28 #define BROWSER_SAVE_CHANGES        1
29 #define BROWSER_DISCARD_CHANGES     2
30 #define BROWSER_KEEP_CURRENT        3
31 
32 //
33 // Browser actions. They can be cominbed together.
34 // If more than one actions are specified, the action with low bit will be executed first.
35 //
36 #define BROWSER_ACTION_UNREGISTER   0
37 #define BROWSER_ACTION_DISCARD      BIT0
38 #define BROWSER_ACTION_DEFAULT      BIT1
39 #define BROWSER_ACTION_SUBMIT       BIT2
40 #define BROWSER_ACTION_RESET        BIT3
41 #define BROWSER_ACTION_EXIT         BIT4
42 #define BROWSER_ACTION_GOTO         BIT5
43 
44 //
45 // Scope for Browser action. It may be Form, FormSet or System level.
46 //
47 typedef enum {
48   FormLevel,
49   FormSetLevel,
50   SystemLevel,
51   MaxLevel
52 } BROWSER_SETTING_SCOPE;
53 
54 /**
55   Configure what scope the hot key will impact.
56   All hot keys have the same scope. The mixed hot keys with the different level are not supported.
57   If no scope is set, the default scope will be FormSet level.
58   After all registered hot keys are removed, previous Scope can reset to another level.
59 
60   @param[in] Scope               Scope level to be set.
61 
62   @retval EFI_SUCCESS            Scope is set correctly.
63   @retval EFI_INVALID_PARAMETER  Scope is not the valid value specified in BROWSER_SETTING_SCOPE.
64   @retval EFI_UNSPPORTED         Scope level is different from current one that the registered hot keys have.
65 
66 **/
67 typedef
68 EFI_STATUS
69 (EFIAPI *SET_SCOPE) (
70   IN BROWSER_SETTING_SCOPE Scope
71   );
72 
73 /**
74   Register the hot key with its browser action, or unregistered the hot key.
75   If the action value is zero, the hot key will be unregistered if it has been registered.
76   If the same hot key has been registered, the new action and help string will override the previous ones.
77 
78   @param[in] KeyData     A pointer to a buffer that describes the keystroke
79                          information for the hot key. Its type is EFI_INPUT_KEY to
80                          be supported by all ConsoleIn devices.
81   @param[in] Action      Action value that describes what action will be trigged when the hot key is pressed.
82   @param[in] DefaultId   Specifies the type of defaults to retrieve, which is only for DEFAULT action.
83   @param[in] HelpString  Help string that describes the hot key information.
84                          Its value may be NULL for the unregistered hot key.
85 
86   @retval EFI_SUCCESS            Hot key is registered or unregistered.
87   @retval EFI_INVALID_PARAMETER  KeyData is NULL.
88 **/
89 typedef
90 EFI_STATUS
91 (EFIAPI *REGISTER_HOT_KEY) (
92   IN EFI_INPUT_KEY *KeyData,
93   IN UINT32        Action,
94   IN UINT16        DefaultId,
95   IN EFI_STRING    HelpString OPTIONAL
96   );
97 
98 /**
99   This handler is responsbile for the left things on normal boot after all UI forms are closed.
100   For example, it can continue to boot the first boot option.
101 
102   It will be used only when EXIT action is trigged as system level.
103 **/
104 typedef
105 VOID
106 (EFIAPI *EXIT_HANDLER) (
107   VOID
108   );
109 
110 /**
111   Register Exit handler function.
112   When more than one handler function is registered, the latter one will override the previous one.
113   When NULL handler is specified, the previous Exit handler will be unregistered.
114 
115   @param[in] Handler      Pointer to handler function.
116 
117 **/
118 typedef
119 VOID
120 (EFIAPI *REGISTER_EXIT_HANDLER) (
121   IN EXIT_HANDLER Handler
122   );
123 
124 /**
125   Create reminder to let user to choose save or discard the changed browser data.
126   Caller can use it to actively check the changed browser data.
127 
128   @retval BROWSER_NO_CHANGES       No browser data is changed.
129   @retval BROWSER_SAVE_CHANGES     The changed browser data is saved.
130   @retval BROWSER_DISCARD_CHANGES  The changed browser data is discard.
131   @retval BROWSER_KEEP_CURRENT     Browser keep current changes.
132 
133 **/
134 typedef
135 UINT32
136 (EFIAPI *SAVE_REMINDER)(
137   VOID
138   );
139 
140 struct _EFI_FORM_BROWSER_EXTENSION_PROTOCOL {
141   SET_SCOPE              SetScope;
142   REGISTER_HOT_KEY       RegisterHotKey;
143   REGISTER_EXIT_HANDLER  RegiserExitHandler;
144   SAVE_REMINDER          SaveReminder;
145 };
146 
147 extern EFI_GUID gEfiFormBrowserExProtocolGuid;
148 
149 #endif
150 
151