Changeset 6843a9c in mainline for uspace/lib/drv/include


Ignore:
Timestamp:
2012-06-29T13:02:14Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
722912e
Parents:
ba72f2b (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

Trivial conflicts.

Location:
uspace/lib/drv/include
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/ddf/driver.h

    rba72f2b r6843a9c  
    8181         */
    8282        devman_handle_t handle;
     83       
    8384        /** Reference count */
    8485        atomic_t refcnt;
     
    104105        /** True if bound to the device manager */
    105106        bool bound;
     107       
    106108        /** Function indentifier (asigned by device manager) */
    107109        devman_handle_t handle;
     110       
    108111        /** Reference count */
    109112        atomic_t refcnt;
     
    114117        /** Function type */
    115118        fun_type_t ftype;
     119       
    116120        /** Function name */
    117121        const char *name;
     122       
    118123        /** List of device ids for driver matching */
    119124        match_id_list_t match_ids;
     125       
    120126        /** Driver-specific data associated with this function */
    121127        void *driver_data;
     128       
    122129        /** Implementation of operations provided by this function */
    123130        ddf_dev_ops_t *ops;
     131       
    124132        /** Connection handler or @c NULL to use the DDF default handler. */
    125133        async_client_conn_t conn_handler;
     
    136144typedef struct driver_ops {
    137145        /** Callback method for passing a new device to the device driver */
    138         int (*add_device)(ddf_dev_t *);
    139         /**
    140          * Notification that the device was succesfully added.
    141          * The driver can do any blocking operation without
    142          * blocking the device manager.
    143          */
    144         void (*device_added)(ddf_dev_t *dev);
     146        int (*dev_add)(ddf_dev_t *);
     147       
    145148        /** Ask driver to remove a device */
    146149        int (*dev_remove)(ddf_dev_t *);
     150       
    147151        /** Inform driver a device disappeared */
    148152        int (*dev_gone)(ddf_dev_t *);
     153       
    149154        /** Ask driver to online a specific function */
    150155        int (*fun_online)(ddf_fun_t *);
     156       
    151157        /** Ask driver to offline a specific function */
    152158        int (*fun_offline)(ddf_fun_t *);
  • uspace/lib/drv/include/ddf/interrupt.h

    rba72f2b r6843a9c  
    3636#define DDF_INTERRUPT_H_
    3737
     38#include <libarch/common.h>
     39#include <libarch/types.h>
    3840#include <abi/ddi/irq.h>
    3941#include <adt/list.h>
    4042#include <ddi.h>
    4143#include <fibril_synch.h>
    42 
    4344#include "driver.h"
    4445#include "../dev_iface.h"
     
    6465} interrupt_context_list_t;
    6566
    66 extern interrupt_context_t *create_interrupt_context(void);
    67 extern void delete_interrupt_context(interrupt_context_t *);
    68 extern void init_interrupt_context_list(interrupt_context_list_t *);
    69 extern void add_interrupt_context(interrupt_context_list_t *,
    70     interrupt_context_t *);
    71 extern void remove_interrupt_context(interrupt_context_list_t *,
    72     interrupt_context_t *);
    73 extern interrupt_context_t *find_interrupt_context_by_id(
    74     interrupt_context_list_t *, int);
    75 extern interrupt_context_t *find_interrupt_context(
    76     interrupt_context_list_t *, ddf_dev_t *, int);
    77 
     67extern void interrupt_init(void);
    7868extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
    7969    irq_code_t *);
  • uspace/lib/drv/include/ops/hw_res.h

    rba72f2b r6843a9c  
    3939#include <device/hw_res.h>
    4040#include <sys/types.h>
    41 
    4241#include "../ddf/driver.h"
    4342
    4443typedef struct {
    45          hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
    46          bool (*enable_interrupt)(ddf_fun_t *);
    47          int (*dma_channel_setup)(ddf_fun_t *,
    48              unsigned, uint32_t, uint16_t, uint8_t);
     44        hw_resource_list_t *(*get_resource_list)(ddf_fun_t *);
     45        bool (*enable_interrupt)(ddf_fun_t *);
     46        int (*dma_channel_setup)(ddf_fun_t *, unsigned, uint32_t, uint16_t, uint8_t);
    4947} hw_res_ops_t;
    5048
  • uspace/lib/drv/include/ops/nic.h

    rba72f2b r6843a9c  
    3737#define LIBDRV_OPS_NIC_H_
    3838
    39 #include <net/packet.h>
    4039#include <ipc/services.h>
    41 #include <net/device.h>
     40#include <nic/nic.h>
    4241#include <sys/time.h>
    43 
    4442#include "../ddf/driver.h"
    4543
    4644typedef struct nic_iface {
    4745        /** Mandatory methods */
    48         int (*send_message)(ddf_fun_t *, packet_id_t);
    49         int (*connect_to_nil)(ddf_fun_t *, services_t, nic_device_id_t);
     46        int (*send_frame)(ddf_fun_t *, void *, size_t);
     47        int (*callback_create)(ddf_fun_t *);
    5048        int (*get_state)(ddf_fun_t *, nic_device_state_t *);
    5149        int (*set_state)(ddf_fun_t *, nic_device_state_t);
     
    8987        int (*vlan_get_mask)(ddf_fun_t *, nic_vlan_mask_t *);
    9088        int (*vlan_set_mask)(ddf_fun_t *, const nic_vlan_mask_t *);
    91         int (*vlan_set_tag)(ddf_fun_t *, uint16_t, int, int);
     89        int (*vlan_set_tag)(ddf_fun_t *, uint16_t, bool, bool);
    9290       
    9391        int (*wol_virtue_add)(ddf_fun_t *, nic_wv_type_t, const void *,
  • uspace/lib/drv/include/usb_iface.h

    rba72f2b r6843a9c  
    3939
    4040#include "ddf/driver.h"
     41#include <async.h>
    4142#include <usb/usb.h>
    42 typedef enum {
    43         /** Tell USB address assigned to device.
    44          * Parameters:
    45          * - devman handle id
    46          * Answer:
    47          * - EINVAL - unknown handle or handle not managed by this driver
    48          * - ENOTSUP - operation not supported (shall not happen)
    49          * - arbitrary error code if returned by remote implementation
    50          * - EOK - handle found, first parameter contains the USB address
    51          *
    52          * The handle must be the one used for binding USB address with
    53          * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller
    54          * (that this request would eventually reach) would not be able
    55          * to find it.
    56          * The problem is that this handle is actually assigned to the
    57          * function inside driver of the parent device (usually hub driver).
    58          * To bypass this problem, the initial caller specify handle as
    59          * zero and the first parent assigns the actual value.
    60          * See usb_iface_get_address_hub_child_impl() implementation
    61          * that could be assigned to device ops of a child device of in a
    62          * hub driver.
    63          * For example, the USB multi interface device driver (MID)
    64          * passes this initial zero without any modification because the
    65          * handle must be resolved by its parent.
    66          */
    67         IPC_M_USB_GET_ADDRESS,
    6843
    69         /** Tell interface number given device can use.
    70          * Parameters
    71          * - devman handle id of the device
    72          * Answer:
    73          * - ENOTSUP - operation not supported (can also mean any interface)
    74          * - EOK - operation okay, first parameter contains interface number
    75          */
    76         IPC_M_USB_GET_INTERFACE,
    77 
    78         /** Tell devman handle of device host controller.
    79          * Parameters:
    80          * - none
    81          * Answer:
    82          * - EOK - request processed without errors
    83          * - ENOTSUP - this indicates invalid USB driver
    84          * Parameters of the answer:
    85          * - devman handle of HC caller is physically connected to
    86          */
    87         IPC_M_USB_GET_HOST_CONTROLLER_HANDLE
    88 } usb_iface_funcs_t;
     44int usb_get_my_address(async_exch_t *, usb_address_t *);
     45int usb_get_my_interface(async_exch_t *, int *);
     46int usb_get_hc_handle(async_exch_t *, devman_handle_t *);
    8947
    9048/** USB device communication interface. */
    9149typedef struct {
    92         int (*get_address)(ddf_fun_t *, devman_handle_t, usb_address_t *);
    93         int (*get_interface)(ddf_fun_t *, devman_handle_t, int *);
     50        int (*get_my_address)(ddf_fun_t *, usb_address_t *);
     51        int (*get_my_interface)(ddf_fun_t *, int *);
    9452        int (*get_hc_handle)(ddf_fun_t *, devman_handle_t *);
    9553} usb_iface_t;
    96 
    9754
    9855#endif
  • uspace/lib/drv/include/usbhc_iface.h

    rba72f2b r6843a9c  
    11/*
    22 * Copyright (c) 2010 Vojtech Horky
     3 * Copyright (c) 2011 Jan Vesely
    34 * All rights reserved.
    45 *
     
    3132 * @{
    3233 */
     34
    3335/** @file
    3436 * @brief USB host controller interface definition.
     
    4244#include <bool.h>
    4345
    44 
    45 /** IPC methods for communication with HC through DDF interface.
    46  *
    47  * Notes for async methods:
    48  *
    49  * Methods for sending data to device (OUT transactions)
    50  * - e.g. IPC_M_USBHC_INTERRUPT_OUT -
    51  * always use the same semantics:
    52  * - first, IPC call with given method is made
    53  *   - argument #1 is target address
    54  *   - argument #2 is target endpoint
    55  *   - argument #3 is max packet size of the endpoint
    56  * - this call is immediately followed by IPC data write (from caller)
    57  * - the initial call (and the whole transaction) is answer after the
    58  *   transaction is scheduled by the HC and acknowledged by the device
    59  *   or immediately after error is detected
    60  * - the answer carries only the error code
    61  *
    62  * Methods for retrieving data from device (IN transactions)
    63  * - e.g. IPC_M_USBHC_INTERRUPT_IN -
    64  * also use the same semantics:
    65  * - first, IPC call with given method is made
    66  *   - argument #1 is target address
    67  *   - argument #2 is target endpoint
    68  * - this call is immediately followed by IPC data read (async version)
    69  * - the call is not answered until the device returns some data (or until
    70  *   error occurs)
    71  *
    72  * Some special methods (NO-DATA transactions) do not send any data. These
    73  * might behave as both OUT or IN transactions because communication parts
    74  * where actual buffers are exchanged are omitted.
    75  **
    76  * For all these methods, wrap functions exists. Important rule: functions
    77  * for IN transactions have (as parameters) buffers where retrieved data
    78  * will be stored. These buffers must be already allocated and shall not be
    79  * touch until the transaction is completed
    80  * (e.g. not before calling usb_wait_for() with appropriate handle).
    81  * OUT transactions buffers can be freed immediately after call is dispatched
    82  * (i.e. after return from wrapping function).
    83  *
    84  */
    85 typedef enum {
    86         /** Asks for address assignment by host controller.
    87          * Answer:
    88          * - ELIMIT - host controller run out of address
    89          * - EOK - address assigned
    90          * Answer arguments:
    91          * - assigned address
    92          *
    93          * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
    94          */
    95         IPC_M_USBHC_REQUEST_ADDRESS,
    96 
    97         /** Bind USB address with devman handle.
    98          * Parameters:
    99          * - USB address
    100          * - devman handle
    101          * Answer:
    102          * - EOK - address binded
    103          * - ENOENT - address is not in use
    104          */
    105         IPC_M_USBHC_BIND_ADDRESS,
    106 
    107         /** Get handle binded with given USB address.
    108          * Parameters
    109          * - USB address
    110          * Answer:
    111          * - EOK - address binded, first parameter is the devman handle
    112          * - ENOENT - address is not in use at the moment
    113          */
    114         IPC_M_USBHC_GET_HANDLE_BY_ADDRESS,
    115 
    116         /** Release address in use.
    117          * Arguments:
    118          * - address to be released
    119          * Answer:
    120          * - ENOENT - address not in use
    121          * - EPERM - trying to release default USB address
    122          */
    123         IPC_M_USBHC_RELEASE_ADDRESS,
    124 
    125         /** Register endpoint attributes at host controller.
    126          * This is used to reserve portion of USB bandwidth.
    127          * When speed is invalid, speed of the device is used.
    128          * Parameters:
    129          * - USB address + endpoint number
    130          *   - packed as ADDR << 16 + EP
    131          * - speed + transfer type + direction
    132          *   - packed as ( SPEED << 8 + TYPE ) << 8 + DIR
    133          * - maximum packet size + interval (in milliseconds)
    134          *   - packed as MPS << 16 + INT
    135          * Answer:
    136          * - EOK - reservation successful
    137          * - ELIMIT - not enough bandwidth to satisfy the request
    138          */
    139         IPC_M_USBHC_REGISTER_ENDPOINT,
    140 
    141         /** Revert endpoint registration.
    142          * Parameters:
    143          * - USB address
    144          * - endpoint number
    145          * - data direction
    146          * Answer:
    147          * - EOK - endpoint unregistered
    148          * - ENOENT - unknown endpoint
    149          */
    150         IPC_M_USBHC_UNREGISTER_ENDPOINT,
    151 
    152         /** Get data from device.
    153          * See explanation at usb_iface_funcs_t (IN transaction).
    154          */
    155         IPC_M_USBHC_READ,
    156 
    157         /** Send data to device.
    158          * See explanation at usb_iface_funcs_t (OUT transaction).
    159          */
    160         IPC_M_USBHC_WRITE,
    161 } usbhc_iface_funcs_t;
     46int usbhc_request_address(async_exch_t *, usb_address_t *, bool, usb_speed_t);
     47int usbhc_bind_address(async_exch_t *, usb_address_t, devman_handle_t);
     48int usbhc_get_handle(async_exch_t *, usb_address_t, devman_handle_t *);
     49int usbhc_release_address(async_exch_t *, usb_address_t);
     50int usbhc_register_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t,
     51    usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
     52int usbhc_unregister_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t,
     53    usb_direction_t);
     54int usbhc_read(async_exch_t *, usb_address_t, usb_endpoint_t,
     55    uint64_t, void *, size_t, size_t *);
     56int usbhc_write(async_exch_t *, usb_address_t, usb_endpoint_t,
     57    uint64_t, const void *, size_t);
    16258
    16359/** Callback for outgoing transfer. */
     
    17066/** USB host controller communication interface. */
    17167typedef struct {
    172         int (*request_address)(ddf_fun_t *, usb_speed_t, usb_address_t *);
     68        int (*request_address)(ddf_fun_t *, usb_address_t *, bool, usb_speed_t);
    17369        int (*bind_address)(ddf_fun_t *, usb_address_t, devman_handle_t);
    174         int (*find_by_address)(ddf_fun_t *, usb_address_t, devman_handle_t *);
     70        int (*get_handle)(ddf_fun_t *, usb_address_t,
     71            devman_handle_t *);
    17572        int (*release_address)(ddf_fun_t *, usb_address_t);
    17673
    17774        int (*register_endpoint)(ddf_fun_t *,
    178             usb_address_t, usb_speed_t, usb_endpoint_t,
     75            usb_address_t, usb_endpoint_t,
    17976            usb_transfer_type_t, usb_direction_t, size_t, unsigned int);
    18077        int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
Note: See TracChangeset for help on using the changeset viewer.