Loading...
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 */
15struct tlmi_err_codes {
16 const char *err_str;
17 int err_code;
18};
19
20enum encoding_option {
21 TLMI_ENCODING_ASCII,
22 TLMI_ENCODING_SCANCODE,
23};
24
25enum level_option {
26 TLMI_LEVEL_USER,
27 TLMI_LEVEL_MASTER,
28};
29
30/* password configuration details */
31struct tlmi_pwdcfg_core {
32 uint32_t password_mode;
33 uint32_t password_state;
34 uint32_t min_length;
35 uint32_t max_length;
36 uint32_t supported_encodings;
37 uint32_t supported_keyboard;
38};
39
40struct tlmi_pwdcfg_ext {
41 uint32_t hdd_user_password;
42 uint32_t hdd_master_password;
43 uint32_t nvme_user_password;
44 uint32_t nvme_master_password;
45};
46
47struct tlmi_pwdcfg {
48 struct tlmi_pwdcfg_core core;
49 struct tlmi_pwdcfg_ext ext;
50};
51
52/* password setting details */
53struct tlmi_pwd_setting {
54 struct kobject kobj;
55 bool valid;
56 char password[TLMI_PWD_BUFSIZE];
57 const char *pwd_type;
58 const char *role;
59 int minlen;
60 int maxlen;
61 enum encoding_option encoding;
62 char kbdlang[TLMI_LANG_MAXLEN];
63 int index; /*Used for HDD and NVME auth */
64 enum level_option level;
65 bool cert_installed;
66 char *signature;
67 char *save_signature;
68};
69
70/* Attribute setting details */
71struct tlmi_attr_setting {
72 struct kobject kobj;
73 int index;
74 char display_name[TLMI_SETTINGS_MAXLEN];
75 char *possible_values;
76};
77
78struct think_lmi {
79 struct wmi_device *wmi_device;
80
81 bool can_set_bios_settings;
82 bool can_get_bios_selections;
83 bool can_set_bios_password;
84 bool can_get_password_settings;
85 bool pending_changes;
86 bool can_debug_cmd;
87 bool opcode_support;
88 bool certificate_support;
89
90 struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
91 struct device *class_dev;
92 struct kset *attribute_kset;
93 struct kset *authentication_kset;
94
95 struct tlmi_pwdcfg pwdcfg;
96 struct tlmi_pwd_setting *pwd_admin;
97 struct tlmi_pwd_setting *pwd_power;
98 struct tlmi_pwd_setting *pwd_system;
99 struct tlmi_pwd_setting *pwd_hdd;
100 struct tlmi_pwd_setting *pwd_nvme;
101};
102
103#endif /* !_THINK_LMI_H_ */
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 */
15struct tlmi_err_codes {
16 const char *err_str;
17 int err_code;
18};
19
20enum encoding_option {
21 TLMI_ENCODING_ASCII,
22 TLMI_ENCODING_SCANCODE,
23};
24
25enum 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 */
37enum save_mode {
38 TLMI_SAVE_SINGLE,
39 TLMI_SAVE_BULK,
40 TLMI_SAVE_SAVE,
41};
42
43/* password configuration details */
44struct tlmi_pwdcfg_core {
45 uint32_t password_mode;
46 uint32_t password_state;
47 uint32_t min_length;
48 uint32_t max_length;
49 uint32_t supported_encodings;
50 uint32_t supported_keyboard;
51};
52
53struct tlmi_pwdcfg_ext {
54 uint32_t hdd_user_password;
55 uint32_t hdd_master_password;
56 uint32_t nvme_user_password;
57 uint32_t nvme_master_password;
58};
59
60struct tlmi_pwdcfg {
61 struct tlmi_pwdcfg_core core;
62 struct tlmi_pwdcfg_ext ext;
63};
64
65/* password setting details */
66struct tlmi_pwd_setting {
67 struct kobject kobj;
68 bool valid;
69 char password[TLMI_PWD_BUFSIZE];
70 const char *pwd_type;
71 const char *role;
72 int minlen;
73 int maxlen;
74 enum encoding_option encoding;
75 char kbdlang[TLMI_LANG_MAXLEN];
76 int index; /*Used for HDD and NVME auth */
77 enum level_option level;
78 bool cert_installed;
79 char *signature;
80 char *save_signature;
81};
82
83/* Attribute setting details */
84struct tlmi_attr_setting {
85 struct kobject kobj;
86 int index;
87 char display_name[TLMI_SETTINGS_MAXLEN];
88 char *possible_values;
89};
90
91struct think_lmi {
92 struct wmi_device *wmi_device;
93
94 bool can_set_bios_settings;
95 bool can_get_bios_selections;
96 bool can_set_bios_password;
97 bool can_get_password_settings;
98 bool pending_changes;
99 bool can_debug_cmd;
100 bool opcode_support;
101 bool certificate_support;
102 enum save_mode save_mode;
103 bool save_required;
104 bool reboot_required;
105
106 struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
107 struct device *class_dev;
108 struct kset *attribute_kset;
109 struct kset *authentication_kset;
110
111 struct tlmi_pwdcfg pwdcfg;
112 struct tlmi_pwd_setting *pwd_admin;
113 struct tlmi_pwd_setting *pwd_power;
114 struct tlmi_pwd_setting *pwd_system;
115 struct tlmi_pwd_setting *pwd_hdd;
116 struct tlmi_pwd_setting *pwd_nvme;
117};
118
119#endif /* !_THINK_LMI_H_ */