示例#1
0
int At250xx::Read(int probe, int type)
{
    UserDebug1(UserApp1, "At250xx::Read(%d)\n", probe);

    if (probe || GetNoOfBank() == 0)
        Probe();

    int size = GetNoOfBank() * GetBankSize();

    UserDebug1(UserApp1, "At250xx::Read() ** Size = %d\n", size);

    int rv = size;
    if (type & PROG_TYPE)
    {
        rv = GetBus()->Read(0, GetBufPtr(), size);
        if (rv != size)
        {
            if (rv > 0)
                rv = OP_ABORTED;
        }
    }

    UserDebug1(UserApp1, "At250xx::Read() = %d\n", rv);

    return rv;
}
示例#2
0
int Device::VerifyProg(unsigned char *localbuf)
{
	int rval = -1;
	int size = GetSplitted();
	int base = 0;

	//Verify only programmed bytes (to save time in big devices)
	long v_len = size;
	if (THEAPP->GetLastProgrammedAddress() > 0 && THEAPP->GetLastProgrammedAddress() < size )
	{
		v_len = THEAPP->GetLastProgrammedAddress() + 1;
		THEAPP->ClearLastProgrammedAddress();		//reset last_programmed_addr, so next verify not preceeded by write verify all the flash
	}
	//Set blank locations to default 0xFF (erased)
	memset(localbuf, 0xFF, size);

	// read the current flash content and store it in localbuf
	rval = GetBus()->Read(0, localbuf, v_len);
	if ( rval != v_len )
	{
		if (rval > 0)
			rval = OP_ABORTED;
	}
	else
		rval = GetBus()->CompareMultiWord(GetBufPtr()+base, localbuf+base, size, 0) == 0 ? OK : 1;

	return rval;
}
示例#3
0
int At250xx::Verify(int type)
{
    if (GetNoOfBank() == 0)
        return BADPARAM;

    int size = GetNoOfBank() * GetBankSize();
    unsigned char *localbuf;
    localbuf = new unsigned char[size];
    if (localbuf == 0)
        return OUTOFMEMORY;

    int rval = 1;
    if (type & PROG_TYPE)
    {
        rval = GetBus()->Read(0, localbuf, size);
        if (rval != size)
        {
            if (rval > 0)
                rval = OP_ABORTED;
        }
        else
        {
            rval = ( memcmp(GetBufPtr(), localbuf, size) != 0 ) ? 0 : 1;
        }
    }
    delete localbuf;

    return rval;
}
示例#4
0
//Read Flash program memory
int Device::ReadProg()
{
	int retval;
	int size = GetSplitted();
	int base = 0;

	retval = GetBus()->Read(0, GetBufPtr()+base, size);
	if (retval != size)
	{
		if (retval > 0)
			retval = OP_ABORTED;
	}

	return retval;
}
示例#5
0
//Write EEprom data memory
int Device::WriteData()
{
	int rv;
	int size = GetSize() - GetSplitted();
	int base = GetSplitted();

	rv = GetBus()->Write(1, GetBufPtr()+base, size);
	if ( rv != size )
	{
		if (rv > 0)
			rv = OP_ABORTED;
	}

	return rv;
}
示例#6
0
//Write Flash program memory
int Device::WriteProg()
{
	int rv;
	int size = GetSplitted();
	int base = 0;

	rv = GetBus()->Write(0, GetBufPtr()+base, size);
	if ( rv != size )
	{
		if (rv > 0)
			rv = OP_ABORTED;
	}

	return rv;
}
示例#7
0
int Device::VerifyData(unsigned char *localbuf)
{
	int rval;
	int size = GetSize() - GetSplitted();
	int base = GetSplitted();

	//read current EEPROM content and
	rval = GetBus()->Read(1, localbuf+base, size );
	if ( rval != size )
	{
		if (rval > 0)
			rval = OP_ABORTED;
	}
	else
		rval = GetBus()->CompareMultiWord(GetBufPtr()+base, localbuf+base, size, 1) == 0 ? OK : 1;

	return rval;
}
示例#8
0
int At250xx::Write(int probe, int type)
{
    if (probe || GetNoOfBank() == 0)
        Probe();

    int size = GetNoOfBank() * GetBankSize();

    int rv = size;
    if (type & PROG_TYPE)
    {
        rv = GetBus()->Write(0, GetBufPtr(), size);
        if (rv != size)
        {
            if (rv > 0)
                rv = OP_ABORTED;
        }
    }

    return rv;
}
示例#9
0
cl_int GLCLDraw::GetVram(int bmode)
{
   cl_int ret = 0;
   cl_int r;
   cl_kernel kernel;
   int w = 0;
   int h = 0;
   Uint8 *pr,*pg,*pb;
   size_t lws[] = {10}; // local jobs.
   size_t gws[] = {nCLGlobalWorkThreads}; // Parallel jobs.
   size_t *goff = NULL;
   int mpage = multi_page;
   int dummy = 0;
   int vpage;
   int crtflag = crt_flag;
   int bank;
   BOOL flag = FALSE;
   int i;
   cl_float4 bright;
   cl_event copy_event;

   bright.s[0] = fBrightR; // R
   bright.s[1] = fBrightG; // G
   bright.s[2] = fBrightB; // B
   bright.s[3] = 1.0; // A
 
   //if(inbuf == NULL) return -1;
   if(outbuf == NULL) return -1;
   //if(TransferBuffer == NULL) return -1;
   /*
    * Swap Buffer
    */
   {
     size_t transfer_size = 0;
     bank = inbuf_bank;
     Uint8 *p;
     p = GetBufPtr(0); // Maybe okay?
     for(i = 0; i < 400 ; i++) {
       if(bDrawLine[i]) flag = TRUE;
       bDrawLine[i] = FALSE;
    }
    if(flag) {
       ret = UnMapTransferBuffer(p);
       if(ret < CL_SUCCESS) {
	 ReleaseBufPtr();
	 return ret;
       }
     }
     switch(bmode){
     case SCR_200LINE:
       transfer_size = 0x4000 * 3;
       break;
     case SCR_400LINE:
       transfer_size = 0x8000 * 3;
       break;
     case SCR_4096:
       transfer_size = 0x2000 * 12;
       break;
     case SCR_262144:
       transfer_size = 0x2000 * 18;
       break;
     }
     //if((flag != FALSE) && (transfer_size > 0)){
       inbuf_bank++;
       if(inbuf_bank >= 2) inbuf_bank = 0;
#if 0
         size_t lws_copy[] = {1};
	 size_t gws_copy[] = {gws[0]};
	      
	 cl_int size = transfer_size;
	 ret |= clSetKernelArg(kernel_copyvram, 0, sizeof(cl_mem), (void *)&(inbuf[inbuf_bank]));
	 ret |= clSetKernelArg(kernel_copyvram, 1, sizeof(cl_mem), (void *)&(inbuf[bank]));
	 ret |= clSetKernelArg(kernel_copyvram, 2, sizeof(cl_int), &size);
	 ret |= clSetKernelArg(kernel_copyvram, 3, sizeof(cl_int), &bCLSparse);
	 if(bCLSparse) {
	    ret = clEnqueueNDRangeKernel(command_queue, kernel_copyvram, 1, 
					 goff, gws_copy, lws_copy, 
					 0, NULL,  &copy_event);
	 } else {
	    ret = clEnqueueTask(command_queue,
				kernel_copyvram, 0, NULL, &copy_event);
	 }
      } else {