The IEEE 1149.1-1990 specification provides an optional IDCODE instruction mode that permits blind interrogation of the devices in a JTAG chain.
Upon power-up, any device that supports IDCODE will automatically load the IDCODE instruction into the instruction register. Any device that does not support IDCODE will automatically load the BYPASS instruction into the instruction register.
After power-up, the blind interrogation is accomplished by shifting data from the data register. Any device that supports IDCODE will shift out the 32-bit ID value with a "1" in the least significant bit (LSB) and any device that does not will shift out a zero in the BYPASS register. To determine if a device supports IDCODE, simply check whether the first bit shifted out is a "1" or "0."
For additional information on JTAG support, refer to AN 39: IEEE 1149.1 (JTAG) Boundary-Scan Testing in Altera Devices (PDF).