⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udi2mtip.c

📁 gdb for adsp develop
💻 C
📖 第 1 页 / 共 5 页
字号:
    } else {      return (UDINoError);    }  } else {    *count_done = (UDISizeT) 0;    TotalDone = (UDIUInt32) 0;    Channel1_count = (UDISizeT) 0;    chan1_indx = 0;	/*	 * The HIF kernel from MiniMON29K release 2.1 expects MONTIP	 * to send a HIF_CALL_RTN response for a HIF_CALL message, and	 * a CHANNEL1_ACK response for a CHANNEL1 message, and 	 * a CHANNEL2_ACK response for a CHANNEL2 message, and	 * a CHANNEL0 message for a asynchronous input.	 * The HIF kernel version numbers 0x05 and above support these	 * features.	 */     if ((tip_target_config.os_version & 0xf) > 4) { /* new HIF kernel */       Mini_build_channel1_ack_msg(TotalDone); /* send gr96 value */       if (Mini_msg_send() != SUCCESS)         return ((-1) * MONErrCantSendMsg);     } else { /* old HIF kernel */       if ((UDIretval = Write_Glob_Reg(TotalDone, (int) 96)) != UDINoError)         return (UDIretval);       reg_val = (UDIUInt32) 0x80000000;       if ((UDIretval = Write_Glob_Reg(reg_val, (int) 121)) != UDINoError)         return (UDIretval);     }  }  if (StepCmdGiven) {    ProcessorState = UDIStepped;    PreviousProcessorState = UDIStepped;    StepCmdGiven = 0;  } else {      if (!BreaksInPlace) {	PutAllBreakpoints();	BreaksInPlace = 1;      }	/*	 * The HIF kernel from MiniMON29K release 2.1 expects MONTIP	 * to send a HIF_CALL_RTN response for a HIF_CALL message, and	 * a CHANNEL1_ACK response for a CHANNEL1 message, and 	 * a CHANNEL2_ACK response for a CHANNEL2 message, and	 * a CHANNEL0 message for a asynchronous input.	 * The HIF kernel version numbers 0x05 and above support these	 * features.	 */     if ((tip_target_config.os_version & 0xf) > 4) { /* new HIF kernel */       ProcessorState = (UDIUInt32) UDIRunning;       PreviousProcessorState = (UDIUInt32) UDIRunning;     } else { /* old HIF kernel */       UDIExecute();	/* sends a GO to the Debugger to start application */     }  }  return (UDINoError);}#ifdef	MSDOSUDIError OldHIFGetStderr( UDIHostMemPtr buf,UDISizeT bufsize,UDISizeT *count_done);#elseUDIError OldHIFGetStderr();#endifUDIError UDIGetStderr(buf, bufsize, count_done)  UDIHostMemPtr   buf;  UDISizeT          bufsize;  UDISizeT         *count_done;{  static int      chan2_indx = 0;  UDISizeT          mincount;  UDISizeT          i;  char           *temp;  if ((int) (ProcessorState & 0xFF) != (int) UDIStderrReady) {    *count_done = (UDISizeT) 0;    return (UDINoError);  };	/*	 * The HIF kernel from MiniMON29K release 2.1 expects MONTIP	 * to send a HIF_CALL_RTN response for a HIF_CALL message, and	 * a CHANNEL1_ACK response for a CHANNEL1 message, and 	 * a CHANNEL2_ACK response for a CHANNEL2 message, and	 * a CHANNEL0 message for a asynchronous input.	 * The HIF kernel version numbers 0x05 and above support these	 * features.	 */     if ((tip_target_config.os_version & 0xf) > 4) { /* new HIF kernel */	/*	 * From MiniMON29K release 2.1 all interactions with 	 * stdin, stdout, stderr by the application is handled without	 * invoking the Debugger on the target. Thus, a write to stderr	 * is implemented by a CHANNEL2 message similar to the CHANNEL1	 * message for stdout.	 */       temp = (char *) buf;	/* used for copying */       i = (UDISizeT) chan2_indx;       if (Channel2_count) {         mincount = (Channel2_count < (UDISizeT) bufsize) ? Channel2_count :	     (UDISizeT) bufsize;         for (i = 0; i < mincount; i++) {           (char) *temp++ = (char) channel2_buffer[chan2_indx];           chan2_indx = (chan2_indx + 1) % TIP_IO_BUFSIZE;/* circular buffer */         }         *count_done = (UDISizeT) mincount;         Channel2_count = Channel2_count - mincount;         TotalDone = TotalDone + (UDIUInt32) mincount;         if (Channel2_count <= (UDISizeT) 0) {            Mini_build_channel2_ack_msg(TotalDone); /* send gr96 value */            if (Mini_msg_send() != SUCCESS)              return ((-1) * MONErrCantSendMsg);            TotalDone = (UDIUInt32) 0;            Channel2_count = (UDISizeT) 0;            chan2_indx = 0;          } else {            return (UDINoError);          }       } else {          *count_done = (UDISizeT) 0;          TotalDone = (UDIUInt32) 0;          Channel2_count = (UDISizeT) 0;          chan2_indx = 0;          Mini_build_channel2_ack_msg(TotalDone); /* send gr96 value */          if (Mini_msg_send() != SUCCESS)            return ((-1) * MONErrCantSendMsg);      }      if (StepCmdGiven) {        ProcessorState = UDIStepped;        PreviousProcessorState = UDIStepped;        StepCmdGiven = 0;      } else {          if (!BreaksInPlace) {             PutAllBreakpoints();             BreaksInPlace = 1;          }        ProcessorState = (UDIUInt32) UDIRunning;        PreviousProcessorState = (UDIUInt32) UDIRunning;      }     } else { /* old HIF kernel code */	return (OldHIFGetStderr(buf, bufsize, count_done));     }	/* old kernel code */  return (UDINoError);}UDIErrorOldHIFGetStderr(buf, bufsize, count_done)  UDIHostMemPtr   buf;  UDISizeT          bufsize;  UDISizeT         *count_done;/* * For HIF kernel version 0x04 and lower. */{  UDIUInt32       count;  UDIUInt32       done;  UDIResource     from;  UDIBool         host_endian;  UDISizeT          size;  UDIError        UDIretval;  UDIUInt32       reg_val;       /* Lr4_count gives the bytes to be written */       /* Lr3_addr gives the address in the target */       if (Lr4_count > (UDIUInt32) 0) {         count = (Lr4_count < (UDIUInt32) bufsize) ? Lr4_count : (UDIUInt32) bufsize;         /* read count bytes from Lr3_addr */         from.Offset = Lr3_addr;         from.Space = UDI29KDRAMSpace;         size = 1;         host_endian = FALSE;         if ((UDIretval = UDIRead(from,			          buf,			          count,			          size,			          &done,			          host_endian)) != UDINoError) {           return (UDIretval);         }         *count_done = (UDISizeT) count;         Lr4_count = Lr4_count - count;         Lr3_addr = Lr3_addr + count;         TotalDone = TotalDone + (UDIUInt32) count;         if (Lr4_count <= (UDISizeT) 0) {             if ((UDIretval = Write_Glob_Reg(TotalDone, (int) 96)) != UDINoError)                  return (UDIretval);             reg_val = (UDIUInt32) 0x80000000;             if ((UDIretval = Write_Glob_Reg(reg_val, (int) 121)) != UDINoError)                  return (UDIretval);             TotalDone = (UDIUInt32) 0;	     Lr4_count = (UDIUInt32) 0;         } else {           return (UDINoError);         }       } else {         *count_done = (UDISizeT) 0;         TotalDone = (UDIUInt32) 0;         if ((UDIretval = Write_Glob_Reg(TotalDone, (int) 96)) != UDINoError)              return (UDIretval);         reg_val = (UDIUInt32) 0x80000000;         if ((UDIretval = Write_Glob_Reg(reg_val, (int) 121)) != UDINoError)              return (UDIretval);         Lr4_count = (UDIUInt32) 0;       };            /* Resume execution  UDIExecute()? */       if (StepCmdGiven) {         ProcessorState = UDIStepped;         PreviousProcessorState = UDIStepped;         StepCmdGiven = 0;       } else {           if (!BreaksInPlace) {	     PutAllBreakpoints();	     BreaksInPlace = 1;           }         UDIExecute();       }  return (UDINoError);}#ifdef MSDOSUDIError OldHIFPutStdin( UDIHostMemPtr buf,UDISizeT count,UDISizeT *count_done);#elseUDIError OldHIFPutStdin();#endifUDIError UDIPutStdin(buf, count, count_done)  UDIHostMemPtr   buf;  UDISizeT          count;  UDISizeT         *count_done;{     char	*CharPtr;     UINT32	MinCnt;     INT32	Code;     if ((tip_target_config.os_version & 0xf) > 0x6) { /* MiniMON29K 3.0 */       if ((int) (ProcessorState & 0xFF) != (int) UDIStdinNeeded) {           /* non-blocking mode asynchronous mode */	   /* 	    if asynchronous mode, we sent a channel0 message for	    every character sent by DFE in this call. 	    */	    if (PgmStdinMode & TIP_NBLOCK) {                if ((Code = Mini_msg_recv(NONBLOCK)) != FAILURE) {		   MsgAlreadyReceived=Code;		   MsgAlreadyInBuffer = 1;	       }                CharPtr = buf;	       if (!Channel0Busy) {	         /* send one character and return to DFE */	         Mini_build_channel0_msg(CharPtr, (INT32) 1);	         /*		  * Just send the message here, and wait for the ack later	         SEND_AND_WAIT_ACK(CHANNEL0_ACK);	         */	         if (Mini_msg_send() != SUCCESS) 		    return((-1) * MONErrCantSendMsg);#if 0	         Channel0Busy = 1;	/* never set */#endif	       } else {		 /* save it in channel0_buffer */	         channel0_buffer[Channel0_count] = (char) *CharPtr;	         Channel0_count=Channel0_count+1;	       }	       *count_done = (UDISizeT) 1;	       return (UDINoError);	    } else  if (PgmStdinMode & TIP_ASYNC) {               if ((Code = Mini_msg_recv(NONBLOCK)) != FAILURE) {		   MsgAlreadyReceived=Code;		   MsgAlreadyInBuffer = 1; /* check in UDIWait */	       }                CharPtr = buf;	       *count_done = (UDISizeT) 0;	       for ( ; count > 0; count--) {	            Mini_build_channel0_msg(CharPtr, (INT32) 1);	           /*		    * Just send the message here, and wait for the ack later	           SEND_AND_WAIT_ACK(CHANNEL0_ACK);	           */		    if (Mini_msg_send() != SUCCESS)		      return((-1)*MONErrCantSendMsg);	            *count_done = (UDISizeT) (*count_done + (UDISizeT) 1);	            CharPtr++;	       }    	       return (UDINoError);	    }       } else { /* synchronous mode */	  /*	   in synchronous mode, we send all the characters received using	   stdin_needed_ack_msg, when the processorstate becomes stdinneeded.	   This is line-buffered mode. So we clear variables	   after we send.	   What do we do when DFE sends more characters than we need now?	   The count_done return value gives number accepted. But who keeps	   the rest.	   Otherwise, what do we do???????	   */	  if (PgmStdinMode & TIP_NBLOCK) { 	     /* send one character and return to DFE */             CharPtr = buf;             if ((Code = Mini_msg_recv(NONBLOCK)) != FAILURE) {		   MsgAlreadyReceived=Code;		   MsgAlreadyInBuffer = 1;	     }	     *count_done = (UDISizeT) 1;	     Mini_build_channel0_msg(CharPtr, (INT32) 1);	     /*	      * Send the message now and wait for the ack later.	     SEND_AND_WAIT_ACK(CHANNEL0_ACK);	      */	     if (Mini_msg_send() != SUCCESS)	       return ((-1)*MONErrCantSendMsg);	     return (UDINoError);	  }; 	  MinCnt = ((UINT32) StdinCharsNeeded > (UINT32) count) ?		      (UINT32) count : (UINT32) StdinCharsNeeded;	  Mini_build_stdin_needed_ack_msg (MinCnt, buf);          if (Mini_msg_send() != SUCCESS)            return ((-1) * MONErrCantSendMsg);	  *count_done = (UDISizeT) MinCnt;	  StdinCharsNeeded = 0;		/* reset to zero ?? */          if (StepCmdGiven) {            ProcessorState = UDIStepped;            PreviousProcessorState = UDIStepped;            StepCmdGiven = 0;          } else {            if (!BreaksInPlace) {	      PutAllBreakpoints();	      BreaksInPlace = 1;            }	    ProcessorState = UDIRunning;	    PreviousProcessorState = UDIRunning;	  }	  return (UDINoError);       }     } else if ((tip_target_config.os_version & 0xf) > 4) { /* pre-release */	/*	 * The HIF kernel from MiniMON29K release 2.1 expects MONTIP	 * to send a HIF_CALL_RTN response for a HIF_CALL message, and	 * a CHANNEL1_ACK response for a CHANNEL1 message, and 	 * a CHANNEL2_ACK response for a CHANNEL2 message, and	 * a CHANNEL0 message for a asynchronous input.	 * The HIF kernel version numbers 0x05 and above support these	 * features.	 */       /* Send CHANNEL0 message depending on StdinMode. */       CharPtr = buf;       if (PgmStdinMode == TIP_COOKED) { /* default line buffered */	 /*	  * send a line of input using channel0 	  * Check for '\n' sent from DFE.	  */	  if ((int) *CharPtr == (int) 8) {/* backspace */	    Channel0_count=Channel0_count-1;	  } else if ((int) *CharPtr == (int) 127) {/* delete */	    Channel0_count=Channel0_count-1;#ifdef MSDOS	  } else if ((int) *CharPtr == (int) 10) {/* \n */	    /* simply return, no change. already padded. */	    *count_done = count;	    return (UDINoError);	  } else if ((int) *CharPtr == (int) 13) {/* end of line */	    channel0_buffer[Channel0_count] = (char) *CharPtr;	    Channel0_count=Channel0_count+1;	    channel0_buffer[Channel0_count] = (char) 10; /* add \n */	    Channel0_count=Channel0_count+1;	    Mini_build_channel0_msg(channel0_buffer, Channel0_count);	    SEND_AND_WAIT_ACK(CHANNEL0_ACK);	    Channel0_count = 0;	/* reset */	    *count_done = count;#else	/* MSDOS */	  } else if ((int) *CharPtr == (int) 13) {/* end of line */	    /* simply return, added on \n */	    *count_done = count;	    return (UDINoError);	  } else if ((int) *CharPtr == (int) 10) {/* \n */	    channel0_buffer[Channel0_count] = (char) 13; /* add \r */	    Channel0_count=Channel0_count+1;	    channel0_buffer[Channel0_count] = (char) *CharPtr;	    Channel0_count=Channel0_count+1;	    Mini_build_channel0_msg(channel0_buffer, Channel0_count);	    SEND_AND_WAIT_ACK(CHANNEL0_ACK);	    Channel0_count = 0;	/* reset */#endif /* MSDOS */	  } else { /* store it in buffer here */	    channel0_buffer[Channel0_count] = (char) *CharPtr;	    Channel0_count=Channel0_count+1;	    *count_done = count;	  }	  return (UDINoError);       } else if (PgmStdinMode == TIP_RAW) { /* for other modes of input */	    channel0_buffer[Channel0_count] = (char) *CharPtr;	    Channel0_count=Channel0_count+1;	    Mini_build_channel0_msg(channel0_buffer, Channel0_count);	    SEND_AND_WAIT_ACK(CHANNEL0_ACK);	    Channel0_count = 0;	/* reset */	    *count_done = count;	    return (UDINoError);       } else { /* for other modes of input */	 /* NOT IMPLEMENTED */	    return (UDINoError);       }     } else { /* old HIF kernel */       return(OldHIFPutStdin(buf, count, count_done));     }}UDIErrorOldHIFPutStdin(buf, count, count_done)  UDIHostMemPtr   buf;  UDISizeT          count;  UDISizeT         *count_d

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -