/*1* HPMC (High Priority Machine Check) handler.2*3* Copyright (C) 1999 Philipp Rumpf <[email protected]>4* Copyright (C) 1999 Hewlett-Packard (Frank Rowand)5* Copyright (C) 2000 Hewlett-Packard (John Marvin)6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2, or (at your option)10* any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*/212223/*24* This HPMC handler retrieves the HPMC pim data, resets IO and25* returns to the default trap handler with code set to 1 (HPMC).26* The default trap handler calls handle interruption, which27* does a stack and register dump. This at least allows kernel28* developers to get back to C code in virtual mode, where they29* have the option to examine and print values from memory that30* would help in debugging an HPMC caused by a software bug.31*32* There is more to do here:33*34* 1) On MP systems we need to synchronize processors35* before calling pdc/iodc.36* 2) We should be checking the system state and not37* returning to the fault handler if things are really38* bad.39*40*/4142.level 1.143.data4445#include <asm/assembly.h>46#include <asm/pdc.h>4748#include <linux/linkage.h>4950/*51* stack for os_hpmc, the HPMC handler.52* buffer for IODC procedures (for the HPMC handler).53*54* IODC requires 7K byte stack. That leaves 1K byte for os_hpmc.55*/5657.align PAGE_SIZE58hpmc_stack:59.block 163846061#define HPMC_IODC_BUF_SIZE 0x80006263.align PAGE_SIZE64hpmc_iodc_buf:65.block HPMC_IODC_BUF_SIZE6667.align 868hpmc_raddr:69.block 1287071#define HPMC_PIM_DATA_SIZE 896 /* Enough to hold all architected 2.0 state */7273.align 874ENTRY(hpmc_pim_data)75.block HPMC_PIM_DATA_SIZE76END(hpmc_pim_data)7778.text7980.import intr_save, code81ENTRY(os_hpmc)82.os_hpmc:8384/*85* registers modified:86*87* Using callee saves registers without saving them. The88* original values are in the pim dump if we need them.89*90* r2 (rp) return pointer91* r3 address of PDCE_PROC92* r4 scratch93* r5 scratch94* r23 (arg3) procedure arg95* r24 (arg2) procedure arg96* r25 (arg1) procedure arg97* r26 (arg0) procedure arg98* r30 (sp) stack pointer99*100* registers read:101*102* r26 contains address of PDCE_PROC on entry103* r28 (ret0) return value from procedure104*/105106copy arg0, %r3 /* save address of PDCE_PROC */107108/*109* disable nested HPMCs110*111* Increment os_hpmc checksum to invalidate it.112* Do this before turning the PSW M bit off.113*/114115mfctl %cr14, %r4116ldw 52(%r4),%r5117addi 1,%r5,%r5118stw %r5,52(%r4)119120/* MP_FIXME: synchronize all processors. */121122/* Setup stack pointer. */123124load32 PA(hpmc_stack),sp125126ldo 128(sp),sp /* leave room for arguments */127128/*129* Most PDC routines require that the M bit be off.130* So turn on the Q bit and turn off the M bit.131*/132133ldo 8(%r0),%r4 /* PSW Q on, PSW M off */134mtctl %r4,ipsw135mtctl %r0,pcsq136mtctl %r0,pcsq137load32 PA(os_hpmc_1),%r4138mtctl %r4,pcoq139ldo 4(%r4),%r4140mtctl %r4,pcoq141rfi142nop143144os_hpmc_1:145146/* Call PDC_PIM to get HPMC pim info */147148/*149* Note that on some newer boxes, PDC_PIM must be called150* before PDC_IO if you want IO to be reset. PDC_PIM sets151* a flag that PDC_IO examines.152*/153154ldo PDC_PIM(%r0), arg0155ldo PDC_PIM_HPMC(%r0),arg1 /* Transfer HPMC data */156load32 PA(hpmc_raddr),arg2157load32 PA(hpmc_pim_data),arg3158load32 HPMC_PIM_DATA_SIZE,%r4159stw %r4,-52(sp)160161ldil L%PA(os_hpmc_2), rp162bv (r3) /* call pdce_proc */163ldo R%PA(os_hpmc_2)(rp), rp164165os_hpmc_2:166comib,<> 0,ret0, os_hpmc_fail167168/* Reset IO by calling the hversion dependent PDC_IO routine */169170ldo PDC_IO(%r0),arg0171ldo 0(%r0),arg1 /* log IO errors */172ldo 0(%r0),arg2 /* reserved */173ldo 0(%r0),arg3 /* reserved */174stw %r0,-52(sp) /* reserved */175176ldil L%PA(os_hpmc_3),rp177bv (%r3) /* call pdce_proc */178ldo R%PA(os_hpmc_3)(rp),rp179180os_hpmc_3:181182/* FIXME? Check for errors from PDC_IO (-1 might be OK) */183184/*185* Initialize the IODC console device (HPA,SPA, path etc.186* are stored on page 0.187*/188189/*190* Load IODC into hpmc_iodc_buf by calling PDC_IODC.191* Note that PDC_IODC handles flushing the appropriate192* data and instruction cache lines.193*/194195ldo PDC_IODC(%r0),arg0196ldo PDC_IODC_READ(%r0),arg1197load32 PA(hpmc_raddr),arg2198ldw BOOT_CONSOLE_HPA_OFFSET(%r0),arg3 /* console hpa */199ldo PDC_IODC_RI_INIT(%r0),%r4200stw %r4,-52(sp)201load32 PA(hpmc_iodc_buf),%r4202stw %r4,-56(sp)203load32 HPMC_IODC_BUF_SIZE,%r4204stw %r4,-60(sp)205206ldil L%PA(os_hpmc_4),rp207bv (%r3) /* call pdce_proc */208ldo R%PA(os_hpmc_4)(rp),rp209210os_hpmc_4:211comib,<> 0,ret0,os_hpmc_fail212213/* Call the entry init (just loaded by PDC_IODC) */214215ldw BOOT_CONSOLE_HPA_OFFSET(%r0),arg0 /* console hpa */216ldo ENTRY_INIT_MOD_DEV(%r0), arg1217ldw BOOT_CONSOLE_SPA_OFFSET(%r0),arg2 /* console spa */218depi 0,31,11,arg2 /* clear bits 21-31 */219ldo BOOT_CONSOLE_PATH_OFFSET(%r0),arg3 /* console path */220load32 PA(hpmc_raddr),%r4221stw %r4, -52(sp)222stw %r0, -56(sp) /* HV */223stw %r0, -60(sp) /* HV */224stw %r0, -64(sp) /* HV */225stw %r0, -68(sp) /* lang, must be zero */226227load32 PA(hpmc_iodc_buf),%r5228ldil L%PA(os_hpmc_5),rp229bv (%r5)230ldo R%PA(os_hpmc_5)(rp),rp231232os_hpmc_5:233comib,<> 0,ret0,os_hpmc_fail234235/* Prepare to call intr_save */236237/*238* Load kernel page directory (load into user also, since239* we don't intend to ever return to user land anyway)240*/241242load32 PA(swapper_pg_dir),%r4243mtctl %r4,%cr24 /* Initialize kernel root pointer */244mtctl %r4,%cr25 /* Initialize user root pointer */245246/* Clear sr4-sr7 */247248mtsp %r0, %sr4249mtsp %r0, %sr5250mtsp %r0, %sr6251mtsp %r0, %sr7252253tovirt_r1 %r30 /* make sp virtual */254255rsm 8,%r0 /* Clear Q bit */256ldi 1,%r8 /* Set trap code to "1" for HPMC */257load32 PA(intr_save),%r1258be 0(%sr7,%r1)259nop260261os_hpmc_fail:262263/*264* Reset the system265*266* Some systems may lockup from a broadcast reset, so try the267* hversion PDC_BROADCAST_RESET() first.268* MP_FIXME: reset all processors if more than one central bus.269*/270271/* PDC_BROADCAST_RESET() */272273ldo PDC_BROADCAST_RESET(%r0),arg0274ldo 0(%r0),arg1 /* do reset */275276ldil L%PA(os_hpmc_6),rp277bv (%r3) /* call pdce_proc */278ldo R%PA(os_hpmc_6)(rp),rp279280os_hpmc_6:281282/*283* possible return values:284* -1 non-existent procedure285* -2 non-existent option286* -16 unaligned stack287*288* If call returned, do a broadcast reset.289*/290291ldil L%0xfffc0000,%r4 /* IO_BROADCAST */292ldo 5(%r0),%r5293stw %r5,48(%r4) /* CMD_RESET to IO_COMMAND offset */294295b .296nop297ENDPROC(os_hpmc)298.os_hpmc_end:299nop300.data301.align 4302.export os_hpmc_size303os_hpmc_size:304.word .os_hpmc_end-.os_hpmc305306307