Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: SS_AsiMap.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef __SS_AsiMap_h__ | |
24 | #define __SS_AsiMap_h__ | |
25 | ||
26 | #include <map> | |
27 | #include <list> | |
28 | #include "SS_Asi.h" | |
29 | #include "SS_AsiSpace.h" | |
30 | ||
31 | ||
32 | class SS_AsiMap | |
33 | { | |
34 | public: | |
35 | SS_AsiMap(); | |
36 | ||
37 | void merge( SS_AsiMap& asi_map ); | |
38 | ||
39 | // set_asi_read() is used by the cosim environement to provide a per asi table that | |
40 | // contain addr:value pairs that overwrite the value returned by ld64() or rd64(). | |
41 | void set_asi_read( std::map<SS_Vaddr,std::list<uint64_t>*>(* _asi_rd)[SS_Asi::MAX] ) { asi_rd = _asi_rd; } | |
42 | ||
43 | SS_AsiSpace::Error ld64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t* data ); | |
44 | SS_AsiSpace::Error st64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t data ); | |
45 | ||
46 | SS_AsiSpace::Error rd64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t* data ) | |
47 | { | |
48 | SS_AsiSpace::Error ok = table[asi].rd64(s,addr,data); | |
49 | if ((ok == SS_AsiSpace::OK) && asi_rd) | |
50 | { | |
51 | addr &= table[asi].get_mask(); | |
52 | std::map<SS_Vaddr,std::list<uint64_t>*>::iterator i = (*asi_rd)[asi].find(addr); | |
53 | if (i != (*asi_rd)[asi].end()) | |
54 | { | |
55 | if ((*i).second->size()) | |
56 | { | |
57 | uint64_t temp = (*i).second->front(); | |
58 | // asi_read follow-me is use-once-only, remove it after use | |
59 | (*i).second->pop_front(); | |
60 | std::map<SS_Vaddr,uint64_t>::const_iterator m = asi_mask[asi].find(addr); | |
61 | if (m != asi_mask[asi].end()) | |
62 | *data = (temp & (*m).second) | (*data &~ ((*m).second)); | |
63 | else | |
64 | *data = temp; | |
65 | } | |
66 | } | |
67 | } | |
68 | return ok; | |
69 | } | |
70 | ||
71 | SS_AsiSpace::Error wr64( SS_Strand* s, uint8_t asi, SS_Vaddr addr, uint64_t data ) | |
72 | { | |
73 | return table[asi].wr64(s,addr,data); | |
74 | } | |
75 | ||
76 | SS_AsiSpace& operator[]( SS_Asi asi ) { return table[asi()]; } | |
77 | ||
78 | // set_mask() sets the mask that is applied to address before look up | |
79 | // for all asi's (0 to 255). Note this mask doesw not apply to translating ASIs | |
80 | void set_mask( SS_Vaddr mask ); | |
81 | ||
82 | ||
83 | void set_asi_va_follow_me_mask( uint8_t asi, SS_Vaddr va, uint64_t mask ) | |
84 | { | |
85 | asi_mask[asi][va] = mask; | |
86 | } | |
87 | ||
88 | protected: | |
89 | std::map<SS_Vaddr,std::list<uint64_t>*> (*asi_rd)[SS_Asi::MAX]; | |
90 | std::map<SS_Vaddr,uint64_t> asi_mask[SS_Asi::MAX]; | |
91 | ||
92 | SS_AsiSpace table[SS_Asi::MAX]; | |
93 | }; | |
94 | ||
95 | #endif |