コード例 #1
0
ファイル: rpmb.c プロジェクト: cancro-dev/lk_candyboot
/* This API calls into TZ app to read device_info */
int read_device_info_rpmb(void *info, uint32_t sz)
{
	int ret = 0;
	struct send_cmd_req read_req = {0};
	struct send_cmd_rsp read_rsp = {0};

	read_req.cmd_id = KEYMASTER_READ_LK_DEVICE_STATE;
	read_req.data   = (uint32_t) info;
	read_req.len    = sz;

	read_rsp.cmd_id = CLIENT_CMD_READ_LK_DEVICE_STATE;

	/* Read the device info */
	arch_clean_invalidate_cache_range((addr_t) info, sz);
	ret = qseecom_send_command(get_secapp_handle(), (void*) &read_req, sizeof(read_req), (void*) &read_rsp, sizeof(read_rsp));
	arch_invalidate_cache_range((addr_t) info, sz);

	if (ret < 0 || read_rsp.status < 0)
	{
		dprintf(CRITICAL, "Reading device info failed: Error: %d\n", read_rsp.status);
		return read_rsp.status;
	}

	return 0;
}
コード例 #2
0
ファイル: qseecom_lk_test.c プロジェクト: KortanZ/linux
int qsc_run_get_version(char *appname, uint32_t iterations)
{
	struct qsc_send_cmd send_cmd;
	struct qsc_send_cmd_rsp msgrsp={0};	/* response data sent from QSEE */
	uint32_t i = 0, ret = 0, err = -1;

	dprintf(CRITICAL, "%s:Get_version\n", __func__);

	dprintf(CRITICAL, "(This may take a few minutes please wait....)\n");
	/* Start the application */
	for  (i = 0;  i < iterations;  i++) {
		dprintf(CRITICAL, "iteration %d\n", i);
		ret = qseecom_start_app(appname);
		if (ret <= 0) {
			dprintf(CRITICAL, "Start app: fail: ret:%d\n", ret);
			err = -1;
			goto err_ret;
		}
		dprintf(CRITICAL, "apphandle %u\n", ret);
		ret = qseecom_start_app(appname);
		if (ret <= 0) {
			dprintf(CRITICAL, "Start app: fail: ret:%d\n", ret);
			err = -1;
			goto err_ret_shutdown;
		}
		dprintf(CRITICAL, "apphandle %u\n", ret);
		send_cmd.cmd_id = CLIENT_CMD0_GET_VERSION;
		err = qseecom_send_command(ret, &send_cmd, sizeof(struct qsc_send_cmd), &msgrsp, sizeof(struct qsc_send_cmd_rsp));
		if (err) {
			dprintf(CRITICAL, "Send app: fail\n");
			goto err_ret_shutdown;
		}
		dprintf(ALWAYS, "The version of %s is: %u\n", appname, msgrsp.data);
		/* Shutdown the application */
		dprintf(ALWAYS, "Shutting down %s\n", appname);
		err = qseecom_shutdown_app(ret);
		if (err) {
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
			goto err_ret;
		}
		dprintf(ALWAYS, "Shutting down %s\n", appname);
		err = qseecom_shutdown_app(ret);
		if (err) {
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
			goto err_ret;
		}

    }
err_ret_shutdown:
	if (err) {
		if (qseecom_shutdown_app(ret))
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
	}
err_ret:
	if (err)
		dprintf(CRITICAL, "Test %u failed with error %d, shutting down %s\n", CLIENT_CMD0_GET_VERSION, err, appname);
	else
		dprintf(CRITICAL, "Test %u passed for iterations %u executing %s\n", CLIENT_CMD0_GET_VERSION, iterations, appname);
	return err;
}
コード例 #3
0
ファイル: qseecom_lk_test.c プロジェクト: KortanZ/linux
int qsc_run_start_stop_app_basic_test(char *appname, uint32_t iterations)
{
	uint32_t i = 0;
	int ret = 0;			/* return value */
	int err = 0;			/* return value */
	struct qsc_send_cmd send_cmd = {0};
	struct qsc_send_cmd_rsp msgrsp={0};	/* response data sent from QSEE */

	dprintf(CRITICAL, "%s:Basic_start_stop_test\n", __func__);

	dprintf(CRITICAL, "(This may take a few minutes please wait....)\n");
	/* Start the application */
    for  (i = 0;  i < iterations;  i++) {
		dprintf(CRITICAL, "iteration %d\n", i);
		ret = qseecom_start_app(appname);
		if (ret <= 0) {
			dprintf(CRITICAL, "Start app: fail: ret:%d\n", ret);
			err = -1;
			goto err_ret;
		}
		/* Send data using send command to QSEE application */
		send_cmd.cmd_id = CLIENT_CMD1_BASIC_DATA;
		send_cmd.start_pkt = 0;
		send_cmd.end_pkt = 0;
		send_cmd.test_buf_size = 0;
		send_cmd.data = 100;
		err = qseecom_send_command(ret, &send_cmd, sizeof(struct qsc_send_cmd), &msgrsp, sizeof(struct qsc_send_cmd_rsp));
		if (err) {
			dprintf(CRITICAL, "Send app: fail\n");
			goto err_ret_shutdown;
		}
		if (((msgrsp.data)/100) != 10) {
			dprintf(CRITICAL, "App Comm Error:%u\n", msgrsp.data);
			err = -1;
			goto err_ret_shutdown;
		}
		dprintf(CRITICAL, "msg.rsp:%u\n", msgrsp.data);
		/* Shutdown the application */
		err = qseecom_shutdown_app(ret);
		if (err) {
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
			goto err_ret;
		}
    }
err_ret_shutdown:
    if (err) {
		if (qseecom_shutdown_app(ret))
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
    }
err_ret:
	if (err)
		dprintf(CRITICAL, "Test %u failed with error %d, shutting down %s\n", CLIENT_CMD0_GET_VERSION, err, appname);
	else
		dprintf(CRITICAL, "Test %u passed for iterations %u executing %s\n", CLIENT_CMD0_GET_VERSION, iterations, appname);
		return err;
}
コード例 #4
0
ファイル: ssm.c プロジェクト: romanbb/android_kernel_lge_d851
int ssm_oem_driver_intf(int cmd, char *mode, int len)
{
	int rc, req_len, resp_len;
	struct tzapp_get_mode_info_req *get_mode_req;
	struct tzapp_get_mode_info_rsp *get_mode_resp;

	/*                                  */
	if (!ssm_drv)
		return -ENODEV;

	mutex_lock(&ssm_drv->mutex);

	if (ssm_drv->app_status == RETRY) {
		/*            */
		rc = ssm_load_app(ssm_drv);
		if (rc) {
			rc = -ENODEV;
			goto unlock;
		}
	} else if (ssm_drv->app_status == FAILED) {
		rc = -ENODEV;
		goto unlock;
	}

	/*                          */
	if (!ssm_drv->ready) {
		rc = smd_open(ssm_drv->channel_name, &ssm_drv->ch, ssm_drv,
							modem_request);
		if (rc) {
			rc = -EAGAIN;
			goto unlock;
		} else
			ssm_drv->ready = true;
	}

	/*                                           */
	if (!ssm_drv->key_status) {
		rc = -EAGAIN;
		goto unlock;
	}

	/*                              */
	rc = 0;

	switch (cmd) {
	case SSM_READY:
		break;

	case SSM_MODE_INFO_READY:
		ssm_drv->update_status = RETRY;
		/*                        */
		req_len = sizeof(struct tzapp_get_mode_info_req);
		resp_len = sizeof(struct tzapp_get_mode_info_rsp);
		setup_cmd_rsp_buffers(ssm_drv->qseecom_handle,
				(void **)&get_mode_req, &req_len,
				(void **)&get_mode_resp, &resp_len);
		get_mode_req->tzapp_ssm_cmd = GET_ENC_MODE;

		rc = qseecom_set_bandwidth(ssm_drv->qseecom_handle, 1);
		if (rc) {
			ssm_drv->update_status = FAILED;
			dev_err(ssm_drv->dev, "set bandwidth failed\n");
			rc = -EIO;
			break;
		}
		rc = qseecom_send_command(ssm_drv->qseecom_handle,
				(void *)get_mode_req, req_len,
				(void *)get_mode_resp, resp_len);
		if (rc || get_mode_resp->status) {
			ssm_drv->update_status = FAILED;
			break;
		}
		rc = qseecom_set_bandwidth(ssm_drv->qseecom_handle, 0);
		if (rc) {
			ssm_drv->update_status = FAILED;
			dev_err(ssm_drv->dev, "clear bandwidth failed\n");
			rc = -EIO;
			break;
		}

		if (get_mode_resp->enc_mode_len > ENC_MODE_MAX_SIZE) {
			ssm_drv->update_status = FAILED;
			rc = -EINVAL;
			break;
		}
		/*                         */
		rc = update_modem(SSM_ATOM_MODE_UPDATE, ssm_drv,
				get_mode_resp->enc_mode_len,
				get_mode_resp->enc_mode_info);
		if (rc)
			ssm_drv->update_status = FAILED;
		break;

	case SSM_SET_MODE:
		ssm_drv->update_status = RETRY;

		if (len > ENC_MODE_MAX_SIZE) {
			ssm_drv->update_status = FAILED;
			rc = -EINVAL;
			break;
		}
		memcpy(ssm_drv->resp->enc_mode_info, mode, len);
		ssm_drv->resp->enc_mode_len = len;

		/*                         */
		rc = update_modem(SSM_ATOM_MODE_UPDATE, ssm_drv,
				ssm_drv->resp->enc_mode_len,
				ssm_drv->resp->enc_mode_info);
		if (rc)
			ssm_drv->update_status = FAILED;
		break;

	case SSM_GET_MODE_STATUS:
		rc = ssm_drv->update_status;
		break;

	default:
		rc = -EINVAL;
		dev_err(ssm_drv->dev, "Invalid command\n");
		break;
	};

unlock:
	mutex_unlock(&ssm_drv->mutex);
	return rc;
}
コード例 #5
0
ファイル: qseecom_lk_test.c プロジェクト: KortanZ/linux
int qsc_run_start_stop_app_listener_test(char *appname, uint32_t iterations)
{
	uint32_t i = 0;
	int ret = 0;			/* return value */
	int err = 0;			/* return value */
	struct qsc_send_cmd send_cmd;
	struct qsc_send_cmd_rsp msgrsp={0};	/* response data sent from QSEE */

	dprintf(CRITICAL, "%s:qsc_run_start_stop_app_listener_test\n", __func__);

	dprintf(CRITICAL, "(This may take a few minutes please wait....)\n");

	ret = qseecom_register_listener(&listeners[0]);
	if (ret < 0) {
		dprintf(CRITICAL, "Reg Listener: fail: ret:%d\n", ret);
		err = -1;
		goto err_ret;
	}
	/* Start the application */
    for  (i = 0;  i < iterations;  i++) {
		dprintf(CRITICAL, "iteration %d\n", i);
		ret = qseecom_start_app(appname);
		if (ret <= 0) {
			dprintf(CRITICAL, "Start app: fail: ret:%d\n", ret);
			err = -1;
			goto err_dereg;
		}
		/* Send data using send command to QSEE application */
		send_cmd.cmd_id = CLIENT_APPSBL_QSEECOM_RUN_LISTENER_FRAMEWORK_TEST_1;
		send_cmd.start_pkt = 0;
		send_cmd.end_pkt = 0;
		send_cmd.test_buf_size = 0;
		send_cmd.data = 100;
		err = qseecom_send_command(ret, &send_cmd, sizeof(struct qsc_send_cmd), &msgrsp, sizeof(struct qsc_send_cmd_rsp));
		if (err) {
			dprintf(CRITICAL, "Send app: fail\n");
			goto err_ret_shutdown;
		}
		if (((msgrsp.data)/100) != 10) {
			dprintf(CRITICAL, "App Comm Error:%u Status:%d\n", msgrsp.data, msgrsp.status);
			err = -1;
			goto err_ret_shutdown;
		}
		/* Shutdown the application */
		err = qseecom_shutdown_app(ret);
		if (err) {
			dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
			goto err_dereg;
		}
    }

err_ret_shutdown:
	if (err) {
	   	if (qseecom_shutdown_app(ret))
	   		dprintf(CRITICAL, "Failed to shutdown app: %d\n",err);
	}
err_dereg:
	ret = qseecom_deregister_listener(listeners[0].id);
	if (ret < 0) {
		dprintf(CRITICAL, "DeReg Listener: fail: ret:%d\n", ret);
		err = -1;
	}
err_ret:
	if (err)
		dprintf(CRITICAL, "Test %u failed with error %d, shutting down %s\n", CLIENT_CMD0_GET_VERSION, err, appname);
	else
		dprintf(CRITICAL, "Test %u passed for iterations %u executing %s\n", CLIENT_CMD0_GET_VERSION, iterations, appname);
	return err;
}