home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / croutes.zip / MEMCLEAN.C < prev    next >
Text File  |  1984-07-29  |  5KB  |  160 lines

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