tape390.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*************************************************************************
  2. *
  3. * enables user programs to display messages and control encryption
  4. * on s390 tape devices
  5. *
  6. * Copyright IBM Corp. 2001, 2006
  7. * Author(s): Michael Holzheu <holzheu@de.ibm.com>
  8. *
  9. *************************************************************************/
  10. #ifndef _TAPE390_H
  11. #define _TAPE390_H
  12. #define TAPE390_DISPLAY _IOW('d', 1, struct display_struct)
  13. /*
  14. * The TAPE390_DISPLAY ioctl calls the Load Display command
  15. * which transfers 17 bytes of data from the channel to the subsystem:
  16. * - 1 format control byte, and
  17. * - two 8-byte messages
  18. *
  19. * Format control byte:
  20. * 0-2: New Message Overlay
  21. * 3: Alternate Messages
  22. * 4: Blink Message
  23. * 5: Display Low/High Message
  24. * 6: Reserved
  25. * 7: Automatic Load Request
  26. *
  27. */
  28. typedef struct display_struct {
  29. char cntrl;
  30. char message1[8];
  31. char message2[8];
  32. } display_struct;
  33. /*
  34. * Tape encryption support
  35. */
  36. struct tape390_crypt_info {
  37. char capability;
  38. char status;
  39. char medium_status;
  40. } __attribute__ ((packed));
  41. /* Macros for "capable" field */
  42. #define TAPE390_CRYPT_SUPPORTED_MASK 0x01
  43. #define TAPE390_CRYPT_SUPPORTED(x) \
  44. ((x.capability & TAPE390_CRYPT_SUPPORTED_MASK))
  45. /* Macros for "status" field */
  46. #define TAPE390_CRYPT_ON_MASK 0x01
  47. #define TAPE390_CRYPT_ON(x) (((x.status) & TAPE390_CRYPT_ON_MASK))
  48. /* Macros for "medium status" field */
  49. #define TAPE390_MEDIUM_LOADED_MASK 0x01
  50. #define TAPE390_MEDIUM_ENCRYPTED_MASK 0x02
  51. #define TAPE390_MEDIUM_ENCRYPTED(x) \
  52. (((x.medium_status) & TAPE390_MEDIUM_ENCRYPTED_MASK))
  53. #define TAPE390_MEDIUM_LOADED(x) \
  54. (((x.medium_status) & TAPE390_MEDIUM_LOADED_MASK))
  55. /*
  56. * The TAPE390_CRYPT_SET ioctl is used to switch on/off encryption.
  57. * The "encryption_capable" and "tape_status" fields are ignored for this ioctl!
  58. */
  59. #define TAPE390_CRYPT_SET _IOW('d', 2, struct tape390_crypt_info)
  60. /*
  61. * The TAPE390_CRYPT_QUERY ioctl is used to query the encryption state.
  62. */
  63. #define TAPE390_CRYPT_QUERY _IOR('d', 3, struct tape390_crypt_info)
  64. /* Values for "kekl1/2_type" and "kekl1/2_type_on_tape" fields */
  65. #define TAPE390_KEKL_TYPE_NONE 0
  66. #define TAPE390_KEKL_TYPE_LABEL 1
  67. #define TAPE390_KEKL_TYPE_HASH 2
  68. struct tape390_kekl {
  69. unsigned char type;
  70. unsigned char type_on_tape;
  71. char label[65];
  72. } __attribute__ ((packed));
  73. struct tape390_kekl_pair {
  74. struct tape390_kekl kekl[2];
  75. } __attribute__ ((packed));
  76. /*
  77. * The TAPE390_KEKL_SET ioctl is used to set Key Encrypting Key labels.
  78. */
  79. #define TAPE390_KEKL_SET _IOW('d', 4, struct tape390_kekl_pair)
  80. /*
  81. * The TAPE390_KEKL_QUERY ioctl is used to query Key Encrypting Key labels.
  82. */
  83. #define TAPE390_KEKL_QUERY _IOR('d', 5, struct tape390_kekl_pair)
  84. #endif