RubySlicc_ComponentMapping.hh revision 6785
16145Snate@binkert.org 26145Snate@binkert.org/* 36145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 46145Snate@binkert.org * All rights reserved. 56145Snate@binkert.org * 66145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 76145Snate@binkert.org * modification, are permitted provided that the following conditions are 86145Snate@binkert.org * met: redistributions of source code must retain the above copyright 96145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 106145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 116145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 126145Snate@binkert.org * documentation and/or other materials provided with the distribution; 136145Snate@binkert.org * neither the name of the copyright holders nor the names of its 146145Snate@binkert.org * contributors may be used to endorse or promote products derived from 156145Snate@binkert.org * this software without specific prior written permission. 166145Snate@binkert.org * 176145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 186145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 196145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 206145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 216145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 226145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 236145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 246145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 256145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 266145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 276145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 286145Snate@binkert.org */ 296145Snate@binkert.org 306145Snate@binkert.org/* 316145Snate@binkert.org * $Id$ 326145Snate@binkert.org */ 336145Snate@binkert.org 346145Snate@binkert.org#ifndef COMPONENTMAPPINGFNS_H 356145Snate@binkert.org#define COMPONENTMAPPINGFNS_H 366145Snate@binkert.org 376154Snate@binkert.org#include "mem/ruby/common/Global.hh" 386154Snate@binkert.org#include "mem/ruby/system/NodeID.hh" 396154Snate@binkert.org#include "mem/ruby/system/MachineID.hh" 406154Snate@binkert.org#include "mem/ruby/common/Address.hh" 416154Snate@binkert.org#include "mem/ruby/common/Set.hh" 426154Snate@binkert.org#include "mem/ruby/common/NetDest.hh" 436154Snate@binkert.org#include "mem/protocol/GenericMachineType.hh" 446285Snate@binkert.org#include "mem/ruby/system/DirectoryMemory.hh" 456145Snate@binkert.org 466145Snate@binkert.org#ifdef MACHINETYPE_L1Cache 476145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache 486145Snate@binkert.org#else 496145Snate@binkert.org#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM 506145Snate@binkert.org#endif 516145Snate@binkert.org 526145Snate@binkert.org#ifdef MACHINETYPE_L2Cache 536145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache 546145Snate@binkert.org#else 556145Snate@binkert.org#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM 566145Snate@binkert.org#endif 576145Snate@binkert.org 586145Snate@binkert.org#ifdef MACHINETYPE_L3Cache 596145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache 606145Snate@binkert.org#else 616145Snate@binkert.org#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM 626145Snate@binkert.org#endif 636145Snate@binkert.org 646785SBrad.Beckmann@amd.com#ifdef MACHINETYPE_DMA 656785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_DMA 666785SBrad.Beckmann@amd.com#else 676785SBrad.Beckmann@amd.com#define MACHINETYPE_DMA_ENUM MachineType_NUM 686785SBrad.Beckmann@amd.com#endif 696785SBrad.Beckmann@amd.com 706785SBrad.Beckmann@amd.com// used to determine the number of acks to wait for 716785SBrad.Beckmann@amd.comint getNumberOfLastLevelCaches(); 726785SBrad.Beckmann@amd.com 736145Snate@binkert.org// used to determine the home directory 746145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 756145Snate@binkert.orginline 766145Snate@binkert.orgNodeID map_Address_to_DirectoryNode(const Address& addr) 776145Snate@binkert.org{ 786285Snate@binkert.org return DirectoryMemory::mapAddressToDirectoryVersion(addr); 796145Snate@binkert.org} 806145Snate@binkert.org 816145Snate@binkert.org// used to determine the home directory 826145Snate@binkert.org// returns a value between 0 and total_directories_within_the_system 836145Snate@binkert.orginline 846145Snate@binkert.orgMachineID map_Address_to_Directory(const Address &addr) 856145Snate@binkert.org{ 866145Snate@binkert.org MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)}; 876145Snate@binkert.org return mach; 886145Snate@binkert.org} 896145Snate@binkert.org 906145Snate@binkert.orginline 916285Snate@binkert.orgMachineID map_Address_to_DMA(const Address & addr) 926145Snate@binkert.org{ 936785SBrad.Beckmann@amd.com MachineID dma = {MACHINETYPE_DMA_ENUM, 0}; 946285Snate@binkert.org return dma; 956145Snate@binkert.org} 966145Snate@binkert.org 976467Sdrh5@cs.wisc.eduinline 986468Sdrh5@cs.wisc.eduMachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits) 996467Sdrh5@cs.wisc.edu{ 1006467Sdrh5@cs.wisc.edu MachineID mach = {type, 0}; 1016468Sdrh5@cs.wisc.edu if (num_bits == 0) 1026468Sdrh5@cs.wisc.edu return mach; 1036468Sdrh5@cs.wisc.edu mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1); 1046467Sdrh5@cs.wisc.edu return mach; 1056467Sdrh5@cs.wisc.edu} 1066467Sdrh5@cs.wisc.edu 1076145Snate@binkert.orgextern inline NodeID machineIDToNodeID(MachineID machID) 1086145Snate@binkert.org{ 1096145Snate@binkert.org return machID.num; 1106145Snate@binkert.org} 1116145Snate@binkert.org 1126145Snate@binkert.orgextern inline MachineType machineIDToMachineType(MachineID machID) 1136145Snate@binkert.org{ 1146145Snate@binkert.org return machID.type; 1156145Snate@binkert.org} 1166145Snate@binkert.org 1176145Snate@binkert.orgextern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID) 1186145Snate@binkert.org{ 1196145Snate@binkert.org assert(machID.type == MachineType_L1Cache); 1206145Snate@binkert.org return machID.num; 1216145Snate@binkert.org} 1226372Sdrh5@cs.wisc.edu 1236145Snate@binkert.orgextern inline MachineID getL1MachineID(NodeID L1RubyNode) 1246145Snate@binkert.org{ 1256145Snate@binkert.org MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode}; 1266145Snate@binkert.org return mach; 1276145Snate@binkert.org} 1286145Snate@binkert.org 1296145Snate@binkert.orgextern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) { 1306145Snate@binkert.org if (machType == MACHINETYPE_L1CACHE_ENUM) { 1316145Snate@binkert.org return GenericMachineType_L1Cache; 1326145Snate@binkert.org } else if (machType == MACHINETYPE_L2CACHE_ENUM) { 1336145Snate@binkert.org return GenericMachineType_L2Cache; 1346145Snate@binkert.org } else if (machType == MACHINETYPE_L3CACHE_ENUM) { 1356145Snate@binkert.org return GenericMachineType_L3Cache; 1366145Snate@binkert.org } else if (machType == MachineType_Directory) { 1376145Snate@binkert.org return GenericMachineType_Directory; 1386145Snate@binkert.org } else { 1396145Snate@binkert.org ERROR_MSG("cannot convert to a GenericMachineType"); 1406145Snate@binkert.org return GenericMachineType_NULL; 1416145Snate@binkert.org } 1426145Snate@binkert.org} 1436145Snate@binkert.org 1446145Snate@binkert.org 1456145Snate@binkert.org#endif // COMPONENTMAPPINGFNS_H 146