Exemplo n.º 1
0
        static void ShiftFshKey()
        {
            FlashAddr = 0X2074;
            R0X41     = ReadFshData(R0XC1);

            if (R0X41 != 0)
            {
                for (; ;)
                {
                    //			asm("BANKSEL _A.R0XAB");
                    //			asm("RRCF _A.R0XAB, F, B");
                    //			asm("RRCF _A.R0XAC, F, B");
                    //			asm("RRCF _A.R0XAD, F, B");
                    //			asm("RRCF _A.R0XAE, F, B ");
                    ulR0XAB >>= 1;

                    BytesOP.ClrBit(ref ulR0XAB, 7);
                    if (BytesOP.GetBit(ulR0XAB, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAB, 7);
                    }
                    ;

                    //           asm("BANKSEL _A.R0XAF");
                    //		   asm("RRCF _A.R0XAF, F, B");
                    //		   asm("RRCF _A.R0XB0, F, B");
                    //		   asm("RRCF _A.R0XB1, F, B");
                    //		   asm("RRCF _A.R0XB2, F, B");
                    ulR0XAF >>= 1;

                    BytesOP.ClrBit(ref ulR0XAF, 7);
                    if (BytesOP.GetBit(ulR0XAF, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAF, 7);
                    }
                    ;

                    R0X41--;
                    if (R0X41 == 0)
                    {
                        break;
                    }
                }
            }

            R0XBB = 0XAB;
            R0XBC = 0XB3;
            R0X52 = 0X7F;
            R0X53 = 0X3F;

            BytesOP.SetBit(ref R0XCB, 6);
            GetFshKey();
        }
Exemplo n.º 2
0
        public static byte[] Decode(byte[] sin)
        {
            byte[] sout = new byte[8];

            for (int i = 0; i < 8; i++)
            {
                RAMBUF[i + 0x83 - 0x83] = sin[i];
                RAMBUF[i + 0x8b - 0x83] = sin[i];
            }

            R0XBB = 0X8B;
            R0XBC = 0XA3;
            R0X52 = 0X3F;
            R0X53 = 0X3F;

            BytesOP.ClrBit(ref R0XCB, 6);

            GetFshKey();

            R0XBB = 0X93;
            R0XBC = 0XAB;
            R0X52 = 0X3F;
            R0X53 = 0X3F;

            BytesOP.SetBit(ref R0XCB, 6);

            GetFshKey();

            for (int i = 16; i != 0; i--)     // 16次循环
            {
                MixFshKey();
            }

            R0XBB = 0XA3;
            R0XBC = 0X8B;
            R0X52 = 0X7F;
            R0X53 = 0X3F;

            BytesOP.ClrBit(ref R0XCB, 6);

            GetFshKey();
            for (int i = 0; i < 8; i++)
            {
                sout[i] = RAMBUF[0x8b - 0x83 + i];
            }
            return(sout);
        }
Exemplo n.º 3
0
        void InitPCIE()
        {
            byte[] readList = new byte[0x100];
            byte   read     = 0;

            //获得中断号
            CH368.CH367mGetIntLine(CH368Index, ref oIntLine);
            //取得操作基地址
            CH368.CH367mGetIoBaseAddr(CH368Index, out mBaseAddr);
            CH368.CH368mGetMemBaseAddr(CH368Index, out mMemAddr);
            //RAM CE 高电平 A15
            CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xf8, ref read);
            BytesOP.SetBit(ref read, 0);
            BytesOP.ClrBit(ref read, 2);//清中断标志
            CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xf8, read);
            //8位数据总线
            CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xfa, ref read);
            BytesOP.ClrBit(ref read, 6);
            CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xfa, read);
            //SCS 高电平
            CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xe8, ref read);
            BytesOP.SetBit(ref read, 2);
            CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xe8, read);
            //配置中断服务程序
            _CH368IntProc = new CH368.mPCH367_INT_ROUTINE(CH368IntProc);
            CH368.CH367mSetIntRoutine(CH368Index, _CH368IntProc);
            //低电平中断
            read = 0xe2;
            CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xeb, read);
            //首次判断
//             CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xf8, ref read);
//             if (!BytesOP.GetBit(read, 3))
//             {
//                 CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xe8, ref read);
//                 BytesOP.ClrBit(ref read, 2);//拉低SCS
//                 CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xe8, read);
//                 while (true)
//                 {
//                     CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xf8, ref read);
//                     if (BytesOP.GetBit(read, 3))
//                         break;
//                 }
//             }
            //CH368.CH367mAccessBlock(CH368Index, CH368.mFuncReadIoByte, mBaseAddr->mCH367IoPort[mAddr], read, 1);
        }
Exemplo n.º 4
0
        static void MixFshKey()
        {
            int p0, p1, p2;

            R0XBB = 0XA7;
            R0XBC = 0X9B;
            R0X52 = 0XBF;
            R0X53 = 0X3F;

            BytesOP.ClrBit(ref R0XCB, 6);
            GetFshKey();
            ShiftFshKey();

            R0X53 = 8;
            p0    = 0x9b;
            p1    = 0xb3;

            for (; ;)
            {
                RAMBUF[p0 - 0x83] ^= (RAMBUF[p1 - 0x83]);
                p0++;
                p1++;

                R0X53--;
                if (R0X53 == 0)
                {
                    break;
                }
            }

            R0XBB = 0X9B;
            R0XBC = 0X9B;
            ShiftMixKey();

            R0XBB = 0X9B;
            R0XBC = 0XB3;
            R0X52 = 0XDF;
            R0X53 = 0X1F;

            BytesOP.ClrBit(ref R0XCB, 6);
            GetFshKey();

            R0X53 = 4;
            p0    = 0xa6;
            p1    = 0xaa;
            p2    = 0xb6;

            for (; ;)
            {
                RAMBUF[p2 - 0x83] ^= (RAMBUF[p0 - 0x83]);
                RAMBUF[p0 - 0x83]  = RAMBUF[p1 - 0x83];
                RAMBUF[p1 - 0x83]  = RAMBUF[p2 - 0x83];

                p0--;
                p1--;
                p2--;

                R0X53--;
                if (R0X53 == 0)
                {
                    break;
                }
            }
        }