home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / tt / vmem11 / vmem_prg / test.c < prev    next >
C/C++ Source or Header  |  1993-08-30  |  5KB  |  223 lines

  1. #include "vmem.h"
  2.  
  3. long clock (void);
  4. int printf(const char *format, ... );
  5.  
  6. #define    ALLOC_SIZE    (128*1024L)
  7.  
  8. char memory [ALLOC_SIZE];
  9.  
  10. int main (void)
  11. {
  12.     V_INFO    *infoblk;
  13.     char    *cacheadr;
  14.     TAB        parameter;
  15.     V_ADR    testadr;
  16.     long    ret_code;
  17.     int        handle, i;
  18.     long    time1, time2;
  19.  
  20.     time1 = clock ();
  21.  
  22. #if 0
  23.     parameter.version = 0x100;
  24.     parameter.count_page = 256;
  25.     parameter.cache_size = 50;
  26.     parameter.page_type = SIZE_4096;
  27.     parameter.fill_value = 0;
  28.     parameter.drive_no = 'C' - 'C' + 3;
  29. #else
  30.     parameter.version = 0x100;
  31.     parameter.count_page = 100;
  32.     parameter.cache_size = 6;
  33.     parameter.page_type = SIZE_32768;
  34.     parameter.fill_value = 0;
  35.     parameter.drive_no = 'C' - 'C' + 3;
  36. #endif
  37.  
  38. printf ("\nVM_CONFIG: $%lx", ¶meter);
  39.  
  40.     ret_code = vm_config (¶meter);
  41.     if (ret_code != OK)
  42.     {
  43.         printf (" !!! => %ld\n", ret_code);
  44.         return (1);
  45.     }
  46.  
  47.  
  48.  
  49.     infoblk = vm_info ();
  50.  
  51. printf ("\nVM_INFO: => $%lx", infoblk);
  52.  
  53.     printf ("\nVersion:\t$%x\n", infoblk->version);
  54.     printf ("count page:\t#$%x\n", infoblk->count_page);
  55.     printf ("count blocks:\t#$%x\n", infoblk->count_blocks);
  56.     printf ("free blocks:\t#$%x\n", infoblk->free_blocks);
  57.     printf ("fill value:\t$%x\n", infoblk->fill_value);
  58.     printf ("cache size:\t$%lx bytes\n", infoblk->cache_size);
  59.     printf ("cache count:\t$%x\n", infoblk->cache_count);
  60.     printf ("page size:\t$%lx bytes\n", infoblk->page_size);
  61.     printf ("max size:\t$%lx bytes\n", infoblk->max_size);
  62.     printf ("max alloc:\t$%lx bytes\n", infoblk->max_alloc);
  63.     printf ("drive no:\t#%x\n", infoblk->drive_no);
  64.     printf ("Drive %c free:\t%ld bytes\n\n", (infoblk->drive_no + '@'), infoblk->drive_free);
  65.  
  66.  
  67.  
  68. printf ("\nVM_ALLOC: $%lx", ALLOC_SIZE);
  69.  
  70.     testadr = vm_alloc (ALLOC_SIZE);
  71.  
  72.  
  73.  
  74. printf ("\nVM_FILL: $%lx $%lx $%x", testadr, ALLOC_SIZE, 0xff);
  75.  
  76.     ret_code = vm_fill (testadr, ALLOC_SIZE, 0xff);
  77.     if (ret_code != ALLOC_SIZE)
  78.         printf ("%ld\n", ret_code);
  79.  
  80.  
  81.  
  82.     memcpy (memory, (char *) 0x100000L, 128*1024L);
  83.  
  84.  
  85.  
  86. printf ("\nVM_SAVE: $%lx $%lx $%lx", memory, testadr, ALLOC_SIZE);
  87.  
  88.     ret_code = vm_save (memory, testadr, ALLOC_SIZE);
  89.     if (ret_code != ALLOC_SIZE)
  90.         printf ("%ld\n", ret_code);
  91.  
  92.  
  93.  
  94.     handle = Fcreate ("C:\\TEST1.TMP", 0);
  95.  
  96. printf ("\nVM_WRITE: $%x $%lx $%lx", handle, ALLOC_SIZE, testadr);
  97.  
  98.     ret_code = vm_write (handle, ALLOC_SIZE, testadr);
  99.     if (ret_code != ALLOC_SIZE)
  100.         printf ("%ld\n", ret_code);
  101.  
  102.     Fclose (handle);
  103.  
  104.  
  105.     handle = Fopen ("C:\\TEST1.TMP", 0);
  106.  
  107. printf ("\nVM_READ: $%x $%lx $%lx", handle, ALLOC_SIZE, testadr);
  108.  
  109.     ret_code = vm_read (handle, ALLOC_SIZE, testadr);
  110.     if (ret_code != ALLOC_SIZE)
  111.         printf ("%ld\n", ret_code);
  112.  
  113.     Fclose (handle);
  114.  
  115.  
  116.  
  117.     ret_code = 15000L;
  118.  
  119. printf ("\nVM_ADDRESS: $%lx $%lx $%x", testadr+0x123, &ret_code, WRITE_MODE);
  120.  
  121.     cacheadr = vm_address (testadr+0x123, &ret_code, WRITE_MODE);
  122.  
  123. printf ("\n => $%lx $%lx", cacheadr, ret_code);
  124.  
  125. #ifdef FILL
  126.     memset (cacheadr, 0x61, ret_code);
  127. #endif
  128.  
  129.  
  130.     ret_code = 10000L;
  131.  
  132. printf ("\nVM_ADDRESS: $%lx $%lx $%x", testadr+0x823, &ret_code, WRITE_MODE);
  133.  
  134.     cacheadr = vm_address (testadr+0x823, &ret_code, WRITE_MODE);
  135.  
  136. printf ("\n => $%lx $%lx", cacheadr, ret_code);
  137.  
  138. #ifdef FILL
  139.     memset (cacheadr, 0x62, ret_code);
  140. #endif
  141.  
  142.  
  143.  
  144.     ret_code = 20000L;
  145.  
  146. printf ("\nVM_ADDRESS: $%lx $%lx $%x", testadr+0x1023, &ret_code, WRITE_MODE);
  147.  
  148.     cacheadr = vm_address (testadr+0x1023, &ret_code, WRITE_MODE);
  149.  
  150. printf ("\n => $%lx $%lx", cacheadr, ret_code);
  151.  
  152. #ifdef FILL
  153.     memset (cacheadr, 0x63, ret_code);
  154. #endif
  155.  
  156.  
  157. #ifdef FILL
  158.     for (i=7; i>=3; i--)
  159.     {
  160.         COPY_CACHE (CACHE_ADDRESS (i+1), CACHE_ADDRESS (i));
  161.         ALLOC_CACHE (i+1, cache_flags [i], cache_page [i]);
  162.         FREE_CACHE (i);
  163.     }
  164.  
  165.     COPY_CACHE (CACHE_ADDRESS (0), CACHE_ADDRESS (2));
  166.     ALLOC_CACHE (0, cache_flags [2], cache_page [2]);
  167.     FREE_CACHE (2);
  168.  
  169.     COPY_CACHE (CACHE_ADDRESS (2), CACHE_ADDRESS (4));
  170.     ALLOC_CACHE (2, cache_flags [4], cache_page [4]);
  171.     FREE_CACHE (4);
  172. #endif
  173.  
  174.  
  175.     ret_code = 30000L;
  176.  
  177. printf ("\nVM_ADDRESS: $%lx $%lx $%x", testadr+0x223, &ret_code, READ_MODE);
  178.  
  179.     cacheadr = vm_address (testadr+0x223, &ret_code, READ_MODE);
  180.  
  181. printf ("\n => $%lx $%lx", cacheadr, ret_code);
  182.  
  183.  
  184.  
  185.     handle = Fcreate ("C:\\TEST2.TMP", 0);
  186.  
  187. printf ("\nVM_WRITE: $%x $%lx $%lx", handle, ALLOC_SIZE, testadr);
  188.  
  189.     ret_code = vm_write (handle, ALLOC_SIZE, testadr);
  190.     if (ret_code != ALLOC_SIZE)
  191.         printf ("%ld\n", ret_code);
  192.  
  193.     Fclose (handle);
  194.  
  195.  
  196.     handle = Fcreate ("C:\\TEST2.TM", 0);
  197.  
  198. printf ("\nVM_WRITE: $%x $%lx $%lx", handle, ALLOC_SIZE, testadr);
  199.  
  200.     ret_code = vm_write (handle, ALLOC_SIZE, testadr);
  201.     if (ret_code != ALLOC_SIZE)
  202.         printf ("%ld\n", ret_code);
  203.  
  204.     Fclose (handle);
  205.  
  206.  
  207.  
  208. printf ("\nVM_FREE: $%lx", testadr);
  209.  
  210.     vm_free (testadr);
  211.  
  212.  
  213.  
  214. printf ("\nVM_CLOSE:\n");
  215.  
  216.     vm_close ();
  217.  
  218.     time2 = clock ();
  219.     printf ("\nZeit: %ld Einheiten\n", (time2 - time1));
  220.  
  221.     return (0);
  222. }
  223.