home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / findboards.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  2.5 KB  |  81 lines

  1. ;/* findboards.c - Execute me to compile me with SAS C 5.10
  2. LC -b1 -cfistq -v -y -j73 findboards.c
  3. Blink FROM LIB:c.o,findboards.o TO findboards LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. */
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8. #include <libraries/dos.h>
  9. #include <libraries/configvars.h>
  10.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/expansion_protos.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16.  
  17. #ifdef LATTICE
  18. int CXBRK(void) { return(0); }  /* Disable Lattice CTRL/C handling */
  19. int chkabort(void) { return(0); }  /* really */
  20. #endif
  21.  
  22. struct Library   *ExpansionBase = NULL;
  23.  
  24. void main(int argc, char **argv)
  25. {
  26.     struct ConfigDev *myCD;
  27.     UWORD m,i;
  28.     UBYTE p,f,t;
  29.  
  30.     if((ExpansionBase=OpenLibrary("expansion.library",0L))==NULL)
  31.     exit(RETURN_FAIL);
  32.  
  33.     /*--------------------------------------------------*/
  34.     /* FindConfigDev(oldConfigDev,manufacturer,product) */
  35.     /* oldConfigDev = NULL for the top of the list      */
  36.     /* manufacturer = -1 for any manufacturer           */
  37.     /* product      = -1 for any product                */
  38.     /*--------------------------------------------------*/
  39.  
  40.     myCD = NULL;
  41.     while(myCD=FindConfigDev(myCD,-1L,-1L)) /* search for all ConfigDevs */
  42.     {
  43.     printf("\n---ConfigDev structure found at location $%lx---\n",myCD);
  44.  
  45.     /* These values were read directly from the board at expansion time */
  46.     printf("Board ID (ExpansionRom) information:\n");
  47.  
  48.     t = myCD->cd_Rom.er_Type;
  49.     m = myCD->cd_Rom.er_Manufacturer;
  50.     p = myCD->cd_Rom.er_Product;
  51.     f = myCD->cd_Rom.er_Flags;
  52.     i = myCD->cd_Rom.er_InitDiagVec;
  53.  
  54.     printf("er_Manufacturer         =%d=$%04x=(~$%4x)\n",m,m,(UWORD)~m);
  55.     printf("er_Product              =%d=$%02x=(~$%2x)\n",p,p,(UBYTE)~p);
  56.  
  57.     printf("er_Type                 =$%02x",myCD->cd_Rom.er_Type);
  58.     if(myCD->cd_Rom.er_Type & ERTF_MEMLIST)
  59.         printf("  (Adds memory to free list)\n");
  60.     else printf("\n");
  61.  
  62.     printf("er_Flags                =$%02x=(~$%2x)\n",f,(UBYTE)~f);
  63.     printf("er_InitDiagVec          =$%04x=(~$%4x)\n",i,(UWORD)~i);
  64.  
  65.  
  66.     /* These values are generated when the AUTOCONFIG(tm) software
  67.      * relocates the board
  68.      */
  69.     printf("Configuration (ConfigDev) information:\n");
  70.     printf("cd_BoardAddr            =$%lx\n",myCD->cd_BoardAddr);
  71.     printf("cd_BoardSize            =$%lx (%ldK)\n",
  72.            myCD->cd_BoardSize,((ULONG)myCD->cd_BoardSize)/1024);
  73.  
  74.     printf("cd_Flags                =$%x",myCD->cd_Flags);
  75.     if(myCD->cd_Flags & CDF_CONFIGME)
  76.         printf("\n");
  77.     else printf("  (driver clears CONFIGME bit)\n");
  78.     }
  79.     CloseLibrary(ExpansionBase);
  80. }
  81.