system.cc revision 2680
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
382158SN/A#include "arch/alpha/system.hh"
392212SN/A#include "arch/alpha/freebsd/system.hh"
401782SN/A#include "base/loader/symtab.hh"
412680Sktlim@umich.edu#include "cpu/thread_context.hh"
422521SN/A#include "mem/physical.hh"
432521SN/A#include "mem/port.hh"
442234SN/A#include "arch/isa_traits.hh"
451782SN/A#include "sim/builder.hh"
462036SN/A#include "sim/byteswap.hh"
472170SN/A#include "arch/vtophys.hh"
481782SN/A
491847SN/A#define TIMER_FREQUENCY 1193180
501847SN/A
511782SN/Ausing namespace std;
522212SN/Ausing namespace AlphaISA;
531782SN/A
542212SN/AFreebsdAlphaSystem::FreebsdAlphaSystem(Params *p)
552158SN/A    : AlphaSystem(p)
561782SN/A{
571782SN/A    /**
581823SN/A     * Any time DELAY is called just skip the function.
591885SN/A     * Shouldn't we actually emulate the delay?
601782SN/A     */
611885SN/A    skipDelayEvent = addKernelFuncEvent<SkipFuncEvent>("DELAY");
621885SN/A    skipCalibrateClocks =
631885SN/A        addKernelFuncEvent<SkipCalibrateClocksEvent>("calibrate_clocks");
641782SN/A}
651782SN/A
661821SN/A
672212SN/AFreebsdAlphaSystem::~FreebsdAlphaSystem()
681782SN/A{
691782SN/A    delete skipDelayEvent;
701821SN/A    delete skipCalibrateClocks;
711821SN/A}
721821SN/A
731821SN/A
741821SN/Avoid
752680Sktlim@umich.eduFreebsdAlphaSystem::doCalibrateClocks(ThreadContext *tc)
761821SN/A{
771821SN/A    Addr ppc_vaddr = 0;
781821SN/A    Addr timer_vaddr = 0;
791821SN/A
802680Sktlim@umich.edu    ppc_vaddr = (Addr)tc->readIntReg(ArgumentReg1);
812680Sktlim@umich.edu    timer_vaddr = (Addr)tc->readIntReg(ArgumentReg2);
821821SN/A
832521SN/A    virtPort.write(ppc_vaddr, (uint32_t)Clock::Frequency);
842521SN/A    virtPort.write(timer_vaddr, (uint32_t)TIMER_FREQUENCY);
851782SN/A}
861782SN/A
871782SN/A
881885SN/Avoid
892680Sktlim@umich.eduFreebsdAlphaSystem::SkipCalibrateClocksEvent::process(ThreadContext *tc)
901885SN/A{
912680Sktlim@umich.edu    SkipFuncEvent::process(tc);
922680Sktlim@umich.edu    ((FreebsdAlphaSystem *)tc->getSystemPtr())->doCalibrateClocks(tc);
931885SN/A}
941885SN/A
951885SN/A
962212SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
971782SN/A
981782SN/A    Param<Tick> boot_cpu_frequency;
991782SN/A    SimObjectParam<PhysicalMemory *> physmem;
1001782SN/A
1011782SN/A    Param<string> kernel;
1021782SN/A    Param<string> console;
1031782SN/A    Param<string> pal;
1041782SN/A
1051782SN/A    Param<string> boot_osflags;
1061782SN/A    Param<string> readfile;
1071782SN/A    Param<unsigned int> init_param;
1081782SN/A
1091782SN/A    Param<uint64_t> system_type;
1101782SN/A    Param<uint64_t> system_rev;
1111782SN/A
1121782SN/A    Param<bool> bin;
1131782SN/A    VectorParam<string> binned_fns;
1141782SN/A    Param<bool> bin_int;
1151782SN/A
1162212SN/AEND_DECLARE_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
1171782SN/A
1182212SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
1191782SN/A
1201782SN/A    INIT_PARAM(boot_cpu_frequency, "Frequency of the boot CPU"),
1211782SN/A    INIT_PARAM(physmem, "phsyical memory"),
1221782SN/A    INIT_PARAM(kernel, "file that contains the kernel code"),
1231782SN/A    INIT_PARAM(console, "file that contains the console code"),
1241782SN/A    INIT_PARAM(pal, "file that contains palcode"),
1251782SN/A    INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
1261782SN/A                    "a"),
1271782SN/A    INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
1281782SN/A    INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
1291782SN/A    INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 34),
1301782SN/A    INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 1<<10),
1311782SN/A    INIT_PARAM_DFLT(bin, "is this system to be binned", false),
1321782SN/A    INIT_PARAM(binned_fns, "functions to be broken down and binned"),
1331782SN/A    INIT_PARAM_DFLT(bin_int, "is interrupt code binned seperately?", true)
1341782SN/A
1352212SN/AEND_INIT_SIM_OBJECT_PARAMS(FreebsdAlphaSystem)
1361782SN/A
1372212SN/ACREATE_SIM_OBJECT(FreebsdAlphaSystem)
1381782SN/A{
1392158SN/A    AlphaSystem::Params *p = new AlphaSystem::Params;
1401782SN/A    p->name = getInstanceName();
1411782SN/A    p->boot_cpu_frequency = boot_cpu_frequency;
1421782SN/A    p->physmem = physmem;
1431782SN/A    p->kernel_path = kernel;
1441782SN/A    p->console_path = console;
1451782SN/A    p->palcode = pal;
1461782SN/A    p->boot_osflags = boot_osflags;
1471782SN/A    p->init_param = init_param;
1481782SN/A    p->readfile = readfile;
1491782SN/A    p->system_type = system_type;
1501782SN/A    p->system_rev = system_rev;
1511782SN/A    p->bin = bin;
1521782SN/A    p->binned_fns = binned_fns;
1531782SN/A    p->bin_int = bin_int;
1542212SN/A    return new FreebsdAlphaSystem(p);
1551782SN/A}
1561782SN/A
1572212SN/AREGISTER_SIM_OBJECT("FreebsdAlphaSystem", FreebsdAlphaSystem)
1581782SN/A
159