Changeset 79ae36dd in mainline for uspace/drv


Ignore:
Timestamp:
2011-06-08T19:01:55Z (14 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.)
Location:
uspace/drv
Files:
19 edited

Legend:

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

    r764d71e r79ae36dd  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/**
    2930 * @addtogroup drvusbehci
     
    3435 * PCI related functions needed by the EHCI driver.
    3536 */
     37
    3638#include <errno.h>
    3739#include <str_error.h>
     
    7274#define PCI_READ(size) \
    7375do { \
    74         const int parent_phone = \
    75             devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);\
    76         if (parent_phone < 0) {\
    77                 return parent_phone; \
    78         } \
    79         sysarg_t add = (sysarg_t)address; \
     76        async_sess_t *parent_sess = \
     77            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \
     78            IPC_FLAG_BLOCKING); \
     79        if (!parent_sess) \
     80                return ENOMEM; \
     81        \
     82        sysarg_t add = (sysarg_t) address; \
    8083        sysarg_t val; \
     84        \
     85        async_exch_t *exch = async_exchange_begin(parent_sess); \
     86        \
    8187        const int ret = \
    82             async_req_2_1(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), \
     88            async_req_2_1(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \
    8389                IPC_M_CONFIG_SPACE_READ_##size, add, &val); \
     90        \
     91        async_exchange_end(exch); \
     92        async_hangup(parent_sess); \
     93        \
    8494        assert(value); \
     95        \
    8596        *value = val; \
    86         async_hangup(parent_phone); \
     97        return ret; \
     98} while (0)
     99
     100static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value)
     101{
     102        PCI_READ(32);
     103}
     104
     105static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value)
     106{
     107        PCI_READ(16);
     108}
     109
     110static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value)
     111{
     112        PCI_READ(8);
     113}
     114
     115#define PCI_WRITE(size) \
     116do { \
     117        async_sess_t *parent_sess = \
     118            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle, \
     119            IPC_FLAG_BLOCKING); \
     120        if (!parent_sess) \
     121                return ENOMEM; \
     122        \
     123        sysarg_t add = (sysarg_t) address; \
     124        sysarg_t val = value; \
     125        \
     126        async_exch_t *exch = async_exchange_begin(parent_sess); \
     127        \
     128        const int ret = \
     129            async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE), \
     130                IPC_M_CONFIG_SPACE_WRITE_##size, add, val); \
     131        \
     132        async_exchange_end(exch); \
     133        async_hangup(parent_sess); \
     134        \
    87135        return ret; \
    88136} while(0)
    89137
    90 static int pci_read32(const ddf_dev_t *dev, int address, uint32_t *value)
    91 {
    92         PCI_READ(32);
    93 }
    94 static int pci_read16(const ddf_dev_t *dev, int address, uint16_t *value)
    95 {
    96         PCI_READ(16);
    97 }
    98 static int pci_read8(const ddf_dev_t *dev, int address, uint8_t *value)
    99 {
    100         PCI_READ(8);
    101 }
    102 #define PCI_WRITE(size) \
    103 do { \
    104         const int parent_phone = \
    105             devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);\
    106         if (parent_phone < 0) {\
    107                 return parent_phone; \
    108         } \
    109         sysarg_t add = (sysarg_t)address; \
    110         sysarg_t val = value; \
    111         const int ret = \
    112             async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE), \
    113                 IPC_M_CONFIG_SPACE_WRITE_##size, add, val); \
    114         async_hangup(parent_phone); \
    115         return ret; \
    116 } while(0)
    117 
    118138static int pci_write32(const ddf_dev_t *dev, int address, uint32_t value)
    119139{
    120140        PCI_WRITE(32);
    121141}
     142
    122143static int pci_write16(const ddf_dev_t *dev, int address, uint16_t value)
    123144{
    124145        PCI_WRITE(16);
    125146}
     147
    126148static int pci_write8(const ddf_dev_t *dev, int address, uint8_t value)
    127149{
     
    141163{
    142164        assert(dev != NULL);
    143 
    144         const int parent_phone =
    145             devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);
    146         if (parent_phone < 0) {
    147                 return parent_phone;
    148         }
    149 
    150         int rc;
    151 
     165       
     166        async_sess_t *parent_sess =
     167            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     168            IPC_FLAG_BLOCKING);
     169        if (!parent_sess)
     170                return ENOMEM;
     171       
    152172        hw_resource_list_t hw_resources;
    153         rc = hw_res_get_resource_list(parent_phone, &hw_resources);
     173        int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
    154174        if (rc != EOK) {
    155                 async_hangup(parent_phone);
     175                async_hangup(parent_sess);
    156176                return rc;
    157177        }
    158 
     178       
    159179        uintptr_t mem_address = 0;
    160180        size_t mem_size = 0;
    161181        bool mem_found = false;
    162 
     182       
    163183        int irq = 0;
    164184        bool irq_found = false;
    165 
     185       
    166186        size_t i;
    167187        for (i = 0; i < hw_resources.count; i++) {
    168188                hw_resource_t *res = &hw_resources.resources[i];
    169                 switch (res->type)
    170                 {
     189                switch (res->type) {
    171190                case INTERRUPT:
    172191                        irq = res->res.interrupt.irq;
     
    174193                        usb_log_debug2("Found interrupt: %d.\n", irq);
    175194                        break;
    176 
    177195                case MEM_RANGE:
    178196                        if (res->res.mem_range.address != 0
     
    183201                                    mem_address, mem_size);
    184202                                mem_found = true;
    185                                 }
     203                        }
    186204                default:
    187205                        break;
    188206                }
    189207        }
    190 
     208       
    191209        if (mem_found && irq_found) {
    192210                *mem_reg_address = mem_address;
     
    197215                rc = ENOENT;
    198216        }
    199 
    200         async_hangup(parent_phone);
     217       
     218        async_hangup(parent_sess);
    201219        return rc;
    202220}
     
    209227int pci_enable_interrupts(const ddf_dev_t *device)
    210228{
    211         const int parent_phone =
    212             devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    213         if (parent_phone < 0) {
    214                 return parent_phone;
    215         }
    216         const bool enabled = hw_res_enable_interrupt(parent_phone);
    217         async_hangup(parent_phone);
     229        async_sess_t *parent_sess =
     230            devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
     231            IPC_FLAG_BLOCKING);
     232        if (!parent_sess)
     233                return ENOMEM;
     234       
     235        const bool enabled = hw_res_enable_interrupt(parent_sess);
     236        async_hangup(parent_sess);
     237       
    218238        return enabled ? EOK : EIO;
    219239}
     
    366386#undef CHECK_RET_RETURN
    367387}
    368 /*----------------------------------------------------------------------------*/
     388
    369389/**
    370390 * @}
    371391 */
    372 
    373 /**
    374  * @}
    375  */
  • uspace/drv/ns8250/ns8250.c

    r764d71e r79ae36dd  
    263263static void ns8250_dev_cleanup(ns8250_t *ns)
    264264{
    265         if (ns->dev->parent_phone > 0) {
    266                 async_hangup(ns->dev->parent_phone);
    267                 ns->dev->parent_phone = 0;
     265        if (ns->dev->parent_sess) {
     266                async_hangup(ns->dev->parent_sess);
     267                ns->dev->parent_sess = NULL;
    268268        }
    269269}
     
    337337       
    338338        /* Connect to the parent's driver. */
    339         ns->dev->parent_phone = devman_parent_device_connect(ns->dev->handle,
    340             IPC_FLAG_BLOCKING);
    341         if (ns->dev->parent_phone < 0) {
     339        ns->dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE,
     340            ns->dev->handle, IPC_FLAG_BLOCKING);
     341        if (!ns->dev->parent_sess) {
    342342                ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
    343343                    "device %s.", ns->dev->name);
    344                 ret = ns->dev->parent_phone;
     344                ret = ENOENT;
    345345                goto failed;
    346346        }
    347347       
    348348        /* Get hw resources. */
    349         ret = hw_res_get_resource_list(ns->dev->parent_phone, &hw_resources);
     349        ret = hw_res_get_resource_list(ns->dev->parent_sess, &hw_resources);
    350350        if (ret != EOK) {
    351351                ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
  • uspace/drv/ohci/pci.c

    r764d71e r79ae36dd  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/**
    2930 * @addtogroup drvusbohci
     
    3435 * PCI related functions needed by the OHCI driver.
    3536 */
     37
    3638#include <errno.h>
    3739#include <assert.h>
     
    6365        assert(irq_no);
    6466
    65         int parent_phone = devman_parent_device_connect(dev->handle,
     67        async_sess_t *parent_sess =
     68            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    6669            IPC_FLAG_BLOCKING);
    67         if (parent_phone < 0) {
    68                 return parent_phone;
    69         }
    70 
    71         int rc;
    72 
     70        if (!parent_sess)
     71                return ENOMEM;
     72       
    7373        hw_resource_list_t hw_resources;
    74         rc = hw_res_get_resource_list(parent_phone, &hw_resources);
     74        int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
    7575        if (rc != EOK) {
    76                 async_hangup(parent_phone);
     76                async_hangup(parent_sess);
    7777                return rc;
    7878        }
    79 
     79       
    8080        uintptr_t mem_address = 0;
    8181        size_t mem_size = 0;
    8282        bool mem_found = false;
    83 
     83       
    8484        int irq = 0;
    8585        bool irq_found = false;
    86 
     86       
    8787        size_t i;
    8888        for (i = 0; i < hw_resources.count; i++) {
    8989                hw_resource_t *res = &hw_resources.resources[i];
    90                 switch (res->type)
    91                 {
     90                switch (res->type) {
    9291                case INTERRUPT:
    9392                        irq = res->res.interrupt.irq;
     
    9594                        usb_log_debug2("Found interrupt: %d.\n", irq);
    9695                        break;
    97 
    9896                case MEM_RANGE:
    9997                        if (res->res.mem_range.address != 0
     
    104102                                    (void *) mem_address, mem_size);
    105103                                mem_found = true;
    106                                 }
     104                        }
    107105                default:
    108106                        break;
    109107                }
    110108        }
    111 
     109       
    112110        if (mem_found && irq_found) {
    113111                *mem_reg_address = mem_address;
     
    115113                *irq_no = irq;
    116114                rc = EOK;
    117         } else {
     115        } else
    118116                rc = ENOENT;
    119         }
    120 
    121         async_hangup(parent_phone);
     117       
     118        async_hangup(parent_sess);
    122119        return rc;
    123120}
    124 /*----------------------------------------------------------------------------*/
    125 /** Calls the PCI driver with a request to enable interrupts
     121
     122/** Call the PCI driver with a request to enable interrupts
    126123 *
    127124 * @param[in] device Device asking for interrupts
     
    130127int pci_enable_interrupts(ddf_dev_t *device)
    131128{
    132         int parent_phone =
    133             devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    134         if (parent_phone < 0) {
    135                 return parent_phone;
    136         }
    137         bool enabled = hw_res_enable_interrupt(parent_phone);
    138         async_hangup(parent_phone);
     129        async_sess_t *parent_sess =
     130            devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
     131            IPC_FLAG_BLOCKING);
     132        if (!parent_sess)
     133                return ENOMEM;
     134       
     135        bool enabled = hw_res_enable_interrupt(parent_sess);
     136        async_hangup(parent_sess);
     137       
    139138        return enabled ? EOK : EIO;
    140139}
    141 /**
    142  * @}
    143  */
    144140
    145141/**
  • 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}
  • uspace/drv/uhci_hcd/pci.c

    r764d71e r79ae36dd  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/**
    2930 * @addtogroup drvusbuhcihc
     
    3435 * PCI related functions needed by the UHCI driver.
    3536 */
     37
    3638#include <errno.h>
    3739#include <assert.h>
     
    5961        assert(io_reg_size);
    6062        assert(irq_no);
    61 
    62         int parent_phone =
    63             devman_parent_device_connect(dev->handle, IPC_FLAG_BLOCKING);
    64         if (parent_phone < 0) {
    65                 return parent_phone;
    66         }
    67 
     63       
     64        async_sess_t *parent_sess =
     65            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     66            IPC_FLAG_BLOCKING);
     67        if (!parent_sess)
     68                return ENOMEM;
     69       
    6870        hw_resource_list_t hw_resources;
    69         int rc = hw_res_get_resource_list(parent_phone, &hw_resources);
     71        int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
    7072        if (rc != EOK) {
    71                 async_hangup(parent_phone);
     73                async_hangup(parent_sess);
    7274                return rc;
    7375        }
    74 
     76       
    7577        uintptr_t io_address = 0;
    7678        size_t io_size = 0;
    7779        bool io_found = false;
    78 
     80       
    7981        int irq = 0;
    8082        bool irq_found = false;
    81 
     83       
    8284        size_t i;
    8385        for (i = 0; i < hw_resources.count; i++) {
    8486                const hw_resource_t *res = &hw_resources.resources[i];
    85                 switch (res->type)
    86                 {
     87                switch (res->type) {
    8788                case INTERRUPT:
    8889                        irq = res->res.interrupt.irq;
     
    9091                        usb_log_debug2("Found interrupt: %d.\n", irq);
    9192                        break;
    92 
    9393                case IO_RANGE:
    9494                        io_address = res->res.io_range.address;
     
    9898                        io_found = true;
    9999                        break;
    100 
    101100                default:
    102101                        break;
    103102                }
    104103        }
    105         async_hangup(parent_phone);
    106 
     104       
     105        async_hangup(parent_sess);
     106       
    107107        if (!io_found || !irq_found)
    108108                return ENOENT;
    109 
     109       
    110110        *io_reg_address = io_address;
    111111        *io_reg_size = io_size;
    112112        *irq_no = irq;
    113 
     113       
    114114        return EOK;
    115115}
    116 /*----------------------------------------------------------------------------*/
     116
    117117/** Call the PCI driver with a request to enable interrupts
    118118 *
     
    122122int pci_enable_interrupts(const ddf_dev_t *device)
    123123{
    124         const int parent_phone =
    125             devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    126         if (parent_phone < 0) {
    127                 return parent_phone;
    128         }
    129         const bool enabled = hw_res_enable_interrupt(parent_phone);
    130         async_hangup(parent_phone);
     124        async_sess_t *parent_sess =
     125            devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
     126            IPC_FLAG_BLOCKING);
     127        if (!parent_sess)
     128                return ENOMEM;
     129       
     130        const bool enabled = hw_res_enable_interrupt(parent_sess);
     131        async_hangup(parent_sess);
     132       
    131133        return enabled ? EOK : EIO;
    132134}
    133 /*----------------------------------------------------------------------------*/
     135
    134136/** Call the PCI driver with a request to clear legacy support register
    135137 *
     
    140142{
    141143        assert(device);
    142         const int parent_phone =
    143             devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    144         if (parent_phone < 0) {
    145                 return parent_phone;
    146         }
    147 
     144       
     145        async_sess_t *parent_sess =
     146            devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
     147            IPC_FLAG_BLOCKING);
     148        if (!parent_sess)
     149                return ENOMEM;
     150       
    148151        /* See UHCI design guide for these values p.45,
    149152         * write all WC bits in USB legacy register */
    150153        const sysarg_t address = 0xc0;
    151154        const sysarg_t value = 0xaf00;
    152 
    153         const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
     155       
     156        async_exch_t *exch = async_exchange_begin(parent_sess);
     157       
     158        const int rc = async_req_3_0(exch, DEV_IFACE_ID(PCI_DEV_IFACE),
    154159            IPC_M_CONFIG_SPACE_WRITE_16, address, value);
    155         async_hangup(parent_phone);
    156 
     160       
     161        async_exchange_end(exch);
     162        async_hangup(parent_sess);
     163       
    157164        return rc;
    158165}
    159 /*----------------------------------------------------------------------------*/
    160 /**
    161  * @}
    162  */
    163166
    164167/**
  • uspace/drv/uhci_rhd/main.c

    r764d71e r79ae36dd  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829/** @addtogroup drvusbuhcirh
    2930 * @{
     
    3233 * @brief UHCI root hub initialization routines
    3334 */
     35
    3436#include <ddf/driver.h>
    3537#include <devman.h>
     
    4850static int hc_get_my_registers(const ddf_dev_t *dev,
    4951    uintptr_t *io_reg_address, size_t *io_reg_size);
    50 /*----------------------------------------------------------------------------*/
     52
    5153static int uhci_rh_add_device(ddf_dev_t *device);
    52 /*----------------------------------------------------------------------------*/
     54
    5355static driver_ops_t uhci_rh_driver_ops = {
    5456        .add_device = uhci_rh_add_device,
    5557};
    56 /*----------------------------------------------------------------------------*/
     58
    5759static driver_t uhci_rh_driver = {
    5860        .name = NAME,
    5961        .driver_ops = &uhci_rh_driver_ops
    6062};
    61 /*----------------------------------------------------------------------------*/
     63
    6264/** Initialize global driver structures (NONE).
    6365 *
     
    7476        return ddf_driver_main(&uhci_rh_driver);
    7577}
    76 /*----------------------------------------------------------------------------*/
     78
    7779/** Initialize a new ddf driver instance of UHCI root hub.
    7880 *
     
    122124        return EOK;
    123125}
    124 /*----------------------------------------------------------------------------*/
     126
    125127/** Get address of I/O registers.
    126128 *
     
    134136{
    135137        assert(dev);
    136 
    137         const int parent_phone = devman_parent_device_connect(dev->handle,
     138       
     139        async_sess_t *parent_sess =
     140            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    138141            IPC_FLAG_BLOCKING);
    139         if (parent_phone < 0) {
    140                 return parent_phone;
    141         }
    142 
     142        if (!parent_sess)
     143                return ENOMEM;
     144       
    143145        hw_resource_list_t hw_resources;
    144         const int ret = hw_res_get_resource_list(parent_phone, &hw_resources);
     146        const int ret = hw_res_get_resource_list(parent_sess, &hw_resources);
    145147        if (ret != EOK) {
    146                 async_hangup(parent_phone);
     148                async_hangup(parent_sess);
    147149                return ret;
    148150        }
    149 
     151       
    150152        uintptr_t io_address = 0;
    151153        size_t io_size = 0;
    152154        bool io_found = false;
    153 
     155       
    154156        size_t i = 0;
    155157        for (; i < hw_resources.count; i++) {
     
    160162                        io_found = true;
    161163                }
     164       
    162165        }
    163         async_hangup(parent_phone);
    164 
    165         if (!io_found) {
     166        async_hangup(parent_sess);
     167       
     168        if (!io_found)
    166169                return ENOENT;
    167         }
    168         if (io_reg_address != NULL) {
     170       
     171        if (io_reg_address != NULL)
    169172                *io_reg_address = io_address;
    170         }
    171         if (io_reg_size != NULL) {
     173       
     174        if (io_reg_size != NULL)
    172175                *io_reg_size = io_size;
    173         }
     176       
    174177        return EOK;
    175178}
     179
    176180/**
    177181 * @}
  • uspace/drv/usbhid/kbd/kbddev.c

    r764d71e r79ae36dd  
    4242#include <ipc/kbd.h>
    4343#include <async.h>
     44#include <async_obsolete.h>
    4445#include <fibril.h>
    4546#include <fibril_synch.h>
     
    6768
    6869#include "../usbhid.h"
     70
     71// FIXME: remove this header
     72#include <kernel/ipc/ipc_methods.h>
    6973
    7074/*----------------------------------------------------------------------------*/
     
    307311    unsigned int key)
    308312{
    309         console_event_t ev;
     313        kbd_event_t ev;
    310314        unsigned mod_mask;
    311315
     
    399403        }
    400404       
    401         async_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key,
     405        async_obsolete_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key,
    402406            ev.mods, ev.c);
    403407}
     
    892896       
    893897        // hangup phone to the console
    894         async_hangup((*kbd_dev)->console_phone);
     898        async_obsolete_hangup((*kbd_dev)->console_phone);
    895899       
    896900        if ((*kbd_dev)->repeat_mtx != NULL) {
  • uspace/drv/usbhid/layout.h

    r764d71e r79ae36dd  
    4444typedef struct {
    4545        void (*reset)(void);
    46         wchar_t (*parse_ev)(console_event_t *);
     46        wchar_t (*parse_ev)(kbd_event_t *);
    4747} layout_op_t;
    4848
  • uspace/drv/usbhid/mouse/mousedev.c

    r764d71e r79ae36dd  
    4141#include <usb/hid/usages/core.h>
    4242#include <errno.h>
     43#include <async.h>
     44#include <async_obsolete.h>
    4345#include <str_error.h>
    4446#include <ipc/mouse.h>
     
    5052#include "mousedev.h"
    5153#include "../usbhid.h"
     54
     55// FIXME: remove this header
     56#include <kernel/ipc/ipc_methods.h>
    5257
    5358#define NAME "mouse"
     
    181186        // hangup phone to the console
    182187        if ((*mouse_dev)->mouse_phone >= 0) {
    183                 async_hangup((*mouse_dev)->mouse_phone);
     188                async_obsolete_hangup((*mouse_dev)->mouse_phone);
    184189        }
    185190       
    186191        if ((*mouse_dev)->wheel_phone >= 0) {
    187                 async_hangup((*mouse_dev)->wheel_phone);
     192                async_obsolete_hangup((*mouse_dev)->wheel_phone);
    188193        }
    189194       
     
    196201static void usb_mouse_send_wheel(const usb_mouse_t *mouse_dev, int wheel)
    197202{
    198         console_event_t ev;
     203        kbd_event_t ev;
    199204       
    200205        ev.type = KEY_PRESS;
     
    214219        for (i = 0; i < count * 3; ++i) {
    215220                usb_log_debug2("Sending key %d to the console\n", ev.key);
    216                 async_msg_4(mouse_dev->wheel_phone, KBD_EVENT, ev.type,
     221                async_obsolete_msg_4(mouse_dev->wheel_phone, KBD_EVENT, ev.type,
    217222                    ev.key, ev.mods, ev.c);
    218223                // send key release right away
    219                 async_msg_4(mouse_dev->wheel_phone, KBD_EVENT, KEY_RELEASE,
     224                async_obsolete_msg_4(mouse_dev->wheel_phone, KBD_EVENT, KEY_RELEASE,
    220225                    ev.key, ev.mods, ev.c);
    221226        }
     
    303308       
    304309        if ((shift_x != 0) || (shift_y != 0)) {
    305                 async_req_2_0(mouse_dev->mouse_phone,
     310                async_obsolete_req_2_0(mouse_dev->mouse_phone,
    306311                    MEVENT_MOVE, shift_x, shift_y);
    307312        }
     
    353358                if (mouse_dev->buttons[field->usage - field->usage_minimum] == 0
    354359                    && field->value != 0) {
    355                         async_req_2_0(mouse_dev->mouse_phone,
     360                        async_obsolete_req_2_0(mouse_dev->mouse_phone,
    356361                            MEVENT_BUTTON, field->usage, 1);
    357362                        mouse_dev->buttons[field->usage - field->usage_minimum]
     
    360365                    mouse_dev->buttons[field->usage - field->usage_minimum] != 0
    361366                    && field->value == 0) {
    362                        async_req_2_0(mouse_dev->mouse_phone,
     367                       async_obsolete_req_2_0(mouse_dev->mouse_phone,
    363368                           MEVENT_BUTTON, field->usage, 0);
    364369                       mouse_dev->buttons[field->usage - field->usage_minimum]
  • uspace/drv/usbhid/multimedia/multimedia.c

    r764d71e r79ae36dd  
    4646
    4747#include <errno.h>
     48#include <async.h>
     49#include <async_obsolete.h>
    4850#include <str_error.h>
    4951
    5052#include <ipc/kbd.h>
    5153#include <io/console.h>
     54
     55// FIXME: remove this header
     56#include <kernel/ipc/ipc_methods.h>
    5257
    5358#define NAME "multimedia-keys"
     
    143148        assert(multim_dev != NULL);
    144149       
    145         console_event_t ev;
     150        kbd_event_t ev;
    146151       
    147152        ev.type = type;
     
    157162        }
    158163       
    159         async_msg_4(multim_dev->console_phone, KBD_EVENT, ev.type, ev.key,
     164        async_obsolete_msg_4(multim_dev->console_phone, KBD_EVENT, ev.type, ev.key,
    160165            ev.mods, ev.c);
    161166}
     
    170175       
    171176        // hangup phone to the console
    172         async_hangup((*multim_dev)->console_phone);
     177        async_obsolete_hangup((*multim_dev)->console_phone);
    173178
    174179        free(*multim_dev);
  • uspace/drv/usbmouse/init.c

    r764d71e r79ae36dd  
    3434 * Initialization routines for USB mouse driver.
    3535 */
     36
    3637#include "mouse.h"
    3738#include <usb/debug.h>
     
    4142#include <usb/hid/request.h>
    4243#include <errno.h>
     44
     45// FIXME: remove this header
     46#include <kernel/ipc/ipc_methods.h>
    4347
    4448/** Mouse polling endpoint description for boot protocol subclass. */
  • uspace/drv/usbmouse/mouse.c

    r764d71e r79ae36dd  
    3434 * Actual handling of USB mouse protocol.
    3535 */
    36 #include "mouse.h"
     36
    3737#include <usb/debug.h>
    3838#include <errno.h>
    3939#include <str_error.h>
    4040#include <ipc/mouse.h>
     41#include <async.h>
     42#include <async_obsolete.h>
     43#include "mouse.h"
    4144
    4245/** Mouse polling callback.
     
    8184                if ((shift_x != 0) || (shift_y != 0)) {
    8285                        /* FIXME: guessed for QEMU */
    83                         async_req_2_0(mouse->console_phone,
     86                        async_obsolete_req_2_0(mouse->console_phone,
    8487                            MEVENT_MOVE,
    8588                            - shift_x / 10,  - shift_y / 10);
     
    8790                if (butt) {
    8891                        /* FIXME: proper button clicking. */
    89                         async_req_2_0(mouse->console_phone,
     92                        async_obsolete_req_2_0(mouse->console_phone,
    9093                            MEVENT_BUTTON, 1, 1);
    91                         async_req_2_0(mouse->console_phone,
     94                        async_obsolete_req_2_0(mouse->console_phone,
    9295                            MEVENT_BUTTON, 1, 0);
    9396                }
     
    115118        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    116119
    117         async_hangup(mouse->console_phone);
     120        async_obsolete_hangup(mouse->console_phone);
    118121        mouse->console_phone = -1;
    119122
  • uspace/drv/vhc/conndev.c

    r764d71e r79ae36dd  
    3838#include <ddf/driver.h>
    3939#include <usbvirt/ipc.h>
     40#include <async.h>
    4041#include "conn.h"
    4142
     
    4445static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>";
    4546
     47#if 0
    4648/** Receive device name.
    4749 *
    4850 * @warning Errors are silently ignored.
    4951 *
    50  * @param phone Phone to the virtual device.
     52 * @param sess Session to the virtual device.
     53 *
    5154 */
    52 static void receive_device_name(int phone)
     55static void receive_device_name(async_sess_t *sess)
    5356{
    54         aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
     57        async_exch_t *exch = async_exchange_begin(sess);
     58       
     59        aid_t opening_request = async_send_0(exch, IPC_M_USBVIRT_GET_NAME, NULL);
    5560        if (opening_request == 0) {
     61                async_exchange_end(exch);
    5662                return;
    5763        }
    58 
    59 
     64       
    6065        ipc_call_t data_request_call;
    61         aid_t data_request = async_data_read(phone,
    62              plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
    63              &data_request_call);
    64 
     66        aid_t data_request = async_data_read(exch, plugged_device_name,
     67             PLUGGED_DEVICE_NAME_MAXLEN, &data_request_call);
     68       
     69        async_exchange_end(exch);
     70       
    6571        if (data_request == 0) {
    6672                async_wait_for(opening_request, NULL);
    6773                return;
    6874        }
    69 
     75       
    7076        sysarg_t data_request_rc;
    7177        sysarg_t opening_request_rc;
    7278        async_wait_for(data_request, &data_request_rc);
    7379        async_wait_for(opening_request, &opening_request_rc);
    74 
    75         if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
     80       
     81        if ((data_request_rc != EOK) || (opening_request_rc != EOK))
    7682                return;
    77         }
    78 
     83       
    7984        size_t len = IPC_GET_ARG2(data_request_call);
    8085        plugged_device_name[len] = 0;
    8186}
     87#endif
    8288
    8389/** Default handler for IPC methods not handled by DDF.
     
    9096    ipc_callid_t icallid, ipc_call_t *icall)
    9197{
     98// FIXME:
     99// This code needs to be refactored since the async
     100// framework does not support automatic callback connections
     101// yet.
     102
     103#if 0
    92104        vhc_data_t *vhc = fun->dev->driver_data;
    93105        sysarg_t method = IPC_GET_IMETHOD(*icall);
     
    112124                return;
    113125        }
     126#endif
    114127
    115128        async_answer_0(icallid, EINVAL);
  • uspace/drv/vhc/devconn.c

    r764d71e r79ae36dd  
     1/*
     2 * Copyright (c) 2011 Vojtech Horky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
    129#include <errno.h>
    230#include "vhcd.h"
     
    1139        }
    1240        dev->address = 0;
    13         dev->dev_phone = -1;
     41        dev->dev_sess = NULL;
    1442        dev->dev_local = NULL;
    1543        dev->plugged = true;
     
    2250
    2351static int vhc_virtdev_plug_generic(vhc_data_t *vhc,
    24     int phone, usbvirt_device_t *virtdev,
     52    async_sess_t *sess, usbvirt_device_t *virtdev,
    2553    uintptr_t *handle, bool connect)
    2654{
     
    3058        }
    3159
    32         dev->dev_phone = phone;
     60        dev->dev_sess = sess;
    3361        dev->dev_local = virtdev;
    3462
     
    5684}
    5785
    58 int vhc_virtdev_plug(vhc_data_t *vhc, int phone, uintptr_t *handle)
     86int vhc_virtdev_plug(vhc_data_t *vhc, async_sess_t *sess, uintptr_t *handle)
    5987{
    60         return vhc_virtdev_plug_generic(vhc, phone, NULL, handle, true);
     88        return vhc_virtdev_plug_generic(vhc, sess, NULL, handle, true);
    6189}
    6290
    6391int vhc_virtdev_plug_local(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle)
    6492{
    65         return vhc_virtdev_plug_generic(vhc, -1, dev, handle, true);
     93        return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, true);
    6694}
    6795
    6896int vhc_virtdev_plug_hub(vhc_data_t *vhc, usbvirt_device_t *dev, uintptr_t *handle)
    6997{
    70         return vhc_virtdev_plug_generic(vhc, -1, dev, handle, false);
     98        return vhc_virtdev_plug_generic(vhc, NULL, dev, handle, false);
    7199}
    72100
  • uspace/drv/vhc/hub.c

    r764d71e r79ae36dd  
    3333 * @brief Virtual USB hub.
    3434 */
     35
    3536#include <usb/classes/classes.h>
    3637#include <usbvirt/device.h>
    3738#include <errno.h>
     39#include <async.h>
    3840#include <str_error.h>
    3941#include <stdlib.h>
     
    4446
    4547#include "hub.h"
    46 //#include "hub/virthub.h"
    4748#include "vhcd.h"
    4849#include "conn.h"
     
    9798         * Wait until parent device is properly initialized.
    9899         */
    99         int phone;
     100        async_sess_t *sess;
    100101        do {
    101                 phone = devman_device_connect(hc_dev->handle, 0);
    102         } while (phone < 0);
    103         async_hangup(phone);
     102                sess = devman_device_connect(EXCHANGE_SERIALIZE, hc_dev->handle, 0);
     103        } while (!sess);
     104        async_hangup(sess);
    104105
    105106        int rc;
     
    129130        return 0;
    130131}
    131        
    132132
    133133/**
  • uspace/drv/vhc/hub.h

    r764d71e r79ae36dd  
    3333 * @brief Virtual USB hub.
    3434 */
     35
    3536#ifndef VHCD_HUB_H_
    3637#define VHCD_HUB_H_
  • uspace/drv/vhc/main.c

    r764d71e r79ae36dd  
    2929/** @addtogroup drvusbvhc
    3030 * @{
    31  */ 
     31 */
    3232/** @file
    3333 * Virtual host controller.
  • uspace/drv/vhc/transfer.c

    r764d71e r79ae36dd  
     1/*
     2 * Copyright (c) 2011 Vojtech Horky
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
     28
    129#include <errno.h>
    230#include <str_error.h>
     
    123151
    124152static int process_transfer_remote(vhc_transfer_t *transfer,
    125     int phone, size_t *actual_data_size)
     153    async_sess_t *sess, size_t *actual_data_size)
    126154{
    127155        int rc;
     
    129157        if (transfer->transfer_type == USB_TRANSFER_CONTROL) {
    130158                if (transfer->direction == USB_DIRECTION_IN) {
    131                         rc = usbvirt_ipc_send_control_read(phone,
    132                             transfer->setup_buffer, transfer->setup_buffer_size,
    133                             transfer->data_buffer, transfer->data_buffer_size,
    134                             actual_data_size);
    135                 } else {
    136                         assert(transfer->direction == USB_DIRECTION_OUT);
    137                         rc = usbvirt_ipc_send_control_write(phone,
    138                             transfer->setup_buffer, transfer->setup_buffer_size,
    139                             transfer->data_buffer, transfer->data_buffer_size);
    140                 }
    141         } else {
    142                 if (transfer->direction == USB_DIRECTION_IN) {
    143                         rc = usbvirt_ipc_send_data_in(phone, transfer->endpoint,
     159                        rc = usbvirt_ipc_send_control_read(sess,
     160                            transfer->setup_buffer, transfer->setup_buffer_size,
     161                            transfer->data_buffer, transfer->data_buffer_size,
     162                            actual_data_size);
     163                } else {
     164                        assert(transfer->direction == USB_DIRECTION_OUT);
     165                        rc = usbvirt_ipc_send_control_write(sess,
     166                            transfer->setup_buffer, transfer->setup_buffer_size,
     167                            transfer->data_buffer, transfer->data_buffer_size);
     168                }
     169        } else {
     170                if (transfer->direction == USB_DIRECTION_IN) {
     171                        rc = usbvirt_ipc_send_data_in(sess, transfer->endpoint,
    144172                            transfer->transfer_type,
    145173                            transfer->data_buffer, transfer->data_buffer_size,
     
    147175                } else {
    148176                        assert(transfer->direction == USB_DIRECTION_OUT);
    149                         rc = usbvirt_ipc_send_data_out(phone, transfer->endpoint,
     177                        rc = usbvirt_ipc_send_data_out(sess, transfer->endpoint,
    150178                            transfer->transfer_type,
    151179                            transfer->data_buffer, transfer->data_buffer_size);
     
    206234                int rc = EOK;
    207235                size_t data_transfer_size = 0;
    208                 if (dev->dev_phone > 0) {
    209                         rc = process_transfer_remote(transfer, dev->dev_phone,
     236                if (dev->dev_sess) {
     237                        rc = process_transfer_remote(transfer, dev->dev_sess,
    210238                            &data_transfer_size);
    211239                } else if (dev->dev_local != NULL) {
  • uspace/drv/vhc/vhcd.h

    r764d71e r79ae36dd  
    4141#include <usb/host/device_keeper.h>
    4242#include <usbhc_iface.h>
     43#include <async.h>
    4344
    4445#define NAME "vhc"
     
    4647typedef struct {
    4748        link_t link;
    48         int dev_phone;
     49        async_sess_t *dev_sess;
    4950        usbvirt_device_t *dev_local;
    5051        bool plugged;
     
    8283vhc_transfer_t *vhc_transfer_create(usb_address_t, usb_endpoint_t,
    8384    usb_direction_t, usb_transfer_type_t, ddf_fun_t *, void *);
    84 int vhc_virtdev_plug(vhc_data_t *, int, uintptr_t *);
     85int vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *);
    8586int vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
    8687int vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
Note: See TracChangeset for help on using the changeset viewer.