Changeset decfc8d1 in mainline


Ignore:
Timestamp:
2017-08-20T18:52:03Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3d8a3bd
Parents:
8b415cc
Message:

Dcbaa_virt now contains the virtual device contexts instead of just containing pointers to them, this eases its use a lot while wasting a negligale amount of memory.

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

Legend:

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

    r8b415cc rdecfc8d1  
    202202                return ENOMEM;
    203203
    204         hc->dcbaa_virt = malloc32((1 + hc->max_slots) * sizeof(xhci_device_ctx_t*));
     204        hc->dcbaa_virt = malloc32((1 + hc->max_slots) * sizeof(xhci_virt_device_ctx_t));
    205205        if (!hc->dcbaa_virt) {
    206206                err = ENOMEM;
     
    507507        /* Idx 0 already deallocated by xhci_scratchpad_free. */
    508508        for (unsigned i = 1; i < hc->max_slots + 1; ++i) {
    509                 if (hc->dcbaa_virt[i]) {
    510                         if (hc->dcbaa_virt[i]->dev_ctx)
    511                                 free32(hc->dcbaa_virt[i]->dev_ctx);
    512 
    513                         for (unsigned i = 0; i < XHCI_EP_COUNT; ++i) {
    514                                 trb_ring = hc->dcbaa_virt[i]->trs[i];
    515                                 if (trb_ring) {
    516                                         xhci_trb_ring_fini(trb_ring);
    517                                         free32(trb_ring);
    518                                 }
     509                if (hc->dcbaa_virt[i].dev_ctx) {
     510                        free32(hc->dcbaa_virt[i].dev_ctx);
     511                        hc->dcbaa_virt[i].dev_ctx = NULL;
     512                }
     513
     514                for (unsigned i = 0; i < XHCI_EP_COUNT; ++i) {
     515                        trb_ring = hc->dcbaa_virt[i].trs[i];
     516                        if (trb_ring) {
     517                                hc->dcbaa_virt[i].trs[i] = NULL;
     518                                xhci_trb_ring_fini(trb_ring);
     519                                free32(trb_ring);
    519520                        }
    520 
    521                         free32(hc->dcbaa_virt[i]);
    522                         hc->dcbaa_virt[i] = NULL;
    523521                }
    524522        }
  • uspace/drv/bus/usb/xhci/hc.h

    r8b415cc rdecfc8d1  
    7373        xhci_event_ring_t event_ring;
    7474        uint64_t *dcbaa;
    75         xhci_virt_device_ctx_t **dcbaa_virt;
     75        xhci_virt_device_ctx_t *dcbaa_virt;
    7676        xhci_scratchpad_t *scratchpad;
    7777
  • uspace/drv/bus/usb/xhci/rh.c

    r8b415cc rdecfc8d1  
    126126
    127127        hc->dcbaa[slot_id] = addr_to_phys(dctx);
    128         hc->dcbaa_virt[slot_id]->dev_ctx = dctx;
     128
     129        memset(&hc->dcbaa_virt[slot_id], 0, sizeof(xhci_virt_device_ctx_t));
     130        hc->dcbaa_virt[slot_id].dev_ctx = dctx;
    129131
    130132        cmd = xhci_alloc_command();
     
    145147                free32(dctx);
    146148                hc->dcbaa[slot_id] = 0;
    147                 hc->dcbaa_virt[slot_id] = NULL;
     149                memset(&hc->dcbaa_virt[slot_id], 0, sizeof(xhci_virt_device_ctx_t));
    148150        }
    149151err_ring:
  • uspace/drv/bus/usb/xhci/scratchpad.c

    r8b415cc rdecfc8d1  
    132132
    133133        hc->dcbaa[0] = 0;
    134         hc->dcbaa_virt[0] = NULL;
     134        memset(&hc->dcbaa_virt[0], 0, sizeof(xhci_virt_device_ctx_t));
     135
    135136        return;
    136137}
Note: See TracChangeset for help on using the changeset viewer.