#include #include #include #include #include int buffer[0X100600]; struct IOSB { unsigned short cond_value; short extra_word; unsigned int PFN; } pio_iosb; FILE file_ptr; static $DESCRIPTOR(pio_device_name, "RSA0:"); static $DESCRIPTOR(section_name, "PIO_MAP_SECTON"); int pio_channel_number; int i,j; int status; int iofunction_code; int vme_offset; int page_align; char *byte_ptr; short *word_ptr; int *long_ptr; int *saved_ptr; int vme_address; int physical_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 inadr[2]; int retadr[2]; int section_flags; int page_count; int loop, loop_request; int vbn; 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; page_align = &buffer[0]; page_align = page_align + 512; byte_ptr = page_align & 0XFFFFFE00; inadr[0] = byte_ptr; inadr[1] = byte_ptr + byte_count + vme_offset; section_flags = SEC$M_WRT + SEC$M_PFNMAP; page_count = (byte_count + vme_offset + 511)/512; vbn = pio_iosb.PFN; status = SYS$CRMPSC( &inadr[0], &retadr[0], 0, /* Access mode par */ section_flags, §ion_name, 0, /* Ident par */ 0, /* Relative page #. Not used for PFN mapping */ 0, /* Channel #. Not used for PFN mapping */ page_count, vbn, 0, /* protection par */ 0); /* Page fault par. Not used for PFN mapping */ if (!(status&1)) { printf("Create/Map Section failed. Error = %d.", status); goto pio_end; } byte_ptr = byte_ptr + vme_offset; saved_ptr = byte_ptr; word_ptr = byte_ptr; long_ptr = byte_ptr; /* Map section */ loop = 1; while (loop == 1) { if (loop_request == 0) loop = 0; byte_ptr = saved_ptr; if ((access_mode[0] == 'B') || (access_mode[0] == 'b')) { byte_value = 0; for (i = 0; i < byte_count; i++) { byte_value++; if (byte_value >= 256) byte_value = 0; *byte_ptr = byte_value; byte_ptr++; } byte_value = 0; byte_ptr = saved_ptr; for (i = 0; i < byte_count; i++) { byte_received = *byte_ptr; byte_ptr++; 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; word_ptr = saved_ptr; if ((access_mode[0] == 'W') || (access_mode[0] == 'w')) { word_value = 0; for (i = 0; i < word_count; i++) { word_value++; if (word_value >= 65536) word_value = 0; *word_ptr++ = word_value; } word_value = 0; word_ptr = saved_ptr; /* reset the buffer ptr */ for (i = 0; i < word_count; i++) { word_received = *word_ptr++; 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; long_ptr = saved_ptr; if ((access_mode[0] == 'L') || (access_mode[0] == 'l')) { for (i = 0; i < long_count; i++) { *long_ptr++ = i; } long_ptr = saved_ptr; /* reset the buffer ptr */ for (i = 0; i < long_count; i++) { long_received = *long_ptr++; 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); }