Browse Source

pci: _pci_alloc_io, _pci_alloc_mem call weak function pci_alloc_fixmemio first, to be redefined for ls2k.

Change-Id: I558a4fc4fcc470de41b71524c4c264d47c08016f
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 6 years ago
parent
commit
075e7b2f77
  1. 14
      sys/dev/pci/pciconf.c

14
sys/dev/pci/pciconf.c

@ -87,6 +87,7 @@ static void _insertsort_window(struct pci_win **, struct pci_win *);
static void _pci_device_insert(struct pci_device *parent, struct pci_device *device);
pcireg_t _pci_allocate_mem __P((struct pci_device *, vm_size_t, unsigned int));
pcireg_t _pci_allocate_io __P((struct pci_device *, vm_size_t, unsigned int));
pcireg_t __attribute__((weak)) pci_alloc_fixmemio(struct pci_win *pm);
static void _setup_pcibuses(int );
static void _pci_bus_insert(struct pci_bus *);
@ -894,6 +895,11 @@ _pci_query_dev (struct pci_device *dev, int bus, int device, int initialise)
}
}
pcireg_t __attribute__((weak)) pci_alloc_fixmemio(struct pci_win *pm)
{
return -1;
}
pcireg_t
_pci_allocate_mem(dev, size, align)
struct pci_device *dev;
@ -989,6 +995,8 @@ _pci_setup_windows (struct pci_device *dev)
if(pd->bridge.child) align = ~pd->bridge.mem_mask+1;
else align = 1<<(fls(pm->size)-1);
pm->address = pci_alloc_fixmemio(pm);
if(pm->address == -1)
pm->address = _pci_allocate_mem (dev, pm->size, align);
if (pm->address == -1) {
pci_bigmem_address = (pci_bigmem_address + pm->size-1) & ~(pm->size - 1);
@ -1016,8 +1024,12 @@ _pci_setup_windows (struct pci_device *dev)
memory = (((pm->address+pm->size-1) >> 16) << 16) | (pm->address >> 16);
_pci_conf_write(pd->pa.pa_tag, pm->reg, memory);
#ifdef LOONGSON_2K
_pci_conf_write(pd->pa.pa_tag,PCI_PMBASEL_1, memory);
#else
/*set end memory bellow start memory to disable prefectable memory*/
_pci_conf_write(pd->pa.pa_tag,PCI_PMBASEL_1,0x00000010);
#endif
} else if (pm->reg != PCI_MAPREG_ROM) {
/* normal memory - expansion rom done below */
@ -1104,6 +1116,8 @@ _pci_setup_windows (struct pci_device *dev)
if(pd->bridge.child) align = ~pd->bridge.io_mask+1;
else align = 1<<(fls(pm->size)-1);
pm->address = pci_alloc_fixmemio(pm);
if(pm->address == -1)
pm->address = _pci_allocate_io (dev, pm->size, align);
if (pm->address == -1) {
_pci_tagprintf (pd->pa.pa_tag,

Loading…
Cancel
Save