| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * Hypervisor Software File: errs_common.s |
| 5 | * |
| 6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 7 | * |
| 8 | * - Do no alter or remove copyright notices |
| 9 | * |
| 10 | * - Redistribution and use of this software in source and binary forms, with |
| 11 | * or without modification, are permitted provided that the following |
| 12 | * conditions are met: |
| 13 | * |
| 14 | * - Redistribution of source code must retain the above copyright notice, |
| 15 | * this list of conditions and the following disclaimer. |
| 16 | * |
| 17 | * - Redistribution in binary form must reproduce the above copyright notice, |
| 18 | * this list of conditions and the following disclaimer in the |
| 19 | * documentation and/or other materials provided with the distribution. |
| 20 | * |
| 21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors |
| 22 | * may be used to endorse or promote products derived from this software |
| 23 | * without specific prior written permission. |
| 24 | * |
| 25 | * This software is provided "AS IS," without a warranty of any kind. |
| 26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, |
| 27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
| 28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN |
| 29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR |
| 30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR |
| 31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN |
| 32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR |
| 33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE |
| 34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, |
| 35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF |
| 36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
| 37 | * |
| 38 | * You acknowledge that this software is not designed, licensed or |
| 39 | * intended for use in the design, construction, operation or maintenance of |
| 40 | * any nuclear facility. |
| 41 | * |
| 42 | * ========== Copyright Header End ============================================ |
| 43 | */ |
| 44 | /* |
| 45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
| 46 | * Use is subject to license terms. |
| 47 | */ |
| 48 | |
| 49 | .ident "@(#)errs_common.s 1.8 07/05/03 SMI" |
| 50 | |
| 51 | #include <sys/asm_linkage.h> |
| 52 | #include <sys/htypes.h> |
| 53 | #include <hypervisor.h> |
| 54 | #include <sparcv9/asi.h> |
| 55 | #include <sun4v/asi.h> |
| 56 | #include <asi.h> |
| 57 | |
| 58 | #include <offsets.h> |
| 59 | #include <strand.h> |
| 60 | #include <debug.h> |
| 61 | #include <util.h> |
| 62 | #include <errs_common.h> |
| 63 | #include <svc.h> |
| 64 | #include <abort.h> |
| 65 | |
| 66 | /* |
| 67 | * send_diag_erpt - send the diag error report. The offset of the error |
| 68 | * report buffwe is passed in as E_OFF |
| 69 | * |
| 70 | * %g1 - erpt |
| 71 | * %g2 - ptr to sent flag |
| 72 | * %g3 - packet size |
| 73 | * %g7 - return address |
| 74 | * %g4 - %g6 used and garbbled |
| 75 | * |
| 76 | * For service delivery the flag is not cleared until the packet |
| 77 | * has been received (ACK) by the SP, this ensures that we dont trample |
| 78 | * on the current report in the sram while the notify packet is being delivered |
| 79 | */ |
| 80 | ENTRY_NP(send_diag_erpt) |
| 81 | #if defined(CONFIG_FPGA) && defined(CONFIG_SVC) |
| 82 | CPU_PUSH(%g7, %g4, %g5, %g6) /* save return addr */ |
| 83 | CPU_PUSH(%g2, %g4, %g5, %g6) /* save unsent flag ptr */ |
| 84 | ROOT_STRUCT(%g6) |
| 85 | add %g6, CONFIG_SRAM_ERPT_BUF_INUSE, %g5 |
| 86 | mov ERR_BUF_BUSY, %g4 |
| 87 | casx [%g5], %g0, %g4 |
| 88 | brnz,pn %g4, 1f /* buf busy, flag it */ |
| 89 | nop |
| 90 | ldx [%g6 + CONFIG_ERPT_PA], %g2 /* erpt buffer (dest) */ |
| 91 | brz %g2, 2f /* no buffer */ |
| 92 | add %g2, 7, %g2 /* align pa */ |
| 93 | andn %g2, 7, %g2 |
| 94 | HVCALL(xcopy) /* send erpt */ |
| 95 | ldx [%g6 + CONFIG_ERROR_SVCH], %g1 /* error service */ |
| 96 | brz %g1, 2f /* skip if no svc */ |
| 97 | add %g6, CONFIG_ERPT_PA, %g2 /* error present pkt */ |
| 98 | add %g0, ERPT_SVC_PKT_SIZE, %g3 /* pkt len */ |
| 99 | HVCALL(svc_internal_send) /* send erpt */ |
| 100 | brnz,a,pt %g1, 1f |
| 101 | ldx [%g2 + CPU_ROOT], %g6 /* config data */ |
| 102 | CPU_POP(%g4, %g1, %g2, %g3) /* restore unsent flag ptr */ |
| 103 | st %g0, [%g4] /* flag as no need to send */ |
| 104 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 105 | HVRET |
| 106 | 1: |
| 107 | /* |
| 108 | * SRAM is busy, flag so it gets sent later |
| 109 | * %g6 still contains the ROOT |
| 110 | */ |
| 111 | CPU_POP(%g4, %g1, %g2, %g3) |
| 112 | mov 1, %g3 |
| 113 | st %g3, [%g4] /* flag pkt */ |
| 114 | add %g6, CONFIG_ERRS_TO_SEND, %g6 |
| 115 | ldx [%g6], %g1 |
| 116 | 0: add %g1, 1, %g3 |
| 117 | casx [%g6], %g1, %g3 |
| 118 | cmp %g1, %g3 |
| 119 | bne,a,pn %xcc, 0b |
| 120 | mov %g3, %g1 |
| 121 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 122 | HVRET |
| 123 | 2: |
| 124 | CPU_POP(%g4, %g1, %g2, %g3) /* pop unsent flag ptr */ |
| 125 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 126 | HVRET |
| 127 | #else /* !(CONFIG_FPGA && CONFIG_SVC) */ |
| 128 | HVRET |
| 129 | #endif /* CONFIG_FPGA && CONFIG_SVC */ |
| 130 | SET_SIZE(send_diag_erpt) |
| 131 | |
| 132 | /* |
| 133 | * send_diag_erpt_nolock - send the diag error report. The offset of the error |
| 134 | * report buffwe is passed in as E_OFF |
| 135 | * |
| 136 | * %g1 - erpt |
| 137 | * %g2 - ptr to sent flag |
| 138 | * %g3 - packet size |
| 139 | * %g7 - return address |
| 140 | * %g4 - %g6 used and garbbled |
| 141 | * |
| 142 | * For service delivery the flag is not cleared until the packet |
| 143 | * has been received (ACK) by the SP, this ensures that we dont trample |
| 144 | * on the current report in the sram while the notify packet is being delivered |
| 145 | */ |
| 146 | ENTRY_NP(send_diag_erpt_nolock) |
| 147 | #ifdef NO_SVC_EREPORTS |
| 148 | HVRET |
| 149 | #endif |
| 150 | #if defined(CONFIG_FPGA) && defined(CONFIG_SVC) |
| 151 | CPU_PUSH(%g7, %g4, %g5, %g6) /* save unsent flag ptr */ |
| 152 | CPU_PUSH(%g2, %g4, %g5, %g6) /* save return addr */ |
| 153 | ROOT_STRUCT(%g6) |
| 154 | add %g6, CONFIG_SRAM_ERPT_BUF_INUSE, %g5 |
| 155 | mov ERR_BUF_BUSY, %g4 |
| 156 | casx [%g5], %g0, %g4 |
| 157 | brnz,pn %g4, 1f /* buf busy, flag it */ |
| 158 | nop |
| 159 | ldx [%g6 + CONFIG_ERPT_PA], %g2 /* erpt buffer (dest) */ |
| 160 | brz %g2, 2f /* no buffer */ |
| 161 | add %g2, 7, %g2 /* align pa */ |
| 162 | andn %g2, 7, %g2 |
| 163 | HVCALL(xcopy) /* send erpt */ |
| 164 | ldx [%g6 + CONFIG_ERROR_SVCH], %g1 /* error service */ |
| 165 | brz %g1, 2f /* skip if no svc */ |
| 166 | add %g6, CONFIG_ERPT_PA, %g2 /* error present pkt */ |
| 167 | add %g0, ERPT_SVC_PKT_SIZE, %g3 /* pkt len */ |
| 168 | HVCALL(svc_internal_send_nolock) /* send erpt */ |
| 169 | ROOT_STRUCT(%g6) |
| 170 | ldx [%g6 + CONFIG_ERROR_SVCH], %g6 /* error service handle */ |
| 171 | ld [%g6 + SVC_CTRL_STATE], %g5 |
| 172 | andn %g5, SVC_FLAGS_RI, %g5 |
| 173 | st %g5, [%g6 + SVC_CTRL_STATE] ! clear RECV pending |
| 174 | UNLOCK(%g6, SVC_CTRL_LOCK) |
| 175 | ROOT_STRUCT(%g6) |
| 176 | ldx [%g6 + CONFIG_SVCS], %g6 ! svc root |
| 177 | UNLOCK(%g6, HV_SVC_DATA_LOCK) |
| 178 | CPU_POP(%g4, %g1, %g2, %g3) |
| 179 | st %g0, [%g4] /* flag as no need to send */ |
| 180 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 181 | HVRET |
| 182 | 1: |
| 183 | /* |
| 184 | * SRAM is busy, flag so it gets sent later |
| 185 | * %g6 still contains the ROOT |
| 186 | */ |
| 187 | CPU_POP(%g4, %g1, %g2, %g3) |
| 188 | mov 1, %g3 |
| 189 | st %g3, [%g4] /* flag pkt */ |
| 190 | add %g6, CONFIG_ERRS_TO_SEND, %g6 |
| 191 | ldx [%g6], %g1 |
| 192 | 0: add %g1, 1, %g3 |
| 193 | casx [%g6], %g1, %g3 |
| 194 | cmp %g1, %g3 |
| 195 | bne,a,pn %xcc, 0b |
| 196 | mov %g3, %g1 |
| 197 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 198 | |
| 199 | HVRET |
| 200 | 2: |
| 201 | CPU_POP(%g4, %g1, %g2, %g3) /* pop unsent flag ptr */ |
| 202 | CPU_POP(%g7, %g1, %g2, %g3) /* restore callers return */ |
| 203 | HVRET |
| 204 | #else /* !(CONFIG_FPGA && CONFIG_SVC) */ |
| 205 | HVRET |
| 206 | #endif /* CONFIG_FPGA && CONFIG_SVC */ |
| 207 | SET_SIZE(send_diag_erpt_nolock) |