Home | History | Annotate | Line # | Download | only in src
      1 /*
      2  * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi (at) xfree86.org
      3  *
      4  * Permission to use, copy, modify, distribute, and sell this software and its
      5  * documentation for any purpose is hereby granted without fee, provided that
      6  * the above copyright notice appear in all copies and that both that copyright
      7  * notice and this permission notice appear in supporting documentation, and
      8  * that the name of Marc Aurele La France not be used in advertising or
      9  * publicity pertaining to distribution of the software without specific,
     10  * written prior permission.  Marc Aurele La France makes no representations
     11  * about the suitability of this software for any purpose.  It is provided
     12  * "as-is" without express or implied warranty.
     13  *
     14  * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO
     16  * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     18  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     19  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     20  * PERFORMANCE OF THIS SOFTWARE.
     21  */
     22 
     23 #ifdef HAVE_CONFIG_H
     24 #include "config.h"
     25 #endif
     26 
     27 #include <string.h>
     28 
     29 #include "ati.h"
     30 #include "atibus.h"
     31 #include "atichip.h"
     32 #include "atimach64io.h"
     33 #include "atistruct.h"
     34 
     35 /*
     36  * Definitions related to an adapter's system bus interface.
     37  */
     38 
     39 const char *ATIBusNames[] =
     40 {
     41     "PCI",
     42     "AGP"
     43 };
     44 
     45 /*
     46  * ATIClaimResources --
     47  *
     48  * This function registers most of the bus resources used by an adapter.  The
     49  * exceptions are PCI-configured resources and non-PCI non-AGP linear
     50  * apertures, both of which are registered by ATIPreInit().  This function also
     51  * attempts to register unshareable resources for inactive PCI adapters,
     52  * whether or not they are relocatable.
     53  */
     54 static void
     55 ATIClaimResources
     56 (
     57     ATIPtr pATI,
     58     Bool   Active
     59 )
     60 {
     61 
     62 #ifndef XSERVER_LIBPCIACCESS
     63 #ifndef AVOID_CPIO
     64 
     65     resRange Resources[2] = {{0, 0, 0}, _END};
     66 
     67     /* Claim VGA and VGAWonder resources */
     68     if ((pATI->VGAAdapter) && (Active))
     69     {
     70         /*
     71          * 18800-x's are the only ATI controllers that decode all ISA aliases
     72          * of VGA and VGA Wonder I/O ports.  Other x8800's do not decode >any<
     73          * VGA aliases, but do decode VGA Wonder aliases whose most significant
     74          * nibble is zero.
     75          */
     76         xf86ClaimFixedResources(resVgaShared, pATI->iEntity);
     77 
     78         if (pATI->CPIO_VGAWonder)
     79         {
     80             Resources[0].type = ResShrIoSparse | ResBus;
     81             Resources[0].rBase = pATI->CPIO_VGAWonder;
     82             Resources[0].rMask = 0xF3FEU;
     83 
     84             xf86ClaimFixedResources(Resources, pATI->iEntity);
     85 
     86             (void)memcpy(pATI->VGAWonderResources,
     87                 Resources, SizeOf(Resources));
     88         }
     89     }
     90 
     91     if (!Active)
     92         return;
     93 
     94     /* Claim Mach64 sparse I/O resources */
     95     if ((pATI->CPIODecoding == SPARSE_IO))
     96     {
     97         Resources[0].type = ResShrIoSparse | ResBus;
     98         Resources[0].rBase = pATI->CPIOBase;
     99         Resources[0].rMask = 0x03FCU;
    100 
    101         xf86ClaimFixedResources(Resources, pATI->iEntity);
    102     }
    103 
    104 #endif /* AVOID_CPIO */
    105 #endif
    106 }
    107 
    108 /*
    109  * ATIClaimBusSlot --
    110  *
    111  * Claim an adapter and register its resources.
    112  */
    113 int
    114 ATIClaimBusSlot
    115 (
    116     Bool      Active,
    117     ATIPtr    pATI
    118 )
    119 {
    120     if (pATI->iEntity >= 0)
    121         ATIClaimResources(pATI, Active);
    122 
    123     return pATI->iEntity;
    124 }
    125