2019-05-01 02:42:39 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2017-02-04 03:50:31 +08:00
|
|
|
/*
|
|
|
|
* Copyright © 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Rafael Antognolli <rafael.antognolli@intel.com>
|
|
|
|
* Scott Bauer <scott.bauer@intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LINUX_OPAL_H
|
|
|
|
#define LINUX_OPAL_H
|
|
|
|
|
|
|
|
#include <uapi/linux/sed-opal.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
|
|
|
struct opal_dev;
|
|
|
|
|
2017-02-17 20:59:39 +08:00
|
|
|
typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
|
|
|
|
size_t len, bool send);
|
2017-02-04 03:50:31 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_SED_OPAL
|
2017-02-23 01:15:06 +08:00
|
|
|
void free_opal_dev(struct opal_dev *dev);
|
2017-02-04 03:50:31 +08:00
|
|
|
bool opal_unlock_from_suspend(struct opal_dev *dev);
|
2017-02-17 20:59:39 +08:00
|
|
|
struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
|
2017-02-15 08:29:36 +08:00
|
|
|
int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
|
2017-02-04 03:50:31 +08:00
|
|
|
|
|
|
|
static inline bool is_sed_ioctl(unsigned int cmd)
|
|
|
|
{
|
|
|
|
switch (cmd) {
|
|
|
|
case IOC_OPAL_SAVE:
|
|
|
|
case IOC_OPAL_LOCK_UNLOCK:
|
|
|
|
case IOC_OPAL_TAKE_OWNERSHIP:
|
|
|
|
case IOC_OPAL_ACTIVATE_LSP:
|
|
|
|
case IOC_OPAL_SET_PW:
|
|
|
|
case IOC_OPAL_ACTIVATE_USR:
|
|
|
|
case IOC_OPAL_REVERT_TPR:
|
|
|
|
case IOC_OPAL_LR_SETUP:
|
|
|
|
case IOC_OPAL_ADD_USR_TO_LR:
|
|
|
|
case IOC_OPAL_ENABLE_DISABLE_MBR:
|
|
|
|
case IOC_OPAL_ERASE_LR:
|
|
|
|
case IOC_OPAL_SECURE_ERASE_LR:
|
2019-06-28 06:30:02 +08:00
|
|
|
case IOC_OPAL_PSID_REVERT_TPR:
|
2019-05-22 04:46:44 +08:00
|
|
|
case IOC_OPAL_MBR_DONE:
|
2019-05-22 04:46:45 +08:00
|
|
|
case IOC_OPAL_WRITE_SHADOW_MBR:
|
2019-11-01 00:13:21 +08:00
|
|
|
case IOC_OPAL_GENERIC_TABLE_RW:
|
2022-08-16 22:07:13 +08:00
|
|
|
case IOC_OPAL_GET_STATUS:
|
2017-02-04 03:50:31 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#else
|
2017-02-23 01:15:06 +08:00
|
|
|
static inline void free_opal_dev(struct opal_dev *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-04 03:50:31 +08:00
|
|
|
static inline bool is_sed_ioctl(unsigned int cmd)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
|
2017-02-15 08:29:36 +08:00
|
|
|
void __user *ioctl_ptr)
|
2017-02-04 03:50:31 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-02-17 20:59:39 +08:00
|
|
|
#define init_opal_dev(data, send_recv) NULL
|
2017-02-04 03:50:31 +08:00
|
|
|
#endif /* CONFIG_BLK_SED_OPAL */
|
|
|
|
#endif /* LINUX_OPAL_H */
|