18582Sgblack@eecs.umich.edu/*
28582Sgblack@eecs.umich.edu * Copyright (c) 2011 Google
38582Sgblack@eecs.umich.edu * All rights reserved.
48582Sgblack@eecs.umich.edu *
58582Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
68582Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
78582Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
88582Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
98582Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
108582Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
118582Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
128582Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
138582Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
148582Sgblack@eecs.umich.edu * this software without specific prior written permission.
158582Sgblack@eecs.umich.edu *
168582Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178582Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
188582Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198582Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208582Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218582Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228582Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238582Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
248582Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258582Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268582Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278582Sgblack@eecs.umich.edu *
288582Sgblack@eecs.umich.edu * Authors: Gabe Black
298582Sgblack@eecs.umich.edu */
308582Sgblack@eecs.umich.edu
318582Sgblack@eecs.umich.edu#ifndef __ARCH_X86_REG_MSR_HH__
328582Sgblack@eecs.umich.edu#define __ARCH_X86_REG_MSR_HH__
338582Sgblack@eecs.umich.edu
3411168Sandreas.hansson@arm.com#include <unordered_map>
3511168Sandreas.hansson@arm.com
368582Sgblack@eecs.umich.edu#include "arch/x86/regs/misc.hh"
378582Sgblack@eecs.umich.edu#include "base/types.hh"
388582Sgblack@eecs.umich.edu
398582Sgblack@eecs.umich.edunamespace X86ISA
408582Sgblack@eecs.umich.edu{
418582Sgblack@eecs.umich.edu
4211168Sandreas.hansson@arm.comtypedef std::unordered_map<Addr, MiscRegIndex> MsrMap;
439875Sandreas@sandberg.pp.se
449875Sandreas@sandberg.pp.se/**
459875Sandreas@sandberg.pp.se * Map between MSR addresses and their corresponding misc registers.
469875Sandreas@sandberg.pp.se *
479875Sandreas@sandberg.pp.se * @note This map is usually only used when enumeration of supported
489875Sandreas@sandberg.pp.se * MSRs is needed (e.g., in virtualized CPUs). Code that needs to
499875Sandreas@sandberg.pp.se * look-up specific MSRs should use msrAddrToIndex().
509875Sandreas@sandberg.pp.se */
519875Sandreas@sandberg.pp.seextern const MsrMap msrMap;
529875Sandreas@sandberg.pp.se
539875Sandreas@sandberg.pp.se/**
549875Sandreas@sandberg.pp.se * Find and return the misc reg corresponding to an MSR address.
559875Sandreas@sandberg.pp.se *
569875Sandreas@sandberg.pp.se * Look for an MSR (addr) in #msrMap and return the
579875Sandreas@sandberg.pp.se * corresponding misc reg in regNum. The value of regNum is undefined
589875Sandreas@sandberg.pp.se * if the MSR was not found.
599875Sandreas@sandberg.pp.se *
609875Sandreas@sandberg.pp.se * @param regNum misc reg index (out).
619875Sandreas@sandberg.pp.se * @param addr MSR address
629875Sandreas@sandberg.pp.se * @return True if the MSR was found, false otherwise.
639875Sandreas@sandberg.pp.se */
648582Sgblack@eecs.umich.edubool msrAddrToIndex(MiscRegIndex &regNum, Addr addr);
658582Sgblack@eecs.umich.edu
668582Sgblack@eecs.umich.edu} // namespace X86ISA
678582Sgblack@eecs.umich.edu
688582Sgblack@eecs.umich.edu#endif // __ARCH_X86_REG_MSR_HH__
69