Replace with completely new version derived from APECS code. No serious
bugs to fix (that i know of), just doing it that way was easiest.
This commit is contained in:
parent
56a6e33bb6
commit
c0b2b5595c
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: cia_pci.c,v 1.1 1995/11/23 02:37:29 cgd Exp $ */
|
||||
/* $NetBSD: cia_pci.c,v 1.2 1996/04/12 23:37:10 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Carnegie-Mellon University.
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author: Chris G. Demetriou
|
||||
|
@ -38,33 +38,83 @@
|
|||
#include <alpha/pci/ciareg.h>
|
||||
#include <alpha/pci/ciavar.h>
|
||||
|
||||
pci_confreg_t cia_conf_read __P((void *, pci_conftag_t, pci_confoffset_t));
|
||||
void cia_conf_write __P((void *, pci_conftag_t,
|
||||
pci_confoffset_t, pci_confreg_t));
|
||||
int cia_find_io __P((void *, pci_conftag_t,
|
||||
pci_confoffset_t, pci_iooffset_t *, pci_iosize_t *));
|
||||
int cia_find_mem __P((void *, pci_conftag_t,
|
||||
pci_confoffset_t, pci_moffset_t *, pci_msize_t *, int *));
|
||||
void cia_attach_hook __P((struct device *, struct device *,
|
||||
struct pcibus_attach_args *));
|
||||
int cia_bus_maxdevs __P((void *, int));
|
||||
pcitag_t cia_make_tag __P((void *, int, int, int));
|
||||
void cia_decompose_tag __P((void *, pcitag_t, int *, int *,
|
||||
int *));
|
||||
pcireg_t cia_conf_read __P((void *, pcitag_t, int));
|
||||
void cia_conf_write __P((void *, pcitag_t, int, pcireg_t));
|
||||
|
||||
__const struct pci_conf_fns cia_conf_fns = {
|
||||
cia_conf_read,
|
||||
cia_conf_write,
|
||||
cia_find_io,
|
||||
cia_find_mem,
|
||||
};
|
||||
void
|
||||
cia_pci_init(pc, v)
|
||||
pci_chipset_tag_t pc;
|
||||
void *v;
|
||||
{
|
||||
|
||||
pci_confreg_t
|
||||
pc->pc_conf_v = v;
|
||||
pc->pc_attach_hook = cia_attach_hook;
|
||||
pc->pc_bus_maxdevs = cia_bus_maxdevs;
|
||||
pc->pc_make_tag = cia_make_tag;
|
||||
pc->pc_decompose_tag = cia_decompose_tag;
|
||||
pc->pc_conf_read = cia_conf_read;
|
||||
pc->pc_conf_write = cia_conf_write;
|
||||
}
|
||||
|
||||
void
|
||||
cia_attach_hook(parent, self, pba)
|
||||
struct device *parent, *self;
|
||||
struct pcibus_attach_args *pba;
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
cia_bus_maxdevs(cpv, busno)
|
||||
void *cpv;
|
||||
int busno;
|
||||
{
|
||||
|
||||
return 32;
|
||||
}
|
||||
|
||||
pcitag_t
|
||||
cia_make_tag(cpv, b, d, f)
|
||||
void *cpv;
|
||||
int b, d, f;
|
||||
{
|
||||
|
||||
return (b << 16) | (d << 11) | (f << 8);
|
||||
}
|
||||
|
||||
void
|
||||
cia_decompose_tag(cpv, tag, bp, dp, fp)
|
||||
void *cpv;
|
||||
pcitag_t tag;
|
||||
int *bp, *dp, *fp;
|
||||
{
|
||||
|
||||
if (bp != NULL)
|
||||
*bp = (tag >> 16) & 0xff;
|
||||
if (dp != NULL)
|
||||
*dp = (tag >> 11) & 0x1f;
|
||||
if (fp != NULL)
|
||||
*fp = (tag >> 8) & 0x7;
|
||||
}
|
||||
|
||||
pcireg_t
|
||||
cia_conf_read(cpv, tag, offset)
|
||||
void *cpv;
|
||||
pci_conftag_t tag;
|
||||
pci_confoffset_t offset;
|
||||
pcitag_t tag;
|
||||
int offset;
|
||||
{
|
||||
struct cia_config *acp = cpv;
|
||||
pci_confreg_t *datap, data;
|
||||
struct cia_config *ccp = cpv;
|
||||
pcireg_t *datap, data;
|
||||
int s, secondary, ba;
|
||||
int32_t old_haxr2; /* XXX */
|
||||
|
||||
secondary = PCI_TAG_BUS(tag) != 0;
|
||||
/* secondary if bus # != 0 */
|
||||
pci_decompose_tag(&ccp->cc_pc, tag, &secondary, 0, 0);
|
||||
if (secondary) {
|
||||
s = splhigh();
|
||||
old_haxr2 = REGVAL(CIA_CSRS + 0x480); /* XXX */
|
||||
|
@ -73,12 +123,12 @@ cia_conf_read(cpv, tag, offset)
|
|||
wbflush();
|
||||
}
|
||||
|
||||
datap = (pci_confreg_t *)phystok0seg(CIA_PCI_CONF |
|
||||
datap = (pcireg_t *)phystok0seg(CIA_PCI_CONF |
|
||||
tag << 5UL | /* XXX */
|
||||
(offset & ~0x03) << 5 | /* XXX */
|
||||
0 << 5 | /* XXX */
|
||||
0x3 << 3); /* XXX */
|
||||
data = (pci_confreg_t)-1;
|
||||
data = (pcireg_t)-1;
|
||||
if (!(ba = badaddr(datap, sizeof *datap)))
|
||||
data = *datap;
|
||||
|
||||
|
@ -100,16 +150,17 @@ cia_conf_read(cpv, tag, offset)
|
|||
void
|
||||
cia_conf_write(cpv, tag, offset, data)
|
||||
void *cpv;
|
||||
pci_conftag_t tag;
|
||||
pci_confoffset_t offset;
|
||||
pci_confreg_t data;
|
||||
pcitag_t tag;
|
||||
int offset;
|
||||
pcireg_t data;
|
||||
{
|
||||
struct cia_config *acp = cpv;
|
||||
pci_confreg_t *datap;
|
||||
struct cia_config *ccp = cpv;
|
||||
pcireg_t *datap;
|
||||
int s, secondary;
|
||||
int32_t old_haxr2; /* XXX */
|
||||
|
||||
secondary = PCI_TAG_BUS(tag) != 0;
|
||||
/* secondary if bus # != 0 */
|
||||
pci_decompose_tag(&ccp->cc_pc, tag, &secondary, 0, 0);
|
||||
if (secondary) {
|
||||
s = splhigh();
|
||||
old_haxr2 = REGVAL(CIA_CSRS + 0x480); /* XXX */
|
||||
|
@ -118,7 +169,7 @@ cia_conf_write(cpv, tag, offset, data)
|
|||
wbflush();
|
||||
}
|
||||
|
||||
datap = (pci_confreg_t *)phystok0seg(CIA_PCI_CONF |
|
||||
datap = (pcireg_t *)phystok0seg(CIA_PCI_CONF |
|
||||
tag << 5UL | /* XXX */
|
||||
(offset & ~0x03) << 5 | /* XXX */
|
||||
0 << 5 | /* XXX */
|
||||
|
@ -137,86 +188,3 @@ cia_conf_write(cpv, tag, offset, data)
|
|||
reg, data, datap);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
cia_find_io(cpv, tag, reg, iobasep, sizep)
|
||||
void *cpv;
|
||||
pci_conftag_t tag;
|
||||
pci_confoffset_t reg;
|
||||
pci_iooffset_t *iobasep;
|
||||
pci_iosize_t *sizep;
|
||||
{
|
||||
struct cia_config *acp = cpv;
|
||||
pci_confreg_t addrdata, sizedata;
|
||||
pci_iooffset_t pci_iobase;
|
||||
|
||||
if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
|
||||
panic("cia_map_io: bad request");
|
||||
|
||||
addrdata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg);
|
||||
|
||||
PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, 0xffffffff);
|
||||
sizedata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg);
|
||||
PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, addrdata);
|
||||
|
||||
if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_MEM)
|
||||
panic("cia_map_io: attempt to I/O map an memory region");
|
||||
|
||||
if (iobasep != NULL)
|
||||
*iobasep = PCI_MAPREG_IO_ADDRESS(addrdata);
|
||||
if (sizep != NULL)
|
||||
*sizep = ~PCI_MAPREG_IO_ADDRESS(sizedata) + 1;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
cia_find_mem(cpv, tag, reg, paddrp, sizep, cacheablep)
|
||||
void *cpv;
|
||||
pci_conftag_t tag;
|
||||
pci_confoffset_t reg;
|
||||
pci_moffset_t *paddrp;
|
||||
pci_msize_t *sizep;
|
||||
int *cacheablep;
|
||||
{
|
||||
struct cia_config *acp = cpv;
|
||||
pci_confreg_t addrdata, sizedata;
|
||||
|
||||
if (reg < PCI_MAPREG_START || reg >= PCI_MAPREG_END || (reg & 3))
|
||||
panic("cia_map_mem: bad request");
|
||||
|
||||
/*
|
||||
* The PROM has mapped the device for us. We take the address
|
||||
* that's been assigned to the register, and figure out what
|
||||
* physical and virtual addresses go with it...
|
||||
*/
|
||||
addrdata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg);
|
||||
|
||||
PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, 0xffffffff);
|
||||
sizedata = PCI_CONF_READ(acp->cc_conffns, acp->cc_confarg, tag, reg);
|
||||
PCI_CONF_WRITE(acp->cc_conffns, acp->cc_confarg, tag, reg, addrdata);
|
||||
|
||||
if (PCI_MAPREG_TYPE(addrdata) == PCI_MAPREG_TYPE_IO)
|
||||
panic("cia_map_mem: attempt to memory map an I/O region");
|
||||
|
||||
switch (PCI_MAPREG_MEM_TYPE(addrdata)) {
|
||||
case PCI_MAPREG_MEM_TYPE_32BIT:
|
||||
case PCI_MAPREG_MEM_TYPE_32BIT_1M:
|
||||
break;
|
||||
case PCI_MAPREG_MEM_TYPE_64BIT:
|
||||
/* XXX */ printf("cia_map_mem: attempt to map 64-bit region\n");
|
||||
/* XXX */ break;
|
||||
default:
|
||||
printf("cia_map_mem: reserved mapping type\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (paddrp != NULL)
|
||||
*paddrp = PCI_MAPREG_MEM_ADDRESS(addrdata); /* PCI addr */
|
||||
if (sizep != NULL)
|
||||
*sizep = ~PCI_MAPREG_MEM_ADDRESS(sizedata) + 1;
|
||||
if (cacheablep != NULL)
|
||||
*cacheablep = PCI_MAPREG_MEM_CACHEABLE(addrdata);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue