3 * Purpose: Machine check handling specific defines
5 * Copyright (C) 1999 Silicon Graphics, Inc.
6 * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
7 * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
8 * Copyright (C) 2000 Hewlett-Packard Co.
9 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
10 * Copyright (C) 2002 Intel Corp.
11 * Copyright (C) 2002 Jenna Hall <jenna.s.hall@intel.com>
12 * Copyright (C) 2005 Silicon Graphics, Inc
13 * Copyright (C) 2005 Keith Owens <kaos@sgi.com>
15 #ifndef _ASM_IA64_MCA_ASM_H
16 #define _ASM_IA64_MCA_ASM_H
27 * This macro converts a instruction virtual address to a physical address
28 * Right now for simulation purposes the virtual addresses are
29 * direct mapped to physical addresses.
30 * 1. Lop off bits 61 thru 63 in the virtual address
32 #define INST_VA_TO_PA(addr) \
33 dep addr = 0, addr, 61, 3
35 * This macro converts a data virtual address to a physical address
36 * Right now for simulation purposes the virtual addresses are
37 * direct mapped to physical addresses.
38 * 1. Lop off bits 61 thru 63 in the virtual address
40 #define DATA_VA_TO_PA(addr) \
43 * This macro converts a data physical address to a virtual address
44 * Right now for simulation purposes the virtual addresses are
45 * direct mapped to physical addresses.
46 * 1. Put 0x7 in bits 61 thru 63.
48 #define DATA_PA_TO_VA(addr,temp) \
50 dep addr = temp, addr, 61, 3
52 #define GET_THIS_PADDR(reg, var) \
53 mov reg = IA64_KR(PER_CPU_DATA);; \
54 addl reg = THIS_CPU(var), reg
57 * This macro jumps to the instruction at the given virtual address
58 * and starts execution in physical mode with all the address
59 * translations turned off.
60 * 1. Save the current psr
61 * 2. Make sure that all the upper 32 bits are off
63 * 3. Clear the interrupt enable and interrupt state collection bits
64 * in the psr before updating the ipsr and iip.
66 * 4. Turn off the instruction, data and rse translation bits of the psr
67 * and store the new value into ipsr
68 * Also make sure that the interrupts are disabled.
69 * Ensure that we are in little endian mode.
70 * [psr.{rt, it, dt, i, be} = 0]
72 * 5. Get the physical address corresponding to the virtual address
73 * of the next instruction bundle and put it in iip.
74 * (Using magic numbers 24 and 40 in the deposint instruction since
75 * the IA64_SDK code directly maps to lower 24bits as physical address
76 * from a virtual address).
78 * 6. Do an rfi to move the values from ipsr to psr and iip to ip.
80 #define PHYSICAL_MODE_ENTER(temp1, temp2, start_addr, old_psr) \
83 dep old_psr = 0, old_psr, 32, 32; \
88 mov temp2 = ar.bspstore; \
90 DATA_VA_TO_PA(temp2); \
92 mov temp1 = ar.rnat; \
94 mov ar.bspstore = temp2; \
96 mov ar.rnat = temp1; \
101 dep temp2 = 0, temp2, PSR_IC, 2; \
106 dep temp1 = 0, temp1, 32, 32; \
108 dep temp1 = 0, temp1, PSR_IT, 1; \
110 dep temp1 = 0, temp1, PSR_DT, 1; \
112 dep temp1 = 0, temp1, PSR_RT, 1; \
114 dep temp1 = 0, temp1, PSR_I, 1; \
116 dep temp1 = 0, temp1, PSR_IC, 1; \
118 dep temp1 = -1, temp1, PSR_MC, 1; \
120 mov cr.ipsr = temp1; \
122 LOAD_PHYSICAL(p0, temp2, start_addr); \
124 mov cr.iip = temp2; \
139 * This macro jumps to the instruction at the given virtual address
140 * and starts execution in virtual mode with all the address
141 * translations turned on.
142 * 1. Get the old saved psr
144 * 2. Clear the interrupt state collection bit in the current psr.
146 * 3. Set the instruction translation bit back in the old psr
147 * Note we have to do this since we are right now saving only the
148 * lower 32-bits of old psr.(Also the old psr has the data and
149 * rse translation bits on)
151 * 4. Set ipsr to this old_psr with "it" bit set and "bn" = 1.
153 * 5. Reset the current thread pointer (r13).
155 * 6. Set iip to the virtual address of the next instruction bundle.
157 * 7. Do an rfi to move ipsr to psr and iip to ip.
160 #define VIRTUAL_MODE_ENTER(temp1, temp2, start_addr, old_psr) \
163 mov old_psr = temp2; \
165 dep temp2 = 0, temp2, PSR_IC, 2; \
172 mov temp2 = ar.bspstore; \
174 DATA_PA_TO_VA(temp2,temp1); \
176 mov temp1 = ar.rnat; \
178 mov ar.bspstore = temp2; \
180 mov ar.rnat = temp1; \
182 mov temp1 = old_psr; \
186 dep temp1 = temp2, temp1, PSR_IC, 1; \
188 dep temp1 = temp2, temp1, PSR_IT, 1; \
190 dep temp1 = temp2, temp1, PSR_DT, 1; \
192 dep temp1 = temp2, temp1, PSR_RT, 1; \
194 dep temp1 = temp2, temp1, PSR_BN, 1; \
197 mov cr.ipsr = temp1; \
198 movl temp2 = start_addr; \
200 mov cr.iip = temp2; \
203 DATA_PA_TO_VA(sp, temp1); \
213 * The MCA and INIT stacks in struct ia64_mca_cpu look like normal kernel
214 * stacks, except that the SAL/OS state and a switch_stack are stored near the
215 * top of the MCA/INIT stack. To support concurrent entry to MCA or INIT, as
216 * well as MCA over INIT, each event needs its own SAL/OS state. All entries
217 * are 16 byte aligned.
219 * +---------------------------+
221 * +---------------------------+
223 * +---------------------------+
225 * +---------------------------+
226 * | 16 byte scratch area |
227 * +---------------------------+ <-------- SP at start of C MCA handler
229 * +---------------------------+
230 * | RBS for MCA/INIT handler |
231 * +---------------------------+
232 * | struct task for MCA/INIT |
233 * +---------------------------+ <-------- Bottom of MCA/INIT stack
236 #define ALIGN16(x) ((x)&~15)
237 #define MCA_PT_REGS_OFFSET ALIGN16(KERNEL_STACK_SIZE-IA64_PT_REGS_SIZE)
238 #define MCA_SWITCH_STACK_OFFSET ALIGN16(MCA_PT_REGS_OFFSET-IA64_SWITCH_STACK_SIZE)
239 #define MCA_SOS_OFFSET ALIGN16(MCA_SWITCH_STACK_OFFSET-IA64_SAL_OS_STATE_SIZE)
240 #define MCA_SP_OFFSET ALIGN16(MCA_SOS_OFFSET-16)
242 #endif /* _ASM_IA64_MCA_ASM_H */