Commit e8ffe79d authored by Wendy Liang's avatar Wendy Liang
Browse files

Add Xilinx ZynqMP IPI mailbox service



Add IPI mailbox service to manage Xilinx ZynqMP IPI(Inter Processors
Interrupt) access.
Signed-off-by: default avatarWendy Liang <jliang@xilinx.com>
parent dc1dfe83
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* Top-level SMC handler for ZynqMP IPI Mailbox doorbell functions.
*/
#include <bakery_lock.h>
#include <debug.h>
#include <errno.h>
#include <mmio.h>
#include <runtime_svc.h>
#include <string.h>
#include "ipi_mailbox_svc.h"
#include "../zynqmp_ipi.h"
#include "../zynqmp_private.h"
#include "../../../services/spd/trusty/smcall.h"
/*********************************************************************
* Macros definitions
********************************************************************/
/* IPI SMC calls macros: */
#define IPI_SMC_OPEN_IRQ_MASK 0x00000001U /* IRQ enable bit in IPI
* open SMC call
*/
#define IPI_SMC_NOTIFY_BLOCK_MASK 0x00000001U /* Flag to indicate if
* IPI notification needs
* to be blocking.
*/
#define IPI_SMC_ENQUIRY_DIRQ_MASK 0x00000001U /* Flag to indicate if
* notification interrupt
* to be disabled.
*/
#define IPI_SMC_ACK_EIRQ_MASK 0x00000001U /* Flag to indicate if
* notification interrupt
* to be enable.
*/
#define UNSIGNED32_MASK 0xFFFFFFFFU /* 32bit mask */
/**
* ipi_smc_handler() - SMC handler for IPI SMC calls
*
* @smc_fid - Function identifier
* @x1 - x4 - Arguments
* @cookie - Unused
* @handler - Pointer to caller's context structure
*
* @return - Unused
*
* Determines that smc_fid is valid and supported PM SMC Function ID from the
* list of pm_api_ids, otherwise completes the request with
* the unknown SMC Function ID
*
* The SMC calls for PM service are forwarded from SIP Service SMC handler
* function with rt_svc_handle signature
*/
uint64_t ipi_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
uint64_t x3, uint64_t x4, void *cookie,
void *handle, uint64_t flags)
{
int ret;
uint32_t ipi_local_id;
uint32_t ipi_remote_id;
unsigned int is_secure;
ipi_local_id = x1 & UNSIGNED32_MASK;
ipi_remote_id = x2 & UNSIGNED32_MASK;
if (SMC_ENTITY(smc_fid) >= SMC_ENTITY_TRUSTED_APP)
is_secure = 1;
else
is_secure = 0;
/* Validate IPI mailbox access */
ret = ipi_mb_validate(ipi_local_id, ipi_remote_id, is_secure);
if (ret)
SMC_RET1(handle, ret);
switch (SMC_FUNCTION(smc_fid)) {
case IPI_MAILBOX_OPEN:
ipi_mb_open(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, 0);
case IPI_MAILBOX_RELEASE:
ipi_mb_release(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, 0);
case IPI_MAILBOX_STATUS_ENQUIRY:
{
int disable_irq;
disable_irq = (x3 & IPI_SMC_ENQUIRY_DIRQ_MASK) ? 1 : 0;
ret = ipi_mb_enquire_status(ipi_local_id, ipi_remote_id);
if ((ret & IPI_MB_STATUS_RECV_PENDING) && disable_irq)
ipi_mb_disable_irq(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, ret);
}
case IPI_MAILBOX_NOTIFY:
{
uint32_t is_blocking;
is_blocking = (x3 & IPI_SMC_NOTIFY_BLOCK_MASK) ? 1 : 0;
ipi_mb_notify(ipi_local_id, ipi_remote_id, is_blocking);
SMC_RET1(handle, 0);
}
case IPI_MAILBOX_ACK:
{
int enable_irq;
enable_irq = (x3 & IPI_SMC_ACK_EIRQ_MASK) ? 1 : 0;
ipi_mb_ack(ipi_local_id, ipi_remote_id);
if (enable_irq)
ipi_mb_enable_irq(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, 0);
}
case IPI_MAILBOX_ENABLE_IRQ:
ipi_mb_enable_irq(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, 0);
case IPI_MAILBOX_DISABLE_IRQ:
ipi_mb_disable_irq(ipi_local_id, ipi_remote_id);
SMC_RET1(handle, 0);
default:
WARN("Unimplemented IPI service call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
}
}
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/* ZynqMP IPI mailbox doorbell service enums and defines */
#ifndef _IPI_MAILBOX_SVC_H_
#define _IPI_MAILBOX_SVC_H_
#include <stdint.h>
/*********************************************************************
* Enum definitions
********************************************************************/
/* IPI SMC function numbers enum definition */
enum ipi_api_id {
/* IPI mailbox operations functions: */
IPI_MAILBOX_OPEN = 0x1000,
IPI_MAILBOX_RELEASE,
IPI_MAILBOX_STATUS_ENQUIRY,
IPI_MAILBOX_NOTIFY,
IPI_MAILBOX_ACK,
IPI_MAILBOX_ENABLE_IRQ,
IPI_MAILBOX_DISABLE_IRQ
};
/*********************************************************************
* IPI mailbox service APIs declarations
********************************************************************/
/* IPI SMC handler */
uint64_t ipi_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2,
uint64_t x3, uint64_t x4, void *cookie, void *handle,
uint64_t flags);
#endif /* _IPI_MAILBOX_SVC_H_ */
...@@ -42,7 +42,8 @@ $(eval $(call add_define_val,ZYNQMP_CONSOLE,ZYNQMP_CONSOLE_ID_${ZYNQMP_CONSOLE}) ...@@ -42,7 +42,8 @@ $(eval $(call add_define_val,ZYNQMP_CONSOLE,ZYNQMP_CONSOLE_ID_${ZYNQMP_CONSOLE})
PLAT_INCLUDES := -Iinclude/plat/arm/common/ \ PLAT_INCLUDES := -Iinclude/plat/arm/common/ \
-Iinclude/plat/arm/common/aarch64/ \ -Iinclude/plat/arm/common/aarch64/ \
-Iplat/xilinx/zynqmp/include/ \ -Iplat/xilinx/zynqmp/include/ \
-Iplat/xilinx/zynqmp/pm_service/ -Iplat/xilinx/zynqmp/pm_service/ \
-Iplat/xilinx/zynqmp/ipi_mailbox_service/
PLAT_BL_COMMON_SOURCES := lib/xlat_tables/xlat_tables_common.c \ PLAT_BL_COMMON_SOURCES := lib/xlat_tables/xlat_tables_common.c \
lib/xlat_tables/aarch64/xlat_tables.c \ lib/xlat_tables/aarch64/xlat_tables.c \
...@@ -75,4 +76,5 @@ BL31_SOURCES += drivers/arm/cci/cci.c \ ...@@ -75,4 +76,5 @@ BL31_SOURCES += drivers/arm/cci/cci.c \
plat/xilinx/zynqmp/pm_service/pm_svc_main.c \ plat/xilinx/zynqmp/pm_service/pm_svc_main.c \
plat/xilinx/zynqmp/pm_service/pm_api_sys.c \ plat/xilinx/zynqmp/pm_service/pm_api_sys.c \
plat/xilinx/zynqmp/pm_service/pm_ipi.c \ plat/xilinx/zynqmp/pm_service/pm_ipi.c \
plat/xilinx/zynqmp/pm_service/pm_client.c plat/xilinx/zynqmp/pm_service/pm_client.c \
plat/xilinx/zynqmp/ipi_mailbox_service/ipi_mailbox_svc.c
/* /*
* Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
#include <runtime_svc.h> #include <runtime_svc.h>
#include <uuid.h> #include <uuid.h>
#include "ipi_mailbox_svc.h"
#include "pm_svc_main.h" #include "pm_svc_main.h"
#include "zynqmp_ipi.h"
/* SMC function IDs for SiP Service queries */ /* SMC function IDs for SiP Service queries */
#define ZYNQMP_SIP_SVC_CALL_COUNT 0x8200ff00 #define ZYNQMP_SIP_SVC_CALL_COUNT 0x8200ff00
...@@ -19,10 +21,12 @@ ...@@ -19,10 +21,12 @@
#define SIP_SVC_VERSION_MAJOR 0 #define SIP_SVC_VERSION_MAJOR 0
#define SIP_SVC_VERSION_MINOR 1 #define SIP_SVC_VERSION_MINOR 1
/* These macros are used to identify PM calls from the SMC function ID */ /* These macros are used to identify PM, IPI calls from the SMC function ID */
#define PM_FID_MASK 0xf000u #define PM_FID_MASK 0xf000u
#define PM_FID_VALUE 0u #define PM_FID_VALUE 0u
#define IPI_FID_VALUE 0x1000u
#define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE) #define is_pm_fid(_fid) (((_fid) & PM_FID_MASK) == PM_FID_VALUE)
#define is_ipi_fid(_fid) (((_fid) & PM_FID_MASK) == IPI_FID_VALUE)
/* SiP Service UUID */ /* SiP Service UUID */
DEFINE_SVC_UUID(zynqmp_sip_uuid, DEFINE_SVC_UUID(zynqmp_sip_uuid,
...@@ -63,6 +67,12 @@ uint64_t sip_svc_smc_handler(uint32_t smc_fid, ...@@ -63,6 +67,12 @@ uint64_t sip_svc_smc_handler(uint32_t smc_fid,
flags); flags);
} }
/* Let IPI SMC handler deal with IPI-related requests */
if (is_ipi_fid(smc_fid)) {
return ipi_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle,
flags);
}
switch (smc_fid) { switch (smc_fid) {
case ZYNQMP_SIP_SVC_CALL_COUNT: case ZYNQMP_SIP_SVC_CALL_COUNT:
/* PM functions + default functions */ /* PM functions + default functions */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment