sed-opal.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright © 2016 Intel Corporation
  4. *
  5. * Authors:
  6. * Rafael Antognolli <[email protected]>
  7. * Scott Bauer <[email protected]>
  8. */
  9. #ifndef LINUX_OPAL_H
  10. #define LINUX_OPAL_H
  11. #include <uapi/linux/sed-opal.h>
  12. #include <linux/kernel.h>
  13. struct opal_dev;
  14. typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
  15. size_t len, bool send);
  16. #ifdef CONFIG_BLK_SED_OPAL
  17. void free_opal_dev(struct opal_dev *dev);
  18. bool opal_unlock_from_suspend(struct opal_dev *dev);
  19. struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
  20. int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
  21. static inline bool is_sed_ioctl(unsigned int cmd)
  22. {
  23. switch (cmd) {
  24. case IOC_OPAL_SAVE:
  25. case IOC_OPAL_LOCK_UNLOCK:
  26. case IOC_OPAL_TAKE_OWNERSHIP:
  27. case IOC_OPAL_ACTIVATE_LSP:
  28. case IOC_OPAL_SET_PW:
  29. case IOC_OPAL_ACTIVATE_USR:
  30. case IOC_OPAL_REVERT_TPR:
  31. case IOC_OPAL_LR_SETUP:
  32. case IOC_OPAL_ADD_USR_TO_LR:
  33. case IOC_OPAL_ENABLE_DISABLE_MBR:
  34. case IOC_OPAL_ERASE_LR:
  35. case IOC_OPAL_SECURE_ERASE_LR:
  36. case IOC_OPAL_PSID_REVERT_TPR:
  37. case IOC_OPAL_MBR_DONE:
  38. case IOC_OPAL_WRITE_SHADOW_MBR:
  39. case IOC_OPAL_GENERIC_TABLE_RW:
  40. case IOC_OPAL_GET_STATUS:
  41. return true;
  42. }
  43. return false;
  44. }
  45. #else
  46. static inline void free_opal_dev(struct opal_dev *dev)
  47. {
  48. }
  49. static inline bool is_sed_ioctl(unsigned int cmd)
  50. {
  51. return false;
  52. }
  53. static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
  54. void __user *ioctl_ptr)
  55. {
  56. return 0;
  57. }
  58. static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
  59. {
  60. return false;
  61. }
  62. #define init_opal_dev(data, send_recv) NULL
  63. #endif /* CONFIG_BLK_SED_OPAL */
  64. #endif /* LINUX_OPAL_H */