zcrypt_pcicc.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * zcrypt 2.1.0
  3. *
  4. * Copyright IBM Corp. 2001, 2006
  5. * Author(s): Robert Burroughs
  6. * Eric Rossman (edrossma@us.ibm.com)
  7. *
  8. * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
  9. * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
  10. *
  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.
  15. *
  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.
  20. *
  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.
  24. */
  25. #ifndef _ZCRYPT_PCICC_H_
  26. #define _ZCRYPT_PCICC_H_
  27. /**
  28. * The type 6 message family is associated with PCICC or PCIXCC cards.
  29. *
  30. * It contains a message header followed by a CPRB, both of which
  31. * are described below.
  32. *
  33. * Note that all reserved fields must be zeroes.
  34. */
  35. struct type6_hdr {
  36. unsigned char reserved1; /* 0x00 */
  37. unsigned char type; /* 0x06 */
  38. unsigned char reserved2[2]; /* 0x0000 */
  39. unsigned char right[4]; /* 0x00000000 */
  40. unsigned char reserved3[2]; /* 0x0000 */
  41. unsigned char reserved4[2]; /* 0x0000 */
  42. unsigned char apfs[4]; /* 0x00000000 */
  43. unsigned int offset1; /* 0x00000058 (offset to CPRB) */
  44. unsigned int offset2; /* 0x00000000 */
  45. unsigned int offset3; /* 0x00000000 */
  46. unsigned int offset4; /* 0x00000000 */
  47. unsigned char agent_id[16]; /* PCICC: */
  48. /* 0x0100 */
  49. /* 0x4343412d4150504c202020 */
  50. /* 0x010101 */
  51. /* PCIXCC: */
  52. /* 0x4341000000000000 */
  53. /* 0x0000000000000000 */
  54. unsigned char rqid[2]; /* rqid. internal to 603 */
  55. unsigned char reserved5[2]; /* 0x0000 */
  56. unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */
  57. unsigned char reserved6[2]; /* 0x0000 */
  58. unsigned int ToCardLen1; /* (request CPRB len + 3) & -4 */
  59. unsigned int ToCardLen2; /* db len 0x00000000 for PKD */
  60. unsigned int ToCardLen3; /* 0x00000000 */
  61. unsigned int ToCardLen4; /* 0x00000000 */
  62. unsigned int FromCardLen1; /* response buffer length */
  63. unsigned int FromCardLen2; /* db len 0x00000000 for PKD */
  64. unsigned int FromCardLen3; /* 0x00000000 */
  65. unsigned int FromCardLen4; /* 0x00000000 */
  66. } __attribute__((packed));
  67. /**
  68. * CPRB
  69. * Note that all shorts, ints and longs are little-endian.
  70. * All pointer fields are 32-bits long, and mean nothing
  71. *
  72. * A request CPRB is followed by a request_parameter_block.
  73. *
  74. * The request (or reply) parameter block is organized thus:
  75. * function code
  76. * VUD block
  77. * key block
  78. */
  79. struct CPRB {
  80. unsigned short cprb_len; /* CPRB length */
  81. unsigned char cprb_ver_id; /* CPRB version id. */
  82. unsigned char pad_000; /* Alignment pad byte. */
  83. unsigned char srpi_rtcode[4]; /* SRPI return code LELONG */
  84. unsigned char srpi_verb; /* SRPI verb type */
  85. unsigned char flags; /* flags */
  86. unsigned char func_id[2]; /* function id */
  87. unsigned char checkpoint_flag; /* */
  88. unsigned char resv2; /* reserved */
  89. unsigned short req_parml; /* request parameter buffer */
  90. /* length 16-bit little endian */
  91. unsigned char req_parmp[4]; /* request parameter buffer *
  92. * pointer (means nothing: the *
  93. * parameter buffer follows *
  94. * the CPRB). */
  95. unsigned char req_datal[4]; /* request data buffer */
  96. /* length ULELONG */
  97. unsigned char req_datap[4]; /* request data buffer */
  98. /* pointer */
  99. unsigned short rpl_parml; /* reply parameter buffer */
  100. /* length 16-bit little endian */
  101. unsigned char pad_001[2]; /* Alignment pad bytes. ULESHORT */
  102. unsigned char rpl_parmp[4]; /* reply parameter buffer *
  103. * pointer (means nothing: the *
  104. * parameter buffer follows *
  105. * the CPRB). */
  106. unsigned char rpl_datal[4]; /* reply data buffer len ULELONG */
  107. unsigned char rpl_datap[4]; /* reply data buffer */
  108. /* pointer */
  109. unsigned short ccp_rscode; /* server reason code ULESHORT */
  110. unsigned short ccp_rtcode; /* server return code ULESHORT */
  111. unsigned char repd_parml[2]; /* replied parameter len ULESHORT*/
  112. unsigned char mac_data_len[2]; /* Mac Data Length ULESHORT */
  113. unsigned char repd_datal[4]; /* replied data length ULELONG */
  114. unsigned char req_pc[2]; /* PC identifier */
  115. unsigned char res_origin[8]; /* resource origin */
  116. unsigned char mac_value[8]; /* Mac Value */
  117. unsigned char logon_id[8]; /* Logon Identifier */
  118. unsigned char usage_domain[2]; /* cdx */
  119. unsigned char resv3[18]; /* reserved for requestor */
  120. unsigned short svr_namel; /* server name length ULESHORT */
  121. unsigned char svr_name[8]; /* server name */
  122. } __attribute__((packed));
  123. /**
  124. * The type 86 message family is associated with PCICC and PCIXCC cards.
  125. *
  126. * It contains a message header followed by a CPRB. The CPRB is
  127. * the same as the request CPRB, which is described above.
  128. *
  129. * If format is 1, an error condition exists and no data beyond
  130. * the 8-byte message header is of interest.
  131. *
  132. * The non-error message is shown below.
  133. *
  134. * Note that all reserved fields must be zeroes.
  135. */
  136. struct type86_hdr {
  137. unsigned char reserved1; /* 0x00 */
  138. unsigned char type; /* 0x86 */
  139. unsigned char format; /* 0x01 (error) or 0x02 (ok) */
  140. unsigned char reserved2; /* 0x00 */
  141. unsigned char reply_code; /* reply code (see above) */
  142. unsigned char reserved3[3]; /* 0x000000 */
  143. } __attribute__((packed));
  144. #define TYPE86_RSP_CODE 0x86
  145. #define TYPE86_FMT2 0x02
  146. struct type86_fmt2_ext {
  147. unsigned char reserved[4]; /* 0x00000000 */
  148. unsigned char apfs[4]; /* final status */
  149. unsigned int count1; /* length of CPRB + parameters */
  150. unsigned int offset1; /* offset to CPRB */
  151. unsigned int count2; /* 0x00000000 */
  152. unsigned int offset2; /* db offset 0x00000000 for PKD */
  153. unsigned int count3; /* 0x00000000 */
  154. unsigned int offset3; /* 0x00000000 */
  155. unsigned int count4; /* 0x00000000 */
  156. unsigned int offset4; /* 0x00000000 */
  157. } __attribute__((packed));
  158. struct function_and_rules_block {
  159. unsigned char function_code[2];
  160. unsigned short ulen;
  161. unsigned char only_rule[8];
  162. } __attribute__((packed));
  163. int zcrypt_pcicc_init(void);
  164. void zcrypt_pcicc_exit(void);
  165. #endif /* _ZCRYPT_PCICC_H_ */