#define _GNU_SOURCE #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE #define _FILE_OFFSET_BITS 64 #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dev/pci/sis1100_var.h" #define IVAL 1 #define VMESTART 0x84000000 int sis1100, interval; off_t devstart; size_t maxsize; static void printusage(int argc, char* argv[]) { printf("usage: %s [-i interval][-s maxsize] sis1100_path\n", argv[0]); } static int getoptions(int argc, char* argv[]) { extern char *optarg; extern int optind; extern int opterr; extern int optopt; int errflag, c; char* sis1100_path=0; const char* args="i:s:"; optarg=0; errflag=0; while (!errflag && ((c=getopt(argc, argv, args))!=-1)) { switch (c) { case 'i': interval=atoi(optarg); break; case 's': maxsize=atoi(optarg); break; default: errflag=1; } } if (errflag || optind!=argc-1) { printusage(argc, argv); return -1; } sis1100_path=argv[optind]; if ((sis1100=open(sis1100_path, O_RDWR, 0))<0) { printf("open \"%s\": %s\n", sis1100_path, strerror(errno)); return -1; } return 0; } static int do_write(int p, int start, int size, int* data) { off_t pos; int res; pos=lseek(p, sizeof(int)*start+devstart, SEEK_SET); if (pos==(off_t)-1) { perror("do_write::lseek"); return 1; } res=write(p, data, size*sizeof(int)); if (res!=size*sizeof(int)) { u_int32_t error; ioctl(p, SIS1100_LAST_ERROR, &error); if (res<0) { printf("write: %s; error=0x%x\n", strerror(errno), error); } else { printf("write: res=%d; error=0x%x\n", res, error); } return 1; } return 0; } static int do_read(int p, int start, int size, int* data) { off_t pos; int res; pos=lseek(p, sizeof(int)*start+devstart, SEEK_SET); if (pos==(off_t)-1) { perror("do_read::lseek"); return 1; } res=read(p, data, size*sizeof(int)); if (res!=size*sizeof(int)) { u_int32_t error; ioctl(p, SIS1100_LAST_ERROR, &error); if (res<0) { printf("read: %s; error=0x%x\n", strerror(errno), error); } else { printf("read: res=%d; error=0x%x\n", res, error); } return 1; } return 0; } static void set_break(int p, int size) { struct vmespace space; int res; space.am=0xb; space.datasize=4; space.swap=1; space.mapit=0; space.mindmalen=size; res=ioctl(p, SETVMESPACE, &space); if (res<0) printf("ioctl(SETVMESPACE): %s\n", strerror(errno)); } static int do_check(int p, int num, int* ibuf, int* obuf) { int val0, stopsec, i, loops; struct timeval start, stop; printf("%d", num); fflush(stdout); val0=random(); for (i=0; i