summaryrefslogtreecommitdiffstats
path: root/plugins/sed/sedopal_cmd.h
blob: 3b6eae27a8ac3841f1071e491d5208903831c699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef _SED_OPAL_CMD_H
#define _SED_OPAL_CMD_H

#define	SEDOPAL_CURRENT_PW_PROMPT	"Password: "
#define	SEDOPAL_NEW_PW_PROMPT		"New Password: "
#define	SEDOPAL_REENTER_PW_PROMPT	"Re-enter New Password: "
#define	SEDOPAL_PSID_PROMPT		"PSID: "

#define	SEDOPAL_MIN_PASSWORD_LEN	8
#define	SEDOPAL_MAX_PASSWORD_LEN	32

#define NVME_DEV_PATH			"/dev/nvme"

extern bool sedopal_ask_key;
extern bool sedopal_ask_new_key;
extern bool sedopal_destructive_revert;
extern bool sedopal_psid_revert;

/*
 * Sub-commands supported by the sedopal command
 */
enum sedopal_cmds {
	SEDOPAL_CMD_NOT_SPECIFIED =	-1,
	SEDOPAL_CMD_INITIALIZE =	0,
	SEDOPAL_CMD_LOCK =		1,
	SEDOPAL_CMD_UNLOCK =		2,
	SEDOPAL_CMD_REVERT =		3,
	SEDOPAL_CMD_PASSWORD =		4,
	SEDOPAL_CMD_DISCOVER =		5,
};

struct cmd_table {
	int (*cmd_handler)(int fd);
};

/*
 * command handlers
 */
int sedopal_cmd_initialize(int fd);
int sedopal_cmd_lock(int fd);
int sedopal_cmd_unlock(int fd);
int sedopal_cmd_revert(int fd);
int sedopal_cmd_password(int fd);
int sedopal_cmd_discover(int fd);

/*
 * utility functions
 */
int sedopal_open_nvme_device(char *device);
int sedopal_lock_unlock(int fd, int lock_state);
const char *sedopal_error_to_text(int code);

#endif /* _SED_OPAL_CMD_H */