Home | History | Annotate | Download | only in DeviceManagerLib
      1 /** @file
      2 The device manager reference implement
      3 
      4 Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
      5 This program and the accompanying materials
      6 are licensed and made available under the terms and conditions of the BSD License
      7 which accompanies this distribution.  The full text of the license may be found at
      8 http://opensource.org/licenses/bsd-license.php
      9 
     10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 #ifndef _DEVICE_MANAGER_H_
     16 #define _DEVICE_MANAGER_H_
     17 
     18 #include <Guid/MdeModuleHii.h>
     19 #include <Guid/HiiPlatformSetupFormset.h>
     20 
     21 #include <Protocol/HiiConfigAccess.h>
     22 #include <Protocol/PciIo.h>
     23 
     24 #include <Library/PrintLib.h>
     25 #include <Library/DebugLib.h>
     26 #include <Library/BaseMemoryLib.h>
     27 #include <Library/UefiBootServicesTableLib.h>
     28 #include <Library/MemoryAllocationLib.h>
     29 #include <Library/BaseLib.h>
     30 #include <Library/HiiLib.h>
     31 #include <Library/DevicePathLib.h>
     32 #include <Library/UefiHiiServicesLib.h>
     33 
     34 //
     35 // These are defined as the same with vfr file
     36 //
     37 #define DEVICE_MANAGER_FORMSET_GUID  \
     38   { \
     39   0x3ebfa8e6, 0x511d, 0x4b5b, {0xa9, 0x5f, 0xfb, 0x38, 0x26, 0xf, 0x1c, 0x27} \
     40   }
     41 
     42 #define LABEL_END                            0xffff
     43 #define LABEL_FORM_ID_OFFSET                 0x0100
     44 
     45 #define DEVICE_MANAGER_FORM_ID               0x1000
     46 #define NETWORK_DEVICE_LIST_FORM_ID          0x1001
     47 #define NETWORK_DEVICE_FORM_ID               0x1002
     48 #define DEVICE_KEY_OFFSET                    0x4000
     49 #define NETWORK_DEVICE_LIST_KEY_OFFSET       0x2000
     50 
     51 #define MAX_KEY_SECTION_LEN                  0x1000
     52 
     53 #define QUESTION_NETWORK_DEVICE_ID           0x3FFF
     54 //
     55 // These are the VFR compiler generated data representing our VFR data.
     56 //
     57 extern UINT8  DeviceManagerVfrBin[];
     58 
     59 #define DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE  SIGNATURE_32 ('D', 'M', 'C', 'B')
     60 
     61 ///
     62 /// HII specific Vendor Device Path definition.
     63 ///
     64 typedef struct {
     65   VENDOR_DEVICE_PATH             VendorDevicePath;
     66   EFI_DEVICE_PATH_PROTOCOL       End;
     67 } HII_VENDOR_DEVICE_PATH;
     68 
     69 typedef struct {
     70   UINTN                           Signature;
     71 
     72   ///
     73   /// Device Manager HII relative handles
     74   ///
     75   EFI_HII_HANDLE                  HiiHandle;
     76 
     77   EFI_HANDLE                      DriverHandle;
     78 
     79   ///
     80   /// Device Manager Produced protocols
     81   ///
     82   EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;
     83 
     84   ///
     85   /// Configuration data
     86   ///
     87   UINT8                           VideoBios;
     88 } DEVICE_MANAGER_CALLBACK_DATA;
     89 
     90 typedef struct {
     91   EFI_STRING_ID    PromptId;
     92   EFI_QUESTION_ID  QuestionId;
     93 }MENU_INFO_ITEM;
     94 
     95 typedef struct {
     96   UINTN           CurListLen;
     97   UINTN           MaxListLen;
     98   MENU_INFO_ITEM  *NodeList;
     99 } MAC_ADDRESS_NODE_LIST;
    100 
    101 #define DEVICE_MANAGER_CALLBACK_DATA_FROM_THIS(a) \
    102   CR (a, \
    103       DEVICE_MANAGER_CALLBACK_DATA, \
    104       ConfigAccess, \
    105       DEVICE_MANAGER_CALLBACK_DATA_SIGNATURE \
    106       )
    107 typedef struct {
    108   EFI_STRING_ID  StringId;
    109   UINT16         Class;
    110 } DEVICE_MANAGER_MENU_ITEM;
    111 
    112 /**
    113   This function allows a caller to extract the current configuration for one
    114   or more named elements from the target driver.
    115 
    116 
    117   @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
    118   @param Request         A null-terminated Unicode string in <ConfigRequest> format.
    119   @param Progress        On return, points to a character in the Request string.
    120                          Points to the string's null terminator if request was successful.
    121                          Points to the most recent '&' before the first failing name/value
    122                          pair (or the beginning of the string if the failure is in the
    123                          first name/value pair) if the request was not successful.
    124   @param Results         A null-terminated Unicode string in <ConfigAltResp> format which
    125                          has all values filled in for the names in the Request string.
    126                          String to be allocated by the called function.
    127 
    128   @retval  EFI_SUCCESS            The Results is filled with the requested values.
    129   @retval  EFI_OUT_OF_RESOURCES   Not enough memory to store the results.
    130   @retval  EFI_INVALID_PARAMETER  Request is illegal syntax, or unknown name.
    131   @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
    132 
    133 **/
    134 EFI_STATUS
    135 EFIAPI
    136 DeviceManagerExtractConfig (
    137   IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
    138   IN  CONST EFI_STRING                       Request,
    139   OUT EFI_STRING                             *Progress,
    140   OUT EFI_STRING                             *Results
    141   );
    142 
    143 /**
    144   This function processes the results of changes in configuration.
    145 
    146 
    147   @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
    148   @param Configuration   A null-terminated Unicode string in <ConfigResp> format.
    149   @param Progress        A pointer to a string filled in with the offset of the most
    150                          recent '&' before the first failing name/value pair (or the
    151                          beginning of the string if the failure is in the first
    152                          name/value pair) or the terminating NULL if all was successful.
    153 
    154   @retval  EFI_SUCCESS            The Results is processed successfully.
    155   @retval  EFI_INVALID_PARAMETER  Configuration is NULL.
    156   @retval  EFI_NOT_FOUND          Routing data doesn't match any storage in this driver.
    157 
    158 **/
    159 EFI_STATUS
    160 EFIAPI
    161 DeviceManagerRouteConfig (
    162   IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
    163   IN  CONST EFI_STRING                       Configuration,
    164   OUT EFI_STRING                             *Progress
    165   );
    166 
    167 /**
    168   This function is invoked if user selected a interactive opcode from Device Manager's
    169   Formset. If user set VBIOS, the new value is saved to EFI variable.
    170 
    171   @param This            Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
    172   @param Action          Specifies the type of action taken by the browser.
    173   @param QuestionId      A unique value which is sent to the original exporting driver
    174                          so that it can identify the type of data to expect.
    175   @param Type            The type of value for the question.
    176   @param Value           A pointer to the data being sent to the original exporting driver.
    177   @param ActionRequest   On return, points to the action requested by the callback function.
    178 
    179   @retval  EFI_SUCCESS           The callback successfully handled the action.
    180   @retval  EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
    181 
    182 **/
    183 EFI_STATUS
    184 EFIAPI
    185 DeviceManagerCallback (
    186   IN  CONST EFI_HII_CONFIG_ACCESS_PROTOCOL   *This,
    187   IN  EFI_BROWSER_ACTION                     Action,
    188   IN  EFI_QUESTION_ID                        QuestionId,
    189   IN  UINT8                                  Type,
    190   IN  EFI_IFR_TYPE_VALUE                     *Value,
    191   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
    192   );
    193 
    194 #endif
    195