tape390.h 2.8 KB

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