Пример #1
0
        public static void Test_QueueHeadWrapper()
        {
            FOS_System.String testName = "Queue Head Wrapper";
            DBGMSG(testName, "START");

            errors = 0;
            warnings = 0;

            EHCI_QueueHead qh = new EHCI_QueueHead();
            try
            {
                byte* pQH = (byte*)qh.queueHead;

                //Verifications done via two methods:
                //  1. Check value from pointer & manual shifting to confirm set properly
                //  2. Check value from "get" method to confirm reading properly
                //  3. For boolean types, also test & verify setting to false!

                qh.Active = true;
                if ((pQH[0x18u] & 0x80u) == 0)
                {
                    DBGERR(testName, "Active - Failed to set to true.");
                }
                else
                {
                    if (!qh.Active)
                    {
                        DBGERR(testName, "Active - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x18u] = 0xFF;
                        qh.Active = false;
                        if ((pQH[0x18u] & 0x80u) != 0)
                        {
                            DBGERR(testName, "Active - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.Active)
                            {
                                DBGERR(testName, "Active - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.ControlEndpointFlag = true;
                if ((pQH[0x07u] & 0x08u) == 0)
                {
                    DBGERR(testName, "ControlEndpointFlag - Failed to set to true.");
                }
                else
                {
                    if (!qh.ControlEndpointFlag)
                    {
                        DBGERR(testName, "ControlEndpointFlag - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x07u] = 0xFF;
                        qh.ControlEndpointFlag = false;
                        if ((pQH[0x07u] & 0x08u) != 0)
                        {
                            DBGERR(testName, "ControlEndpointFlag - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.ControlEndpointFlag)
                            {
                                DBGERR(testName, "ControlEndpointFlag - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.CurrentqTDPointer = (EHCI_qTD_Struct*)0xDEADBEFFu;
                //- Read back should equal 0xDEADBEE0
                if ((pQH[0x0Cu] & 0xF0u) != 0xF0u ||
                     pQH[0x0Du]          != 0xBEu ||
                     pQH[0x0Eu]          != 0xADu ||
                     pQH[0x0Fu]          != 0xDEu)
                {
                    DBGERR(testName, "CurrentqTDPointer - Failed to set.");
                }
                else
                {
                    if ((uint)qh.CurrentqTDPointer != 0xDEADBEF0u)
                    {
                        DBGERR(testName, "CurrentqTDPointer - Failed to read.");
                    }
                }

                qh.DataToggleControl = true;
                if ((pQH[0x05u] & 0x40u) == 0)
                {
                    DBGERR(testName, "DataToggleControl - Failed to set to true.");
                }
                else
                {
                    if (!qh.DataToggleControl)
                    {
                        DBGERR(testName, "DataToggleControl - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x05u] = 0xFF;
                        qh.DataToggleControl = false;
                        if ((pQH[0x05u] & 0x40u) != 0)
                        {
                            DBGERR(testName, "DataToggleControl - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.DataToggleControl)
                            {
                                DBGERR(testName, "DataToggleControl - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.DeviceAddress = 0xDE;
                if ((pQH[0x04u] & 0x7Fu) != 0x5Eu)
                {
                    DBGERR(testName, "DeviceAddress - Failed to set.");
                }
                else
                {
                    if ((uint)qh.DeviceAddress != 0x5Eu)
                    {
                        DBGERR(testName, "DeviceAddress - Failed to read.");
                    }
                }

                qh.EndpointNumber = 0xBF;
                //Shift!
                if ((pQH[0x05u] & 0x0Fu) != 0x0Fu)
                {
                    DBGERR(testName, "EndpointNumber - Failed to set.");
                }
                else
                {
                    if ((uint)qh.EndpointNumber != 0x0Fu)
                    {
                        DBGERR(testName, "EndpointNumber - Failed to read.");
                    }
                }

                qh.EndpointSpeed = 0xB3;
                //Shift!
                if ((pQH[0x05u] & 0x30u) != 0x30u)
                {
                    DBGERR(testName, "EndpointSpeed - Failed to set.");
                }
                else
                {
                    if ((uint)qh.EndpointSpeed != 0x03u)
                    {
                        DBGERR(testName, "EndpointSpeed - Failed to read.");
                    }
                }

                qh.HeadOfReclamationList = true;
                if ((pQH[0x05u] & 0x80u) == 0)
                {
                    DBGERR(testName, "HeadOfReclamationList - Failed to set to true.");
                }
                else
                {
                    if (!qh.HeadOfReclamationList)
                    {
                        DBGERR(testName, "HeadOfReclamationList - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x05u] = 0xFF;
                        qh.HeadOfReclamationList = false;
                        if ((pQH[0x05u] & 0x80u) != 0)
                        {
                            DBGERR(testName, "HeadOfReclamationList - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.HeadOfReclamationList)
                            {
                                DBGERR(testName, "HeadOfReclamationList - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.HighBandwidthPipeMultiplier = 0xDF;
                //Shift!
                if ((pQH[0x0Bu] & 0xC0u) != 0xC0u)
                {
                    DBGERR(testName, "HighBandwidthPipeMultiplier - Failed to set.");
                }
                else
                {
                    if ((uint)qh.HighBandwidthPipeMultiplier != 0x03u)
                    {
                        DBGERR(testName, "HighBandwidthPipeMultiplier - Failed to read.");
                    }
                }

                qh.HorizontalLinkPointer = (EHCI_QueueHead_Struct*)0xDEADBEFE;
                if ((pQH[0x00u] & 0xE0u) != 0xE0u ||
                     pQH[0x01u]          != 0xBEu ||
                     pQH[0x02u]          != 0xADu ||
                     pQH[0x03u]          != 0xDEu)
                {
                    DBGERR(testName, "HorizontalLinkPointer - Failed to set.");
                }
                else
                {
                    if ((uint)qh.HorizontalLinkPointer != 0xDEADBEE0u)
                    {
                        DBGERR(testName, "HorizontalLinkPointer - Failed to read.");
                    }
                }

                qh.HubAddr = 0xBE;
                //Shift!
                if ((pQH[0x0Au] & 0x7Fu) != 0x3Eu)
                {
                    DBGERR(testName, "HubAddr - Failed to set.");
                }
                else
                {
                    if ((uint)qh.HubAddr != 0x3Eu)
                    {
                        DBGERR(testName, "HubAddr - Failed to read.");
                    }
                }

                qh.InactiveOnNextTransaction = true;
                if ((pQH[0x04u] & 0x80u) == 0)
                {
                    DBGERR(testName, "InactiveOnNextTransaction - Failed to set to true.");
                }
                else
                {
                    if (!qh.InactiveOnNextTransaction)
                    {
                        DBGERR(testName, "InactiveOnNextTransaction - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x04u] = 0xFF;
                        qh.InactiveOnNextTransaction = false;
                        if ((pQH[0x04u] & 0x80u) != 0)
                        {
                            DBGERR(testName, "InactiveOnNextTransaction - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.InactiveOnNextTransaction)
                            {
                                DBGERR(testName, "InactiveOnNextTransaction - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.InterruptScheduleMask = 0xFE;
                //Shift!
                if (pQH[0x08u] != 0xFEu)
                {
                    DBGERR(testName, "InterruptScheduleMask - Failed to set.");
                }
                else
                {
                    if ((uint)qh.InterruptScheduleMask != 0xFEu)
                    {
                        DBGERR(testName, "InterruptScheduleMask - Failed to read.");
                    }
                }

                qh.MaximumPacketLength = 0xDEAD;
                //Shift!
                if ( pQH[0x06u]          != 0xADu ||
                    (pQH[0x07u] & 0x07u) != 0x06u)
                {
                    DBGERR(testName, "MaximumPacketLength - Failed to set.");
                }
                else
                {
                    if ((uint)qh.MaximumPacketLength != 0x06ADu)
                    {
                        DBGERR(testName, "MaximumPacketLength - Failed to read.");
                    }
                }

                qh.NakCountReload = 0xFF;
                //Shift!
                if ((pQH[0x07u] & 0xF0u) != 0xF0u)
                {
                    DBGERR(testName, "NakCountReload - Failed to set.");
                }
                else
                {
                    if ((uint)qh.NakCountReload != 0x0Fu)
                    {
                        DBGERR(testName, "NakCountReload - Failed to read.");
                    }
                }

                qh.NextqTDPointer = (EHCI_qTD_Struct*)0xDEADBEFF;
                //- Read back should equal 0xDEADBEE0
                if ((pQH[0x10u] & 0xF0u) != 0xF0u ||
                     pQH[0x11u] != 0xBEu ||
                     pQH[0x12u] != 0xADu ||
                     pQH[0x13u] != 0xDEu)
                {
                    DBGERR(testName, "NextqTDPointer - Failed to set.");
                }
                else
                {
                    if ((uint)qh.NextqTDPointer != 0xDEADBEF0u)
                    {
                        DBGERR(testName, "NextqTDPointer - Failed to read.");
                    }
                }

                qh.NextqTDPointerTerminate = true;
                if ((pQH[0x10u] & 0x01u) == 0)
                {
                    DBGERR(testName, "NextqTDPointerTerminate - Failed to set to true.");
                }
                else
                {
                    if (!qh.NextqTDPointerTerminate)
                    {
                        DBGERR(testName, "NextqTDPointerTerminate - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x10u] = 0xFF;
                        qh.NextqTDPointerTerminate = false;
                        if ((pQH[0x10u] & 0x01u) != 0)
                        {
                            DBGERR(testName, "NextqTDPointerTerminate - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.NextqTDPointerTerminate)
                            {
                                DBGERR(testName, "NextqTDPointerTerminate - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.PortNumber = 0xFF;
                //Shift!
                if ((pQH[0x0Au] & 0x80u) != 0x80u ||
                    (pQH[0x0Bu] & 0x3Fu) != 0x3Fu)
                {
                    DBGERR(testName, "PortNumber - Failed to set.");
                }
                else
                {
                    if ((uint)qh.PortNumber != 0x7Fu)
                    {
                        DBGERR(testName, "PortNumber - Failed to read.");
                    }
                }

                qh.SplitCompletionMask = 0xBE;
                //Shift!
                if (pQH[0x09u] != 0xBEu)
                {
                    DBGERR(testName, "SplitCompletionMask - Failed to set.");
                }
                else
                {
                    if ((uint)qh.SplitCompletionMask != 0xBEu)
                    {
                        DBGERR(testName, "SplitCompletionMask - Failed to read.");
                    }
                }

                qh.Terminate = true;
                if ((pQH[0x00u] & 0x01u) == 0)
                {
                    DBGERR(testName, "Terminate - Failed to set to true.");
                }
                else
                {
                    if (!qh.Terminate)
                    {
                        DBGERR(testName, "Terminate - Failed to read as true.");
                    }
                    else
                    {
                        pQH[0x00u] = 0xFF;
                        qh.Terminate = false;
                        if ((pQH[0x00u] & 0x01u) != 0)
                        {
                            DBGERR(testName, "Terminate - Failed to set to false.");
                        }
                        else
                        {
                            if (qh.Terminate)
                            {
                                DBGERR(testName, "Terminate - Failed to read as false.");
                            }
                        }
                    }
                }

                qh.Type = 0xFF;
                //Shift!
                if ((pQH[0x00u] & 0x06u) != 0x06u)
                {
                    DBGERR(testName, "Type - Failed to set.");
                }
                else
                {
                    if ((uint)qh.Type != 0x03u)
                    {
                        DBGERR(testName, "Type - Failed to read.");
                    }
                }

            }
            catch
            {
                errors++;
                BasicConsole.SetTextColour(BasicConsole.warning_colour);
                BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                BasicConsole.SetTextColour(BasicConsole.default_colour);
            }
            finally
            {
                qh.Free();
            }

            if (errors > 0)
            {
                DBGERR(testName, ((FOS_System.String)"Test failed! Errors: ") + errors + " Warnings: " + warnings);
            }
            else
            {
                if (warnings > 0)
                {
                    DBGWRN(testName, ((FOS_System.String)"Test passed with warnings: ") + warnings);
                }
                else
                {
                    DBGMSG(testName, "Test passed.");
                }
            }

            DBGMSG(testName, "END");

            BasicConsole.DelayOutput(1);
        }
Пример #2
0
        //SetupTransfer
        //SETUPTransaction
        //INTransaction
        //OUTTransaction
        //IssueTransfer
        //CreateQTD_SETUP
        //CreateQTD_IO
        //Create_QH
        public void Test_Create_QH()
        {
            FOS_System.String testName = "Queue Transfer Descrip";
            EHCITesting.DBGMSG(testName, "START");

            EHCITesting.errors = 0;
            EHCITesting.warnings = 0;

            EHCI_QueueHead qh = new EHCI_QueueHead();
            EHCI_QueueHead_Struct* pQH = qh.queueHead;
            try
            {
                CreateQH(pQH, 0xDEADBEEFu, (EHCI_qTD_Struct*)0x12345678u, true, 0xFE, 0xED, 0x1234);

                //Confirm values (other tests check that these get/set properties work properly)

            }
            catch
            {
                EHCITesting.errors++;
                BasicConsole.SetTextColour(BasicConsole.warning_colour);
                BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                BasicConsole.SetTextColour(BasicConsole.default_colour);
            }
            finally
            {
                qh.Free();
            }

            if (EHCITesting.errors > 0)
            {
                EHCITesting.DBGERR(testName, ((FOS_System.String)"Test failed! Errors: ") + EHCITesting.errors + " Warnings: " + EHCITesting.warnings);
            }
            else
            {
                if (EHCITesting.warnings > 0)
                {
                    EHCITesting.DBGWRN(testName, ((FOS_System.String)"Test passed with warnings: ") + EHCITesting.warnings);
                }
                else
                {
                    EHCITesting.DBGMSG(testName, "Test passed.");
                }
            }

            EHCITesting.DBGMSG(testName, "END");

            BasicConsole.DelayOutput(4);
        }