2 * HPMC (High Priority Machine Check) handler.
4 * Copyright (C) 1999 Philipp Rumpf <prumpf@tux.org>
5 * Copyright (C) 1999 Hewlett-Packard (Frank Rowand)
6 * Copyright (C) 2000 Hewlett-Packard (John Marvin)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * This HPMC handler retrieves the HPMC pim data, resets IO and
26 * returns to the default trap handler with code set to 1 (HPMC).
27 * The default trap handler calls handle interruption, which
28 * does a stack and register dump. This at least allows kernel
29 * developers to get back to C code in virtual mode, where they
30 * have the option to examine and print values from memory that
31 * would help in debugging an HPMC caused by a software bug.
33 * There is more to do here:
35 * 1) On MP systems we need to synchronize processors
36 * before calling pdc/iodc.
37 * 2) We should be checking the system state and not
38 * returning to the fault handler if things are really
45 #include <asm/assembly.h>
49 #include <linux/linkage.h>
50 #include <linux/init.h>
53 * stack for os_hpmc, the HPMC handler.
54 * buffer for IODC procedures (for the HPMC handler).
56 * IODC requires 7K byte stack. That leaves 1K byte for os_hpmc.
64 #define HPMC_IODC_BUF_SIZE 0x8000
69 .block HPMC_IODC_BUF_SIZE
76 #define HPMC_PIM_DATA_SIZE 896 /* Enough to hold all architected 2.0 state */
81 .block HPMC_PIM_DATA_SIZE
86 .import intr_save, code
93 * Using callee saves registers without saving them. The
94 * original values are in the pim dump if we need them.
96 * r2 (rp) return pointer
97 * r3 address of PDCE_PROC
100 * r23 (arg3) procedure arg
101 * r24 (arg2) procedure arg
102 * r25 (arg1) procedure arg
103 * r26 (arg0) procedure arg
104 * r30 (sp) stack pointer
108 * r26 contains address of PDCE_PROC on entry
109 * r28 (ret0) return value from procedure
112 copy arg0, %r3 /* save address of PDCE_PROC */
115 * disable nested HPMCs
117 * Increment os_hpmc checksum to invalidate it.
118 * Do this before turning the PSW M bit off.
126 /* MP_FIXME: synchronize all processors. */
128 /* Setup stack pointer. */
130 load32 PA(hpmc_stack),sp
132 ldo 128(sp),sp /* leave room for arguments */
135 * Most PDC routines require that the M bit be off.
136 * So turn on the Q bit and turn off the M bit.
139 ldi PSW_SM_Q,%r4 /* PSW Q on, PSW M off */
143 load32 PA(os_hpmc_1),%r4
152 /* Call PDC_PIM to get HPMC pim info */
155 * Note that on some newer boxes, PDC_PIM must be called
156 * before PDC_IO if you want IO to be reset. PDC_PIM sets
157 * a flag that PDC_IO examines.
160 ldo PDC_PIM(%r0), arg0
161 ldo PDC_PIM_HPMC(%r0),arg1 /* Transfer HPMC data */
162 load32 PA(hpmc_raddr),arg2
163 load32 PA(hpmc_pim_data),arg3
164 load32 HPMC_PIM_DATA_SIZE,%r4
167 ldil L%PA(os_hpmc_2), rp
168 bv (r3) /* call pdce_proc */
169 ldo R%PA(os_hpmc_2)(rp), rp
172 comib,<> 0,ret0, os_hpmc_fail
174 /* Reset IO by calling the hversion dependent PDC_IO routine */
177 ldo 0(%r0),arg1 /* log IO errors */
178 ldo 0(%r0),arg2 /* reserved */
179 ldo 0(%r0),arg3 /* reserved */
180 stw %r0,-52(sp) /* reserved */
182 ldil L%PA(os_hpmc_3),rp
183 bv (%r3) /* call pdce_proc */
184 ldo R%PA(os_hpmc_3)(rp),rp
188 /* FIXME? Check for errors from PDC_IO (-1 might be OK) */
191 * Initialize the IODC console device (HPA,SPA, path etc.
192 * are stored on page 0.
196 * Load IODC into hpmc_iodc_buf by calling PDC_IODC.
197 * Note that PDC_IODC handles flushing the appropriate
198 * data and instruction cache lines.
201 ldo PDC_IODC(%r0),arg0
202 ldo PDC_IODC_READ(%r0),arg1
203 load32 PA(hpmc_raddr),arg2
204 ldw BOOT_CONSOLE_HPA_OFFSET(%r0),arg3 /* console hpa */
205 ldo PDC_IODC_RI_INIT(%r0),%r4
207 load32 PA(hpmc_iodc_buf),%r4
209 load32 HPMC_IODC_BUF_SIZE,%r4
212 ldil L%PA(os_hpmc_4),rp
213 bv (%r3) /* call pdce_proc */
214 ldo R%PA(os_hpmc_4)(rp),rp
217 comib,<> 0,ret0,os_hpmc_fail
219 /* Call the entry init (just loaded by PDC_IODC) */
221 ldw BOOT_CONSOLE_HPA_OFFSET(%r0),arg0 /* console hpa */
222 ldo ENTRY_INIT_MOD_DEV(%r0), arg1
223 ldw BOOT_CONSOLE_SPA_OFFSET(%r0),arg2 /* console spa */
224 depi 0,31,11,arg2 /* clear bits 21-31 */
225 ldo BOOT_CONSOLE_PATH_OFFSET(%r0),arg3 /* console path */
226 load32 PA(hpmc_raddr),%r4
228 stw %r0, -56(sp) /* HV */
229 stw %r0, -60(sp) /* HV */
230 stw %r0, -64(sp) /* HV */
231 stw %r0, -68(sp) /* lang, must be zero */
233 load32 PA(hpmc_iodc_buf),%r5
234 ldil L%PA(os_hpmc_5),rp
236 ldo R%PA(os_hpmc_5)(rp),rp
239 comib,<> 0,ret0,os_hpmc_fail
241 /* Prepare to call intr_save */
244 * Load kernel page directory (load into user also, since
245 * we don't intend to ever return to user land anyway)
248 load32 PA(swapper_pg_dir),%r4
249 mtctl %r4,%cr24 /* Initialize kernel root pointer */
250 mtctl %r4,%cr25 /* Initialize user root pointer */
259 tovirt_r1 %r30 /* make sp virtual */
261 rsm PSW_SM_Q,%r0 /* Clear Q bit */
262 ldi 1,%r8 /* Set trap code to "1" for HPMC */
263 load32 PA(intr_save),%r1
272 * Some systems may lockup from a broadcast reset, so try the
273 * hversion PDC_BROADCAST_RESET() first.
274 * MP_FIXME: reset all processors if more than one central bus.
277 /* PDC_BROADCAST_RESET() */
279 ldo PDC_BROADCAST_RESET(%r0),arg0
280 ldo 0(%r0),arg1 /* do reset */
282 ldil L%PA(os_hpmc_6),rp
283 bv (%r3) /* call pdce_proc */
284 ldo R%PA(os_hpmc_6)(rp),rp
289 * possible return values:
290 * -1 non-existent procedure
291 * -2 non-existent option
292 * -16 unaligned stack
294 * If call returned, do a broadcast reset.
297 ldil L%0xfffc0000,%r4 /* IO_BROADCAST */
299 stw %r5,48(%r4) /* CMD_RESET to IO_COMMAND offset */
311 .word .os_hpmc_end-.os_hpmc