|
|
1.1 ! root 1: /* (-lgl ! 2: * COHERENT Driver Kit Version 1.1.0 ! 3: * Copyright (c) 1982, 1990 by Mark Williams Company. ! 4: * All rights reserved. May not be copied without permission. ! 5: -lgl) */ ! 6: /* ! 7: * prate.c - display polling rate of com[1-4] drivers ! 8: */ ! 9: ! 10: #include <stdio.h> ! 11: #include <l.out.h> ! 12: #include <poll_clk.h> ! 13: ! 14: /* ! 15: * For easy referencing. ! 16: */ ! 17: #define plrate nl[0].n_value ! 18: #define plowner nl[1].n_value ! 19: ! 20: /* ! 21: * Table for namelist. ! 22: */ ! 23: struct nlist nl[] ={ ! 24: "poll_rate_", 0, 0, ! 25: "poll_owner_", 0, 0, ! 26: "" ! 27: }; ! 28: ! 29: /* ! 30: * Symbols. ! 31: */ ! 32: char *kfile; /* Kernel data memory file */ ! 33: char *nfile; /* Namelist file */ ! 34: int kfd; /* Kernel memory file descriptor */ ! 35: ! 36: main(argc, argv) ! 37: char *argv[]; ! 38: { ! 39: register int i; ! 40: register char *cp; ! 41: ! 42: initialise(); ! 43: for (i=1; i<argc; i++) { ! 44: for (cp=&argv[i][0]; *cp; cp++) { ! 45: switch (*cp) { ! 46: case '-': ! 47: continue; ! 48: case 'c': ! 49: if (++i >= argc) ! 50: usage(); ! 51: nfile = argv[i]; ! 52: continue; ! 53: default: ! 54: usage(); ! 55: } ! 56: } ! 57: } ! 58: execute(); ! 59: exit(0); ! 60: } ! 61: ! 62: /* ! 63: * Initialise. ! 64: */ ! 65: initialise() ! 66: { ! 67: nfile = "/coherent"; ! 68: kfile = "/dev/kmem"; ! 69: } ! 70: ! 71: /* ! 72: * Print out usage. ! 73: */ ! 74: usage() ! 75: { ! 76: panic("Usage: prate [-][c kernel_file]"); ! 77: } ! 78: ! 79: /* ! 80: * Display polling rate ! 81: */ ! 82: execute() ! 83: { ! 84: int rate, owner; ! 85: ! 86: nlist(nfile, nl); ! 87: if (nl[0].n_type == 0) ! 88: panic("Bad namelist file %s", nfile); ! 89: if ((kfd = open(kfile, 0)) < 0) ! 90: panic("Cannot open %s", kfile); ! 91: ! 92: kread((long)plrate, &rate, sizeof(rate)); ! 93: kread((long)plowner, &owner, sizeof(owner)); ! 94: if (rate) { ! 95: if (owner & POLL_AL) ! 96: printf("al driver is "); ! 97: else if (owner & POLL_HS) ! 98: printf("hs driver is "); ! 99: printf("polling at %d Hz\n", rate); ! 100: } else ! 101: printf("polling is OFF\n"); ! 102: } ! 103: ! 104: /* ! 105: * Read `n' bytes into the buffer `bp' from kernel memory ! 106: * starting at seek position `s'. ! 107: */ ! 108: kread(s, bp, n) ! 109: long s; ! 110: { ! 111: lseek(kfd, (long)s, 0); ! 112: if (read(kfd, bp, n) != n) ! 113: panic("Kernel memory read error"); ! 114: } ! 115: ! 116: /* ! 117: * Print out an error message and exit. ! 118: */ ! 119: panic(a1) ! 120: char *a1; ! 121: { ! 122: fflush(stdout); ! 123: fprintf(stderr, "%r", &a1); ! 124: fprintf(stderr, "\n"); ! 125: exit(1); ! 126: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.