Example #1
0
XStatus XIpiPsu_WriteMessage(XIpiPsu *InstancePtr, u32 TargetMask, u32 *MsgPtr,
		u32 MsgLength, u8 BufferType)
{
	u32 *BufferPtr;
	u32 Index;
	u32 Status;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(MsgPtr != NULL);
	Xil_AssertNonvoid(MsgLength <= XIPIPSU_MAX_MSG_LEN);

	BufferPtr = XIpiPsu_GetBufferAddress(InstancePtr,
			InstancePtr->Config.BitMask, TargetMask, BufferType);
	if (BufferPtr != NULL) {
		/* Copy the Message to IPI Buffer */
		for (Index = 0; Index < MsgLength; Index++) {
			BufferPtr[Index] = MsgPtr[Index];
		}
		Status = XST_SUCCESS;
	} else {
		Status = XST_FAILURE;
	}

	return Status;
}
XStatus XIpiPsu_ReadMessage(XIpiPsu *InstancePtr, u32 SrcCpuMask, u32 *MsgPtr,
		u32 MsgLength, u8 BufferType)
{
	u32 *BufferPtr;
	u32 Index;
	XStatus Status;

	Xil_AssertNonvoid(InstancePtr != NULL);
	Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
	Xil_AssertNonvoid(MsgPtr != NULL);
	Xil_AssertNonvoid(MsgLength <= XIPIPSU_MAX_MSG_LEN);

	BufferPtr = XIpiPsu_GetBufferAddress(InstancePtr, SrcCpuMask,
			InstancePtr->Config.BitMask, BufferType);
	if (BufferPtr != NULL) {
		/* Copy the IPI Buffer contents into Users's Buffer*/
		for (Index = 0U; Index < MsgLength; Index++) {
			MsgPtr[Index] = BufferPtr[Index];
		}
		Status = XST_SUCCESS;
	} else {
		Status = XST_FAILURE;
	}

	return Status;
}