gdb/xtensa-tdep.h - gdb

Data types defined

Macros defined

Source code

  1. /* Target-dependent code for the Xtensa port of GDB, the GNU debugger.

  2.    Copyright (C) 2003-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */


  14. /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION
  15.    whenever the "tdep" structure changes in an incompatible way.  */

  16. #define XTENSA_TDEP_VERSION 0x60

  17. /*  Xtensa register type.  */

  18. typedef enum
  19. {
  20.   xtRegisterTypeArRegfile = 1,        /* Register File ar0..arXX.  */
  21.   xtRegisterTypeSpecialReg,        /* CPU states, such as PS, Booleans, (rsr).  */
  22.   xtRegisterTypeUserReg,        /* User defined registers (rur).  */
  23.   xtRegisterTypeTieRegfile,        /* User define register files.  */
  24.   xtRegisterTypeTieState,        /* TIE States (mapped on user regs).  */
  25.   xtRegisterTypeMapped,                /* Mapped on Special Registers.  */
  26.   xtRegisterTypeUnmapped,        /* Special case of masked registers.  */
  27.   xtRegisterTypeWindow,                /* Live window registers (a0..a15).  */
  28.   xtRegisterTypeVirtual,        /* PC, FP.  */
  29.   xtRegisterTypeUnknown
  30. } xtensa_register_type_t;


  31. /*  Xtensa register group.  */

  32. #define XTENSA_MAX_COPROCESSOR        0x10  /* Number of Xtensa coprocessors.  */

  33. typedef enum
  34. {
  35.   xtRegisterGroupUnknown = 0,
  36.   xtRegisterGroupRegFile        = 0x0001,    /* Register files without ARx.  */
  37.   xtRegisterGroupAddrReg        = 0x0002,    /* ARx.  */
  38.   xtRegisterGroupSpecialReg        = 0x0004,    /* SRxx.  */
  39.   xtRegisterGroupUserReg        = 0x0008,    /* URxx.  */
  40.   xtRegisterGroupState                 = 0x0010,    /* States.  */

  41.   xtRegisterGroupGeneral        = 0x0100,    /* General registers, Ax, SR.  */
  42.   xtRegisterGroupUser                = 0x0200,    /* User registers.  */
  43.   xtRegisterGroupFloat                = 0x0400,    /* Floating Point.  */
  44.   xtRegisterGroupVectra                = 0x0800,    /* Vectra.  */
  45.   xtRegisterGroupSystem                = 0x1000,    /* System.  */

  46.   xtRegisterGroupNCP            = 0x00800000,    /* Non-CP non-base opt/custom.  */
  47.   xtRegisterGroupCP0            = 0x01000000,    /* CP0.  */
  48.   xtRegisterGroupCP1            = 0x02000000,    /* CP1.  */
  49.   xtRegisterGroupCP2            = 0x04000000,    /* CP2.  */
  50.   xtRegisterGroupCP3            = 0x08000000,    /* CP3.  */
  51.   xtRegisterGroupCP4            = 0x10000000,    /* CP4.  */
  52.   xtRegisterGroupCP5            = 0x20000000,    /* CP5.  */
  53.   xtRegisterGroupCP6            = 0x40000000,    /* CP6.  */
  54.   xtRegisterGroupCP7            = 0x80000000,    /* CP7.  */

  55. } xtensa_register_group_t;


  56. /*  Xtensa target flags.  */

  57. typedef enum
  58. {
  59.   xtTargetFlagsNonVisibleRegs        = 0x0001,
  60.   xtTargetFlagsUseFetchStore        = 0x0002,
  61. } xtensa_target_flags_t;


  62. /* Xtensa ELF core file register set representation ('.reg' section).
  63.    Copied from target-side ELF header <xtensa/elf.h>.  */

  64. typedef uint32_t xtensa_elf_greg_t;

  65. typedef struct
  66. {
  67.   xtensa_elf_greg_t pc;
  68.   xtensa_elf_greg_t ps;
  69.   xtensa_elf_greg_t lbeg;
  70.   xtensa_elf_greg_t lend;
  71.   xtensa_elf_greg_t lcount;
  72.   xtensa_elf_greg_t sar;
  73.   xtensa_elf_greg_t windowstart;
  74.   xtensa_elf_greg_t windowbase;
  75.   xtensa_elf_greg_t reserved[8+48];
  76.   xtensa_elf_greg_t ar[64];
  77. } xtensa_elf_gregset_t;

  78. #define XTENSA_ELF_NGREG (sizeof (xtensa_elf_gregset_t) \
  79.                           / sizeof (xtensa_elf_greg_t))

  80. /*  Mask.  */

  81. typedef struct
  82. {
  83.   int reg_num;
  84.   int bit_start;
  85.   int bit_size;
  86. } xtensa_reg_mask_t;

  87. typedef struct
  88. {
  89.   int count;
  90.   xtensa_reg_mask_t *mask;
  91. } xtensa_mask_t;


  92. /*  Xtensa register representation.  */

  93. typedef struct
  94. {
  95.   char* name;                     /* Register name.  */
  96.   int offset;                     /* Offset.  */
  97.   xtensa_register_type_t type/* Register type.  */
  98.   xtensa_register_group_t group;/* Register group.  */
  99.   struct type* ctype;                /* C-type.  */
  100.   int bit_size;                  /* The actual bit size in the target.  */
  101.   int byte_size;                  /* Actual space allocated in registers[].  */
  102.   int align;                        /* Alignment for this register.  */

  103.   unsigned int target_number;        /* Register target number.  */

  104.   int flags;                        /* Flags.  */
  105.   int coprocessor;                /* Coprocessor num, -1 for non-CP, else -2.  */

  106.   const xtensa_mask_t *mask;        /* Register is a compilation of other regs.  */
  107.   const char *fetch;                /* Instruction sequence to fetch register.  */
  108.   const char *store;                /* Instruction sequence to store register.  */
  109. } xtensa_register_t;

  110. /*  For xtensa-config.c to expand to the structure above.  */
  111. #define XTREG(index,ofs,bsz,sz,al,tnum,flg,cp,ty,gr,name,fet,sto,mas,ct,x,y) \
  112.         {#name, ofs, ty, ((gr) | ((xtRegisterGroupNCP >> 2) << (cp + 2))), \
  113.          ct, bsz, sz, al, tnum, flg, cp, mas, fet, sto},
  114. #define XTREG_END {0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0},

  115. #define XTENSA_REGISTER_FLAGS_PRIVILEGED        0x0001
  116. #define XTENSA_REGISTER_FLAGS_READABLE                0x0002
  117. #define XTENSA_REGISTER_FLAGS_WRITABLE                0x0004
  118. #define XTENSA_REGISTER_FLAGS_VOLATILE                0x0008

  119. /*  Call-ABI for stack frame.  */

  120. typedef enum
  121. {
  122.   CallAbiDefault = 0,                /* Any 'callX' instructions; default stack.  */
  123.   CallAbiCall0Only,                /* Only 'call0' instructions; flat stack.  */
  124. } call_abi_t;


  125. /*  Xtensa-specific target dependencies.  */

  126. struct gdbarch_tdep
  127. {
  128.   unsigned int target_flags;

  129.   /* Spill location for TIE register files under ocd.  */

  130.   unsigned int spill_location;
  131.   unsigned int spill_size;

  132.   char *unused;                                /* Placeholder for compatibility.  */
  133.   call_abi_t call_abi;                        /* Calling convention.  */

  134.   /* CPU configuration.  */

  135.   unsigned int debug_interrupt_level;

  136.   unsigned int icache_line_bytes;
  137.   unsigned int dcache_line_bytes;
  138.   unsigned int dcache_writeback;

  139.   unsigned int isa_use_windowed_registers;
  140.   unsigned int isa_use_density_instructions;
  141.   unsigned int isa_use_exceptions;
  142.   unsigned int isa_use_ext_l32r;
  143.   unsigned int isa_max_insn_size;        /* Maximum instruction length.  */
  144.   unsigned int debug_num_ibreaks;        /* Number of IBREAKs.  */
  145.   unsigned int debug_num_dbreaks;

  146.   /* Register map.  */

  147.   xtensa_register_t* regmap;

  148.   unsigned int num_regs;        /* Number of registers in register map.  */
  149.   unsigned int num_nopriv_regs;        /* Number of non-privileged registers.  */
  150.   unsigned int num_pseudo_regs;        /* Number of pseudo registers.  */
  151.   unsigned int num_aregs;        /* Size of register file.  */
  152.   unsigned int num_contexts;

  153.   int ar_base;                        /* Register number for AR0.  */
  154.   int a0_base;                        /* Register number for A0 (pseudo).  */
  155.   int wb_regnum;                /* Register number for WB.  */
  156.   int ws_regnum;                /* Register number for WS.  */
  157.   int pc_regnum;                /* Register number for PC.  */
  158.   int ps_regnum;                /* Register number for PS.  */
  159.   int lbeg_regnum;                /* Register numbers for count regs.  */
  160.   int lend_regnum;
  161.   int lcount_regnum;
  162.   int sar_regnum;                /* Register number of SAR.  */
  163.   int litbase_regnum;                /* Register number of LITBASE.  */

  164.   int interrupt_regnum;                /* Register number for interrupt.  */
  165.   int interrupt2_regnum;        /* Register number for interrupt2.  */
  166.   int cpenable_regnum;                /* Register number for cpenable.  */
  167.   int debugcause_regnum;        /* Register number for debugcause.  */
  168.   int exccause_regnum;                /* Register number for exccause.  */
  169.   int excvaddr_regnum;                /* Register number for excvaddr.  */

  170.   int max_register_raw_size;
  171.   int max_register_virtual_size;
  172.   unsigned long *fp_layout;        /* Layout of custom/TIE regs in 'FP' area.  */
  173.   unsigned int fp_layout_bytes;        /* Size of layout information (in bytes).  */
  174.   unsigned long *gregmap;

  175.   /* Cached register types.  */
  176.   struct ctype_cache
  177.     {
  178.       struct ctype_cache *next;
  179.       int size;
  180.       struct type *virtual_type;
  181.     } *type_entries;
  182. };

  183. /* Macro to instantiate a gdbarch_tdep structure.  */

  184. #define XTENSA_GDBARCH_TDEP_INSTANTIATE(rmap,spillsz)                \
  185.         {                                                        \
  186.           .target_flags = 0,                                        \
  187.           .spill_location = -1,                                        \
  188.           .spill_size = (spillsz),                                \
  189.           .unused = 0,                                                \
  190.           .call_abi = 0,                                        \
  191.           .debug_interrupt_level = XCHAL_DEBUGLEVEL,                \
  192.           .icache_line_bytes = XCHAL_ICACHE_LINESIZE,                \
  193.           .dcache_line_bytes = XCHAL_DCACHE_LINESIZE,                \
  194.           .dcache_writeback = XCHAL_DCACHE_IS_WRITEBACK,        \
  195.           .isa_use_windowed_registers = (XSHAL_ABI != XTHAL_ABI_CALL0),        \
  196.           .isa_use_density_instructions = XCHAL_HAVE_DENSITY,        \
  197.           .isa_use_exceptions = XCHAL_HAVE_EXCEPTIONS,                \
  198.           .isa_use_ext_l32r = XSHAL_USE_ABSOLUTE_LITERALS,        \
  199.           .isa_max_insn_size = XCHAL_MAX_INSTRUCTION_SIZE,        \
  200.           .debug_num_ibreaks = XCHAL_NUM_IBREAK,                \
  201.           .debug_num_dbreaks = XCHAL_NUM_DBREAK,                \
  202.           .regmap = rmap,                        \
  203.           .num_regs = 0,                        \
  204.           .num_nopriv_regs = 0,                        \
  205.           .num_pseudo_regs = 0,                        \
  206.           .num_aregs = XCHAL_NUM_AREGS,                \
  207.           .num_contexts = XCHAL_NUM_CONTEXTS,        \
  208.           .ar_base = -1,                        \
  209.           .a0_base = -1,                        \
  210.           .wb_regnum = -1,                        \
  211.           .ws_regnum = -1,                        \
  212.           .pc_regnum = -1,                        \
  213.           .ps_regnum = -1,                        \
  214.           .lbeg_regnum = -1,                        \
  215.           .lend_regnum = -1,                        \
  216.           .lcount_regnum = -1,                        \
  217.           .sar_regnum = -1,                        \
  218.           .litbase_regnum = -1,                        \
  219.           .interrupt_regnum = -1,                \
  220.           .interrupt2_regnum = -1,                \
  221.           .cpenable_regnum = -1,                \
  222.           .debugcause_regnum = -1,                \
  223.           .exccause_regnum = -1,                \
  224.           .excvaddr_regnum = -1,                \
  225.           .max_register_raw_size = 0,                \
  226.           .max_register_virtual_size = 0,        \
  227.           .fp_layout = 0,                        \
  228.           .fp_layout_bytes = 0,                        \
  229.           .gregmap = 0,                                \
  230.         }
  231. #define XTENSA_CONFIG_INSTANTIATE(rmap,spill_size)        \
  232.         struct gdbarch_tdep xtensa_tdep = \
  233.           XTENSA_GDBARCH_TDEP_INSTANTIATE(rmap,spill_size);

  234. #ifndef XCHAL_NUM_CONTEXTS
  235. #define XCHAL_NUM_CONTEXTS        0
  236. #endif
  237. #ifndef XCHAL_HAVE_EXCEPTIONS
  238. #define XCHAL_HAVE_EXCEPTIONS        1
  239. #endif
  240. #define WB_SHIFT          2

  241. /* We assign fixed numbers to the registers of the "current" window
  242.    (i.e., relative to WB).  The registers get remapped via the reg_map
  243.    data structure to their corresponding register in the AR register
  244.    file (see xtensa-tdep.c).  */