utility.hh revision 7707
111661Stushar@ece.gatech.edu/*
211661Stushar@ece.gatech.edu * Copyright (c) 2007 The Hewlett-Packard Development Company
311661Stushar@ece.gatech.edu * All rights reserved.
411661Stushar@ece.gatech.edu *
511661Stushar@ece.gatech.edu * The license below extends only to copyright in the software and shall
611661Stushar@ece.gatech.edu * not be construed as granting a license to any other intellectual
711661Stushar@ece.gatech.edu * property including but not limited to intellectual property relating
811661Stushar@ece.gatech.edu * to a hardware implementation of the functionality of the software
911661Stushar@ece.gatech.edu * licensed hereunder.  You may use the software subject to the license
1011661Stushar@ece.gatech.edu * terms below provided that you ensure that this notice is replicated
1111661Stushar@ece.gatech.edu * unmodified and in its entirety in all distributions of the software,
1211661Stushar@ece.gatech.edu * modified or unmodified, in source code or in binary form.
1311661Stushar@ece.gatech.edu *
1411661Stushar@ece.gatech.edu * Redistribution and use in source and binary forms, with or without
1511661Stushar@ece.gatech.edu * modification, are permitted provided that the following conditions are
1611661Stushar@ece.gatech.edu * met: redistributions of source code must retain the above copyright
1711661Stushar@ece.gatech.edu * notice, this list of conditions and the following disclaimer;
1811661Stushar@ece.gatech.edu * redistributions in binary form must reproduce the above copyright
1911661Stushar@ece.gatech.edu * notice, this list of conditions and the following disclaimer in the
2011661Stushar@ece.gatech.edu * documentation and/or other materials provided with the distribution;
2111661Stushar@ece.gatech.edu * neither the name of the copyright holders nor the names of its
2211661Stushar@ece.gatech.edu * contributors may be used to endorse or promote products derived from
2311661Stushar@ece.gatech.edu * this software without specific prior written permission.
2411661Stushar@ece.gatech.edu *
2511661Stushar@ece.gatech.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2611661Stushar@ece.gatech.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2711661Stushar@ece.gatech.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2811661Stushar@ece.gatech.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2911661Stushar@ece.gatech.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3011661Stushar@ece.gatech.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3111793Sbrandon.potter@amd.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3211793Sbrandon.potter@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3311661Stushar@ece.gatech.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3411661Stushar@ece.gatech.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3511661Stushar@ece.gatech.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3611661Stushar@ece.gatech.edu *
3711661Stushar@ece.gatech.edu * Authors: Gabe Black
3811661Stushar@ece.gatech.edu */
3911661Stushar@ece.gatech.edu
4011661Stushar@ece.gatech.edu#ifndef __ARCH_X86_UTILITY_HH__
4111661Stushar@ece.gatech.edu#define __ARCH_X86_UTILITY_HH__
4211661Stushar@ece.gatech.edu
4311661Stushar@ece.gatech.edu#include "arch/x86/regs/misc.hh"
4411661Stushar@ece.gatech.edu#include "arch/x86/types.hh"
4511661Stushar@ece.gatech.edu#include "base/hashmap.hh"
4611661Stushar@ece.gatech.edu#include "base/misc.hh"
4711661Stushar@ece.gatech.edu#include "base/types.hh"
4811661Stushar@ece.gatech.edu#include "config/full_system.hh"
4911661Stushar@ece.gatech.edu#include "cpu/thread_context.hh"
5011661Stushar@ece.gatech.edu
5111661Stushar@ece.gatech.educlass ThreadContext;
5211661Stushar@ece.gatech.edu
5311661Stushar@ece.gatech.edunamespace X86ISA
5411661Stushar@ece.gatech.edu{
5511661Stushar@ece.gatech.edu    uint64_t
5611661Stushar@ece.gatech.edu    getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
5711661Stushar@ece.gatech.edu
5811661Stushar@ece.gatech.edu    static inline bool
5911661Stushar@ece.gatech.edu    inUserMode(ThreadContext *tc)
6011661Stushar@ece.gatech.edu    {
6111661Stushar@ece.gatech.edu#if FULL_SYSTEM
6211661Stushar@ece.gatech.edu        HandyM5Reg m5reg = tc->readMiscRegNoEffect(MISCREG_M5_REG);
6311661Stushar@ece.gatech.edu        return m5reg.cpl == 3;
6411661Stushar@ece.gatech.edu#else
6511661Stushar@ece.gatech.edu        return true;
6611661Stushar@ece.gatech.edu#endif
6711661Stushar@ece.gatech.edu    }
6811661Stushar@ece.gatech.edu
6911661Stushar@ece.gatech.edu    /**
7011661Stushar@ece.gatech.edu     * Function to insure ISA semantics about 0 registers.
7111661Stushar@ece.gatech.edu     * @param tc The thread context.
7211661Stushar@ece.gatech.edu     */
7311661Stushar@ece.gatech.edu    template <class TC>
7411661Stushar@ece.gatech.edu    void zeroRegisters(TC *tc);
7511661Stushar@ece.gatech.edu
7611661Stushar@ece.gatech.edu#if FULL_SYSTEM
7711661Stushar@ece.gatech.edu
7811661Stushar@ece.gatech.edu    void initCPU(ThreadContext *tc, int cpuId);
7912129Sspwilson2@wisc.edu
8012129Sspwilson2@wisc.edu#endif
8111661Stushar@ece.gatech.edu
8211661Stushar@ece.gatech.edu    void startupCPU(ThreadContext *tc, int cpuId);
8311661Stushar@ece.gatech.edu
8411661Stushar@ece.gatech.edu    void copyRegs(ThreadContext *src, ThreadContext *dest);
8511661Stushar@ece.gatech.edu
8611661Stushar@ece.gatech.edu    void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
8711661Stushar@ece.gatech.edu
8811661Stushar@ece.gatech.edu    void skipFunction(ThreadContext *tc);
8911661Stushar@ece.gatech.edu};
9011661Stushar@ece.gatech.edu
9111661Stushar@ece.gatech.edu#endif // __ARCH_X86_UTILITY_HH__
9211661Stushar@ece.gatech.edu