XilinxProcessorIPLib/drivers/prc/src/xprc.c
u32 XPrc_GetRegisterAddress(XPrc *InstancePtr, u32 VsmId,
			u8 RegisterType, u16 TableRow)
{
	/* XPRC_VSM_GENERAL_REG_BANK, XPRC_VSM_TRIGGER_REG_BANK,
	 * XPRC_VSM_RM_REG_BANK, XPRC_VSM_BS_REG_BANK
	 */
	u8 BankId;
	u8 TableInBank;

	switch (RegisterType) {
		/* The bank the reg is in; The table within the bank */
		case XPRC_STATUS_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_STATUS_REG_TABLE_ID;
			break;
		case XPRC_CONTROL_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_CONTROL_REG_TABLE_ID;
			break;
		case XPRC_SW_TRIGGER_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_SW_TRIGGER_REG_TABLE_ID;
			break;
		case XPRC_TRIGGER_REG:
			BankId = XPRC_VSM_TRIGGER_REG_BANK;
			TableInBank = XPRC_TRIGGER_REG_TABLE_ID;
			break;
		case XPRC_RM_BS_INDEX_REG:
			BankId = XPRC_VSM_RM_REG_BANK;
			TableInBank = XPRC_RM_BS_INDEX_REG_TABLE_ID;
			break;
		case XPRC_RM_CONTROL_REG:
			BankId = XPRC_VSM_RM_REG_BANK;
			TableInBank = XPRC_RM_CONTROL_REG_TABLE_ID;
			break;
		case XPRC_BS_ID_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_ID_REG_TABLE_ID;
			break;
		case XPRC_BS_ADDRESS_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_ADDRESS_REG_TABLE_ID;
			break;
		case XPRC_BS_SIZE_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_SIZE_REG_TABLE_ID;
			break;
		default:
			BankId = XPRC_DEFAULT_BANKID;
			TableInBank = XPRC_DEFAULT_TABLEID;
			break;
	}

	return (InstancePtr->Config.BaseAddress) + XPrc_GetRegisterOffset(
			InstancePtr, VsmId, BankId, TableInBank, TableRow);
}
/*****************************************************************************/
/**
*
* The register offsets for the PRC are dynamic. These could become awkward to
* use as each Trigger, VS, RM and BS require their own registers so looking up
* hard wired names would be clumsy.  For example a reference to a constant
* PRC_VS3_TRIGGER7 would be difficult to generate in a loop that iterated
* over each VS and Trigger.
*
* This function gets the address offset for a register in the PRC.
* As this is a Direct Hardware Interface, it cannot use device configuration
* parameters, and multiple instances are supported through the base address.
*
* @param	InstancePtr is a pointer to the PRC instance.
* @param	VsmId is the identifier of the VSM to access.
* @param	RegisterType is the type of register(XPRC_STATUS_REG,
*		XPRC_CONTROL_REG, XPRC_SW_TRIGGER_REG, XPRC_TRIGGER_REG, etc)
* @param	TableRow is the row of the table(trigger_id, rm_id,
*		rm_bs_index).
*
* @return	Address of the register.
*
* @note		None
*
******************************************************************************/
The register offsets for the PRC are dynamic. These could become awkward to
use as each Trigger, VS, RM and BS require their own registers so looking up
hard wired names would be clumsy.  For example a reference to a constant
PRC_VS3_TRIGGER7 would be difficult to generate in a loop that iterated
over each VS and Trigger.

This function gets the address offset for a register in the PRC.
As this is a Direct Hardware Interface, it cannot use device configuration
parameters, and multiple instances are supported through the base address.
The register offsets for the PRC are dynamic . These could become awkward to use as each Trigger VS RM and BS require their own registers so looking up hard wired names would be clumsy . For example a reference to a constant PRC_VS3_TRIGGER7 would be difficult to generate in a loop that iterated over each VS and Trigger . This function gets the address offset for a register in the PRC . As this is a Direct Hardware Interface it cannot use device configuration parameters and multiple instances are supported through the base address .
u32 XPrc_GetRegisterAddress(XPrc *InstancePtr, u32 VsmId,
			u8 RegisterType, u16 TableRow)
{
	u8 BankId;
	u8 TableInBank;
	switch (RegisterType) {
		case XPRC_STATUS_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_STATUS_REG_TABLE_ID;
			break;
		case XPRC_CONTROL_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_CONTROL_REG_TABLE_ID;
			break;
		case XPRC_SW_TRIGGER_REG:
			BankId = XPRC_VSM_GENERAL_REG_BANK;
			TableInBank = XPRC_SW_TRIGGER_REG_TABLE_ID;
			break;
		case XPRC_TRIGGER_REG:
			BankId = XPRC_VSM_TRIGGER_REG_BANK;
			TableInBank = XPRC_TRIGGER_REG_TABLE_ID;
			break;
		case XPRC_RM_BS_INDEX_REG:
			BankId = XPRC_VSM_RM_REG_BANK;
			TableInBank = XPRC_RM_BS_INDEX_REG_TABLE_ID;
			break;
		case XPRC_RM_CONTROL_REG:
			BankId = XPRC_VSM_RM_REG_BANK;
			TableInBank = XPRC_RM_CONTROL_REG_TABLE_ID;
			break;
		case XPRC_BS_ID_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_ID_REG_TABLE_ID;
			break;
		case XPRC_BS_ADDRESS_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_ADDRESS_REG_TABLE_ID;
			break;
		case XPRC_BS_SIZE_REG:
			BankId = XPRC_VSM_BS_REG_BANK;
			TableInBank = XPRC_BS_SIZE_REG_TABLE_ID;
			break;
		default:
			BankId = XPRC_DEFAULT_BANKID;
			TableInBank = XPRC_DEFAULT_TABLEID;
			break;
	}
	return (InstancePtr->Config.BaseAddress) + XPrc_GetRegisterOffset(
			InstancePtr, VsmId, BankId, TableInBank, TableRow);
}
u32 XPrc_GetRegisterAddress ( XPrc * InstancePtr , u32 VsmId , u8 RegisterType , u16 TableRow ) { u8 BankId ; u8 TableInBank ; switch ( RegisterType ) { case XPRC_STATUS_REG : BankId = XPRC_VSM_GENERAL_REG_BANK ; TableInBank = XPRC_STATUS_REG_TABLE_ID ; break ; case XPRC_CONTROL_REG : BankId = XPRC_VSM_GENERAL_REG_BANK ; TableInBank = XPRC_CONTROL_REG_TABLE_ID ; break ; case XPRC_SW_TRIGGER_REG : BankId = XPRC_VSM_GENERAL_REG_BANK ; TableInBank = XPRC_SW_TRIGGER_REG_TABLE_ID ; break ; case XPRC_TRIGGER_REG : BankId = XPRC_VSM_TRIGGER_REG_BANK ; TableInBank = XPRC_TRIGGER_REG_TABLE_ID ; break ; case XPRC_RM_BS_INDEX_REG : BankId = XPRC_VSM_RM_REG_BANK ; TableInBank = XPRC_RM_BS_INDEX_REG_TABLE_ID ; break ; case XPRC_RM_CONTROL_REG : BankId = XPRC_VSM_RM_REG_BANK ; TableInBank = XPRC_RM_CONTROL_REG_TABLE_ID ; break ; case XPRC_BS_ID_REG : BankId = XPRC_VSM_BS_REG_BANK ; TableInBank = XPRC_BS_ID_REG_TABLE_ID ; break ; case XPRC_BS_ADDRESS_REG : BankId = XPRC_VSM_BS_REG_BANK ; TableInBank = XPRC_BS_ADDRESS_REG_TABLE_ID ; break ; case XPRC_BS_SIZE_REG : BankId = XPRC_VSM_BS_REG_BANK ; TableInBank = XPRC_BS_SIZE_REG_TABLE_ID ; break ; default : BankId = XPRC_DEFAULT_BANKID ; TableInBank = XPRC_DEFAULT_TABLEID ; break ; } return ( InstancePtr -> Config . BaseAddress ) + XPrc_GetRegisterOffset ( InstancePtr , VsmId , BankId , TableInBank , TableRow ) ; }
The register offsets for the PRC are dynamic.
The register offsets for the PRC are dynamic .
/* XPRC_VSM_GENERAL_REG_BANK, XPRC_VSM_TRIGGER_REG_BANK,
	 * XPRC_VSM_RM_REG_BANK, XPRC_VSM_BS_REG_BANK
	 */ /* The bank the reg is in; The table within the bank */