Agilent Technologies

Program that Demonstrates How to Use i?blockcopy to Move Data

/* blockcopy.c
   This examples demonstrates how to use i?blockcopy to move
   data. The SICL blockcopy routines will attempt to use DMA,
   if one the locations is A24, or A32 address space. If neither
   location is in A24 or A32 space the data will be move in the
   normal fashion.
   Note: This program requires a device that responds to both
   D16 and D32 accesses. If your device does not resond to
   both D16 and D32 this program will bus error. So you may need
   to modify this program to work with your device.
   Usage:
      blockcopy -a <symbolic_name>
   Return Value:
      none */
#include <stdio.h>
#include <stdlib.h>
#include "sicl.h"
static void error_usage(const char *);
main(int argc, char *argv[]) {
   long o;
   INST id;
   static char _huge *a24_buf;
   static char _huge *shr_buf;
   unsigned long bufsize = 1024 * 2;
   char *addr = NULL;
   while ((o = getopt(argc, argv, "a:b:i:n:")) != EOF)
      switch (o) {
      case 'a':
         addr = optarg;
         break;
      default:
         error_usage(argv[0]);
         break;
      }
   if (addr == NULL)
      error_usage(argv[0]);
   ionerror (I_ERROR_NO_EXIT);
   id = iopen (addr);
   shr_buf = imap (id, I_MAP_SHARED, 0, 0, 0);
   a24_buf = imap (id, I_MAP_A24, 0x20, 0x8, 0);
   printf("Shared memory to A24 (D16).

");
   iwblockcopy (id,
                (unsigned short *)shr_buf,
                (unsigned short *)a24_buf,
               bufsize,
               0
              );

   printf("A24 to Shared memory (D16).

");
   iwblockcopy (id,
                (unsigned short *)a24_buf,
                (unsigned short *)shr_buf,
                1,
                0
               );
   printf("Shared memory to A24 (D32).

");
   ilblockcopy (id,
                (unsigned long *)shr_buf,
                (unsigned long *)a24_buf,
                bufsize,
                0
               );
   printf("A24 to Shared memory (D32).

");
   ilblockcopy (id,
                (unsigned long *)a24_buf,
                (unsigned long *)shr_buf,
                bufsize,
                0
               );
}
static void error_usage(const char *progname)
{
   printf("Usage Error: %s <options>
", progname);
   printf("	-a <addr>:	SICL address
");
   exit(1);
}


© Agilent 2000-2006