// ========== Copyright Header Begin ========================================== // // OpenSPARC T2 Processor File: niu_dma_bind.vr // 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 // otherwise unspecified. // // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, // CA 95054 USA or visit www.sun.com if you need additional information or // have any questions. // // ========== Copyright Header End ============================================ #include #include "pio_memory_map.vri" #include "niu_gen_pio.vrh" #include "niu_mem.vrh" #include "niu_cbclass.vrh" #include "mbox_class.vrh" #include "cMesg.vrh" extern niu_gen_pio gen_pio_drv; extern CSparseMem SparseMem; extern mbox_class mbox_id; extern Mesg be_msg; class CNiuDMABind { // Bind Shadows // group to DMA Shadow local bit [31:0] grp_tx_dma_bind[64]; local bit [31:0] grp_rx_dma_bind[64]; local bit[63:0] prog_grps; // DMA to group Shadow local integer tx_dma_grp_bind[64]; local integer rx_dma_grp_bind[64]; // functions numbers per DMA integer tx_dma_func_bind[32]; integer rx_dma_func_bind[32]; local task WriteDMABind(integer group_no, bit[63:0] data); function bit[63:0] ReadDMABind(integer group_no); task SetTxBind( integer dma_no, integer group_no); task SetRxBind( integer dma_no, integer group_no); task ResetTxBind( integer dma_no, integer group_no); task ResetRxBind( integer dma_no, integer group_no); task SetRxTxBind( integer tx_dma_no, integer rx_dma_no, integer group_no); function integer isDMABound(integer dma_no, integer tx_or_rx, integer group_no); function bit[63:0] getPIOAddress( integer dma_no, integer tx_or_rx, integer group_no, bit[63:0] address, (integer pass_through=1) ); function bit[63:0] getFuncNoBase( integer group_no) ; function integer getUnboundPIOAddress(var bit [63:0] address) ; task CheckFunctionBinds(bit [63:0] address,integer func); task InitUnBoundGroups() ; task spCheckFunctionBinds (); task SetDefFunc(integer func,integer type,integer id) ; task new() { integer i; integer func_chk_enable; prog_grps = 64'h0; for(i=0;i<64;i++) { grp_tx_dma_bind[i] = 32'h0; grp_rx_dma_bind[i] = 32'h0; } for(i=0;i<64;i++) { tx_dma_grp_bind[i] = -1; rx_dma_grp_bind[i] = -1; } for(i=0;i<32;i++) { rx_dma_func_bind[i] = -1; tx_dma_func_bind[i] = -1; } } } task CNiuDMABind::SetDefFunc(integer func,integer type,integer id) { if(type==1/*RX*/) { rx_dma_func_bind[id] = func; } else {/*TX*/ tx_dma_func_bind[id] = func; } } task CNiuDMABind::WriteDMABind(integer group_no, bit[63:0] data) { bit[63:0] address; address = DMA_BIND + 8*group_no; gen_pio_drv.pio_wr(address,data); } function bit[63:0] CNiuDMABind::ReadDMABind(integer group_no) { bit[63:0] address; address = DMA_BIND + 8*group_no; gen_pio_drv.pio_rd(address,ReadDMABind); } task CNiuDMABind::SetTxBind( integer dma_no, integer group_no) { // Check if this group is already bound. If so do a RMW bit [63:0] rdata; bit [4:0] d; d = dma_no; // vera issue //if((rx_dma_grp_bind[group_no]!= -1)|(tx_dma_grp_bind[group_no]!= -1)) { // } if((grp_tx_dma_bind[group_no]!= 0) | (grp_rx_dma_bind[group_no]!= 0)) { // group already bound rdata = ReadDMABind(group_no); } else { rdata = 64'h0; } rdata[12:8] = d; rdata[13] = 1; WriteDMABind(group_no,rdata); // update the Shadows tx_dma_grp_bind[dma_no] = group_no; tx_dma_func_bind[dma_no] = group_no/16; grp_tx_dma_bind[group_no] = grp_tx_dma_bind[group_no] | 1<