Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_dma.vr | |
4 | // Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | // 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | // | |
7 | // * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | // | |
9 | // This program is free software; you can redistribute it and/or modify | |
10 | // it under the terms of the GNU General Public License as published by | |
11 | // the Free Software Foundation; version 2 of the License. | |
12 | // | |
13 | // This program is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License | |
19 | // along with this program; if not, write to the Free Software | |
20 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | // | |
22 | // For the avoidance of doubt, and except that if any non-GPL license | |
23 | // choice is available it will apply instead, Sun elects to use only | |
24 | // the General Public License version 2 (GPLv2) at this time for any | |
25 | // software where a choice of GPL license versions is made | |
26 | // available with the language indicating that GPLv2 or any later version | |
27 | // may be used, or where a choice of which version of the GPL is applied is | |
28 | // otherwise unspecified. | |
29 | // | |
30 | // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | // CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | // have any questions. | |
33 | // | |
34 | // ========== Copyright Header End ============================================ | |
35 | #include <vera_defines.vrh> | |
36 | #include <ListMacros.vrh> | |
37 | #include "niu_dmc_descr.vrh" | |
38 | #include "niu_dmc_descr_ring.vrh" | |
39 | ||
40 | #include "niu_int_dev.vrh" | |
41 | #include "niu_dma_bind.vrh" | |
42 | ||
43 | extern CNiuDMABind NiuDMABind; | |
44 | ||
45 | class CDMA extends CNiuIntrDev { | |
46 | integer id; | |
47 | integer type; //0=Tx or 1=Rx | |
48 | ||
49 | integer group_no = -1; | |
50 | integer function_no =-1; | |
51 | integer en_pio_virt=0; | |
52 | ||
53 | integer address_incr; // either 4 or 8 depending upon Tx or Rx | |
54 | ||
55 | ||
56 | // partition support shadow variables | |
57 | bit [63:0] ring_lpvalid; | |
58 | bit [63:0] ring_lpmask1; | |
59 | bit [63:0] ring_lpvalue1; | |
60 | bit [63:0] ring_lpmask2; | |
61 | bit [63:0] ring_lpvalue2; | |
62 | bit [63:0] ring_lprelo1; | |
63 | bit [63:0] ring_lprelo2; | |
64 | bit [63:0] ring_lphandle; | |
65 | ||
66 | // descriptor_ring -- - | |
67 | CDescrRing desc_ring; | |
68 | ||
69 | function bit[63:0] translate_address(bit[63:0] sw_address); | |
70 | virtual function integer isr( ( bit[1:0] ldf_flags = 0) ){} | |
71 | task SetDMAGroupBind( integer g); | |
72 | task ResetDMAGroupBind( integer g); | |
73 | function integer isDMABound(integer dma_no, integer tx_or_rx, integer group_no); | |
74 | function bit[63:0] getPIOAddress( bit[63:0] address, (integer pass_through=1)); | |
75 | task new( integer i, integer t, (integer intr_dev_id = 0) ) { | |
76 | super.new(intr_dev_id); | |
77 | id = i; | |
78 | type = t; | |
79 | } | |
80 | task SetDefFunc(integer func) { | |
81 | NiuDMABind.SetDefFunc(func,type,id); | |
82 | } | |
83 | } | |
84 | function bit[63:0] CDMA::getPIOAddress( bit[63:0] address, (integer pass_through=1)) { | |
85 | ||
86 | getPIOAddress = NiuDMABind.getPIOAddress(id, type, group_no, address, pass_through); | |
87 | ||
88 | } | |
89 | ||
90 | task CDMA::SetDMAGroupBind( integer g){ | |
91 | group_no = g; | |
92 | printf("CDMA::SetDMAGroupBind Group - %d DMA - %d \n",g,id); | |
93 | if(group_no<=15) { | |
94 | function_no = 0; | |
95 | } else if(group_no<=31) { | |
96 | function_no = 1; | |
97 | } else if(group_no<=47) { | |
98 | function_no = 2; | |
99 | } else if(group_no<=63) { | |
100 | function_no = 3; | |
101 | } else { | |
102 | printf(" ERROR Incorrect Group Number Specified for DMA - %d \n",id); | |
103 | } | |
104 | ||
105 | if(type==0) // TX | |
106 | NiuDMABind.SetTxBind(id,group_no); | |
107 | else // RX | |
108 | NiuDMABind.SetRxBind(id,group_no); | |
109 | ||
110 | } | |
111 | ||
112 | function integer CDMA::isDMABound(integer dma_no, integer tx_or_rx, integer group_no) { | |
113 | isDMABound = NiuDMABind.isDMABound(dma_no, tx_or_rx, group_no); | |
114 | } | |
115 | ||
116 | task CDMA::ResetDMAGroupBind( integer g){ | |
117 | group_no = g; | |
118 | printf("CDMA::ResetDMAGroupBind Group - %d DMA - %d \n",g,id); | |
119 | if(group_no<=15) { | |
120 | function_no = 0; | |
121 | } else if(group_no<=31) { | |
122 | function_no = 1; | |
123 | } else if(group_no<=47) { | |
124 | function_no = 2; | |
125 | } else if(group_no<=63) { | |
126 | function_no = 3; | |
127 | } else { | |
128 | printf(" ERROR Incorrect Group Number Specified for DMA - %d \n",id); | |
129 | } | |
130 | ||
131 | if(type==0) // TX | |
132 | NiuDMABind.ResetTxBind(id,group_no); | |
133 | else // RX | |
134 | NiuDMABind.ResetRxBind(id,group_no); | |
135 | ||
136 | group_no = -1; | |
137 | } | |
138 | ||
139 | ||
140 | function bit[63:0] CDMA ::translate_address(bit[63:0] sw_address) | |
141 | { | |
142 | integer loop=0; | |
143 | bit [31:0] mask_address; | |
144 | ||
145 | if(ring_lpvalid[0]) { | |
146 | // first check Page0 | |
147 | mask_address = sw_address[43:12] & ring_lpmask1; | |
148 | if(mask_address == ring_lpvalue1) { | |
149 | // translate the address | |
150 | printf("Address within the Page0\n"); | |
151 | translate_address[63:44] = ring_lphandle; | |
152 | for(loop=0;loop<32;loop++) { | |
153 | if(ring_lpmask1[loop]) | |
154 | translate_address[12+loop] = ring_lprelo1[loop]; | |
155 | else | |
156 | translate_address[12+loop] = sw_address[12+loop]; | |
157 | } | |
158 | // translate_address[43:12] = ring_lprelo1 & ring_lpmask1; | |
159 | translate_address[11:0] = sw_address[11:0]; | |
160 | printf("The Trans_Address is %0h\n",translate_address); | |
161 | } else { | |
162 | printf("Page0 enabled, but Address not within Page0\n"); | |
163 | // check for page1 | |
164 | mask_address = sw_address[43:12] & ring_lpmask2; | |
165 | if(mask_address == ring_lpvalue2) { | |
166 | // translate the address | |
167 | printf("Address within the Page1\n"); | |
168 | translate_address[63:44] = ring_lphandle; | |
169 | for(loop=0;loop<32;loop++) { | |
170 | if(ring_lpmask2[loop]) | |
171 | translate_address[12+loop] = ring_lprelo2[loop]; | |
172 | else | |
173 | translate_address[12+loop] = sw_address[12+loop]; | |
174 | } | |
175 | // translate_address[43:12] = ring_lprelo1 & ring_lpmask1; | |
176 | translate_address[11:0] = sw_address[11:0]; | |
177 | printf("The Trans_Address is %0h\n",translate_address); | |
178 | } else { | |
179 | printf("Page1 enabled, but Address not within Page1\n"); | |
180 | translate_address = sw_address; | |
181 | } | |
182 | } | |
183 | } else if(ring_lpvalid[1]) { | |
184 | // check if the address is in Page1 | |
185 | mask_address = sw_address[43:12] & ring_lpmask2; | |
186 | if(mask_address == ring_lpvalue2) { | |
187 | // translate the address | |
188 | printf("Address within the Page1\n"); | |
189 | translate_address[63:44] = ring_lphandle; | |
190 | for(loop=0;loop<32;loop++) { | |
191 | if(ring_lpmask2[loop]) | |
192 | translate_address[12+loop] = ring_lprelo2[loop]; | |
193 | else | |
194 | translate_address[12+loop] = sw_address[12+loop]; | |
195 | } | |
196 | // translate_address[43:12] = ring_lprelo1 & ring_lpmask1; | |
197 | translate_address[11:0] = sw_address[11:0]; | |
198 | printf("The Trans_Address is %0h\n",translate_address); | |
199 | } else { | |
200 | printf("Page1 enabled, but Address not within Page1\n"); | |
201 | translate_address = sw_address; | |
202 | } | |
203 | } else { | |
204 | printf("Neither Page0 or Page1 is defined, Potenial SW_Error\n"); | |
205 | translate_address = sw_address; | |
206 | } | |
207 | } | |
208 | ||
209 | ||
210 |