Changeset 5ac5eb1 in mainline


Ignore:
Timestamp:
2017-07-13T14:26:47Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8db42f7
Parents:
c362127
Message:

Added means to send & handle disable slot command, improved cstyle and did some minor refactoring.

Location:
uspace/drv/bus/usb/xhci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/commands.c

    rc362127 r5ac5eb1  
    8181        trb.control |= host2xhci(32, hc->command_ring.pcs);
    8282
    83         // TODO: Setup input control context.
     83        return enqueue_trb(hc, &trb, 0, 0);
     84}
     85
     86int xhci_send_disable_slot_command(xhci_hc_t *hc, uint32_t slot_id)
     87{
     88        xhci_trb_t trb;
     89        memset(&trb, 0, sizeof(trb));
     90
     91        trb.control = host2xhci(32, XHCI_TRB_TYPE_DISABLE_SLOT_CMD << 10);
     92        trb.control |= host2xhci(32, hc->command_ring.pcs);
     93        trb.control |= host2xhci(32, slot_id << 24);
    8494
    8595        return enqueue_trb(hc, &trb, 0, 0);
     
    8898int xhci_handle_command_completion(xhci_hc_t *hc, xhci_trb_t *trb)
    8999{
    90         usb_log_debug2("HC(%p) Command completed.", hc);
     100        usb_log_debug("HC(%p) Command completed.", hc);
    91101        xhci_dump_trb(trb);
    92102
    93         int code = XHCI_DWORD_EXTRACT(trb->status, 31, 24);
     103        int code;
     104        uint32_t slot_id;
     105        xhci_trb_t *command;
    94106
    95         xhci_trb_t *command = (xhci_trb_t *) XHCI_QWORD_EXTRACT(trb->parameter, 63, 4);
     107        code = XHCI_DWORD_EXTRACT(trb->status, 31, 24);
     108        command = (xhci_trb_t *) XHCI_QWORD_EXTRACT(trb->parameter, 63, 4);
     109        slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24);
     110        (void) slot_id;
    96111
    97         switch(TRB_TYPE(*command)) {
     112        switch (TRB_TYPE(*command)) {
    98113        case XHCI_TRB_TYPE_NO_OP_CMD:
    99114                assert(code == XHCI_TRBC_TRB_ERROR);
    100115                break;
    101116        case XHCI_TRB_TYPE_ENABLE_SLOT_CMD:
    102         {
    103                 uint32_t slot_id = XHCI_DWORD_EXTRACT(trb->control, 31, 24);
    104                 (void) slot_id;
    105117                // TODO: Call a device addition callback once it's implemented.
    106                 //       Also check for a suitable type of the slot id.
    107118                break;
    108         }
     119        case XHCI_TRB_TYPE_DISABLE_SLOT_CMD:
     120                if (code == XHCI_TRBC_SLOT_NOT_ENABLED_ERROR)
     121                        usb_log_debug2("Slot ID to be disabled was not enabled.");
     122                // TODO: Call a device removal callback that will deallocate associated
     123                //       data structures once it's implemented.
     124                break;
    109125        default:
    110                 usb_log_warning("HC(%p) Command of an unsupported type has been completed.", hc);
     126                usb_log_debug2("Unsupported command trb.");
     127                xhci_dump_trb(command);
    111128                break;
    112129        }
  • uspace/drv/bus/usb/xhci/commands.h

    rc362127 r5ac5eb1  
    4242int xhci_send_no_op_command(xhci_hc_t *);
    4343int xhci_send_enable_slot_command(xhci_hc_t *);
     44int xhci_send_disable_slot_command(xhci_hc_t *, uint32_t);
    4445
    4546int xhci_handle_command_completion(xhci_hc_t *, xhci_trb_t *);
  • uspace/drv/bus/usb/xhci/hc.c

    rc362127 r5ac5eb1  
    360360static void hc_handle_event(xhci_hc_t *hc, xhci_trb_t *trb)
    361361{
    362         switch(TRB_TYPE(*trb)) {
     362        switch (TRB_TYPE(*trb)) {
    363363                case XHCI_TRB_TYPE_COMMAND_COMPLETION_EVENT:
    364364                        xhci_handle_command_completion(hc, trb);
Note: See TracChangeset for help on using the changeset viewer.