logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

sed-opal.h (5343B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright © 2016 Intel Corporation
  4. *
  5. * Authors:
  6. * Rafael Antognolli <rafael.antognolli@intel.com>
  7. * Scott Bauer <scott.bauer@intel.com>
  8. */
  9. #ifndef _SED_OPAL_H
  10. #define _SED_OPAL_H
  11. #include <linux/types.h>
  12. #define OPAL_KEY_MAX 256
  13. #define OPAL_MAX_LRS 9
  14. enum opal_mbr {
  15. OPAL_MBR_ENABLE = 0x0,
  16. OPAL_MBR_DISABLE = 0x01,
  17. };
  18. enum opal_mbr_done_flag {
  19. OPAL_MBR_NOT_DONE = 0x0,
  20. OPAL_MBR_DONE = 0x01
  21. };
  22. enum opal_user {
  23. OPAL_ADMIN1 = 0x0,
  24. OPAL_USER1 = 0x01,
  25. OPAL_USER2 = 0x02,
  26. OPAL_USER3 = 0x03,
  27. OPAL_USER4 = 0x04,
  28. OPAL_USER5 = 0x05,
  29. OPAL_USER6 = 0x06,
  30. OPAL_USER7 = 0x07,
  31. OPAL_USER8 = 0x08,
  32. OPAL_USER9 = 0x09,
  33. };
  34. enum opal_lock_state {
  35. OPAL_RO = 0x01, /* 0001 */
  36. OPAL_RW = 0x02, /* 0010 */
  37. OPAL_LK = 0x04, /* 0100 */
  38. };
  39. enum opal_lock_flags {
  40. /* IOC_OPAL_SAVE will also store the provided key for locking */
  41. OPAL_SAVE_FOR_LOCK = 0x01,
  42. };
  43. enum opal_key_type {
  44. OPAL_INCLUDED = 0, /* key[] is the key */
  45. OPAL_KEYRING, /* key is in keyring */
  46. };
  47. struct opal_key {
  48. __u8 lr;
  49. __u8 key_len;
  50. __u8 key_type;
  51. __u8 __align[5];
  52. __u8 key[OPAL_KEY_MAX];
  53. };
  54. enum opal_revert_lsp_opts {
  55. OPAL_PRESERVE = 0x01,
  56. };
  57. struct opal_lr_act {
  58. struct opal_key key;
  59. __u32 sum;
  60. __u8 num_lrs;
  61. __u8 lr[OPAL_MAX_LRS];
  62. __u8 align[2]; /* Align to 8 byte boundary */
  63. };
  64. struct opal_session_info {
  65. __u32 sum;
  66. __u32 who;
  67. struct opal_key opal_key;
  68. };
  69. struct opal_user_lr_setup {
  70. __u64 range_start;
  71. __u64 range_length;
  72. __u32 RLE; /* Read Lock enabled */
  73. __u32 WLE; /* Write Lock Enabled */
  74. struct opal_session_info session;
  75. };
  76. struct opal_lr_status {
  77. struct opal_session_info session;
  78. __u64 range_start;
  79. __u64 range_length;
  80. __u32 RLE; /* Read Lock enabled */
  81. __u32 WLE; /* Write Lock Enabled */
  82. __u32 l_state;
  83. __u8 align[4];
  84. };
  85. struct opal_lock_unlock {
  86. struct opal_session_info session;
  87. __u32 l_state;
  88. __u16 flags;
  89. __u8 __align[2];
  90. };
  91. struct opal_new_pw {
  92. struct opal_session_info session;
  93. /* When we're not operating in sum, and we first set
  94. * passwords we need to set them via ADMIN authority.
  95. * After passwords are changed, we can set them via,
  96. * User authorities.
  97. * Because of this restriction we need to know about
  98. * Two different users. One in 'session' which we will use
  99. * to start the session and new_userr_pw as the user we're
  100. * chaning the pw for.
  101. */
  102. struct opal_session_info new_user_pw;
  103. };
  104. struct opal_mbr_data {
  105. struct opal_key key;
  106. __u8 enable_disable;
  107. __u8 __align[7];
  108. };
  109. struct opal_mbr_done {
  110. struct opal_key key;
  111. __u8 done_flag;
  112. __u8 __align[7];
  113. };
  114. struct opal_shadow_mbr {
  115. struct opal_key key;
  116. const __u64 data;
  117. __u64 offset;
  118. __u64 size;
  119. };
  120. /* Opal table operations */
  121. enum opal_table_ops {
  122. OPAL_READ_TABLE,
  123. OPAL_WRITE_TABLE,
  124. };
  125. #define OPAL_UID_LENGTH 8
  126. struct opal_read_write_table {
  127. struct opal_key key;
  128. const __u64 data;
  129. const __u8 table_uid[OPAL_UID_LENGTH];
  130. __u64 offset;
  131. __u64 size;
  132. #define OPAL_TABLE_READ (1 << OPAL_READ_TABLE)
  133. #define OPAL_TABLE_WRITE (1 << OPAL_WRITE_TABLE)
  134. __u64 flags;
  135. __u64 priv;
  136. };
  137. #define OPAL_FL_SUPPORTED 0x00000001
  138. #define OPAL_FL_LOCKING_SUPPORTED 0x00000002
  139. #define OPAL_FL_LOCKING_ENABLED 0x00000004
  140. #define OPAL_FL_LOCKED 0x00000008
  141. #define OPAL_FL_MBR_ENABLED 0x00000010
  142. #define OPAL_FL_MBR_DONE 0x00000020
  143. #define OPAL_FL_SUM_SUPPORTED 0x00000040
  144. struct opal_status {
  145. __u32 flags;
  146. __u32 reserved;
  147. };
  148. /*
  149. * Geometry Reporting per TCG Storage OPAL SSC
  150. * section 3.1.1.4
  151. */
  152. struct opal_geometry {
  153. __u8 align;
  154. __u32 logical_block_size;
  155. __u64 alignment_granularity;
  156. __u64 lowest_aligned_lba;
  157. __u8 __align[3];
  158. };
  159. struct opal_discovery {
  160. __u64 data;
  161. __u64 size;
  162. };
  163. struct opal_revert_lsp {
  164. struct opal_key key;
  165. __u32 options;
  166. __u32 __pad;
  167. };
  168. #define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
  169. #define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
  170. #define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
  171. #define IOC_OPAL_ACTIVATE_LSP _IOW('p', 223, struct opal_lr_act)
  172. #define IOC_OPAL_SET_PW _IOW('p', 224, struct opal_new_pw)
  173. #define IOC_OPAL_ACTIVATE_USR _IOW('p', 225, struct opal_session_info)
  174. #define IOC_OPAL_REVERT_TPR _IOW('p', 226, struct opal_key)
  175. #define IOC_OPAL_LR_SETUP _IOW('p', 227, struct opal_user_lr_setup)
  176. #define IOC_OPAL_ADD_USR_TO_LR _IOW('p', 228, struct opal_lock_unlock)
  177. #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data)
  178. #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info)
  179. #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info)
  180. #define IOC_OPAL_PSID_REVERT_TPR _IOW('p', 232, struct opal_key)
  181. #define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done)
  182. #define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr)
  183. #define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table)
  184. #define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
  185. #define IOC_OPAL_GET_LR_STATUS _IOW('p', 237, struct opal_lr_status)
  186. #define IOC_OPAL_GET_GEOMETRY _IOR('p', 238, struct opal_geometry)
  187. #define IOC_OPAL_DISCOVERY _IOW('p', 239, struct opal_discovery)
  188. #define IOC_OPAL_REVERT_LSP _IOW('p', 240, struct opal_revert_lsp)
  189. #endif /* _SED_OPAL_H */