mmapped_ipr.hh revision 9180
14120SN/A/*
25417SN/A * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
34120SN/A * All rights reserved.
44120SN/A *
57087SN/A * The license below extends only to copyright in the software and shall
67087SN/A * not be construed as granting a license to any other intellectual
77087SN/A * property including but not limited to intellectual property relating
87087SN/A * to a hardware implementation of the functionality of the software
97087SN/A * licensed hereunder.  You may use the software subject to the license
107087SN/A * terms below provided that you ensure that this notice is replicated
117087SN/A * unmodified and in its entirety in all distributions of the software,
127087SN/A * modified or unmodified, in source code or in binary form.
134120SN/A *
147087SN/A * Redistribution and use in source and binary forms, with or without
157087SN/A * modification, are permitted provided that the following conditions are
167087SN/A * met: redistributions of source code must retain the above copyright
177087SN/A * notice, this list of conditions and the following disclaimer;
187087SN/A * redistributions in binary form must reproduce the above copyright
197087SN/A * notice, this list of conditions and the following disclaimer in the
207087SN/A * documentation and/or other materials provided with the distribution;
217087SN/A * neither the name of the copyright holders nor the names of its
224120SN/A * contributors may be used to endorse or promote products derived from
237087SN/A * this software without specific prior written permission.
244120SN/A *
254120SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
264120SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
274120SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
284120SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
294120SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
304120SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
314120SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
324120SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
334120SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
344120SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
354120SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
364120SN/A *
374120SN/A * Authors: Gabe Black
384120SN/A */
394120SN/A
408105Sgblack@eecs.umich.edu#ifndef __ARCH_X86_MMAPPEDIPR_HH__
418105Sgblack@eecs.umich.edu#define __ARCH_X86_MMAPPEDIPR_HH__
424120SN/A
434152SN/A/**
444152SN/A * @file
454152SN/A *
464152SN/A * ISA-specific helper functions for memory mapped IPR accesses.
474152SN/A */
484152SN/A
499897Sandreas@sandberg.pp.se#include "arch/x86/regs/misc.hh"
507629SN/A#include "cpu/base.hh"
515182SN/A#include "cpu/thread_context.hh"
524152SN/A#include "mem/packet.hh"
534152SN/A
544120SN/Anamespace X86ISA
554120SN/A{
564120SN/A    inline Cycles
579180Sandreas.hansson@arm.com    handleIprRead(ThreadContext *xc, Packet *pkt)
584152SN/A    {
594152SN/A        Addr offset = pkt->getAddr() & mask(3);
609897Sandreas@sandberg.pp.se        MiscRegIndex index = (MiscRegIndex)(pkt->getAddr() / sizeof(MiscReg));
619897Sandreas@sandberg.pp.se        MiscReg data = htog(xc->readMiscReg(index));
629897Sandreas@sandberg.pp.se        // Make sure we don't trot off the end of data.
639897Sandreas@sandberg.pp.se        assert(offset + pkt->getSize() <= sizeof(MiscReg));
649897Sandreas@sandberg.pp.se        pkt->setData(((uint8_t *)&data) + offset);
659897Sandreas@sandberg.pp.se        return Cycles(1);
669897Sandreas@sandberg.pp.se    }
679897Sandreas@sandberg.pp.se
689897Sandreas@sandberg.pp.se    inline Cycles
699897Sandreas@sandberg.pp.se    handleIprWrite(ThreadContext *xc, Packet *pkt)
709897Sandreas@sandberg.pp.se    {
719897Sandreas@sandberg.pp.se        Addr offset = pkt->getAddr() & mask(3);
724152SN/A        MiscRegIndex index = (MiscRegIndex)(pkt->getAddr() / sizeof(MiscReg));
734152SN/A        MiscReg data;
749180Sandreas.hansson@arm.com        data = htog(xc->readMiscRegNoEffect(index));
754152SN/A        // Make sure we don't trot off the end of data.
764152SN/A        assert(offset + pkt->getSize() <= sizeof(MiscReg));
779897Sandreas@sandberg.pp.se        pkt->writeData(((uint8_t *)&data) + offset);
789897Sandreas@sandberg.pp.se        xc->setMiscReg(index, gtoh(data));
799897Sandreas@sandberg.pp.se        return Cycles(1);
809897Sandreas@sandberg.pp.se    }
819897Sandreas@sandberg.pp.se}
829897Sandreas@sandberg.pp.se
839897Sandreas@sandberg.pp.se#endif // __ARCH_X86_MMAPPEDIPR_HH__
849897Sandreas@sandberg.pp.se