File Index
Files and directories
Sign in
FILE

think-lmi.h

File preview with syntax highlighting.

linux-6.19.14/drivers/platform/x86/lenovo/think-lmi.h C
  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 */
 16struct tlmi_err_codes {
 17	const char *err_str;
 18	int err_code;
 19};
 20
 21enum encoding_option {
 22	TLMI_ENCODING_ASCII,
 23	TLMI_ENCODING_SCANCODE,
 24};
 25
 26enum 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 */
 38enum save_mode {
 39	TLMI_SAVE_SINGLE,
 40	TLMI_SAVE_BULK,
 41	TLMI_SAVE_SAVE,
 42};
 43
 44/* GUIDs can differ between platforms */
 45struct tlmi_cert_guids {
 46	const char *thumbprint;
 47	const char *set_bios_setting;
 48	const char *save_bios_setting;
 49	const char *cert_to_password;
 50	const char *clear_bios_cert;
 51	const char *update_bios_cert;
 52	const char *set_bios_cert;
 53};
 54
 55/* password configuration details */
 56#define TLMI_PWDCFG_MODE_LEGACY    0
 57#define TLMI_PWDCFG_MODE_PASSWORD  1
 58#define TLMI_PWDCFG_MODE_MULTICERT 3
 59
 60struct tlmi_pwdcfg_core {
 61	uint32_t password_mode;
 62	uint32_t password_state;
 63	uint32_t min_length;
 64	uint32_t max_length;
 65	uint32_t supported_encodings;
 66	uint32_t supported_keyboard;
 67};
 68
 69struct tlmi_pwdcfg_ext {
 70	uint32_t hdd_user_password;
 71	uint32_t hdd_master_password;
 72	uint32_t nvme_user_password;
 73	uint32_t nvme_master_password;
 74};
 75
 76struct tlmi_pwdcfg {
 77	struct tlmi_pwdcfg_core core;
 78	struct tlmi_pwdcfg_ext ext;
 79};
 80
 81/* password setting details */
 82struct tlmi_pwd_setting {
 83	struct kobject kobj;
 84	bool pwd_enabled;
 85	char password[TLMI_PWD_BUFSIZE];
 86	const char *pwd_type;
 87	const char *role;
 88	int minlen;
 89	int maxlen;
 90	enum encoding_option encoding;
 91	char kbdlang[TLMI_LANG_MAXLEN];
 92	int index; /*Used for HDD and NVME auth */
 93	enum level_option level;
 94	bool cert_installed;
 95	char *signature;
 96	char *save_signature;
 97};
 98
 99/* Attribute setting details */
100struct tlmi_attr_setting {
101	struct kobject kobj;
102	struct wmi_device *wdev;
103	int index;
104	char name[TLMI_SETTINGS_MAXLEN];
105	char display_name[TLMI_SETTINGS_MAXLEN];
106	char *possible_values;
107};
108
109struct think_lmi {
110	struct wmi_device *wmi_device;
111
112	bool can_set_bios_settings;
113	bool can_get_bios_selections;
114	bool can_set_bios_password;
115	bool can_get_password_settings;
116	bool pending_changes;
117	bool can_debug_cmd;
118	bool opcode_support;
119	bool certificate_support;
120	enum save_mode save_mode;
121	bool save_required;
122	bool reboot_required;
123	bool thinkcenter_mode;
124
125	struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
126	struct device *class_dev;
127	struct kset *attribute_kset;
128	struct kset *authentication_kset;
129
130	struct tlmi_pwdcfg pwdcfg;
131	struct tlmi_pwd_setting *pwd_admin;
132	struct tlmi_pwd_setting *pwd_power;
133	struct tlmi_pwd_setting *pwd_system;
134	struct tlmi_pwd_setting *pwd_hdd;
135	struct tlmi_pwd_setting *pwd_nvme;
136
137	const struct tlmi_cert_guids *cert_guid;
138};
139
140#endif /* !_THINK_LMI_H_ */
~/ Read-only file preview.