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 497629SN/A#include "arch/x86/regs/misc.hh" 505182SN/A#include "cpu/base.hh" 514152SN/A#include "cpu/thread_context.hh" 524152SN/A#include "mem/packet.hh" 534120SN/A 544120SN/Anamespace X86ISA 554120SN/A{ 569180Sandreas.hansson@arm.com inline Cycles 574152SN/A handleIprRead(ThreadContext *xc, Packet *pkt) 584152SN/A { 595417SN/A Addr offset = pkt->getAddr() & mask(3); 605360SN/A MiscRegIndex index = (MiscRegIndex)(pkt->getAddr() / sizeof(MiscReg)); 615417SN/A MiscReg data = htog(xc->readMiscReg(index)); 625417SN/A // Make sure we don't trot off the end of data. 635417SN/A assert(offset + pkt->getSize() <= sizeof(MiscReg)); 645417SN/A pkt->setData(((uint8_t *)&data) + offset); 659180Sandreas.hansson@arm.com return Cycles(1); 664152SN/A } 674152SN/A 689180Sandreas.hansson@arm.com inline Cycles 694152SN/A handleIprWrite(ThreadContext *xc, Packet *pkt) 704152SN/A { 715417SN/A Addr offset = pkt->getAddr() & mask(3); 725357SN/A MiscRegIndex index = (MiscRegIndex)(pkt->getAddr() / sizeof(MiscReg)); 735647SN/A MiscReg data; 745648SN/A data = htog(xc->readMiscRegNoEffect(index)); 755417SN/A // Make sure we don't trot off the end of data. 765417SN/A assert(offset + pkt->getSize() <= sizeof(MiscReg)); 775417SN/A pkt->writeData(((uint8_t *)&data) + offset); 785417SN/A xc->setMiscReg(index, gtoh(data)); 799180Sandreas.hansson@arm.com return Cycles(1); 804152SN/A } 818902Sandreas.hansson@arm.com} 824120SN/A 838105Sgblack@eecs.umich.edu#endif // __ARCH_X86_MMAPPEDIPR_HH__ 84