system.cc revision 8706
11782SN/A/*
21782SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
31782SN/A * All rights reserved.
41782SN/A *
51782SN/A * Redistribution and use in source and binary forms, with or without
61782SN/A * modification, are permitted provided that the following conditions are
71782SN/A * met: redistributions of source code must retain the above copyright
81782SN/A * notice, this list of conditions and the following disclaimer;
91782SN/A * redistributions in binary form must reproduce the above copyright
101782SN/A * notice, this list of conditions and the following disclaimer in the
111782SN/A * documentation and/or other materials provided with the distribution;
121782SN/A * neither the name of the copyright holders nor the names of its
131782SN/A * contributors may be used to endorse or promote products derived from
141782SN/A * this software without specific prior written permission.
151782SN/A *
161782SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171782SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181782SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191782SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201782SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211782SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221782SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231782SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241782SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251782SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261782SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Ben Nash
291782SN/A */
301782SN/A
311782SN/A/**
321782SN/A * @file
331835SN/A * Modifications for the FreeBSD kernel.
341835SN/A * Based on kern/linux/linux_system.cc.
351782SN/A *
361782SN/A */
371782SN/A
384762Snate@binkert.org#include "arch/alpha/freebsd/system.hh"
392158SN/A#include "arch/alpha/system.hh"
404762Snate@binkert.org#include "arch/isa_traits.hh"
414762Snate@binkert.org#include "arch/vtophys.hh"
421782SN/A#include "base/loader/symtab.hh"
432680Sktlim@umich.edu#include "cpu/thread_context.hh"
448706Sandreas.hansson@arm.com#include "mem/fs_translating_port_proxy.hh"
452036SN/A#include "sim/byteswap.hh"
461782SN/A
471847SN/A#define TIMER_FREQUENCY 1193180
481847SN/A
491782SN/Ausing namespace std;
502212SN/Ausing namespace AlphaISA;
511782SN/A
522212SN/AFreebsdAlphaSystem::FreebsdAlphaSystem(Params *p)
532158SN/A    : AlphaSystem(p)
541782SN/A{
551782SN/A    /**
561823SN/A     * Any time DELAY is called just skip the function.
571885SN/A     * Shouldn't we actually emulate the delay?
581782SN/A     */
591885SN/A    skipDelayEvent = addKernelFuncEvent<SkipFuncEvent>("DELAY");
601885SN/A    skipCalibrateClocks =
611885SN/A        addKernelFuncEvent<SkipCalibrateClocksEvent>("calibrate_clocks");
621782SN/A}
631782SN/A
642212SN/AFreebsdAlphaSystem::~FreebsdAlphaSystem()
651782SN/A{
661782SN/A    delete skipDelayEvent;
671821SN/A    delete skipCalibrateClocks;
681821SN/A}
691821SN/A
701821SN/Avoid
712680Sktlim@umich.eduFreebsdAlphaSystem::doCalibrateClocks(ThreadContext *tc)
721821SN/A{
731821SN/A    Addr ppc_vaddr = 0;
741821SN/A    Addr timer_vaddr = 0;
751821SN/A
765958Sgblack@eecs.umich.edu    ppc_vaddr = (Addr)tc->readIntReg(17);
775958Sgblack@eecs.umich.edu    timer_vaddr = (Addr)tc->readIntReg(18);
781821SN/A
798706Sandreas.hansson@arm.com    virtProxy->write(ppc_vaddr, (uint32_t)SimClock::Frequency);
808706Sandreas.hansson@arm.com    virtProxy->write(timer_vaddr, (uint32_t)TIMER_FREQUENCY);
811782SN/A}
821782SN/A
831885SN/Avoid
842680Sktlim@umich.eduFreebsdAlphaSystem::SkipCalibrateClocksEvent::process(ThreadContext *tc)
851885SN/A{
862680Sktlim@umich.edu    SkipFuncEvent::process(tc);
872680Sktlim@umich.edu    ((FreebsdAlphaSystem *)tc->getSystemPtr())->doCalibrateClocks(tc);
881885SN/A}
891885SN/A
904762Snate@binkert.orgFreebsdAlphaSystem *
914762Snate@binkert.orgFreebsdAlphaSystemParams::create()
921782SN/A{
934762Snate@binkert.org    return new FreebsdAlphaSystem(this);
941782SN/A}
95