aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2023-09-27 15:41:10 +0200
committerHelge Deller <deller@gmx.de>2023-09-27 15:41:10 +0200
commit7c6087cd7d698135be9b899885624cb23d1e4b23 (patch)
tree34d66be37c1c638f4122473f65d7fb0fca7c40ca
parent0ada59604e5b66616617ead890534c3a7261fec6 (diff)
downloadseabios-hppa-7c6087cd7d698135be9b899885624cb23d1e4b23.zip
seabios-hppa-7c6087cd7d698135be9b899885624cb23d1e4b23.tar.gz
seabios-hppa-7c6087cd7d698135be9b899885624cb23d1e4b23.tar.bz2
detect all PCI devices on the busses
-rw-r--r--src/block.c2
-rw-r--r--src/boot.c4
-rw-r--r--src/fw/pciinit.c9
-rw-r--r--src/hw/pci.c58
-rw-r--r--src/parisc/malloc.c2
-rw-r--r--src/parisc/parisc.c4
6 files changed, 57 insertions, 22 deletions
diff --git a/src/block.c b/src/block.c
index 1b85154..ed08bb7 100644
--- a/src/block.c
+++ b/src/block.c
@@ -623,7 +623,7 @@ process_op_16(struct disk_op_s *op)
int
process_op(struct disk_op_s *op)
{
- dprintf(DEBUG_HDL_13, "disk_op d=%p lba=%d buf=%p count=%d cmd=%d\n"
+ if (0) dprintf(DEBUG_HDL_13, "disk_op d=%p lba=%d buf=%p count=%d cmd=%d\n"
, op->drive_fl, (u32)op->lba, op->buf_fl
, op->count, op->command);
diff --git a/src/boot.c b/src/boot.c
index 4aec948..cf1b2fe 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -178,7 +178,7 @@ loadBiosGeometry(void)
static BootDeviceLCHS *
boot_lchs_find(const char *glob)
{
- dprintf(1, "Searching bios-geometry for: %s\n", glob);
+ // dprintf(1, "Searching bios-geometry for: %s\n", glob);
int i;
for (i = 0; i < BiosGeometryCount; i++)
if (glob_prefix(glob, BiosGeometry[i].name))
@@ -291,7 +291,7 @@ loadBootOrder(void)
static int
find_prio(const char *glob)
{
- dprintf(1, "Searching bootorder for: %s\n", glob);
+ // dprintf(1, "Searching bootorder for: %s\n", glob);
int i;
for (i = 0; i < BootorderCount; i++)
if (glob_prefix(glob, Bootorder[i]))
diff --git a/src/fw/pciinit.c b/src/fw/pciinit.c
index abf5007..c4e60ae 100644
--- a/src/fw/pciinit.c
+++ b/src/fw/pciinit.c
@@ -539,8 +539,9 @@ static void dino_mem_addr_setup(struct pci_device *dev, void *arg)
static int astro_pci_slot_get_irq(struct pci_device *pci, int pin)
{
+ int bus = pci_bdf_to_bus(pci->bdf);
int slot = pci_bdf_to_dev(pci->bdf);
- return slot & 0x03;
+ return (bus + 1) * 4 + (slot & 0x03);
}
static void astro_mem_addr_setup(struct pci_device *dev, void *arg)
@@ -548,6 +549,7 @@ static void astro_mem_addr_setup(struct pci_device *dev, void *arg)
pcimem_start = LMMIO_DIST_BASE_ADDR;
pcimem_end = pcimem_start + LMMIO_DIST_BASE_SIZE / ROPES_PER_IOC;
+ MaxPCIBus = 4;
pci_slot_get_irq = astro_pci_slot_get_irq;
/* setup io address space */
@@ -633,7 +635,7 @@ pci_bios_init_bus_rec(int bus, u8 *pci_bus)
int bdf;
u16 class;
- dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
+ // dprintf(1, "PCI: %s bus = 0x%x\n", __func__, bus);
/* prevent accidental access to unintended devices */
foreachbdf(bdf, bus) {
@@ -718,6 +720,7 @@ pci_bios_init_bus(void)
pci_bios_init_bus_rec(0 /* host bus */, &pci_bus);
+dprintf(1,"EXTRA ROOTS %d\n", extraroots);
if (extraroots) {
while (pci_bus < 0xff) {
pci_bus++;
@@ -925,7 +928,7 @@ static int pci_bios_check_devices(struct pci_bus *busses)
busses[pci->secondary_bus].bus_dev = pci;
struct pci_bus *bus = &busses[pci_bdf_to_bus(pci->bdf)];
- if (!bus->bus_dev)
+ if (!bus->bus_dev && !CONFIG_PARISC)
/*
* Resources for all root busses go in busses[0]
*/
diff --git a/src/hw/pci.c b/src/hw/pci.c
index 7d8b19e..763ca39 100644
--- a/src/hw/pci.c
+++ b/src/hw/pci.c
@@ -40,13 +40,30 @@ static u32 ioconfig_cmd(u16 bdf, u32 addr)
* eg dev->hpa or 0xfee00000.
*/
-#define _pciport(x) (void *)((unsigned long)(x))
+/* each elroy has 0x2000 offset */
+#define ELROY_MAX_BUSSES 4
+static unsigned long elroy_offset(u16 bdf)
+{
+ static const int elroy_hpa_offsets[ELROY_MAX_BUSSES] = { 0x30000, 0x32000, 0x38000, 0x3c000 };
+ int bus = pci_bdf_to_bus(bdf);
+ if (bus >= ELROY_MAX_BUSSES)
+ return -1UL;
+ return elroy_hpa_offsets[bus] - elroy_hpa_offsets[0];
+}
+
+static void *elroy_port(unsigned long port, unsigned long offs)
+{
+ return (void *)(port + offs);
+}
void pci_config_writel(u16 bdf, u32 addr, u32 val)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- writel(_pciport(PORT_PCI_DATA), val);
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ writel(elroy_port(PORT_PCI_DATA, offs), val);
} else
if (!MODESEGMENT && mmconfig) {
writel(mmconfig_addr(bdf, addr), val);
@@ -59,8 +76,11 @@ void pci_config_writel(u16 bdf, u32 addr, u32 val)
void pci_config_writew(u16 bdf, u32 addr, u16 val)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- writew(_pciport(PORT_PCI_DATA + (addr & 2)), val);
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ writew(elroy_port(PORT_PCI_DATA + (addr & 2), offs), val);
} else
if (!MODESEGMENT && mmconfig) {
writew(mmconfig_addr(bdf, addr), val);
@@ -73,8 +93,11 @@ void pci_config_writew(u16 bdf, u32 addr, u16 val)
void pci_config_writeb(u16 bdf, u32 addr, u8 val)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- writeb(_pciport(PORT_PCI_DATA + (addr & 3)), val);
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ writeb(elroy_port(PORT_PCI_DATA + (addr & 3), offs), val);
} else
if (!MODESEGMENT && mmconfig) {
writeb(mmconfig_addr(bdf, addr), val);
@@ -87,8 +110,11 @@ void pci_config_writeb(u16 bdf, u32 addr, u8 val)
u32 pci_config_readl(u16 bdf, u32 addr)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- return readl(_pciport(PORT_PCI_DATA));
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return -1;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ return readl(elroy_port(PORT_PCI_DATA, offs));
} else
if (!MODESEGMENT && mmconfig) {
return readl(mmconfig_addr(bdf, addr));
@@ -101,8 +127,11 @@ u32 pci_config_readl(u16 bdf, u32 addr)
u16 pci_config_readw(u16 bdf, u32 addr)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- return readw(_pciport(PORT_PCI_DATA + (addr & 2)));
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return -1;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ return readw(elroy_port(PORT_PCI_DATA + (addr & 2), offs));
} else
if (!MODESEGMENT && mmconfig) {
return readw(mmconfig_addr(bdf, addr));
@@ -115,8 +144,11 @@ u16 pci_config_readw(u16 bdf, u32 addr)
u8 pci_config_readb(u16 bdf, u32 addr)
{
if (has_astro) {
- writel(_pciport(PORT_PCI_CMD), ioconfig_cmd(bdf, addr));
- return readb(_pciport(PORT_PCI_DATA + (addr & 3)));
+ unsigned long offs = elroy_offset(bdf);
+ if (offs == -1UL)
+ return -1;
+ writel(elroy_port(PORT_PCI_CMD, offs), ioconfig_cmd((u8)bdf, addr));
+ return readb(elroy_port(PORT_PCI_DATA + (addr & 3), offs));
} else
if (!MODESEGMENT && mmconfig) {
return readb(mmconfig_addr(bdf, addr));
diff --git a/src/parisc/malloc.c b/src/parisc/malloc.c
index 5f4d219..b4f56d5 100644
--- a/src/parisc/malloc.c
+++ b/src/parisc/malloc.c
@@ -35,7 +35,7 @@ malloc_palloc(struct zone_s *zone, u32 size, u32 align)
data = stackptr;
stackptr += size;
- dprintf(9, "malloc: size=%d align=%d ret=0x%lx\n" , size, align, data);
+ // dprintf(9, "malloc: size=%d align=%d ret=0x%lx\n" , size, align, data);
return data;
}
diff --git a/src/parisc/parisc.c b/src/parisc/parisc.c
index bba92fc..06a1d3c 100644
--- a/src/parisc/parisc.c
+++ b/src/parisc/parisc.c
@@ -2278,8 +2278,8 @@ void __VISIBLE start_parisc_firmware(void)
if (strcmp(str, "C3700") == 0) {
current_machine = &machine_C3700;
has_astro = 1;
- hppa_port_pci_cmd = 0xfed30000 + 0x040;
- hppa_port_pci_data = hppa_port_pci_cmd + 8;
+ hppa_port_pci_cmd = 0xfed30000 + 0x040;
+ hppa_port_pci_data = 0xfed30000 + 0x048;
}
parisc_devices = current_machine->device_list;
strtcpy(qemu_machine, str, sizeof(qemu_machine));