aboutsummaryrefslogtreecommitdiff
path: root/pci-arbiter/pcifs.c
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2019-11-03 21:35:57 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-11-03 21:37:57 +0100
commitb160d6f3b3cdcd6a293c33cd89dcc46ab54c3264 (patch)
treebabcc0b5db069672277131e914beef6d6b4dddc5 /pci-arbiter/pcifs.c
parent084e5a86e5eca77cec49e08e0d83fe8266eca91b (diff)
downloadhurd-b160d6f3b3cdcd6a293c33cd89dcc46ab54c3264.tar.gz
hurd-b160d6f3b3cdcd6a293c33cd89dcc46ab54c3264.tar.bz2
hurd-b160d6f3b3cdcd6a293c33cd89dcc46ab54c3264.zip
pci-arbiter: Use libpciaccess instead of embedding it
This patch removes all embedded pciaccess code from the arbiter and instead uses the external pciaccess library. * pci-arbiter/Makefile: * Remove pci_access.c and x86_pci.c from the sources. * pci-arbiter/func_files.c: * io_config_file: Use a harcoded PCI config size. * read_rom_file: Grab the full rom first, then return the requested amount. * pci-arbiter/main.c: * main: Call create_fs_tree() w/o pci_sys. Since it's not part of the translator anymore. * pci-arbiter/netfs_impl.c: * netfs_attempt_read: Send pci_device_cfg_read() as the read op. * netfs_attempt_write: Send pci_device_cfg_write() as the write op. * pci-arbiter/pci-ops.c: * S_pci_conf_read: Call libpciaccess' pci_device_cfg_read(). * S_pci_conf_write: Call libpciaccess' pci_device_cfg_write(). * S_pci_get_dev_rom: Set rom.base_addr to zero for the moment, until libpciaccess esposes it properly. * pci-arbiter/pci_access.c: Deleted * pci-arbiter/pci_access.h: Deleted * pci-arbiter/pcifs.c: * create_fs_tree: Remove the pci_sys parameter. Use libpciaccess' iterator. Use a hardcoded config space size. * pci-arbiter/pcifs.h: Definitions for changes in pcifs.c. * pci-arbiter/x86_pci.c: Deleted. * pci-arbiter/x86_pci.h: Deleted.
Diffstat (limited to 'pci-arbiter/pcifs.c')
-rw-r--r--pci-arbiter/pcifs.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/pci-arbiter/pcifs.c b/pci-arbiter/pcifs.c
index 3bf255bc..cc08fad0 100644
--- a/pci-arbiter/pcifs.c
+++ b/pci-arbiter/pcifs.c
@@ -134,7 +134,7 @@ init_file_system (file_t underlying_node, struct pcifs * fs)
}
error_t
-create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
+create_fs_tree (struct pcifs * fs)
{
error_t err = 0;
int c_domain, c_bus, c_dev, i, j;
@@ -144,11 +144,17 @@ create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
*func_parent, *list;
struct stat e_stat;
char entry_name[NAME_SIZE];
+ const struct pci_slot_match match =
+ { PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0 };
+ /* domain bus device func */
+ struct pci_device_iterator *iter;
nentries = 1; /* Skip root entry */
c_domain = c_bus = c_dev = -1;
- for (i = 0, device = pci_sys->devices; i < pci_sys->num_devices;
- i++, device++)
+ iter = pci_slot_match_iterator_create(&match);
+ device = pci_device_next(iter);
+
+ for (i = 0; device != NULL; i++, device = pci_device_next(iter) )
{
if (device->domain != c_domain)
{
@@ -181,6 +187,8 @@ create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
nentries++; /* + rom */
}
+ pci_iterator_destroy(iter);
+
list = realloc (fs->entries, nentries * sizeof (struct pcifs_dirent));
if (!list)
return ENOMEM;
@@ -189,8 +197,10 @@ create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
memset (e, 0, sizeof (struct pcifs_dirent));
c_domain = c_bus = c_dev = -1;
domain_parent = bus_parent = dev_parent = func_parent = 0;
- for (i = 0, device = pci_sys->devices; i < pci_sys->num_devices;
- i++, device++)
+ iter = pci_slot_match_iterator_create(&match);
+ device = pci_device_next(iter);
+
+ for (i = 0; device != NULL; i++, device = pci_device_next(iter))
{
if (device->domain != c_domain)
{
@@ -268,7 +278,7 @@ create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
e_stat = func_parent->stat;
e_stat.st_mode &= ~(S_IFDIR | S_IXUSR | S_IXGRP);
e_stat.st_mode |= S_IFREG | S_IWUSR | S_IWGRP;
- e_stat.st_size = device->config_size;
+ e_stat.st_size = PCI_CONFIG_SIZE; // FIXME: Hardcoded
/* Create config entry */
strncpy (entry_name, FILE_CONFIG_NAME, NAME_SIZE - 1);
@@ -312,6 +322,8 @@ create_fs_tree (struct pcifs * fs, struct pci_system * pci_sys)
}
}
+ pci_iterator_destroy(iter);
+
/* The root node points to the first element of the entry list */
fs->entries = list;
fs->num_entries = nentries;