コード例 #1
0
        protected override void DecodePartial()
        {
            int count = base.Count;

            System.Diagnostics.Debug.Assert(count > 0 && count < 5);

            // According to Table 7-13, "Missing components of exception Branch address packets"
            // then after a partial branch, we're always in "no exception" state
            base.ExceptionType = TArmExceptionType.ENone;

            if (count == 1)
            {
                // The single-byte packet is exactly the same as in the original encoding
                base.DecodePartial();
            }
            else
            {
                // We have full 5 bytes of address info.
                SymMask maskFirst  = new SymMask(0x7E, SymMask.TShiftDirection.ERight, 1);
                SymMask maskMiddle = new SymMask(0x7F);
                SymMask maskLast   = new SymMask(0x3F);

                SymByte b;
                SymAddressWithKnownBits address = new SymAddressWithKnownBits();
                uint masked = 0;

                // First byte
                b = base[0];
                address.KnownBits += 6;
                address.Address   |= maskFirst.Apply(b);

                // Middle bytes, but not the last
                for (int i = 1; i < count - 1; i++)
                {
                    b                  = base[i];
                    b                  = (byte)maskMiddle.Apply(b);
                    masked             = (uint)(b << address.KnownBits);
                    address.KnownBits += 7;
                    address.Address   |= masked;
                }

                // Last byte
                b = base.LastByte;
                address.KnownBits += 6;
                address.Address   |= maskLast.Apply(b);

                // Shift entire address by shift count based upon current instruction set.
                int isShift = ETMBranchDecoder.CompressionLeftShiftCount(base.InstructionSet);
                address.KnownBits += isShift;
                address.Address  <<= isShift;

                // Save address
                base.BranchAddress = address;
            }
        }
コード例 #2
0
        protected override void DecodePartial()
        {
            // According to Table 7-13, "Missing components of exception Branch address packets"
            // then after a partial branch, we're always in "no exception" state
            base.ExceptionType = TArmExceptionType.ENone;

            // We have full 5 bytes of address info.
            SymMask maskFirst  = new SymMask(0x7E, SymMask.TShiftDirection.ERight, 1);
            SymMask maskMiddle = new SymMask(0x7F);

            SymByte b;
            SymAddressWithKnownBits address = new SymAddressWithKnownBits();
            uint masked = 0;
            int  count  = base.Count;

            // First byte
            b = base[0];
            address.KnownBits += 6;
            address.Address   |= maskFirst.Apply(b);

            // Bytes 1, 2, 3
            for (int i = 1; i < count; i++)
            {
                b                  = base[i];
                b                  = (byte)maskMiddle.Apply(b);
                masked             = (uint)(b << address.KnownBits);
                address.KnownBits += 7;
                address.Address   |= masked;
            }

            // Shift entire address by shift count based upon current instruction set.
            int isShift = ETMBranchDecoder.CompressionLeftShiftCount(base.InstructionSet);

            address.KnownBits += isShift;
            address.Address  <<= isShift;

            // Save address
            base.BranchAddress = address;
        }
コード例 #3
0
        protected override void DecodeFull()
        {
            // We have full 5 bytes of address info.
            SymMask maskFirst  = new SymMask(0x7E, SymMask.TShiftDirection.ERight, 1);
            SymMask maskMiddle = new SymMask(0x7F);

            SymByte b;
            SymAddressWithKnownBits address = new SymAddressWithKnownBits();
            uint masked = 0;

            // First byte
            b = base[0];
            address.KnownBits += 6;
            address.Address   |= maskFirst.Apply(b);

            // Bytes 1, 2, 3
            for (int i = 1; i <= 3; i++)
            {
                b                  = base[i];
                b                  = (byte)maskMiddle.Apply(b);
                masked             = (uint)(b << address.KnownBits);
                address.KnownBits += 7;
                address.Address   |= masked;
            }

            // Last byte - mask depends on instruction set.
            b = base[4];
            int lastByteAddressBits = 0;

            if (this.ContainsInlineException || iMaskByte5_ARM.IsMatch(b))
            {
                // Inline exception indicates ARM.
                base.InstructionSet = TArmInstructionSet.EARM;
                lastByteAddressBits = 3;
            }
            else if (iMaskByte5_THUMB.IsMatch(b))
            {
                base.InstructionSet = TArmInstructionSet.ETHUMB;
                lastByteAddressBits = 4;
            }
            else if (iMaskByte5_JAZELLE.IsMatch(b))
            {
                base.InstructionSet = TArmInstructionSet.EJAZELLE;
                lastByteAddressBits = 5;
            }
            else
            {
                throw new ETMException("ERROR: branch type unknown");
            }

            // Now we can process the last byte
            masked             = b.LowestBits(lastByteAddressBits);
            masked           <<= address.KnownBits;
            address.KnownBits += lastByteAddressBits;
            address.Address   |= masked;

            // Shift entire address by shift count based upon current instruction set.
            int isShift = ETMBranchDecoder.CompressionLeftShiftCount(base.InstructionSet);

            System.Diagnostics.Debug.Assert(address.KnownBits + isShift == 32);
            address.KnownBits = 32;
            address.Address <<= isShift;

            // Save address
            base.BranchAddress = address;

            // We may also need to decode the inline exception
            if (ContainsInlineException)
            {
                // Yup, line exception...
                DecodeInlineException(base.LastByte);
            }
        }