sed-opal.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright © 2016 Intel Corporation
  3. *
  4. * Authors:
  5. * Rafael Antognolli <rafael.antognolli@intel.com>
  6. * Scott Bauer <scott.bauer@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. */
  17. #ifndef LINUX_OPAL_H
  18. #define LINUX_OPAL_H
  19. #include <uapi/linux/sed-opal.h>
  20. #include <linux/kernel.h>
  21. struct opal_dev;
  22. typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
  23. size_t len, bool send);
  24. #ifdef CONFIG_BLK_SED_OPAL
  25. void free_opal_dev(struct opal_dev *dev);
  26. bool opal_unlock_from_suspend(struct opal_dev *dev);
  27. struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
  28. int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
  29. static inline bool is_sed_ioctl(unsigned int cmd)
  30. {
  31. switch (cmd) {
  32. case IOC_OPAL_SAVE:
  33. case IOC_OPAL_LOCK_UNLOCK:
  34. case IOC_OPAL_TAKE_OWNERSHIP:
  35. case IOC_OPAL_ACTIVATE_LSP:
  36. case IOC_OPAL_SET_PW:
  37. case IOC_OPAL_ACTIVATE_USR:
  38. case IOC_OPAL_REVERT_TPR:
  39. case IOC_OPAL_LR_SETUP:
  40. case IOC_OPAL_ADD_USR_TO_LR:
  41. case IOC_OPAL_ENABLE_DISABLE_MBR:
  42. case IOC_OPAL_ERASE_LR:
  43. case IOC_OPAL_SECURE_ERASE_LR:
  44. return true;
  45. }
  46. return false;
  47. }
  48. #else
  49. static inline void free_opal_dev(struct opal_dev *dev)
  50. {
  51. }
  52. static inline bool is_sed_ioctl(unsigned int cmd)
  53. {
  54. return false;
  55. }
  56. static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
  57. void __user *ioctl_ptr)
  58. {
  59. return 0;
  60. }
  61. static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
  62. {
  63. return false;
  64. }
  65. #define init_opal_dev(data, send_recv) NULL
  66. #endif /* CONFIG_BLK_SED_OPAL */
  67. #endif /* LINUX_OPAL_H */