Exemplo n.º 1
0
//--------------------------------------------------------------------------
// ExtendedRead_Page:
//
// Read a extended page from the current Eprom Touch Memory.
// The record will be placed into a (uchar) memory location
// starting at the location pointed to by (buf).  This function will 
// read a page out of normal memory.  If the page being read is
// redirected then an error is returned
// The following return codes will be provided to the caller:
//
// 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.
// buff       the buffer for the data that was read
// pg         the page that starts the read
//
// return TRUE if the read was successful.
//  
SMALLINT ExtendedRead_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg)               
{    
	SMALLINT  bank;
   PAGE_TYPE page;
	uchar     extra[20]; 
   int       len,i;
                     
	bank = getBank(portnum,SNum,pg,REGMEM);
	page = getPage(portnum,SNum,pg,REGMEM);
	
	if(!owIsWriteOnce(bank,portnum,SNum) && ((SNum[0] != 0x18) && 
      (SNum[0] != 0x33) && (SNum[0] != 0xB3)) )
	{
		OWERROR(OWERROR_NOT_WRITE_ONCE);
		return FALSE;
	}
	
   // check on the program job to see if this page is in it 
   if(isJob(portnum,SNum))
   {      
      if(getJobData(portnum,SNum,pg,&buff[1],&len))
      {
         return TRUE;
      }
   }     
  
   if(owIsWriteOnce(bank,portnum,SNum))
   {
      if(!owReadPageExtraCRC(bank,portnum,SNum,page,&buff[0],&extra[0]))
     	   return FALSE;    
   }
   else
   {
      if(!owReadPageExtra(bank,portnum,SNum,page,FALSE,&buff[0],&extra[0]))
         return FALSE;

      for(i=0;i<owGetExtraInfoLength(bank,SNum);i++)
         buff[i+32] = extra[i];

      extra[0] = 0xFF;
   }

	if(extra[0] != 0xFF)
	{
		OWERROR(OWERROR_REDIRECTED_PAGE);
		return FALSE;
	}
   	
   return TRUE;
}
Exemplo n.º 2
0
/* handleNewJobArray()
 */
void
handleNewJobArray(struct jData *jarray,
                  struct idxList *idxList,
                  int maxJLimit)
{
    struct idxList *idxPtr;
    struct jData *jPtr;
    int numJobs = 0;
    int i;
    int userPending = 0;

    addJobIdHT(jarray);
    jarray->nodeType = JGRP_NODE_ARRAY;
    jarray->nextJob = NULL;

    if (mSchedStage != M_STAGE_REPLAY) {
        putOntoTree(jarray, JOB_NEW);
    } else {
        putOntoTree(jarray, JOB_REPLAY);
    }

    jarray->uPtr = getUserData(jarray->userName);

    if (jarray->shared->jobBill.options2 & SUB2_HOLD) {
        userPending = 1;
    }

    jPtr = jarray;
    for (idxPtr = idxList; idxPtr; idxPtr = idxPtr->next) {

        for (i = idxPtr->start; i <= idxPtr->end; i += idxPtr->step) {
            if (getJobData(LSB_JOBID((LS_LONG_INT)jarray->jobId, i)))
                continue;
            jPtr->nextJob = copyJData(jarray);
            numJobs++;
            jPtr = jPtr->nextJob;

            jPtr->nodeType = JGRP_NODE_JOB;
            jPtr->nextJob = NULL;
            jPtr->jobId = LSB_JOBID((LS_LONG_INT)jarray->jobId, i);
            addJobIdHT(jPtr);
            inPendJobList(jPtr, PJL, 0);
            if (userPending) {
                jPtr->newReason = PEND_USER_STOP;
                jPtr->jStatus = JOB_STAT_PSUSP;
            }
        }
    }

    ARRAY_DATA(jarray->jgrpNode)->maxJLimit = maxJLimit;

    if (mSchedStage != M_STAGE_REPLAY)
        log_newjob(jarray);

    if (mSchedStage != M_STAGE_REPLAY) {
        updQaccount(jarray,
                    jarray->shared->jobBill.maxNumProcessors * numJobs,
                    jarray->shared->jobBill.maxNumProcessors * numJobs,
                    0,
                    0,
                    0,
                    0);
        updUserData(jarray,
                    jarray->shared->jobBill.maxNumProcessors * numJobs,
                    jarray->shared->jobBill.maxNumProcessors * numJobs,
                    0,
                    0,
                    0,
                    0);
    }

    if (mSchedStage == M_STAGE_REPLAY) {

        if (maxUserPriority > 0) {
            if (jarray->shared->jobBill.userPriority < 0) {

                modifyJobPriority(jarray, maxUserPriority/2);
                for (jPtr = jarray->nextJob; jPtr; jPtr = jPtr->nextJob) {
                    modifyJobPriority(jPtr, maxUserPriority/2);
                }
            } else {
                modifyJobPriority(jarray,
                                  jarray->shared->jobBill.userPriority);
                for (jPtr = jarray->nextJob; jPtr; jPtr = jPtr->nextJob) {
                    modifyJobPriority(jPtr,
                                      jPtr->shared->jobBill.userPriority);
                }
            }
        }
    }

    ARRAY_DATA(jarray->jgrpNode)->counts[getIndexOfJStatus(jarray->nextJob->jStatus)] = numJobs;
    ARRAY_DATA(jarray->jgrpNode)->counts[JGRP_COUNT_NJOBS] = numJobs;
    updJgrpCountByOp(jarray->jgrpNode, 1);
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------
// Read_Page:
//
// Read a default data structure page from the current Touch Memory.
// The record will be placed shorto a (uchar) memory location
// starting at the location poshorted to by (buf).  This function will 
// read a page out of normal memory (flag = REGMEM) or a status memory
// page out of an eprom (flag = STATUSMEM).  If the page being read is
// redirected as in an eprom device then the page value passes by referece
// is changed to match the new page.
//
// 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.
// flag       tells weather to read regular memory or status memory
// buff       location for data read
// page       page number to read packet from
// len        the length of the data read
//
// return TRUE if the data was read correctly
//  
SMALLINT Read_Page(int portnum, uchar *SNum, uchar *buff, uchar flag, 
                   PAGE_TYPE *pg, int *len)
{
	SMALLINT  bank;
	PAGE_TYPE page;
   int       jobopen = FALSE;
   int       cnt = 0;
	uchar     extra[3],space;
	uchar     temp_buff[32];
	uchar     rd_buf[2];
   uchar     addpg;
   int       i;	

	
   // Are program jobs possible
   // is there a job that has been opened and is this a regular memory read
   if(isJob(portnum,SNum))
      jobopen = TRUE;
            
   // loop while redirected
   for (cnt = 0; cnt <= 256; cnt++)
   {       
      // if an program job is open then check there for page
      if(jobopen && (flag != STATUSMEM))
      {
         if(getJobData(portnum,SNum,*pg,buff,len))
         {
            return TRUE;
         }
      }

      // nope so look for page in cache
      if(FindPage(portnum,SNum,pg,flag,TRUE,buff,len,&space))  
      {
         if(*len == 0x41)
         {
            *pg = buff[0];
         }
         else if(flag != STATUSMEM)
         {
     		   return TRUE;
         }
      }

      bank = getBank(portnum,SNum,*pg,flag);
		page = getPage(portnum,SNum,*pg,flag);
			
      // nope so get it from the part      
      // if the page is in the status memory then call read status
      if (flag == STATUSMEM)
      {
      	if(owIsWriteOnce(bank,portnum,SNum) && owHasExtraInfo(bank,SNum))
      	{
      		if(!owReadPageExtraCRC(bank,portnum,SNum,page,&temp_buff[0],&extra[0]))
            {
               if(extra[0] == 0xFF)
         		   return FALSE;
            }
      	}
      	else
      	{
            if(owHasPageAutoCRC(bank,SNum))
            {
          	   if(!owReadPageCRC(bank,portnum,SNum,page,&temp_buff[0]))
                  return FALSE;
            }
            else
            {
               if(!owReadPage(bank,portnum,SNum,page,FALSE,&temp_buff[0]))
  		            return FALSE;
            }
      				
         	extra[0] = 0xFF;
         }

         if(extra[0] != 0xFF)
         {
      	   rd_buf[0] = ~extra[0];
      		addpg = AddPage(portnum,SNum,*pg,&rd_buf[0],STATUSMEM);
      		*pg = (PAGE_TYPE) rd_buf[0];      
            continue;
         }
         else
         {
            *len = 8;
            for(i=0;i<*len;i++)
               buff[i] = temp_buff[i];
            addpg = AddPage(portnum,SNum,*pg,&buff[0],STATUSMEM);
//  		   	   AddPage(portnum,SNum,*pg,&buff[0],*len);
//               AddPage(portnum,SNum,*pg,&buff[0],0x41);
            return TRUE;

         }
      }
      // else call on the regular readpack function
      else 
      {          
         *len = 0;
      	if(owIsWriteOnce(bank,portnum,SNum) && owHasExtraInfo(bank,SNum))
      	{
      		if(!owReadPagePacketExtra(bank,portnum,SNum,page,FALSE,
         										&temp_buff[0],len,&extra[0]))
            {
               if(extra[0] == 0xFF)
         		   return FALSE;
            }
      	}
      	else
      	{
            if(owHasPageAutoCRC(bank,SNum))
            {
         	   if(!owReadPageCRC(bank,portnum,SNum,page,&temp_buff[0]))
                  return FALSE;
            }
            else
            {
               if(!owReadPage(bank,portnum,SNum,page,FALSE,&temp_buff[0]))
  		            return FALSE;
            }
      				
      		extra[0] = 0xFF;
         } 
            
         if(extra[0] != 0xFF)
         {
         	rd_buf[0] = ~extra[0];
      		addpg = AddPage(portnum,SNum,*pg,&rd_buf[0],REDIRMEM);
      		*pg = (PAGE_TYPE) rd_buf[0];  
            continue;
         }
         else
         {
            if(*len > 0)
            {
               if(*len > 32)
               {
                  OWERROR(OWERROR_INVALID_PACKET_LENGTH);
                  return FALSE;
               }

               for(i=0;i<(*len);i++)
                  buff[i] = temp_buff[i];
            }
            else
            {
               if(temp_buff[0] > 32)
               {
                  OWERROR(OWERROR_INVALID_PACKET_LENGTH);
                  return FALSE;
               }

     	     	   for(i=1;i<(temp_buff[0]+1);i++)
     	   		   buff[i-1] = temp_buff[i];
               *len = temp_buff[0];
            }

            addpg = AddPage(portnum,SNum,*pg,&buff[0],*len);
            return TRUE;
         }
    	}
   }         
   
   // could not find the page
   return FALSE;
}