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

📄 armrdi.c

📁 这个是LINUX下的GDB调度工具的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
  if (!state->CanWatch)    return RDIError_UnimplementedMessage;  removewatch (address, type);  p = installwatch (address, type, datatype, bound);  if (datatype & Watch_AnyRead)    state->MemReadDebug++;  if (datatype & Watch_AnyWrite)    state->MemWriteDebug++;  *handle = (PointHandle) p;  TracePrint ((state, " returns %.8lx\n", *handle));  return RDIError_NoError;}/***************************************************************************\*                               RDI_clearwatch                              *\***************************************************************************/static intRDI_clearwatch (PointHandle handle){  TracePrint ((state, "RDI_clearwatch: address=%.8lx\n", handle));  {    WatchNode *p, **prevp = &WatchList;    for (; (p = *prevp) != NULL; prevp = &p->next)      if (p == (WatchNode *) handle)	break;    if (p == NULL)      return RDIError_NoSuchPoint;    deletewatchnode (prevp);    return RDIError_NoError;  }}/***************************************************************************\*                               RDI_execute                                 *\***************************************************************************/static intRDI_execute (PointHandle * handle){  TracePrint ((state, "RDI_execute\n"));  if (rdi_log & 4)    {      state->CallDebug++;      state->Debug = TRUE;    }  state->EndCondition = RDIError_NoError;  state->StopHandle = 0;  ARMul_DoProg (state);  *handle = state->StopHandle;  state->Reg[15] -= 8;		/* undo the pipeline */  if (rdi_log & 4)    {      state->CallDebug--;      state->Debug = FALSE;    }  return (state->EndCondition);}/***************************************************************************\*                                RDI_step                                   *\***************************************************************************/static intRDI_step (unsigned ninstr, PointHandle * handle){  TracePrint ((state, "RDI_step\n"));  if (ninstr != 1)    return RDIError_UnimplementedMessage;  if (rdi_log & 4)    {      state->CallDebug++;      state->Debug = TRUE;    }  state->EndCondition = RDIError_NoError;  state->StopHandle = 0;  ARMul_DoInstr (state);  *handle = state->StopHandle;  state->Reg[15] -= 8;		/* undo the pipeline */  if (rdi_log & 4)    {      state->CallDebug--;      state->Debug = FALSE;    }  return (state->EndCondition);}/***************************************************************************\*                               RDI_info                                    *\***************************************************************************/static intRDI_info (unsigned type, ARMword * arg1, ARMword * arg2){  switch (type)    {    case RDIInfo_Target:      TracePrint ((state, "RDI_Info_Target\n"));      /* Emulator, speed 10**5 IPS */      *arg1 = 5 | HIGHEST_RDI_LEVEL << 5 | LOWEST_RDI_LEVEL << 8;      *arg2 = 1298224434;      return RDIError_NoError;    case RDIInfo_Points:      {	ARMword n = RDIPointCapability_Comparison | RDIPointCapability_Range |	  RDIPointCapability_Mask | RDIPointCapability_Status;	TracePrint ((state, "RDI_Info_Points\n"));	if (state->CanWatch)	  n |= (Watch_AnyRead + Watch_AnyWrite) << 2;	*arg1 = n;	return RDIError_NoError;      }    case RDIInfo_Step:      TracePrint ((state, "RDI_Info_Step\n"));      *arg1 = RDIStep_Single;      return RDIError_NoError;    case RDIInfo_MMU:      TracePrint ((state, "RDI_Info_MMU\n"));      *arg1 = 1313820229;      return RDIError_NoError;    case RDISignal_Stop:      TracePrint ((state, "RDISignal_Stop\n"));      state->CallDebug++;      state->EndCondition = RDIError_UserInterrupt;      return RDIError_NoError;    case RDIVector_Catch:      TracePrint ((state, "RDIVector_Catch %.8lx\n", *arg1));      state->VectorCatch = (unsigned) *arg1;      return RDIError_NoError;    case RDISet_Cmdline:      TracePrint ((state, "RDI_Set_Cmdline %s\n", (char *) arg1));      state->CommandLine =	(char *) malloc ((unsigned) strlen ((char *) arg1) + 1);      (void) strcpy (state->CommandLine, (char *) arg1);      return RDIError_NoError;    case RDICycles:      TracePrint ((state, "RDI_Info_Cycles\n"));      arg1[0] = 0;      arg1[1] = state->NumInstrs;      arg1[2] = 0;      arg1[3] = state->NumScycles;      arg1[4] = 0;      arg1[5] = state->NumNcycles;      arg1[6] = 0;      arg1[7] = state->NumIcycles;      arg1[8] = 0;      arg1[9] = state->NumCcycles;      arg1[10] = 0;      arg1[11] = state->NumFcycles;      return RDIError_NoError;    case RDIErrorP:      *arg1 = ARMul_OSLastErrorP (state);      TracePrint ((state, "RDI_ErrorP returns %ld\n", *arg1));      return RDIError_NoError;    case RDIInfo_DescribeCoPro:      {	int cpnum = *(int *) arg1;	struct Dbg_CoProDesc *cpd = (struct Dbg_CoProDesc *) arg2;	int i;	unsigned char const *map = state->CPRegWords[cpnum];	if (map == NULL)	  return RDIError_UnknownCoPro;	for (i = 0; i < cpd->entries; i++)	  {	    unsigned r, w = cpd->regdesc[i].nbytes / sizeof (ARMword);	    for (r = cpd->regdesc[i].rmin; r <= cpd->regdesc[i].rmax; r++)	      if (map[r] != w)		return RDIError_BadCoProState;	  }	return RDIError_NoError;      }    case RDIInfo_RequestCoProDesc:      {	int cpnum = *(int *) arg1;	struct Dbg_CoProDesc *cpd = (struct Dbg_CoProDesc *) arg2;	int i = -1, lastw = -1, r;	unsigned char const *map;	if ((unsigned) cpnum >= 16)	  return RDIError_UnknownCoPro;	map = state->CPRegWords[cpnum];	if (map == NULL)	  return RDIError_UnknownCoPro;	for (r = 0; r < map[-1]; r++)	  {	    int words = map[r];	    if (words == lastw)	      cpd->regdesc[i].rmax = r;	    else	      {		if (++i >= cpd->entries)		  return RDIError_BufferFull;		cpd->regdesc[i].rmax = cpd->regdesc[i].rmin = r;		cpd->regdesc[i].nbytes = words * sizeof (ARMword);		cpd->regdesc[i].access =		  Dbg_Access_Readable + Dbg_Access_Writable;	      }	  }	cpd->entries = i + 1;	return RDIError_NoError;      }    case RDIInfo_Log:      *arg1 = (ARMword) rdi_log;      return RDIError_NoError;    case RDIInfo_SetLog:      rdi_log = (int) *arg1;      return RDIError_NoError;    case RDIInfo_CoPro:      return RDIError_NoError;    case RDIPointStatus_Watch:      {	WatchNode *p, *handle = (WatchNode *) * arg1;	for (p = WatchList; p != NULL; p = p->next)	  if (p == handle)	    {	      *arg1 = -1;	      *arg2 = 1;	      return RDIError_NoError;	    }	return RDIError_NoSuchPoint;      }    case RDIPointStatus_Break:      {	BreakNode *p, *handle = (BreakNode *) * arg1;	for (p = BreakList; p != NULL; p = p->next)	  if (p == handle)	    {	      *arg1 = -1;	      *arg2 = 1;	      return RDIError_NoError;	    }	return RDIError_NoSuchPoint;      }    case RDISet_RDILevel:      if (*arg1 < LOWEST_RDI_LEVEL || *arg1 > HIGHEST_RDI_LEVEL)	return RDIError_IncompatibleRDILevels;      MYrdi_level = *arg1;      return RDIError_NoError;    default:      return RDIError_UnimplementedMessage;    }}/***************************************************************************\* The emulator calls this routine at the beginning of every cycle when the  ** CallDebug flag is set.  The second parameter passed is the address of the ** currently executing instruction (i.e Program Counter - 8), the third      ** parameter is the instruction being executed.                              *\***************************************************************************/ARMwordARMul_Debug (ARMul_State * state, ARMword pc, ARMword instr){  if (state->EndCondition == RDIError_UserInterrupt)    {      TracePrint ((state, "User interrupt at %.8lx\n", pc));      state->CallDebug--;      state->Emulate = STOP;    }  else    {      BreakNode *p = BreakList;      for (; p != NULL; p = p->next)	{	  switch (p->type)	    {	    case RDIPoint_EQ:	      if (pc == p->address)		break;	      continue;	    case RDIPoint_GT:	      if (pc > p->address)		break;	      continue;	    case RDIPoint_GE:	      if (pc >= p->address)		break;	      continue;	    case RDIPoint_LT:	      if (pc < p->address)		break;	      continue;	    case RDIPoint_LE:	      if (pc <= p->address)		break;	      continue;	    case RDIPoint_IN:	      if (p->address <= pc && pc < p->address + p->bound)		break;	      continue;	    case RDIPoint_OUT:	      if (p->address > pc || pc >= p->address + p->bound)		break;	      continue;	    case RDIPoint_MASK:	      if ((pc & p->bound) == p->address)		break;	      continue;	    }	  /* found a match */	  TracePrint ((state, "Breakpoint reached at %.8lx\n", pc));	  state->EndCondition = RDIError_BreakpointReached;	  state->Emulate = STOP;	  state->StopHandle = (ARMword) p;	  break;	}    }  return instr;}voidARMul_CheckWatch (ARMul_State * state, ARMword addr, int access){  WatchNode *p;  for (p = WatchList; p != NULL; p = p->next)    if (p->datatype & access)      {	switch (p->type)	  {	  case RDIPoint_EQ:	    if (addr == p->address)	      break;	    continue;	  case RDIPoint_GT:	    if (addr > p->address)	      break;	    continue;	  case RDIPoint_GE:	    if (addr >= p->address)	      break;	    continue;	  case RDIPoint_LT:	    if (addr < p->address)	      break;	    continue;	  case RDIPoint_LE:	    if (addr <= p->address)	      break;	    continue;	  case RDIPoint_IN:	    if (p->address <= addr && addr < p->address + p->bound)	      break;	    continue;	  case RDIPoint_OUT:	    if (p->address > addr || addr >= p->address + p->bound)	      break;	    continue;	  case RDIPoint_MASK:	    if ((addr & p->bound) == p->address)	      break;	    continue;	  }	/* found a match */	TracePrint ((state, "Watchpoint at %.8lx accessed\n", addr));	state->EndCondition = RDIError_WatchpointAccessed;	state->Emulate = STOP;	state->StopHandle = (ARMword) p;	return;      }}static RDI_NameList const *RDI_cpunames (){  return (RDI_NameList const *) &processorconfig.count;}const struct RDIProcVec armul_rdi = {  "ARMUL",  RDI_open,  RDI_close,  RDI_read,  RDI_write,  RDI_CPUread,  RDI_CPUwrite,  RDI_CPread,  RDI_CPwrite,  RDI_setbreak,  RDI_clearbreak,  RDI_setwatch,  RDI_clearwatch,  RDI_execute,  RDI_step,  RDI_info,  0,				/*pointinq */  0,				/*addconfig */  0,				/*loadconfigdata */  0,				/*selectconfig */  0,				/*drivernames */  RDI_cpunames};

⌨️ 快捷键说明

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