Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright © 2016 Intel Corporation
0004  *
0005  * Authors:
0006  *    Rafael Antognolli <rafael.antognolli@intel.com>
0007  *    Scott  Bauer      <scott.bauer@intel.com>
0008  */
0009 
0010 #ifndef LINUX_OPAL_H
0011 #define LINUX_OPAL_H
0012 
0013 #include <uapi/linux/sed-opal.h>
0014 #include <linux/kernel.h>
0015 
0016 struct opal_dev;
0017 
0018 typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
0019         size_t len, bool send);
0020 
0021 #ifdef CONFIG_BLK_SED_OPAL
0022 void free_opal_dev(struct opal_dev *dev);
0023 bool opal_unlock_from_suspend(struct opal_dev *dev);
0024 struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
0025 int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
0026 
0027 static inline bool is_sed_ioctl(unsigned int cmd)
0028 {
0029     switch (cmd) {
0030     case IOC_OPAL_SAVE:
0031     case IOC_OPAL_LOCK_UNLOCK:
0032     case IOC_OPAL_TAKE_OWNERSHIP:
0033     case IOC_OPAL_ACTIVATE_LSP:
0034     case IOC_OPAL_SET_PW:
0035     case IOC_OPAL_ACTIVATE_USR:
0036     case IOC_OPAL_REVERT_TPR:
0037     case IOC_OPAL_LR_SETUP:
0038     case IOC_OPAL_ADD_USR_TO_LR:
0039     case IOC_OPAL_ENABLE_DISABLE_MBR:
0040     case IOC_OPAL_ERASE_LR:
0041     case IOC_OPAL_SECURE_ERASE_LR:
0042     case IOC_OPAL_PSID_REVERT_TPR:
0043     case IOC_OPAL_MBR_DONE:
0044     case IOC_OPAL_WRITE_SHADOW_MBR:
0045     case IOC_OPAL_GENERIC_TABLE_RW:
0046         return true;
0047     }
0048     return false;
0049 }
0050 #else
0051 static inline void free_opal_dev(struct opal_dev *dev)
0052 {
0053 }
0054 
0055 static inline bool is_sed_ioctl(unsigned int cmd)
0056 {
0057     return false;
0058 }
0059 
0060 static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
0061                 void __user *ioctl_ptr)
0062 {
0063     return 0;
0064 }
0065 static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
0066 {
0067     return false;
0068 }
0069 #define init_opal_dev(data, send_recv)      NULL
0070 #endif /* CONFIG_BLK_SED_OPAL */
0071 #endif /* LINUX_OPAL_H */