[go: up one dir, main page]

File: utils.h

package info (click to toggle)
s390-tools 2.15.1-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 8,216 kB
  • sloc: ansic: 130,144; sh: 9,397; cpp: 8,359; perl: 2,517; makefile: 1,960; asm: 1,016
file content (80 lines) | stat: -rw-r--r-- 2,150 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * zkey - Generate, re-encipher, and validate secure keys
 *
 * This header file defines the interface to the CCA host library.
 *
 * Copyright IBM Corp. 2019
 *
 * s390-tools is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#ifndef UTILS_H
#define UTILS_H

#include "lib/zt_common.h"

#include "pkey.h"

int sysfs_is_card_online(unsigned int card, enum card_type cardtype);

int sysfs_is_apqn_online(unsigned int card, unsigned int domain,
			 enum card_type cardtype);

int sysfs_get_card_level(unsigned int card);

enum card_type sysfs_get_card_type(unsigned int card);

#define SERIALNR_LENGTH		17

int sysfs_get_serialnr(unsigned int card, char *serialnr, bool verbose);

struct fw_version {
	unsigned int	major;
	unsigned int	minor;
	unsigned int	api_ordinal;
};

int sysfs_get_firmware_version(unsigned int card, struct fw_version *fw_version,
			       bool verbose);

#define MK_STATE_EMPTY		0
#define MK_STATE_PARTIAL	1 /* For CCA only */
#define MK_STATE_FULL		2 /* For CCA only */
#define MK_STATE_VALID		3
#define MK_STATE_INVALID	4
#define MK_STATE_UNCOMMITTED	5 /* For EP11 only */
#define MK_STATE_COMMITTED	6 /* For EP11 only */
#define MK_STATE_UNKNOWN	-1

struct mk_info_reg {
	int	mk_state;
	u8	mkvp[MKVP_LENGTH];
};

struct mk_info {
	struct mk_info_reg	new_mk;
	struct mk_info_reg	cur_mk;
	struct mk_info_reg	old_mk; /* only available on CCA cards */
};

int sysfs_get_mkvps(unsigned int card, unsigned int domain,
		    struct mk_info *mk_info, bool verbose);

typedef int(*apqn_handler_t) (unsigned int card, unsigned int domain,
			      void *handler_data);

int handle_apqns(const char *apqns, enum card_type cardtype,
		 apqn_handler_t handler, void *handler_data, bool verbose);

int print_mk_info(const char *apqns, enum card_type cardtype, bool verbose);

int cross_check_apqns(const char *apqns, u8 *mkvp, int min_level,
		      const struct fw_version *min_fw_version,
		      enum card_type cardtype, bool print_mks, bool verbose);

bool prompt_for_yes(bool verbose);

char *printable_mkvp(enum card_type cardtype, u8 *mkvp);

#endif