drivers: misc: Add qseecom proxy module
qseecom proxy module serves kernel clients by providing required ops to smcinvoke and qseecom drivers via call back functions with a minimal framework. Change-Id: I1974329e4699f72cd1e41fb723acd72959e21ba2 Signed-off-by: Anmolpreet Kaur <quic_anmolpre@quicinc.com> Signed-off-by: Smita Ghosh <quic_smitag@quicinc.com>
This commit is contained in:
parent
0e41a7e344
commit
91fd24bcdd
@ -512,6 +512,14 @@ config VCPU_STALL_DETECTOR
|
||||
|
||||
If you do not intend to run this kernel as a guest, say N.
|
||||
|
||||
config QSEECOM_PROXY
|
||||
tristate "To enable qseecom proxy driver for kernel client"
|
||||
help
|
||||
qseecom proxy driver serves the kernel clients by providing
|
||||
required ops via call back functions with a minimal framework.
|
||||
These callback functions can be used to start, shutdown and
|
||||
send commands to the trusted apps.
|
||||
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
|
@ -62,3 +62,4 @@ obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o
|
||||
obj-$(CONFIG_OPEN_DICE) += open-dice.o
|
||||
obj-$(CONFIG_VCPU_STALL_DETECTOR) += vcpu_stall_detector.o
|
||||
obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o
|
||||
obj-$(CONFIG_QSEECOM_PROXY) += qseecom_proxy.o
|
||||
|
85
drivers/misc/qseecom_proxy.c
Normal file
85
drivers/misc/qseecom_proxy.c
Normal file
@ -0,0 +1,85 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/qseecom_kernel.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
|
||||
static struct qseecom_drv_ops qseecom_fun_ops = {0};
|
||||
|
||||
int provide_qseecom_kernel_fun_ops(const struct qseecom_drv_ops *ops)
|
||||
{
|
||||
if (!ops) {
|
||||
pr_err("ops is NULL\n");
|
||||
return -1;
|
||||
}
|
||||
qseecom_fun_ops = *ops;
|
||||
pr_debug("QSEECOM proxy Ready to be served\n");
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(provide_qseecom_kernel_fun_ops);
|
||||
|
||||
int qseecom_start_app(struct qseecom_handle **handle,
|
||||
char *app_name, uint32_t size)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
|
||||
/* start the application */
|
||||
if (qseecom_fun_ops.qseecom_start_app) {
|
||||
ret = qseecom_fun_ops.qseecom_start_app(handle, app_name, size);
|
||||
if (ret != 0)
|
||||
pr_err("%s: Start app -%s failed\n", __func__, app_name);
|
||||
} else {
|
||||
pr_err_ratelimited("Qseecom driver is not up yet\n");
|
||||
ret = -EAGAIN;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(qseecom_start_app);
|
||||
|
||||
|
||||
int qseecom_shutdown_app(struct qseecom_handle **handle)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
|
||||
/* shutdown the application */
|
||||
if (qseecom_fun_ops.qseecom_shutdown_app) {
|
||||
ret = qseecom_fun_ops.qseecom_shutdown_app(handle);
|
||||
if (ret != 0)
|
||||
pr_err("%s: qseecom shutdown app failed with ret = %d\n", __func__, ret);
|
||||
} else {
|
||||
pr_err_ratelimited("Qseecom driver is not up yet\n");
|
||||
ret = -EAGAIN;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(qseecom_shutdown_app);
|
||||
|
||||
|
||||
int qseecom_send_command(struct qseecom_handle *handle, void *send_buf,
|
||||
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
|
||||
/* send command to application*/
|
||||
if (qseecom_fun_ops.qseecom_send_command) {
|
||||
ret = qseecom_fun_ops.qseecom_send_command(handle, send_buf, sbuf_len,
|
||||
resp_buf, rbuf_len);
|
||||
if (ret != 0)
|
||||
pr_err("%s: qseecom send command failed with ret = %d\n", __func__, ret);
|
||||
} else {
|
||||
pr_err_ratelimited("Qseecom driver is not up yet\n");
|
||||
ret = -EAGAIN;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(qseecom_send_command);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Qseecom proxy driver");
|
50
include/linux/qseecom_kernel.h
Normal file
50
include/linux/qseecom_kernel.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __QSEECOM_KERNEL_H_
|
||||
#define __QSEECOM_KERNEL_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
|
||||
#define QSEECOM_ALIGN_SIZE 0x40
|
||||
#define QSEECOM_ALIGN_MASK (QSEECOM_ALIGN_SIZE - 1)
|
||||
#define QSEECOM_ALIGN(x) \
|
||||
((x + QSEECOM_ALIGN_MASK) & (~QSEECOM_ALIGN_MASK))
|
||||
|
||||
/*
|
||||
* struct qseecom_handle -
|
||||
* Handle to the qseecom device for kernel clients
|
||||
* @dev - qseecom_dev_handle
|
||||
* @sbuf - shared buffer pointer
|
||||
* @sbbuf_len - shared buffer size
|
||||
*/
|
||||
struct qseecom_handle {
|
||||
void *dev; /* in/out */
|
||||
unsigned char *sbuf; /* in/out */
|
||||
uint32_t sbuf_len; /* in/out */
|
||||
};
|
||||
|
||||
int qseecom_start_app(struct qseecom_handle **handle,
|
||||
char *app_name,
|
||||
uint32_t size);
|
||||
int qseecom_shutdown_app(struct qseecom_handle **handle);
|
||||
int qseecom_send_command(struct qseecom_handle *handle,
|
||||
void *send_buf, uint32_t sbuf_len,
|
||||
void *resp_buf, uint32_t rbuf_len);
|
||||
|
||||
#if IS_ENABLED(CONFIG_QSEECOM_PROXY)
|
||||
struct qseecom_drv_ops {
|
||||
int (*qseecom_send_command)(struct qseecom_handle *handle, void *send_buf,
|
||||
uint32_t sbuf_len, void *resp_buf, uint32_t rbuf_len);
|
||||
int (*qseecom_start_app)(struct qseecom_handle **handle,
|
||||
char *app_name, uint32_t size);
|
||||
int (*qseecom_shutdown_app)(struct qseecom_handle **handle);
|
||||
};
|
||||
|
||||
int provide_qseecom_kernel_fun_ops(const struct qseecom_drv_ops *ops);
|
||||
#endif
|
||||
|
||||
#endif /* __QSEECOM_KERNEL_H_ */
|
Loading…
Reference in New Issue
Block a user