/* * eppconfig.c * * This is part of ppa3 package. * Use this program to configure EPP speed. * * Get the address of the ppa_epp_speed from startup log, something like: * ppa0: ppa_epp_speed = 10000 at 0xf01c1a30 * * Then use eppconfig like this: * * $ eppconfig 0x * * Of course, DO NOT USE ANY OTHER ADDRESS. eppconfig writes directly to * the device /dev/kmem to update the value. * * EPP timeouts are generated by the port because the drive is too slow. * EPP timeouts are avoided in ppa3.c with a DELAY(). epp_speed is the * duration of this delay. Then EPP timeouts are lost CPU time. */ #include #include #include #define EPP_VERSION "1.0" #define PPA_VERSION "0.62-BETA" #define DEV_MEM "/dev/kmem" void usage (int argc, char ** argv) { fprintf (stderr, "usage: %s
\n", argv[0]); return; } /* usage */ int open_mem (void) { int dev; dev = open (DEV_MEM, O_RDWR); if (dev < 0) { perror ("open"); exit (1); } return dev; } /* open_mem */ int read_value (int dev, unsigned int address) { int value; if (lseek (dev, address, SEEK_SET) < 0) { perror ("lseek"); exit (1); } if (read (dev, &value, sizeof (int)) < 0) { perror ("read"); exit (1); } return value; } /* read_value */ void write_value (int dev, unsigned int address, int value) { if (lseek (dev, address, SEEK_SET) < 0) { perror ("lseek"); exit (1); } if (write (dev, &value, sizeof (int)) < 0) { perror ("read"); exit (1); } return; } /* write_value */ void main (int argc, char ** argv) { unsigned int address; int oldv, newv, dev; if (argc != 3) { usage (argc, argv); exit (1); } if (sscanf (argv[1], "0x%x", &address) != 1 || sscanf (argv[2], "%d", &newv) != 1) { usage (argc, argv); exit (1); } printf ("eppconfig version %s to use with PPA3 driver release %s.\n", EPP_VERSION, PPA_VERSION); dev = open_mem (); oldv = read_value (dev, address); printf ("Old value: %d at 0x%x\n", oldv, address); write_value (dev, address, newv); newv = read_value (dev, address); printf ("New value: %d at 0x%x\n", newv, address); exit (0); } /* main */