Changeset 89ce401a in mainline


Ignore:
Timestamp:
2010-04-08T10:20:29Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2480e19
Parents:
5e598e0
Message:

fixed some bugs, parts of pci bus enumeration

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libc/include/ipc/dev_iface.h

    r5e598e0 r89ce401a  
    3232#include <ipc/ipc.h>
    3333#include <malloc.h>
     34#include <unistd.h>
    3435
    3536#define DEV_IFACE_FIRST IPC_FIRST_USER_METHOD
     
    8889static inline void clean_hw_resource_list(hw_resource_list_t *hw_res)
    8990{
    90         free(hw_res->resources);
    91         hw_res->resources = 0;
     91        if(NULL != hw_res->resources) {
     92                free(hw_res->resources);
     93                hw_res->resources = NULL;
     94        }
    9295        hw_res->count = 0;     
    9396}
  • uspace/srv/drivers/pciintel/pci.c

    r5e598e0 r89ce401a  
    150150}
    151151
     152void create_pci_match_ids(device_t *dev)
     153{
     154        pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
     155        match_id_t *match_id = NULL;   
     156        match_id = create_match_id();
     157        if (NULL != match_id) {
     158                asprintf(&match_id->id, "pci/ven=%04x,dev=%04x", dev_data->vendor_id, dev_data->device_id);
     159                match_id->score = 90;
     160                add_match_id(&dev->match_ids, match_id);
     161        }       
     162        // TODO add more ids (with subsys ids, using class id etc.)
     163}
     164
     165
    152166void pci_bus_scan(device_t *parent, int bus_num)
    153167{
     
    181195                        header_type = header_type & 0x7F; // clear the multifunction bit
    182196                       
    183                         // TODO initialize device - name, match ids, interfaces
    184                         // TODO register device
     197                        // TODO initialize device - interfaces, hw resources
     198                       
     199                        create_pci_dev_name(dev);
     200                        printf(NAME ": adding new device name %s.\n", dev->name);
     201                       
     202                        create_pci_match_ids(dev);
     203                       
     204                        if (!child_device_register(dev, parent)) {
     205                                clean_match_ids(&dev->match_ids);
     206                                free((char *)dev->name);
     207                                dev->name = NULL;
     208                                continue;
     209                        }
    185210                       
    186211                        if (header_type == PCI_HEADER_TYPE_BRIDGE || header_type == PCI_HEADER_TYPE_CARDBUS ) {
     
    219244        if (dev->parent_phone <= 0) {
    220245                printf(NAME ": pci_add_device failed to connect to the parent's driver.\n");
    221                 free(bus_data);
     246                delete_pci_bus_data(bus_data);
    222247                return false;
    223248        }
     
    227252        if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
    228253                printf(NAME ": pci_add_device failed to get hw resources for the device.\n");
    229                 free(bus_data);
     254                delete_pci_bus_data(bus_data);
    230255                ipc_hangup(dev->parent_phone);
    231256                return false;           
     
    243268        if (pio_enable(bus_data->conf_io_addr, 8, &bus_data->conf_addr_port)) {
    244269                printf(NAME ": failed to enable configuration ports.\n");
    245                 free(bus_data);
     270                delete_pci_bus_data(bus_data);
    246271                ipc_hangup(dev->parent_phone);
    247272                clean_hw_resource_list(&hw_resources);
     
    252277        dev->driver_data = bus_data;
    253278       
    254         // TODO scan the bus   
     279        // enumerate child devices
     280        printf(NAME ": scanning the bus\n");
    255281        pci_bus_scan(dev, 0);
    256282       
  • uspace/srv/drivers/pciintel/pci.h

    r5e598e0 r89ce401a  
    7474}
    7575
     76static inline void create_pci_dev_name(device_t *dev)
     77{
     78        pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
     79        char *name = NULL;
     80        asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, dev_data->fn);
     81        dev->name = name;
     82}
     83
     84void create_pci_match_ids(device_t *dev);
     85
    7686uint8_t pci_conf_read_8(device_t *dev, int reg);
    7787uint16_t pci_conf_read_16(device_t *dev, int reg);
Note: See TracChangeset for help on using the changeset viewer.