Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ioscan.c

Go to the documentation of this file.
00001 
00002 /* scan i/o space looking for possible opennings */
00003 
00004 /*
00005   Modification history:
00006   11/16/95 - Szabo created
00007   */
00008 
00009 #include <stdio.h>
00010 #include <string.h>
00011 #include <signal.h>
00012 #include <stdlib.h>
00013 #include "pcioDrv.h"
00014 
00015 #define MSG_LEN 40
00016 #define PAGE_SIZE 20            /* number of lines printed / page */
00017 #define LINE_SIZE 8
00018 static int pagesize = PAGE_SIZE;
00019 static int linesize = LINE_SIZE;
00020 static int line;
00021 
00022 
00023 void menu()
00024 {
00025   printf("\n");
00026   printf("#   - prints page starting at i/o address #\n");
00027   printf("p # - sets lines/page of i/o scan to #, default is 1 line/page\n");
00028   printf("    - blank line prints next page\n");
00029   printf("^C  - get out of ioscan\n");
00030   printf("\n");
00031 }
00032 
00033 void printpage(int value)
00034 {
00035   int i,j;
00036   for(i=value;i<value+(pagesize*linesize);i+=linesize)
00037   {
00038     printf("> %x : ", i);
00039     for(j=i;j<i+linesize;j++)
00040     {
00041       printf("%2x ", inputb(j));
00042       /*printf("%x ", j);*/
00043     }
00044     printf("\n");
00045   }
00046   line = i;
00047 }
00048 
00049 
00050 int main(int argc, char *argv[])
00051 {
00052   char cmd[MSG_LEN];
00053 
00054   if(1 < argc)
00055   {
00056     sscanf(argv[1],"%x",&pagesize);
00057     printf("You have changed the page size to %x\n",pagesize);
00058   }
00059 
00060   signal( SIGINT, exit );
00061 
00062   menu();
00063 
00064   while (1)
00065   {
00066     printf("io> ");
00067     fgets(cmd, MSG_LEN, stdin);
00068 
00069     if('h' == *cmd)
00070     {
00071       menu();
00072     }
00073     else if('p' == *cmd)
00074     {
00075       printf("Current page size is %d\n", pagesize);
00076       printf("Enter new page size in decimal ");
00077       printf("\n");
00078 
00079       fgets(cmd, MSG_LEN, stdin);
00080       if (1 != sscanf(cmd,"%d",&pagesize))
00081       {
00082         printf("try again\n\n");
00083         return;
00084       }
00085 
00086       printf("New page size is %x\n", pagesize);
00087 
00088     }
00089     else if('\n' == *cmd)
00090       printpage(line);
00091     else
00092     { /* assume it is a number, then print page starting at the number */
00093       if (1 != sscanf(cmd,"%x",&line))
00094       {
00095         printf("try again\n\n");
00096         return;
00097       }
00098       printpage(line);
00099     }
00100   }
00101 }

Generated on Sun Dec 2 15:56:50 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001