Merge git://git.infradead.org/mtd-2.6
[pandora-kernel.git] / arch / tile / include / arch / abi.h
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 helpful when writing assembly code.
19  */
20
21 #ifndef __ARCH_ABI_H__
22 #define __ARCH_ABI_H__
23
24 #include <arch/chip.h>
25
26 /* Registers 0 - 55 are "normal", but some perform special roles. */
27
28 #define TREG_FP       52   /**< Frame pointer. */
29 #define TREG_TP       53   /**< Thread pointer. */
30 #define TREG_SP       54   /**< Stack pointer. */
31 #define TREG_LR       55   /**< Link to calling function PC. */
32
33 /** Index of last normal general-purpose register. */
34 #define TREG_LAST_GPR 55
35
36 /* Registers 56 - 62 are "special" network registers. */
37
38 #define TREG_SN       56   /**< Static network access. */
39 #define TREG_IDN0     57   /**< IDN demux 0 access. */
40 #define TREG_IDN1     58   /**< IDN demux 1 access. */
41 #define TREG_UDN0     59   /**< UDN demux 0 access. */
42 #define TREG_UDN1     60   /**< UDN demux 1 access. */
43 #define TREG_UDN2     61   /**< UDN demux 2 access. */
44 #define TREG_UDN3     62   /**< UDN demux 3 access. */
45
46 /* Register 63 is the "special" zero register. */
47
48 #define TREG_ZERO     63   /**< "Zero" register; always reads as "0". */
49
50
51 /** By convention, this register is used to hold the syscall number. */
52 #define TREG_SYSCALL_NR      10
53
54 /** Name of register that holds the syscall number, for use in assembly. */
55 #define TREG_SYSCALL_NR_NAME r10
56
57
58 /**
59  * The ABI requires callers to allocate a caller state save area of
60  * this many bytes at the bottom of each stack frame.
61  */
62 #define C_ABI_SAVE_AREA_SIZE (2 * (CHIP_WORD_SIZE() / 8))
63
64 /**
65  * The operand to an 'info' opcode directing the backtracer to not
66  * try to find the calling frame.
67  */
68 #define INFO_OP_CANNOT_BACKTRACE 2
69
70 #ifndef __ASSEMBLER__
71 #if CHIP_WORD_SIZE() > 32
72
73 /** Unsigned type that can hold a register. */
74 typedef unsigned long long uint_reg_t;
75
76 /** Signed type that can hold a register. */
77 typedef long long int_reg_t;
78
79 /** String prefix to use for printf(). */
80 #define INT_REG_FMT "ll"
81
82 #elif !defined(__LP64__)   /* avoid confusion with LP64 cross-build tools */
83
84 /** Unsigned type that can hold a register. */
85 typedef unsigned long uint_reg_t;
86
87 /** Signed type that can hold a register. */
88 typedef long int_reg_t;
89
90 /** String prefix to use for printf(). */
91 #define INT_REG_FMT "l"
92
93 #endif
94 #endif /* __ASSEMBLER__ */
95
96 #endif /* !__ARCH_ABI_H__ */