From ffb6aec603c38e16ae91ea975c16fc3e8fb337e5 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Wed, 19 Sep 2012 06:15:44 -0400 Subject: [PATCH] AddrRange: Transition from Range to AddrRange This patch takes the final plunge and transitions from the templated Range class to the more specific AddrRange. In doing so it changes the obvious Range to AddrRange, and also bumps the range_map to be AddrRangeMap. In addition to the obvious changes, including the removal of redundant includes, this patch also does some house keeping in preparing for the introduction of address interleaving support in the ranges. The Range class is also stripped of all the functionality that is never used. --HG-- rename : src/base/range.hh => src/base/addr_range.hh rename : src/base/range_map.hh => src/base/addr_range_map.hh --- src/arch/x86/interrupts.cc | 6 +- src/base/addr_range.hh | 126 +++++++ src/base/{range_map.hh => addr_range_map.hh} | 58 ++-- src/base/inet.hh | 1 - src/base/random.hh | 8 - src/base/range.hh | 328 ------------------- src/cpu/simple/base.cc | 1 - src/dev/alpha/backdoor.hh | 1 - src/dev/alpha/tsunami_cchip.hh | 1 - src/dev/alpha/tsunami_io.hh | 1 - src/dev/alpha/tsunami_pchip.hh | 1 - src/dev/arm/a9scu.hh | 1 - src/dev/arm/amba_device.hh | 1 - src/dev/arm/amba_fake.hh | 1 - src/dev/arm/gic.hh | 1 - src/dev/arm/kmi.hh | 1 - src/dev/arm/pl011.hh | 1 - src/dev/arm/pl111.hh | 1 - src/dev/arm/rtc_pl031.hh | 1 - src/dev/arm/rv_ctrl.hh | 1 - src/dev/arm/timer_cpulocal.hh | 1 - src/dev/arm/timer_sp804.hh | 1 - src/dev/baddev.hh | 1 - src/dev/isa_fake.hh | 1 - src/dev/mc146818.hh | 1 - src/dev/mips/malta_cchip.hh | 1 - src/dev/mips/malta_io.hh | 1 - src/dev/mips/malta_pchip.hh | 1 - src/dev/pciconfigall.hh | 1 - src/dev/sparc/dtod.hh | 1 - src/dev/sparc/iob.hh | 1 - src/dev/sparc/mm_disk.hh | 1 - src/dev/uart.hh | 1 - src/dev/uart8250.hh | 1 - src/dev/x86/i82094aa.hh | 1 - src/mem/abstract_mem.cc | 7 +- src/mem/abstract_mem.hh | 4 +- src/mem/bridge.cc | 2 +- src/mem/bridge.hh | 2 +- src/mem/bus.cc | 3 +- src/mem/bus.hh | 9 +- src/mem/cache/cache_impl.hh | 1 - src/mem/physical.cc | 8 +- src/mem/physical.hh | 6 +- src/mem/port.hh | 8 +- src/python/m5/params.py | 12 +- src/python/swig/range.i | 7 +- src/unittest/rangemaptest.cc | 42 +-- 48 files changed, 213 insertions(+), 454 deletions(-) create mode 100644 src/base/addr_range.hh rename src/base/{range_map.hh => addr_range_map.hh} (74%) delete mode 100644 src/base/range.hh diff --git a/src/arch/x86/interrupts.cc b/src/arch/x86/interrupts.cc index 906903b8b9..b34124ce7e 100644 --- a/src/arch/x86/interrupts.cc +++ b/src/arch/x86/interrupts.cc @@ -371,9 +371,9 @@ AddrRangeList X86ISA::Interrupts::getAddrRanges() const { AddrRangeList ranges; - Range range = RangeEx(x86LocalAPICAddress(initialApicId, 0), - x86LocalAPICAddress(initialApicId, 0) + - PageBytes); + AddrRange range = RangeEx(x86LocalAPICAddress(initialApicId, 0), + x86LocalAPICAddress(initialApicId, 0) + + PageBytes); ranges.push_back(range); return ranges; } diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh new file mode 100644 index 0000000000..21593355b0 --- /dev/null +++ b/src/base/addr_range.hh @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2012 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * + * Copyright (c) 2002-2005 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Nathan Binkert + * Steve Reinhardt + * Andreas Hansson + */ + +#ifndef __BASE_ADDR_RANGE_HH__ +#define __BASE_ADDR_RANGE_HH__ + +#include "base/types.hh" + +class AddrRange +{ + + public: + + Addr start; + Addr end; + + AddrRange() + : start(1), end(0) + {} + + AddrRange(Addr _start, Addr _end) + : start(_start), end(_end) + {} + + AddrRange(const std::pair &r) + : start(r.first), end(r.second) + {} + + Addr size() const { return end - start + 1; } + bool valid() const { return start < end; } +}; + +/** + * Keep the operators away from SWIG. + */ +#ifndef SWIG + +/** + * @param range1 is a range. + * @param range2 is a range. + * @return if range1 is less than range2 and does not overlap range1. + */ +inline bool +operator<(const AddrRange& range1, const AddrRange& range2) +{ + return range1.start < range2.start; +} + +/** + * @param addr address in the range + * @param range range compared against. + * @return indicates that the address is not within the range. + */ +inline bool +operator!=(const Addr& addr, const AddrRange& range) +{ + return addr < range.start || addr > range.end; +} + +/** + * @param range range compared against. + * @param pos position compared to the range. + * @return indicates that position pos is within the range. + */ +inline bool +operator==(const AddrRange& range, const Addr& addr) +{ + return addr >= range.start && addr <= range.end; +} + +inline AddrRange +RangeEx(Addr start, Addr end) +{ return std::make_pair(start, end - 1); } + +inline AddrRange +RangeIn(Addr start, Addr end) +{ return std::make_pair(start, end); } + +inline AddrRange +RangeSize(Addr start, Addr size) +{ return std::make_pair(start, start + size - 1); } + +#endif // SWIG + +#endif // __BASE_ADDR_RANGE_HH__ diff --git a/src/base/range_map.hh b/src/base/addr_range_map.hh similarity index 74% rename from src/base/range_map.hh rename to src/base/addr_range_map.hh index a9774274e7..c35befdce3 100644 --- a/src/base/range_map.hh +++ b/src/base/addr_range_map.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2006 The Regents of The University of Michigan * All rights reserved. * @@ -26,36 +38,35 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Ali Saidi + * Andreas Hansson */ -#ifndef __BASE_RANGE_MAP_HH__ -#define __BASE_RANGE_MAP_HH__ +#ifndef __BASE_ADDR_RANGE_MAP_HH__ +#define __BASE_ADDR_RANGE_MAP_HH__ #include #include -#include "base/range.hh" +#include "base/addr_range.hh" /** - * The range_map uses an STL map to implement an interval tree. The - * type of both the key (range) and the value are template - * parameters. It can, for example, be used for address decoding, - * using a range of addresses to map to ports. + * The AddrRangeMap uses an STL map to implement an interval tree for + * address decoding. The value stored is a template type and can be + * e.g. a port identifier, or a pointer. */ -template -class range_map +template +class AddrRangeMap { private: - typedef std::map,V> RangeMap; + typedef std::map RangeMap; RangeMap tree; public: typedef typename RangeMap::iterator iterator; typedef typename RangeMap::const_iterator const_iterator; - template const_iterator - find(const Range &r) const + find(const AddrRange &r) const { const_iterator i; @@ -77,9 +88,8 @@ class range_map return tree.end(); } - template iterator - find(const Range &r) + find(const AddrRange &r) { iterator i; @@ -101,23 +111,20 @@ class range_map return tree.end(); } - template const_iterator - find(const U &r) const + find(const Addr &r) const { return find(RangeSize(r, 1)); } - template iterator - find(const U &r) + find(const Addr &r) { return find(RangeSize(r, 1)); } - template bool - intersect(const Range &r) + intersect(const AddrRange &r) { iterator i; i = find(r); @@ -126,9 +133,8 @@ class range_map return false; } - template iterator - insert(const Range &r, const W d) + insert(const AddrRange &r, const V& d) { if (intersect(r)) return tree.end(); @@ -136,8 +142,8 @@ class range_map return tree.insert(std::make_pair(r, d)).first; } - size_t - erase(T k) + std::size_t + erase(Addr k) { return tree.erase(k); } @@ -184,7 +190,7 @@ class range_map return tree.end(); } - size_t + std::size_t size() const { return tree.size(); @@ -197,4 +203,4 @@ class range_map } }; -#endif //__BASE_RANGE_MAP_HH__ +#endif //__BASE_ADDR_RANGE_MAP_HH__ diff --git a/src/base/inet.hh b/src/base/inet.hh index 4b73355910..1df175c1ea 100644 --- a/src/base/inet.hh +++ b/src/base/inet.hh @@ -39,7 +39,6 @@ #include #include -#include "base/range.hh" #include "base/types.hh" #include "dev/etherpkt.hh" #include "dnet/os.h" diff --git a/src/base/random.hh b/src/base/random.hh index b7e2a50735..34107c76f3 100644 --- a/src/base/random.hh +++ b/src/base/random.hh @@ -42,7 +42,6 @@ #include #include -#include "base/range.hh" #include "base/types.hh" class Checkpoint; @@ -210,13 +209,6 @@ class Random return _random(min, max); } - template - T - random(const Range &range) - { - return _random(range.start, range.end); - } - // [0,1] double gen_real1() diff --git a/src/base/range.hh b/src/base/range.hh deleted file mode 100644 index 3b1a9277b8..0000000000 --- a/src/base/range.hh +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (c) 2002-2005 The Regents of The University of Michigan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Authors: Nathan Binkert - * Steve Reinhardt - */ - -#ifndef __BASE_RANGE_HH__ -#define __BASE_RANGE_HH__ - -template -struct Range -{ - T start; - T end; - - Range() { invalidate(); } - - template - Range(const std::pair &r) - : start(r.first), end(r.second) - {} - - template - Range(const Range &r) - : start(r.start), end(r.end) - {} - - template - const Range &operator=(const Range &r) - { - start = r.start; - end = r.end; - return *this; - } - - template - const Range &operator=(const std::pair &r) - { - start = r.first; - end = r.second; - return *this; - } - - void invalidate() { start = 1; end = 0; } - T size() const { return end - start + 1; } - bool valid() const { return start < end; } -}; - -template -inline Range -RangeEx(T start, T end) -{ return std::make_pair(start, end - 1); } - -template -inline Range -RangeIn(T start, T end) -{ return std::make_pair(start, end); } - -template -inline Range -RangeSize(T start, U size) -{ return std::make_pair(start, start + size - 1); } - -//////////////////////////////////////////////////////////////////////// -// -// Range to Range Comparisons -// - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 and range2 are identical. - */ -template -inline bool -operator==(const Range &range1, const Range &range2) -{ - return range1.start == range2.start && range1.end == range2.end; -} - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 and range2 are not identical. - */ -template -inline bool -operator!=(const Range &range1, const Range &range2) -{ - return range1.start != range2.start || range1.end != range2.end; -} - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 is less than range2 and does not overlap range1. - */ -template -inline bool -operator<(const Range &range1, const Range &range2) -{ - return range1.start < range2.start; -} - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 is less than range2. range1 may overlap range2, - * but not extend beyond the end of range2. - */ -template -inline bool -operator<=(const Range &range1, const Range &range2) -{ - return range1.start <= range2.start; -} - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 is greater than range2 and does not overlap range2. - */ -template -inline bool -operator>(const Range &range1, const Range &range2) -{ - return range1.start > range2.start; -} - -/** - * @param range1 is a range. - * @param range2 is a range. - * @return if range1 is greater than range2. range1 may overlap range2, - * but not extend beyond the beginning of range2. - */ -template -inline bool -operator>=(const Range &range1, const Range &range2) -{ - return range1.start >= range2.start; -} - -//////////////////////////////////////////////////////////////////////// -// -// Position to Range Comparisons -// - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is within the range. - */ -template -inline bool -operator==(const T &pos, const Range &range) -{ - return pos >= range.start && pos <= range.end; -} - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is not within the range. - */ -template -inline bool -operator!=(const T &pos, const Range &range) -{ - return pos < range.start || pos > range.end; -} - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is below the range. - */ -template -inline bool -operator<(const T &pos, const Range &range) -{ - return pos < range.start; -} - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is below or in the range. - */ -template -inline bool -operator<=(const T &pos, const Range &range) -{ - return pos <= range.end; -} - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is above the range. - */ -template -inline bool -operator>(const T &pos, const Range &range) -{ - return pos > range.end; -} - -/** - * @param pos position compared to the range. - * @param range range compared against. - * @return indicates that position pos is above or in the range. - */ -template -inline bool -operator>=(const T &pos, const Range &range) -{ - return pos >= range.start; -} - -//////////////////////////////////////////////////////////////////////// -// -// Range to Position Comparisons (for symmetry) -// - -/** - * @param range range compared against. - * @param pos position compared to the range. - * @return indicates that position pos is within the range. - */ -template -inline bool -operator==(const Range &range, const U &pos) -{ - return pos >= range.start && pos <= range.end; -} - -/** - * @param range range compared against. - * @param pos position compared to the range. - * @return indicates that position pos is not within the range. - */ -template -inline bool -operator!=(const Range &range, const U &pos) -{ - return pos < range.start || pos > range.end; -} - -/** - * @param range range compared against. - * @param pos position compared to the range. - * @return indicates that position pos is above the range. - */ -template -inline bool -operator<(const Range &range, const U &pos) -{ - // with -std=gnu++0x, gcc and clang get confused when range.end is - // compared to pos using the operator "<", and the parser expects it - // to be the opening bracket for a template parameter, - // i.e. range.end(...);, the reason seems to be the range-type - // iteration introduced in c++11 where begin and end are members - // that return iterators - return operator<(range.end, pos); -} - -/** - * @param range range compared against. - * @param pos position compared to the range. - * @return indicates that position pos is above or in the range. - */ -template -inline bool -operator<=(const Range &range, const U &pos) -{ - return range.start <= pos; -} - -/** - * @param range range compared against. - * @param pos position compared to the range. - * 'range > pos' indicates that position pos is below the range. - */ -template -inline bool -operator>(const Range &range, const U &pos) -{ - return range.start > pos; -} - -/** - * @param range range compared against. - * @param pos position compared to the range. - * 'range >= pos' indicates that position pos is below or in the range. - */ -template -inline bool -operator>=(const Range &range, const U &pos) -{ - return range.end >= pos; -} - -#endif // __BASE_RANGE_HH__ diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc index bdc4b0f44e..5a9499333f 100644 --- a/src/cpu/simple/base.cc +++ b/src/cpu/simple/base.cc @@ -51,7 +51,6 @@ #include "base/inifile.hh" #include "base/misc.hh" #include "base/pollevent.hh" -#include "base/range.hh" #include "base/trace.hh" #include "base/types.hh" #include "config/the_isa.hh" diff --git a/src/dev/alpha/backdoor.hh b/src/dev/alpha/backdoor.hh index 2acaba9a36..b9d04c7c08 100644 --- a/src/dev/alpha/backdoor.hh +++ b/src/dev/alpha/backdoor.hh @@ -35,7 +35,6 @@ #ifndef __DEV_ALPHA_BACKDOOR_HH__ #define __DEV_ALPHA_BACKDOOR_HH__ -#include "base/range.hh" #include "base/types.hh" #include "dev/alpha/access.h" #include "dev/io_device.hh" diff --git a/src/dev/alpha/tsunami_cchip.hh b/src/dev/alpha/tsunami_cchip.hh index 1265c2e802..e9aca5d5ce 100644 --- a/src/dev/alpha/tsunami_cchip.hh +++ b/src/dev/alpha/tsunami_cchip.hh @@ -35,7 +35,6 @@ #ifndef __TSUNAMI_CCHIP_HH__ #define __TSUNAMI_CCHIP_HH__ -#include "base/range.hh" #include "dev/alpha/tsunami.hh" #include "dev/io_device.hh" #include "params/TsunamiCChip.hh" diff --git a/src/dev/alpha/tsunami_io.hh b/src/dev/alpha/tsunami_io.hh index f88cf5a6cf..212e2a3d5c 100644 --- a/src/dev/alpha/tsunami_io.hh +++ b/src/dev/alpha/tsunami_io.hh @@ -37,7 +37,6 @@ #ifndef __DEV_TSUNAMI_IO_HH__ #define __DEV_TSUNAMI_IO_HH__ -#include "base/range.hh" #include "dev/alpha/tsunami.hh" #include "dev/intel_8254_timer.hh" #include "dev/io_device.hh" diff --git a/src/dev/alpha/tsunami_pchip.hh b/src/dev/alpha/tsunami_pchip.hh index d31a28dbe6..3e32db989b 100644 --- a/src/dev/alpha/tsunami_pchip.hh +++ b/src/dev/alpha/tsunami_pchip.hh @@ -35,7 +35,6 @@ #ifndef __TSUNAMI_PCHIP_HH__ #define __TSUNAMI_PCHIP_HH__ -#include "base/range.hh" #include "dev/alpha/tsunami.hh" #include "dev/io_device.hh" #include "params/TsunamiPChip.hh" diff --git a/src/dev/arm/a9scu.hh b/src/dev/arm/a9scu.hh index 881401ca69..10428d91e0 100644 --- a/src/dev/arm/a9scu.hh +++ b/src/dev/arm/a9scu.hh @@ -40,7 +40,6 @@ #ifndef __DEV_ARM_A9SCU_HH__ #define __DEV_ARM_A9SCU_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "params/A9SCU.hh" diff --git a/src/dev/arm/amba_device.hh b/src/dev/arm/amba_device.hh index 4bea1e0758..92dfed541d 100644 --- a/src/dev/arm/amba_device.hh +++ b/src/dev/arm/amba_device.hh @@ -49,7 +49,6 @@ #ifndef __DEV_ARM_AMBA_DEVICE_HH__ #define __DEV_ARM_AMBA_DEVICE_HH__ -#include "base/range.hh" #include "dev/arm/gic.hh" #include "dev/dma_device.hh" #include "dev/io_device.hh" diff --git a/src/dev/arm/amba_fake.hh b/src/dev/arm/amba_fake.hh index 4a67ab9d5d..24b326e8aa 100644 --- a/src/dev/arm/amba_fake.hh +++ b/src/dev/arm/amba_fake.hh @@ -51,7 +51,6 @@ #ifndef __DEV_ARM_AMBA_FAKE_H__ #define __DEV_ARM_AMBA_FAKE_H__ -#include "base/range.hh" #include "dev/arm/amba_device.hh" #include "params/AmbaFake.hh" diff --git a/src/dev/arm/gic.hh b/src/dev/arm/gic.hh index 9d93bbedf6..02448f6511 100644 --- a/src/dev/arm/gic.hh +++ b/src/dev/arm/gic.hh @@ -49,7 +49,6 @@ #define __DEV_ARM_GIC_H__ #include "base/bitunion.hh" -#include "base/range.hh" #include "dev/io_device.hh" #include "dev/platform.hh" #include "cpu/intr_control.hh" diff --git a/src/dev/arm/kmi.hh b/src/dev/arm/kmi.hh index dc488ccce0..e769a8a468 100644 --- a/src/dev/arm/kmi.hh +++ b/src/dev/arm/kmi.hh @@ -51,7 +51,6 @@ #include #include "base/vnc/vncserver.hh" -#include "base/range.hh" #include "dev/arm/amba_device.hh" #include "params/Pl050.hh" diff --git a/src/dev/arm/pl011.hh b/src/dev/arm/pl011.hh index ddfd8305bc..dbd8bd539e 100644 --- a/src/dev/arm/pl011.hh +++ b/src/dev/arm/pl011.hh @@ -48,7 +48,6 @@ #ifndef __DEV_ARM_PL011_H__ #define __DEV_ARM_PL011_H__ -#include "base/range.hh" #include "dev/io_device.hh" #include "dev/uart.hh" #include "params/Pl011.hh" diff --git a/src/dev/arm/pl111.hh b/src/dev/arm/pl111.hh index 599d4fa3ee..5776f199ce 100644 --- a/src/dev/arm/pl111.hh +++ b/src/dev/arm/pl111.hh @@ -48,7 +48,6 @@ #include -#include "base/range.hh" #include "dev/arm/amba_device.hh" #include "params/Pl111.hh" #include "sim/serialize.hh" diff --git a/src/dev/arm/rtc_pl031.hh b/src/dev/arm/rtc_pl031.hh index f5615dd55b..0f1929d29c 100644 --- a/src/dev/arm/rtc_pl031.hh +++ b/src/dev/arm/rtc_pl031.hh @@ -40,7 +40,6 @@ #ifndef __DEV_ARM_RTC_PL310_HH__ #define __DEV_ARM_RTC_PL310_HH__ -#include "base/range.hh" #include "dev/arm/amba_device.hh" #include "params/PL031.hh" diff --git a/src/dev/arm/rv_ctrl.hh b/src/dev/arm/rv_ctrl.hh index cf14f6bcd2..c6cf40f96c 100644 --- a/src/dev/arm/rv_ctrl.hh +++ b/src/dev/arm/rv_ctrl.hh @@ -41,7 +41,6 @@ #define __DEV_ARM_RV_HH__ #include "base/bitunion.hh" -#include "base/range.hh" #include "dev/io_device.hh" #include "params/RealViewCtrl.hh" diff --git a/src/dev/arm/timer_cpulocal.hh b/src/dev/arm/timer_cpulocal.hh index 144e0b8070..cf7e464964 100644 --- a/src/dev/arm/timer_cpulocal.hh +++ b/src/dev/arm/timer_cpulocal.hh @@ -41,7 +41,6 @@ #ifndef __DEV_ARM_LOCALTIMER_HH__ #define __DEV_ARM_LOCALTIMER_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "params/CpuLocalTimer.hh" diff --git a/src/dev/arm/timer_sp804.hh b/src/dev/arm/timer_sp804.hh index afb6e29ed2..9f137001da 100644 --- a/src/dev/arm/timer_sp804.hh +++ b/src/dev/arm/timer_sp804.hh @@ -40,7 +40,6 @@ #ifndef __DEV_ARM_SP804_HH__ #define __DEV_ARM_SP804_HH__ -#include "base/range.hh" #include "dev/arm/amba_device.hh" #include "params/Sp804.hh" diff --git a/src/dev/baddev.hh b/src/dev/baddev.hh index 9cf592c0ef..ea902152ea 100644 --- a/src/dev/baddev.hh +++ b/src/dev/baddev.hh @@ -36,7 +36,6 @@ #ifndef __DEV_BADDEV_HH__ #define __DEV_BADDEV_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "params/BadDevice.hh" diff --git a/src/dev/isa_fake.hh b/src/dev/isa_fake.hh index 07657ad7df..1223e3b22e 100644 --- a/src/dev/isa_fake.hh +++ b/src/dev/isa_fake.hh @@ -37,7 +37,6 @@ #include -#include "base/range.hh" #include "dev/io_device.hh" // #include "dev/alpha/tsunami.hh" #include "mem/packet.hh" diff --git a/src/dev/mc146818.hh b/src/dev/mc146818.hh index 576c4ab9fe..c2f1e2dd89 100644 --- a/src/dev/mc146818.hh +++ b/src/dev/mc146818.hh @@ -33,7 +33,6 @@ #ifndef __DEV_MC146818_HH__ #define __DEV_MC146818_HH__ -#include "base/range.hh" #include "sim/eventq.hh" /** Real-Time Clock (MC146818) */ diff --git a/src/dev/mips/malta_cchip.hh b/src/dev/mips/malta_cchip.hh index 4841551c4b..9a17f632f5 100755 --- a/src/dev/mips/malta_cchip.hh +++ b/src/dev/mips/malta_cchip.hh @@ -36,7 +36,6 @@ #ifndef __MALTA_CCHIP_HH__ #define __MALTA_CCHIP_HH__ -#include "base/range.hh" #include "dev/mips/malta.hh" #include "dev/io_device.hh" #include "params/MaltaCChip.hh" diff --git a/src/dev/mips/malta_io.hh b/src/dev/mips/malta_io.hh index 38da5adeac..9311d7c225 100755 --- a/src/dev/mips/malta_io.hh +++ b/src/dev/mips/malta_io.hh @@ -37,7 +37,6 @@ #ifndef __DEV_MALTA_IO_HH__ #define __DEV_MALTA_IO_HH__ -#include "base/range.hh" #include "dev/mips/malta.hh" #include "dev/intel_8254_timer.hh" #include "dev/io_device.hh" diff --git a/src/dev/mips/malta_pchip.hh b/src/dev/mips/malta_pchip.hh index a554e253e2..a6145515a9 100755 --- a/src/dev/mips/malta_pchip.hh +++ b/src/dev/mips/malta_pchip.hh @@ -35,7 +35,6 @@ #ifndef __MALTA_PCHIP_HH__ #define __MALTA_PCHIP_HH__ -#include "base/range.hh" #include "dev/mips/malta.hh" #include "dev/io_device.hh" #include "params/MaltaPChip.hh" diff --git a/src/dev/pciconfigall.hh b/src/dev/pciconfigall.hh index eb480ad166..4df36f0b3d 100644 --- a/src/dev/pciconfigall.hh +++ b/src/dev/pciconfigall.hh @@ -37,7 +37,6 @@ #ifndef __PCICONFIGALL_HH__ #define __PCICONFIGALL_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "dev/pcireg.h" #include "params/PciConfigAll.hh" diff --git a/src/dev/sparc/dtod.hh b/src/dev/sparc/dtod.hh index 325bce90a1..a5b2dfaffe 100644 --- a/src/dev/sparc/dtod.hh +++ b/src/dev/sparc/dtod.hh @@ -38,7 +38,6 @@ #include -#include "base/range.hh" #include "dev/io_device.hh" #include "params/DumbTOD.hh" diff --git a/src/dev/sparc/iob.hh b/src/dev/sparc/iob.hh index b92d3cb2a7..fc5e610925 100644 --- a/src/dev/sparc/iob.hh +++ b/src/dev/sparc/iob.hh @@ -36,7 +36,6 @@ #ifndef __DEV_SPARC_IOB_HH__ #define __DEV_SPARC_IOB_HH__ -#include "base/range.hh" #include "dev/disk_image.hh" #include "dev/io_device.hh" #include "params/Iob.hh" diff --git a/src/dev/sparc/mm_disk.hh b/src/dev/sparc/mm_disk.hh index 0e43449a14..d14e1d4a4c 100644 --- a/src/dev/sparc/mm_disk.hh +++ b/src/dev/sparc/mm_disk.hh @@ -36,7 +36,6 @@ #ifndef __DEV_SPARC_MM_DISK_HH__ #define __DEV_SPARC_MM_DISK_HH__ -#include "base/range.hh" #include "dev/disk_image.hh" #include "dev/io_device.hh" #include "params/MmDisk.hh" diff --git a/src/dev/uart.hh b/src/dev/uart.hh index ba10c204c3..eac70bf1f7 100644 --- a/src/dev/uart.hh +++ b/src/dev/uart.hh @@ -35,7 +35,6 @@ #ifndef __UART_HH__ #define __UART_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "params/Uart.hh" diff --git a/src/dev/uart8250.hh b/src/dev/uart8250.hh index e2fb043c19..7d577954cf 100644 --- a/src/dev/uart8250.hh +++ b/src/dev/uart8250.hh @@ -35,7 +35,6 @@ #ifndef __DEV_UART8250_HH__ #define __DEV_UART8250_HH__ -#include "base/range.hh" #include "dev/io_device.hh" #include "dev/uart.hh" #include "params/Uart8250.hh" diff --git a/src/dev/x86/i82094aa.hh b/src/dev/x86/i82094aa.hh index c90a5b812b..76a8f9c004 100644 --- a/src/dev/x86/i82094aa.hh +++ b/src/dev/x86/i82094aa.hh @@ -34,7 +34,6 @@ #include #include "base/bitunion.hh" -#include "base/range_map.hh" #include "dev/x86/intdev.hh" #include "dev/io_device.hh" #include "params/I82094AA.hh" diff --git a/src/mem/abstract_mem.cc b/src/mem/abstract_mem.cc index 775517e3b2..ebe4a64b5e 100644 --- a/src/mem/abstract_mem.cc +++ b/src/mem/abstract_mem.cc @@ -85,9 +85,8 @@ AbstractMemory::AbstractMemory(const Params *p) : int fd = open(params()->file.c_str(), O_RDONLY); long _size = lseek(fd, 0, SEEK_END); if (_size != range.size()) { - warn("Specified size %d does not match file %s %d\n", range.size(), - params()->file, _size); - range = RangeSize(range.start, _size); + fatal("Specified size %d does not match file %s %d\n", + range.size(), params()->file, _size); } lseek(fd, 0, SEEK_SET); pmemAddr = (uint8_t *)mmap(NULL, roundUp(_size, sysconf(_SC_PAGESIZE)), @@ -222,7 +221,7 @@ AbstractMemory::regStats() bwTotal = (bytesRead + bytesWritten) / simSeconds; } -Range +AddrRange AbstractMemory::getAddrRange() const { return range; diff --git a/src/mem/abstract_mem.hh b/src/mem/abstract_mem.hh index 43d9656dad..66d4a1f16c 100644 --- a/src/mem/abstract_mem.hh +++ b/src/mem/abstract_mem.hh @@ -68,7 +68,7 @@ class AbstractMemory : public MemObject protected: // Address range of this memory - Range range; + AddrRange range; // Pointer to host memory used to implement this memory uint8_t* pmemAddr; @@ -209,7 +209,7 @@ class AbstractMemory : public MemObject * * @return a single contigous address range */ - Range getAddrRange() const; + AddrRange getAddrRange() const; /** * Get the memory size. diff --git a/src/mem/bridge.cc b/src/mem/bridge.cc index 3a185a8eb5..8bc34e12e7 100644 --- a/src/mem/bridge.cc +++ b/src/mem/bridge.cc @@ -57,7 +57,7 @@ Bridge::BridgeSlavePort::BridgeSlavePort(const std::string& _name, Bridge& _bridge, BridgeMasterPort& _masterPort, Cycles _delay, int _resp_limit, - std::vector > _ranges) + std::vector _ranges) : SlavePort(_name, &_bridge), bridge(_bridge), masterPort(_masterPort), delay(_delay), ranges(_ranges.begin(), _ranges.end()), outstandingResponses(0), retryReq(false), diff --git a/src/mem/bridge.hh b/src/mem/bridge.hh index c521464633..eb0b2434fa 100644 --- a/src/mem/bridge.hh +++ b/src/mem/bridge.hh @@ -193,7 +193,7 @@ class Bridge : public MemObject */ BridgeSlavePort(const std::string& _name, Bridge& _bridge, BridgeMasterPort& _masterPort, Cycles _delay, - int _resp_limit, std::vector > _ranges); + int _resp_limit, std::vector _ranges); /** * Queue a response packet to be sent out later and also schedule diff --git a/src/mem/bus.cc b/src/mem/bus.cc index 829d694de3..75ece9bc85 100644 --- a/src/mem/bus.cc +++ b/src/mem/bus.cc @@ -355,7 +355,6 @@ BaseBus::findPort(Addr addr) void BaseBus::recvRangeChange(PortID master_port_id) { - AddrRangeList ranges; AddrRangeIter iter; if (inRecvRangeChange.count(master_port_id)) @@ -394,7 +393,7 @@ BaseBus::recvRangeChange(PortID master_port_id) } // get the address ranges of the connected slave port - ranges = port->getAddrRanges(); + AddrRangeList ranges = port->getAddrRanges(); for (iter = ranges.begin(); iter != ranges.end(); iter++) { DPRINTF(BusAddrRanges, "Adding range %#llx - %#llx for id %d\n", diff --git a/src/mem/bus.hh b/src/mem/bus.hh index ac35581b1d..541e2f3635 100644 --- a/src/mem/bus.hh +++ b/src/mem/bus.hh @@ -54,8 +54,7 @@ #include #include -#include "base/range.hh" -#include "base/range_map.hh" +#include "base/addr_range_map.hh" #include "base/types.hh" #include "mem/mem_object.hh" #include "params/BaseBus.hh" @@ -233,9 +232,9 @@ class BaseBus : public MemObject /** the width of the bus in bytes */ int width; - typedef range_map::iterator PortMapIter; - typedef range_map::const_iterator PortMapConstIter; - range_map portMap; + typedef AddrRangeMap::iterator PortMapIter; + typedef AddrRangeMap::const_iterator PortMapConstIter; + AddrRangeMap portMap; AddrRangeList defaultRange; diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index 563160ac18..9b9010d344 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -51,7 +51,6 @@ */ #include "base/misc.hh" -#include "base/range.hh" #include "base/types.hh" #include "debug/Cache.hh" #include "debug/CachePort.hh" diff --git a/src/mem/physical.cc b/src/mem/physical.cc index 5f92976f9d..23556f0ab1 100644 --- a/src/mem/physical.cc +++ b/src/mem/physical.cc @@ -64,7 +64,6 @@ PhysicalMemory::PhysicalMemory(const vector& _memories) : "Skipping memory %s that is not in global address map\n", (*m)->name()); } - rangeCache.invalidate(); } bool @@ -73,8 +72,7 @@ PhysicalMemory::isMemAddr(Addr addr) const // see if the address is within the last matched range if (addr != rangeCache) { // lookup in the interval tree - range_map::const_iterator r = - addrMap.find(addr); + AddrRangeMap::const_iterator r = addrMap.find(addr); if (r == addrMap.end()) { // not in the cache, and not in the tree return false; @@ -110,7 +108,7 @@ PhysicalMemory::access(PacketPtr pkt) { assert(pkt->isRequest()); Addr addr = pkt->getAddr(); - range_map::const_iterator m = addrMap.find(addr); + AddrRangeMap::const_iterator m = addrMap.find(addr); assert(m != addrMap.end()); m->second->access(pkt); } @@ -120,7 +118,7 @@ PhysicalMemory::functionalAccess(PacketPtr pkt) { assert(pkt->isRequest()); Addr addr = pkt->getAddr(); - range_map::const_iterator m = addrMap.find(addr); + AddrRangeMap::const_iterator m = addrMap.find(addr); assert(m != addrMap.end()); m->second->functionalAccess(pkt); } diff --git a/src/mem/physical.hh b/src/mem/physical.hh index e78b1d2da3..fb9969a348 100644 --- a/src/mem/physical.hh +++ b/src/mem/physical.hh @@ -40,7 +40,7 @@ #ifndef __PHYSICAL_MEMORY_HH__ #define __PHYSICAL_MEMORY_HH__ -#include "base/range_map.hh" +#include "base/addr_range_map.hh" #include "mem/abstract_mem.hh" #include "mem/packet.hh" @@ -55,10 +55,10 @@ class PhysicalMemory private: // Global address map - range_map addrMap; + AddrRangeMap addrMap; // a mutable cache for the last range that matched an address - mutable Range rangeCache; + mutable AddrRange rangeCache; // All address-mapped memories std::vector memories; diff --git a/src/mem/port.hh b/src/mem/port.hh index 631725ce18..eaad9668a0 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -52,7 +52,7 @@ #include -#include "base/range.hh" +#include "base/addr_range.hh" #include "mem/packet.hh" /** @@ -62,9 +62,9 @@ * defined. */ -typedef std::list > AddrRangeList; -typedef std::list >::iterator AddrRangeIter; -typedef std::list >::const_iterator AddrRangeConstIter; +typedef std::list AddrRangeList; +typedef std::list::iterator AddrRangeIter; +typedef std::list::const_iterator AddrRangeConstIter; class MemObject; diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 46c3d028c5..cabb91b28a 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -550,7 +550,7 @@ class Addr(CheckedInt): return self.value + other class AddrRange(ParamValue): - cxx_type = 'Range' + cxx_type = 'AddrRange' def __init__(self, *args, **kwargs): def handle_kwargs(self, kwargs): @@ -594,20 +594,18 @@ class AddrRange(ParamValue): @classmethod def cxx_predecls(cls, code): Addr.cxx_predecls(code) - code('#include "base/range.hh"') + code('#include "base/addr_range.hh"') @classmethod def swig_predecls(cls, code): Addr.swig_predecls(code) - code('%import "python/swig/range.i"') def getValue(self): + # Go from the Python class to the wrapped C++ class generated + # by swig from m5.internal.range import AddrRange - value = AddrRange() - value.start = long(self.start) - value.end = long(self.end) - return value + return AddrRange(long(self.start), long(self.end)) # Boolean parameter type. Python doesn't let you subclass bool, since # it doesn't want to let you create multiple instances of True and diff --git a/src/python/swig/range.i b/src/python/swig/range.i index d8da677bbb..e3a7943100 100644 --- a/src/python/swig/range.i +++ b/src/python/swig/range.i @@ -31,15 +31,12 @@ %module(package="m5.internal") range %{ -#include "base/range.hh" #include "base/types.hh" +#include "base/addr_range.hh" %} %include %rename(assign) *::operator=; -%include "base/range.hh" %include "base/types.hh" - -%template(AddrRange) Range; -%template(TickRange) Range; +%include "base/addr_range.hh" diff --git a/src/unittest/rangemaptest.cc b/src/unittest/rangemaptest.cc index af00e4e588..57b954b0ad 100644 --- a/src/unittest/rangemaptest.cc +++ b/src/unittest/rangemaptest.cc @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2006 The Regents of The University of Michigan * All rights reserved. * @@ -31,46 +43,38 @@ #include #include -#include "base/range_map.hh" -#include "base/types.hh" +#include "base/addr_range_map.hh" using namespace std; int main() { - range_map r; + AddrRangeMap r; - range_map::iterator i; + AddrRangeMap::iterator i; - i = r.insert(RangeIn(10,40),5); + i = r.insert(RangeIn(10, 40), 5); assert(i != r.end()); - i = r.insert(RangeIn(60,90),3); + i = r.insert(RangeIn(60, 90), 3); assert(i != r.end()); - i = r.find(RangeIn(20,30)); + i = r.find(RangeIn(20, 30)); assert(i != r.end()); cout << i->first << " " << i->second << endl; - i = r.find(RangeIn(55,55)); + i = r.find(RangeIn(55, 55)); assert(i == r.end()); - i = r.insert(RangeIn(0,12),1); + i = r.insert(RangeIn(0, 12), 1); assert(i == r.end()); - i = r.insert(RangeIn(0,9),1); + i = r.insert(RangeIn(0, 9), 1); assert(i != r.end()); - i = r.find(RangeIn(20,30)); + i = r.find(RangeIn(20, 30)); assert(i != r.end()); cout << i->first << " " << i->second << endl; + return 0; } - - - - - - - -