Esempio n. 1
0
//---------------------------------------
// Main program
//---------------------------------------
void main(void)
{
	InitSerial();        // Initialize serial port
	putchar(0x0C);        // clear hyper terminal
	DelayMs(5);
	WriteBYTE(0x0000);
	WriteI2C('A');        //Write Data's Here
	WriteI2C('B');
	WriteI2C('C');
	WriteI2C('D');  
	WriteI2C('E');
	WriteI2C('F');  
	Stop(); 
	DelayMs(10);
	ReadBYTE(0x0000);
	EData[0] = ReadI2C(NO_ACK);   
	EData[1] = ReadI2C(NO_ACK);   
	EData[2] = ReadI2C(NO_ACK);   
	EData[3] = ReadI2C(NO_ACK);   
	EData[4] = ReadI2C(NO_ACK);   
	EData[5] = ReadI2C(NO_ACK);

	for(i=0;i<6;i++)
	{
		printf("value = %c\n",EData[i]);   // display data        */
		DelayMs(100);
    }
	while(1);
}
Esempio n. 2
0
String			TSearchFilesFrm::GetSearchData()
{
	AnsiString data;
	AnsiString content_text = edtSearchContent->Text;

	if(cbSearchMode->ItemIndex == 0)
	{
		data = content_text;
	}
	else if(cbSearchMode->ItemIndex == 1)
	{
		data = BinToStr(content_text.c_str(), content_text.Length());
	}
	else if(cbSearchMode->ItemIndex == 2)
	{
		DWORD num = content_text.ToInt();
		data.SetLength(4);
		int pos = 0;
		WriteDWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 3)
	{
		WORD num = content_text.ToInt();
		data.SetLength(2);
		int pos = 0;
		WriteWORD(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	else if(cbSearchMode->ItemIndex == 4)
	{
		BYTE num = content_text.ToInt();
		data.SetLength(1);
		int pos = 0;
		WriteBYTE(data.c_str(), pos, num);
		data = BinToStr(data.c_str(), data.Length());
	}
	return	data;
}
Esempio n. 3
0
    void PatchBlob( Blob& rOutputBlob, const ShaderArgs& rArgs, const Blob& rTemplateBlob, size_t nTemplateIsaStart )
    {
        
        //
        //  Summary of what I know about the blob layout:
        //
        // 
        //  DWORD 0: 0x00003142  This is a 4CC code "B1"
        //  DWORD 1: 0x020423c8.  Version number?  Device number? dunno
        //  DWORD 2 looks like it contains the blob length minus some constant
        //            but this field is itself shifted one byte.  the lower 8 bits are 0xB...?
        //  ^
        //  |  Rest is unknown
        //  V
        //  DWORD 16 threadgroup size X
        //  DWORD 17 " " Y (-1 if not specified)
        //  DWORD 18 " " Z (-1 if not specified)
        //  ^
        //  |
        //  | Unknown length and contents
        //  |   AT SOME POINT IN HERE, WE STOP BEING DWORD ALIGNED
        //  |
        //  |
        //  V 
        //  ^
        //  |  Various pre-isa fields, a few of which are understood
        //  |      (see below)
        //  V
        //  ^
        //  |
        //  | ISA   !NOT DWORD ALIGNED!
        //  |
        //  V
        //  ^
        //  |
        //  | Padding to align ISA to 64 bytes
        //  |
        //  V
        //  ^
        //  |
        //  | 512 bytes of zero padding
        //  |
        //  V
        //  CURBE data
        //   ....
        //   ....
        //  ^
        //  |
        //  | Unknown length and content
        //  V
        //  Last two DWORDS are a hash


        //
        //    By comparing different shaders I was able to decipher the important looking parts of the blob prior to the isa
        //     
        //        At isa-24 is the number of threads in the OpenGL workgroup grid (width*height*depth)
        //        At isa-32 is the SIMD mode (0 for SIMD0, 1 for SIMD16)
        //        At isa-104 and isa-702 is the number of 256-bit CURBE entries per hardware thread
        //        At isa-100 and isa-700 is the number of HW threads
        //        At isa-4 and isa-128 is the length of the isa block (including padding)
        //        At isa-40 is the length of the CURBE data
        //        
        //    
        //     The Isa block is always padded with 512 bytes (128 DWORDS) of zero.  
        //        Intel docs state that the 128 bytes following the last instruction are MBZ
        //          because instruction prefetching will yank those bytes in before the EU realizes the thread is done
        //
        //       512 bytes is more padding than we need.  Either the docs are wrong, or the driver is over-zealous
        //           Or else there's something there I haven't figured out yet.
 
        const unsigned char* pTemplate = ((const unsigned char*)rTemplateBlob.GetBytes());
        const unsigned char* isa = pTemplate  + nTemplateIsaStart;
        
        DWORD dwGridSize        = FetchDWORD(isa-24);  // width*height*depth for the GL threadgroup
        DWORD dwMode            = FetchDWORD(isa-32);  // 0 for SIMD8, 1 for SIMD16          
        DWORD dwCURBEEntrySize  = FetchDWORD(isa-104); 
        DWORD dwThreadCount     = FetchDWORD(isa-100); // also at isa-700
        DWORD dwIsaLength       = FetchDWORD(isa-4);   // also at isa-128
        DWORD dwCURBELength     = FetchDWORD(isa-40);

        size_t nPreIsaLength    = nTemplateIsaStart;
        size_t nPostCURBEStart  = nTemplateIsaStart + dwIsaLength + dwCURBELength;
        size_t nPostCURBELength = rTemplateBlob.GetLength() - nPostCURBEStart;

        size_t nNewIsaLength    = 512 + ( (rArgs.nIsaLength + 63) & ~63);
        size_t nNewCURBELength  =  rArgs.nCURBEAllocsPerThread*rArgs.nDispatchThreadCount*32;

        size_t nNewBlobSize = nPreIsaLength + nPostCURBELength + nNewIsaLength + nNewCURBELength;
        
        rOutputBlob.SetLength(nNewBlobSize);

        unsigned char* pNewBlob = (unsigned char*) rOutputBlob.GetBytes();
        unsigned char* pNewIsa       = pNewBlob  + nPreIsaLength;
        unsigned char* pNewCURBE     = pNewIsa   + nNewIsaLength;
        unsigned char* pNewPostCURBE = pNewCURBE + nNewCURBELength;

        // copy pre-Isa blob
        memcpy( pNewBlob, pTemplate, nPreIsaLength );

        // copy the new Isa into place and add the padding
        memcpy( pNewIsa, rArgs.pIsa, rArgs.nIsaLength );
        memset( pNewIsa + rArgs.nIsaLength, 0, nNewIsaLength - rArgs.nIsaLength  );

        // copy the new CURBE into place
        memcpy( pNewCURBE, rArgs.pCURBE, nNewCURBELength );

        // copy post-CURBE blob
        memcpy(pNewPostCURBE, pTemplate + nPostCURBEStart, nPostCURBELength );

        // override the fields we might need to change

        DWORD nDispatchMode = 0;
        switch( rArgs.nSIMDMode )
        {
        case 16: nDispatchMode = 1; break;
        case 32: nDispatchMode = 2; break;
        case 8:
        default:
           break; // keep SIMD8 dispatch (mode=0)
        }

        WriteDWORD( pNewIsa-32, nDispatchMode );

        // change thread grid size
        WriteDWORD( pNewIsa-24, (8<<nDispatchMode)*rArgs.nDispatchThreadCount );

        // change HW thread count
        WriteDWORD( pNewIsa-100, rArgs.nDispatchThreadCount );
        WriteBYTE( pNewIsa-700, rArgs.nDispatchThreadCount );

        // change CURBE allocation size
        WriteDWORD( pNewIsa-104, rArgs.nCURBEAllocsPerThread ); 
        WriteBYTE( pNewIsa-702, rArgs.nCURBEAllocsPerThread ); 

        // change CURBE length
        WriteDWORD( pNewIsa-40, nNewCURBELength );

        // change Isa length
        WriteDWORD( pNewIsa-4, nNewIsaLength );
        WriteDWORD( pNewIsa-128, nNewIsaLength );

        // Near the top, we have blob_length minus some constant.  696, in the case of our sample blobs
        //  This looks to be a "how many bytes follow" field
        //
        //   Not sure if the 696 is fixed or varies with the particular GLSL program
        //    Let's assume it varies...
        //
        DWORD nSizeDifference = rTemplateBlob.GetLength() - FetchDWORD( pTemplate + 13 );
        WriteDWORD( pNewBlob + 13, nNewBlobSize - nSizeDifference );

        // fix the hash
        DriverHashFunction( (DWORD*)(pNewBlob + (nNewBlobSize-8)), (DWORD*)pNewBlob, (nNewBlobSize-8)/4 );

    }