Changeset 6843a9c in mainline for uspace/lib/drv/include
- Timestamp:
- 2012-06-29T13:02:14Z (13 years ago)
- 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. - Location:
- uspace/lib/drv/include
- Files:
-
- 6 edited
-
ddf/driver.h (modified) (4 diffs)
-
ddf/interrupt.h (modified) (2 diffs)
-
ops/hw_res.h (modified) (1 diff)
-
ops/nic.h (modified) (2 diffs)
-
usb_iface.h (modified) (1 diff)
-
usbhc_iface.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/include/ddf/driver.h
rba72f2b r6843a9c 81 81 */ 82 82 devman_handle_t handle; 83 83 84 /** Reference count */ 84 85 atomic_t refcnt; … … 104 105 /** True if bound to the device manager */ 105 106 bool bound; 107 106 108 /** Function indentifier (asigned by device manager) */ 107 109 devman_handle_t handle; 110 108 111 /** Reference count */ 109 112 atomic_t refcnt; … … 114 117 /** Function type */ 115 118 fun_type_t ftype; 119 116 120 /** Function name */ 117 121 const char *name; 122 118 123 /** List of device ids for driver matching */ 119 124 match_id_list_t match_ids; 125 120 126 /** Driver-specific data associated with this function */ 121 127 void *driver_data; 128 122 129 /** Implementation of operations provided by this function */ 123 130 ddf_dev_ops_t *ops; 131 124 132 /** Connection handler or @c NULL to use the DDF default handler. */ 125 133 async_client_conn_t conn_handler; … … 136 144 typedef struct driver_ops { 137 145 /** 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 145 148 /** Ask driver to remove a device */ 146 149 int (*dev_remove)(ddf_dev_t *); 150 147 151 /** Inform driver a device disappeared */ 148 152 int (*dev_gone)(ddf_dev_t *); 153 149 154 /** Ask driver to online a specific function */ 150 155 int (*fun_online)(ddf_fun_t *); 156 151 157 /** Ask driver to offline a specific function */ 152 158 int (*fun_offline)(ddf_fun_t *); -
uspace/lib/drv/include/ddf/interrupt.h
rba72f2b r6843a9c 36 36 #define DDF_INTERRUPT_H_ 37 37 38 #include <libarch/common.h> 39 #include <libarch/types.h> 38 40 #include <abi/ddi/irq.h> 39 41 #include <adt/list.h> 40 42 #include <ddi.h> 41 43 #include <fibril_synch.h> 42 43 44 #include "driver.h" 44 45 #include "../dev_iface.h" … … 64 65 } interrupt_context_list_t; 65 66 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 67 extern void interrupt_init(void); 78 68 extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *, 79 69 irq_code_t *); -
uspace/lib/drv/include/ops/hw_res.h
rba72f2b r6843a9c 39 39 #include <device/hw_res.h> 40 40 #include <sys/types.h> 41 42 41 #include "../ddf/driver.h" 43 42 44 43 typedef 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); 49 47 } hw_res_ops_t; 50 48 -
uspace/lib/drv/include/ops/nic.h
rba72f2b r6843a9c 37 37 #define LIBDRV_OPS_NIC_H_ 38 38 39 #include <net/packet.h>40 39 #include <ipc/services.h> 41 #include <n et/device.h>40 #include <nic/nic.h> 42 41 #include <sys/time.h> 43 44 42 #include "../ddf/driver.h" 45 43 46 44 typedef struct nic_iface { 47 45 /** Mandatory methods */ 48 int (*send_ message)(ddf_fun_t *, packet_id_t);49 int (*c onnect_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 *); 50 48 int (*get_state)(ddf_fun_t *, nic_device_state_t *); 51 49 int (*set_state)(ddf_fun_t *, nic_device_state_t); … … 89 87 int (*vlan_get_mask)(ddf_fun_t *, nic_vlan_mask_t *); 90 88 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); 92 90 93 91 int (*wol_virtue_add)(ddf_fun_t *, nic_wv_type_t, const void *, -
uspace/lib/drv/include/usb_iface.h
rba72f2b r6843a9c 39 39 40 40 #include "ddf/driver.h" 41 #include <async.h> 41 42 #include <usb/usb.h> 42 typedef enum {43 /** Tell USB address assigned to device.44 * Parameters:45 * - devman handle id46 * Answer:47 * - EINVAL - unknown handle or handle not managed by this driver48 * - ENOTSUP - operation not supported (shall not happen)49 * - arbitrary error code if returned by remote implementation50 * - EOK - handle found, first parameter contains the USB address51 *52 * The handle must be the one used for binding USB address with53 * it (IPC_M_USBHC_BIND_ADDRESS), otherwise the host controller54 * (that this request would eventually reach) would not be able55 * to find it.56 * The problem is that this handle is actually assigned to the57 * function inside driver of the parent device (usually hub driver).58 * To bypass this problem, the initial caller specify handle as59 * zero and the first parent assigns the actual value.60 * See usb_iface_get_address_hub_child_impl() implementation61 * that could be assigned to device ops of a child device of in a62 * hub driver.63 * For example, the USB multi interface device driver (MID)64 * passes this initial zero without any modification because the65 * handle must be resolved by its parent.66 */67 IPC_M_USB_GET_ADDRESS,68 43 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; 44 int usb_get_my_address(async_exch_t *, usb_address_t *); 45 int usb_get_my_interface(async_exch_t *, int *); 46 int usb_get_hc_handle(async_exch_t *, devman_handle_t *); 89 47 90 48 /** USB device communication interface. */ 91 49 typedef 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 *); 94 52 int (*get_hc_handle)(ddf_fun_t *, devman_handle_t *); 95 53 } usb_iface_t; 96 97 54 98 55 #endif -
uspace/lib/drv/include/usbhc_iface.h
rba72f2b r6843a9c 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2011 Jan Vesely 3 4 * All rights reserved. 4 5 * … … 31 32 * @{ 32 33 */ 34 33 35 /** @file 34 36 * @brief USB host controller interface definition. … … 42 44 #include <bool.h> 43 45 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; 46 int usbhc_request_address(async_exch_t *, usb_address_t *, bool, usb_speed_t); 47 int usbhc_bind_address(async_exch_t *, usb_address_t, devman_handle_t); 48 int usbhc_get_handle(async_exch_t *, usb_address_t, devman_handle_t *); 49 int usbhc_release_address(async_exch_t *, usb_address_t); 50 int usbhc_register_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t, 51 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); 52 int usbhc_unregister_endpoint(async_exch_t *, usb_address_t, usb_endpoint_t, 53 usb_direction_t); 54 int usbhc_read(async_exch_t *, usb_address_t, usb_endpoint_t, 55 uint64_t, void *, size_t, size_t *); 56 int usbhc_write(async_exch_t *, usb_address_t, usb_endpoint_t, 57 uint64_t, const void *, size_t); 162 58 163 59 /** Callback for outgoing transfer. */ … … 170 66 /** USB host controller communication interface. */ 171 67 typedef 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); 173 69 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 *); 175 72 int (*release_address)(ddf_fun_t *, usb_address_t); 176 73 177 74 int (*register_endpoint)(ddf_fun_t *, 178 usb_address_t, usb_ speed_t, usb_endpoint_t,75 usb_address_t, usb_endpoint_t, 179 76 usb_transfer_type_t, usb_direction_t, size_t, unsigned int); 180 77 int (*unregister_endpoint)(ddf_fun_t *, usb_address_t, usb_endpoint_t,
Note:
See TracChangeset
for help on using the changeset viewer.
