Advertisement
micha_b

checkMMU.c

Mar 24th, 2023
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.95 KB | Source Code | 0 0
  1. /*
  2.     checkMMU
  3. */
  4.  
  5. #define __CLIB_PRAGMA_LIBCALL
  6. #include <libraries/identify.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11. #include <proto/identify.h>
  12. #include <exec/types.h>
  13. #include <exec/lists.h>
  14. #include <exec/memory.h>
  15. #include <exec/execbase.h>
  16. #include <mmu/context.h>
  17. #include <mmu/mmubase.h>
  18. #include <mmu/mmutags.h>
  19. #include <mmu/exceptions.h>
  20. #include <utility/tagitem.h>
  21.  
  22. #define DOS_IO
  23. #include <proto/exec.h>
  24. #include <proto/dos.h>
  25. #include <proto/mmu.h>
  26. #include <string.h>
  27.  
  28. struct MMUBase *MMUBase;
  29.  
  30. char *vers="\0$VER: checkMMU (21.03.2023)";
  31. char *stacksize = "$STACK:8192"; // only works when started from CLI
  32.  
  33.  
  34. int main(void)
  35. {
  36.     LONG retval = 0;
  37.     char mmutype;
  38.    
  39.     /* -- Open Libraries -- */
  40.     SysBase = *((struct ExecBase **)4L);
  41.         DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",40L);
  42.         if (DOSBase)
  43.         {
  44.             MMUBase = (struct MMUBase *)OpenLibrary("mmu.library",46L);
  45.             if (MMUBase)
  46.             {
  47.                 puts("Found mmu.library - maybe there is a MMU in that System?\n");
  48.                 retval = 1;
  49.             }
  50.             else
  51.             {
  52.                 puts("There seems to be NO MMU in that System.\n");
  53.                 retval = -1;
  54.             }
  55.         }
  56.         else
  57.             puts("Could not open DOSBase.");  
  58.            
  59.         /* check for MMU */
  60.         if (MMUBase)
  61.         {
  62.             mmutype = GetMMUType();
  63.             printf("MMU: %ld\n", GetMMUType());
  64.            
  65.             switch (mmutype)
  66.             {
  67.                 /* 68000 (no MMU) */
  68.                 case MUTYPE_NONE:
  69.                     puts("\nNo working MMU found!");
  70.                     puts("This seems to be MC68000, defective MMU\nor UAE flavour with MMU disabled.");
  71.                     retval = -1;
  72.                     break;
  73.                 /* 68020 (68851 MMU) */
  74.                 case MUTYPE_68851:
  75.                     puts("\nWorking MMU detected!");
  76.                     puts("This seems to be MC68020 with 68851 MMU");
  77.                     retval = 0;
  78.                     break; 
  79.                 /* 68030 (internal MMU) */
  80.                 case MUTYPE_68030:
  81.                     puts("\nWorking MMU detected!");
  82.                     puts("This seems to be MC68030 with internal MMU");
  83.                     retval = 0;
  84.                     break;
  85.                 /* 68040 (internal MMU) */
  86.                 case MUTYPE_68040:
  87.                     puts("\nWorking MMU detected!");
  88.                     puts("This seems to be MC68040 with internal MMU");
  89.                     retval = 0;
  90.                     break;
  91.                 /* 68030 (internal MMU) */
  92.                 case MUTYPE_68060:
  93.                     puts("\nWorking MMU detected!");
  94.                     puts("This seems to be MC68060 with internal MMU");
  95.                     retval = 0;
  96.                     break;
  97.                 default:
  98.                     puts("\nCould not determine if there is a working MMU.");
  99.             }
  100.         }
  101.          
  102.         /* -- Close Libraries -- */  
  103.         if (MMUBase)
  104.             CloseLibrary((struct Library *)MMUBase);  
  105.         if (DOSBase)
  106.             CloseLibrary((struct Library *)DOSBase);                
  107.    
  108.     return (retval);
  109. }
  110.  
  111.  
Tags: amiga MMU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement