zcrypt_pcicc.h 6.5 KB

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