physical.hh revision 8931
12391SN/A/*
28931Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited
38931Sandreas.hansson@arm.com * All rights reserved
48931Sandreas.hansson@arm.com *
58931Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
68931Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
78931Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
88931Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
98931Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
108931Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
118931Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
128931Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
132391SN/A *
142391SN/A * Redistribution and use in source and binary forms, with or without
152391SN/A * modification, are permitted provided that the following conditions are
162391SN/A * met: redistributions of source code must retain the above copyright
172391SN/A * notice, this list of conditions and the following disclaimer;
182391SN/A * redistributions in binary form must reproduce the above copyright
192391SN/A * notice, this list of conditions and the following disclaimer in the
202391SN/A * documentation and/or other materials provided with the distribution;
212391SN/A * neither the name of the copyright holders nor the names of its
222391SN/A * contributors may be used to endorse or promote products derived from
232391SN/A * this software without specific prior written permission.
242391SN/A *
252391SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
262391SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
272391SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
282391SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
292391SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
302391SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
312391SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
322391SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
332391SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
342391SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
352391SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
362665Ssaidi@eecs.umich.edu *
378931Sandreas.hansson@arm.com * Authors: Andreas Hansson
382391SN/A */
392391SN/A
402391SN/A#ifndef __PHYSICAL_MEMORY_HH__
412391SN/A#define __PHYSICAL_MEMORY_HH__
422391SN/A
438931Sandreas.hansson@arm.com#include "base/range_map.hh"
448931Sandreas.hansson@arm.com#include "mem/abstract_mem.hh"
458931Sandreas.hansson@arm.com#include "mem/packet.hh"
464762Snate@binkert.org
478931Sandreas.hansson@arm.com/**
488931Sandreas.hansson@arm.com * The physical memory encapsulates all memories in the system and
498931Sandreas.hansson@arm.com * provides basic functionality for accessing those memories without
508931Sandreas.hansson@arm.com * going through the memory system and interconnect.
518931Sandreas.hansson@arm.com */
528931Sandreas.hansson@arm.comclass PhysicalMemory
532391SN/A{
542413SN/A
552391SN/A  private:
562391SN/A
578931Sandreas.hansson@arm.com    // Global address map
588931Sandreas.hansson@arm.com    range_map<Addr, AbstractMemory* > addrMap;
593170Sstever@eecs.umich.edu
608931Sandreas.hansson@arm.com    // a mutable cache for the last range that matched an address
618931Sandreas.hansson@arm.com    mutable Range<Addr> rangeCache;
623170Sstever@eecs.umich.edu
638931Sandreas.hansson@arm.com    // All address-mapped memories
648931Sandreas.hansson@arm.com    std::vector<AbstractMemory*> memories;
653170Sstever@eecs.umich.edu
668931Sandreas.hansson@arm.com    // The total memory size
678931Sandreas.hansson@arm.com    uint64_t size;
683170Sstever@eecs.umich.edu
698931Sandreas.hansson@arm.com    // Prevent copying
708931Sandreas.hansson@arm.com    PhysicalMemory(const PhysicalMemory&);
713170Sstever@eecs.umich.edu
728931Sandreas.hansson@arm.com    // Prevent assignment
738931Sandreas.hansson@arm.com    PhysicalMemory& operator=(const PhysicalMemory&);
748719SAli.Saidi@ARM.com
752391SN/A  public:
762391SN/A
778931Sandreas.hansson@arm.com    /**
788931Sandreas.hansson@arm.com     * Create a physical memory object, wrapping a number of memories.
798931Sandreas.hansson@arm.com     */
808931Sandreas.hansson@arm.com    PhysicalMemory(const std::vector<AbstractMemory*>& _memories);
812391SN/A
828931Sandreas.hansson@arm.com    /**
838931Sandreas.hansson@arm.com     * Nothing to destruct.
848931Sandreas.hansson@arm.com     */
858931Sandreas.hansson@arm.com    ~PhysicalMemory() { }
864762Snate@binkert.org
878931Sandreas.hansson@arm.com    /**
888931Sandreas.hansson@arm.com     * Check if a physical address is within a range of a memory that
898931Sandreas.hansson@arm.com     * is part of the global address map.
908931Sandreas.hansson@arm.com     *
918931Sandreas.hansson@arm.com     * @param addr A physical address
928931Sandreas.hansson@arm.com     * @return Whether the address corresponds to a memory
938931Sandreas.hansson@arm.com     */
948931Sandreas.hansson@arm.com    bool isMemAddr(Addr addr) const;
952391SN/A
968931Sandreas.hansson@arm.com    /**
978931Sandreas.hansson@arm.com     * Get the memory ranges for all memories that are to be reported
988931Sandreas.hansson@arm.com     * to the configuration table.
998931Sandreas.hansson@arm.com     *
1008931Sandreas.hansson@arm.com     * @return All configuration table memory ranges
1018931Sandreas.hansson@arm.com     */
1028931Sandreas.hansson@arm.com    AddrRangeList getConfAddrRanges() const;
1038923Sandreas.hansson@arm.com
1048931Sandreas.hansson@arm.com    /**
1058931Sandreas.hansson@arm.com     * Get the total physical memory size.
1068931Sandreas.hansson@arm.com     *
1078931Sandreas.hansson@arm.com     * @return The sum of all memory sizes
1088931Sandreas.hansson@arm.com     */
1098931Sandreas.hansson@arm.com    uint64_t totalSize() const { return size; }
1108923Sandreas.hansson@arm.com
1118931Sandreas.hansson@arm.com    /**
1128931Sandreas.hansson@arm.com     *
1138719SAli.Saidi@ARM.com     */
1148931Sandreas.hansson@arm.com    void access(PacketPtr pkt);
1158931Sandreas.hansson@arm.com    void functionalAccess(PacketPtr pkt);
1162391SN/A};
1172391SN/A
1188931Sandreas.hansson@arm.com
1198931Sandreas.hansson@arm.com
1208931Sandreas.hansson@arm.com
1212391SN/A#endif //__PHYSICAL_MEMORY_HH__
122