Ticket #8833: usb.x86-64.patch

File usb.x86-64.patch, 51.9 KB (added by anevilyak, 7 years ago)
  • src/add-ons/kernel/bus_managers/usb/Device.cpp

    diff --git a/src/add-ons/kernel/bus_managers/usb/Device.cpp b/src/add-ons/kernel/bus_managers/usb/Device.cpp
    index e169952..1d6ce1b 100644
    a b Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,  
    8181            &actualLength);
    8282
    8383        if (status < B_OK || actualLength != sizeof(usb_configuration_descriptor)) {
    84             TRACE_ERROR("error fetching configuration %ld\n", i);
     84            TRACE_ERROR("error fetching configuration %" B_PRId32 "\n", i);
    8585            return;
    8686        }
    8787
    88         TRACE("configuration %ld\n", i);
     88        TRACE("configuration %" B_PRId32 "\n", i);
    8989        TRACE("\tlength:..............%d\n", configDescriptor.length);
    9090        TRACE("\tdescriptor_type:.....0x%02x\n", configDescriptor.descriptor_type);
    9191        TRACE("\ttotal_length:........%d\n", configDescriptor.total_length);
    Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,  
    106106
    107107        if (status < B_OK || actualLength != configDescriptor.total_length) {
    108108            TRACE_ERROR("error fetching full configuration"
    109                 " descriptor %ld got %lu expected %u\n", i,
    110                 actualLength, configDescriptor.total_length);
     109                " descriptor %" B_PRId32 " got %" B_PRIuSIZE " expected %"
     110                B_PRIu16 "\n", i, actualLength, configDescriptor.total_length);
    111111            free(configData);
    112112            return;
    113113        }
  • src/add-ons/kernel/bus_managers/usb/Hub.cpp

    diff --git a/src/add-ons/kernel/bus_managers/usb/Hub.cpp b/src/add-ons/kernel/bus_managers/usb/Hub.cpp
    index df51aea..271efaf 100644
    a b Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort,  
    8787            USB_REQUEST_SET_FEATURE, PORT_POWER, i + 1, 0, NULL, 0, NULL);
    8888
    8989        if (status < B_OK)
    90             TRACE_ERROR("power up failed on port %ld\n", i);
     90            TRACE_ERROR("power up failed on port %" B_PRId32 "\n", i);
    9191    }
    9292
    9393    // Wait for power to stabilize
    Hub::Explore(change_item **changeList)  
    201201
    202202#ifdef TRACE_USB
    203203        if (fPortStatus[i].change) {
    204             TRACE("port %ld: status: 0x%04x; change: 0x%04x\n", i,
     204            TRACE("port %" B_PRId32 ": status: 0x%04x; change: 0x%04x\n", i,
    205205                fPortStatus[i].status, fPortStatus[i].change);
    206             TRACE("device at port %ld: %p (%ld)\n", i, fChildren[i],
    207                 fChildren[i] != NULL ? fChildren[i]->USBID() : 0);
     206            TRACE("device at port %" B_PRId32 ": %p (%" B_PRId32 ")\n", i,
     207                fChildren[i], fChildren[i] != NULL
     208                    ? fChildren[i]->USBID() : 0);
    208209        }
    209210#endif
    210211
    Hub::Explore(change_item **changeList)  
    216217
    217218            if (fPortStatus[i].status & PORT_STATUS_CONNECTION) {
    218219                // new device attached!
    219                 TRACE_ALWAYS("port %ld: new device connected\n", i);
     220                TRACE_ALWAYS("port %" B_PRId32 ": new device connected\n", i);
    220221
    221222                int32 retry = 2;
    222223                while (retry--) {
    Hub::Explore(change_item **changeList)  
    226227                    // reset the port, this will also enable it
    227228                    result = ResetPort(i);
    228229                    if (result < B_OK) {
    229                         TRACE_ERROR("resetting port %ld failed\n", i);
     230                        TRACE_ERROR("resetting port %" B_PRId32 " failed\n",
     231                            i);
    230232                        break;
    231233                    }
    232234
    Hub::Explore(change_item **changeList)  
    282284                }
    283285            } else {
    284286                // Device removed...
    285                 TRACE_ALWAYS("port %ld: device removed\n", i);
     287                TRACE_ALWAYS("port %" B_PRId32 ": device removed\n", i);
    286288                if (fChildren[i] != NULL) {
    287289                    TRACE("removing device %p\n", fChildren[i]);
    288290                    fChildren[i]->Changed(changeList, false);
    Hub::Explore(change_item **changeList)  
    293295
    294296        // other port changes we do not really handle, report and clear them
    295297        if (fPortStatus[i].change & PORT_STATUS_ENABLE) {
    296             TRACE_ALWAYS("port %ld %sabled\n", i, (fPortStatus[i].status & PORT_STATUS_ENABLE) ? "en" : "dis");
     298            TRACE_ALWAYS("port %" B_PRId32 " %sabled\n", i,
     299                (fPortStatus[i].status & PORT_STATUS_ENABLE) ? "en" : "dis");
    297300            DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
    298301                USB_REQUEST_CLEAR_FEATURE, C_PORT_ENABLE, i + 1,
    299302                0, NULL, 0, NULL);
    300303        }
    301304
    302305        if (fPortStatus[i].change & PORT_STATUS_SUSPEND) {
    303             TRACE_ALWAYS("port %ld is %ssuspended\n", i, (fPortStatus[i].status & PORT_STATUS_SUSPEND) ? "" : "not ");
     306            TRACE_ALWAYS("port %" B_PRId32 " is %ssuspended\n", i,
     307                (fPortStatus[i].status & PORT_STATUS_SUSPEND) ? "" : "not ");
    304308            DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
    305309                USB_REQUEST_CLEAR_FEATURE, C_PORT_SUSPEND, i + 1,
    306310                0, NULL, 0, NULL);
    307311        }
    308312
    309313        if (fPortStatus[i].change & PORT_STATUS_OVER_CURRENT) {
    310             TRACE_ALWAYS("port %ld is %sin an over current state\n", i, (fPortStatus[i].status & PORT_STATUS_OVER_CURRENT) ? "" : "not ");
     314            TRACE_ALWAYS("port %" B_PRId32 " is %sin an over current state\n",
     315                i, (fPortStatus[i].status & PORT_STATUS_OVER_CURRENT) ? "" : "not ");
    311316            DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
    312317                USB_REQUEST_CLEAR_FEATURE, C_PORT_OVER_CURRENT, i + 1,
    313318                0, NULL, 0, NULL);
    314319        }
    315320
    316321        if (fPortStatus[i].change & PORT_STATUS_RESET) {
    317             TRACE_ALWAYS("port %ld was reset\n", i);
     322            TRACE_ALWAYS("port %" B_PRId32 "was reset\n", i);
    318323            DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
    319324                USB_REQUEST_CLEAR_FEATURE, C_PORT_RESET, i + 1,
    320325                0, NULL, 0, NULL);
    Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,  
    400405        if (*index < bufferSize) {
    401406            int32 managerIndex = GetStack()->IndexOfBusManager(GetBusManager());
    402407            size_t totalBytes = snprintf(string + *index, bufferSize - *index,
    403                 "%ld", managerIndex);
     408                "%" B_PRId32, managerIndex);
    404409            *index += std::min(totalBytes, bufferSize - *index - 1);
    405410        }
    406411    }
    Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,  
    418423            if (fChildren[i] == device) {
    419424                if (*index < bufferSize) {
    420425                    size_t totalBytes = snprintf(string + *index,
    421                         bufferSize - *index, "/%ld", i);
     426                        bufferSize - *index, "/%" B_PRId32, i);
    422427                    *index += std::min(totalBytes, bufferSize - *index - 1);
    423428                }
    424429                break;
  • src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp

    diff --git a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.cpp
    index 29450ea..c86dbd0 100644
    a b PhysicalMemoryAllocator::PhysicalMemoryAllocator(const char *name,  
    7777
    7878    fArea = create_area(fName, &fLogicalBase, B_ANY_KERNEL_ADDRESS,
    7979        roundedSize, B_32_BIT_CONTIGUOUS, B_READ_AREA | B_WRITE_AREA);
    80         // TODO: Use B_CONTIGUOUS when the TODOs regarding 64 bit physical
    81         // addresses are fixed (if possible).
    8280    if (fArea < B_OK) {
    8381        TRACE_ERROR(("PMA: failed to create memory area\n"));
    8482        return;
    PhysicalMemoryAllocator::_Unlock()  
    131129
    132130status_t
    133131PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,
    134     void **physicalAddress)
     132    phys_addr_t *physicalAddress)
    135133{
    136 // TODO: physicalAddress should be a phys_addr_t*!
    137134#ifdef HAIKU_TARGET_PLATFORM_HAIKU
    138135    if (debug_debugger_running()) {
    139136        for (int32 i = 0; i < 64; i++) {
    PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,  
    142139                fDebugUseMap |= mask;
    143140                *logicalAddress = (void *)((uint8 *)fLogicalBase + fDebugBase
    144141                    + i * fDebugChunkSize);
    145                 *physicalAddress = (void *)(fPhysicalBase + fDebugBase
     142                *physicalAddress = (phys_addr_t)(fPhysicalBase + fDebugBase
    146143                    + i * fDebugChunkSize);
    147144                return B_OK;
    148145            }
    PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,  
    204201                _Unlock();
    205202                size_t offset = fBlockSize[arrayToUse] * i;
    206203                *logicalAddress = (void *)((uint8 *)fLogicalBase + offset);
    207                 *physicalAddress = (void *)(fPhysicalBase + offset);
     204                *physicalAddress = (phys_addr_t)(fPhysicalBase + offset);
    208205                return B_OK;
    209206            }
    210207        }
    PhysicalMemoryAllocator::Allocate(size_t size, void **logicalAddress,  
    234231
    235232status_t
    236233PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress,
    237     void *physicalAddress)
     234    phys_addr_t physicalAddress)
    238235{
    239 // TODO: physicalAddress should be a phys_addr_t!
    240236#ifdef HAIKU_TARGET_PLATFORM_HAIKU
    241237    if (debug_debugger_running()) {
    242238        uint32 index = ((uint8 *)logicalAddress - (uint8 *)fLogicalBase
    PhysicalMemoryAllocator::Deallocate(size_t size, void *logicalAddress,  
    259255        }
    260256    }
    261257
    262     uint32 offset;
     258    phys_addr_t offset;
    263259    if (logicalAddress)
    264         offset = (uint32)logicalAddress - (uint32)fLogicalBase;
     260        offset = (addr_t)logicalAddress - (addr_t)fLogicalBase;
    265261    else if (physicalAddress)
    266262        offset = (addr_t)physicalAddress - fPhysicalBase;
    267263    else {
    PhysicalMemoryAllocator::PrintToStream()  
    318314    dprintf("\tMin block size:\t\t\t%ld bytes\n", fBlockSize[0]);
    319315    dprintf("\tMax block size:\t\t\t%ld bytes\n", fBlockSize[fArrayCount - 1]);
    320316    dprintf("\tMin count per block:\t%ld\n\n", fArrayLength[fArrayCount - 1]);
    321     dprintf("\tArray count:\t\t\t%ld\n", fArrayCount);
     317    dprintf("\tArray count:\t\t\t%" B_PRId32 "\n", fArrayCount);
    322318
    323319    dprintf("\tArray slots:\t\t\t% 8ld", fArrayLength[0]);
    324320    for (int32 i = 1; i < fArrayCount; i++)
    PhysicalMemoryAllocator::DumpArrays()  
    344340{
    345341    uint32 padding = 2;
    346342    for (int32 i = 0; i < fArrayCount; i++) {
    347         dprintf("\tArray(%ld):\t", i);
     343        dprintf("\tArray(%" B_PRId32 "):\t", i);
    348344        for (size_t j = 0; j < fArrayLength[i]; j++) {
    349345            if (padding > 2) {
    350346                for (uint32 k = 0; k < (padding - 2) / 4; k++)
    PhysicalMemoryAllocator::DumpFreeSlots()  
    393389        }
    394390
    395391        if (i > 0)
    396             dprintf(", % 8ld", freeSlots);
     392            dprintf(", %8" B_PRIu32, freeSlots);
    397393        else
    398             dprintf("% 8ld", freeSlots);
     394            dprintf("%8" B_PRIu32, freeSlots);
    399395    }
    400396    dprintf("\n");
    401397}
  • src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h

    diff --git a/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h b/src/add-ons/kernel/bus_managers/usb/PhysicalMemoryAllocator.h
    index 90207ce..ce12f24 100644
    a b public:  
    2626
    2727        status_t                    Allocate(size_t size,
    2828                                        void **logicalAddress,
    29                                         void **physicalAddress);
     29                                        phys_addr_t *physicalAddress);
    3030
    3131        // one of both addresses needs to be provided, the other may be NULL
    3232        status_t                    Deallocate(size_t size,
    3333                                        void *logicalAddress,
    34                                         void *physicalAddress);
     34                                        phys_addr_t physicalAddress);
    3535
    3636        void                        PrintToStream();
    3737        void                        DumpArrays();
  • src/add-ons/kernel/bus_managers/usb/Stack.cpp

    diff --git a/src/add-ons/kernel/bus_managers/usb/Stack.cpp b/src/add-ons/kernel/bus_managers/usb/Stack.cpp
    index 049d6f0..6c81516 100644
    a b Stack::BusManagerAt(int32 index) const  
    278278
    279279
    280280status_t
    281 Stack::AllocateChunk(void **logicalAddress, void **physicalAddress, size_t size)
     281Stack::AllocateChunk(void **logicalAddress, phys_addr_t *physicalAddress,
     282    size_t size)
    282283{
    283284    return fAllocator->Allocate(size, logicalAddress, physicalAddress);
    284285}
    285286
    286287
    287288status_t
    288 Stack::FreeChunk(void *logicalAddress, void *physicalAddress, size_t size)
     289Stack::FreeChunk(void *logicalAddress, phys_addr_t physicalAddress,
     290    size_t size)
    289291{
    290292    return fAllocator->Deallocate(size, logicalAddress, physicalAddress);
    291293}
    292294
    293295
    294296area_id
    295 Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
     297Stack::AllocateArea(void **logicalAddress, phys_addr_t *physicalAddress, size_t size,
    296298    const char *name)
    297299{
    298 // TODO: physicalAddress should be a phys_addr_t*!
    299300    TRACE("allocating %ld bytes for %s\n", size, name);
    300301
    301302    void *logAddress;
    Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,  
    323324        *logicalAddress = logAddress;
    324325
    325326    if (physicalAddress)
    326         *physicalAddress = (void*)(addr_t)physicalEntry.address;
     327        *physicalAddress = (phys_addr_t)physicalEntry.address;
    327328
    328     TRACE("area = %ld, size = %ld, log = %p, phy = %#" B_PRIxPHYSADDR "\n",
    329         area, size, logAddress, physicalEntry.address);
     329    TRACE("area = %" B_PRId32 ", size = %" B_PRIuSIZE ", log = %p, phy = %#"
     330        B_PRIxPHYSADDR "\n", area, size, logAddress, physicalEntry.address);
    330331    return area;
    331332}
    332333
  • src/add-ons/kernel/bus_managers/usb/usb.cpp

    diff --git a/src/add-ons/kernel/bus_managers/usb/usb.cpp b/src/add-ons/kernel/bus_managers/usb/usb.cpp
    index 7887f2b..83cf8a9 100644
    a b uninstall_notify(const char *driverName)  
    145145const usb_device_descriptor *
    146146get_device_descriptor(usb_device device)
    147147{
    148     TRACE_MODULE("get_device_descriptor(%ld)\n", device);
     148    TRACE_MODULE("get_device_descriptor(%" B_PRId32 ")\n", device);
    149149    Object *object = gUSBStack->GetObject(device);
    150150    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    151151        return NULL;
    get_device_descriptor(usb_device device)  
    157157const usb_configuration_info *
    158158get_nth_configuration(usb_device device, uint32 index)
    159159{
    160     TRACE_MODULE("get_nth_configuration(%ld, %lu)\n", device, index);
     160    TRACE_MODULE("get_nth_configuration(%" B_PRId32 ", %" B_PRIu32 ")\n",
     161        device, index);
    161162    Object *object = gUSBStack->GetObject(device);
    162163    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    163164        return NULL;
    get_nth_configuration(usb_device device, uint32 index)  
    169170const usb_configuration_info *
    170171get_configuration(usb_device device)
    171172{
    172     TRACE_MODULE("get_configuration(%ld)\n", device);
     173    TRACE_MODULE("get_configuration(%" B_PRId32 ")\n", device);
    173174    Object *object = gUSBStack->GetObject(device);
    174175    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    175176        return NULL;
    status_t  
    182183set_configuration(usb_device device,
    183184    const usb_configuration_info *configuration)
    184185{
    185     TRACE_MODULE("set_configuration(%ld, %p)\n", device, configuration);
     186    TRACE_MODULE("set_configuration(%" B_PRId32 ", %p)\n", device,
     187        configuration);
    186188    Object *object = gUSBStack->GetObject(device);
    187189    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    188190        return B_DEV_INVALID_PIPE;
    set_configuration(usb_device device,  
    194196status_t
    195197set_alt_interface(usb_device device, const usb_interface_info *interface)
    196198{
    197     TRACE_MODULE("set_alt_interface(%ld, %p)\n", device, interface);
     199    TRACE_MODULE("set_alt_interface(%" B_PRId32 ", %p)\n", device, interface);
    198200    Object *object = gUSBStack->GetObject(device);
    199201    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    200202        return B_DEV_INVALID_PIPE;
    set_alt_interface(usb_device device, const usb_interface_info *interface)  
    206208status_t
    207209set_feature(usb_id handle, uint16 selector)
    208210{
    209     TRACE_MODULE("set_feature(%ld, %d)\n", handle, selector);
     211    TRACE_MODULE("set_feature(%" B_PRId32 ", %d)\n", handle, selector);
    210212    Object *object = gUSBStack->GetObject(handle);
    211213    if (!object)
    212214        return B_DEV_INVALID_PIPE;
    set_feature(usb_id handle, uint16 selector)  
    218220status_t
    219221clear_feature(usb_id handle, uint16 selector)
    220222{
    221     TRACE_MODULE("clear_feature(%ld, %d)\n", handle, selector);
     223    TRACE_MODULE("clear_feature(%" B_PRId32 ", %d)\n", handle, selector);
    222224    Object *object = gUSBStack->GetObject(handle);
    223225    if (!object)
    224226        return B_DEV_INVALID_PIPE;
    clear_feature(usb_id handle, uint16 selector)  
    230232status_t
    231233get_status(usb_id handle, uint16 *status)
    232234{
    233     TRACE_MODULE("get_status(%ld, %p)\n", handle, status);
     235    TRACE_MODULE("get_status(%" B_PRId32 ", %p)\n", handle, status);
    234236    if (!status)
    235237        return B_BAD_VALUE;
    236238
    status_t  
    246248get_descriptor(usb_device device, uint8 type, uint8 index, uint16 languageID,
    247249    void *data, size_t dataLength, size_t *actualLength)
    248250{
    249     TRACE_MODULE("get_descriptor(%ld, 0x%02x, 0x%02x, 0x%04x, %p, %ld, %p)\n",
     251    TRACE_MODULE("get_descriptor(%" B_PRId32 ", 0x%02x, 0x%02x, 0x%04x, %p, "
     252        "%" B_PRIuSIZE ", %p)\n",
    250253        device, type, index, languageID, data, dataLength, actualLength);
    251254    Object *object = gUSBStack->GetObject(device);
    252255    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    status_t  
    261264send_request(usb_device device, uint8 requestType, uint8 request,
    262265    uint16 value, uint16 index, uint16 length, void *data, size_t *actualLength)
    263266{
    264     TRACE_MODULE("send_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %d, %p, %p)\n",
    265         device, requestType, request, value, index, length, data, actualLength);
     267    TRACE_MODULE("send_request(%" B_PRId32 ", 0x%02x, 0x%02x, 0x%04x, 0x%04x, "
     268        "%d, %p, %p)\n", device, requestType, request, value, index, length,
     269        data, actualLength);
    266270    Object *object = gUSBStack->GetObject(device);
    267271    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    268272        return B_DEV_INVALID_PIPE;
    queue_request(usb_device device, uint8 requestType, uint8 request,  
    277281    uint16 value, uint16 index, uint16 length, void *data,
    278282    usb_callback_func callback, void *callbackCookie)
    279283{
    280     TRACE_MODULE("queue_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %u, %p, %p, %p)\n",
    281         device, requestType, request, value, index, length, data, callback,
    282         callbackCookie);
     284    TRACE_MODULE("queue_request(%" B_PRId32 ", 0x%02x, 0x%02x, 0x%04x, 0x%04x,"
     285        " %u, %p, %p, %p)\n", device, requestType, request, value, index,
     286        length, data, callback, callbackCookie);
    283287    Object *object = gUSBStack->GetObject(device);
    284288    if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
    285289        return B_DEV_INVALID_PIPE;
    status_t  
    293297queue_interrupt(usb_pipe pipe, void *data, size_t dataLength,
    294298    usb_callback_func callback, void *callbackCookie)
    295299{
    296     TRACE_MODULE("queue_interrupt(%ld, %p, %ld, %p, %p)\n",
     300    TRACE_MODULE("queue_interrupt(%" B_PRId32 ", %p, %ld, %p, %p)\n",
    297301        pipe, data, dataLength, callback, callbackCookie);
    298302    Object *object = gUSBStack->GetObject(pipe);
    299303    if (!object || (object->Type() & USB_OBJECT_INTERRUPT_PIPE) == 0)
    status_t  
    308312queue_bulk(usb_pipe pipe, void *data, size_t dataLength,
    309313    usb_callback_func callback, void *callbackCookie)
    310314{
    311     TRACE_MODULE("queue_bulk(%ld, %p, %ld, %p, %p)\n",
     315    TRACE_MODULE("queue_bulk(%"B_PRId32 ", %p, %" B_PRIuSIZE ", %p, %p)\n",
    312316        pipe, data, dataLength, callback, callbackCookie);
    313317    Object *object = gUSBStack->GetObject(pipe);
    314318    if (!object || (object->Type() & USB_OBJECT_BULK_PIPE) == 0)
    status_t  
    323327queue_bulk_v(usb_pipe pipe, iovec *vector, size_t vectorCount,
    324328    usb_callback_func callback, void *callbackCookie)
    325329{
    326     TRACE_MODULE("queue_bulk_v(%ld, %p, %ld, %p, %p)\n",
     330    TRACE_MODULE("queue_bulk_v(%" B_PRId32 ", %p, %" B_PRIuSIZE " %p, %p)\n",
    327331        pipe, vector, vectorCount, callback, callbackCookie);
    328332    Object *object = gUSBStack->GetObject(pipe);
    329333    if (!object || (object->Type() & USB_OBJECT_BULK_PIPE) == 0)
    status_t  
    338342queue_bulk_v_physical(usb_pipe pipe, iovec *vector, size_t vectorCount,
    339343    usb_callback_func callback, void *callbackCookie)
    340344{
    341     TRACE_MODULE("queue_bulk_v_physical(%ld, %p, %ld, %p, %p)\n",
    342         pipe, vector, vectorCount, callback, callbackCookie);
     345    TRACE_MODULE("queue_bulk_v_physical(%" B_PRId32 ", %p, %" B_PRIuSIZE
     346        ", %p, %p)\n", pipe, vector, vectorCount, callback, callbackCookie);
    343347    Object *object = gUSBStack->GetObject(pipe);
    344348    if (!object || (object->Type() & USB_OBJECT_BULK_PIPE) == 0)
    345349        return B_DEV_INVALID_PIPE;
    queue_isochronous(usb_pipe pipe, void *data, size_t dataLength,  
    355359    uint32 *startingFrameNumber, uint32 flags, usb_callback_func callback,
    356360    void *callbackCookie)
    357361{
    358     TRACE_MODULE("queue_isochronous(%ld, %p, %ld, %p, %ld, %p, 0x%08lx, %p, %p)\n",
     362    TRACE_MODULE("queue_isochronous(%" B_PRId32 ", %p, %" B_PRIuSIZE ", %p, "
     363        "%" B_PRId32 ", %p, 0x%08" B_PRIx32 ", %p, %p)\n",
    359364        pipe, data, dataLength, packetDesc, packetCount, startingFrameNumber,
    360365        flags, callback, callbackCookie);
    361366    Object *object = gUSBStack->GetObject(pipe);
    status_t  
    372377set_pipe_policy(usb_pipe pipe, uint8 maxQueuedPackets,
    373378    uint16 maxBufferDurationMS, uint16 sampleSize)
    374379{
    375     TRACE_MODULE("set_pipe_policy(%ld, %d, %d, %d)\n", pipe, maxQueuedPackets,
    376         maxBufferDurationMS, sampleSize);
     380    TRACE_MODULE("set_pipe_policy(%" B_PRId32 ", %d, %d, %d)\n", pipe,
     381        maxQueuedPackets, maxBufferDurationMS, sampleSize);
    377382    Object *object = gUSBStack->GetObject(pipe);
    378383    if (!object || (object->Type() & USB_OBJECT_ISO_PIPE) == 0)
    379384        return B_DEV_INVALID_PIPE;
    set_pipe_policy(usb_pipe pipe, uint8 maxQueuedPackets,  
    386391status_t
    387392cancel_queued_transfers(usb_pipe pipe)
    388393{
    389     TRACE_MODULE("cancel_queued_transfers(%ld)\n", pipe);
     394    TRACE_MODULE("cancel_queued_transfers(%" B_PRId32 ")\n", pipe);
    390395    Object *object = gUSBStack->GetObject(pipe);
    391396    if (!object || (object->Type() & USB_OBJECT_PIPE) == 0)
    392397        return B_DEV_INVALID_PIPE;
    cancel_queued_transfers(usb_pipe pipe)  
    398403status_t
    399404usb_ioctl(uint32 opcode, void *buffer, size_t bufferSize)
    400405{
    401     TRACE_MODULE("usb_ioctl(%lu, %p, %ld)\n", opcode, buffer, bufferSize);
     406    TRACE_MODULE("usb_ioctl(%" B_PRIu32 ", %p, %" B_PRIuSIZE ")\n", opcode,
     407        buffer, bufferSize);
    402408
    403409    switch (opcode) {
    404410        case 'DNAM': {
    struct usb_module_info gModuleInfoV3 = {  
    564570const usb_device_descriptor *
    565571get_device_descriptor_v2(const void *device)
    566572{
    567     return get_device_descriptor((usb_id)device);
     573    return get_device_descriptor((usb_id)(ssize_t)device);
    568574}
    569575
    570576
    571577const usb_configuration_info *
    572578get_nth_configuration_v2(const void *device, uint index)
    573579{
    574     return get_nth_configuration((usb_id)device, index);
     580    return get_nth_configuration((usb_id)(ssize_t)device, index);
    575581}
    576582
    577583
    578584const usb_configuration_info *
    579585get_configuration_v2(const void *device)
    580586{
    581     return get_configuration((usb_id)device);
     587    return get_configuration((usb_id)(ssize_t)device);
    582588}
    583589
    584590
    status_t  
    586592set_configuration_v2(const void *device,
    587593    const usb_configuration_info *configuration)
    588594{
    589     return set_configuration((usb_id)device, configuration);
     595    return set_configuration((usb_id)(ssize_t)device, configuration);
    590596}
    591597
    592598
    593599status_t
    594600set_alt_interface_v2(const void *device, const usb_interface_info *interface)
    595601{
    596     return set_alt_interface((usb_id)device, interface);
     602    return set_alt_interface((usb_id)(ssize_t)device, interface);
    597603}
    598604
    599605
    600606status_t
    601607set_feature_v2(const void *object, uint16 selector)
    602608{
    603     return set_feature((usb_id)object, selector);
     609    return set_feature((usb_id)(ssize_t)object, selector);
    604610}
    605611
    606612
    607613status_t
    608614clear_feature_v2(const void *object, uint16 selector)
    609615{
    610     return clear_feature((usb_id)object, selector);
     616    return clear_feature((usb_id)(ssize_t)object, selector);
    611617}
    612618
    613619
    614620status_t
    615621get_status_v2(const void *object, uint16 *status)
    616622{
    617     return get_status((usb_id)object, status);
     623    return get_status((usb_id)(ssize_t)object, status);
    618624}
    619625
    620626
    status_t  
    622628get_descriptor_v2(const void *device, uint8 type, uint8 index,
    623629    uint16 languageID, void *data, size_t dataLength, size_t *actualLength)
    624630{
    625     return get_descriptor((usb_id)device, type, index, languageID, data,
     631    return get_descriptor((usb_id)(ssize_t)device, type, index, languageID, data,
    626632        dataLength, actualLength);
    627633}
    628634
    send_request_v2(const void *device, uint8 requestType, uint8 request,  
    632638    uint16 value, uint16 index, uint16 length, void *data,
    633639    size_t /*dataLength*/, size_t *actualLength)
    634640{
    635     return send_request((usb_id)device, requestType, request, value, index,
     641    return send_request((usb_id)(ssize_t)device, requestType, request, value, index,
    636642        length, data, actualLength);
    637643}
    638644
    queue_request_v2(const void *device, uint8 requestType, uint8 request,  
    642648    uint16 value, uint16 index, uint16 length, void *data,
    643649    size_t /*dataLength*/, usb_callback_func callback, void *callbackCookie)
    644650{
    645     return queue_request((usb_id)device, requestType, request, value, index,
     651    return queue_request((usb_id)(ssize_t)device, requestType, request, value, index,
    646652        length, data, callback, callbackCookie);
    647653}
    648654
    status_t  
    651657queue_interrupt_v2(const void *pipe, void *data, size_t dataLength,
    652658    usb_callback_func callback, void *callbackCookie)
    653659{
    654     return queue_interrupt((usb_id)pipe, data, dataLength, callback,
     660    return queue_interrupt((usb_id)(ssize_t)pipe, data, dataLength, callback,
    655661        callbackCookie);
    656662}
    657663
    status_t  
    660666queue_bulk_v2(const void *pipe, void *data, size_t dataLength,
    661667    usb_callback_func callback, void *callbackCookie)
    662668{
    663     return queue_bulk((usb_id)pipe, data, dataLength, callback,
     669    return queue_bulk((usb_id)(ssize_t)pipe, data, dataLength, callback,
    664670        callbackCookie);
    665671}
    666672
    queue_isochronous_v2(const void *pipe, void *data, size_t dataLength,  
    673679    // ToDo: convert rlea to usb_iso_packet_descriptor
    674680    // ToDo: use a flag to indicate that the callback shall produce a rlea
    675681    usb_iso_packet_descriptor *packetDesc = NULL;
    676     return queue_isochronous((usb_id)pipe, data, dataLength, packetDesc, 0,
     682    return queue_isochronous((usb_id)(ssize_t)pipe, data, dataLength, packetDesc, 0,
    677683        NULL, 0, callback, callbackCookie);
    678684}
    679685
    status_t  
    682688set_pipe_policy_v2(const void *pipe, uint8 maxQueuedPackets,
    683689    uint16 maxBufferDurationMS, uint16 sampleSize)
    684690{
    685     return set_pipe_policy((usb_id)pipe, maxQueuedPackets, maxBufferDurationMS,
     691    return set_pipe_policy((usb_id)(ssize_t)pipe, maxQueuedPackets, maxBufferDurationMS,
    686692        sampleSize);
    687693}
    688694
    set_pipe_policy_v2(const void *pipe, uint8 maxQueuedPackets,  
    690696status_t
    691697cancel_queued_transfers_v2(const void *pipe)
    692698{
    693     return cancel_queued_transfers((usb_id)pipe);
     699    return cancel_queued_transfers((usb_id)(ssize_t)pipe);
    694700}
    695701
    696702
  • src/add-ons/kernel/bus_managers/usb/usb_private.h

    diff --git a/src/add-ons/kernel/bus_managers/usb/usb_private.h b/src/add-ons/kernel/bus_managers/usb/usb_private.h
    index dbc3f04..be8b321 100644
    a b  
    1717
    1818#define TRACE_OUTPUT(x, y, z...) \
    1919    { \
    20         dprintf("usb %s%s %ld: ", y, (x)->TypeName(), (x)->USBID()); \
     20        dprintf("usb %s%s %" B_PRId32 ": ", y, (x)->TypeName(), (x)->USBID()); \
    2121        dprintf(z); \
    2222    }
    2323
    public:  
    136136        BusManager *                    BusManagerAt(int32 index) const;
    137137
    138138        status_t                        AllocateChunk(void **logicalAddress,
    139                                             void **physicalAddress,
     139                                            phys_addr_t *physicalAddress,
    140140                                            size_t size);
    141141        status_t                        FreeChunk(void *logicalAddress,
    142                                             void *physicalAddress, size_t size);
     142                                            phys_addr_t physicalAddress,
     143                                            size_t size);
    143144
    144145        area_id                         AllocateArea(void **logicalAddress,
    145                                             void **physicalAddress,
     146                                            phys_addr_t *physicalAddress,
    146147                                            size_t size, const char *name);
    147148
    148149        void                            NotifyDeviceChange(Device *device,
  • src/add-ons/kernel/bus_managers/usb/usbspec_private.h

    diff --git a/src/add-ons/kernel/bus_managers/usb/usbspec_private.h b/src/add-ons/kernel/bus_managers/usb/usbspec_private.h
    index 5e70ad2..2103994 100644
    a b  
    3939
    4040struct memory_chunk
    4141{
    42     addr_t next_item;
    43     addr_t physical;
     42    uint32 next_item;
     43    uint32 physical;
    4444};
    4545
    4646
  • src/add-ons/kernel/busses/usb/ehci.cpp

    diff --git a/src/add-ons/kernel/busses/usb/ehci.cpp b/src/add-ons/kernel/busses/usb/ehci.cpp
    index 86ca326..56a2ffd 100644
    a b void  
    6565print_descriptor_chain(ehci_qtd *descriptor)
    6666{
    6767    while (descriptor) {
    68         dprintf(" %08lx n%08lx a%08lx t%08lx %08lx %08lx %08lx %08lx %08lx s%ld\n",
     68        dprintf(" %08" B_PRIx32 " n%08" B_PRIx32 " a%08" B_PRIx32 " t%08" B_PRIx32
     69            " %08" B_PRIx32 " %08" B_PRIx32 " %08" B_PRIx32 " %08" B_PRIx32
     70            " %08" B_PRIx32 " s%"B_PRIuSIZE "\n",
    6971            descriptor->this_phy, descriptor->next_phy,
    7072            descriptor->alt_next_phy, descriptor->token,
    7173            descriptor->buffer_phy[0], descriptor->buffer_phy[1],
    print_descriptor_chain(ehci_qtd *descriptor)  
    8284void
    8385print_queue(ehci_qh *queueHead)
    8486{
    85     dprintf("queue:    t%08lx n%08lx ch%08lx ca%08lx cu%08lx\n",
     87    dprintf("queue:    t%08" B_PRIx32 " n%08" B_PRIx32 " ch%08" B_PRIx32
     88        " ca%08" B_PRIx32 " cu%08" B_PRIx32 "\n",
    8689        queueHead->this_phy, queueHead->next_phy, queueHead->endpoint_chars,
    8790        queueHead->endpoint_caps, queueHead->current_qtd_phy);
    88     dprintf("overlay:  n%08lx a%08lx t%08lx %08lx %08lx %08lx %08lx %08lx\n",
    89         queueHead->overlay.next_phy, queueHead->overlay.alt_next_phy,
    90         queueHead->overlay.token, queueHead->overlay.buffer_phy[0],
    91         queueHead->overlay.buffer_phy[1], queueHead->overlay.buffer_phy[2],
    92         queueHead->overlay.buffer_phy[3], queueHead->overlay.buffer_phy[4]);
     91    dprintf("overlay:  n%08" B_PRIx32 " a%08" B_PRIx32 " t%08" B_PRIx32
     92        " %08" B_PRIx32 " %08" B_PRIx32 " %08" B_PRIx32 " %08" B_PRIx32
     93        " %08" B_PRIx32 "\n", queueHead->overlay.next_phy,
     94        queueHead->overlay.alt_next_phy, queueHead->overlay.token,
     95        queueHead->overlay.buffer_phy[0], queueHead->overlay.buffer_phy[1],
     96        queueHead->overlay.buffer_phy[2], queueHead->overlay.buffer_phy[3],
     97        queueHead->overlay.buffer_phy[4]);
    9398    print_descriptor_chain(queueHead->element_log);
    9499}
    95100
    EHCI::EHCI(pci_info *info, Stack *stack)  
    201206
    202207    // map the registers
    203208    uint32 offset = fPCIInfo->u.h0.base_registers[0] & (B_PAGE_SIZE - 1);
    204     addr_t physicalAddress = fPCIInfo->u.h0.base_registers[0] - offset;
     209    phys_addr_t physicalAddress = fPCIInfo->u.h0.base_registers[0] - offset;
    205210    size_t mapSize = (fPCIInfo->u.h0.base_register_sizes[0] + offset
    206211        + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
    207212
    208     TRACE("map physical memory 0x%08lx (base: 0x%08lx; offset: %lx); size: %ld\n",
     213    TRACE("map physical memory 0x%08" B_PRIx32 " (base: 0x%08" B_PRIxPHYSADDR
     214        "; offset: %" B_PRIx32 "); size: %" B_PRIu32 "\n",
    209215        fPCIInfo->u.h0.base_registers[0], physicalAddress, offset,
    210216        fPCIInfo->u.h0.base_register_sizes[0]);
    211217
    EHCI::EHCI(pci_info *info, Stack *stack)  
    220226
    221227    fCapabilityRegisters += offset;
    222228    fOperationalRegisters = fCapabilityRegisters + ReadCapReg8(EHCI_CAPLENGTH);
    223     TRACE("mapped capability registers: 0x%08lx\n", (uint32)fCapabilityRegisters);
    224     TRACE("mapped operational registers: 0x%08lx\n", (uint32)fOperationalRegisters);
     229    TRACE("mapped capability registers: 0x%p\n", fCapabilityRegisters);
     230    TRACE("mapped operational registers: 0x%p\n", fOperationalRegisters);
    225231
    226     TRACE("structural parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCSPARAMS));
    227     TRACE("capability parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCCPARAMS));
     232    TRACE("structural parameters: 0x%08" B_PRIx32 "\n", ReadCapReg32(EHCI_HCSPARAMS));
     233    TRACE("capability parameters: 0x%08" B_PRIx32 "\n", ReadCapReg32(EHCI_HCCPARAMS));
    228234
    229235    if (EHCI_HCCPARAMS_FRAME_CACHE(ReadCapReg32(EHCI_HCCPARAMS)))
    230236        fThreshold = 2 + 8;
    EHCI::EHCI(pci_info *info, Stack *stack)  
    237243    uint32 extendedCapPointer = ReadCapReg32(EHCI_HCCPARAMS) >> EHCI_ECP_SHIFT;
    238244    extendedCapPointer &= EHCI_ECP_MASK;
    239245    if (extendedCapPointer > 0) {
    240         TRACE("extended capabilities register at %ld\n", extendedCapPointer);
     246        TRACE("extended capabilities register at %" B_PRIu32 "\n", extendedCapPointer);
    241247
    242248        uint32 legacySupport = sPCIModule->read_pci_config(fPCIInfo->bus,
    243249            fPCIInfo->device, fPCIInfo->function, extendedCapPointer, 4);
    EHCI::EHCI(pci_info *info, Stack *stack)  
    376382
    377383    // allocate the periodic frame list
    378384    fPeriodicFrameListArea = fStack->AllocateArea((void **)&fPeriodicFrameList,
    379         (void **)&physicalAddress, frameListSize, "USB EHCI Periodic Framelist");
     385        &physicalAddress, frameListSize, "USB EHCI Periodic Framelist");
    380386    if (fPeriodicFrameListArea < B_OK) {
    381387        TRACE_ERROR("unable to allocate periodic framelist\n");
    382388        return;
    383389    }
    384390
    385     if ((physicalAddress & 0xfff) != 0)
    386         panic("EHCI_PERIODICLISTBASE not aligned on 4k: 0x%lx\n", physicalAddress);
     391    if ((physicalAddress & 0xfff) != 0) {
     392        panic("EHCI_PERIODICLISTBASE not aligned on 4k: 0x%" B_PRIxPHYSADDR
     393            "\n", physicalAddress);
     394    }
    387395    // set the periodic frame list base on the controller
    388396    WriteOpReg(EHCI_PERIODICLISTBASE, (uint32)physicalAddress);
    389397
    390398    // create the interrupt entries to support different polling intervals
    391399    TRACE("creating interrupt entries\n");
    392     addr_t physicalBase = physicalAddress + B_PAGE_SIZE;
     400    uint32_t physicalBase = physicalAddress + B_PAGE_SIZE;
    393401    uint8 *logicalBase = (uint8 *)fPeriodicFrameList + B_PAGE_SIZE;
    394402    memset(logicalBase, 0, B_PAGE_SIZE);
    395403
    EHCI::EHCI(pci_info *info, Stack *stack)  
    414422
    415423    // create the itd and sitd entries
    416424    TRACE("build up iso entries\n");
    417     addr_t itdPhysicalBase = physicalAddress + B_PAGE_SIZE + B_PAGE_SIZE;
     425    uint32_t itdPhysicalBase = physicalAddress + B_PAGE_SIZE + B_PAGE_SIZE;
    418426    itd_entry* itds = (itd_entry *)((uint8 *)fPeriodicFrameList + B_PAGE_SIZE
    419427        + B_PAGE_SIZE);
    420428    memset(itds, 0, itdListSize);
    421429
    422     addr_t sitdPhysicalBase = itdPhysicalBase + itdListSize;
     430    uint32_t sitdPhysicalBase = itdPhysicalBase + itdListSize;
    423431    sitd_entry* sitds = (sitd_entry *)((uint8 *)fPeriodicFrameList + B_PAGE_SIZE
    424432        + B_PAGE_SIZE + itdListSize);
    425433    memset(sitds, 0, sitdListSize);
    EHCI::EHCI(pci_info *info, Stack *stack)  
    427435    fItdEntries = new(std::nothrow) ehci_itd *[EHCI_VFRAMELIST_ENTRIES_COUNT];
    428436    fSitdEntries = new(std::nothrow) ehci_sitd *[EHCI_VFRAMELIST_ENTRIES_COUNT];
    429437
     438    dprintf("sitd entry size %lu, itd entry size %lu\n", sizeof(sitd_entry), sizeof(itd_entry));
    430439    for (int32 i = 0; i < EHCI_VFRAMELIST_ENTRIES_COUNT; i++) {
    431440        ehci_sitd *sitd = &sitds[i].sitd;
    432441        sitd->this_phy = sitdPhysicalBase | EHCI_ITEM_TYPE_SITD;
    433442        sitd->back_phy = EHCI_ITEM_TERMINATE;
    434443        fSitdEntries[i] = sitd;
    435         TRACE("sitd entry %ld %p 0x%lx\n", i, sitd, sitd->this_phy);
     444        TRACE("sitd entry %" B_PRId32 " %p 0x%" B_PRIx32 "\n", i, sitd, sitd->this_phy);
    436445
    437446        ehci_itd *itd = &itds[i].itd;
    438447        itd->this_phy = itdPhysicalBase | EHCI_ITEM_TYPE_ITD;
    439448        itd->next_phy = sitd->this_phy;
    440449        fItdEntries[i] = itd;
    441         TRACE("itd entry %ld %p 0x%lx\n", i, itd, itd->this_phy);
     450        TRACE("itd entry %" B_PRId32 " %p 0x%" B_PRIx32 "\n", i, itd, itd->this_phy);
    442451
    443452        sitdPhysicalBase += sizeof(sitd_entry);
    444453        itdPhysicalBase += sizeof(itd_entry);
    445454        if ((sitdPhysicalBase & 0x10) != 0 || (itdPhysicalBase & 0x10) != 0)
    446             panic("physical base for entry %ld not aligned on 32\n", i);
     455            panic("physical base for entry %" B_PRId32 " not aligned on 32\n",
     456                i);
    447457    }
    448458
    449459    // build flat interrupt tree
    EHCI::EHCI(pci_info *info, Stack *stack)  
    479489    for (int32 i = 0; i < EHCI_FRAMELIST_ENTRIES_COUNT; i++) {
    480490        fPeriodicFrameList[i] =
    481491            fItdEntries[i & (EHCI_VFRAMELIST_ENTRIES_COUNT - 1)]->this_phy;
    482         TRACE("periodic entry %ld linked to 0x%lx\n", i, fPeriodicFrameList[i]);
     492        TRACE("periodic entry %" B_PRId32 " linked to 0x%" B_PRIx32 "\n", i, fPeriodicFrameList[i]);
    483493    }
    484494
    485495    // Create the array that will keep bandwidth information
    EHCI::EHCI(pci_info *info, Stack *stack)  
    504514    fAsyncQueueHead->overlay.next_phy = EHCI_ITEM_TERMINATE;
    505515
    506516    WriteOpReg(EHCI_ASYNCLISTADDR, (uint32)fAsyncQueueHead->this_phy);
    507     TRACE("set the async list addr to 0x%08lx\n", ReadOpReg(EHCI_ASYNCLISTADDR));
     517    TRACE("set the async list addr to 0x%08" B_PRIx32 "\n", ReadOpReg(EHCI_ASYNCLISTADDR));
    508518
    509519    fInitOK = true;
    510520    TRACE("EHCI host controller driver constructed\n");
    status_t  
    554564EHCI::Start()
    555565{
    556566    TRACE("starting EHCI host controller\n");
    557     TRACE("usbcmd: 0x%08lx; usbsts: 0x%08lx\n", ReadOpReg(EHCI_USBCMD),
     567    TRACE("usbcmd: 0x%08" B_PRIx32 "; usbsts: 0x%08" B_PRIx32 "\n", ReadOpReg(EHCI_USBCMD),
    558568        ReadOpReg(EHCI_USBSTS));
    559569
    560570    bool hasPerPortChangeEvent = (ReadCapReg32(EHCI_HCCPARAMS)
    EHCI::Start()  
    589599    bool running = false;
    590600    for (int32 i = 0; i < 10; i++) {
    591601        uint32 status = ReadOpReg(EHCI_USBSTS);
    592         TRACE("try %ld: status 0x%08lx\n", i, status);
     602        TRACE("try %" B_PRId32 ": status 0x%08" B_PRIx32 "\n", i, status);
    593603
    594604        if (status & EHCI_USBSTS_HCHALTED) {
    595605            snooze(10000);
    EHCI::SubmitIsochronous(Transfer *transfer)  
    729739        return B_NO_MEMORY;
    730740    }
    731741
    732     TRACE("isochronous submitted size=%ld bytes, TDs=%ld, "
    733         "maxPacketSize=%ld, packetSize=%ld, restSize=%ld\n", transfer->DataLength(),
    734         isochronousData->packet_count, pipe->MaxPacketSize(), packetSize, restSize);
     742    TRACE("isochronous submitted size=%" B_PRIuSIZE " bytes, TDs=%" B_PRIu32 ", "
     743        "maxPacketSize=%" B_PRIuSIZE ", packetSize=%" B_PRIuSIZE ", restSize=%"
     744        B_PRIuSIZE "\n", transfer->DataLength(), isochronousData->packet_count,
     745        pipe->MaxPacketSize(), packetSize, restSize);
    735746
    736747    // Find the entry where to start inserting the first Isochronous descriptor
    737748    if (isochronousData->flags & USB_ISO_ASAP ||
    EHCI::SubmitIsochronous(Transfer *transfer)  
    741752            currentFrame = fNextStartingFrame;
    742753        else {
    743754            uint32 threshold = fThreshold;
    744             TRACE("threshold: %ld\n", threshold);
     755            TRACE("threshold: %" B_PRIu32 "\n", threshold);
    745756
    746757            // find the first available frame with enough bandwidth.
    747758            // This should always be the case, as defining the starting frame
    EHCI::SubmitIsochronous(Transfer *transfer)  
    768779    uint16 itdIndex = 0;
    769780    size_t dataLength = transfer->DataLength();
    770781    void* bufferLog;
    771     addr_t bufferPhy;
    772     if (fStack->AllocateChunk(&bufferLog, (void**)&bufferPhy, dataLength) < B_OK) {
     782    phys_addr_t bufferPhy;
     783    if (fStack->AllocateChunk(&bufferLog, &bufferPhy, dataLength) < B_OK) {
    773784        TRACE_ERROR("unable to allocate itd buffer\n");
    774785        delete[] isoRequest;
    775786        return B_NO_MEMORY;
    EHCI::SubmitIsochronous(Transfer *transfer)  
    777788
    778789    memset(bufferLog, 0, dataLength);
    779790
    780     addr_t currentPhy = bufferPhy;
     791    phys_addr_t currentPhy = bufferPhy;
    781792    uint32 frameCount = 0;
    782793    while (dataLength > 0) {
    783794        ehci_itd* itd = CreateItdDescriptor();
    EHCI::SubmitIsochronous(Transfer *transfer)  
    792803                | (length << EHCI_ITD_TLENGTH_SHIFT) | (pg << EHCI_ITD_PG_SHIFT)
    793804                | (offset << EHCI_ITD_TOFFSET_SHIFT);
    794805            itd->last_token = i;
    795             TRACE("isochronous filled slot %ld 0x%lx\n", i, itd->token[i]);
     806            TRACE("isochronous filled slot %" B_PRId32 " 0x%" B_PRIx32 "\n", i, itd->token[i]);
    796807            dataLength -= length;
    797808            offset += length;
    798809            if (dataLength > 0 && offset > 0xfff) {
    EHCI::SubmitIsochronous(Transfer *transfer)  
    815826            ((((pipe->MaxPacketSize() >> EHCI_ITD_MAXPACKETSIZE_LENGTH) + 1)
    816827            & EHCI_ITD_MUL_MASK) << EHCI_ITD_MUL_SHIFT);
    817828
    818         TRACE("isochronous filled itd buffer_phy[0,1,2] 0x%lx, 0x%lx 0x%lx\n",
     829        TRACE("isochronous filled itd buffer_phy[0,1,2] 0x%" B_PRIx32 ", 0x%"
     830            B_PRIx32 " 0x%" B_PRIx32 "\n",
    819831            itd->buffer_phy[0], itd->buffer_phy[1], itd->buffer_phy[2]);
    820832
    821833        if (!LockIsochronous())
    EHCI::AddTo(Stack *stack)  
    905917    if (!sPCIModule) {
    906918        status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
    907919        if (status < B_OK) {
    908             TRACE_MODULE_ERROR("getting pci module failed! 0x%08lx\n", status);
     920            TRACE_MODULE_ERROR("getting pci module failed! 0x%08" B_PRIx32
     921                "\n", status);
    909922            return status;
    910923        }
    911924    }
    EHCI::Interrupt()  
    11781191    uint32 status = ReadOpReg(EHCI_USBSTS) & EHCI_USBSTS_INTMASK;
    11791192    if ((status & fEnabledInterrupts) == 0) {
    11801193        if (status != 0) {
    1181             TRACE("discarding not enabled interrupts 0x%08lx\n", status);
     1194            TRACE("discarding not enabled interrupts 0x%08" B_PRIx32 "\n", status);
    11821195            WriteOpReg(EHCI_USBSTS, status);
    11831196        }
    11841197
    EHCI::FinishTransfers()  
    14801493                uint32 status = descriptor->token;
    14811494                if (status & EHCI_QTD_STATUS_ACTIVE) {
    14821495                    // still in progress
    1483                     TRACE("qtd (0x%08lx) still active\n", descriptor->this_phy);
     1496                    TRACE("qtd (0x%08" B_PRIx32 ") still active\n", descriptor->this_phy);
    14841497                    break;
    14851498                }
    14861499
    14871500                if (status & EHCI_QTD_STATUS_ERRMASK) {
    14881501                    // a transfer error occured
    1489                     TRACE_ERROR("qtd (0x%08lx) error: 0x%08lx\n", descriptor->this_phy, status);
     1502                    TRACE_ERROR("qtd (0x%" B_PRIx32 ") error: 0x%08" B_PRIx32
     1503                        "\n", descriptor->this_phy, status);
    14901504
    14911505                    uint8 errorCount = status >> EHCI_QTD_ERRCOUNT_SHIFT;
    14921506                    errorCount &= EHCI_QTD_ERRCOUNT_MASK;
    EHCI::FinishTransfers()  
    15351549
    15361550                if (descriptor->next_phy & EHCI_ITEM_TERMINATE) {
    15371551                    // we arrived at the last (stray) descriptor, we're done
    1538                     TRACE("qtd (0x%08lx) done\n", descriptor->this_phy);
     1552                    TRACE("qtd (0x%08" B_PRIx32 ") done\n", descriptor->this_phy);
    15391553                    callbackStatus = B_OK;
    15401554                    transferDone = true;
    15411555                    break;
    EHCI::FinishIsochronousTransfers()  
    17181732
    17191733            ehci_itd *itd = fItdEntries[currentFrame];
    17201734
    1721             TRACE("FinishIsochronousTransfers itd %p phy 0x%lx prev (%p/0x%lx)"
    1722                 " at frame %ld\n", itd, itd->this_phy, itd->prev,
    1723                 itd->prev != NULL ? itd->prev->this_phy : 0, currentFrame);
     1735            TRACE("FinishIsochronousTransfers itd %p phy 0x%" B_PRIx32
     1736                " prev (%p/0x%" B_PRIx32 ") at frame %" B_PRId32 "\n", itd,
     1737                itd->this_phy, itd->prev, itd->prev != NULL
     1738                    ? itd->prev->this_phy : 0, currentFrame);
    17241739
    17251740            if (!LockIsochronous())
    17261741                continue;
    EHCI::FinishIsochronousTransfers()  
    17281743            // Process the frame till it has isochronous descriptors in it.
    17291744            while (!(itd->next_phy & EHCI_ITEM_TERMINATE) && itd->prev != NULL) {
    17301745                TRACE("FinishIsochronousTransfers checking itd %p last_token"
    1731                     " %ld\n", itd, itd->last_token);
    1732                 TRACE("FinishIsochronousTransfers tokens 0x%lx 0x%lx 0x%lx "
    1733                     "0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
     1746                    " %" B_PRId32 "\n", itd, itd->last_token);
     1747                TRACE("FinishIsochronousTransfers tokens 0x%" B_PRIx32 " 0x%"
     1748                    B_PRIx32 " 0x%" B_PRIx32 " 0x%" B_PRIx32 " 0x%" B_PRIx32
     1749                    " 0x%" B_PRIx32 " 0x%" B_PRIx32 " 0x%" B_PRIx32 "\n",
    17341750                    itd->token[0], itd->token[1], itd->token[2], itd->token[3],
    17351751                    itd->token[4], itd->token[5], itd->token[6], itd->token[7]);
    17361752                if (((itd->token[itd->last_token] >> EHCI_ITD_STATUS_SHIFT)
    EHCI::FinishIsochronousTransfers()  
    17841800                    delete [] transfer->descriptors;
    17851801                    delete transfer->transfer;
    17861802                    fStack->FreeChunk(transfer->buffer_log,
    1787                         (void *)transfer->buffer_phy, transfer->buffer_size);
     1803                        (phys_addr_t)transfer->buffer_phy, transfer->buffer_size);
    17881804                    delete transfer;
    17891805                    transferDone = true;
    17901806                } else {
    ehci_qh *  
    18091825EHCI::CreateQueueHead()
    18101826{
    18111827    ehci_qh *result;
    1812     void *physicalAddress;
     1828    phys_addr_t physicalAddress;
    18131829    if (fStack->AllocateChunk((void **)&result, &physicalAddress,
    18141830        sizeof(ehci_qh)) < B_OK) {
    18151831        TRACE_ERROR("failed to allocate queue head\n");
    EHCI::FreeQueueHead(ehci_qh *queueHead)  
    18891905
    18901906    FreeDescriptorChain(queueHead->element_log);
    18911907    FreeDescriptor(queueHead->stray_log);
    1892     fStack->FreeChunk(queueHead, (void *)queueHead->this_phy, sizeof(ehci_qh));
     1908    fStack->FreeChunk(queueHead, (phys_addr_t)queueHead->this_phy, sizeof(ehci_qh));
    18931909}
    18941910
    18951911
    ehci_qtd *  
    20882104EHCI::CreateDescriptor(size_t bufferSize, uint8 pid)
    20892105{
    20902106    ehci_qtd *result;
    2091     void *physicalAddress;
     2107    phys_addr_t physicalAddress;
    20922108    if (fStack->AllocateChunk((void **)&result, &physicalAddress,
    20932109        sizeof(ehci_qtd)) < B_OK) {
    20942110        TRACE_ERROR("failed to allocate a qtd\n");
    EHCI::CreateDescriptor(size_t bufferSize, uint8 pid)  
    21182134    if (fStack->AllocateChunk(&result->buffer_log, &physicalAddress,
    21192135        bufferSize) < B_OK) {
    21202136        TRACE_ERROR("unable to allocate qtd buffer\n");
    2121         fStack->FreeChunk(result, (void *)result->this_phy, sizeof(ehci_qtd));
     2137        fStack->FreeChunk(result, (phys_addr_t)result->this_phy, sizeof(ehci_qtd));
    21222138        return NULL;
    21232139    }
    21242140
    EHCI::FreeDescriptor(ehci_qtd *descriptor)  
    21812197
    21822198    if (descriptor->buffer_log) {
    21832199        fStack->FreeChunk(descriptor->buffer_log,
    2184             (void *)descriptor->buffer_phy[0], descriptor->buffer_size);
     2200            (phys_addr_t)descriptor->buffer_phy[0], descriptor->buffer_size);
    21852201    }
    21862202
    2187     fStack->FreeChunk(descriptor, (void *)descriptor->this_phy,
     2203    fStack->FreeChunk(descriptor, (phys_addr_t)descriptor->this_phy,
    21882204        sizeof(ehci_qtd));
    21892205}
    21902206
    ehci_itd *  
    22072223EHCI::CreateItdDescriptor()
    22082224{
    22092225    ehci_itd *result;
    2210     void *physicalAddress;
     2226    phys_addr_t physicalAddress;
    22112227    if (fStack->AllocateChunk((void **)&result, &physicalAddress,
    22122228        sizeof(ehci_itd)) < B_OK) {
    22132229        TRACE_ERROR("failed to allocate a itd\n");
    ehci_sitd *  
    22262242EHCI::CreateSitdDescriptor()
    22272243{
    22282244    ehci_sitd *result;
    2229     void *physicalAddress;
     2245    phys_addr_t physicalAddress;
    22302246    if (fStack->AllocateChunk((void **)&result, &physicalAddress,
    22312247        sizeof(ehci_sitd)) < B_OK) {
    22322248        TRACE_ERROR("failed to allocate a sitd\n");
    EHCI::FreeDescriptor(ehci_itd *descriptor)  
    22472263    if (!descriptor)
    22482264        return;
    22492265
    2250     fStack->FreeChunk(descriptor, (void *)descriptor->this_phy,
     2266    fStack->FreeChunk(descriptor, (phys_addr_t)descriptor->this_phy,
    22512267        sizeof(ehci_itd));
    22522268}
    22532269
    EHCI::FreeDescriptor(ehci_sitd *descriptor)  
    22582274    if (!descriptor)
    22592275        return;
    22602276
    2261     fStack->FreeChunk(descriptor, (void *)descriptor->this_phy,
     2277    fStack->FreeChunk(descriptor, (phys_addr_t)descriptor->this_phy,
    22622278        sizeof(ehci_sitd));
    22632279}
    22642280
    EHCI::ReadIsochronousDescriptorChain(isochronous_transfer_data *transfer)  
    25582574        }
    25592575    }
    25602576
    2561     TRACE("ReadIsochronousDescriptorChain packet count %ld\n", packet);
     2577    TRACE("ReadIsochronousDescriptorChain packet count %" B_PRId32 "\n",
     2578        packet);
    25622579
    25632580    return totalLength;
    25642581}
  • src/add-ons/kernel/busses/usb/ehci.h

    diff --git a/src/add-ons/kernel/busses/usb/ehci.h b/src/add-ons/kernel/busses/usb/ehci.h
    index 8692939..4680e2b 100644
    a b static pci_module_info * sPCIModule;  
    199199
    200200        // Periodic transfer framelist and interrupt entries
    201201        area_id                     fPeriodicFrameListArea;
    202         addr_t *                    fPeriodicFrameList;
     202        uint32 *                    fPeriodicFrameList;
    203203        interrupt_entry *           fInterruptEntries;
    204204        ehci_itd **                 fItdEntries;
    205205        ehci_sitd **                fSitdEntries;
  • src/add-ons/kernel/busses/usb/ehci_hardware.h

    diff --git a/src/add-ons/kernel/busses/usb/ehci_hardware.h b/src/add-ons/kernel/busses/usb/ehci_hardware.h
    index 876414d..90579f6 100644
    a b  
    130130// Isochronous (High-Speed) Transfer Descriptors (iTD, EHCI Spec 3.2)
    131131typedef struct ehci_itd {
    132132    // Hardware Part
    133     addr_t      next_phy;
     133    uint32      next_phy;
    134134    uint32      token[8];
    135     addr_t      buffer_phy[7];
    136     addr_t      ext_buffer_phy[7];
     135    uint32      buffer_phy[7];
     136    uint32      ext_buffer_phy[7];
    137137
    138138    // Software Part
    139     addr_t      this_phy;
     139    uint32      this_phy;
    140140    struct ehci_itd *next;
    141141    struct ehci_itd *prev;
    142142    uint32      last_token;
    typedef struct ehci_itd {  
    172172// Split Transaction Isochronous Transfer Descriptors (siTD, EHCI Spec 3.3)
    173173typedef struct ehci_sitd {
    174174    // Hardware Part
    175     addr_t      next_phy;
     175    uint32      next_phy;
    176176    uint8       port_number;
    177177    uint8       hub_address;
    178178    uint8       endpoint;
    typedef struct ehci_sitd {  
    183183    uint16      transfer_length;
    184184    uint8       cprogmask;
    185185    uint8       status;
    186     addr_t      buffer_phy[2];
    187     addr_t      back_phy;
    188     addr_t      ext_buffer_phy[2];
     186    uint32      buffer_phy[2];
     187    uint32      back_phy;
     188    uint32      ext_buffer_phy[2];
    189189
    190190    // Software Part
    191     addr_t      this_phy;
     191    uint32      this_phy;
    192192    struct ehci_sitd *next;
    193193    struct ehci_sitd *prev;
    194194    size_t      buffer_size;
    195195    void        *buffer_log;
    196 } ehci_sitd;
     196} _PACKED ehci_sitd;
    197197
    198198// Queue Element Transfer Descriptors (qTD, EHCI Spec 3.5)
    199199typedef struct ehci_qtd {
    200200    // Hardware Part
    201     addr_t      next_phy;
    202     addr_t      alt_next_phy;
     201    uint32      next_phy;
     202    uint32      alt_next_phy;
    203203    uint32      token;
    204     addr_t      buffer_phy[5];
    205     addr_t      ext_buffer_phy[5];
     204    uint32      buffer_phy[5];
     205    uint32      ext_buffer_phy[5];
    206206
    207207    // Software Part
    208     addr_t      this_phy;
     208    uint32      this_phy;
    209209    struct ehci_qtd *next_log;
    210210    void        *alt_next_log;
    211211    size_t      buffer_size;
    212212    void        *buffer_log;
    213 } ehci_qtd;
     213} _PACKED ehci_qtd;
    214214
    215215
    216216#define EHCI_QTD_DATA_TOGGLE    (1 << 31)
    typedef struct ehci_qtd {  
    244244// Queue Head (QH, EHCI Spec 3.6)
    245245typedef struct ehci_qh {
    246246    // Hardware Part
    247     addr_t      next_phy;
     247    uint32      next_phy;
    248248    uint32      endpoint_chars;
    249249    uint32      endpoint_caps;
    250     addr_t      current_qtd_phy;
     250    uint32      current_qtd_phy;
    251251
    252252    struct {
    253         addr_t      next_phy;
    254         addr_t      alt_next_phy;
     253        uint32      next_phy;
     254        uint32      alt_next_phy;
    255255        uint32      token;
    256         addr_t      buffer_phy[5];
    257         addr_t      ext_buffer_phy[5];
     256        uint32      buffer_phy[5];
     257        uint32      ext_buffer_phy[5];
    258258    } overlay;
    259259
    260260    // Software Part
    261     addr_t      this_phy;
     261    uint32      this_phy;
    262262    struct ehci_qh *next_log;
    263263    struct ehci_qh *prev_log;
    264264    ehci_qtd    *stray_log;
    typedef struct ehci_qh {  
    268268
    269269typedef struct {
    270270    ehci_qh     queue_head;
     271#ifdef B_HAIKU_64_BIT
     272    uint32      padding[6];
     273#else
    271274    uint32      padding[2];
     275#endif
    272276} interrupt_entry;
    273277
    274278typedef struct {
    275279    ehci_itd    itd;
     280#ifdef B_HAIKU_64_BIT
     281    uint32      padding[1]; // align on 128
     282#else
    276283    uint32      padding[5]; // align on 128
     284#endif
    277285} itd_entry;
    278286
    279287typedef struct {
    280288    ehci_sitd   sitd;
    281     uint32      padding[2]; // align on 64
     289
     290#ifdef B_HAIKU_64_BIT
     291    uint32      padding[14]; // align on 64
     292#else
     293    uint32      padding[2]; // align on 64
     294#endif
    282295} sitd_entry;
    283296
    284297#define EHCI_INTERRUPT_ENTRIES_COUNT    (7 + 1)     // (log 128 / log 2) + 1
  • src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp

    diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp
    index 70236c5..4154151 100644
    a b  
    1818
    1919#define DRIVER_NAME         "usb_disk"
    2020#define DEVICE_NAME_BASE    "disk/usb/"
    21 #define DEVICE_NAME         DEVICE_NAME_BASE"%ld/%d/raw"
     21#define DEVICE_NAME         DEVICE_NAME_BASE"%" B_PRIu32 "/%d/raw"
    2222
    2323
    2424//#define TRACE_USB_DISK
    status_t usb_disk_receive_csw(disk_device *device,  
    130130                command_status_wrapper *status);
    131131status_t    usb_disk_operation(device_lun *lun, uint8 operation,
    132132                uint8 opLength, uint32 logicalBlockAddress,
    133                 uint16 transferLength, void *data, uint32 *dataLength,
     133                uint16 transferLength, void *data, size_t *dataLength,
    134134                bool directionIn);
    135135
    136136status_t    usb_disk_request_sense(device_lun *lun);
    usb_disk_receive_csw(disk_device *device, command_status_wrapper *status)  
    259259status_t
    260260usb_disk_operation(device_lun *lun, uint8 operation, uint8 opLength,
    261261    uint32 logicalBlockAddress, uint16 transferLength, void *data,
    262     uint32 *dataLength, bool directionIn)
     262    size_t *dataLength, bool directionIn)
    263263{
    264264    TRACE("operation: lun: %u; op: %u; oplen: %u; lba: %lu; tlen: %u; data: "
    265265        "%p; dlen: %p (%lu); in: %c\n",
    usb_disk_operation(device_lun *lun, uint8 operation, uint8 opLength,  
    427427status_t
    428428usb_disk_request_sense(device_lun *lun)
    429429{
    430     uint32 dataLength = sizeof(scsi_request_sense_6_parameter);
     430    size_t dataLength = sizeof(scsi_request_sense_6_parameter);
    431431    scsi_request_sense_6_parameter parameter;
    432432    status_t result = usb_disk_operation(lun, SCSI_REQUEST_SENSE_6, 6, 0,
    433433        dataLength, &parameter, &dataLength, true);
    usb_disk_request_sense(device_lun *lun)  
    492492status_t
    493493usb_disk_mode_sense(device_lun *lun)
    494494{
    495     uint32 dataLength = sizeof(scsi_mode_sense_6_parameter);
     495    size_t dataLength = sizeof(scsi_mode_sense_6_parameter);
    496496    scsi_mode_sense_6_parameter parameter;
    497497    status_t result = usb_disk_operation(lun, SCSI_MODE_SENSE_6, 6,
    498498        SCSI_MODE_PAGE_DEVICE_CONFIGURATION, dataLength, &parameter,
    usb_disk_test_unit_ready(device_lun *lun)  
    538538status_t
    539539usb_disk_inquiry(device_lun *lun)
    540540{
    541     uint32 dataLength = sizeof(scsi_inquiry_6_parameter);
     541    size_t dataLength = sizeof(scsi_inquiry_6_parameter);
    542542    scsi_inquiry_6_parameter parameter;
    543543    status_t result = B_ERROR;
    544544    for (uint32 tries = 0; tries < 3; tries++) {
    usb_disk_reset_capacity(device_lun *lun)  
    586586status_t
    587587usb_disk_update_capacity(device_lun *lun)
    588588{
    589     uint32 dataLength = sizeof(scsi_read_capacity_10_parameter);
     589    size_t dataLength = sizeof(scsi_read_capacity_10_parameter);
    590590    scsi_read_capacity_10_parameter parameter;
    591591    status_t result = B_ERROR;
    592592
    usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)  
    11261126#endif
    11271127
    11281128        default:
    1129             TRACE_ALWAYS("unhandled ioctl %ld\n", op);
     1129            TRACE_ALWAYS("unhandled ioctl %" B_PRId32 "\n", op);
    11301130            break;
    11311131    }
    11321132
    usb_disk_read(void *cookie, off_t position, void *buffer, size_t *length)  
    11771177    }
    11781178
    11791179    *length = 0;
    1180     TRACE_ALWAYS("read fails with 0x%08lx\n", result);
     1180    TRACE_ALWAYS("read fails with 0x%08" B_PRIx32 "\n", result);
    11811181    return result;
    11821182}
    11831183
    usb_disk_write(void *cookie, off_t position, const void *buffer,  
    12281228    }
    12291229
    12301230    *length = 0;
    1231     TRACE_ALWAYS("write fails with 0x%08lx\n", result);
     1231    TRACE_ALWAYS("write fails with 0x%08" B_PRIx32 "\n", result);
    12321232    return result;
    12331233}
    12341234
    init_driver()  
    12701270    status_t result = get_module(B_USB_MODULE_NAME,
    12711271        (module_info **)&gUSBModule);
    12721272    if (result < B_OK) {
    1273         TRACE_ALWAYS("getting module failed 0x%08lx\n", result);
     1273        TRACE_ALWAYS("getting module failed 0x%08" B_PRIx32 "\n", result);
    12741274        mutex_destroy(&gDeviceListLock);
    12751275        return result;
    12761276    }