From fc45d42d01fba4f858012740e6a8a43ce5ecad9b Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 3 Jan 2007 10:12:55 -0800 Subject: Add 'Time' as a parameter type that can accept various formats for time (strings, datetime objects, etc.) Advance system time to 1/1/2009 Clean up time management code a little bit --HG-- extra : convert_revision : 28ebecc7ea6b12f4345c77a9a6b4bdf2e752c4f8 --- src/python/m5/objects/Tsunami.py | 4 ++-- src/python/m5/params.py | 52 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 3 deletions(-) (limited to 'src/python/m5') diff --git a/src/python/m5/objects/Tsunami.py b/src/python/m5/objects/Tsunami.py index ac9020b47..18a776a7f 100644 --- a/src/python/m5/objects/Tsunami.py +++ b/src/python/m5/objects/Tsunami.py @@ -13,8 +13,8 @@ class TsunamiCChip(BasicPioDevice): class TsunamiIO(BasicPioDevice): type = 'TsunamiIO' - time = Param.UInt64(1136073600, - "System time to use (0 for actual time, default is 1/1/06)") + time = Param.Time('01/01/2009', + "System time to use ('Now' for actual time)") tsunami = Param.Tsunami(Parent.any, "Tsunami") frequency = Param.Frequency('1024Hz', "frequency of interrupts") diff --git a/src/python/m5/params.py b/src/python/m5/params.py index d83d5f73f..d570804d8 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -44,7 +44,12 @@ # ##################################################################### -import sys, inspect, copy +import copy +import datetime +import inspect +import sys +import time + import convert from util import * @@ -513,6 +518,50 @@ class EthernetAddr(ParamValue): else: return self.value +def parse_time(value): + strings = [ "%a %b %d %H:%M:%S %Z %Y", + "%a %b %d %H:%M:%S %Z %Y", + "%Y/%m/%d %H:%M:%S", + "%Y/%m/%d %H:%M", + "%Y/%m/%d", + "%m/%d/%Y %H:%M:%S", + "%m/%d/%Y %H:%M", + "%m/%d/%Y", + "%m/%d/%y %H:%M:%S", + "%m/%d/%y %H:%M", + "%m/%d/%y"] + + for string in strings: + try: + return time.strptime(value, string) + except ValueError: + pass + + raise ValueError, "Could not parse '%s' as a time" % value + +class Time(ParamValue): + cxx_type = 'time_t' + def __init__(self, value): + if isinstance(value, time.struct_time): + self.value = time.mktime(value) + elif isinstance(value, int): + self.value = value + elif isinstance(value, str): + if value in ('Now', 'Today'): + self.value = time.time() + else: + self.value = time.mktime(parse_time(value)) + elif isinstance(value, (datetime.datetime, datetime.date)): + self.value = time.mktime(value.timetuple()) + else: + raise ValueError, "Could not parse '%s' as a time" % value + + def __str__(self): + return str(int(self.value)) + + def ini_str(self): + return str(int(self.value)) + # Enumerated types are a little more complex. The user specifies the # type as Enum(foo) where foo is either a list or dictionary of # alternatives (typically strings, but not necessarily so). (In the @@ -973,6 +1022,7 @@ __all__ = ['Param', 'VectorParam', 'NetworkBandwidth', 'MemoryBandwidth', 'Range', 'AddrRange', 'TickRange', 'MaxAddr', 'MaxTick', 'AllMemory', + 'Time', 'NextEthernetAddr', 'NULL', 'Port', 'VectorPort'] -- cgit v1.2.3 From e6b4fed75d8b1044835bfbef77934b9a47bb2680 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 3 Jan 2007 10:16:22 -0800 Subject: set __name__ in the root m5 script to __m5_main__ so we can tell if the script is run from m5 as the m5 script --HG-- extra : convert_revision : 06f646cbb8c82444ef345115aa49324a4d3a2c9f --- src/python/m5/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/python/m5') diff --git a/src/python/m5/main.py b/src/python/m5/main.py index 114c668a6..5df6d03cf 100644 --- a/src/python/m5/main.py +++ b/src/python/m5/main.py @@ -304,7 +304,8 @@ def main(): sys.argv = arguments sys.path = [ os.path.dirname(sys.argv[0]) ] + sys.path - scope = { '__file__' : sys.argv[0] } + scope = { '__file__' : sys.argv[0], + '__name__' : '__m5_main__' } # we want readline if we're doing anything interactive if options.interactive or options.pdb: -- cgit v1.2.3 From 7933aade85a61ba745a9dd694b26b7420b7e649c Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Tue, 9 Jan 2007 22:16:49 -0500 Subject: add memory mapped disk device configs/common/FSConfig.py: src/python/m5/objects/T1000.py: add configuration for memory mapped disk src/dev/sparc/SConscript: add memory mapped disk to sconscript --HG-- extra : convert_revision : d8df4a455cf48000042d0ff93a274985f4dbe905 --- src/python/m5/objects/T1000.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/python/m5') diff --git a/src/python/m5/objects/T1000.py b/src/python/m5/objects/T1000.py index 79195d976..030f4abd8 100644 --- a/src/python/m5/objects/T1000.py +++ b/src/python/m5/objects/T1000.py @@ -5,6 +5,12 @@ from Uart import Uart8250 from Platform import Platform from SimConsole import SimConsole, ConsoleListener + +class MmDisk(BasicPioDevice): + type = 'MmDisk' + image = Param.DiskImage("Disk Image") + pio_addr = 0x1F40000000 + class T1000(Platform): type = 'T1000' system = Param.System(Parent.any, "system") -- cgit v1.2.3 From 3af3610c625d57db3fa75af4f4b24ae72a76595f Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Sun, 21 Jan 2007 18:04:40 -0500 Subject: add dumb time of day device --HG-- extra : convert_revision : 52e51ff49f7ed73065f04707ded06dc7254292c4 --- src/python/m5/objects/T1000.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/python/m5') diff --git a/src/python/m5/objects/T1000.py b/src/python/m5/objects/T1000.py index 030f4abd8..7b93268ac 100644 --- a/src/python/m5/objects/T1000.py +++ b/src/python/m5/objects/T1000.py @@ -11,6 +11,12 @@ class MmDisk(BasicPioDevice): image = Param.DiskImage("Disk Image") pio_addr = 0x1F40000000 +class DumbTOD(BasicPioDevice): + type = 'DumbTOD' + time = Param.Time('01/01/2009', "System time to use ('Now' for real time)") + pio_addr = 0xfff0c1fff8 + + class T1000(Platform): type = 'T1000' system = Param.System(Parent.any, "system") @@ -64,6 +70,8 @@ class T1000(Platform): warn_access="Accessing SSI -- Unimplemented!") hvuart = Uart8250(pio_addr=0xfff0c2c000) + htod = DumbTOD() + puart0 = Uart8250(pio_addr=0x1f10000000) console = SimConsole(listener = ConsoleListener()) @@ -86,3 +94,4 @@ class T1000(Platform): self.fake_ssi.pio = bus.port self.puart0.pio = bus.port self.hvuart.pio = bus.port + self.htod.pio = bus.port -- cgit v1.2.3