Changeset b25970f in mainline for uspace/drv/platform


Ignore:
Timestamp:
2018-10-29T14:11:39Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
94ab1fee
Parents:
184f2f8a
git-author:
Jiri Svoboda <jiri@…> (2018-10-28 22:10:25)
git-committer:
Jiri Svoboda <jiri@…> (2018-10-29 14:11:39)
Message:

Fix ISA-only PC support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/platform/pc/pc.c

    r184f2f8a rb25970f  
    11/*
     2 * Copyright (c) 2018 Jiri Svoboda
    23 * Copyright (c) 2010 Lenka Trochtova
    34 * All rights reserved.
     
    9394};
    9495
    95 static pc_fun_t pci_data = {
     96static pc_fun_t sys_data = {
    9697        .hw_resources = {
    9798                sizeof(pci_conf_regs) / sizeof(pci_conf_regs[0]),
     
    151152static ddf_dev_ops_t pc_fun_ops;
    152153
    153 static bool
    154 pc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
    155     pc_fun_t *fun_proto)
    156 {
    157         ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
    158 
     154static errno_t pc_add_sysbus(ddf_dev_t *dev)
     155{
    159156        ddf_fun_t *fnode = NULL;
    160157        errno_t rc;
    161158
     159        ddf_msg(LVL_DEBUG, "Adding system bus.");
     160
    162161        /* Create new device. */
    163         fnode = ddf_fun_create(dev, fun_inner, name);
    164         if (fnode == NULL)
    165                 goto failure;
     162        fnode = ddf_fun_create(dev, fun_inner, "sys");
     163        if (fnode == NULL) {
     164                rc = ENOMEM;
     165                goto error;
     166        }
    166167
    167168        pc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(pc_fun_t));
    168         *fun = *fun_proto;
    169 
    170         /* Add match ID */
    171         rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
     169        *fun = sys_data;
     170
     171        /* Add match IDs */
     172        rc = ddf_fun_add_match_id(fnode, "intel_pci", 100);
    172173        if (rc != EOK)
    173                 goto failure;
     174                goto error;
     175
     176        rc = ddf_fun_add_match_id(fnode, "isa", 10);
     177        if (rc != EOK)
     178                goto error;
    174179
    175180        /* Set provided operations to the device. */
     
    177182
    178183        /* Register function. */
    179         if (ddf_fun_bind(fnode) != EOK) {
    180                 ddf_msg(LVL_ERROR, "Failed binding function %s.", name);
    181                 goto failure;
    182         }
    183 
    184         return true;
    185 
    186 failure:
     184        rc = ddf_fun_bind(fnode);
     185        if (rc != EOK) {
     186                ddf_msg(LVL_ERROR, "Failed binding system bus function.");
     187                goto error;
     188        }
     189
     190        return EOK;
     191
     192error:
    187193        if (fnode != NULL)
    188194                ddf_fun_destroy(fnode);
    189195
    190         ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);
    191 
    192         return false;
    193 }
    194 
    195 static bool pc_add_functions(ddf_dev_t *dev)
    196 {
    197         return pc_add_fun(dev, "pci0", "intel_pci", &pci_data);
     196        ddf_msg(LVL_ERROR, "Failed adding system bus.");
     197        return rc;
     198}
     199
     200static errno_t pc_add_functions(ddf_dev_t *dev)
     201{
     202        errno_t rc;
     203
     204        rc = pc_add_sysbus(dev);
     205        if (rc != EOK)
     206                return rc;
     207
     208        return EOK;
    198209}
    199210
     
    206217static errno_t pc_dev_add(ddf_dev_t *dev)
    207218{
     219        errno_t rc;
     220
    208221        ddf_msg(LVL_DEBUG, "pc_dev_add, device handle = %d",
    209222            (int)ddf_dev_get_handle(dev));
    210223
    211224        /* Register functions. */
    212         if (!pc_add_functions(dev)) {
     225        rc = pc_add_functions(dev);
     226        if (rc != EOK) {
    213227                ddf_msg(LVL_ERROR, "Failed to add functions for PC platform.");
     228                return rc;
    214229        }
    215230
Note: See TracChangeset for help on using the changeset viewer.