Annotation of coherent/d/kernel/USRSRC/i8086/drv/tools/parms.c, revision 1.1.1.1

1.1       root        1: /* parms.c - display hard drive parameters per "atparm" in kernel */
                      2: 
                      3: #include <stdio.h>
                      4: #include <l.out.h>
                      5: 
                      6: /*
                      7:  * For easy referencing.
                      8:  */
                      9: #define        at_table                nl[0].n_value
                     10: #define        plowner         nl[1].n_value
                     11: #define NDRIVE         2
                     12: 
                     13: struct dparm_s {
                     14:        unsigned short  d_ncyl;         /* number of cylinders */
                     15:        unsigned char   d_nhead;        /* number of heads */
                     16:        unsigned short  d_rwcc;         /* reduced write current cyl */
                     17:        unsigned short  d_wpcc;         /* write pre-compensation cyl */
                     18:        unsigned char   d_eccl;         /* max ecc data length */
                     19:        unsigned char   d_ctrl;         /* control byte */
                     20:        unsigned char   d_fill2[3];
                     21:        unsigned short  d_landc;        /* landing zone cylinder */
                     22:        unsigned char   d_nspt;         /* number of sectors per track */
                     23:        unsigned char   d_fill3;
                     24: 
                     25: }      atparm[ NDRIVE ] = {
                     26:        0                               /* Initialized to allow patching */
                     27: };
                     28: 
                     29: /*
                     30:  * Table for namelist.
                     31:  */
                     32: struct nlist nl[] ={
                     33:        "atparm_",              0,      0,
                     34:        ""
                     35: };
                     36: 
                     37: /*
                     38:  * Symbols.
                     39:  */
                     40: char    *kfile;                        /* Kernel data memory file */
                     41: char    *nfile;                        /* Namelist file */
                     42: int     kfd;                           /* Kernel memory file descriptor */
                     43: 
                     44: main(argc, argv)
                     45: char *argv[];
                     46: {
                     47:        register int i;
                     48:        register char *cp;
                     49: 
                     50:        initialise();
                     51:        for (i=1; i<argc; i++) {
                     52:                for (cp=&argv[i][0]; *cp; cp++) {
                     53:                        switch (*cp) {
                     54:                        case '-':
                     55:                                continue;
                     56:                        case 'c':
                     57:                                if (++i >= argc)
                     58:                                        usage();
                     59:                                nfile = argv[i];
                     60:                                continue;
                     61:                        default:
                     62:                                usage();
                     63:                        }
                     64:                }
                     65:        }
                     66:        execute();
                     67:        exit(0);
                     68: }
                     69: 
                     70: /*
                     71:  * Initialise.
                     72:  */
                     73: initialise()
                     74: {
                     75:        nfile = "/coherent";
                     76:        kfile = "/dev/kmem";
                     77: }
                     78: 
                     79: /*
                     80:  * Print out usage.
                     81:  */
                     82: usage()
                     83: {
                     84:        panic("Usage: parms [-][c kernel_file]");
                     85: }
                     86: 
                     87: /*
                     88:  * Display parameters
                     89:  */
                     90: execute()
                     91: {
                     92:        int dr;
                     93: 
                     94:        nlist(nfile, nl);
                     95:        if (nl[0].n_type == 0)
                     96:                panic("Bad namelist file %s", nfile);
                     97:        if ((kfd = open(kfile, 0)) < 0)
                     98:                panic("Cannot open %s", kfile);
                     99: 
                    100:        kread((long)at_table, atparm, sizeof(atparm));
                    101:        printf("Hard drive parameters as stored in \"at\" driver:\n");
                    102:        for (dr = 0;  dr < NDRIVE;  dr++) {
                    103:                printf("drive %d  cyl=%4d  hd=%2d  spt=%2d  ctrl=%02x\n",
                    104:                        dr, atparm[dr].d_ncyl, atparm[dr].d_nhead,
                    105:                        atparm[dr].d_nspt, atparm[dr].d_ctrl);
                    106:        }
                    107: }
                    108: 
                    109: /*
                    110:  * Read `n' bytes into the buffer `bp' from kernel memory
                    111:  * starting at seek position `s'.
                    112:  */
                    113: kread(s, bp, n)
                    114: long s;
                    115: {
                    116:        lseek(kfd, (long)s, 0);
                    117:        if (read(kfd, bp, n) != n)
                    118:                panic("Kernel memory read error");
                    119: }
                    120: 
                    121: /*
                    122:  * Print out an error message and exit.
                    123:  */
                    124: panic(a1)
                    125: char *a1;
                    126: {
                    127:        fflush(stdout);
                    128:        fprintf(stderr, "%r", &a1);
                    129:        fprintf(stderr, "\n");
                    130:        exit(1);
                    131: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.