[OpenBIOS] [PATCH 2/5] pci: introduce ob_pci_is_bus_master_capable() function
Hervé Poussineau
hpoussin at reactos.org
Wed Dec 30 17:51:25 CET 2015
Hi,
Le 30/12/2015 17:44, Mark Cave-Ayland a écrit :
> This function indicates whether the device represented by the given PCI
> configuration is capable of becoming a bus master. Currently this information
> is encoded in the PCI bus pci_arch_t structure as an array of bitmaps similar
> to the Open Firmware bus-master-capable property with one entry per PCI bus.
>
> Currently we use a default maximum of 2 PCI buses, however this can always
> be extended at a later date if required.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
> ---
> openbios-devel/drivers/pci.c | 17 +++++++++++++++++
> openbios-devel/drivers/pci_database.h | 1 +
> openbios-devel/include/drivers/pci.h | 1 +
> 3 files changed, 19 insertions(+)
>
> diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c
> index 9405e28..0108a0d 100644
> --- a/openbios-devel/drivers/pci.c
> +++ b/openbios-devel/drivers/pci.c
> @@ -899,6 +899,23 @@ void ob_pci_enable_bus_master(const pci_config_t *config)
> pci_config_write16(addr, PCI_COMMAND, cmd);
> }
>
> +int ob_pci_is_bus_master_capable(const pci_config_t *config)
> +{
> + /* Return true if this device is bus-master capable, false otherwise */
> + uint32_t bus = PCI_BUS(config->dev);
> + uint32_t dev = PCI_DEV(config->dev);
> +
> + if (bus >= sizeof(arch->bus_master_capable)) {
> + return 0;
> + }
Here, you probably want sizeof(arch->bus_master_capable)/sizeof(arch->bus_master_capable[0]), or some macro which does the same thing.
> +
> + if (arch->bus_master_capable[bus] & (1U << dev)) {
> + return -1;
> + }
> +
> + return 0;
> +}
> +
> static void ob_pci_add_properties(phandle_t phandle,
> pci_addr addr, const pci_dev_t *pci_dev,
> const pci_config_t *config, int num_bars)
> diff --git a/openbios-devel/drivers/pci_database.h b/openbios-devel/drivers/pci_database.h
> index 9e8dc05..92234fc 100644
> --- a/openbios-devel/drivers/pci_database.h
> +++ b/openbios-devel/drivers/pci_database.h
> @@ -57,3 +57,4 @@ extern const pci_dev_t *pci_find_device(uint8_t class, uint8_t subclass,
> uint16_t product);
>
> extern void ob_pci_enable_bus_master(const pci_config_t *config);
> +extern int ob_pci_is_bus_master_capable(const pci_config_t *config);
> diff --git a/openbios-devel/include/drivers/pci.h b/openbios-devel/include/drivers/pci.h
> index 2eb5685..bee9183 100644
> --- a/openbios-devel/include/drivers/pci.h
> +++ b/openbios-devel/include/drivers/pci.h
> @@ -21,6 +21,7 @@ struct pci_arch_t {
> unsigned long rbase;
> unsigned long rlen;
> uint8_t irqs[4];
> + uint32_t bus_master_capable[2]; /* Default to 2 PCI buses */
> };
>
> extern const pci_arch_t *arch;
>
More information about the OpenBIOS
mailing list