/** * * Perform a destructive 32-bit wide register IO test. Each location is tested * by sequentially writing a 32-bit wide regsiter, reading the register, and * comparing value. This function tests three kinds of register IO functions, * normal register IO, little-endian register IO, and big-endian register IO. * When testing little/big-endian IO, the function perform the following * sequence, Xil_Out32LE/Xil_Out32BE, Xil_In32, Compare, * Xil_Out32, Xil_In32LE/Xil_In32BE, Compare. Whether to swap the read-in value * before comparing is controlled by the 5th argument. * * @param Addr is a pointer to the region of memory to be tested. * @param Length is the Length of the block. * @param Value is the constant used for writting the memory. * @param Kind is the test kind. Acceptable values are: * XIL_TESTIO_DEFAULT, XIL_TESTIO_LE, XIL_TESTIO_BE. * @param Swap indicates whether to byte swap the read-in value. * * @return * * - -1 is returned for a failure * - 0 is returned for a pass * *****************************************************************************/ s32 Xil_TestIO32(u32 *Addr, s32 Length, u32 Value, s32 Kind, s32 Swap) { u32 *TempAddr; u32 ValueIn = 0U; s32 Index; TempAddr = Addr; Xil_AssertNonvoid(TempAddr != NULL); for (Index = 0; Index < Length; Index++) { switch (Kind) { case XIL_TESTIO_LE: Xil_Out32LE((INTPTR)TempAddr, Value); break; case XIL_TESTIO_BE: Xil_Out32BE((INTPTR)TempAddr, Value); break; default: Xil_Out32((INTPTR)TempAddr, Value); break; } ValueIn = Xil_In32((INTPTR)TempAddr); if ((Kind != 0) && (Swap != 0)) { ValueIn = Swap32(ValueIn); } if (Value != ValueIn) { return -1; } /* second round */ Xil_Out32((INTPTR)TempAddr, Value); switch (Kind) { case XIL_TESTIO_LE: ValueIn = Xil_In32LE((INTPTR)TempAddr); break; case XIL_TESTIO_BE: ValueIn = Xil_In32BE((INTPTR)TempAddr); break; default: ValueIn = Xil_In32((INTPTR)TempAddr); break; } if ((Kind != 0) && (Swap != 0)) { ValueIn = Swap32(ValueIn); } if (Value != ValueIn) { return -1; } TempAddr += sizeof(u32); } return 0; }
/** * * Perform a destructive 32-bit wide register IO test. Each location is tested * by sequentially writing a 32-bit wide regsiter, reading the register, and * comparing value. This function tests three kinds of register IO functions, * normal register IO, little-endian register IO, and big-endian register IO. * When testing little/big-endian IO, the function perform the following * sequence, Xil_Out32LE/Xil_Out32BE, Xil_In32, Compare, * Xil_Out32, Xil_In32LE/Xil_In32BE, Compare. Whether to swap the read-in value * before comparing is controlled by the 5th argument. * * @param Addr is a pointer to the region of memory to be tested. * @param Len is the length of the block. * @param Value is the constant used for writting the memory. * @param Kind is the test kind. Acceptable values are: * XIL_TESTIO_DEFAULT, XIL_TESTIO_LE, XIL_TESTIO_BE. * @param Swap indicates whether to byte swap the read-in value. * * @return * * - -1 is returned for a failure * - 0 is returned for a pass * *****************************************************************************/ int Xil_TestIO32(u32 *Addr, int Len, u32 Value, int Kind, int Swap) { u32 ValueIn; int Index; for (Index = 0; Index < Len; Index++) { switch (Kind) { case XIL_TESTIO_LE: Xil_Out32LE((u32)Addr, Value); break; case XIL_TESTIO_BE: Xil_Out32BE((u32)Addr, Value); break; default: Xil_Out32((u32)Addr, Value); break; } ValueIn = Xil_In32((u32)Addr); if (Kind && Swap) ValueIn = Swap32(ValueIn); if (Value != ValueIn) { return -1; } /* second round */ Xil_Out32((u32)Addr, Value); switch (Kind) { case XIL_TESTIO_LE: ValueIn = Xil_In32LE((u32)Addr); break; case XIL_TESTIO_BE: ValueIn = Xil_In32BE((u32)Addr); break; default: ValueIn = Xil_In32((u32)Addr); break; } if (Kind && Swap) ValueIn = Swap32(ValueIn); if (Value != ValueIn) { return -1; } Addr++; } return 0; }