Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: N2_PioAsi.cc | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | ||
22 | #include <iostream> | |
23 | #include <unistd.h> | |
24 | #include "N2_PioAsi.h" | |
25 | #include "N2_Model.h" | |
26 | #include "SS_Io.h" | |
27 | #include "N2_Cpu.h" | |
28 | #include "N2_Core.h" | |
29 | #include "N2_Strand.h" | |
30 | ||
31 | using namespace std; | |
32 | ||
33 | N2_PioAsi::N2_PioAsi( N2_Model* _model, SS_AddressMap* map, SS_Paddr lo, SS_Paddr hi )/*{{{*/ | |
34 | : | |
35 | model(_model), | |
36 | base(lo) | |
37 | { | |
38 | //TODO is it too much to register the entire block from 0x9001040000 to | |
39 | // 0x9001cc0000? | |
40 | ||
41 | // NCU_ASI_COREAVAIL = 0x9001040000; | |
42 | // NCU_ASI_CORE_ENABLE_STATUS = 0x9001040010; | |
43 | // NCU_ASI_CORE_ENABLE = 0x9001040020; | |
44 | // NCU_ASI_XIR_STEERING = 0x9001040030; | |
45 | // NCU_ASI_TICK_ENABLE = 0x9001040038; | |
46 | // NCU_ASI_CORE_RUNNINGRW = 0x9001040050; | |
47 | // NCU_ASI_CORE_RUNNING_STATUS = 0x9001040058; | |
48 | // NCU_ASI_CORE_RUNNING_W1S = 0x9001040060; | |
49 | // NCU_ASI_CORE_RUNNING_W1C = 0x9001040068; | |
50 | // NCU_ASI_OVERLAP_MODE = 0x9001140010; | |
51 | // NCU_ASI_WMR_VEC_MASK = 0x9001140018; | |
52 | // NCU_ASI_INTVECDISP = 0x9001cc0000; | |
53 | ||
54 | if ((lo != 0x9001040000) || (hi != 0x9001cc0000+7)) | |
55 | { | |
56 | cerr << "ERROR: N2_PioAsi (0x9001040000..0x9001cc0000) being given wrong range, lo=0x" << hex << lo << " hi=0x" << hi << endl; | |
57 | return; | |
58 | } | |
59 | map->add(lo,hi,this,SS_AddressMap::REL,N2_PioAsi::access); | |
60 | } | |
61 | /*}}}*/ | |
62 | N2_PioAsi::~N2_PioAsi()/*{{{*/ | |
63 | { | |
64 | } | |
65 | /*}}}*/ | |
66 | ||
67 | void N2_PioAsi::access( void* obj, uint_t sid, SS_Access::Type type, SS_Paddr pa, uint_t size, uint64_t* data )/*{{{*/ | |
68 | { | |
69 | N2_PioAsi* self = (N2_PioAsi*)obj; | |
70 | pa += self->base; | |
71 | ||
72 | // PA[39:32] = 0x90 | |
73 | // PA[31:29] = core_id[2:0] (physical core id) | |
74 | // PA[28:26] = tid[2:0] (thread id within a core) | |
75 | // PA[25:18] = asi[7:0] | |
76 | // PA[17:3] = VA[17:3] | |
77 | // PA[2:0] = 000 | |
78 | ||
79 | int tid = (pa >> 26) & 0x3f; | |
80 | int asi = (pa >> 18) & 0xff; | |
81 | int va = ((pa >> 3) & 0x7fff) << 3; | |
82 | ||
83 | SS_Strand* strand = self->model->cpu[0]->strand[tid]; | |
84 | ||
85 | switch (type) | |
86 | { | |
87 | case SS_Access::LOAD: | |
88 | strand->asi_map.ld64(strand, asi, va, data); | |
89 | break; | |
90 | case SS_Access::STORE: | |
91 | strand->asi_map.st64(strand, asi, va, *data); | |
92 | break; | |
93 | default: | |
94 | assert(0); | |
95 | } | |
96 | } | |
97 | /*}}}*/ | |
98 | ||
99 |