home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 171_01 / memclean.c < prev    next >
Text File  |  1983-10-30  |  6KB  |  165 lines

  1. /*
  2.  
  3.         MEMORY CLEAN PROGRAM FOR THE IBM PERSONAL COMPUTER
  4.         Version 1.00  3 May 1983
  5.  
  6.         COPYRIGHT (C) ROBERT J. BEILSTEIN, 1983
  7.  
  8.                       N O T I C E
  9.  
  10.       This program is supplied for your personal and
  11.       non-commercial use only. No commercial use permitted.
  12.       Users of this program are granted limited rights to
  13.       reproduce and distribute this program, provided
  14.       the following conditions are met:
  15.  
  16.       1) This program must be supplied in original form,
  17.          with no modifications.
  18.       2) Notices contained in this source file, and those
  19.          produced by the executable program, must not be
  20.          altered or removed.
  21.       3) This program may not be sold. Providing this
  22.          program for consideration of any sort, including
  23.          copying or distribution fees, is prohibited.
  24.       4) This program may not be used on timesharing
  25.          systems where fees are charged for access,
  26.          or or supplied as part of any other form of
  27.          rental access computing, without the express
  28.          written permission of the author.
  29.  
  30.       PLEASE SEND PROBLEM REPORTS AND SUGGESTIONS
  31.       TO:
  32.             ROBERT J. BEILSTEIN
  33.             413 Wells Avenue, West
  34.             North Syracuse, New York 13212
  35.  
  36.         This program is designed to be run immediately following
  37.         powerup, and will fill all of expansion memory with good-parity
  38.         data (thus avoiding problems with spurious parity checks
  39.         if uninitialized memory is read).
  40.  
  41.         The program will write to all available memory locations
  42.         above the 640K the ROM BIOS knows about.  That is:
  43.  
  44.         X'C0000' --> X'EFFFF'
  45.  
  46.         In addition, if 'SEGA' is specified on the command line,
  47.         locations X'A0000' --> X'AFFFF' will be initialized.
  48.  
  49.         Also, for compatibility with pre-XT machines which have
  50.         a limit on DOS-addressible RAM of 544K, specifying '544K'
  51.         on the command line will start clearing at X'88000'.
  52.  
  53. */
  54.  
  55. #include <stdio.h>
  56.  
  57. #define WRITE_DATA 0xaaaa   /* memory initialization value */
  58.  
  59. main(argc,argv)     /* define entry point */
  60.  
  61. int argc;           /* count of function arguments */
  62. char *argv[];       /* pointer array to argument strings */
  63. {
  64.     unsigned int cur_segment;           /* current segment pointer */
  65.     unsigned int cur_offset;            /* current offset within segment */
  66.     unsigned int start_segment=0xa000;  /* starting segment */
  67.     unsigned int start_offset=0;        /* starting offset within segment
  68.                                            used to start 544k seg on 32k
  69.                                            boundary */
  70.  
  71.                                         /* a bunch of useful flags */
  72.         unsigned is_xt = 1;             /* if set, start at 640k */
  73.         unsigned resv_ok = 0;           /* if set, clear reserved memory
  74.                                            between X'A0000' and X'AFFFF' */
  75.         unsigned no_high = 0;           /* if set, do not initialize
  76.                                            X'C0000' or above */
  77.         unsigned good_parm;             /* current parameter valid */
  78.  
  79.     int i;                              /* the canonical temporary */
  80.  
  81.     unsigned long bot,top;              /* for displaying limit values */
  82.  
  83.     printf("\nMEMCLEAN V1.00, COPYRIGHT (C) Robert J. Beilstein, 1983\n\n");
  84.  
  85.     for (i = 1;i < argc;i++)            /* check invocation parms */
  86.     {
  87.         good_parm = 0;                  /* reset good parm flag */
  88.  
  89.         if (!strcmp(argv[i],"544k") && strcmp(argv[i],"544K"))
  90.         {
  91.             is_xt = 0;                  /* start at X'88000' */
  92.  
  93.             good_parm = 1;
  94.         }
  95.  
  96.         if (!strcmp(argv[i],"sega") && strcmp(argv[i],"SEGA"))
  97.         {
  98.  
  99.             resv_ok = 1;                /* do X'A0000' --> X'AFFFF' */
  100.  
  101.             good_parm = 1;
  102.  
  103.         }
  104.  
  105.         if (!strcmp(argv[i],"nohigh") && strcmp(argv[i],"NOHIGH"))
  106.         {
  107.  
  108.             no_high = 1;                /* skip X'C0000' --> X'EFFFF'  */
  109.  
  110.             good_parm = 1;
  111.  
  112.         }
  113.  
  114.         if (!good_parm)                 /* execute if a bad parm given */
  115.             abort("INVALID PARAMETER TO <MEMCLEAN>:  \"%s\"\nVALID PARAMETERS\
  116.  ARE: \"544k\", \"sega\" and \"nohigh\"",argv[i]);
  117.     }
  118.  
  119.     /* now that parameters are decoded, we can start doing something useful */
  120.  
  121.     if (!is_xt)                         /* if "544K" specified, reset addr */
  122.     {
  123.  
  124.         start_segment = 0x8000;
  125.         start_offset = 0x8000;
  126.  
  127.     }
  128.  
  129.     for (cur_segment = start_segment;cur_segment < 0xf000;cur_segment+=4096)
  130.     {
  131.  
  132.         if ((!resv_ok) && cur_segment == 0xa000) continue;
  133.  
  134.         if (cur_segment == 0xb000) continue;    /* skip graphics ram */
  135.  
  136.         if (no_high && cur_segment >= 0xc000) break;    /* quit on "nohigh */
  137.  
  138.         bot = (unsigned long) cur_segment * 16 + start_offset;
  139.         top = (unsigned long) cur_segment * 16 + 65535;
  140.  
  141.         printf("INITIALIZING %lx --> %lx\n",bot,top);   /* show same */
  142.  
  143.         for (cur_offset = start_offset;;cur_offset+=2)
  144.         {
  145.             pokew(cur_offset,cur_segment,WRITE_DATA);
  146.  
  147.             if (cur_offset == 0xfffe) break;
  148.  
  149.         }
  150.  
  151.         start_offset = 0;               /* subsequently start at offset 0 */
  152.  
  153.     }
  154.  
  155.     printf("ALL REQUESTED MEMORY INITIALIZED\n");
  156.  
  157. }
  158.     powerup, and will fill alluently start at offset 0 */
  159.  
  160.     }
  161.  
  162.     printf("ALL REQUESTED MEMORY INITIALIZED\n");
  163.  
  164. }
  165.     powerup, and will fill all