| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: FcNiu_Trap_Handler.s |
| 5 | * Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved |
| 6 | * 4150 Network Circle, Santa Clara, California 95054, U.S.A. |
| 7 | * |
| 8 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; version 2 of the License. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
| 23 | * For the avoidance of doubt, and except that if any non-GPL license |
| 24 | * choice is available it will apply instead, Sun elects to use only |
| 25 | * the General Public License version 2 (GPLv2) at this time for any |
| 26 | * software where a choice of GPL license versions is made |
| 27 | * available with the language indicating that GPLv2 or any later version |
| 28 | * may be used, or where a choice of which version of the GPL is applied is |
| 29 | * otherwise unspecified. |
| 30 | * |
| 31 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 32 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 33 | * have any questions. |
| 34 | * |
| 35 | * |
| 36 | * ========== Copyright Header End ============================================ |
| 37 | */ |
| 38 | #include "niu_defines.h" |
| 39 | #include "ncu_defines.h" |
| 40 | #include "niu_macros.h" |
| 41 | /* ******************************************************************** */ |
| 42 | /* NIU Tx DMA and Rx-DMA initialization for TRAPS */ |
| 43 | /* ******************************************************************** */ |
| 44 | HTrap_NIU_TxDma_Init: |
| 45 | save |
| 46 | nop |
| 47 | HTrap_NIU_TxDMAActivate: |
| 48 | setx MAC_ID, %g1, %o0 ! 1st Parameter |
| 49 | setx SetTxDMAActive_list, %g1, %o1 ! 2st parameter |
| 50 | call SetTxDMAActive |
| 51 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_TxDMAActivate)) -> NIU_TxDMAActivate (MAC_ID, TxDmaActive_list) |
| 52 | |
| 53 | HTrap_NIU_AddTxChannels : |
| 54 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_AddTxChannels)) -> NIU_AddTxChannels(MAC_ID, NIU_TxDmaNoUE) |
| 55 | |
| 56 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 ! Just for delay |
| 57 | nop |
| 58 | |
| 59 | HTrap_NIU_SetTxMaxBurst : |
| 60 | setx NIU_TxDmaNo, %g1, %o0 ! 1st parameter : |
| 61 | setx SetTxMaxBurst_Data, %g1, %o1 ! 2nd parameter |
| 62 | call SetTxMaxBurst |
| 63 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_SetTxMaxBurst)) -> NIU_SetTxMaxBurst (MAC_ID, NIU_TxDmaNoUE, TxMaxBurst_Data) |
| 64 | |
| 65 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 ! Just for delay |
| 66 | nop |
| 67 | |
| 68 | HTrap_NIU_InitTxDma: |
| 69 | setx NIU_TxDmaNo, %g1, %o0 ! 1st parameter : |
| 70 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_InitTxDma)) -> NIU_InitTxDma (MAC_ID, NIU_TxDmaNoUE, NIU_Xlate_On) |
| 71 | call InitTxDma |
| 72 | nop |
| 73 | |
| 74 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 ! Just for delay |
| 75 | nop |
| 76 | |
| 77 | ret |
| 78 | restore |
| 79 | HTrap_NIU_TxDma_Init_Done: |
| 80 | |
| 81 | /* ******************************************************************** */ |
| 82 | |
| 83 | HTrap_NIU_RxDma_Init: |
| 84 | save |
| 85 | nop |
| 86 | HTrap_NIU_RxInitDma: |
| 87 | nop !$EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_RxInitDma)) -> NIU_InitRxDma(RXDMA_CHNL, RX_DESC_RING_LENGTH, RX_COMPL_RING_LEN,, RBR_CONFIG_B_DATA_UE, RX_INITIAL_KICK, NIU_Xlate_On) |
| 88 | |
| 89 | setx 0x5, %g1, %g4 ! Delay for Vera to complete |
| 90 | HTrap_delay_loop_Rx: |
| 91 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 |
| 92 | nop |
| 93 | nop |
| 94 | nop |
| 95 | nop |
| 96 | dec %g4 |
| 97 | brnz %g4, HTrap_delay_loop_Rx |
| 98 | nop |
| 99 | |
| 100 | nop |
| 101 | setx RXDMA_CHNL, %g1, %o0 |
| 102 | setx RX_DESC_RING_LENGTH, %g1, %o1 |
| 103 | setx RX_COMPL_RING_LEN, %g1, %o2 |
| 104 | setx RBR_CONFIG_B_DATA, %g1, %o3 |
| 105 | setx RX_INITIAL_KICK, %g1, %o4 |
| 106 | call NiuInitRxDma |
| 107 | nop |
| 108 | |
| 109 | ret |
| 110 | restore |
| 111 | HTrap_NIU_RxDma_Init_Done: |
| 112 | |
| 113 | /* ******************************************************************** */ |
| 114 | /* ISR for kicking in Tx packets */ |
| 115 | /* ******************************************************************** */ |
| 116 | HTrap_NIU_Tx: |
| 117 | save |
| 118 | nop |
| 119 | |
| 120 | HTrap_NIU_Tx_PktConfig: |
| 121 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_Tx_PktConfig)) -> pktGenConfig(MAC_ID, FRAME_TYPE, FRAME_CLASS, HTRAP_NIU_TX_PKT_LEN) |
| 122 | |
| 123 | HTrap_NIU_Tx_Gen_Packet: |
| 124 | nop ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_Tx_Gen_Packet)) -> TxPktGen(MAC_ID, NIU_TxDmaNoUE, HTRAP_NIU_TX_PKT_CNT) |
| 125 | nop |
| 126 | |
| 127 | setx 0x5, %g1, %g4 |
| 128 | HTrap_NIU_delay_loop_tmp: |
| 129 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 |
| 130 | nop |
| 131 | nop |
| 132 | nop |
| 133 | nop |
| 134 | dec %g4 |
| 135 | brnz %g4, HTrap_NIU_delay_loop_tmp |
| 136 | nop |
| 137 | |
| 138 | |
| 139 | HTrap_SetTxRingKick: |
| 140 | setx 0x100000100, %g1, %g2 ! $EV trig_pc_d(1, @VA(.MAIN.HTrap_SetTxRingKick)) -> NIU_SetTxRingKick(MAC_ID, NIU_TxDmaNoUE) |
| 141 | setx NIU_TxDmaNo, %g1, %o0 |
| 142 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g3 |
| 143 | nop |
| 144 | mulx %o0, 0x200, %g5 |
| 145 | setx TX_RING_KICK_Addr, %g1, %g2 |
| 146 | add %g2, %g5, %g2 |
| 147 | stxa %g3, [%g2]ASI_PRIMARY_LITTLE |
| 148 | nop |
| 149 | |
| 150 | HTrap_SetTxCs : |
| 151 | setx NIU_TxDmaNo, %g1, %o0 |
| 152 | setx TX_CS_Data, %g1, %g3 |
| 153 | mulx %o0, 0x200, %g5 |
| 154 | setx TX_CS_Addr, %g1, %g2 |
| 155 | add %g2, %g5, %g2 |
| 156 | stxa %g3, [%g2]ASI_PRIMARY_LITTLE |
| 157 | nop |
| 158 | |
| 159 | ba HTrap_NIU_Tx_Done |
| 160 | nop |
| 161 | |
| 162 | HTrap_NIU_Tx_Passed: |
| 163 | nop ! $EV trig_pc_d(1, @VA(.MAIN.test_passed_tx)) -> NIU_EXIT_chk(MAC_ID) |
| 164 | EXIT_GOOD |
| 165 | |
| 166 | HTrap_NIU_Tx_Done: |
| 167 | ret |
| 168 | restore |
| 169 | |
| 170 | |
| 171 | /* ******************************************************************** */ |
| 172 | /* ISR for kicking in Rx packets */ |
| 173 | /* ******************************************************************** */ |
| 174 | HTrap_NIU_Rx: |
| 175 | save |
| 176 | nop |
| 177 | |
| 178 | HTrap_NIU_RxPkt_Conf: |
| 179 | nop !$EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_RxPkt_Conf)) -> NIU_RxPktConf(HTRAP_NIU_RXMAC_PKTCNT) |
| 180 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 ! Just for Delay |
| 181 | nop |
| 182 | |
| 183 | HTrap_NIU_Rx_GenPkt: |
| 184 | setx HTRAP_NIU_RXMAC_PKTCNT, %g1, %g6 ! Packet count |
| 185 | nop |
| 186 | HTrap_NIU_Rx_pktcnt_loop: |
| 187 | nop !$EV trig_pc_d(1, @VA(.MAIN.HTrap_NIU_Rx_pktcnt_loop)) -> NIU_RxGenPkt(MAC_ID, RXDMA_CHNL, 1, HTRAP_NIU_MAC_PKT_LEN, 1) |
| 188 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g5 ! just for delay |
| 189 | nop |
| 190 | dec %g6 |
| 191 | brnz %g6, HTrap_NIU_Rx_pktcnt_loop |
| 192 | nop |
| 193 | |
| 194 | ret |
| 195 | restore |
| 196 | |
| 197 | HTrap_NIU_Rx_Done: |
| 198 | /* ******************************************************************** */ |
| 199 | /* Setup NCU for NIU Traps */ |
| 200 | /* ******************************************************************** */ |
| 201 | HTrap_NCU_Setup: |
| 202 | save |
| 203 | nop |
| 204 | HTrap_Clear_All_Ints: |
| 205 | rdpr %pstate, %g7 |
| 206 | xor %g7, 0x2, %g7 ! Reset interrupt enable |
| 207 | wrpr %g7, %pstate |
| 208 | |
| 209 | HTrap_NCU_Init_MAN: |
| 210 | ! Initially set all the Interrupt Management Registers |
| 211 | ! Later will set all those not used to have a different vector number |
| 212 | |
| 213 | setx INT_MAN, %g1, %g2 ! %g2 = INT_MAN reg. addr. |
| 214 | setx INT_MAN_COUNT, %g1, %g4 ! %g4 = INT_MAN reg. count value |
| 215 | set 1, %g5 ! %g5 = value to write to INT_MAN reg. |
| 216 | |
| 217 | HTrap_NCU_Init_Man_loop: |
| 218 | stx %g5, [%g2] |
| 219 | add %g2, INT_MAN_STEP, %g2 |
| 220 | cmp %g4, 1 |
| 221 | bne HTrap_NCU_Init_Man_loop |
| 222 | add %g4, -1, %g4 |
| 223 | |
| 224 | /* Initialize the NIU for TX DMA interrupt. */ |
| 225 | |
| 226 | NIU_TX_LD_IM0_INTR_ON_MARK( NIU_TxDmaNo, %g1, %g2, %g3, %g4, 0 ) |
| 227 | |
| 228 | ! Enable interrupts |
| 229 | |
| 230 | HTrap_Int_En: |
| 231 | rdpr %pstate, %g7 |
| 232 | or %g7, 0x2, %g7 ! Set interrupt enable |
| 233 | wrpr %g7, %pstate |
| 234 | |
| 235 | HTrap_NCU_Setup_Done: |
| 236 | ret |
| 237 | restore |
| 238 | /* ******************************************************************** */ |
| 239 | /* Trap code */ |
| 240 | /* ******************************************************************** */ |
| 241 | |
| 242 | NIU_Trap_Handler: |
| 243 | |
| 244 | setx 0x300000000, %l2, %l6 |
| 245 | ld [%l6], %l5 |
| 246 | add %l5, 1, %l5 |
| 247 | st %l5, [%l6] |
| 248 | membar #Sync |
| 249 | |
| 250 | ! Clear the interrupt in the core |
| 251 | ldxa [%g0]ASI_SWVR_INTR_R, %l3 |
| 252 | |
| 253 | setx TX_CS, %g1, %g2 ! TX_CS, Tx DMA channel 0 |
| 254 | ldxa [%g2]ASI_PRIMARY_LITTLE, %g1 ! Reset MK |
| 255 | nop |
| 256 | |
| 257 | setx LDGIMGN, %g1, %g2 ! logical device group 0 |
| 258 | setx 0x80000001, %g1, %g3 |
| 259 | stxa %g3, [%g2]ASI_PRIMARY_LITTLE |
| 260 | nop |
| 261 | #ifdef KICK_NIU_TX |
| 262 | call HTrap_NIU_Tx |
| 263 | nop |
| 264 | #endif |
| 265 | |
| 266 | #ifdef KICK_NIU_RX |
| 267 | call HTrap_NIU_Rx |
| 268 | nop |
| 269 | #endif |
| 270 | |
| 271 | NIU_Trap_Handler_Done: |
| 272 | jmpl %o7+0x8, %g0 |
| 273 | nop |
| 274 | |
| 275 | /* ******************************************************************** */ |