msr.hh revision 9875
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
348582Sgblack@eecs.umich.edu#include "arch/x86/regs/misc.hh"
359875Sandreas@sandberg.pp.se#include "base/hashmap.hh"
368582Sgblack@eecs.umich.edu#include "base/types.hh"
378582Sgblack@eecs.umich.edu
388582Sgblack@eecs.umich.edunamespace X86ISA
398582Sgblack@eecs.umich.edu{
408582Sgblack@eecs.umich.edu
419875Sandreas@sandberg.pp.setypedef m5::hash_map<Addr, MiscRegIndex> MsrMap;
429875Sandreas@sandberg.pp.se
439875Sandreas@sandberg.pp.se/**
449875Sandreas@sandberg.pp.se * Map between MSR addresses and their corresponding misc registers.
459875Sandreas@sandberg.pp.se *
469875Sandreas@sandberg.pp.se * @note This map is usually only used when enumeration of supported
479875Sandreas@sandberg.pp.se * MSRs is needed (e.g., in virtualized CPUs). Code that needs to
489875Sandreas@sandberg.pp.se * look-up specific MSRs should use msrAddrToIndex().
499875Sandreas@sandberg.pp.se */
509875Sandreas@sandberg.pp.seextern const MsrMap msrMap;
519875Sandreas@sandberg.pp.se
529875Sandreas@sandberg.pp.se/**
539875Sandreas@sandberg.pp.se * Find and return the misc reg corresponding to an MSR address.
549875Sandreas@sandberg.pp.se *
559875Sandreas@sandberg.pp.se * Look for an MSR (addr) in #msrMap and return the
569875Sandreas@sandberg.pp.se * corresponding misc reg in regNum. The value of regNum is undefined
579875Sandreas@sandberg.pp.se * if the MSR was not found.
589875Sandreas@sandberg.pp.se *
599875Sandreas@sandberg.pp.se * @param regNum misc reg index (out).
609875Sandreas@sandberg.pp.se * @param addr MSR address
619875Sandreas@sandberg.pp.se * @return True if the MSR was found, false otherwise.
629875Sandreas@sandberg.pp.se */
638582Sgblack@eecs.umich.edubool msrAddrToIndex(MiscRegIndex &regNum, Addr addr);
648582Sgblack@eecs.umich.edu
658582Sgblack@eecs.umich.edu} // namespace X86ISA
668582Sgblack@eecs.umich.edu
678582Sgblack@eecs.umich.edu#endif // __ARCH_X86_REG_MSR_HH__
68