Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 713a4b9 in mainline


Ignore:
Timestamp:
2010-10-23T17:39:53Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
8304889
Parents:
791f58c
Message:

Convert inline functions to regular functions in pciintel.

Location:
uspace/drv/pciintel
Files:
2 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{
  • uspace/drv/pciintel/pci.h

    r791f58c r713a4b9  
    6969extern void pci_bus_scan(device_t *, int);
    7070
    71 static inline pci_dev_data_t *create_pci_dev_data(void)
    72 {
    73         pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t));
    74        
    75         if (NULL != res)
    76                 memset(res, 0, sizeof(pci_dev_data_t));
    77         return res;
    78 }
     71extern pci_dev_data_t *create_pci_dev_data(void);
     72extern void init_pci_dev_data(pci_dev_data_t *, int, int, int);
     73extern void delete_pci_dev_data(pci_dev_data_t *);
     74extern void create_pci_dev_name(device_t *);
    7975
    80 static inline void
    81 init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn)
    82 {
    83         d->bus = bus;
    84         d->dev = dev;
    85         d->fn = fn;
    86 }
     76extern bool pci_alloc_resource_list(device_t *);
     77extern void pci_clean_resource_list(device_t *);
    8778
    88 static inline void delete_pci_dev_data(pci_dev_data_t *d)
    89 {
    90         if (NULL != d) {
    91                 clean_hw_resource_list(&d->hw_resources);
    92                 free(d);
    93         }
    94 }
    95 
    96 static inline void create_pci_dev_name(device_t *dev)
    97 {
    98         pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    99         char *name = NULL;
    100        
    101         asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev,
    102             dev_data->fn);
    103         dev->name = name;
    104 }
    105 
    106 static inline bool pci_alloc_resource_list(device_t *dev)
    107 {
    108         pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
    109        
    110         dev_data->hw_resources.resources =
    111             (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
    112         return dev_data->hw_resources.resources != NULL;
    113 }
    114 
    115 static inline void pci_clean_resource_list(device_t *dev)
    116 {
    117         pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    118        
    119         if (NULL != dev_data->hw_resources.resources) {
    120                 free(dev_data->hw_resources.resources);
    121                 dev_data->hw_resources.resources = NULL;
    122         }
    123 }
    124 
    125 /** Read the base address registers (BARs) of the device and adds the addresses
    126  * to its hw resource list.
    127  *
    128  * @param dev the pci device.
    129  */
    130 static inline  void pci_read_bars(device_t *dev)
    131 {
    132         /*
    133          * Position of the BAR in the PCI configuration address space of the
    134          * device.
    135          */
    136         int addr = PCI_BASE_ADDR_0;
    137        
    138         while (addr <= PCI_BASE_ADDR_5)
    139                 addr = pci_read_bar(dev, addr);
    140 }
    141 
    142 static inline size_t pci_bar_mask_to_size(uint32_t mask)
    143 {
    144         return ((mask & 0xfffffff0) ^ 0xffffffff) + 1;
    145 }
     79extern void pci_read_bars(device_t *);
     80extern size_t pci_bar_mask_to_size(uint32_t);
    14681
    14782#endif
Note: See TracChangeset for help on using the changeset viewer.