Changeset 713a4b9 in mainline for uspace/drv/pciintel/pci.c


Ignore:
Timestamp:
2010-10-23T17:39:53Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8304889
Parents:
791f58c
Message:

Convert inline functions to regular functions in pciintel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/pciintel/pci.c

    r791f58c r713a4b9  
    513513}
    514514
     515pci_dev_data_t *create_pci_dev_data(void)
     516{
     517        pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t));
     518       
     519        if (NULL != res)
     520                memset(res, 0, sizeof(pci_dev_data_t));
     521        return res;
     522}
     523
     524void init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn)
     525{
     526        d->bus = bus;
     527        d->dev = dev;
     528        d->fn = fn;
     529}
     530
     531void delete_pci_dev_data(pci_dev_data_t *d)
     532{
     533        if (NULL != d) {
     534                clean_hw_resource_list(&d->hw_resources);
     535                free(d);
     536        }
     537}
     538
     539void create_pci_dev_name(device_t *dev)
     540{
     541        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
     542        char *name = NULL;
     543       
     544        asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev,
     545            dev_data->fn);
     546        dev->name = name;
     547}
     548
     549bool pci_alloc_resource_list(device_t *dev)
     550{
     551        pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
     552       
     553        dev_data->hw_resources.resources =
     554            (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
     555        return dev_data->hw_resources.resources != NULL;
     556}
     557
     558void pci_clean_resource_list(device_t *dev)
     559{
     560        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
     561       
     562        if (NULL != dev_data->hw_resources.resources) {
     563                free(dev_data->hw_resources.resources);
     564                dev_data->hw_resources.resources = NULL;
     565        }
     566}
     567
     568/** Read the base address registers (BARs) of the device and adds the addresses
     569 * to its hw resource list.
     570 *
     571 * @param dev the pci device.
     572 */
     573void pci_read_bars(device_t *dev)
     574{
     575        /*
     576         * Position of the BAR in the PCI configuration address space of the
     577         * device.
     578         */
     579        int addr = PCI_BASE_ADDR_0;
     580       
     581        while (addr <= PCI_BASE_ADDR_5)
     582                addr = pci_read_bar(dev, addr);
     583}
     584
     585size_t pci_bar_mask_to_size(uint32_t mask)
     586{
     587        return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
     588}
     589
    515590int main(int argc, char *argv[])
    516591{
Note: See TracChangeset for help on using the changeset viewer.