Example #1
0
E_NANDERRORCODE Nand_WriteSector_Exnftl(T_PNANDFLASH pNand, T_U32 nChip, T_U32 nPlaneCnt, T_U32 nBlock, T_U32 nPage, T_U8 *pMain, T_U8 *pAdd , T_U32 nAddLen, T_U32 nPageCnt)
{
   E_NANDERRORCODE ret;
   T_U32 i;

   for(i = 0; i < nPageCnt; i++)
   {
       ret = Write_Page(nChip, nBlock, nPage, pMain, pAdd, nAddLen, AREA_FSA);

       if(NF_FAIL == ret)
       {
           goto L_EXIT;
       }
       
       nPage++;
       pMain += g_nPageSize;
       pAdd += nAddLen;
   }

L_EXIT:
   return  ret;
}
Example #2
0
E_NANDERRORCODE Nand_WriteSector(T_PNANDFLASH pNand, T_U32 nChip, T_U32 nBlock, T_U32 nPage, T_U8 *pMain, T_U8 *pAdd, T_U32 nAddLen)
{
    return Write_Page(nChip, nBlock, nPage, pMain, pAdd, nAddLen, ASA_ADD_LEN ==  nAddLen ? AREA_ASA : AREA_FSA);
}
Example #3
0
//--------------------------------------------------------------------------
// ExtWrite writes an extended file at a location.  The bitmap bits are
// set each time a pages is written and verified.
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// strt_page  the page to start the extended write
// file       location of the file to write
// fllen      the length of the file
// BM         the bitmap
//
// return TRUE if the write was successful.
//
SMALLINT ExtWrite(int portnum, uchar *SNum, uchar strt_page, uchar *file, 
                  int fllen, uchar *BM)
{
	int   pgs = 0;
	int   len = 0;
	PAGE_TYPE avail,next;
	uchar WrStr[32];
   int   i,j;
	                        
   if(fllen == 0)
   {
      if(!BitMapChange(portnum,SNum,strt_page,1,BM))
         return FALSE;

      return TRUE;
   }

   // calculate number of universal pages in file                     
   pgs = fllen / 28;    
   if (fllen % 28 || !fllen) 
      pgs++;

   // find available page and next available page
   FindEmpties(portnum,SNum,BM,&avail,&next);

   if(avail == 0)
   { 
   	OWERROR(OWERROR_OUT_OF_SPACE);
   	return FALSE;
   }  

   next = avail;
   avail = strt_page;
   // loop to write each page of the file
   for(i=0;i<pgs;i++)
   {
      // check to see if next chunk is last chunk and adjust size
      len = fllen - (i*28);
      if (len > 28)  
         len = 28;
      
      // copy next chuck to write buffer
      for (j=0; j<len; j++)
         WrStr[j] = file[(i*28)+j];

      // add the continuation pointer                   
      if(i == (pgs-1)) 
         WrStr[len] = (uchar) 0;  
      else 
         WrStr[len] = (uchar) next;
      
      // write the page
      if(!Write_Page(portnum,SNum,&WrStr[0],avail,(len+1)))
      	return FALSE;
                          
      // set the page just written to in bitmap  BM 
      if(!BitMapChange(portnum,SNum,avail,1,BM))
         return FALSE;

      // find available page and next available page
      FindEmpties(portnum,SNum,BM,&avail,&next);

      if((avail == 0) && ((pgs-1) != i))
      { 
   	   OWERROR(OWERROR_OUT_OF_SPACE);
   	   return FALSE;
      }  
   }

   // must be completed because it has made it this far
   return TRUE;
}