public override ETMDecodeState HandleByte(SymByte aByte)
        {
            ETMDecodeState nextState = this;

            //
            if (aByte == 0)
            {
                ++iASyncConsecutiveNullByteCount;
            }
            else if (aByte == 0x80 && iASyncConsecutiveNullByteCount == 5)
            {
                // That's the start of the a-sync packet
                iASyncConsecutiveNullByteCount = 0;
                base.StateData.SetSynchronized();
                nextState = new ETMDecodeStateSynchronized(base.StateData);
                Trace();
            }
            else
            {
                // Invalid byte
                throw new ETMException("ERROR - data is corrupt - expected null byte or end marker during A-SYNC");
            }
            //
            return(nextState);
        }
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            ETMDecodeState nextState = this;
            //
            ETMPcktBase packet = Packets.Factory.ETMPacketFactory.Create(aByte);

            if (packet != null)
            {
                if (packet is ETMPcktBranch)
                {
                    nextState = new ETMDecodeStateBranch(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktIgnore)
                {
                    nextState = new ETMDecodeStateIgnore(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktISync)
                {
                    nextState = new ETMDecodeStateISync(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktPHeaderFormat1 || packet is ETMPcktPHeaderFormat2)
                {
                    nextState = new ETMDecodeStatePHeader(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktASync)
                {
                    nextState = new ETMDecodeStateASync(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktOutOfOrderData)
                {
                    nextState = new ETMDecodeStateOutOfOrderData(base.StateData);
                    base.StateData.PushBack(aByte);
                }
                else if (packet is ETMPcktCycleCount)
                {
                    nextState = new ETMDecodeStateCycleCount(base.StateData);
                }
                else if (packet is ETMPcktContextID)
                {
                    nextState = new ETMDecodeStateContextID(base.StateData);
                }
                else
                {
                    base.Trace(string.Format("OP NOT HANDLED: {0:x2}", aByte));
                    System.Diagnostics.Debug.Assert(false);
                }
            }
            else
            {
                base.Trace(string.Format("WARNING: OP NOT RECOGNISED: {0:x2}", aByte));
                System.Diagnostics.Debug.Assert(false);
            }
            //
            return(nextState);
        }
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            ETMDecodeState nextState = this;

            if (iSeenHeader == false)
            {
                ETMPcktOutOfOrderData cycle = new ETMPcktOutOfOrderData(aByte);
                cycle.Matches(aByte);
                iDataByteCount = cycle.Size;
                iSeenHeader    = true;
            }
            else
            {
                iBytes.Add(aByte);
                //
                if (iBytes.Count == iDataByteCount)
                {
                    // Done
                    nextState = new ETMDecodeStateSynchronized(base.StateData);
                }
            }

            // Done.
            return(nextState);
        }
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            ETMDecodeState nextState = this;

            //
            if (aByte == 0)
            {
                ++iASyncConsecutiveNullByteCount;
            }
            else if (aByte == 0x80 && iASyncConsecutiveNullByteCount == 5)
            {
                // That's the start of the a-sync packet
                iASyncConsecutiveNullByteCount = 0;
                base.StateData.SetSynchronized();
                nextState = new ETMDecodeStateSynchronized(base.StateData);
                Trace();
            }
            else
            {
                iASyncConsecutiveNullByteCount = 0;
                base.StateData.SetUnsynchronized();
            }
            //
            return(nextState);
        }
Exemplo n.º 5
0
        public virtual ETMDecodeState PrepareToHandleByte(SymByte aByte)
        {
            iCurrentRawByte = aByte;
            //
            ETMDecodeState ret = HandleByte(aByte);

            return(ret);
        }
Exemplo n.º 6
0
        private void Trace(SymAddress aOriginalAddress, TArmInstructionSet aOriginalISet, SymAddress aNewAddress, TArmInstructionSet aNewISet)
        {
            System.Diagnostics.Debug.Assert(base.StateData.LastBranch.IsKnown);
            //
            StringBuilder lines = new StringBuilder();

            lines.AppendLine("   I-SYNC");
            lines.AppendLine(string.Format("       from: {0} 0x{1:x8} {2}", ETMDecodeState.MakeInstructionSetPrefix(aOriginalISet), aOriginalAddress, StateData.Engine.LookUpSymbol(aOriginalAddress)));
            lines.AppendLine(string.Format("         to: {0} 0x{1:x8} {2}", ETMDecodeState.MakeInstructionSetPrefix(aNewISet), aNewAddress, StateData.Engine.LookUpSymbol(aNewAddress)));
            //
            base.Trace(lines.ToString());
        }
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            // Handle the byte
            PerformStateOperation(aByte);

            // Decide what to return based upon current state
            ETMDecodeState nextState = this;

            if (iState == TState.EStateFinished)
            {
                iDecoder.FlushChanges();
                nextState = new ETMDecodeStateSynchronized(base.StateData);
            }

            // Done.
            return(nextState);
        }
Exemplo n.º 8
0
        private void TraceDirectBranch(SymAddress aOriginalAddress, TArmInstructionSet aOriginalISet, SymAddress aNewAddress, TArmInstructionSet aNewISet)
        {
            StringBuilder lines = new StringBuilder();

            lines.AppendLine("   BRANCH-D");
            //
            if (base.StateData.LastBranch.IsKnown)
            {
                lines.AppendLine(string.Format("       from: {0} 0x{1:x8} {2}", ETMDecodeState.MakeInstructionSetPrefix(aOriginalISet), aOriginalAddress, StateData.Engine.LookUpSymbol(aOriginalAddress)));
                lines.AppendLine(string.Format("         to: {0} 0x{1:x8} {2}", ETMDecodeState.MakeInstructionSetPrefix(aNewISet), aNewAddress, StateData.Engine.LookUpSymbol(aNewAddress)));
            }
            else
            {
            }
            //
            base.Trace(lines.ToString());
        }
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            // TODO: test this
            ETMDecodeState nextState = this;
            //
            int  byteNumber = iContextIdBytesRequired - iBytesRemaining;
            uint val        = aByte.LShift(byteNumber * 8);

            iContextId |= val;
            //
            if (--iBytesRemaining == 0)
            {
                // Got everything
                base.StateData.SetContextID(iContextId);
                nextState = new ETMDecodeStateSynchronized(base.StateData);
            }
            //
            return(nextState);
        }
Exemplo n.º 10
0
        public override ETMDecodeState HandleByte(SymByte aByte)
        {
            ETMDecodeState nextState = this;

            //
            switch (iState)
            {
            case TState.EStateHeader:
                if (base.StateData.Config.ContextIDSize != 0)
                {
                    iState = TState.EStateContextId;
                }
                else
                {
                    iState = TState.EStateInformation;
                }
                break;

            case TState.EStateContextId:
                OnContextByte(aByte);
                break;

            case TState.EStateInformation:
                OnInformationByte(aByte);
                break;

            case TState.EStateAddress:
                OnAddress(aByte);
                break;

            default:
            case TState.EStateIdle:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
            //
            if (iState == TState.EStateIdle)
            {
                nextState = new ETMDecodeStateSynchronized(base.StateData);
            }
            //
            return(nextState);
        }