OpenCore  1.0.4
OpenCore Bootloader
1.0.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AIKShim.c
Go to the documentation of this file.
1
15#include "AIK.h"
16#include "AIKShim.h"
17
18#include <Library/BaseMemoryLib.h>
19#include <Library/DebugLib.h>
20#include <Library/UefiBootServicesTableLib.h>
21
22EFI_STATUS
23EFIAPI
26 OUT AMI_EFI_KEY_DATA *KeyData
27 )
28{
29 DEBUG ((
30 DEBUG_VERBOSE,
31 "AIKAmiKeycodeReadEfikey %p %p ours %p event %d",
32 This,
33 KeyData,
36 ));
37
38 if ((This == NULL) || (KeyData == NULL) || gAikSelf.OurJobIsDone) {
39 return EFI_INVALID_PARAMETER;
40 }
41
43 //
44 // Do not touch any protocol but ours.
45 //
46 return AIKDataReadEntry (&gAikSelf.Data, KeyData);
47 }
48
49 return gAikSelf.Source.AmiReadEfikey (This, KeyData);
50}
51
52EFI_STATUS
53EFIAPI
55 IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
56 OUT EFI_INPUT_KEY *Key
57 )
58{
59 EFI_STATUS Status;
60 AMI_EFI_KEY_DATA AmiKeyData;
61
62 DEBUG ((
63 DEBUG_VERBOSE,
64 "AIKTextInputReadKeyStroke %p %p ours %p event %d",
65 This,
66 Key,
69 ));
70
71 if ((This == NULL) || (Key == NULL) || gAikSelf.OurJobIsDone) {
72 return EFI_INVALID_PARAMETER;
73 }
74
76 //
77 // Do not touch any protocol but ours.
78 //
79 Status = AIKDataReadEntry (&gAikSelf.Data, &AmiKeyData);
80 if (!EFI_ERROR (Status)) {
81 //
82 // 'Partial' keys should not be returned by SimpleTextInput protocols.
83 //
84 if ( (AmiKeyData.Key.ScanCode == 0) && (AmiKeyData.Key.UnicodeChar == 0)
85 && (AmiKeyData.KeyState.KeyToggleState & KEY_STATE_EXPOSED))
86 {
87 Status = EFI_NOT_READY;
88 } else {
89 CopyMem (Key, &AmiKeyData.Key, sizeof (AmiKeyData.Key));
90 }
91 }
92
93 return Status;
94 }
95
96 return gAikSelf.Source.TextReadKeyStroke (This, Key);
97}
98
99EFI_STATUS
100EFIAPI
102 IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
103 OUT EFI_KEY_DATA *KeyData
104 )
105{
106 EFI_STATUS Status;
107 AMI_EFI_KEY_DATA AmiKeyData;
108
109 DEBUG ((
110 DEBUG_VERBOSE,
111 "AIKTextInputReadKeyStrokeEx %p %p ours %p event %d",
112 This,
113 KeyData,
116 ));
117
118 if ((This == NULL) || (KeyData == NULL) || gAikSelf.OurJobIsDone) {
119 return EFI_INVALID_PARAMETER;
120 }
121
123 //
124 // Do not touch any protocol but ours.
125 //
126 Status = AIKDataReadEntry (&gAikSelf.Data, &AmiKeyData);
127 if (!EFI_ERROR (Status)) {
128 CopyMem (&KeyData->Key, &AmiKeyData.Key, sizeof (AmiKeyData.Key));
129 CopyMem (&KeyData->KeyState, &AmiKeyData.KeyState, sizeof (AmiKeyData.KeyState));
130 }
131
132 return Status;
133 }
134
135 return gAikSelf.Source.TextReadKeyStrokeEx (This, KeyData);
136}
137
138VOID
139EFIAPI
141 IN EFI_EVENT Event,
142 IN VOID *Context
143 )
144{
146 DEBUG ((DEBUG_INFO, "AIKShimWaitForKeyHandler got null handler or called when done\n"));
147 return;
148 }
149
150 if (!AIKDataEmpty (&gAikSelf.Data)) {
151 DEBUG ((DEBUG_VERBOSE, "Caught KeyBufferSize non-zero\n"));
152 gBS->SignalEvent (Event);
153 }
154}
AIK_SELF gAikSelf
Definition AIK.c:23
EFI_STATUS AIKDataReadEntry(IN OUT AIK_DATA *Data, OUT AMI_EFI_KEY_DATA *KeyData)
Definition AIKData.c:38
BOOLEAN AIKDataEmpty(IN AIK_DATA *Data)
Definition AIKData.c:30
VOID EFIAPI AIKShimWaitForKeyHandler(IN EFI_EVENT Event, IN VOID *Context)
Definition AIKShim.c:140
EFI_STATUS EFIAPI AIKShimTextInputReadKeyStroke(IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, OUT EFI_INPUT_KEY *Key)
Definition AIKShim.c:54
EFI_STATUS EFIAPI AIKShimAmiKeycodeReadEfikey(IN AMI_EFIKEYCODE_PROTOCOL *This, OUT AMI_EFI_KEY_DATA *KeyData)
Definition AIKShim.c:24
EFI_STATUS EFIAPI AIKShimTextInputReadKeyStrokeEx(IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, OUT EFI_KEY_DATA *KeyData)
Definition AIKShim.c:101
#define KEY_STATE_EXPOSED
Definition AmiKeycode.h:27
EFI_BOOT_SERVICES * gBS
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
AIK_SOURCE Source
Definition AIK.h:55
BOOLEAN OurJobIsDone
Definition AIK.h:86
AIK_DATA Data
Definition AIK.h:65
BOOLEAN InPollKeyboardEvent
Definition AIK.h:80
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * TextInputEx
Definition AIKSource.h:38
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * TextInput
Definition AIKSource.h:37
EFI_INPUT_READ_KEY TextReadKeyStroke
Definition AIKSource.h:46
EFI_INPUT_READ_KEY_EX TextReadKeyStrokeEx
Definition AIKSource.h:47
AMI_EFIKEYCODE_PROTOCOL * AmiKeycode
Definition AIKSource.h:36
AMI_READ_EFI_KEY AmiReadEfikey
Definition AIKSource.h:43
EFI_KEY_STATE KeyState
Definition AmiKeycode.h:32
EFI_INPUT_KEY Key
Definition AmiKeycode.h:31