From 41f7459c2371473d388062bbec52dd235aeab9ba Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 7 Feb 2006 02:15:53 +0000 Subject: [PATCH] Added a get_pci_info() to pci_device_module_info. It was a bit too complicated to get a pci_info for a given pci_device before. The function is not very efficiently implemented, but I didn't see how to do that without more intrusive changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16267 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/drivers/bus/PCI.h | 3 +++ src/add-ons/kernel/bus_managers/pci/pci.h | 2 ++ .../kernel/bus_managers/pci/pci_device.c | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/headers/os/drivers/bus/PCI.h b/headers/os/drivers/bus/PCI.h index fcc5b478cc..a036939316 100644 --- a/headers/os/drivers/bus/PCI.h +++ b/headers/os/drivers/bus/PCI.h @@ -110,6 +110,9 @@ typedef struct pci_device_module_info { status_t (*allocate_ioports)( uint16 ioport_base, size_t len, const char *name ); status_t (*release_ioports)( uint16 ioport_base, size_t len );*/ + + status_t (*get_pci_info)(pci_device device, struct pci_info *info); + } pci_device_module_info; diff --git a/src/add-ons/kernel/bus_managers/pci/pci.h b/src/add-ons/kernel/bus_managers/pci/pci.h index 55591e1e43..b099682031 100644 --- a/src/add-ons/kernel/bus_managers/pci/pci.h +++ b/src/add-ons/kernel/bus_managers/pci/pci.h @@ -8,6 +8,8 @@ #ifndef __PCI_H__ #define __PCI_H__ +#include + #include "pci_controller.h" diff --git a/src/add-ons/kernel/bus_managers/pci/pci_device.c b/src/add-ons/kernel/bus_managers/pci/pci_device.c index a9e194ab0f..9432f9b20e 100644 --- a/src/add-ons/kernel/bus_managers/pci/pci_device.c +++ b/src/add-ons/kernel/bus_managers/pci/pci_device.c @@ -17,6 +17,7 @@ #include #include +#include "pci.h" #include "pci_priv.h" @@ -96,6 +97,26 @@ pci_device_ram_address(pci_device_info *device, } +static status_t +pci_device_get_pci_info(pci_device device, struct pci_info *info) +{ + int i; + + if (device == NULL || info == NULL) + return B_BAD_VALUE; + + // TODO: Implement more efficiently! + for (i = 0; pci_get_nth_pci_info(i, info) == B_OK; i++) { + if (device->bus == info->bus && device->device == info->device + && device->function == info->function) { + return B_OK; + } + } + + return B_ENTRY_NOT_FOUND; +} + + static status_t pci_device_init_driver(device_node_handle node, void *user_cookie, void **cookie) { @@ -203,4 +224,6 @@ pci_device_module_info gPCIDeviceModule = { pci_device_write_pci_config, pci_device_ram_address, + + pci_device_get_pci_info, };