Home | History | Annotate | Download | only in WinNtGopDxe
      1 /** @file
      2 
      3 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
      4 This program and the accompanying materials
      5 are licensed and made available under the terms and conditions of the BSD License
      6 which accompanies this distribution.  The full text of the license may be found at
      7 http://opensource.org/licenses/bsd-license.php
      8 
      9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 Module Name:
     13 
     14   WinNtGop.h
     15 
     16 Abstract:
     17 
     18   Private data for the Gop driver that is bound to the WinNt Thunk protocol
     19 
     20 
     21 **/
     22 
     23 #ifndef _WIN_NT_GOP_H_
     24 #define _WIN_NT_GOP_H_
     25 
     26 
     27 #include <Uefi.h>
     28 #include <WinNtDxe.h>
     29 
     30 #include <Guid/EventGroup.h>
     31 #include <Protocol/WinNtIo.h>
     32 #include <Protocol/ComponentName.h>
     33 #include <Protocol/SimpleTextIn.h>
     34 #include <Protocol/SimpleTextInEx.h>
     35 #include <Protocol/DriverBinding.h>
     36 #include <Protocol/GraphicsOutput.h>
     37 
     38 #include <Library/DebugLib.h>
     39 #include <Library/BaseLib.h>
     40 #include <Library/UefiDriverEntryPoint.h>
     41 #include <Library/UefiLib.h>
     42 #include <Library/BaseMemoryLib.h>
     43 #include <Library/UefiBootServicesTableLib.h>
     44 #include <Library/MemoryAllocationLib.h>
     45 
     46 //
     47 // WM_SYSKEYDOWN/WM_SYSKEYUP Notification
     48 // lParam
     49 // bit 24: Specifies whether the key is an extended key,
     50 // such as the right-hand ALT and CTRL keys that appear on
     51 // an enhanced 101- or 102-key keyboard.
     52 // The value is 1 if it is an extended key; otherwise, it is 0.
     53 // bit 29:Specifies the context code.
     54 // The value is 1 if the ALT key is down while the key is pressed/released;
     55 // it is 0 if the WM_SYSKEYDOWN message is posted to the active window
     56 // because no window has the keyboard focus.
     57 #define GOP_EXTENDED_KEY         (0x1 << 24)
     58 #define GOP_ALT_KEY_PRESSED      (0x1 << 29)
     59 
     60 #define KEYBOARD_TIMER_INTERVAL         200000  // 0.02s
     61 
     62 #define MAX_Q 256
     63 
     64 typedef struct {
     65   UINTN             Front;
     66   UINTN             Rear;
     67   EFI_KEY_DATA      Q[MAX_Q];
     68   CRITICAL_SECTION  Cs;
     69 } GOP_QUEUE_FIXED;
     70 
     71 #define WIN_NT_GOP_CLASS_NAME       L"WinNtGopWindow"
     72 
     73 #define GOP_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('S', 'g', 'o', 'N')
     74 
     75 #define WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('W', 'g', 'S', 'n')
     76 
     77 typedef struct _WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
     78   UINTN                                 Signature;
     79   EFI_KEY_DATA                          KeyData;
     80   EFI_KEY_NOTIFY_FUNCTION               KeyNotificationFn;
     81   LIST_ENTRY                            NotifyEntry;
     82 } WIN_NT_GOP_SIMPLE_TEXTIN_EX_NOTIFY;
     83 
     84 #define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
     85 
     86 typedef struct {
     87   UINT32                     HorizontalResolution;
     88   UINT32                     VerticalResolution;
     89   UINT32                     ColorDepth;
     90   UINT32                     RefreshRate;
     91 } GOP_MODE_DATA;
     92 
     93 typedef struct {
     94   UINT64                        Signature;
     95 
     96   EFI_HANDLE                    Handle;
     97   EFI_GRAPHICS_OUTPUT_PROTOCOL  GraphicsOutput;
     98   EFI_SIMPLE_TEXT_INPUT_PROTOCOL   SimpleTextIn;
     99 
    100   EFI_WIN_NT_THUNK_PROTOCOL     *WinNtThunk;
    101 
    102   EFI_UNICODE_STRING_TABLE      *ControllerNameTable;
    103 
    104   //
    105   // GOP Private Data for QueryMode ()
    106   //
    107   GOP_MODE_DATA                 *ModeData;
    108 
    109   //
    110   // GOP Private Data knowing when to start hardware
    111   //
    112   BOOLEAN                       HardwareNeedsStarting;
    113 
    114   CHAR16                        *WindowName;
    115   CHAR16                        Buffer[160];
    116 
    117   HANDLE                        ThreadInited; // Semaphore
    118   HANDLE                        ThreadHandle; // Thread
    119   DWORD                         ThreadId;
    120 
    121   HWND                          WindowHandle;
    122   WNDCLASSEX                    WindowsClass;
    123 
    124   //
    125   // This screen is used to redraw the scree when windows events happen. It's
    126   // updated in the main thread and displayed in the windows thread.
    127   //
    128   BITMAPV4HEADER                *VirtualScreenInfo;
    129   RGBQUAD                       *VirtualScreen;
    130 
    131   EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FillLine;
    132 
    133   //
    134   // Keyboard Queue used by Simple Text In.
    135   // QueueForRead:   WinProc thread adds, and main thread removes.
    136   // QueueForNotify: WinProc thread adds, and timer thread removes.
    137   //
    138   GOP_QUEUE_FIXED               QueueForRead;
    139   GOP_QUEUE_FIXED               QueueForNotify;
    140 
    141   EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
    142   EFI_KEY_STATE                     KeyState;
    143   LIST_ENTRY                        NotifyList;
    144   BOOLEAN                           LeftShift;
    145   BOOLEAN                           RightShift;
    146   BOOLEAN                           LeftAlt;
    147   BOOLEAN                           RightAlt;
    148   BOOLEAN                           LeftCtrl;
    149   BOOLEAN                           RightCtrl;
    150   BOOLEAN                           LeftLogo;
    151   BOOLEAN                           RightLogo;
    152   BOOLEAN                           Menu;
    153   BOOLEAN                           SysReq;
    154   BOOLEAN                           NumLock;
    155   BOOLEAN                           ScrollLock;
    156   BOOLEAN                           CapsLock;
    157   BOOLEAN                           IsPartialKeySupport;
    158   EFI_EVENT                         TimerEvent;
    159 } GOP_PRIVATE_DATA;
    160 
    161 #define GOP_PRIVATE_DATA_FROM_THIS(a)  \
    162          CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
    163 
    164 #define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a)  \
    165          CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)
    166 
    167 #define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a)  \
    168          CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)
    169 
    170 //
    171 // Global Protocol Variables
    172 //
    173 extern EFI_DRIVER_BINDING_PROTOCOL   gWinNtGopDriverBinding;
    174 extern EFI_COMPONENT_NAME_PROTOCOL   gWinNtGopComponentName;
    175 extern EFI_COMPONENT_NAME2_PROTOCOL  gWinNtGopComponentName2;
    176 
    177 
    178 //
    179 // Gop Hardware abstraction internal worker functions
    180 //
    181 
    182 /**
    183   TODO: Add function description
    184 
    185   @param  WinNtIo              TODO: add argument description
    186 
    187   @return TODO: add return values
    188 
    189 **/
    190 EFI_STATUS
    191 WinNtGopSupported (
    192   IN  EFI_WIN_NT_IO_PROTOCOL  *WinNtIo
    193   );
    194 
    195 
    196 /**
    197   TODO: Add function description
    198 
    199   @param  Private              TODO: add argument description
    200 
    201   @return TODO: add return values
    202 
    203 **/
    204 EFI_STATUS
    205 WinNtGopConstructor (
    206   IN  GOP_PRIVATE_DATA    *Private
    207   );
    208 
    209 
    210 /**
    211   TODO: Add function description
    212 
    213   @param  Private              TODO: add argument description
    214 
    215   @return TODO: add return values
    216 
    217 **/
    218 EFI_STATUS
    219 WinNtGopDestructor (
    220   IN  GOP_PRIVATE_DATA    *Private
    221   );
    222 
    223 //
    224 // UEFI 2.0 driver model prototypes for Win NT GOP
    225 //
    226 
    227 
    228 /**
    229   TODO: Add function description
    230 
    231   @param  ImageHandle          TODO: add argument description
    232   @param  SystemTable          TODO: add argument description
    233 
    234   @return TODO: add return values
    235 
    236 **/
    237 EFI_STATUS
    238 EFIAPI
    239 WinNtGopInitialize (
    240   IN EFI_HANDLE            ImageHandle,
    241   IN EFI_SYSTEM_TABLE      *SystemTable
    242   );
    243 
    244 
    245 /**
    246   TODO: Add function description
    247 
    248   @param  This                 TODO: add argument description
    249   @param  Handle               TODO: add argument description
    250   @param  RemainingDevicePath  TODO: add argument description
    251 
    252   @return TODO: add return values
    253 
    254 **/
    255 EFI_STATUS
    256 EFIAPI
    257 WinNtGopDriverBindingSupported (
    258   IN  EFI_DRIVER_BINDING_PROTOCOL     *This,
    259   IN  EFI_HANDLE                      Handle,
    260   IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath
    261   );
    262 
    263 
    264 /**
    265   TODO: Add function description
    266 
    267   @param  This                 TODO: add argument description
    268   @param  Handle               TODO: add argument description
    269   @param  RemainingDevicePath  TODO: add argument description
    270 
    271   @return TODO: add return values
    272 
    273 **/
    274 EFI_STATUS
    275 EFIAPI
    276 WinNtGopDriverBindingStart (
    277   IN  EFI_DRIVER_BINDING_PROTOCOL     *This,
    278   IN  EFI_HANDLE                      Handle,
    279   IN  EFI_DEVICE_PATH_PROTOCOL        *RemainingDevicePath
    280   );
    281 
    282 
    283 /**
    284   TODO: Add function description
    285 
    286   @param  This                 TODO: add argument description
    287   @param  Handle               TODO: add argument description
    288   @param  NumberOfChildren     TODO: add argument description
    289   @param  ChildHandleBuffer    TODO: add argument description
    290 
    291   @return TODO: add return values
    292 
    293 **/
    294 EFI_STATUS
    295 EFIAPI
    296 WinNtGopDriverBindingStop (
    297   IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
    298   IN  EFI_HANDLE                   Handle,
    299   IN  UINTN                        NumberOfChildren,
    300   IN  EFI_HANDLE                   *ChildHandleBuffer
    301   );
    302 
    303 
    304 /**
    305   TODO: Add function description
    306 
    307   @param  Private              TODO: add argument description
    308   @param  Key                  TODO: add argument description
    309 
    310   @return TODO: add return values
    311 
    312 **/
    313 EFI_STATUS
    314 GopPrivateAddKey (
    315   IN  GOP_PRIVATE_DATA    *Private,
    316   IN  EFI_INPUT_KEY       Key
    317   );
    318 
    319 
    320 /**
    321   TODO: Add function description
    322 
    323   @param  Private              TODO: add argument description
    324 
    325   @return TODO: add return values
    326 
    327 **/
    328 EFI_STATUS
    329 WinNtGopInitializeSimpleTextInForWindow (
    330   IN  GOP_PRIVATE_DATA    *Private
    331   );
    332 
    333 
    334 /**
    335   TODO: Add function description
    336 
    337   @param  Private              TODO: add argument description
    338 
    339   @return TODO: add return values
    340 
    341 **/
    342 EFI_STATUS
    343 WinNtGopDestroySimpleTextInForWindow (
    344   IN  GOP_PRIVATE_DATA    *Private
    345   );
    346 
    347 
    348 
    349 #endif
    350