| 1 | /* -*- c++ -*- |
|---|
| 2 | * |
|---|
| 3 | * SOCLIB_LGPL_HEADER_BEGIN |
|---|
| 4 | * |
|---|
| 5 | * This file is part of SoCLib, GNU LGPLv2.1. |
|---|
| 6 | * |
|---|
| 7 | * SoCLib is free software; you can redistribute it and/or modify it |
|---|
| 8 | * under the terms of the GNU Lesser General Public License as published |
|---|
| 9 | * by the Free Software Foundation; version 2.1 of the License. |
|---|
| 10 | * |
|---|
| 11 | * SoCLib is distributed in the hope that it will be useful, but |
|---|
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 14 | * Lesser General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU Lesser General Public |
|---|
| 17 | * License along with SoCLib; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|---|
| 19 | * 02110-1301 USA |
|---|
| 20 | * |
|---|
| 21 | * SOCLIB_LGPL_HEADER_END |
|---|
| 22 | * |
|---|
| 23 | * Copyright (c) UPMC, Lip6, Asim |
|---|
| 24 | * Nicolas Pouillon <nipo@ssji.net>, 2007 |
|---|
| 25 | * |
|---|
| 26 | * Based on previous works by Francois Pecheux & Alain Greiner |
|---|
| 27 | * |
|---|
| 28 | * Maintainers: nipo |
|---|
| 29 | */ |
|---|
| 30 | #ifndef SOCLIB_MAPPING_TABLE_H |
|---|
| 31 | #define SOCLIB_MAPPING_TABLE_H |
|---|
| 32 | |
|---|
| 33 | #include <inttypes.h> |
|---|
| 34 | #include <list> |
|---|
| 35 | #include <sstream> |
|---|
| 36 | |
|---|
| 37 | #include "segment.h" |
|---|
| 38 | #include "address_decoding_table.h" |
|---|
| 39 | #include "address_masking_table.h" |
|---|
| 40 | #include "int_tab.h" |
|---|
| 41 | |
|---|
| 42 | namespace soclib { namespace common { |
|---|
| 43 | |
|---|
| 44 | class MappingTable |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | typedef uint64_t addr64_t; |
|---|
| 48 | typedef uint32_t addr32_t; |
|---|
| 49 | |
|---|
| 50 | private: |
|---|
| 51 | std::list<soclib::common::Segment> m_segment_list; |
|---|
| 52 | size_t m_addr_width; |
|---|
| 53 | addr64_t m_addr_mask; |
|---|
| 54 | IntTab m_level_addr_bits; |
|---|
| 55 | IntTab m_level_id_bits; |
|---|
| 56 | addr64_t m_cacheability_mask; |
|---|
| 57 | addr64_t m_rt_size; |
|---|
| 58 | bool m_used; |
|---|
| 59 | |
|---|
| 60 | public: |
|---|
| 61 | MappingTable( const MappingTable& ); |
|---|
| 62 | const MappingTable &operator=( const MappingTable & ); |
|---|
| 63 | |
|---|
| 64 | MappingTable( size_t addr_width, |
|---|
| 65 | const IntTab &level_addr_bits, |
|---|
| 66 | const IntTab &level_id_bits, |
|---|
| 67 | const addr64_t cacheability_mask ); |
|---|
| 68 | |
|---|
| 69 | void add( const soclib::common::Segment &seg ); |
|---|
| 70 | |
|---|
| 71 | std::list<Segment> getSegmentList( const IntTab &index ) const; |
|---|
| 72 | |
|---|
| 73 | const std::list<Segment> &getAllSegmentList() const; |
|---|
| 74 | |
|---|
| 75 | soclib::common::Segment getSegment( const IntTab &index ) const; |
|---|
| 76 | |
|---|
| 77 | // __attribute__((deprecated)) |
|---|
| 78 | AddressDecodingTable<addr32_t, bool> getCacheabilityTable() const |
|---|
| 79 | { |
|---|
| 80 | return getCacheabilityTable<addr32_t>(); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | // __attribute__((deprecated)) |
|---|
| 84 | AddressDecodingTable<addr32_t, bool> getLocalityTable( const IntTab &index ) const |
|---|
| 85 | { |
|---|
| 86 | return getLocalityTable<addr32_t>( index ); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | // __attribute__((deprecated)) |
|---|
| 90 | AddressDecodingTable<addr32_t, int> getRoutingTable( const IntTab &index, int default_index = 0 ) const |
|---|
| 91 | { |
|---|
| 92 | return getRoutingTable<addr32_t>( index, default_index ); |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | AddressDecodingTable<uint32_t, bool> getIdLocalityTable( const IntTab &index ) const; |
|---|
| 96 | |
|---|
| 97 | AddressMaskingTable<uint32_t> getIdMaskingTable( const int level ) const; |
|---|
| 98 | |
|---|
| 99 | // __attribute__((deprecated)) |
|---|
| 100 | addr32_t *getCoherenceTable() const |
|---|
| 101 | { |
|---|
| 102 | return getCoherenceTable<addr32_t>(); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | template<typename desired_addr_t> |
|---|
| 107 | AddressDecodingTable<desired_addr_t, bool> getCacheabilityTable() const; |
|---|
| 108 | |
|---|
| 109 | template<typename desired_addr_t> |
|---|
| 110 | AddressDecodingTable<desired_addr_t, bool> getLocalityTable( const IntTab &index ) const; |
|---|
| 111 | |
|---|
| 112 | template<typename desired_addr_t> |
|---|
| 113 | AddressDecodingTable<desired_addr_t, int> getRoutingTable( const IntTab &index, int default_index = 0 ) const; |
|---|
| 114 | |
|---|
| 115 | template<typename desired_addr_t> |
|---|
| 116 | desired_addr_t *getCoherenceTable() const; |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | void print( std::ostream &o ) const; |
|---|
| 121 | |
|---|
| 122 | friend std::ostream &operator << (std::ostream &o, const MappingTable &mt) |
|---|
| 123 | { |
|---|
| 124 | mt.print(o); |
|---|
| 125 | return o; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | inline unsigned int indexForId( const IntTab &index ) const |
|---|
| 129 | { |
|---|
| 130 | return index*m_level_id_bits; |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | inline size_t level() const |
|---|
| 134 | { |
|---|
| 135 | return m_level_addr_bits.level(); |
|---|
| 136 | } |
|---|
| 137 | }; |
|---|
| 138 | |
|---|
| 139 | }} |
|---|
| 140 | |
|---|
| 141 | #endif /* SOCLIB_MAPPING_TABLE_H */ |
|---|
| 142 | |
|---|
| 143 | // Local Variables: |
|---|
| 144 | // tab-width: 4 |
|---|
| 145 | // c-basic-offset: 4 |
|---|
| 146 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
|---|
| 147 | // indent-tabs-mode: nil |
|---|
| 148 | // End: |
|---|
| 149 | |
|---|
| 150 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 151 | |
|---|