* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: interrupt_niu_device_id.s
* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For the avoidance of doubt, and except that if any non-GPL license
* choice is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any
* software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later version
* may be used, or where a choice of which version of the GPL is applied is
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* ========== Copyright Header End ============================================
#define MAIN_PAGE_HV_ALSO
#define H_HT0_Interrupt_0x60
#define My_HT0_Interrupt_0x60 \
/************************************************************************
************************************************************************/
/* Initialize the NCU for the interrupt. */
xor %g7, 0x2, %g7 ! Reset interrupt enable
! Initially set all the Interrupt Management Registers
setx INT_MAN, %g1, %g2 ! %g2 = INT_MAN reg. addr.
setx INT_MAN_COUNT, %g1, %g3 ! %g3 = INT_MAN reg. count value
add %g7, 1, %g7 ! increment the vector number
addx %g2, INT_MAN_STEP, %g2
! The second half of the Interrupt Management Registers
! get a decrementing value for vector number.
sub %g7, 1, %g7 ! decrement the vector number
addx %g2, INT_MAN_STEP, %g2
! Initialize the NIU for TX DMA interrupt.
NIU_TX_LD_IM0_INTR_ON_MARK( 0, %g1, %g2, %g3, %g4, 0, 64 )
setx user_data_start, %g1, %2
st %g1, [%g2] ! Record first device number used
or %g7, 0x2, %g7 ! Set interrupt enable
! Generate the interrupt via PIO write
setx TDMC_INTR_DBG, %g1, %g2
setx 0x8000, %g1, %g4 ! Force the MK flag
stxa %g4, [%g2]ASI_PRIMARY_LITTLE
! Have 16 interrupts occured?
setx 0x1000, %g1, %g4 ! timeout loop count
setx user_data_start, %g1, %g2
! ! Now do 64 more interrupts to use reset of Interrupt Management regs.
! ! Generate the interrupt via PIO write
! setx half_time_flag, %g1, %g2
! ! Have 65 more interrupts occured?
! setx 0x1000, %g1, %g4 ! timeout loop count
! setx user_data_start, %g1, %g2
/**********************************************************************
**********************************************************************/
!!! Careful when changing this interrupt trap handler code
!!! Several registers need to keep their values throughout
!!! the whole trap handler. So check before making changes!!!
! Get the expected vector number.
ldxa [%g0]ASI_INTR_RECEIVE, %g1
setx user_data_start, %l2, %l6
! Clear the interrupt in the core & get vector number
ldxa [%g0]ASI_SWVR_INTR_R, %l3
! ! Increment/decrement the expected vector number.
! setx half_time_flag, %l1, %l2
! cmp %l5, 63 ! If 63 & !half_time yet, don't change
! Change the TX dma channel & logical device group to use.
! Increment the Tx dma channel number
Trap3: setx tx_dma_num, %g1, %g2
! But first clear the interrupt in the NIU's Tx DMA channel
ldxa [%g6]ASI_PRIMARY_LITTLE, %g5 ! Read clears interrupt, MK bit
and %g3, %g1, %g3 ! Only values 0->15 are value
st %g3, [%g2] ! for Tx dma channel numbers
! Increment the logical device group number
setx my_ldg_num, %g1, %g2
! Assign the Tx dma channel to the logical device group
add %g3, 32, %g7 ! Convert Tx dma channel number
! to logical device number
setx LDG_NUM_STEP, %g1, %g6
stxa %g4, [%g5]ASI_PRIMARY_LITTLE
! Enable interrupts for the logical device
setx LD_IM0_STEP, %g1, %g5
stxa %g0, [%g2]ASI_PRIMARY_LITTLE
! Arm interrupts in the logical device group
setx LDGIMGN_STEP, %g1, %g6
setx LDGIMGN, %g1, %g2 ! LDGIMGN
setx 0x80000001, %g1, %g5
stxa %g5, [%g2]ASI_PRIMARY_LITTLE
! Increment and set the device ID to send to the NCU
setx user_data_start, %g1, %g2
stxa %g6, [%g2]ASI_PRIMARY_LITTLE
! Enable interrupts in th TX dma channel
setx TX_ENT_MSK, %g1, %g2
stxa %g0, [%g2]ASI_PRIMARY_LITTLE
! Generate another interrupt, but no more that 16
be Trap12 ! Branch if already done 16
setx TDMC_INTR_DBG, %g1, %g2
setx 0x8000, %g1, %g5 ! Force the MK flag
stxa %g5, [%g2]ASI_PRIMARY_LITTLE
/************************************************************************
************************************************************************/