Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: niu_int_sidmgr.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 "pio_memory_map.vri" | |
37 | #include "pio_driver.vrh" | |
38 | ||
39 | extern niu_gen_pio gen_pio_drv; | |
40 | ||
41 | class CSidShadowTab { | |
42 | ||
43 | bit [63:0] valid; | |
44 | local integer ShTab[]; | |
45 | task new(); | |
46 | function integer deleteSidTab(integer gid, bit [6:0] data) ; | |
47 | function integer updateSidTab(integer gid, bit [6:0] data) ; | |
48 | task pio_writeSidTab(integer gid, bit [6:0] data) ; | |
49 | task pio_readSidTab(integer gid, var bit [6:0] data) ; | |
50 | task RemoveSidTab(integer gid) ; | |
51 | function integer getGid(var integer gid, bit [6:0] data); | |
52 | } | |
53 | ||
54 | task CSidShadowTab::new() { | |
55 | valid = 0; | |
56 | } | |
57 | ||
58 | task CSidShadowTab::RemoveSidTab(integer gid) { | |
59 | bit [6:0] data; | |
60 | bit[63:0] address,wdata; | |
61 | integer status; | |
62 | pio_readSidTab(gid,data); | |
63 | status = deleteSidTab(gid,data); | |
64 | address = NIU_SID + 8*gid; | |
65 | wdata = 64'h0; | |
66 | gen_pio_drv.pio_wr(address,wdata); | |
67 | } | |
68 | function integer CSidShadowTab::deleteSidTab(integer gid, bit [6:0] data) { | |
69 | integer status; | |
70 | if(assoc_index(CHECK,ShTab,data)) { | |
71 | status = assoc_index(DELETE,ShTab,data); | |
72 | deleteSidTab = 1; | |
73 | valid[gid]=0; | |
74 | } else { | |
75 | deleteSidTab = 0; | |
76 | } | |
77 | } | |
78 | function integer CSidShadowTab::updateSidTab(integer gid, bit [6:0] data) { | |
79 | if(assoc_index(CHECK,ShTab,data)) { | |
80 | printf(" SID - %x Already exists in the tables !! Skipping the update \n"); | |
81 | updateSidTab = -1; | |
82 | } else { | |
83 | ShTab[data] = gid; | |
84 | updateSidTab = 1; | |
85 | } | |
86 | } | |
87 | ||
88 | task CSidShadowTab::pio_writeSidTab(integer gid, bit [6:0] data) { | |
89 | integer status; | |
90 | bit [63:0] address; | |
91 | bit[63:0] wdata; | |
92 | ||
93 | status = updateSidTab(gid,data); | |
94 | if(status !=-1) { | |
95 | address = NIU_SID + 8*gid; | |
96 | wdata = { 57'h0,data}; | |
97 | gen_pio_drv.pio_wr(address,wdata); | |
98 | valid [gid] = 1; | |
99 | } else { | |
100 | printf("CSidShadowTab::pio_writeSidTab TB ERROR \n"); | |
101 | } | |
102 | } | |
103 | task CSidShadowTab::pio_readSidTab(integer gid, var bit [6:0] data) { | |
104 | integer status; | |
105 | bit [63:0] address; | |
106 | bit[63:0] rdata; | |
107 | ||
108 | address = NIU_SID + 8*gid; | |
109 | gen_pio_drv.pio_rd(address,rdata); | |
110 | data = rdata[6:0]; | |
111 | } | |
112 | ||
113 | function integer CSidShadowTab::getGid(var integer gid, bit [6:0] data){ | |
114 | integer status; | |
115 | if(assoc_index(CHECK,ShTab,data)) { | |
116 | gid = ShTab[data]; | |
117 | status = 1; | |
118 | } else { | |
119 | status = 0; | |
120 | gid = -1; | |
121 | } | |
122 | getGid = status; | |
123 | } | |
124 | ||
125 |