fs.py revision 2948
1import optparse, os, sys
2
3import m5
4from m5.objects import *
5from SysPaths import *
6from FullO3Config import *
7
8parser = optparse.OptionParser()
9
10parser.add_option("-d", "--detailed", action="store_true")
11parser.add_option("-t", "--timing", action="store_true")
12parser.add_option("-m", "--maxtick", type="int")
13parser.add_option("--maxtime", type="float")
14parser.add_option("--dual", help="Run full system using dual systems",
15                  action="store_true")
16
17(options, args) = parser.parse_args()
18
19if args:
20    print "Error: script doesn't take any positional arguments"
21    sys.exit(1)
22
23# Base for tests is directory containing this file.
24test_base = os.path.dirname(__file__)
25
26script.dir =  '/z/saidi/work/m5.newmem/configs/boot'
27
28linux_image = env.get('LINUX_IMAGE', disk('linux-latest.img'))
29
30class CowIdeDisk(IdeDisk):
31    image = CowDiskImage(child=RawDiskImage(read_only=True),
32                         read_only=False)
33
34    def childImage(self, ci):
35        self.image.child.image_file = ci
36
37class BaseTsunami(Tsunami):
38    ethernet = NSGigE(configdata=NSGigEPciData(),
39                      pci_bus=0, pci_dev=1, pci_func=0)
40    etherint = NSGigEInt(device=Parent.ethernet)
41    ide = IdeController(disks=[Parent.disk0, Parent.disk2],
42                        pci_func=0, pci_dev=0, pci_bus=0)
43
44class MyLinuxAlphaSystem(LinuxAlphaSystem):
45    iobus = Bus(bus_id=0)
46    membus = Bus(bus_id=1)
47    bridge = Bridge()
48    physmem = PhysicalMemory(range = AddrRange('128MB'))
49    bridge.side_a = iobus.port
50    bridge.side_b = membus.port
51    physmem.port = membus.port
52    disk0 = CowIdeDisk(driveID='master')
53    disk2 = CowIdeDisk(driveID='master')
54    disk0.childImage(linux_image)
55    disk2.childImage(disk('linux-bigswap2.img'))
56    tsunami = BaseTsunami()
57    tsunami.attachIO(iobus)
58    tsunami.ide.pio = iobus.port
59    tsunami.ide.dma = iobus.port
60    tsunami.ide.config = iobus.port
61    tsunami.ethernet.pio = iobus.port
62    tsunami.ethernet.dma = iobus.port
63    tsunami.ethernet.config = iobus.port
64    simple_disk = SimpleDisk(disk=RawDiskImage(image_file = linux_image,
65                                               read_only = True))
66    intrctrl = IntrControl()
67    if options.detailed:
68        cpu = DetailedO3CPU()
69    elif options.timing:
70        cpu = TimingSimpleCPU()
71        mem_mode = 'timing'
72    else:
73        cpu = AtomicSimpleCPU()
74    cpu.mem = membus
75    cpu.icache_port = membus.port
76    cpu.dcache_port = membus.port
77    cpu.itb = AlphaITB()
78    cpu.dtb = AlphaDTB()
79    cpu.clock = '2GHz'
80    sim_console = SimConsole(listener=ConsoleListener(port=3456))
81    kernel = binary('vmlinux')
82    pal = binary('ts_osfpal')
83    console = binary('console')
84    boot_osflags = 'root=/dev/hda1 console=ttyS0'
85
86class TsunamiRoot(Root):
87    pass
88
89def DualRoot(clientSystem, serverSystem):
90    self = Root()
91    self.client = clientSystem
92    self.server = serverSystem
93
94    self.etherdump = EtherDump(file='ethertrace')
95    self.etherlink = EtherLink(int1 = Parent.client.tsunami.etherint[0],
96                               int2 = Parent.server.tsunami.etherint[0],
97                               dump = Parent.etherdump)
98    self.clock = '1THz'
99    return self
100
101if options.dual:
102    root = DualRoot(
103        MyLinuxAlphaSystem(readfile=script('netperf-stream-nt-client.rcS')),
104        MyLinuxAlphaSystem(readfile=script('netperf-server.rcS')))
105else:
106    root = TsunamiRoot(clock = '1THz', system = MyLinuxAlphaSystem())
107
108m5.instantiate(root)
109
110#exit_event = m5.simulate(2600000000000)
111#if exit_event.getCause() != "user interrupt received":
112#    m5.checkpoint(root, 'cpt')
113#    exit_event = m5.simulate(300000000000)
114#    if exit_event.getCause() != "user interrupt received":
115#        m5.checkpoint(root, 'cptA')
116
117
118if options.maxtick:
119    exit_event = m5.simulate(options.maxtick)
120elif options.maxtime:
121    simtime = int(options.maxtime * root.clock.value)
122    print "simulating for: ", simtime
123    exit_event = m5.simulate(simtime)
124else:
125    exit_event = m5.simulate()
126
127print 'Exiting @ cycle', m5.curTick(), 'because', exit_event.getCause()
128