1: /*
   2:  *	SYSGEN -- an imitation of the CONFIG command of VMS SYSGEN.
   3:  *
   4:  *	$Id: sysgen.c,v 1.9 1997/06/08 12:12:59 tih Exp $
   5:  */
   6: 
   7: #include <stdio.h>
   8: #include <unistd.h>
   9: #include <string.h>
  10: #include <ctype.h>
  11: 
  12: #include "devices.h"
  13: 
  14: struct userdev {
  15:   char username[DEVNAMLEN];
  16:   char name[DEVNAMLEN];
  17:   int vector;
  18:   long csr;
  19: };
  20: 
  21: struct userdev usertab[MAXDEVS];
  22: 
  23: #define roundup(value,align) (value+align-1-((value+align-1)%align))
  24: 
  25: int main(argc, argv)
  26:      int argc;
  27:      char **argv;
  28: {
  29:   int i, j, k, n;
  30:   int vecbase = VECBASE;
  31:   long csrbase = CSRBASE;
  32:   char userdev[DEVNAMLEN];
  33:   char useralias[DEVNAMLEN];
  34:   int userdevs = 0;
  35:   char inputline[BUFSIZ];
  36:   char scanformat[32];
  37: 
  38:   if (isatty(fileno(stdin))) {
  39:     fprintf(stderr, "Type device names one per line, optionally followed\n");
  40:     fprintf(stderr, "by a comma and a repeat count.  Finish with EOF.\n");
  41:   }
  42: 
  43:   sprintf(scanformat, "%%%d[A-Za-z0-9],%%d", DEVNAMLEN - 1);
  44:   while (fgets(inputline, BUFSIZ, stdin)) {
  45:     for (i = 0; i < strlen(inputline); i++)
  46:       if (inputline[i] == '\n')
  47:     inputline[i] = '\0';
  48:       else if (islower(inputline[i]))
  49:     inputline[i] = toupper(inputline[i]);
  50:     n = sscanf(inputline, scanformat, userdev, &k);
  51:     if (n == 0)
  52:       continue;
  53:     if (n == 1)
  54:       k = 1;
  55:     strcpy(useralias, userdev);
  56:     for (i = 0; i < ALIASTABLEN; i++)
  57:       if (!strcmp(aliastab[i].alias, userdev))
  58:     strcpy(useralias, aliastab[i].name);
  59:     for (i = 0; i < DEVTABLEN; i++)
  60:       if (!strcmp(devtab[i].name, useralias))
  61:     break;
  62:     if (i >= DEVTABLEN) {
  63:       fprintf(stderr, "sysgen: %s: unrecognized device name; ignored\n",
  64:           useralias);
  65:       continue;
  66:     }
  67:     while (k--) {
  68:       usertab[userdevs].vector = 0;
  69:       usertab[userdevs].csr = 0;
  70:       strcpy(usertab[userdevs].username, userdev);
  71:       strcpy(usertab[userdevs++].name, useralias);
  72:     }
  73:   }
  74: 
  75:   for (i = 0; i < DEVTABLEN; i++) {
  76:     if (devtab[i].csr == FLOAT)
  77:       csrbase = roundup(csrbase + CSRLEN, devtab[i].csralign);
  78:     for (j = 0; j < userdevs; j++) {
  79:       if ((!strcmp(devtab[i].name, usertab[j].name)) &&
  80:       (usertab[j].csr == 0)) {
  81:     if ((devtab[i].vector == FLOAT) && (devtab[i].csr == FLOAT)) {
  82:       vecbase = roundup(vecbase, devtab[i].vecalign);
  83:       usertab[j].vector = vecbase;
  84:       vecbase = vecbase + devtab[i].numvecs * VECLEN;
  85:       usertab[j].csr = csrbase;
  86:       csrbase = roundup(csrbase + devtab[i].csralign, devtab[i].csralign);
  87:       continue;
  88:     }
  89:     if (devtab[i].vector == FLOAT) {
  90:       vecbase = roundup(vecbase, devtab[i].vecalign);
  91:       usertab[j].vector = vecbase;
  92:       vecbase = vecbase + devtab[i].numvecs * VECLEN;
  93:     } else {
  94:       usertab[j].vector = devtab[i].vector;
  95:     }
  96:     if (devtab[i].csr == FLOAT) {
  97:       usertab[j].csr = csrbase;
  98:     } else {
  99:       usertab[j].csr = devtab[i].csr;
 100:     }
 101:     break;
 102:       }
 103:     }
 104:   }
 105: 
 106:   for (i = 0; i < userdevs; i++) {
 107:     if (usertab[i].csr == 0)
 108:       fprintf(stderr, "sysgen: %s: too many units; ignored\n",
 109:           usertab[i].username);
 110:   }
 111: 
 112:   printf("Table of standard DEC assignments for configuration:\n\n");
 113: 
 114:   printf("  DEVICE     CSR   VECTOR\n-------------------------\n");
 115:   for (i = 0; i < userdevs; i++) {
 116:     if (usertab[i].csr == 0)
 117:       continue;
 118:     printf("%8s  %06lo%c  %04o%c\n",
 119:        usertab[i].username,
 120:        usertab[i].csr, (usertab[i].csr < 0764000) ? '*' : ' ',
 121:        usertab[i].vector, (usertab[i].vector < 0300) ? ' ' : '*');
 122:   }
 123:   printf("\nCSRs and vectors marked '*' are in floating space.\n");
 124: 
 125:   return 0;
 126: }
 127: 
 128: /*
 129:  *	eof
 130:  */

Defined functions

main defined in line 25; never used

Defined variables

usertab defined in line 21; used 20 times

Defined struct's

userdev defined in line 14; used 2 times
  • in line 21(2)

Defined macros

roundup defined in line 23; used 4 times
Last modified: 1997-06-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3113
Valid CSS Valid XHTML 1.0 Strict