Skip to content

Commit

Permalink
Fix PCI to PCI bridge register bit field masks.
Browse files Browse the repository at this point in the history
Thanks to "Mike Durian" <durian@plutotech.com> for the very good
problem report and his support as a beta tester of this patch.
  • Loading branch information
stesser committed Nov 12, 1996
1 parent 62a1627 commit a8b6f7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 36 deletions.
37 changes: 6 additions & 31 deletions sys/pci/pci.c
@@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pci.c,v 1.23.4.5 1996/01/19 19:21:03 se Exp $
** $Id: pci.c,v 1.23.4.6 1996/06/26 04:36:49 davidg Exp $
**
** General subroutines for the PCI bus.
** pci_configure ()
Expand Down Expand Up @@ -773,23 +773,14 @@ pci_bus_config (void)
** Bridge was configured by the bios.
** Read out the mapped io region.
*/
u_int reg, data, mask;
unsigned reg;

reg = pci_conf_read (tag,
PCI_PCI_BRIDGE_IO_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_IO_REG, 0xFFFF);
data = pci_conf_read (tag,
PCI_PCI_BRIDGE_IO_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_IO_REG, reg & 0xffff);

mask = (0xFF00 ^ (data & 0xFF00)) | 0xFF;

this->pcicb_iobase =
PCI_PPB_IOBASE_EXTRACT (reg);
this->pcicb_iolimit =
PCI_PPB_IOLIMIT_EXTRACT(reg) | mask;
PCI_PPB_IOLIMIT_EXTRACT(reg);

/*
** Note the used io space.
Expand All @@ -804,25 +795,17 @@ pci_bus_config (void)
** Bridge was configured by the bios.
** Read out the mapped memory regions.
*/
u_int reg, data, mask;
unsigned reg;

/*
** non prefetchable memory
*/
reg = pci_conf_read (tag,
PCI_PCI_BRIDGE_MEM_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_MEM_REG, 0xFFFFFFFF);
data = pci_conf_read (tag,
PCI_PCI_BRIDGE_MEM_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_MEM_REG, reg);

mask = 0xFFFFFFFF ^ (data & 0xFFFF0000);
this->pcicb_membase =
PCI_PPB_MEMBASE_EXTRACT (reg);
this->pcicb_memlimit =
PCI_PPB_MEMLIMIT_EXTRACT(reg) | mask;
PCI_PPB_MEMLIMIT_EXTRACT(reg);

/*
** Register used memory space.
Expand All @@ -836,18 +819,10 @@ pci_bus_config (void)
*/
reg = pci_conf_read (tag,
PCI_PCI_BRIDGE_PMEM_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_PMEM_REG, 0xFFFFFFFF);
data = pci_conf_read (tag,
PCI_PCI_BRIDGE_PMEM_REG);
pci_conf_write(tag,
PCI_PCI_BRIDGE_PMEM_REG, reg);

mask = 0xFFFFFFFF ^ (data & 0xFFFF0000);
this->pcicb_p_membase=
PCI_PPB_MEMBASE_EXTRACT (reg);
this->pcicb_p_memlimit=
PCI_PPB_MEMLIMIT_EXTRACT(reg) | mask;
PCI_PPB_MEMLIMIT_EXTRACT(reg);

/*
** Register used memory space.
Expand Down
10 changes: 5 additions & 5 deletions sys/pci/pcireg.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
** $Id: pcireg.h,v 1.5.4.1 1996/01/19 19:15:36 se Exp $
** $Id: pcireg.h,v 1.5.4.2 1996/06/26 04:36:50 davidg Exp $
**
** Names for PCI configuration space registers.
**
Expand Down Expand Up @@ -173,11 +173,11 @@
#define PCI_SECONDARY_BUS_INSERT(x, y) (((x) & ~PCI_SECONDARY_BUS_MASK) | ((y) << 8))
#define PCI_SUBORDINATE_BUS_INSERT(x, y) (((x) & ~PCI_SUBORDINATE_BUS_MASK) | ((y) << 16))

#define PCI_PPB_IOBASE_EXTRACT(x) (((x) << 8) & 0xFF00)
#define PCI_PPB_IOLIMIT_EXTRACT(x) (((x) << 0) & 0xFF00)
#define PCI_PPB_IOBASE_EXTRACT(x) (((x) << 8) & 0xF000)
#define PCI_PPB_IOLIMIT_EXTRACT(x) (((x) << 0) & 0xF000 | 0x0FFF)

#define PCI_PPB_MEMBASE_EXTRACT(x) (((x) << 16) & 0xFFFF0000)
#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFFF0000)
#define PCI_PPB_MEMBASE_EXTRACT(x) (((x) << 16) & 0xFFF00000)
#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFF00000 | 0x000FFFFF)

/*
** Interrupt configuration register
Expand Down

0 comments on commit a8b6f7f

Please sign in to comment.