abi.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. /**
  15. * @file
  16. *
  17. * ABI-related register definitions.
  18. */
  19. #ifndef __ARCH_ABI_H__
  20. #if !defined __need_int_reg_t && !defined __DOXYGEN__
  21. # define __ARCH_ABI_H__
  22. # include <arch/chip.h>
  23. #endif
  24. /* Provide the basic machine types. */
  25. #ifndef __INT_REG_BITS
  26. /** Number of bits in a register. */
  27. #if defined __tilegx__
  28. # define __INT_REG_BITS 64
  29. #elif defined __tilepro__
  30. # define __INT_REG_BITS 32
  31. #elif !defined __need_int_reg_t
  32. # include <arch/chip.h>
  33. # define __INT_REG_BITS CHIP_WORD_SIZE()
  34. #else
  35. # error Unrecognized architecture with __need_int_reg_t
  36. #endif
  37. #if __INT_REG_BITS == 64
  38. #ifndef __ASSEMBLER__
  39. /** Unsigned type that can hold a register. */
  40. typedef unsigned long long __uint_reg_t;
  41. /** Signed type that can hold a register. */
  42. typedef long long __int_reg_t;
  43. #endif
  44. /** String prefix to use for printf(). */
  45. #define __INT_REG_FMT "ll"
  46. #else
  47. #ifndef __ASSEMBLER__
  48. /** Unsigned type that can hold a register. */
  49. typedef unsigned long __uint_reg_t;
  50. /** Signed type that can hold a register. */
  51. typedef long __int_reg_t;
  52. #endif
  53. /** String prefix to use for printf(). */
  54. #define __INT_REG_FMT "l"
  55. #endif
  56. #endif /* __INT_REG_BITS */
  57. #ifndef __need_int_reg_t
  58. #ifndef __ASSEMBLER__
  59. /** Unsigned type that can hold a register. */
  60. typedef __uint_reg_t uint_reg_t;
  61. /** Signed type that can hold a register. */
  62. typedef __int_reg_t int_reg_t;
  63. #endif
  64. /** String prefix to use for printf(). */
  65. #define INT_REG_FMT __INT_REG_FMT
  66. /** Number of bits in a register. */
  67. #define INT_REG_BITS __INT_REG_BITS
  68. /* Registers 0 - 55 are "normal", but some perform special roles. */
  69. #define TREG_FP 52 /**< Frame pointer. */
  70. #define TREG_TP 53 /**< Thread pointer. */
  71. #define TREG_SP 54 /**< Stack pointer. */
  72. #define TREG_LR 55 /**< Link to calling function PC. */
  73. /** Index of last normal general-purpose register. */
  74. #define TREG_LAST_GPR 55
  75. /* Registers 56 - 62 are "special" network registers. */
  76. #define TREG_SN 56 /**< Static network access. */
  77. #define TREG_IDN0 57 /**< IDN demux 0 access. */
  78. #define TREG_IDN1 58 /**< IDN demux 1 access. */
  79. #define TREG_UDN0 59 /**< UDN demux 0 access. */
  80. #define TREG_UDN1 60 /**< UDN demux 1 access. */
  81. #define TREG_UDN2 61 /**< UDN demux 2 access. */
  82. #define TREG_UDN3 62 /**< UDN demux 3 access. */
  83. /* Register 63 is the "special" zero register. */
  84. #define TREG_ZERO 63 /**< "Zero" register; always reads as "0". */
  85. /** By convention, this register is used to hold the syscall number. */
  86. #define TREG_SYSCALL_NR 10
  87. /** Name of register that holds the syscall number, for use in assembly. */
  88. #define TREG_SYSCALL_NR_NAME r10
  89. /**
  90. * The ABI requires callers to allocate a caller state save area of
  91. * this many bytes at the bottom of each stack frame.
  92. */
  93. #define C_ABI_SAVE_AREA_SIZE (2 * (INT_REG_BITS / 8))
  94. /**
  95. * The operand to an 'info' opcode directing the backtracer to not
  96. * try to find the calling frame.
  97. */
  98. #define INFO_OP_CANNOT_BACKTRACE 2
  99. #endif /* !__need_int_reg_t */
  100. /* Make sure we later can get all the definitions and declarations. */
  101. #undef __need_int_reg_t
  102. #endif /* !__ARCH_ABI_H__ */