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