1/* $NetBSD: shark_fiq.S,v 1.2 2003/05/20 04:44:52 simonb Exp $ */ 2 3/* 4 * Copyright 1997 5 * Digital Equipment Corporation. All rights reserved. 6 * 7 * This software is furnished under license and may be used and 8 * copied only in accordance with the following terms and conditions. 9 * Subject to these conditions, you may download, copy, install, 10 * use, modify and distribute this software in source and/or binary 11 * form. No title or ownership is transferred hereby. 12 * 13 * 1) Any source code used, modified or distributed must reproduce 14 * and retain this copyright notice and list of conditions as 15 * they appear in the source file. 16 * 17 * 2) No right is granted to use any trade name, trademark, or logo of 18 * Digital Equipment Corporation. Neither the "Digital Equipment 19 * Corporation" name nor any trademark or logo of Digital Equipment 20 * Corporation may be used to endorse or promote products derived 21 * from this software without the prior written permission of 22 * Digital Equipment Corporation. 23 * 24 * 3) This software is provided "AS-IS" and any express or implied 25 * warranties, including but not limited to, any implied warranties 26 * of merchantability, fitness for a particular purpose, or 27 * non-infringement are disclaimed. In no event shall DIGITAL be 28 * liable for any damages whatsoever, and in particular, DIGITAL 29 * shall not be liable for special, indirect, consequential, or 30 * incidental damages or damages for lost profits, loss of 31 * revenue or loss of use, whether such damages arise in contract, 32 * negligence, tort, under statute, in equity, at law or otherwise, 33 * even if advised of the possibility of such damage. 34 */ 35 36/* 37 * fiq.S 38 * 39 * Low level fiq handlers 40 * 41 * Created : 19/05/97 42 */ 43 44#include <machine/asm.h> 45#include <machine/cpu.h> 46#include <shark/shark/shark_fiq.h> 47#include <shark/shark/sequoia.h> 48 49 .text 50 51/* this variable is used to detect when it is necessary to unwedge the 52 sequoia SMI/PMI edge detect logic. *sigh* */ 53Lfiqs_happened: 54 .word _C_LABEL(fiqs_happened) 55Lsequoia_index_cache: 56 .word _C_LABEL(sequoia_index_cache) 57 58 .data 59 .global _C_LABEL(fiqs_happened) 60_C_LABEL(fiqs_happened): 61 .word 0 62 63 .text 64 65 .global _C_LABEL(shark_fiq) 66 .global _C_LABEL(shark_fiq_end) 67 68/* 69 * r8 - VAM_IO_DATA = address of IO space in virtual memory 70 * r9 - C routine to call (0 => no routine) 71 * r10 - argument (0 => pass PMI reason register) 72 * r11 - scratch 73 * r12 - scratch 74 * r13 - stack for C routine call 75 */ 76 77_C_LABEL(shark_fiq): 78 /* clear the FIQ immediately */ 79 /* do the FIQ/SMI clear here to avoid synchronization problems! 80 both the chip enable (caused by the ISA register read) and 81 the sequoia bit clear must be done. do it in that order so 82 the sequoia port accesses will clear the chip enable caused 83 by accessing FIQ_CLEAR_IOPORT 84 */ 85 /* set up to read/write the power management status register */ 86 ldr r11, Lsequoia_index_cache 87 ldr r12, [r11] 88 89 /* see if the index is properly set. unfortunately, the common 90 case will probably be that the FIQ handler (e.g. smartcard) 91 talks to the sequoia, so the index will need to be set. */ 92 cmp r12, #PMC_PMSR_REG 93 movne r12, #PMC_PMSR_REG 94#ifdef STRH 95 strneh r12, [r8, #SEQUOIA_INDEX] 96#else 97 .word 0x11c8c2b4 98#endif 99 strne r12, [r11] 100 101 /* set SMIACT by changing the power management mode to sleep */ 102 mov r12, #PMMD_SLEEP 103#ifdef STRH 104 strh r12, [r8, #SEQUOIA_DATA] 105#else 106 .word 0xe1c8c2b6 107#endif 108 109 /* get the PMI reason register, if desired */ 110 cmp r10, #0 111#ifdef LDRH 112 ldreqh r10, [r8, #SEQUOIA_DATA] 113#else 114 .word 0x01d8a2b6 /* ldrh r10, [r8, #0x26] */ 115#endif 116 117 /* simultaneously clear the PMI reason bits and clear SMIACT */ 118 mov r12, #PMMD_ON 119 orr r12, r12, #PMSR_M_PMISRC 120#ifdef STRH 121 strh r12, [r8, #SEQUOIA_DATA] 122#else 123 .word 0xe1c8c2b6 124#endif 125 126 ldr r12, Lfiqs_happened 127 ldr r11, [r12] 128 add r11, r11, #1 129 str r11, [r12] 130 131 cmp r9, #0 132 subeqs pc, lr, #4 /* no routine => return from trap */ 133 134 /* assume that the C routine follows the ARM procedure call standard. 135 save only user registers and let the C code save the rest. 136 r0-r3, r12, r14 clobbered. other regs should be restored 137 by C code. 138 */ 139 stmfd sp!, {r0-r3, lr} /* save user registers */ 140 mov r0, r10 /* pass the PMI reason register */ 141 mov lr, pc /* call C routine */ 142 mov pc, r9 143 ldmfd sp!, {r0-r3, lr} /* restore user registers */ 144 subs pc, lr, #4 /* return from trap */ 145_C_LABEL(shark_fiq_end): 146 147/* End of fiq.S */ 148