Changeset 79ae36dd in mainline for uspace/drv/uhci_hcd/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/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/**
Note: See TracChangeset for help on using the changeset viewer.