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

📄 udi2mtip.c

📁 gdb for adsp develop
💻 C
📖 第 1 页 / 共 5 页
字号:
  int             Lrnum;  int             j;  UDIResource     temp_from;  UDICount        temp_done;  UDIUInt32       start_offset,                  end_offset;  BYTE           *reg_data;  CLEAR_PENDING_STOP  if (count <= (UDICount) 0) {    *count_done = (UDICount) 0;    return (UDINoError);  }  if (space == (INT32) VERSION_SPACE) {	/* minimon ver cmd */    Version = (INT32 *) to;    *Version = (INT32) tip_target_config.version;     *(Version+1) = (INT32) tip_target_config.os_version;     /*  TIPVERSION must be 11 chars or less  */    strcpy((char *) (Version+2),TIPVERSION);     /*  TIPDATE must be 11 chars or less  */    strcpy((char *) (Version+5),TIPDATE);     /* max msg size */    *(Version + 8) = tip_target_config.max_msg_size;    /* max bkpts */    *(Version + 9) = tip_target_config.max_bkpts;    if ((host_endian) && (tip_target_config.TipEndian != tip_target_config.P29KEndian)) {      output = (BYTE *) to;      for (i = 0; i < count; i++) {        if (size == 4)	  tip_convert32(output);        else if (size == 2)	  tip_convert16(output);        output = output + size;      }    }	/* hostendian */    *count_done = (UDICount) count;    return (UDINoError);  };  if (space < (INT32) 0) {    *count_done = (UDICount) 0;    return (UDIErrorUnknownResourceSpace);  }  output = (BYTE *) to;  switch (from.Space) {   case UDI29KPC:    from.Offset = 1;	/* PC1 */    break;   case UDI29KGlobalRegs:    break;   case UDI29KRealRegs:    /* REAL REGS BEGIN */    /* get global and local reg values from target if target exec'ed */    if (RefreshRegs) {      RefreshRegs = 0;	/* reset */      temp_from.Offset = (CPUOffset) 0;      temp_from.Space = UDI29KGlobalRegs;      if ((UDIretval = UDIRead(temp_from,			       (UDIHostMemPtr) &Glob_Regs[0],			       (UDICount) 2,			       (UDISizeT) 4,			       (UDICount *) &temp_done,			       (UDIBool) TRUE)) != UDINoError)	/* gr0, gr1 */	return (UDIretval);      /* UDIRead ();  gr64 to gr 127 */      temp_from.Offset = (CPUOffset) 64;      temp_from.Space = UDI29KGlobalRegs;      if ((UDIretval = UDIRead(temp_from,			       (UDIHostMemPtr) &Glob_Regs[64],			       (UDICount) 64,			       (UDISizeT) 4,			       (UDICount *) &temp_done,			       (UDIBool) TRUE)) != UDINoError)	/* gr0, gr1 */	return (UDIretval);      /* UDIRead ();   lr0 to lr127 */      temp_from.Offset = (CPUOffset) 0;      temp_from.Space = UDI29KLocalRegs;      if ((UDIretval = UDIRead(temp_from,			       (UDIHostMemPtr) &Loc_Regs[0],			       (UDICount) 128,			       (UDISizeT) 4,			       (UDICount *) &temp_done,			       (UDIBool) TRUE)) != UDINoError)	/* gr0, gr1 */	return (UDIretval);    };    start_offset = from.Offset;    end_offset = start_offset + count;    output = (BYTE *) to;    while (start_offset < end_offset) {	/* do only if count is non zero */      if (start_offset <= (UDIUInt32) 127) {	reg_data = (BYTE *) &Glob_Regs[(int) start_offset];	for (j = 0; j < 4 /* sizeof (UDIUInt32) */ ; j++)	  *output++ = *reg_data++;      } else if ((start_offset >= (UDIUInt32) 128) && (start_offset <= (UDIUInt32) 255)) {	Gr1_val = (int) (Glob_Regs[1] & 0x000001FC) >> 2;	/* bits 2 to 8 */	Lrnum = (int) ((int) start_offset - Gr1_val) % 128;	reg_data = (BYTE *) & Loc_Regs[(int) Lrnum];	for (j = 0; j < 4 /* sizeof (UDIUInt32) */ ; j++)	  *output++ = *reg_data++;      } else	return (UDIErrorUnknownResourceSpace);      start_offset = start_offset + (UDIUInt32) 1;    }	/* end while */    *count_done = (UDICount) count;    return (UDINoError);    /* REAL REGS END */   default:    break;  }  output = (BYTE *) to;  if ( (RemoteTarget == 0) &&	((from.Space == UDI29KDRAMSpace) ||	 (from.Space == UDI29KIRAMSpace) ||	 (from.Space == UDI29KIROMSpace))) { /* shared memory board */      Mini_read_memory(space, from.Offset, count * size, (BYTE *) output);  } else {     /* overhead = checksum + header + size rounding + bfr rounding + ? */     overhead = 32;     ttl_count = count;     output = (BYTE *) to;     while (ttl_count > 0) {	       /* Check for user interrupt */       if (StopFlag) {          STOP_SIG_HDLR          ProcessorState = (UDIUInt32) UDIStopped;          PreviousProcessorState = (UDIUInt32) UDIStopped;          return (UDIErrorAborted);       };        /* Check possible buffer overflow */       if ((ttl_count * size) + overhead > #ifdef MSDOS		   tip_target_config.max_msg_size) {         msg_count = (tip_target_config.max_msg_size-overhead) >> (size >> 1);  #else		   (INT32) 256) { /* SunOS has problems with higher numbers */         msg_count = (256 - overhead) >> (size >> 1);  #endif         ttl_count = ttl_count - msg_count;       } else {         msg_count = ttl_count;         ttl_count = ttl_count - msg_count;       }       Mini_build_read_req_msg(space, (ADDR32) from.Offset, msg_count, size);       SEND_AND_WAIT_ACK(READ_ACK);       if (ReturnedError == (int) 1) {	 ReturnedError = 0;	 return ((-1) * MONErrErrorRead);       }       Mini_unpack_read_ack_msg((INT32 *) &ack_space, (ADDR32 *) &ack_addr,			     (INT32 *) &done, (BYTE *) output);       output = output + (msg_count * size);       if (ISMEM(space))          from.Offset = from.Offset + (CPUOffset) (msg_count * size);       else          from.Offset = from.Offset + (CPUOffset) msg_count;     }  } /* end while */  if ((host_endian) && 	(tip_target_config.TipEndian != tip_target_config.P29KEndian)) {    output = (BYTE *) to;    for (i = 0; i < count; i++) {      if (size == 4)	tip_convert32(output);      else if (size == 2)	tip_convert16(output);      output = output + size;    }  }	/* hostendian */  *count_done = (UDICount) count;  return (UDINoError);}UDIError UDIWrite(from, to, count, size, count_done, HostEndian)  UDIHostMemPtr   from;  UDIResource     to;  UDICount        count;  UDISizeT          size;  UDICount       *count_done;  UDIBool         HostEndian;{  INT32           space = SpaceMap_udi2mm(to.Space);  INT32           done;  INT32           ttl_count;  INT32           msg_count;  INT32           overhead;  ADDR32          ack_addr;  INT32		  ack_space;  BYTE           *input;  UDIError        UDIretval;  UDIUInt32       tmpbuf[2];  UDICount		i;  /* REAL REGS BEGIN */  UDIResource     temp_to;  UDICount        temp_done;  CPUOffset       start_offset,                  end_offset;  UDIUInt32       Gr1_val;  /* REAL REGS END */  CLEAR_PENDING_STOP  if (space < (INT32) 0) {    *count_done = (UDICount) 0;    return (UDIErrorUnknownResourceSpace);  }  if (count <= (UDICount) 0) {    *count_done = (UDICount) 0;    return (UDINoError);  }  if (to.Space == UDI29KPC) {    /* when writing UDI29KPC, set both PC1 and PC0 */    /* NOTE: this assumes we are not in freeze mode */    /* this must all be done before doing the endian conversion below */    to.Offset = 0;	/* start at PC0 */    count = (UDIInt32) 2;	/* writing 2 4-byte quantities */    tmpbuf[1] = *((UDIUInt32 *) from);	/* PC1 = PC */    if (!HostEndian && (tip_target_config.TipEndian != tip_target_config.P29KEndian)) {	tmpbuf[0] = tmpbuf[1];	tip_convert32((BYTE *) &tmpbuf[0]);        tmpbuf[0] = tmpbuf[0] + 4;	/* PC0 = PC + 4 */	tip_convert32((BYTE *) &tmpbuf[0]);    } else {        tmpbuf[0] = tmpbuf[1] + 4;	/* PC0 = PC + 4 */    }    from = (UDIHostMemPtr) tmpbuf;	/* set pointer to temporary (8-byte)					 * buffer */  }  switch (to.Space) {   case UDI29KLocalRegs:    RefreshRegs = 1;    break;   case UDI29KPC:	/* PC causes special regs(PC0,PC1) space */    break;   case UDI29KGlobalRegs:    RefreshRegs = 1;    break;   case UDI29KRealRegs:    RefreshRegs = 1;    /* REAL REGS BEGIN */    start_offset = to.Offset;    end_offset = start_offset + count - 1;    if ((end_offset <= 127)) {	/* all globals asked */      temp_to.Offset = to.Offset;      temp_to.Space = UDI29KGlobalRegs;      if ((UDIretval = UDIWrite(from,				temp_to,				count,				size,				&temp_done,				HostEndian)) != UDINoError)	return (UDIretval);    } else if (start_offset > 127) {	/* all local regs */      /* read gr1 */      temp_to.Offset = (CPUOffset) 1;      temp_to.Space = UDI29KGlobalRegs;      if ((UDIretval = UDIRead(temp_to,			       (UDIHostMemPtr) &Gr1_val,			       (UDICount) 1,			       (UDISizeT) 4,			       (UDICount *) &temp_done,			       (UDIBool) TRUE)) != UDINoError)	/* gr1 */	return (UDIretval);      /* recompute start_offset and end_offset */      Gr1_val = (Gr1_val & 0x01FC) >> 2;      start_offset = (start_offset - Gr1_val) % 128;      end_offset = (end_offset - Gr1_val) % 128;      input = (BYTE *) from;      if (start_offset > end_offset) {	/* wrap around */	temp_to.Offset = start_offset;	temp_to.Space = UDI29KLocalRegs;	if ((UDIretval = UDIWrite(input,				  temp_to,				  (UDICount) (128 - start_offset),				  size,				  &temp_done,				  HostEndian)) != UDINoError)	  return (UDIretval);	input = input + (int) ((128 - start_offset) * size);	temp_to.Offset = (CPUOffset) 0;	/* from LR0 */	temp_to.Space = UDI29KLocalRegs;	if ((UDIretval = UDIWrite(input,				  temp_to,				  (UDICount) (end_offset + 1 ),				  size,				  &temp_done,				  HostEndian)) != UDINoError)	  return (UDIretval);      } else {	/* no wrapping */	temp_to.Offset = start_offset;	temp_to.Space = UDI29KLocalRegs;	if ((UDIretval = UDIWrite(input,				  temp_to,				  count,				  size,				  &temp_done,				  HostEndian)) != UDINoError)	  return (UDIretval);      }    } else {	/* overlap */      input = (BYTE *) from;      /* write globals */      temp_to.Offset = start_offset;      temp_to.Space = UDI29KGlobalRegs;      if ((UDIretval = UDIWrite(input,				temp_to,				((UDICount) 128 - (UDICount) start_offset),				size,				&temp_done,				HostEndian)) != UDINoError)	return (UDIretval);      input = input + (int) (size) * ((UDICount) 128 - (UDICount) start_offset);      /* write locals */      temp_to.Offset = (CPUOffset) 128;      temp_to.Space = UDI29KRealRegs;      if ((UDIretval = UDIWrite(input,				temp_to,				(UDICount) (count - 128 + start_offset),				size,				&temp_done,				HostEndian)) != UDINoError)	return (UDIretval);    }    *count_done = (UDICount) count;    return (UDINoError);    /* REAL REGS END */   default:    break;  }  if (HostEndian && 	      (tip_target_config.TipEndian != tip_target_config.P29KEndian)) {    input = (BYTE *) from;    for (i = 0; i < count; i++) {      if (size == 4)	tip_convert32(input);      else if (size == 2)	tip_convert16(input);      input = input + size;    }  }; /* endian conversion done */  input = (BYTE *) from;  if ((RemoteTarget == 0) &&	((to.Space == UDI29KDRAMSpace) ||	 (to.Space == UDI29KIRAMSpace) ||	 (to.Space == UDI29KIROMSpace))) {      Mini_write_memory(space, to.Offset, count * size, (BYTE *) input);      *count_done = (UDICount) count;      return (UDINoError);  } else {  /* remote */     /* overhead = checksum + header + size rounding + bfr rounding + ? */     overhead = 32;     ttl_count = count;     input = (BYTE *) from;     while (ttl_count > 0) {	       /* Check for user interrupt */       if (StopFlag) {          STOP_SIG_HDLR          ProcessorState = (UDIUInt32) UDIStopped;          PreviousProcessorState = (UDIUInt32) UDIStopped;          return (UDIErrorAborted);       };        /* Check possible buffer overflow */       if ((ttl_count * size) + overhead > 		   tip_target_config.max_msg_size) {         msg_count = (tip_target_config.max_msg_size-overhead) >> (size >> 1);           ttl_count = ttl_count - msg_count;       } else {         msg_count = ttl_count;         ttl_count = ttl_count - msg_count;       }       Mini_build_write_req_msg(space, (ADDR32) to.Offset,			      msg_count, size, (BYTE *) input);       SEND_AND_WAIT_ACK(WRITE_ACK);       if (ReturnedError == (int) 1) {	 ReturnedError = 0;	 return ((-1) * MONErrErrorWrite);       }       Mini_unpack_write_ack_msg((INT32 *) &ack_space,			      (ADDR32 *) &ack_addr,			      (INT32 *) &done);       input = input + (msg_count * size);       if (ISMEM(space))          to.Offset = to.Offset + (CPUOffset) (msg_count * size);       else          to.Offset = to.Offset + (CPUOffset) msg_count;     }	/* while */  } /* end remote */  *count_done = (to.Space == UDI29KPC) ? (UDICount) 1 : (UDICount) count;  return (UDINoError);}UDIError UDICopy(from, to, count, size, count_done, direction)  UDIResource     from;  UDIResource     to;  UDICount        count;  UDISizeT          size;  UDICount       *count_done;  UDIBool         direction;{  INT32           f_space = SpaceMap_udi2mm(from.Space);  INT32           t_space = SpaceMap_udi2mm(to.Space);

⌨️ 快捷键说明

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