[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/14] pci: make pci_parse_devfn() aware of func.
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 05/14] pci: make pci_parse_devfn() aware of func. |
Date: |
Mon, 6 Sep 2010 16:46:19 +0900 |
make pci_parse_devfn() aware of func. With func = NULL it behave as before.
This will be used later.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pci.c | 34 ++++++++++++++++++++++++++--------
hw/pci.h | 2 ++
2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index bb9ddea..f03b83e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -424,15 +424,18 @@ static void pci_set_default_subsystem_id(PCIDevice
*pci_dev)
}
/*
- * Parse [[<domain>:]<bus>:]<slot>, return -1 on error
+ * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
+ * [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
*/
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned
*slotp)
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+ unsigned int *slotp, unsigned int *funcp)
{
const char *p;
char *e;
unsigned long val;
unsigned long dom = 0, bus = 0;
- unsigned slot = 0;
+ unsigned int slot = 0;
+ unsigned int func = 0;
p = addr;
val = strtoul(p, &e, 16);
@@ -454,11 +457,24 @@ static int pci_parse_devaddr(const char *addr, int *domp,
int *busp, unsigned *s
}
}
- if (dom > 0xffff || bus > 0xff || val > 0x1f)
- return -1;
-
slot = val;
+ if (funcp != NULL) {
+ if (*e != '.')
+ return -1;
+
+ p = e + 1;
+ val = strtoul(p, &e, 16);
+ if (e == p)
+ return -1;
+
+ func = val;
+ }
+
+ /* if funcp == NULL func is 0 */
+ if (dom > 0xffff || bus > 0xff || slot > 0x1f || func > 7)
+ return -1;
+
if (*e)
return -1;
@@ -469,6 +485,8 @@ static int pci_parse_devaddr(const char *addr, int *domp,
int *busp, unsigned *s
*domp = dom;
*busp = bus;
*slotp = slot;
+ if (funcp != NULL)
+ *funcp = func;
return 0;
}
@@ -479,7 +497,7 @@ int pci_read_devaddr(Monitor *mon, const char *addr, int
*domp, int *busp,
if (!strncmp(addr, "pci_addr=", 9)) {
addr += 9;
}
- if (pci_parse_devaddr(addr, domp, busp, slotp)) {
+ if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
monitor_printf(mon, "Invalid pci address\n");
return -1;
}
@@ -496,7 +514,7 @@ PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
return pci_find_bus(pci_find_root_bus(0), 0);
}
- if (pci_parse_devaddr(devaddr, &dom, &bus, &slot) < 0) {
+ if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
return NULL;
}
diff --git a/hw/pci.h b/hw/pci.h
index 2ddba59..2b4c318 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -227,6 +227,8 @@ PCIBus *pci_find_bus(PCIBus *bus, int bus_num);
PCIDevice *pci_find_device(PCIBus *bus, int bus_num, int slot, int function);
PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+ unsigned int *slotp, unsigned int *funcp);
int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
unsigned *slotp);
--
1.7.1.1
- [Qemu-devel] [PATCH 01/14] RESEND apb: fix typo., (continued)
[Qemu-devel] [PATCH 10/14] pcie root port: implement pcie root port., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 04/14] pci: call hotplug callback even when not hotplug case for later use., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 06/14] pci_ids.h: add vendor id of Texus Intesruments., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 14/14] pcie/aer: glue aer error injection into qemu monitor., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 03/14] pci bridge: add helper function for ssvid capability., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 05/14] pci: make pci_parse_devfn() aware of func.,
Isaku Yamahata <=
[Qemu-devel] [PATCH 07/14] msi: implemented msi., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 13/14] pcie/hotplug: glue pushing attention button command. pcie_abp, Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 02/14] pci: consolidate pci_add_capability_at_offset() into pci_add_capability()., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 11/14] pcie upstream port: pci express switch upstream port., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 12/14] pcie downstream port: pci express switch downstream port., Isaku Yamahata, 2010/09/06
[Qemu-devel] [PATCH 08/14] pcie: helper functions for pcie extended capability., Isaku Yamahata, 2010/09/06