atibus.c revision 32b578d3
1/* 2 * Copyright 1997 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@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 39const 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 */ 54static void 55ATIClaimResources 56( 57 ATIPtr pATI, 58 Bool Active 59) 60{ 61 62#ifndef AVOID_CPIO 63 64 resRange Resources[2] = {{0, 0, 0}, _END}; 65 66 /* Claim VGA and VGAWonder resources */ 67 if ((pATI->VGAAdapter) && (Active)) 68 { 69 /* 70 * 18800-x's are the only ATI controllers that decode all ISA aliases 71 * of VGA and VGA Wonder I/O ports. Other x8800's do not decode >any< 72 * VGA aliases, but do decode VGA Wonder aliases whose most significant 73 * nibble is zero. 74 */ 75 xf86ClaimFixedResources(resVgaShared, pATI->iEntity); 76 77 if (pATI->CPIO_VGAWonder) 78 { 79 Resources[0].type = ResShrIoSparse | ResBus; 80 Resources[0].rBase = pATI->CPIO_VGAWonder; 81 Resources[0].rMask = 0xF3FEU; 82 83 xf86ClaimFixedResources(Resources, pATI->iEntity); 84 85 (void)memcpy(pATI->VGAWonderResources, 86 Resources, SizeOf(Resources)); 87 } 88 } 89 90 if (!Active) 91 return; 92 93 /* Claim Mach64 sparse I/O resources */ 94 if ((pATI->CPIODecoding == SPARSE_IO)) 95 { 96 Resources[0].type = ResShrIoSparse | ResBus; 97 Resources[0].rBase = pATI->CPIOBase; 98 Resources[0].rMask = 0x03FCU; 99 100 xf86ClaimFixedResources(Resources, pATI->iEntity); 101 } 102 103#endif /* AVOID_CPIO */ 104 105} 106 107/* 108 * ATIClaimBusSlot -- 109 * 110 * Claim an adapter and register its resources. 111 */ 112int 113ATIClaimBusSlot 114( 115 Bool Active, 116 ATIPtr pATI 117) 118{ 119 if (pATI->iEntity >= 0) 120 ATIClaimResources(pATI, Active); 121 122 return pATI->iEntity; 123} 124