Esempio n. 1
0
        private static void InitTransmit(UHCITransmitDescriptor *td, UHCITransmitDescriptor *previous,
                                         USBDeviceSpeed speed, uint address, uint endp, uint toogle, uint type, uint len, byte *data)
        {
            len = (len - 1) & 0x7FFF;

            if (previous != null)
            {
                previous->Link = (int)Paging.GetPhysicalFromVirtual(td) | TD_POINTER_DEPTH;
                previous->Next = td;
            }

            td->Link = TD_POINTER_TERMINATE;
            td->Next = null;

            td->Control = (int)((3 << (int)TD_ERROR_SHIFT) | TD_CONTROL_ACTIVE);
            if (speed == USBDeviceSpeed.LOW_SPEED)
            {
                td->Control |= (int)TD_CONTROL_LOW_SPEED;
            }


            td->Token = (len << TD_TOKEN_MAXLEN) |
                        (toogle << TD_TOKEN_D_SHIFT) |
                        (endp << TD_TOKEN_ENDP) |
                        (address << TD_TOKEN_ADDR) |
                        type;

            td->BufferPointer = (int)Paging.GetPhysicalFromVirtual(data);
        }
Esempio n. 2
0
        private static void InitTransmit(EHCITransferDescriptor *td, EHCITransferDescriptor *previous,
                                         USBDeviceSpeed speed, uint address, uint endp, uint toggle, uint type, uint len, byte *data)
        {
            td->NextLink = TD_TERMINATE;
            td->Reserved = TD_TERMINATE;
            td->Next     = null;

            // Add link
            if (previous != null)
            {
                previous->NextLink = (int)td;
                previous->Next     = td;
            }

            // Set token
            td->Token = (int)((toggle << TD_TOK_TOGGLE_SHIFT) |
                              (len << TD_TOK_TBTT_SHIFT) |
                              (3 << TD_TOK_CERR_SHIFT) |
                              (type << TD_TOK_PID_SHIFT) |
                              TD_TOK_STATUS_ACTIVE);

            // Set data buffer
            int ptr = (int)data;

            td->Buffer[0]    = ptr;
            td->ExtBuffer[0] = (ptr >> 32);
            ptr &= ~0xFFF;

            for (int i = 1; i < 4; i++)
            {
                ptr             += 0x1000;
                td->Buffer[i]    = ptr;
                td->ExtBuffer[i] = (ptr >> 32);
            }
        }