Changeset 17ceb72 in mainline


Ignore:
Timestamp:
2011-03-14T01:39:44Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6298d80
Parents:
3bd96bb
Message:

Doxygen

Location:
uspace
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • uspace/doc/doxygroups.h

    r3bd96bb r17ceb72  
    263263
    264264        /**
     265         * @defgroup drvusbuhcirh UHCI host controller driver
     266         * @ingroup drvusbuhci
     267         * @brief Driver for UHCI complaint USB host controller.
     268         */
     269
     270        /**
    265271         * @defgroup drvusbehci EHCI driver
    266272         * @ingroup usb
  • uspace/drv/uhci-hcd/batch.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver USB transaction structure
    3333 */
    3434#include <errno.h>
     
    5454
    5555
    56 /** Allocates memory and initializes internal data structures.
     56/** Allocate memory and initialize internal data structure.
    5757 *
    5858 * @param[in] fun DDF function to pass to callback.
     
    6969 * @param[in] arg additional parameter to func_in or func_out
    7070 * @param[in] manager Pointer to toggle management structure.
    71  * @return False, if there is an active TD, true otherwise.
     71 * @return Valid pointer if all substructures were successfully created,
     72 * NULL otherwise.
     73 *
     74 * Determines the number of needed packets (TDs). Prepares a transport buffer
     75 * (that is accessible by the hardware). Initializes parameters needed for the
     76 * transaction and callback.
    7277 */
    7378batch_t * batch_get(ddf_fun_t *fun, usb_target_t target,
     
    148153}
    149154/*----------------------------------------------------------------------------*/
    150 /** Checks batch TDs for activity.
     155/** Check batch TDs for activity.
    151156 *
    152157 * @param[in] instance Batch structure to use.
    153158 * @return False, if there is an active TD, true otherwise.
     159 *
     160 * Walk all TDs. Stop with false if there is an active one (it is to be
     161 * processed). Stop with true if an error is found. Return true if the last TS
     162 * is reached.
    154163 */
    155164bool batch_is_complete(batch_t *instance)
     
    190199 *
    191200 * @param[in] instance Batch structure to use.
     201 *
     202 * Uses genercir control function with pids OUT and IN.
    192203 */
    193204void batch_control_write(batch_t *instance)
    194205{
    195206        assert(instance);
    196         /* we are data out, we are supposed to provide data */
     207        /* We are data out, we are supposed to provide data */
    197208        memcpy(instance->transport_buffer, instance->buffer,
    198209            instance->buffer_size);
     
    205216 *
    206217 * @param[in] instance Batch structure to use.
     218 *
     219 * Uses generic control with pids IN and OUT.
    207220 */
    208221void batch_control_read(batch_t *instance)
     
    214227}
    215228/*----------------------------------------------------------------------------*/
    216 /** Prepares interrupt in transaction.
    217  *
    218  * @param[in] instance Batch structure to use.
     229/** Prepare interrupt in transaction.
     230 *
     231 * @param[in] instance Batch structure to use.
     232 *
     233 * Data transaction with PID_IN.
    219234 */
    220235void batch_interrupt_in(batch_t *instance)
     
    226241}
    227242/*----------------------------------------------------------------------------*/
    228 /** Prepares interrupt out transaction.
    229  *
    230  * @param[in] instance Batch structure to use.
     243/** Prepare interrupt out transaction.
     244 *
     245 * @param[in] instance Batch structure to use.
     246 *
     247 * Data transaction with PID_OUT.
    231248 */
    232249void batch_interrupt_out(batch_t *instance)
    233250{
    234251        assert(instance);
    235         /* we are data out, we are supposed to provide data */
     252        /* We are data out, we are supposed to provide data */
    236253        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    237254        batch_data(instance, USB_PID_OUT);
     
    240257}
    241258/*----------------------------------------------------------------------------*/
    242 /** Prepares bulk in transaction.
    243  *
    244  * @param[in] instance Batch structure to use.
     259/** Prepare bulk in transaction.
     260 *
     261 * @param[in] instance Batch structure to use.
     262 *
     263 * Data transaction with PID_IN.
    245264 */
    246265void batch_bulk_in(batch_t *instance)
     
    252271}
    253272/*----------------------------------------------------------------------------*/
    254 /** Prepares bulk out transaction.
    255  *
    256  * @param[in] instance Batch structure to use.
     273/** Prepare bulk out transaction.
     274 *
     275 * @param[in] instance Batch structure to use.
     276 *
     277 * Data transaction with PID_OUT.
    257278 */
    258279void batch_bulk_out(batch_t *instance)
    259280{
    260281        assert(instance);
     282        /* We are data out, we are supposed to provide data */
    261283        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    262284        batch_data(instance, USB_PID_OUT);
     
    265287}
    266288/*----------------------------------------------------------------------------*/
    267 /** Prepares generic data transaction
     289/** Prepare generic data transaction
    268290 *
    269291 * @param[in] instance Batch structure to use.
    270292 * @param[in] pid to use for data packets.
     293 *
     294 * Packets with alternating toggle bit and supplied pid value.
     295 * The last packet is marked with IOC flag.
    271296 */
    272297void batch_data(batch_t *instance, usb_packet_id pid)
     
    309334}
    310335/*----------------------------------------------------------------------------*/
    311 /** Prepares generic control transaction
     336/** Prepare generic control transaction
    312337 *
    313338 * @param[in] instance Batch structure to use.
    314339 * @param[in] data_stage to use for data packets.
    315340 * @param[in] status_stage to use for data packets.
     341 *
     342 * Setup stage with toggle 0 and USB_PID_SETUP.
     343 * Data stage with alternating toggle and pid supplied by parameter.
     344 * Status stage with toggle 1 and pid supplied by parameter.
     345 * The last packet is marked with IOC.
    316346 */
    317347void batch_control(batch_t *instance,
     
    362392}
    363393/*----------------------------------------------------------------------------*/
    364 /** Prepares data, gets error status and calls callback in.
    365  *
    366  * @param[in] instance Batch structure to use.
     394/** Prepare data, get error status and call callback in.
     395 *
     396 * @param[in] instance Batch structure to use.
     397 * Copies data from transport buffer, and calls callback with appropriate
     398 * parameters.
    367399 */
    368400void batch_call_in(batch_t *instance)
     
    371403        assert(instance->callback_in);
    372404
    373         /* we are data in, we need data */
     405        /* We are data in, we need data */
    374406        memcpy(instance->buffer, instance->transport_buffer,
    375407            instance->buffer_size);
     
    384416}
    385417/*----------------------------------------------------------------------------*/
    386 /** Gets error status and calls callback out.
     418/** Get error status and call callback out.
    387419 *
    388420 * @param[in] instance Batch structure to use.
     
    400432}
    401433/*----------------------------------------------------------------------------*/
    402 /** Prepares data, gets error status, calls callback in and dispose.
     434/** Helper function calls callback and correctly disposes of batch structure.
    403435 *
    404436 * @param[in] instance Batch structure to use.
     
    411443}
    412444/*----------------------------------------------------------------------------*/
    413 /** Gets error status, calls callback out and dispose.
     445/** Helper function calls callback and correctly disposes of batch structure.
    414446 *
    415447 * @param[in] instance Batch structure to use.
     
    422454}
    423455/*----------------------------------------------------------------------------*/
    424 /** Correctly disposes all used data structures.
     456/** Correctly dispose all used data structures.
    425457 *
    426458 * @param[in] instance Batch structure to use.
  • uspace/drv/uhci-hcd/batch.h

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver USB transaction structure
    3333 */
    3434#ifndef DRV_UHCI_BATCH_H
  • uspace/drv/uhci-hcd/iface.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver hc interface implementation
    3333 */
    3434#include <ddf/driver.h>
  • uspace/drv/uhci-hcd/iface.h

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup usb
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * @brief UHCI driver iface
    3434 */
    3535#ifndef DRV_UHCI_IFACE_H
  • uspace/drv/uhci-hcd/main.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver initialization
    3333 */
    3434#include <ddf/driver.h>
     
    5555};
    5656/*----------------------------------------------------------------------------*/
    57 /** Initializes a new ddf driver instance for uhci hc and hub.
     57/** Initialize a new ddf driver instance for uhci hc and hub.
    5858 *
    5959 * @param[in] device DDF instance of the device to initialize.
    6060 * @return Error code.
    61  *
    62  * Gets and initialies hardware resources, disables any legacy support,
    63  * and reports root hub device.
    6461 */
    6562int uhci_add_device(ddf_dev_t *device)
     
    8279}
    8380/*----------------------------------------------------------------------------*/
    84 /** Initializes global driver structures (NONE).
     81/** Initialize global driver structures (NONE).
    8582 *
    8683 * @param[in] argc Nmber of arguments in argv vector (ignored).
     
    9289int main(int argc, char *argv[])
    9390{
    94         sleep(3);
     91        sleep(3); /* TODO: remove in final version */
    9592        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    9693
  • uspace/drv/uhci-hcd/pci.c

    r3bd96bb r17ceb72  
    2727 */
    2828/**
    29  * @addtogroup drvusbuhci
     29 * @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
     
    117117}
    118118/*----------------------------------------------------------------------------*/
    119 /** Calls the PCI driver with a request to enable interrupts
     119/** Call the PCI driver with a request to enable interrupts
    120120 *
    121121 * @param[in] device Device asking for interrupts
     
    131131}
    132132/*----------------------------------------------------------------------------*/
    133 /** Calls the PCI driver with a request to clear legacy support register
     133/** Call the PCI driver with a request to clear legacy support register
    134134 *
    135135 * @param[in] device Device asking to disable interrupts
  • uspace/drv/uhci-hcd/pci.h

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * @brief UHCI driver PCI helper functions
    3434 */
    3535#ifndef DRV_UHCI_PCI_H
  • uspace/drv/uhci-hcd/transfer_list.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver transfer list implementation
    3333 */
    3434#include <errno.h>
    35 
    3635#include <usb/debug.h>
    3736
     
    4140    transfer_list_t *instance, batch_t *batch);
    4241/*----------------------------------------------------------------------------*/
    43 /** Initializes transfer list structures.
     42/** Initialize transfer list structures.
    4443 *
    4544 * @param[in] instance Memory place to use.
    46  * @param[in] name Name of te new list.
     45 * @param[in] name Name of the new list.
    4746 * @return Error code
    4847 *
     
    6665}
    6766/*----------------------------------------------------------------------------*/
    68 /** Set the next list in chain.
     67/** Set the next list in transfer list chain.
    6968 *
    7069 * @param[in] instance List to lead.
     
    7271 * @return Error code
    7372 *
    74  * Does not check whether there was a next list already.
     73 * Does not check whether this replaces an existing list .
    7574 */
    7675void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next)
     
    8079        if (!instance->queue_head)
    8180                return;
    82         /* set both next and element to point to the same QH */
     81        /* Set both next and element to point to the same QH */
    8382        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
    8483        qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8584}
    8685/*----------------------------------------------------------------------------*/
    87 /** Submits a new transfer batch to list and queue.
     86/** Submit transfer batch to the list and queue.
    8887 *
    8988 * @param[in] instance List to use.
    9089 * @param[in] batch Transfer batch to submit.
    9190 * @return Error code
     91 *
     92 * The batch is added to the end of the list and queue.
    9293 */
    9394void transfer_list_add_batch(transfer_list_t *instance, batch_t *batch)
     
    106107        fibril_mutex_lock(&instance->guard);
    107108
     109        /* Add to the hardware queue. */
    108110        if (list_empty(&instance->batch_list)) {
    109111                /* There is nothing scheduled */
     
    117119                qh_set_next_qh(last->qh, pa);
    118120        }
     121        /* Add to the driver list */
    119122        list_append(&batch->link, &instance->batch_list);
    120123
     
    126129}
    127130/*----------------------------------------------------------------------------*/
    128 /** Removes a transfer batch from the list and queue.
     131/** Remove a transfer batch from the list and queue.
    129132 *
    130133 * @param[in] instance List to use.
     
    144147
    145148        const char * pos = NULL;
     149        /* Remove from the hardware queue */
    146150        if (batch->link.prev == &instance->batch_list) {
    147151                /* I'm the first one here */
     
    154158                pos = "NOT FIRST";
    155159        }
     160        /* Remove from the driver list */
    156161        list_remove(&batch->link);
    157162        usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
     
    159164}
    160165/*----------------------------------------------------------------------------*/
    161 /** Checks list for finished batches.
     166/** Check list for finished batches.
    162167 *
    163168 * @param[in] instance List to use.
    164169 * @return Error code
     170 *
     171 * Creates a local list of finished batches and calls next_step on each and
     172 * every one. This is safer because next_step may theoretically access
     173 * this transfer list leading to the deadlock if its done inline.
    165174 */
    166175void transfer_list_remove_finished(transfer_list_t *instance)
     
    177186
    178187                if (batch_is_complete(batch)) {
     188                        /* Save for post-processing */
    179189                        transfer_list_remove_batch(instance, batch);
    180190                        list_append(current, &done);
  • uspace/drv/uhci-hcd/transfer_list.h

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI driver transfer list structure
    3333 */
    3434#ifndef DRV_UHCI_TRANSFER_LIST_H
     
    5050} transfer_list_t;
    5151
    52 int transfer_list_init(transfer_list_t *instance, const char *name);
    53 
    54 void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);
    55 
     52/** Dispose transfer list structures.
     53 *
     54 * @param[in] instance Memory place to use.
     55 *
     56 * Frees memory for internal qh_t structure.
     57 */
    5658static inline void transfer_list_fini(transfer_list_t *instance)
    5759{
     
    5961        free32(instance->queue_head);
    6062}
     63
     64int transfer_list_init(transfer_list_t *instance, const char *name);
     65
     66void transfer_list_set_next(transfer_list_t *instance, transfer_list_t *next);
     67
    6168void transfer_list_remove_finished(transfer_list_t *instance);
    6269
  • uspace/drv/uhci-hcd/uhci.c

    r3bd96bb r17ceb72  
    6060}
    6161/*----------------------------------------------------------------------------*/
     62/** Get address of the device identified by handle.
     63 *
     64 * @param[in] dev DDF instance of the device to use.
     65 * @param[in] iid (Unused).
     66 * @param[in] call Pointer to the call that represents interrupt.
     67 */
    6268static int usb_iface_get_address(
    6369    ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address)
     
    106112};
    107113/*----------------------------------------------------------------------------*/
    108 /** Gets root hub hw resources.
     114/** Get root hub hw resources (I/O registers).
    109115 *
    110116 * @param[in] fun Root hub function.
     
    127133};
    128134/*----------------------------------------------------------------------------*/
     135/** Initialize hc and rh ddf structures and their respective drivers.
     136 *
     137 * @param[in] instance UHCI structure to use.
     138 * @param[in] device DDF instance of the device to use.
     139 *
     140 * This function does all the preparatory work for hc and rh drivers:
     141 *  - gets device hw resources
     142 *  - disables UHCI legacy support
     143 *  - asks for interrupt
     144 *  - registers interrupt handler
     145 */
    129146int uhci_init(uhci_t *instance, ddf_dev_t *device)
    130147{
  • uspace/drv/uhci-hcd/uhci.h

    r3bd96bb r17ceb72  
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * @brief UHCI driver main structure for both host controller and root-hub.
    3434 */
    3535#ifndef DRV_UHCI_UHCI_H
  • uspace/drv/uhci-hcd/uhci_hc.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
    3131/** @file
    32  * @brief UHCI driver
     32 * @brief UHCI Host controller driver routines
    3333 */
    3434#include <errno.h>
     
    5959        }
    6060};
    61 
    62 /** Gets USB address of the calling device.
    63  *
    64  * @param[in] fun UHCI hc function.
    65  * @param[in] handle Handle of the device seeking address.
    66  * @param[out] address Place to store found address.
    67  * @return Error code.
    68  */
    6961/*----------------------------------------------------------------------------*/
    7062static int uhci_hc_init_transfer_lists(uhci_hc_t *instance);
     
    7870    bool low_speed, usb_transfer_type_t transfer, size_t size);
    7971/*----------------------------------------------------------------------------*/
    80 /** Initializes UHCI hcd driver structure
     72/** Initialize UHCI hcd driver structure
    8173 *
    8274 * @param[in] instance Memory place to initialize.
     
    8678 * @return Error code.
    8779 * @note Should be called only once on any structure.
     80 *
     81 * Initializes memory structures, starts up hw, and launches debugger and
     82 * interrupt fibrils.
    8883 */
    8984int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size)
     
    130125}
    131126/*----------------------------------------------------------------------------*/
    132 /** Initializes UHCI hcd hw resources.
     127/** Initialize UHCI hc hw resources.
    133128 *
    134129 * @param[in] instance UHCI structure to use.
     130 * For magic values see UHCI Design Guide
    135131 */
    136132void uhci_hc_init_hw(uhci_hc_t *instance)
     
    154150
    155151        /* Enable all interrupts, but resume interrupt */
    156 //      pio_write_16(&instance->registers->usbintr,
    157 //          UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
     152        pio_write_16(&instance->registers->usbintr,
     153            UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
    158154
    159155        uint16_t status = pio_read_16(&registers->usbcmd);
     
    166162}
    167163/*----------------------------------------------------------------------------*/
    168 /** Initializes UHCI hcd memory structures.
     164/** Initialize UHCI hc memory structures.
    169165 *
    170166 * @param[in] instance UHCI structure to use.
    171167 * @return Error code
    172168 * @note Should be called only once on any structure.
     169 *
     170 * Structures:
     171 *  - interrupt code (I/O addressses are customized per instance)
     172 *  - transfer lists (queue heads need to be accessible by the hw)
     173 *  - frame list page (needs to be one UHCI hw accessible 4K page)
    173174 */
    174175int uhci_hc_init_mem_structures(uhci_hc_t *instance)
     
    229230}
    230231/*----------------------------------------------------------------------------*/
    231 /** Initializes UHCI hcd transfer lists.
     232/** Initialize UHCI hc transfer lists.
    232233 *
    233234 * @param[in] instance UHCI structure to use.
    234235 * @return Error code
    235236 * @note Should be called only once on any structure.
     237 *
     238 * Initializes transfer lists and sets them in one chain to support proper
     239 * USB scheduling. Sets pointer table for quick access.
    236240 */
    237241int uhci_hc_init_transfer_lists(uhci_hc_t *instance)
     
    293297}
    294298/*----------------------------------------------------------------------------*/
    295 /** Schedules batch for execution.
     299/** Schedule batch for execution.
    296300 *
    297301 * @param[in] instance UHCI structure to use.
    298302 * @param[in] batch Transfer batch to schedule.
    299303 * @return Error code
     304 *
     305 * Checks for bandwidth availability and appends the batch to the proper queue.
    300306 */
    301307int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch)
     
    312318                return ENOTSUP;
    313319        }
    314         /* TODO: check available bandwith here */
     320        /* TODO: check available bandwidth here */
    315321
    316322        transfer_list_t *list =
     
    322328}
    323329/*----------------------------------------------------------------------------*/
    324 /** Takes action based on the interrupt cause.
     330/** Take action based on the interrupt cause.
    325331 *
    326332 * @param[in] instance UHCI structure to use.
    327  * @param[in] status Value of the stsatus regiser at the time of interrupt.
     333 * @param[in] status Value of the status register at the time of interrupt.
     334 *
     335 * Interrupt might indicate:
     336 * - transaction completed, either by triggering IOC, SPD, or an error
     337 * - some kind of device error
     338 * - resume from suspend state (not implemented)
    328339 */
    329340void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status)
     
    342353/** Polling function, emulates interrupts.
    343354 *
    344  * @param[in] arg UHCI structure to use.
    345  * @return EOK
     355 * @param[in] arg UHCI hc structure to use.
     356 * @return EOK (should never return)
    346357 */
    347358int uhci_hc_interrupt_emulator(void* arg)
     
    366377 *
    367378 * @param[in] arg UHCI structure to use.
    368  * @return EOK
     379 * @return EOK (should never return)
    369380 */
    370381int uhci_hc_debug_checker(void *arg)
     
    430441}
    431442/*----------------------------------------------------------------------------*/
    432 /** Checks transfer packets, for USB validity
     443/** Check transfer packets, for USB validity
    433444 *
    434445 * @param[in] low_speed Transfer speed.
    435446 * @param[in] transfer Transer type
    436447 * @param[in] size Maximum size of used packets
    437  * @return EOK
     448 * @return True if transaction is allowed by USB specs, false otherwise
    438449 */
    439450bool allowed_usb_packet(
  • uspace/drv/uhci-hcd/uhci_hc.h

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
    3232/** @file
    33  * @brief UHCI driver
     33 * @brief UHCI host controller driver structure
    3434 */
    3535#ifndef DRV_UHCI_UHCI_HC_H
     
    103103} uhci_hc_t;
    104104
    105 /* init uhci specifics in device.driver_data */
    106105int uhci_hc_init(uhci_hc_t *instance, ddf_fun_t *fun, void *regs, size_t reg_size);
    107 
    108 static inline void uhci_hc_fini(uhci_hc_t *instance) { /* TODO: implement*/ };
    109106
    110107int uhci_hc_schedule(uhci_hc_t *instance, batch_t *batch);
     
    112109void uhci_hc_interrupt(uhci_hc_t *instance, uint16_t status);
    113110
     111/** Safely dispose host controller internal structures
     112 *
     113 * @param[in] instance Host controller structure to use.
     114 */
     115static inline void uhci_hc_fini(uhci_hc_t *instance) { /* TODO: implement*/ };
     116
     117/** Get and cast pointer to the driver data
     118 *
     119 * @param[in] fun DDF function pointer
     120 * @return cast pointer to driver_data
     121 */
    114122static inline uhci_hc_t * fun_to_uhci_hc(ddf_fun_t *fun)
    115123        { return (uhci_hc_t*)fun->driver_data; }
  • uspace/drv/uhci-hcd/uhci_rh.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhci
    2929 * @{
    3030 */
     
    4242#include "uhci_hc.h"
    4343
    44 /*----------------------------------------------------------------------------*/
     44/** Root hub initialization
     45 * @param[in] instance RH structure to initialize
     46 * @param[in] fun DDF function representing UHCI root hub
     47 * @param[in] reg_addr Address of root hub status and control registers.
     48 * @param[in] reg_size Size of accessible address space.
     49 * @return Error code.
     50 */
    4551int uhci_rh_init(
    4652    uhci_rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size)
     
    6874        instance->io_regs.type = IO_RANGE;
    6975        instance->io_regs.res.io_range.address = reg_addr;
    70 //          ((uintptr_t)hc->registers) + 0x10; // see UHCI design guide
    7176        instance->io_regs.res.io_range.size = reg_size;
    7277        instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN;
  • uspace/drv/uhci-hcd/uhci_struct/link_pointer.h

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
  • uspace/drv/uhci-hcd/uhci_struct/queue_head.h

    r3bd96bb r17ceb72  
    1 
    21/*
    32 * Copyright (c) 2010 Jan Vesely
     
    2726 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2827 */
    29 /** @addtogroup usb
     28/** @addtogroup drv usbuhcihc
    3029 * @{
    3130 */
     
    4746} __attribute__((packed)) qh_t;
    4847/*----------------------------------------------------------------------------*/
     48/** Initialize queue head structure
     49 *
     50 * @param[in] instance qh_t structure to initialize.
     51 *
     52 * Sets both pointer to terminal NULL.
     53 */
    4954static inline void qh_init(qh_t *instance)
    5055{
     
    5560}
    5661/*----------------------------------------------------------------------------*/
     62/** Set queue head next pointer
     63 *
     64 * @param[in] instance qh_t structure to use.
     65 * @param[in] pa Physical address of the next queue head.
     66 *
     67 * Adds proper flag. If the pointer is NULL or terminal, sets next to terminal
     68 * NULL.
     69 */
    5770static inline void qh_set_next_qh(qh_t *instance, uint32_t pa)
    5871{
    59         /* address is valid and not terminal */
     72        /* Address is valid and not terminal */
    6073        if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) {
    6174                instance->next = (pa & LINK_POINTER_ADDRESS_MASK)
     
    6679}
    6780/*----------------------------------------------------------------------------*/
     81/** Set queue head element pointer
     82 *
     83 * @param[in] instance qh_t structure to initialize.
     84 * @param[in] pa Physical address of the next queue head.
     85 *
     86 * Adds proper flag. If the pointer is NULL or terminal, sets element
     87 * to terminal NULL.
     88 */
    6889static inline void qh_set_element_qh(qh_t *instance, uint32_t pa)
    6990{
    70         /* address is valid and not terminal */
     91        /* Address is valid and not terminal */
    7192        if (pa && ((pa & LINK_POINTER_TERMINATE_FLAG) == 0)) {
    7293                instance->element = (pa & LINK_POINTER_ADDRESS_MASK)
     
    7798}
    7899/*----------------------------------------------------------------------------*/
     100/** Set queue head element pointer
     101 *
     102 * @param[in] instance qh_t structure to initialize.
     103 * @param[in] pa Physical address of the TD structure.
     104 *
     105 * Adds proper flag. If the pointer is NULL or terminal, sets element
     106 * to terminal NULL.
     107 */
    79108static inline void qh_set_element_td(qh_t *instance, uint32_t pa)
    80109{
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c

    r3bd96bb r17ceb72  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
     
    3838#include "utils/malloc32.h"
    3939
    40 /** Initializes Transfer Descriptor
     40/** Initialize Transfer Descriptor
    4141 *
    4242 * @param[in] instance Memory place to initialize.
     
    106106}
    107107/*----------------------------------------------------------------------------*/
    108 /** Converts TD status into standard error code
     108/** Convert TD status into standard error code
    109109 *
    110110 * @param[in] instance TD structure to use.
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h

    r3bd96bb r17ceb72  
    11/*
    2  * Copyright (c) 2010 Jan Vesely
     2 * Copyright (c) 2011 Jan Vesely
    33 * All rights reserved.
    44 *
     
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 /** @addtogroup usb
     28/** @addtogroup drvusbuhcihc
    2929 * @{
    3030 */
     
    108108}
    109109/*----------------------------------------------------------------------------*/
    110 /** Checks whether less than max data were recieved and packet is marked as SPD.
     110/** Check whether less than max data were recieved and packet is marked as SPD.
    111111 *
    112112 * @param[in] instance TD structure to use.
  • uspace/drv/uhci-hcd/utils/device_keeper.c

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
     
    4040
    4141/*----------------------------------------------------------------------------*/
    42 /** Initializes device keeper structure.
     42/** Initialize device keeper structure.
    4343 *
    4444 * @param[in] instance Memory place to initialize.
     45 *
     46 * Set all values to false/0.
    4547 */
    4648void device_keeper_init(device_keeper_t *instance)
     
    5860}
    5961/*----------------------------------------------------------------------------*/
    60 /** Attempts to obtain address 0, blocks.
     62/** Attempt to obtain address 0, blocks.
    6163 *
    6264 * @param[in] instance Device keeper structure to use.
     
    7678}
    7779/*----------------------------------------------------------------------------*/
    78 /** Attempts to obtain address 0, blocks.
     80/** Attempt to obtain address 0, blocks.
    7981 *
    8082 * @param[in] instance Device keeper structure to use.
     
    9092}
    9193/*----------------------------------------------------------------------------*/
    92 /** Checks setup data for signs of toggle reset.
     94/** Check setup packet data for signs of toggle reset.
    9395 *
    9496 * @param[in] instance Device keeper structure to use.
    9597 * @param[in] target Device to receive setup packet.
    9698 * @param[in] data Setup packet data.
     99 *
     100 * Really ugly one.
    97101 */
    98102void device_keeper_reset_if_need(
     
    105109            || !instance->devices[target.address].occupied) {
    106110                fibril_mutex_unlock(&instance->guard);
     111                usb_log_error("Invalid data when checking for toggle reset.\n");
    107112                return;
    108113        }
     
    130135}
    131136/*----------------------------------------------------------------------------*/
    132 /** Gets current value of endpoint toggle.
     137/** Get current value of endpoint toggle.
    133138 *
    134139 * @param[in] instance Device keeper structure to use.
     
    144149            || target.address >= USB_ADDRESS_COUNT || target.address < 0
    145150            || !instance->devices[target.address].occupied) {
     151                usb_log_error("Invalid data when asking for toggle value.\n");
    146152                ret = EINVAL;
    147153        } else {
    148                 ret =
    149                     (instance->devices[target.address].toggle_status
     154                ret = (instance->devices[target.address].toggle_status
    150155                        >> target.endpoint) & 1;
    151156        }
     
    154159}
    155160/*----------------------------------------------------------------------------*/
    156 /** Sets current value of endpoint toggle.
     161/** Set current value of endpoint toggle.
    157162 *
    158163 * @param[in] instance Device keeper structure to use.
    159164 * @param[in] target Device and endpoint used.
    160  * @param[in] toggle Current toggle value.
     165 * @param[in] toggle Toggle value.
    161166 * @return Error code.
    162167 */
     
    170175            || target.address >= USB_ADDRESS_COUNT || target.address < 0
    171176            || !instance->devices[target.address].occupied) {
     177                usb_log_error("Invalid data when setting toggle value.\n");
    172178                ret = EINVAL;
    173179        } else {
     
    183189}
    184190/*----------------------------------------------------------------------------*/
    185 /** Gets a free USB address
     191/** Get a free USB address
    186192 *
    187193 * @param[in] instance Device keeper structure to use.
     
    216222}
    217223/*----------------------------------------------------------------------------*/
    218 /** Binds USB address to devman handle.
     224/** Bind USB address to devman handle.
    219225 *
    220226 * @param[in] instance Device keeper structure to use.
     
    234240}
    235241/*----------------------------------------------------------------------------*/
    236 /** Releases used USB address.
     242/** Release used USB address.
    237243 *
    238244 * @param[in] instance Device keeper structure to use.
     
    251257}
    252258/*----------------------------------------------------------------------------*/
    253 /** Finds USB address associated with the device
     259/** Find USB address associated with the device
    254260 *
    255261 * @param[in] instance Device keeper structure to use.
     
    274280}
    275281/*----------------------------------------------------------------------------*/
    276 /** Gets speed associated with the address
     282/** Get speed associated with the address
    277283 *
    278284 * @param[in] instance Device keeper structure to use.
  • uspace/drv/uhci-hcd/utils/device_keeper.h

    r3bd96bb r17ceb72  
    2727 */
    2828
    29 /** @addtogroup drvusbuhci
     29/** @addtogroup drvusbuhcihc
    3030 * @{
    3131 */
  • uspace/drv/uhci-hcd/utils/malloc32.h

    r3bd96bb r17ceb72  
    4343#define UHCI_REQUIRED_PAGE_SIZE 4096
    4444
     45/** Get physical address translation
     46 *
     47 * @param[in] addr Virtual address to translate
     48 * @return Physical address if exists, NULL otherwise.
     49 */
    4550static inline uintptr_t addr_to_phys(void *addr)
    4651{
     
    4853        int ret = as_get_physical_mapping(addr, &result);
    4954
    50         assert(ret == 0);
     55        if (ret != EOK)
     56                return 0;
    5157        return (result | ((uintptr_t)addr & 0xfff));
    5258}
    53 
     59/*----------------------------------------------------------------------------*/
     60/** Physical mallocator simulator
     61 *
     62 * @param[in] size Size of the required memory space
     63 * @return Address of the alligned and big enough memory place, NULL on failure.
     64 */
    5465static inline void * malloc32(size_t size)
    5566        { return memalign(UHCI_STRCUTURES_ALIGNMENT, size); }
    56 
    57 static inline void * get_page()
     67/*----------------------------------------------------------------------------*/
     68/** Physical mallocator simulator
     69 *
     70 * @param[in] addr Address of the place allocated by malloc32
     71 */
     72static inline void free32(void *addr)
     73        { if (addr) free(addr); }
     74/*----------------------------------------------------------------------------*/
     75/** Create 4KB page mapping
     76 *
     77 * @return Address of the mapped page, NULL on failure.
     78 */
     79static inline void * get_page(void)
    5880{
    5981        void * free_address = as_get_mappable_page(UHCI_REQUIRED_PAGE_SIZE);
    6082        assert(free_address);
    6183        if (free_address == 0)
    62                 return 0;
     84                return NULL;
    6385        void* ret =
    6486          as_area_create(free_address, UHCI_REQUIRED_PAGE_SIZE,
    6587                  AS_AREA_READ | AS_AREA_WRITE);
    6688        if (ret != free_address)
    67                 return 0;
     89                return NULL;
    6890        return ret;
    6991}
    70 
    71 static inline void free32(void *addr)
    72         { if (addr) free(addr); }
    7392
    7493#endif
Note: See TracChangeset for help on using the changeset viewer.