home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / CYRIX100.ZIP / CX486DLC / DRAM / DRAM.C next >
Encoding:
C/C++ Source or Header  |  1994-04-05  |  1.2 KB  |  49 lines

  1. /*
  2.    A quick hack to set the refresh timer to a longer period than the
  3.    standard 15 microseconds. This is to help out people who have to
  4.    have their Cx486DLC flush the internal cache on every DRAM refresh,
  5.    because their motherboard doesn't support the Cx's FLUSH input.
  6.  
  7.                         Paul Gortmaker.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <conio.h>
  13.  
  14. unsigned short dram_refresh;
  15. unsigned char dram_timer_lo;
  16. unsigned char dram_timer_hi;
  17.  
  18. int main(int argc, char *argv[]) {
  19.  
  20. if (argc!=2) {
  21.     fprintf(stderr,"\nUsage: %s <time>\n\t\twhere <time> is the DRAM refresh period in µs.\n",argv[0]);
  22.     exit(0);
  23. }
  24.  
  25. dram_refresh=atoi(argv[1]);
  26.  
  27. if (dram_refresh<15) {
  28.     fprintf(stderr,"\nDRAM refresh more freqent than 15 microseconds? Ha!\n");
  29.     exit(1);
  30. }
  31. else if (dram_refresh>55000) {
  32.     fprintf(stderr,"\nDRAM refresh period must be less than 55000 microseconds.\n");
  33.     exit(1);
  34. }
  35.  
  36. dram_refresh=(unsigned short)(dram_refresh*1.193+.5);
  37. /* timer is clocked at 1.19 MHz -- PC std. */
  38.  
  39. dram_timer_hi=dram_refresh/0x100;
  40. dram_timer_lo=dram_refresh%0x100;
  41.  
  42. _outp(0x43,0x74);
  43. _outp(0x41,dram_timer_lo);
  44. _outp(0x41,dram_timer_hi);
  45.  
  46. return (0);
  47.  
  48. }
  49.