Merge iceaxe.:/Volumes/work/research/m5/head
[gem5.git] / src / arch / alpha / tru64 / system.cc
1 /*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 * Lisa Hsu
30 */
31
32 #include "arch/alpha/tru64/system.hh"
33 #include "arch/isa_traits.hh"
34 #include "arch/vtophys.hh"
35 #include "base/loader/symtab.hh"
36 #include "base/trace.hh"
37 #include "cpu/base.hh"
38 #include "cpu/thread_context.hh"
39 #include "kern/tru64/tru64_events.hh"
40 #include "kern/system_events.hh"
41 #include "mem/physical.hh"
42 #include "mem/port.hh"
43 #include "sim/builder.hh"
44
45 using namespace std;
46
47 Tru64AlphaSystem::Tru64AlphaSystem(Tru64AlphaSystem::Params *p)
48 : AlphaSystem(p)
49 {
50 Addr addr = 0;
51 if (kernelSymtab->findAddress("enable_async_printf", addr)) {
52 virtPort.write(addr, (uint32_t)0);
53 }
54
55 #ifdef DEBUG
56 kernelPanicEvent = addKernelFuncEvent<BreakPCEvent>("panic");
57 if (!kernelPanicEvent)
58 panic("could not find kernel symbol \'panic\'");
59 #endif
60
61 badaddrEvent = addKernelFuncEvent<BadAddrEvent>("badaddr");
62 if (!badaddrEvent)
63 panic("could not find kernel symbol \'badaddr\'");
64
65 skipPowerStateEvent =
66 addKernelFuncEvent<SkipFuncEvent>("tl_v48_capture_power_state");
67 skipScavengeBootEvent =
68 addKernelFuncEvent<SkipFuncEvent>("pmap_scavenge_boot");
69
70 #if TRACING_ON
71 printfEvent = addKernelFuncEvent<PrintfEvent>("printf");
72 debugPrintfEvent = addKernelFuncEvent<DebugPrintfEvent>("m5printf");
73 debugPrintfrEvent = addKernelFuncEvent<DebugPrintfrEvent>("m5printfr");
74 dumpMbufEvent = addKernelFuncEvent<DumpMbufEvent>("m5_dump_mbuf");
75 #endif
76 }
77
78 Tru64AlphaSystem::~Tru64AlphaSystem()
79 {
80 #ifdef DEBUG
81 delete kernelPanicEvent;
82 #endif
83 delete badaddrEvent;
84 delete skipPowerStateEvent;
85 delete skipScavengeBootEvent;
86 #if TRACING_ON
87 delete printfEvent;
88 delete debugPrintfEvent;
89 delete debugPrintfrEvent;
90 delete dumpMbufEvent;
91 #endif
92 }
93
94 BEGIN_DECLARE_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
95
96 Param<Tick> boot_cpu_frequency;
97 SimObjectParam<PhysicalMemory *> physmem;
98
99 Param<string> kernel;
100 Param<string> console;
101 Param<string> pal;
102
103 Param<string> boot_osflags;
104 Param<string> readfile;
105 Param<unsigned int> init_param;
106
107 Param<uint64_t> system_type;
108 Param<uint64_t> system_rev;
109
110 END_DECLARE_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
111
112 BEGIN_INIT_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
113
114 INIT_PARAM(boot_cpu_frequency, "frequency of the boot cpu"),
115 INIT_PARAM(physmem, "phsyical memory"),
116 INIT_PARAM(kernel, "file that contains the kernel code"),
117 INIT_PARAM(console, "file that contains the console code"),
118 INIT_PARAM(pal, "file that contains palcode"),
119 INIT_PARAM_DFLT(boot_osflags, "flags to pass to the kernel during boot",
120 "a"),
121 INIT_PARAM_DFLT(readfile, "file to read startup script from", ""),
122 INIT_PARAM_DFLT(init_param, "numerical value to pass into simulator", 0),
123 INIT_PARAM_DFLT(system_type, "Type of system we are emulating", 12),
124 INIT_PARAM_DFLT(system_rev, "Revision of system we are emulating", 2<<1)
125
126 END_INIT_SIM_OBJECT_PARAMS(Tru64AlphaSystem)
127
128 CREATE_SIM_OBJECT(Tru64AlphaSystem)
129 {
130 AlphaSystem::Params *p = new AlphaSystem::Params;
131 p->name = getInstanceName();
132 p->boot_cpu_frequency = boot_cpu_frequency;
133 p->physmem = physmem;
134 p->kernel_path = kernel;
135 p->console_path = console;
136 p->palcode = pal;
137 p->boot_osflags = boot_osflags;
138 p->init_param = init_param;
139 p->readfile = readfile;
140 p->system_type = system_type;
141 p->system_rev = system_rev;
142
143 return new Tru64AlphaSystem(p);
144 }
145
146 REGISTER_SIM_OBJECT("Tru64AlphaSystem", Tru64AlphaSystem)