faults.cc revision 6019
16019Shines@cs.fsu.edu/*
27093Sgblack@eecs.umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan
37093Sgblack@eecs.umich.edu * All rights reserved.
47093Sgblack@eecs.umich.edu *
57093Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
67093Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
77093Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
87093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
97093Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
107093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
117093Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
127093Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
137093Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146019Shines@cs.fsu.edu * this software without specific prior written permission.
156019Shines@cs.fsu.edu *
166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276019Shines@cs.fsu.edu *
286019Shines@cs.fsu.edu * Authors: Nathan Binkert
296019Shines@cs.fsu.edu *          Gabe Black
306019Shines@cs.fsu.edu */
316019Shines@cs.fsu.edu
326019Shines@cs.fsu.edu#include "arch/isa_traits.hh"
336019Shines@cs.fsu.edu#include "base/misc.hh"
346019Shines@cs.fsu.edu#include "cpu/thread_context.hh"
356019Shines@cs.fsu.edu#include "cpu/base.hh"
366019Shines@cs.fsu.edu#include "sim/faults.hh"
376019Shines@cs.fsu.edu#include "sim/process.hh"
386019Shines@cs.fsu.edu#include "mem/page_table.hh"
396019Shines@cs.fsu.edu
406019Shines@cs.fsu.edu#if !FULL_SYSTEM
416735Sgblack@eecs.umich.eduvoid FaultBase::invoke(ThreadContext * tc)
426735Sgblack@eecs.umich.edu{
436019Shines@cs.fsu.edu    fatal("fault (%s) detected @ PC %p", name(), tc->readPC());
446019Shines@cs.fsu.edu}
456019Shines@cs.fsu.edu#else
466019Shines@cs.fsu.eduvoid FaultBase::invoke(ThreadContext * tc)
476019Shines@cs.fsu.edu{
486019Shines@cs.fsu.edu    DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), tc->readPC());
496019Shines@cs.fsu.edu    tc->getCpuPtr()->recordEvent(csprintf("Fault %s", name()));
506019Shines@cs.fsu.edu
516019Shines@cs.fsu.edu    assert(!tc->misspeculating());
526019Shines@cs.fsu.edu}
537362Sgblack@eecs.umich.edu#endif
546735Sgblack@eecs.umich.edu
556019Shines@cs.fsu.eduvoid UnimpFault::invoke(ThreadContext * tc)
567362Sgblack@eecs.umich.edu{
576735Sgblack@eecs.umich.edu    fatal("Unimpfault: %s\n", panicStr.c_str());
586019Shines@cs.fsu.edu}
597362Sgblack@eecs.umich.edu
606735Sgblack@eecs.umich.edu#if !FULL_SYSTEM
616019Shines@cs.fsu.eduvoid GenericPageTableFault::invoke(ThreadContext *tc)
627362Sgblack@eecs.umich.edu{
636735Sgblack@eecs.umich.edu    Process *p = tc->getProcessPtr();
646019Shines@cs.fsu.edu
657362Sgblack@eecs.umich.edu    if (!p->checkAndAllocNextPage(vaddr))
666735Sgblack@eecs.umich.edu        panic("Page table fault when accessing virtual address %#x\n", vaddr);
676019Shines@cs.fsu.edu
687362Sgblack@eecs.umich.edu}
696735Sgblack@eecs.umich.edu
706019Shines@cs.fsu.eduvoid GenericAlignmentFault::invoke(ThreadContext *tc)
717362Sgblack@eecs.umich.edu{
726735Sgblack@eecs.umich.edu    panic("Alignment fault when accessing virtual address %#x\n", vaddr);
736019Shines@cs.fsu.edu}
746735Sgblack@eecs.umich.edu#endif
757362Sgblack@eecs.umich.edu