(c)  Copyright 1989 Commodore-Amiga, Inc.   All rights reserved.
The information contained herein is subject to change without notice, and 
is provided "as is" without warranty of any kind, either expressed or implied.  
The entire risk as to the use of this information is assumed by the user.



                     Your Manufacturer Number    

                          by Dan Baker


     Attention hardware manufacturers.  If you are developing a hardware
expansion product for the Amiga then you will need to obtain a special
manufacturer i.d. number from CATS to identify your product.  This
manufacturer number is used by the Amiga to link your hardware with its
driver software at boot time.

     Your manufacturer number is part of the special protocol that the Amiga
uses to automatically configure all expansion devices on the bus without the
user having to cut jumpers or adjust dip switches.  This is called
auto-config.

     At start-up time, the system first polls each board in the system and
assigns the board its own address space.  If it is a memory board, its RAM
is linked into the memory free pool.  Later in the boot sequence, after DOS
is initialized, the binddrivers program is run.  Binddrivers will search the
directory SYS:Expansion for the drivers that go with the boards.

     To do this binddrivers looks in the Tool Type field of all icon files
in SYS:Expansion.  If the first seven bytes of the Tool Type field are
"PRODUCT", then this is an icon file for a driver.

     Binddrivers will then attempt to match the drivers it has found with
the boards that were found earlier.  This is where your manufacturer number
comes in.

     Your manufacturer number goes in two places.  First, it is burned in
hex form into the PAL which is part of ALL auto-config expansion products.
Second, it appears in ASCII in the Tool Type field of the icon file for
your product's driver.  By matching these two numbers, the Amiga can
automatically configure your board and bind it's software driver into the
system as well.

     The manufacturer's number is a 16-bit i.d. which appears in PAL offsets
$10-$17.  There is also an 8-bit product number which you assign.  The
product number is for uniquely identifying different products from the same
vendor.  The product number will appear in PAL offsets $04-$07.  This gives
you a total of 24 bits to identify each of your products.

     These 24 bits of information in the PAL which identify your product are
matched against the information in the Tool Type field of all icon files in
the SYS:Expansion drawer.  For example, suppose you are manufacturer #1019.
You have two products, #1 and #2 which both use the same driver.  The icon
for your driver for these two products would have a Tool Type set to
"PRODUCT=1019/1|1019/2".  This means: I am an icon for a driver that works
with product number 1 or 2 from manufacturer 1019, now bind me.  Spaces are
not legal.  Here are two other examples:

        PRODUCT=1208/11    is the Tool Type for a driver for product
                           11 from manufacturer number 1208.

        PRODUCT=1017       is the Tool Type for a driver for any
                           product from manufacturer number 1017.


     For an informal explanation of the auto-configuration process, see the
chapter on Software Expansion Architecture from the 2nd Annual Amiga
Developer's Conference Notes (available from CATS, $20).  For the details
of timing, power, the PAL equations and PAL address specifications and the
expansion library documentation, see sections 3.1 to 3.3 of the A500/A2000
Technical Reference Manual ($40).  The original auto-config spec appears in
the A1000 Schematics and Expansion Specification ($20).  All three of these
manuals are available from CATS at the address listed below.

     Manufacturer's numbers are assigned by CATS.  Your manufacturer number
is NOT the same as your developer number.  To obtain your unique
manufacturer number contact:

                 CATS, Commodore-Amiga Technical Support
                 1200 Wilson Dr.
                 West Chester, PA
                 19380
                 215-431-9300

     Be sure and include your name, address, phone number and the type of
expansion product you are developing.  For those doing prototype boards,
we have a temporary hacker's number set aside.

     The auto-config process makes the addition of expansion products to the
system very easy.  All the user has to do is put the board in any slot and
copy the driver from the release disk to his own SYS:Expansion drawer.
Everything else is automatic.  There are no jumpers or dip switches to set.
Best of all, you will get a lot less support calls asking how to make your
product work with the XYZ-Corp-battery-backed-clock.


------------------------Code Starts Here---------------------------
     
/*-----------------------------------------------*/
/* Here is a short program which will tell you   */
/* about the expansion boards configured in your */
/* system without you opening up the machine.    */
/* Code by Bill Koester of CATS                  */
/*-----------------------------------------------*/
#include <libraries/configvars.h>
#include <libraries/expansion.h>

struct ExpansionBase *ExpansionBase;

void main();
void cleanup();
void printdev();

void main()
{
   struct ConfigDev *MyConfigDev;

   /*----------------------------------*/
   /* Open the expansion library,      */
   /* if there is a problem then exit  */
   /*----------------------------------*/

   ExpansionBase =(struct ExpansionBase *) OpenLibrary(EXPANSIONNAME,0);
   if(ExpansionBase==NULL)
   {
      printf("Error opening expansion library!!\n");
      cleanup();
      exit(0);
   }

   /*--------------------------------------------*/
   /* Use FindConfigDev to get info on the first */
   /* expansion board on the list maintained by  */
   /* Exec.  If there are no expansion boards in */
   /* the system then exit.                      */
   /*--------------------------------------------*/

   MyConfigDev = NULL;

  /*--------------------------------------------------*/
  /* FindConfigDev(oldConfigDev,manufacturer,product) */
  /* oldConfigDev = NULL for the top of the list      */
  /* manufacturer = -1 for any manufacturer           */
  /* product      = -1 for any product                */
  /*--------------------------------------------------*/

   MyConfigDev = FindConfigDev(NULL,-1,-1);

   if(MyConfigDev==NULL)
   {
      printf("No Configured Devices found!!\n");
      cleanup();
      exit(0);
   }

   printdev(MyConfigDev);

   /*-----------------------------------*/
   /* OK, there is at least one board,  */
   /* so loop and get the entire list   */
   /* printing as we go with printdev() */
   /*-----------------------------------*/

   while(MyConfigDev = FindConfigDev(MyConfigDev,-1,-1))
   {
      printdev(MyConfigDev);
   }
   cleanup();
}


/*-------------------*/
/* Close up shop...  */
/*-------------------*/
void cleanup()
{
   if(ExpansionBase)
      CloseLibrary(ExpansionBase);
}

/*----------------------------------*/
/* Print out the contents of the    */
/* dev structure for this expansion */
/* product.                         */
/*----------------------------------*/

void printdev(dev)
struct ConfigDev *dev;
{
   char buff[200];

   printf("Flags          = ");
   if(dev->cd_Flags==NULL)
      printf("NULL  ");
   if(dev->cd_Flags&CDF_SHUTUP)
      printf("CDF_SHUTUP  ");
   if(dev->cd_Flags&CDF_CONFIGME)
      printf("CDF_CONFIGME  ");
   printf("\n");
   printf("Board Address  = %x\n",dev->cd_BoardAddr);
   printf("Board Size     = %d bytes\n",dev->cd_BoardSize);
   printf("Slot  Address  = %d\n",dev->cd_SlotAddr);
   printf("Slot  Size     = %d\n",dev->cd_SlotSize);
   printf("Driver code at   %x\n",dev->cd_Driver);

   printf("er_Type         = %x\n",dev->cd_Rom.er_Type);
   printf("er_Product      = %x\n",dev->cd_Rom.er_Product);
   printf("er_Flags        = %x\n",dev->cd_Rom.er_Flags);
   printf("er_Reserved03   = %x\n",dev->cd_Rom.er_Reserved03);
   printf("er_Manufacturer = %x\n",dev->cd_Rom.er_Manufacturer);
   printf("er_SerialNumber = %x\n",dev->cd_Rom.er_SerialNumber);
   printf("er_InitDiagVec  = %x\n",dev->cd_Rom.er_InitDiagVec);
   printf("er_Reserved0c   = %x\n",dev->cd_Rom.er_Reserved0c);
   printf("er_Reserved0d   = %x\n",dev->cd_Rom.er_Reserved0d);
   printf("er_Reserved0e   = %x\n",dev->cd_Rom.er_Reserved0e);
   printf("er_Reserved0f   = %x\n",dev->cd_Rom.er_Reserved0f);

   printf("Hit Return to continue:\n");
   gets(buff);
}
