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