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 /** 16 * @file 17 * 18 * ABI-related register definitions. 19 */ 20 21 #ifndef __ARCH_ABI_H__ 22 23 #if !defined __need_int_reg_t && !defined __DOXYGEN__ 24 # define __ARCH_ABI_H__ 25 # include <arch/chip.h> 26 #endif 27 28 /* Provide the basic machine types. */ 29 #ifndef __INT_REG_BITS 30 31 /** Number of bits in a register. */ 32 #if defined __tilegx__ 33 # define __INT_REG_BITS 64 34 #elif defined __tilepro__ 35 # define __INT_REG_BITS 32 36 #elif !defined __need_int_reg_t 37 # include <arch/chip.h> 38 # define __INT_REG_BITS CHIP_WORD_SIZE() 39 #else 40 # error Unrecognized architecture with __need_int_reg_t 41 #endif 42 43 #if __INT_REG_BITS == 64 44 45 #ifndef __ASSEMBLER__ 46 /** Unsigned type that can hold a register. */ 47 typedef unsigned long long __uint_reg_t; 48 49 /** Signed type that can hold a register. */ 50 typedef long long __int_reg_t; 51 #endif 52 53 /** String prefix to use for printf(). */ 54 #define __INT_REG_FMT "ll" 55 56 #else 57 58 #ifndef __ASSEMBLER__ 59 /** Unsigned type that can hold a register. */ 60 typedef unsigned long __uint_reg_t; 61 62 /** Signed type that can hold a register. */ 63 typedef long __int_reg_t; 64 #endif 65 66 /** String prefix to use for printf(). */ 67 #define __INT_REG_FMT "l" 68 69 #endif 70 #endif /* __INT_REG_BITS */ 71 72 73 #ifndef __need_int_reg_t 74 75 76 #ifndef __ASSEMBLER__ 77 /** Unsigned type that can hold a register. */ 78 typedef __uint_reg_t uint_reg_t; 79 80 /** Signed type that can hold a register. */ 81 typedef __int_reg_t int_reg_t; 82 #endif 83 84 /** String prefix to use for printf(). */ 85 #define INT_REG_FMT __INT_REG_FMT 86 87 /** Number of bits in a register. */ 88 #define INT_REG_BITS __INT_REG_BITS 89 90 91 /* Registers 0 - 55 are "normal", but some perform special roles. */ 92 93 #define TREG_FP 52 /**< Frame pointer. */ 94 #define TREG_TP 53 /**< Thread pointer. */ 95 #define TREG_SP 54 /**< Stack pointer. */ 96 #define TREG_LR 55 /**< Link to calling function PC. */ 97 98 /** Index of last normal general-purpose register. */ 99 #define TREG_LAST_GPR 55 100 101 /* Registers 56 - 62 are "special" network registers. */ 102 103 #define TREG_SN 56 /**< Static network access. */ 104 #define TREG_IDN0 57 /**< IDN demux 0 access. */ 105 #define TREG_IDN1 58 /**< IDN demux 1 access. */ 106 #define TREG_UDN0 59 /**< UDN demux 0 access. */ 107 #define TREG_UDN1 60 /**< UDN demux 1 access. */ 108 #define TREG_UDN2 61 /**< UDN demux 2 access. */ 109 #define TREG_UDN3 62 /**< UDN demux 3 access. */ 110 111 /* Register 63 is the "special" zero register. */ 112 113 #define TREG_ZERO 63 /**< "Zero" register; always reads as "0". */ 114 115 116 /** By convention, this register is used to hold the syscall number. */ 117 #define TREG_SYSCALL_NR 10 118 119 /** Name of register that holds the syscall number, for use in assembly. */ 120 #define TREG_SYSCALL_NR_NAME r10 121 122 123 /** 124 * The ABI requires callers to allocate a caller state save area of 125 * this many bytes at the bottom of each stack frame. 126 */ 127 #define C_ABI_SAVE_AREA_SIZE (2 * (INT_REG_BITS / 8)) 128 129 /** 130 * The operand to an 'info' opcode directing the backtracer to not 131 * try to find the calling frame. 132 */ 133 #define INFO_OP_CANNOT_BACKTRACE 2 134 135 136 #endif /* !__need_int_reg_t */ 137 138 /* Make sure we later can get all the definitions and declarations. */ 139 #undef __need_int_reg_t 140 141 #endif /* !__ARCH_ABI_H__ */ 142