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

📄 ppc-opc.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
  /* The SPR field in an XFX form instruction.  This is flipped--the     lower 5 bits are stored in the upper 5 and vice- versa.  */#define SPR (51)#define SPR_MASK (0x3ff << 11)  { 10, 11, insert_spr, extract_spr, 0 },  /* The BAT index number in an XFX form m[ft]ibat[lu] instruction.  */#define SPRBAT (52)#define SPRBAT_MASK (0x3 << 17)  { 2, 17, 0, 0, 0 },  /* The SPRG register number in an XFX form m[ft]sprg instruction.  */#define SPRG (53)#define SPRG_MASK (0x3 << 16)  { 2, 16, 0, 0, 0 },  /* The SR field in an X form instruction.  */#define SR (54)  { 4, 16, 0, 0, 0 },  /* The SV field in a POWER SC form instruction.  */#define SV (55)  { 14, 2, 0, 0, 0 },  /* The TBR field in an XFX form instruction.  This is like the SPR     field, but it is optional.  */#define TBR (56)  { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL },  /* The TO field in a D or X form instruction.  */#define TO (57)#define TO_MASK (0x1f << 21)  { 5, 21, 0, 0, 0 },  /* The U field in an X form instruction.  */#define U (58)  { 4, 12, 0, 0, 0 },  /* The UI field in a D form instruction.  */#define UI (59)  { 16, 0, 0, 0, 0 },};/* The functions used to insert and extract complicated operands.  *//* The BA field in an XL form instruction when it must be the same as   the BT field in the same instruction.  This operand is marked FAKE.   The insertion function just copies the BT field into the BA field,   and the extraction function just checks that the fields are the   same.  *//*ARGSUSED*/static unsigned long insert_bat (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  return insn | (((insn >> 21) & 0x1f) << 16);}static longextract_bat (insn, invalid)     unsigned long insn;     int *invalid;{  if (invalid != (int *) NULL      && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))    *invalid = 1;  return 0;}/* The BB field in an XL form instruction when it must be the same as   the BA field in the same instruction.  This operand is marked FAKE.   The insertion function just copies the BA field into the BB field,   and the extraction function just checks that the fields are the   same.  *//*ARGSUSED*/static unsigned longinsert_bba (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  return insn | (((insn >> 16) & 0x1f) << 11);}static longextract_bba (insn, invalid)     unsigned long insn;     int *invalid;{  if (invalid != (int *) NULL      && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))    *invalid = 1;  return 0;}/* The BD field in a B form instruction.  The lower two bits are   forced to zero.  *//*ARGSUSED*/static unsigned longinsert_bd (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_bd (insn, invalid)     unsigned long insn;     int *invalid;{  if ((insn & 0x8000) != 0)    return (insn & 0xfffc) - 0x10000;  else    return insn & 0xfffc;}/* The BD field in a B form instruction when the - modifier is used.   This modifier means that the branch is not expected to be taken.   We must set the y bit of the BO field to 1 if the offset is   negative.  When extracting, we require that the y bit be 1 and that   the offset be positive, since if the y bit is 0 we just want to   print the normal form of the instruction.  *//*ARGSUSED*/static unsigned longinsert_bdm (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  if ((value & 0x8000) != 0)    insn |= 1 << 21;  return insn | (value & 0xfffc);}static longextract_bdm (insn, invalid)     unsigned long insn;     int *invalid;{  if (invalid != (int *) NULL      && ((insn & (1 << 21)) == 0	  || (insn & (1 << 15)) == 0))    *invalid = 1;  if ((insn & 0x8000) != 0)    return (insn & 0xfffc) - 0x10000;  else    return insn & 0xfffc;}/* The BD field in a B form instruction when the + modifier is used.   This is like BDM, above, except that the branch is expected to be   taken.  *//*ARGSUSED*/static unsigned longinsert_bdp (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  if ((value & 0x8000) == 0)    insn |= 1 << 21;  return insn | (value & 0xfffc);}static longextract_bdp (insn, invalid)     unsigned long insn;     int *invalid;{  if (invalid != (int *) NULL      && ((insn & (1 << 21)) == 0	  || (insn & (1 << 15)) != 0))    *invalid = 1;  if ((insn & 0x8000) != 0)    return (insn & 0xfffc) - 0x10000;  else    return insn & 0xfffc;}/* Check for legal values of a BO field.  */static intvalid_bo (long value){  /* Certain encodings have bits that are required to be zero.  These     are (z must be zero, y may be anything):         001zy	 011zy	 1z00y	 1z01y	 1z1zz     */  switch (value & 0x14)    {    default:    case 0:      return 1;    case 0x4:      return (value & 0x2) == 0;    case 0x10:      return (value & 0x8) == 0;    case 0x14:      return value == 0x14;    }}/* The BO field in a B form instruction.  Warn about attempts to set   the field to an illegal value.  */static unsigned longinsert_bo (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  if (errmsg != (const char **) NULL      && ! valid_bo (value))    *errmsg = "invalid conditional option";  return insn | ((value & 0x1f) << 21);}static longextract_bo (insn, invalid)     unsigned long insn;     int *invalid;{  long value;  value = (insn >> 21) & 0x1f;  if (invalid != (int *) NULL      && ! valid_bo (value))    *invalid = 1;  return value;}/* The BO field in a B form instruction when the + or - modifier is   used.  This is like the BO field, but it must be even.  When   extracting it, we force it to be even.  */static unsigned longinsert_boe (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  if (errmsg != (const char **) NULL)    {      if (! valid_bo (value))	*errmsg = "invalid conditional option";      else if ((value & 1) != 0)	*errmsg = "attempt to set y bit when using + or - modifier";    }  return insn | ((value & 0x1f) << 21);}static longextract_boe (insn, invalid)     unsigned long insn;     int *invalid;{  long value;  value = (insn >> 21) & 0x1f;  if (invalid != (int *) NULL      && ! valid_bo (value))    *invalid = 1;  return value & 0x1e;}/* The DS field in a DS form instruction.  This is like D, but the   lower two bits are forced to zero.  *//*ARGSUSED*/static unsigned longinsert_ds (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  return insn | (value & 0xfffc);}/*ARGSUSED*/static longextract_ds (insn, invalid)     unsigned long insn;     int *invalid;{  if ((insn & 0x8000) != 0)    return (insn & 0xfffc) - 0x10000;  else    return insn & 0xfffc;}/* The LI field in an I form instruction.  The lower two bits are   forced to zero.  *//*ARGSUSED*/static unsigned longinsert_li (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  return insn | (value & 0x3fffffc);}/*ARGSUSED*/static longextract_li (insn, invalid)     unsigned long insn;     int *invalid;{  if ((insn & 0x2000000) != 0)    return (insn & 0x3fffffc) - 0x4000000;  else    return insn & 0x3fffffc;}/* The MB and ME fields in an M form instruction expressed as a single   operand which is itself a bitmask.  The extraction function always   marks it as invalid, since we never want to recognize an   instruction which uses a field of this type.  */static unsigned longinsert_mbe (insn, value, errmsg)     unsigned long insn;     long value;     const char **errmsg;{  unsigned long uval;  int mb, me;

⌨️ 快捷键说明

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