Changeset 3569955 in mainline


Ignore:
Timestamp:
2011-11-05T17:11:22Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5664cf64
Parents:
d5a78e28 (diff), 54de4836 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline

Location:
uspace
Files:
3 edited

Legend:

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

    rd5a78e28 r3569955  
    7878#define PCI_BUS_FROM_FUN(fun) ((fun)->busptr)
    7979
     80/** Max is 47, align to something nice. */
     81#define ID_MAX_STR_LEN 50
     82
    8083static hw_resource_list_t *pciintel_get_resources(ddf_fun_t *fnode)
    8184{
     
    225228        fibril_mutex_lock(&bus->conf_mutex);
    226229       
    227         uint32_t conf_addr;
    228         conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
     230        const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg);
    229231        void *addr = bus->conf_data_port + (reg & 3);
    230232       
     
    311313void pci_fun_create_match_ids(pci_fun_t *fun)
    312314{
    313         char *match_id_str;
    314315        int rc;
    315        
    316         asprintf(&match_id_str, "pci/ven=%04x&dev=%04x",
     316        char match_id_str[ID_MAX_STR_LEN];
     317
     318        /* Vendor ID & Device ID, length(incl \0) 22 */
     319        rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/ven=%04x&dev=%04x",
    317320            fun->vendor_id, fun->device_id);
    318 
    319         if (match_id_str == NULL) {
    320                 ddf_msg(LVL_ERROR, "Out of memory creating match ID.");
    321                 return;
     321        if (rc < 0) {
     322                ddf_msg(LVL_ERROR, "Failed creating match ID str: %s",
     323                    str_error(rc));
    322324        }
    323325
    324326        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90);
    325327        if (rc != EOK) {
    326                 ddf_msg(LVL_ERROR, "Failed adding match ID: %s",
     328                ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc));
     329        }
     330
     331        /* Class, subclass, prog IF, revision, length(incl \0) 47 */
     332        rc = snprintf(match_id_str, ID_MAX_STR_LEN,
     333            "pci/class=%02x&subclass=%02x&progif=%02x&revision=%02x",
     334            fun->class_code, fun->subclass_code, fun->prog_if, fun->revision);
     335        if (rc < 0) {
     336                ddf_msg(LVL_ERROR, "Failed creating match ID str: %s",
    327337                    str_error(rc));
    328338        }
    329        
    330         free(match_id_str);
    331        
    332         /* TODO add more ids (with subsys ids, using class id etc.) */
     339
     340        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 70);
     341        if (rc != EOK) {
     342                ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc));
     343        }
     344
     345        /* Class, subclass, prog IF, length(incl \0) 35 */
     346        rc = snprintf(match_id_str, ID_MAX_STR_LEN,
     347            "pci/class=%02x&subclass=%02x&progif=%02x",
     348            fun->class_code, fun->subclass_code, fun->prog_if);
     349        if (rc < 0) {
     350                ddf_msg(LVL_ERROR, "Failed creating match ID str: %s",
     351                    str_error(rc));
     352        }
     353
     354        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 60);
     355        if (rc != EOK) {
     356                ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc));
     357        }
     358
     359        /* Class, subclass, length(incl \0) 25 */
     360        rc = snprintf(match_id_str, ID_MAX_STR_LEN,
     361            "pci/class=%02x&subclass=%02x",
     362            fun->class_code, fun->subclass_code);
     363        if (rc < 0) {
     364                ddf_msg(LVL_ERROR, "Failed creating match ID str: %s",
     365                    str_error(rc));
     366        }
     367
     368        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 50);
     369        if (rc != EOK) {
     370                ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc));
     371        }
     372
     373        /* Class, length(incl \0) 13 */
     374        rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/class=%02x",
     375            fun->class_code);
     376        if (rc < 0) {
     377                ddf_msg(LVL_ERROR, "Failed creating match ID str: %s",
     378                    str_error(rc));
     379        }
     380
     381        rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 40);
     382        if (rc != EOK) {
     383                ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc));
     384        }
     385
     386        /* TODO add subsys ids, but those exist only in header type 0 */
    333387}
    334388
     
    481535                for (fnum = 0; multi && fnum < 8; fnum++) {
    482536                        pci_fun_init(fun, bus_num, dnum, fnum);
    483                         fun->vendor_id = pci_conf_read_16(fun,
    484                             PCI_VENDOR_ID);
    485                         fun->device_id = pci_conf_read_16(fun,
    486                             PCI_DEVICE_ID);
    487537                        if (fun->vendor_id == 0xffff) {
    488538                                /*
     
    511561                       
    512562                        fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name);
     563                        free(fun_name);
    513564                        if (fnode == NULL) {
    514565                                ddf_msg(LVL_ERROR, "Failed creating function.");
     
    516567                        }
    517568                       
    518                         free(fun_name);
    519569                        fun->fnode = fnode;
    520570                       
     
    691741        fun->dev = dev;
    692742        fun->fn = fn;
     743        fun->vendor_id = pci_conf_read_16(fun, PCI_VENDOR_ID);
     744        fun->device_id = pci_conf_read_16(fun, PCI_DEVICE_ID);
     745        fun->class_code = pci_conf_read_8(fun, PCI_BASE_CLASS);
     746        fun->subclass_code = pci_conf_read_8(fun, PCI_SUB_CLASS);
     747        fun->prog_if = pci_conf_read_8(fun, PCI_PROG_IF);
     748        fun->revision = pci_conf_read_8(fun, PCI_REVISION_ID);
    693749}
    694750
     
    711767bool pci_alloc_resource_list(pci_fun_t *fun)
    712768{
    713         fun->hw_resources.resources =
    714             (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t));
    715         return fun->hw_resources.resources != NULL;
     769        fun->hw_resources.resources = fun->resources;
     770        return true;
    716771}
    717772
    718773void pci_clean_resource_list(pci_fun_t *fun)
    719774{
    720         if (fun->hw_resources.resources != NULL) {
    721                 free(fun->hw_resources.resources);
    722                 fun->hw_resources.resources = NULL;
    723         }
     775        fun->hw_resources.resources = NULL;
    724776}
    725777
  • uspace/drv/bus/pci/pciintel/pci.h

    rd5a78e28 r3569955  
    6060        int vendor_id;
    6161        int device_id;
     62        uint8_t class_code;
     63        uint8_t subclass_code;
     64        uint8_t prog_if;
     65        uint8_t revision;
    6266        hw_resource_list_t hw_resources;
     67        hw_resource_t resources[PCI_MAX_HW_RES];
    6368} pci_fun_t;
    6469
  • uspace/lib/drv/generic/driver.c

    rd5a78e28 r3569955  
    970970       
    971971        match_id->id = str_dup(match_id_str);
    972         match_id->score = 90;
     972        match_id->score = match_score;
    973973       
    974974        add_match_id(&fun->match_ids, match_id);
Note: See TracChangeset for help on using the changeset viewer.