1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 3 #ifndef _THINK_LMI_H_ 4 #define _THINK_LMI_H_ 5 6 #include <linux/types.h> 7 #include <linux/wmi.h> 8 9 #define TLMI_SETTINGS_COUNT 256 10 #define TLMI_SETTINGS_MAXLEN 512 11 #define TLMI_PWD_BUFSIZE 129 12 #define TLMI_LANG_MAXLEN 4 13 #define TLMI_INDEX_MAX 32 14 15 /* Possible error values */ 16 struct tlmi_err_codes { 17 const char *err_str; 18 int err_code; 19 }; 20 21 enum encoding_option { 22 TLMI_ENCODING_ASCII, 23 TLMI_ENCODING_SCANCODE, 24 }; 25 26 enum level_option { 27 TLMI_LEVEL_USER, 28 TLMI_LEVEL_MASTER, 29 }; 30 31 /* 32 * There are a limit on the number of WMI operations you can do if you use 33 * the default implementation of saving on every set. This is due to a 34 * limitation in EFI variable space used. 35 * Have a 'bulk save' mode where you can manually trigger the save, and can 36 * therefore set unlimited variables - for users that need it. 37 */ 38 enum save_mode { 39 TLMI_SAVE_SINGLE, 40 TLMI_SAVE_BULK, 41 TLMI_SAVE_SAVE, 42 }; 43 44 /* password configuration details */ 45 #define TLMI_PWDCFG_MODE_LEGACY 0 46 #define TLMI_PWDCFG_MODE_PASSWORD 1 47 #define TLMI_PWDCFG_MODE_MULTICERT 3 48 49 struct tlmi_pwdcfg_core { 50 uint32_t password_mode; 51 uint32_t password_state; 52 uint32_t min_length; 53 uint32_t max_length; 54 uint32_t supported_encodings; 55 uint32_t supported_keyboard; 56 }; 57 58 struct tlmi_pwdcfg_ext { 59 uint32_t hdd_user_password; 60 uint32_t hdd_master_password; 61 uint32_t nvme_user_password; 62 uint32_t nvme_master_password; 63 }; 64 65 struct tlmi_pwdcfg { 66 struct tlmi_pwdcfg_core core; 67 struct tlmi_pwdcfg_ext ext; 68 }; 69 70 /* password setting details */ 71 struct tlmi_pwd_setting { 72 struct kobject kobj; 73 bool pwd_enabled; 74 char password[TLMI_PWD_BUFSIZE]; 75 const char *pwd_type; 76 const char *role; 77 int minlen; 78 int maxlen; 79 enum encoding_option encoding; 80 char kbdlang[TLMI_LANG_MAXLEN]; 81 int index; /*Used for HDD and NVME auth */ 82 enum level_option level; 83 bool cert_installed; 84 char *signature; 85 char *save_signature; 86 }; 87 88 /* Attribute setting details */ 89 struct tlmi_attr_setting { 90 struct kobject kobj; 91 struct wmi_device *wdev; 92 int index; 93 char name[TLMI_SETTINGS_MAXLEN]; 94 char display_name[TLMI_SETTINGS_MAXLEN]; 95 char *possible_values; 96 }; 97 98 struct think_lmi { 99 struct wmi_device *wmi_device; 100 101 bool can_set_bios_settings; 102 bool can_get_bios_selections; 103 bool can_set_bios_password; 104 bool can_get_password_settings; 105 bool pending_changes; 106 bool can_debug_cmd; 107 bool opcode_support; 108 bool certificate_support; 109 enum save_mode save_mode; 110 bool save_required; 111 bool reboot_required; 112 113 struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT]; 114 struct device *class_dev; 115 struct kset *attribute_kset; 116 struct kset *authentication_kset; 117 118 struct tlmi_pwdcfg pwdcfg; 119 struct tlmi_pwd_setting *pwd_admin; 120 struct tlmi_pwd_setting *pwd_power; 121 struct tlmi_pwd_setting *pwd_system; 122 struct tlmi_pwd_setting *pwd_hdd; 123 struct tlmi_pwd_setting *pwd_nvme; 124 }; 125 126 #endif /* !_THINK_LMI_H_ */ 127