Linux 4.2.1
[linux/fpc-iii.git] / drivers / s390 / crypto / zcrypt_pcicc.h
blob7fe27e15075b851d01876e88e382902964498e3c
1 /*
2 * zcrypt 2.1.0
4 * Copyright IBM Corp. 2001, 2006
5 * Author(s): Robert Burroughs
6 * Eric Rossman (edrossma@us.ibm.com)
8 * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
9 * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #ifndef _ZCRYPT_PCICC_H_
27 #define _ZCRYPT_PCICC_H_
29 /**
30 * The type 6 message family is associated with PCICC or PCIXCC cards.
32 * It contains a message header followed by a CPRB, both of which
33 * are described below.
35 * Note that all reserved fields must be zeroes.
37 struct type6_hdr {
38 unsigned char reserved1; /* 0x00 */
39 unsigned char type; /* 0x06 */
40 unsigned char reserved2[2]; /* 0x0000 */
41 unsigned char right[4]; /* 0x00000000 */
42 unsigned char reserved3[2]; /* 0x0000 */
43 unsigned char reserved4[2]; /* 0x0000 */
44 unsigned char apfs[4]; /* 0x00000000 */
45 unsigned int offset1; /* 0x00000058 (offset to CPRB) */
46 unsigned int offset2; /* 0x00000000 */
47 unsigned int offset3; /* 0x00000000 */
48 unsigned int offset4; /* 0x00000000 */
49 unsigned char agent_id[16]; /* PCICC: */
50 /* 0x0100 */
51 /* 0x4343412d4150504c202020 */
52 /* 0x010101 */
53 /* PCIXCC: */
54 /* 0x4341000000000000 */
55 /* 0x0000000000000000 */
56 unsigned char rqid[2]; /* rqid. internal to 603 */
57 unsigned char reserved5[2]; /* 0x0000 */
58 unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */
59 unsigned char reserved6[2]; /* 0x0000 */
60 unsigned int ToCardLen1; /* (request CPRB len + 3) & -4 */
61 unsigned int ToCardLen2; /* db len 0x00000000 for PKD */
62 unsigned int ToCardLen3; /* 0x00000000 */
63 unsigned int ToCardLen4; /* 0x00000000 */
64 unsigned int FromCardLen1; /* response buffer length */
65 unsigned int FromCardLen2; /* db len 0x00000000 for PKD */
66 unsigned int FromCardLen3; /* 0x00000000 */
67 unsigned int FromCardLen4; /* 0x00000000 */
68 } __attribute__((packed));
70 /**
71 * CPRB
72 * Note that all shorts, ints and longs are little-endian.
73 * All pointer fields are 32-bits long, and mean nothing
75 * A request CPRB is followed by a request_parameter_block.
77 * The request (or reply) parameter block is organized thus:
78 * function code
79 * VUD block
80 * key block
82 struct CPRB {
83 unsigned short cprb_len; /* CPRB length */
84 unsigned char cprb_ver_id; /* CPRB version id. */
85 unsigned char pad_000; /* Alignment pad byte. */
86 unsigned char srpi_rtcode[4]; /* SRPI return code LELONG */
87 unsigned char srpi_verb; /* SRPI verb type */
88 unsigned char flags; /* flags */
89 unsigned char func_id[2]; /* function id */
90 unsigned char checkpoint_flag; /* */
91 unsigned char resv2; /* reserved */
92 unsigned short req_parml; /* request parameter buffer */
93 /* length 16-bit little endian */
94 unsigned char req_parmp[4]; /* request parameter buffer *
95 * pointer (means nothing: the *
96 * parameter buffer follows *
97 * the CPRB). */
98 unsigned char req_datal[4]; /* request data buffer */
99 /* length ULELONG */
100 unsigned char req_datap[4]; /* request data buffer */
101 /* pointer */
102 unsigned short rpl_parml; /* reply parameter buffer */
103 /* length 16-bit little endian */
104 unsigned char pad_001[2]; /* Alignment pad bytes. ULESHORT */
105 unsigned char rpl_parmp[4]; /* reply parameter buffer *
106 * pointer (means nothing: the *
107 * parameter buffer follows *
108 * the CPRB). */
109 unsigned char rpl_datal[4]; /* reply data buffer len ULELONG */
110 unsigned char rpl_datap[4]; /* reply data buffer */
111 /* pointer */
112 unsigned short ccp_rscode; /* server reason code ULESHORT */
113 unsigned short ccp_rtcode; /* server return code ULESHORT */
114 unsigned char repd_parml[2]; /* replied parameter len ULESHORT*/
115 unsigned char mac_data_len[2]; /* Mac Data Length ULESHORT */
116 unsigned char repd_datal[4]; /* replied data length ULELONG */
117 unsigned char req_pc[2]; /* PC identifier */
118 unsigned char res_origin[8]; /* resource origin */
119 unsigned char mac_value[8]; /* Mac Value */
120 unsigned char logon_id[8]; /* Logon Identifier */
121 unsigned char usage_domain[2]; /* cdx */
122 unsigned char resv3[18]; /* reserved for requestor */
123 unsigned short svr_namel; /* server name length ULESHORT */
124 unsigned char svr_name[8]; /* server name */
125 } __attribute__((packed));
128 * The type 86 message family is associated with PCICC and PCIXCC cards.
130 * It contains a message header followed by a CPRB. The CPRB is
131 * the same as the request CPRB, which is described above.
133 * If format is 1, an error condition exists and no data beyond
134 * the 8-byte message header is of interest.
136 * The non-error message is shown below.
138 * Note that all reserved fields must be zeroes.
140 struct type86_hdr {
141 unsigned char reserved1; /* 0x00 */
142 unsigned char type; /* 0x86 */
143 unsigned char format; /* 0x01 (error) or 0x02 (ok) */
144 unsigned char reserved2; /* 0x00 */
145 unsigned char reply_code; /* reply code (see above) */
146 unsigned char reserved3[3]; /* 0x000000 */
147 } __attribute__((packed));
149 #define TYPE86_RSP_CODE 0x86
150 #define TYPE86_FMT2 0x02
152 struct type86_fmt2_ext {
153 unsigned char reserved[4]; /* 0x00000000 */
154 unsigned char apfs[4]; /* final status */
155 unsigned int count1; /* length of CPRB + parameters */
156 unsigned int offset1; /* offset to CPRB */
157 unsigned int count2; /* 0x00000000 */
158 unsigned int offset2; /* db offset 0x00000000 for PKD */
159 unsigned int count3; /* 0x00000000 */
160 unsigned int offset3; /* 0x00000000 */
161 unsigned int count4; /* 0x00000000 */
162 unsigned int offset4; /* 0x00000000 */
163 } __attribute__((packed));
165 struct function_and_rules_block {
166 unsigned char function_code[2];
167 unsigned short ulen;
168 unsigned char only_rule[8];
169 } __attribute__((packed));
171 int zcrypt_pcicc_init(void);
172 void zcrypt_pcicc_exit(void);
174 #endif /* _ZCRYPT_PCICC_H_ */