#include #include #include #include #include int buffer[0X100600]; struct IOSB { unsigned short cond_value; short extra_word; unsigned int data; } pio_iosb,write_iosb,read_iosb; FILE file_ptr; static $DESCRIPTOR(pio_device_name, "QLA0:"); static $DESCRIPTOR(section_name, "PIO_MAP_SECTON"); int pio_channel_number; int i,j; int status; int iofunction_code; int vme_offset; int vme_address; int VME$M_16 = 0X00080000; int VME$M_24 = 0X000C0000; int VME$M_32 = 0; int VME$M_BYTE = 0X00010000; int VME$M_WORD = 0X00020000; int VME$M_LONG = 0X00030000; int byte_count; int word_count; int long_count; char byte_value = 0; short word_value = 0; int long_value = 0; char byte_received; short word_received; int long_received; int temp_value; int temp_received; int vme_pio_map_flags; int address_mode; char access_mode[2]; int loop, loop_request; int pca; int pca_value; int data_length; main() { status = SYS$ASSIGN(&pio_device_name, &pio_channel_number,0,0); if (status != SS$_NORMAL) { printf("ASSIGN to RSA0: failed. Error = %d\n", status); SYS$EXIT(status); } vme_pio_map_flags = 0; printf("Enter the VME byte count to transfer(1 - 1048576): "); scanf("%D", &byte_count); /* byte_count = 1048576; 1 meg 1048576; */ word_count = byte_count / 2; long_count = byte_count / 4; printf("Enter 1 to loop forever or 0 for one execution:"); scanf("%X", &loop_request); printf("Enter the VME start offest with the 1MB mapped: "); scanf("%X", &vme_offset); printf("Enter the VME address: "); scanf("%X", &vme_address); printf("Enter the Address Mode (16,24,32): "); scanf("%d", &address_mode); if (address_mode == 16) vme_pio_map_flags = vme_pio_map_flags + VME$M_16; if (address_mode == 24) vme_pio_map_flags = vme_pio_map_flags + VME$M_24; if (address_mode == 32) vme_pio_map_flags = vme_pio_map_flags + VME$M_32; printf("Enter the Access Mode (B,W,L): "); scanf("%s", &access_mode[0]); if ((access_mode[0] == 'B') || (access_mode[0] == 'b')) vme_pio_map_flags = vme_pio_map_flags + VME$M_BYTE; if ((access_mode[0] == 'W') || (access_mode[0] == 'w')) vme_pio_map_flags = vme_pio_map_flags + VME$M_WORD; if ((access_mode[0] == 'L') || (access_mode[0] == 'l')) vme_pio_map_flags = vme_pio_map_flags + VME$M_LONG; iofunction_code = IO$_WRITEPBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &pio_iosb, 0, 0, vme_address, byte_count, vme_pio_map_flags, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca = pio_iosb.data + vme_offset; loop = 1; while (loop == 1) { if (loop_request == 0) loop = 0; if ((access_mode[0] == 'B') || (access_mode[0] == 'b')) { pca_value = pca; data_length = 1; byte_value = 0; for (i = 0; i < byte_count; i++) { byte_value++; if (byte_value >= 256) byte_value = 0; iofunction_code = IO$_READLBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &write_iosb, 0, 0, pca_value, data_length, byte_value, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 1; } pca_value = pca; byte_value = 0; for (i = 0; i < byte_count; i++) { iofunction_code = IO$_WRITELBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &read_iosb, 0, 0, pca_value, data_length, byte_value, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 1; byte_received = read_iosb.data; byte_value++; if (byte_value >= 256) byte_value = 0; if (byte_received != byte_value) { temp_value = byte_value; printf("\nComparison error. Expected = %X. Received = %X.", temp_value, byte_received); goto pio_end; } } } } loop = 1; while (loop == 1) { if (loop_request == 0) loop = 0; if ((access_mode[0] == 'W') || (access_mode[0] == 'w')) { pca_value = pca; data_length = 2; word_value = 0; for (i = 0; i < word_count; i++) { word_value++; if (word_value >= 65536) word_value = 0; iofunction_code = IO$_READLBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &write_iosb, 0, 0, pca_value, data_length, word_value, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 2; } pca_value = pca; word_value = 0; for (i = 0; i < word_count; i++) { iofunction_code = IO$_WRITELBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &read_iosb, 0, 0, pca_value, data_length, word_value, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 2; word_received = read_iosb.data; word_value++; if (word_value >= 65536) word_value = 0; if (word_received != word_value) { temp_value = word_value; temp_received = word_received; printf("\nComparison error. Expected = %X. Received = %X.", temp_value, temp_received); goto pio_end; } } } } loop = 1; while (loop == 1) { if (loop_request == 0) loop = 0; if ((access_mode[0] == 'L') || (access_mode[0] == 'l')) { pca_value = pca; data_length = 4; for (i = 0; i < long_count; i++) { iofunction_code = IO$_READLBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &write_iosb, 0, 0, pca_value, data_length, i, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 4; } pca_value = pca; for (i = 0; i < long_count; i++) { iofunction_code = IO$_WRITELBLK; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &read_iosb, 0, 0, pca_value, data_length, i, 0,0,0); if (status != SS$_NORMAL) goto pio_end; pca_value = pca_value + 4; long_received = read_iosb.data; if (long_received != i) { temp_value = i; temp_received = long_received; printf("\nComparison error. Expected = %X. Received = %X.", temp_value, temp_received); } } } } pio_end: iofunction_code = IO$_DEACCESS; status = SYS$QIOW(0, pio_channel_number, iofunction_code, &pio_iosb, 0, 0, 0,0,0,0,0,0); printf("\nDEACCESS return value = %d.", status); SYS$DASSGN(pio_channel_number); }