home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 100-199 / ff187.lzh / SetCPU / ROMBash.c < prev    next >
C/C++ Source or Header  |  1989-02-26  |  2KB  |  77 lines

  1. /* This program bashes on the ROM; basically, just copying the ROM around
  2.    several times. */
  3.  
  4. #include <exec/types.h>
  5. #include <exec/nodes.h>
  6. #include <exec/lists.h>
  7. #include <exec/ports.h>
  8. #include <exec/tasks.h>
  9. #include <exec/devices.h>
  10. #include <exec/io.h>
  11. #include <devices/timer.h>
  12. #include <libraries/dos.h>
  13.  
  14. struct Task *FindTask();
  15. void SubTime(), *AllocMem();
  16. struct Device *TimerBase;
  17.  
  18. /* This routine wastes time, based on ROM access. */
  19.  
  20. #define    ROMBASE        0x00FC0000L
  21. #define ROMSIZE        0x00030000L
  22.  
  23. void ROMBash() {
  24.    short ctr;
  25.    ULONG *mem;
  26.  
  27.    mem = AllocMem(ROMSIZE,0L);
  28.    for (ctr = 0; ctr < 100; ++ctr) {
  29.       CopyMemQuick(ROMBASE,mem,ROMSIZE);
  30.    }
  31.    FreeMem(mem,ROMSIZE);
  32. }
  33.  
  34. /* This is the main program. */
  35.  
  36. void main()
  37. {
  38.    struct MsgPort port;
  39.    struct timerequest treq;
  40.    long pass;
  41.    struct timeval origtime, finaltime;
  42.  
  43.   /* Initialize the timer stuff */
  44.    port.mp_Node.ln_Name = "ROMBash";
  45.    port.mp_Flags = PA_SIGNAL;
  46.    port.mp_SigTask = FindTask(0L);
  47.    port.mp_SigBit = AllocSignal(-1L);
  48.    AddPort(&port);
  49.    treq.tr_node.io_Message.mn_ReplyPort = &port;
  50.  
  51.    if (OpenDevice(TIMERNAME,0L,&treq,0L) != 0) {
  52.       printf("Error: Can't get \"%s\"\n",TIMERNAME);
  53.       exit(20);
  54.    }
  55.    TimerBase = treq.tr_node.io_Device;
  56.    treq.tr_node.io_Command = TR_GETSYSTIME;
  57.  
  58.   /* Find the starting time */
  59.    DoIO(&treq);
  60.    origtime = treq.tr_time;
  61.  
  62.    ROMBash();
  63.  
  64.   /* Find the ending time */
  65.    DoIO(&treq);
  66.    finaltime = treq.tr_time;   
  67.  
  68.    SubTime(&finaltime,&origtime);
  69.    
  70.    printf("DONE: Elapsed time = %ld.%6ld seconds\n",
  71.           finaltime.tv_secs,finaltime.tv_micro);
  72.  
  73.    CloseDevice(&treq);
  74.    RemPort(&port);
  75.    FreeSignal((ULONG)port.mp_SigBit);
  76. }
  77.