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