/*-
* Copyright (c) 2000 Doug Rabson
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/sys/pci/agp_via.c,v 1.3 2001/07/05 21:28:47 jhb Exp $
*/
/*
* The size is determined by the number of low bits of
* register APBASE which are forced to zero. The low 20 bits
* are always forced to zero and each zero bit in the apsize
* field just read forces the corresponding bit in the 27:20
* to be zero. We calculate the aperture size accordingly.
*/
return (((apsize ^ 0xff) << 20) | ((1 << 20) - 1)) + 1;
} else {
apsize = pci_conf_read(sc->as_pc, sc->as_tag,
asc->regs[REG_APSIZE]) & 0xfff;
switch (apsize) {
case 0x800:
return 0x80000000;
case 0xc00:
return 0x40000000;
case 0xe00:
return 0x20000000;
case 0xf00:
return 0x10000000;
case 0xf20:
return 0x08000000;
case 0xf30:
return 0x04000000;
case 0xf38:
return 0x02000000;
case 0xf3c:
return 0x01000000;
case 0xf3e:
return 0x00800000;
case 0xf3f:
return 0x00400000;
default:
aprint_error_dev(sc->as_dev,
"invalid aperture setting 0x%x\n", apsize);
return 0;
}
}
}