Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_AsiMap.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: SS_AsiMap.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 "SS_AsiMap.h"
23#include "SS_Strand.h"
24#include <stdio.h>
25
26SS_AsiMap::SS_AsiMap()/*{{{*/
27 :
28 asi_rd(0)
29{
30 for (int ndx = 0; ndx < SS_Asi::MAX; ++ndx)
31 {
32 table[ndx].asi = ndx;
33 }
34}
35/*}}}*/
36void SS_AsiMap::merge( SS_AsiMap& asi_map )/*{{{*/
37{
38 for (uint_t asi=0; asi < SS_Asi::MAX; asi++)
39 table[asi].merge(asi_map.table[asi]);
40}
41/*}}}*/
42void SS_AsiMap::set_mask( SS_Vaddr mask )/*{{{*/
43{
44 for (uint_t asi=0; asi < SS_Asi::MAX; asi++)
45 table[asi].set_mask(mask);
46}
47/*}}}*/
48
49
50 SS_AsiSpace::Error SS_AsiMap::ld64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t* data )
51 {
52 SS_AsiSpace::Error ok = table[asi].ld64(s,addr,data);
53 // @@ha144505, really in cosim we want control over when a loaded value can
54 // be blown away by value sync (follow me). ToDo: return say NO_VALUE from ld64
55 // whan the returned value is allowed to get the data from the DUT.
56 if (ok == SS_AsiSpace::OK)
57 {
58 if (asi_rd)
59 {
60 addr &= table[asi].get_mask();
61 std::map<SS_Vaddr,std::list<uint64_t>*>::iterator i = (*asi_rd)[asi].find(addr);
62 if (i != (*asi_rd)[asi].end())
63 {
64 if ((*i).second->size())
65 {
66 uint64_t temp = (*i).second->front();
67 // asi_read follow-me is use-once-only, remove it after use
68 (*i).second->pop_front();
69 std::map<SS_Vaddr,uint64_t>::const_iterator m = asi_mask[asi].find(addr);
70 if (m != asi_mask[asi].end())
71 *data = (temp & (*m).second) | (*data &~ ((*m).second));
72 else
73 *data = temp;
74 }
75 }
76 }
77
78 if (s->trc_hook)
79 s->trc_hook->asi_access(SS_Tracer::LD_DATA,asi,addr,data);
80 }
81 return ok;
82 }
83
84 SS_AsiSpace::Error SS_AsiMap::st64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t data )
85 {
86 SS_AsiSpace::Error ok = table[asi].st64(s,addr,data);
87 if (ok == SS_AsiSpace::OK && s->trc_hook)
88 s->trc_hook->asi_access(SS_Tracer::ST_DATA,asi,addr,&data);
89
90 return ok;
91 }