Changeset 79ae36dd in mainline for uspace/drv/pciintel/pci.c


Ignore:
Timestamp:
2011-06-08T19:01:55Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0eff68e
Parents:
764d71e
Message:

new async framework with integrated exchange tracking

  • strict isolation between low-level IPC and high-level async framework with integrated exchange tracking
    • each IPC connection is represented by an async_sess_t structure
    • each IPC exchange is represented by an async_exch_t structure
    • exchange management is either based on atomic messages (EXCHANGE_ATOMIC), locking (EXCHANGE_SERIALIZE) or connection cloning (EXCHANGE_CLONE)
  • async_obsolete: temporary compatibility layer to keep old async clients working (several pieces of code are currently broken, but only non-essential functionality)
  • IPC_M_PHONE_HANGUP is now method no. 0 (for elegant boolean evaluation)
  • IPC_M_DEBUG_ALL has been renamed to IPC_M_DEBUG
  • IPC_M_PING has been removed (VFS protocol now has VFS_IN_PING)
  • console routines in libc have been rewritten for better abstraction
  • additional use for libc-private header files (FILE structure opaque to the client)
  • various cstyle changes (typos, indentation, missing externs in header files, improved comments, etc.)
File:
1 edited

Legend:

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

    r764d71e r79ae36dd  
    5353#include <ipc/dev_iface.h>
    5454#include <ipc/irc.h>
    55 #include <ipc/ns.h>
     55#include <ns.h>
    5656#include <ipc/services.h>
    5757#include <sysinfo.h>
     
    9292        assert(fnode);
    9393        pci_fun_t *dev_data = (pci_fun_t *) fnode->driver_data;
    94 
     94       
    9595        sysarg_t apic;
    9696        sysarg_t i8259;
    97 
    98         int irc_phone = ENOTSUP;
    99 
     97       
     98        async_sess_t *irc_sess = NULL;
     99       
    100100        if (((sysinfo_get_value("apic", &apic) == EOK) && (apic))
    101101            || ((sysinfo_get_value("i8259", &i8259) == EOK) && (i8259))) {
    102                 irc_phone = service_connect_blocking(SERVICE_IRC, 0, 0);
    103         }
    104 
    105         if (irc_phone < 0) {
     102                irc_sess = service_connect_blocking(EXCHANGE_SERIALIZE,
     103                    SERVICE_IRC, 0, 0);
     104        }
     105       
     106        if (!irc_sess)
    106107                return false;
    107         }
    108 
     108       
    109109        size_t i = 0;
    110110        hw_resource_list_t *res = &dev_data->hw_resources;
     
    112112                if (res->resources[i].type == INTERRUPT) {
    113113                        const int irq = res->resources[i].res.interrupt.irq;
     114                       
     115                        async_exch_t *exch = async_exchange_begin(irc_sess);
    114116                        const int rc =
    115                             async_req_1_0(irc_phone, IRC_ENABLE_INTERRUPT, irq);
     117                            async_req_1_0(exch, IRC_ENABLE_INTERRUPT, irq);
     118                        async_exchange_end(exch);
     119                       
    116120                        if (rc != EOK) {
    117                                 async_hangup(irc_phone);
     121                                async_hangup(irc_sess);
    118122                                return false;
    119123                        }
    120124                }
    121125        }
    122 
    123         async_hangup(irc_phone);
     126       
     127        async_hangup(irc_sess);
    124128        return true;
    125129}
    126130
    127 static int pci_config_space_write_32(
    128     ddf_fun_t *fun, uint32_t address, uint32_t data)
     131static int pci_config_space_write_32(ddf_fun_t *fun, uint32_t address,
     132    uint32_t data)
    129133{
    130134        if (address > 252)
     
    576580       
    577581        ddf_msg(LVL_DEBUG, "pci_add_device");
    578         dnode->parent_phone = -1;
     582        dnode->parent_sess = NULL;
    579583       
    580584        bus = pci_bus_new();
     
    587591        dnode->driver_data = bus;
    588592       
    589         dnode->parent_phone = devman_parent_device_connect(dnode->handle,
    590             IPC_FLAG_BLOCKING);
    591         if (dnode->parent_phone < 0) {
     593        dnode->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
     594            dnode->handle, IPC_FLAG_BLOCKING);
     595        if (!dnode->parent_sess) {
    592596                ddf_msg(LVL_ERROR, "pci_add_device failed to connect to the "
    593                     "parent's driver.");
    594                 rc = dnode->parent_phone;
     597                    "parent driver.");
     598                rc = ENOENT;
    595599                goto fail;
    596600        }
     
    598602        hw_resource_list_t hw_resources;
    599603       
    600         rc = hw_res_get_resource_list(dnode->parent_phone, &hw_resources);
     604        rc = hw_res_get_resource_list(dnode->parent_sess, &hw_resources);
    601605        if (rc != EOK) {
    602606                ddf_msg(LVL_ERROR, "pci_add_device failed to get hw resources "
     
    651655        if (bus != NULL)
    652656                pci_bus_delete(bus);
    653         if (dnode->parent_phone >= 0)
    654                 async_hangup(dnode->parent_phone);
     657       
     658        if (dnode->parent_sess)
     659                async_hangup(dnode->parent_sess);
     660       
    655661        if (got_res)
    656662                hw_res_clean_resource_list(&hw_resources);
     663       
    657664        if (ctl != NULL)
    658665                ddf_fun_destroy(ctl);
    659 
     666       
    660667        return rc;
    661668}
Note: See TracChangeset for help on using the changeset viewer.