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

📄 udi2mtip.c

📁 gdb for adsp develop
💻 C
📖 第 1 页 / 共 5 页
字号:
  UDICount	  counter, maxcount,curcount;  INT32	  	fill_count, fill_size;    INT32           done;  ADDR32          ack_saddr,                  ack_daddr;  CLEAR_PENDING_STOP  if ((t_space < 0) || (f_space < 0)) {    *count_done = (UDICount) 0;    return (UDIErrorUnknownResourceSpace);  }  if (count <= (UDICount) 0) {    *count_done = (UDICount) 0;    return (UDINoError);  }  RefreshRegs = 1;  /* Split the copy to smaller copies based on the message size */  maxcount = (UDICount) (tip_target_config.max_msg_size / size);  counter = (UDICount) count;  while (counter > (UDICount) 0) {    /* Check for user interrupt */    if (StopFlag) {       STOP_SIG_HDLR       ProcessorState = (UDIUInt32) UDIStopped;       PreviousProcessorState = (UDIUInt32) UDIStopped;       return (UDIErrorAborted);    };     curcount = (maxcount < counter) ? maxcount : counter;    counter = counter - curcount;    if ((size > (UDISizeT) 4) && (t_space == (INT32) I_MEM)) {        /* reduce it to  4, must be a multiple also for I_MEM */       fill_count = (INT32) (curcount * (size/4));       fill_size = (INT32) size;    } else if ((size > (UDISizeT) 4) && (t_space != (INT32) I_MEM)) {        /* copy as bytes */       fill_count = (INT32) (curcount * size);       fill_size = (INT32) 1; /* bytes */    } else {       fill_count = (INT32) curcount;       fill_size = (INT32) size;    };    Mini_build_copy_msg(f_space, (ADDR32) from.Offset,		      t_space, (ADDR32) to.Offset,		      fill_count, fill_size);    SEND_AND_WAIT_ACK(COPY_ACK);    if (ReturnedError == (int) 1) {      ReturnedError = 0;      return ((-1) * MONErrErrorCopy);    }    Mini_unpack_copy_ack_msg(&f_space, &ack_saddr,			   &t_space, &ack_daddr, &done);    from.Offset = from.Offset + (CPUOffset) (curcount * size);    to.Offset = to.Offset + (CPUOffset) (curcount * size);  }; /* end while */  *count_done = (UDICount) count;  return (UDINoError);}UDIError UDIExecute(){  INT32           MsgCode;    CLEAR_PENDING_STOP  if (!NoStepReqd) {    if (!StepCmdGiven) {      /* Execute one instruction */      Mini_build_step_msg((INT32) 1);      if (Mini_msg_send() != SUCCESS)	return ((-1) * MONErrCantSendMsg);      /* process message received from target */      MsgCode = Wait_For_Ack();      if (MsgCode == ABORT_FAILURE)	return (UDIErrorAborted);      else if (MsgCode == FAILURE)	return ((-1) * MONErrNoAck);      process_target_msg(MsgCode);      /* if processor state is stepped, set breakpoints, issue a GO */      if (ProcessorState != (UDIUInt32) UDIStepped) {	RefreshRegs = 1;	return (UDINoError);      }      PutAllBreakpoints();      BreaksInPlace = 1;    }  }  Mini_build_go_msg();  if (Mini_msg_send() != SUCCESS)    return ((-1) * MONErrCantSendMsg);  RefreshRegs = 1;  ProcessorState = (UDIUInt32) UDIRunning;  PreviousProcessorState = (UDIUInt32) UDIRunning;  return (UDINoError);}/* * Stepping will NOT cause any breakpoints to be installed. It will step the * number requested. */UDIError UDIStep(steps, steptype, range)  UDIUInt32       steps;  UDIStepType     steptype;  UDIRange        range;{  CLEAR_PENDING_STOP  if (steps == (UDIUInt32) 0)    return (UDINoError);  if ((steptype & UDIStepOverCalls) || (steptype & UDIStepOverTraps) ||       (steptype & UDIStepInRange))       return (UDIErrorUnsupportedStepType);  StepCmdGiven = 1;  Mini_build_step_msg(steps);  if (Mini_msg_send() != SUCCESS)    return ((-1) * MONErrCantSendMsg);  RefreshRegs = 1;  ProcessorState = (UDIUInt32) UDIRunning;  PreviousProcessorState = (UDIUInt32) UDIRunning;  return (UDINoError);}UDIVoid UDIStop(){  int	GrossState;  GrossState = (int) (ProcessorState & 0xFF);  if ((GrossState == UDINotExecuting) || (GrossState == UDIRunning) ||      (GrossState == UDIStdoutReady) || (GrossState == UDIStderrReady) ||      (GrossState == UDIStdinNeeded) ) {      StopFlag = 1; /* This will be reset after its handled */  }  /* Else ignored */  return; }UDIError UDIWait(maxtime, pid, stop_reason)  UDIInt32        maxtime;  UDIPId         *pid;  UDIUInt32      *stop_reason;{  INT32           MsgCode;  *pid = (UDIPId) CurrentPID;  if (ProcessorState == (UDIUInt32) UDIRunning) {    while (1) { /* handle messages as long as they are coming */      if (MsgAlreadyInBuffer==1) {	MsgCode = MsgAlreadyReceived;	MsgAlreadyInBuffer=0;      } else {        MsgCode = CheckForMsg(maxtime);      }#if 0      MsgCode = CheckForMsg(maxtime);#endif      if ((MsgCode == FAILURE) || (MsgCode == ABORT_FAILURE)) { /* no news */        *stop_reason = ProcessorState;	        return (UDINoError);      } else {	/* a message from target has arrived */        *stop_reason = ProcessorState;	if (MsgCode == CHANNEL0_ACK) {	   process_chan0_ack();	   return (UDINoError);	}        (void) process_target_msg(MsgCode);        if (ProcessorState != (UDIUInt32) UDIRunning)           return (UDINoError);      };    }  } else {    *stop_reason = ProcessorState;    return (UDINoError);  }}UDIError UDISetBreakpoint(addr, pass_count, bk_type, break_id)  UDIResource     addr;  UDIInt32        pass_count;  UDIBreakType    bk_type;  BreakIdType    *break_id;{  INT32           space = SpaceMap_udi2mm(addr.Space);  ADDR32          ack_addr;  INT32           set_count,                  set_type;  BreakIdType     newid;  UDIUInt32       BreakInst;	/* EB29K */  UDIError        UDIretval;	/* EB29K */  CLEAR_PENDING_STOP  if (space < 0)    return (UDIErrorUnknownResourceSpace);  /*   * Minimon currently supports only two types of breakpoints * BKPT_29000   * and BKPT_29050 *   */  if (bk_type & MONBreakFlagHardware) {    if (bk_type & MONBreakTranslationEnabled)      bk_type = BKPT_29050_BTE_1;    else      bk_type = BKPT_29050_BTE_0;	/* default */  } else if ((bk_type & UDIBreakFlagRead) || (bk_type & UDIBreakFlagWrite))    return ((-1) * MONErrUnknownBreakType);  else if (bk_type & UDIBreakFlagExecute)    bk_type = BKPT_29000;	/* Minimon uses this */  if (pass_count == (UDIInt32) 0)     pass_count = (UDIInt32) -1; /* make it temporary */  Mini_build_bkpt_set_msg(space,			  (ADDR32) addr.Offset,			  (INT32) pass_count,			  (INT32) bk_type);  SEND_AND_WAIT_ACK (BKPT_SET_ACK);  if (ReturnedError == (int) 1) {    ReturnedError = 0;    return ((-1) * MONErrErrorSetBreak);  }  Mini_unpack_bkpt_set_ack_msg((INT32 *) &space,			       (ADDR32 *) &ack_addr,			       (INT32 *) &set_count,			       (INT32 *) &set_type);  BreakInst = (ADDR32) - 1;  if (!strcmp(TargetType, "eb29k")) {	/* For EB29K */    /* UDIRead(); read instruction */    if ((UDIretval = UDIRead(addr,			     (UDIHostMemPtr) &BreakInst,			     (UDICount) 4,			     (UDISizeT) 1,			     (UDICount *) &ack_addr,			     (UDIBool) FALSE)) != UDINoError)	/* 29K endian */      return (UDIretval);  };  add_to_bp_table(&newid, space, addr.Offset, set_count, set_type, BreakInst);  *break_id = (BreakIdType) newid;  LastBreakId = newid + 1;	/* ??? */  return (UDINoError);}UDIError UDIQueryBreakpoint(break_id, addr, pass_count,		   bk_type, current_count)  BreakIdType     break_id;  UDIResource    *addr;  UDIInt32       *pass_count;  UDIBreakType   *bk_type;  UDIInt32       *current_count;{  INT32           space;  ADDR32          offset;  INT32           pcount;  INT32           type;  INT32           ccount;  ADDR32          Inst;  CLEAR_PENDING_STOP  if (break_id >= LastBreakId)    return (UDIErrorNoMoreBreakIds);  if (get_from_bp_table(break_id, &space, &offset, &pcount, &type, &Inst) != 0)    return (UDIErrorInvalidBreakId);  Mini_build_bkpt_stat_msg(space, offset);  SEND_AND_WAIT_ACK (BKPT_STAT_ACK);  if (ReturnedError == (int) 1) {    ReturnedError = 0;    return ((-1) * MONErrErrorStatBreak);  }  Mini_unpack_bkpt_stat_ack_msg((INT32 *) &space,				(ADDR32 *) &offset,				(INT32 *) &ccount,				(INT32 *) &type);  addr->Space = SpaceMap_mm2udi(space);  addr->Offset = (CPUOffset) offset;  *pass_count = (UDIInt32) pcount;  if (type == (INT32) BKPT_29000)    type = UDIBreakFlagExecute;  else if (type == BKPT_29050_BTE_0)    type = (MONBreakFlagHardware | UDIBreakFlagExecute);  else if (type == BKPT_29050_BTE_1)    type = (MONBreakTranslationEnabled | MONBreakFlagHardware | UDIBreakFlagExecute);  *bk_type = (UDIBreakType) type;  *current_count = (UDIInt32) ccount;  return (UDINoError);}UDIError UDIClearBreakpoint(break_id)  BreakIdType     break_id;{  INT32           space;  ADDR32          offset;  INT32           count;  INT32           type;  ADDR32          Inst;  UDIResource     addr;	/* EB29K */  UDIError        UDIretval;	/* EB29K */  CLEAR_PENDING_STOP  /* should bkpt be removed from linked list ?? */  if (get_from_bp_table(break_id, &space, &offset, &count, &type, &Inst) != 0)    return (UDIErrorInvalidBreakId);  Mini_build_bkpt_rm_msg(space, offset);  SEND_AND_WAIT_ACK (BKPT_RM_ACK);  if (ReturnedError == (int) 1) {    ReturnedError = 0;    return ((-1) * MONErrErrorRmBreak);  }  Mini_unpack_bkpt_rm_ack_msg(&space, &offset);  if (!strcmp(TargetType, "eb29k")) {	/* For EB29K */    /* Write back the original instruction * UDIWrite(Inst); */    addr.Offset = offset;    addr.Space = SpaceMap_mm2udi(space);    if ((UDIretval = UDIWrite((UDIHostMemPtr) &Inst,			      addr,			      (UDICount) 4,			      (UDISizeT) 1,			      &offset,			      FALSE)) != UDINoError)      return (UDIretval);  };  remove_from_bp_table(break_id);  return (UDINoError);}UDIError UDIGetStdout(buf, bufsize, count_done)  UDIHostMemPtr   buf;  UDISizeT          bufsize;  UDISizeT         *count_done;{  static int      chan1_indx = 0;  UDISizeT          mincount;  UDISizeT          i;  char           *temp;  UDIUInt32	  reg_val;  UDIError	  UDIretval;  if ((int) (ProcessorState & 0xFF) != (int) UDIStdoutReady) {     *count_done = (UDISizeT) 0;      return (UDINoError);  };  temp = (char *) buf;	/* used for copying */  i = (UDISizeT) chan1_indx;  if (Channel1_count) {    mincount = (Channel1_count < (UDISizeT) bufsize) ? Channel1_count :	(UDISizeT) bufsize;    for (i = 0; i < mincount; i++) {      (char) *temp++ = (char) channel1_buffer[chan1_indx];      chan1_indx = (chan1_indx + 1) % TIP_IO_BUFSIZE;	/* circular buffer */    }    *count_done = (UDISizeT) mincount;    Channel1_count = Channel1_count - mincount;    TotalDone = TotalDone + (UDIUInt32) mincount;    if (Channel1_count <= (UDISizeT) 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 */       if (!NoChan1Ack) {          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);     }      TotalDone = (UDIUInt32) 0;      Channel1_count = (UDISizeT) 0;      chan1_indx = 0;

⌨️ 快捷键说明

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