Changeset 663f41c4 in mainline for uspace/drv/pciintel/pci.h


Ignore:
Timestamp:
2010-10-23T10:56:44Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5291411
Parents:
49698fa
Message:

Cstyle fixes in pciintel.

File:
1 edited

Legend:

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

    r49698fa r663f41c4  
    11/*
    2  * Copyright (c) 2010 Lenka Trochtova 
     2 * Copyright (c) 2010 Lenka Trochtova
    33 * All rights reserved.
    44 *
     
    3232/** @file
    3333 */
    34  
    35 #ifndef PCI_H
    36 #define PCI_H
    3734
     35#ifndef PCI_H_
     36#define PCI_H_
    3837
    3938#include <stdlib.h>
     
    5453} pci_dev_data_t;
    5554
    56 void create_pci_match_ids(device_t *dev);
     55extern void create_pci_match_ids(device_t *);
    5756
    58 uint8_t pci_conf_read_8(device_t *dev, int reg);
    59 uint16_t pci_conf_read_16(device_t *dev, int reg);
    60 uint32_t pci_conf_read_32(device_t *dev, int reg);
    61 void pci_conf_write_8(device_t *dev, int reg, uint8_t val);
    62 void pci_conf_write_16(device_t *dev, int reg, uint16_t val);
    63 void pci_conf_write_32(device_t *dev, int reg, uint32_t val);
     57extern uint8_t pci_conf_read_8(device_t *, int);
     58extern uint16_t pci_conf_read_16(device_t *, int);
     59extern uint32_t pci_conf_read_32(device_t *, int);
     60extern void pci_conf_write_8(device_t *, int, uint8_t);
     61extern void pci_conf_write_16(device_t *, int, uint16_t);
     62extern void pci_conf_write_32(device_t *, int, uint32_t);
    6463
    65 void pci_add_range(device_t *dev, uint64_t range_addr, size_t range_size, bool io);
    66 int pci_read_bar(device_t *dev, int addr);
    67 void pci_read_interrupt(device_t *dev);
    68 void pci_add_interrupt(device_t *dev, int irq);
     64extern void pci_add_range(device_t *, uint64_t, size_t, bool);
     65extern int pci_read_bar(device_t *, int);
     66extern void pci_read_interrupt(device_t *);
     67extern void pci_add_interrupt(device_t *, int);
    6968
    70 void pci_bus_scan(device_t *parent, int bus_num);
     69extern void pci_bus_scan(device_t *, int);
    7170
    72 
    73 static inline pci_dev_data_t *create_pci_dev_data()
     71static inline pci_dev_data_t *create_pci_dev_data(void)
    7472{
    75         pci_dev_data_t *res = (pci_dev_data_t *)malloc(sizeof(pci_dev_data_t));
    76         if (NULL != res) {
     73        pci_dev_data_t *res = (pci_dev_data_t *) malloc(sizeof(pci_dev_data_t));
     74       
     75        if (NULL != res)
    7776                memset(res, 0, sizeof(pci_dev_data_t));
    78         }
    79         return res;     
     77        return res;
    8078}
    8179
    82 static inline void init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn)
     80static inline void
     81init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn)
    8382{
    8483        d->bus = bus;
    8584        d->dev = dev;
    86         d->fn = fn;     
     85        d->fn = fn;
    8786}
    8887
    89 static inline void delete_pci_dev_data(pci_dev_data_t *d) 
     88static inline void delete_pci_dev_data(pci_dev_data_t *d)
    9089{
    9190        if (NULL != d) {
    9291                clean_hw_resource_list(&d->hw_resources);
    93                 free(d);       
     92                free(d);
    9493        }
    9594}
     
    9796static inline void create_pci_dev_name(device_t *dev)
    9897{
    99         pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
     98        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
    10099        char *name = NULL;
    101         asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, dev_data->fn);
     100       
     101        asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev,
     102            dev_data->fn);
    102103        dev->name = name;
    103104}
     
    106107{
    107108        pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
    108         dev_data->hw_resources.resources = (hw_resource_t *)malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
    109         return dev_data->hw_resources.resources != NULL;       
     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;
    110113}
    111114
    112115static inline void pci_clean_resource_list(device_t *dev)
    113116{
    114         pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
     117        pci_dev_data_t *dev_data = (pci_dev_data_t *) dev->driver_data;
     118       
    115119        if (NULL != dev_data->hw_resources.resources) {
    116120                free(dev_data->hw_resources.resources);
     
    119123}
    120124
    121 /** Read the base address registers (BARs) of the device
    122  *  and adds the addresses to its hw resource list.
    123  * 
     125/** Read the base address registers (BARs) of the device and adds the addresses
     126 * to its hw resource list.
     127 *
    124128 * @param dev the pci device.
    125129 */
    126130static inline  void pci_read_bars(device_t *dev)
    127131{
    128         // position of the BAR in the PCI configuration address space of the device
     132        /*
     133         * Position of the BAR in the PCI configuration address space of the
     134         * device.
     135         */
    129136        int addr = PCI_BASE_ADDR_0;
    130137       
    131         while (addr <= PCI_BASE_ADDR_5) {
    132                 addr = pci_read_bar(dev, addr);
    133         }       
     138        while (addr <= PCI_BASE_ADDR_5)
     139                addr = pci_read_bar(dev, addr);
    134140}
    135141
     
    139145}
    140146
    141 
    142147#endif
    143 
    144148
    145149/**
Note: See TracChangeset for help on using the changeset viewer.