memory-per-range.py revision 11077
112854Sgabeblack@google.com# The backing store supporting the memories in the system has changed
212854Sgabeblack@google.com# in that it is now stored globally per address range. As a result the
312854Sgabeblack@google.com# actual storage is separate from the memory controllers themselves.
412854Sgabeblack@google.comdef upgrader(cpt):
512854Sgabeblack@google.com    for sec in cpt.sections():
612854Sgabeblack@google.com        import re
712854Sgabeblack@google.com        # Search for a physical memory
812854Sgabeblack@google.com        if re.search('.*sys.*\.physmem$', sec):
912854Sgabeblack@google.com            # Add the number of stores attribute to the global physmem
1012854Sgabeblack@google.com            cpt.set(sec, 'nbr_of_stores', '1')
1112854Sgabeblack@google.com
1212854Sgabeblack@google.com            # Get the filename and size as this is moving to the
1312854Sgabeblack@google.com            # specific backing store
1412854Sgabeblack@google.com            mem_filename = cpt.get(sec, 'filename')
1512854Sgabeblack@google.com            mem_size = cpt.get(sec, '_size')
1612854Sgabeblack@google.com            cpt.remove_option(sec, 'filename')
1712854Sgabeblack@google.com            cpt.remove_option(sec, '_size')
1812854Sgabeblack@google.com
1912854Sgabeblack@google.com            # Get the name so that we can create the new section
2012854Sgabeblack@google.com            system_name = str(sec).split('.')[0]
2112854Sgabeblack@google.com            section_name = system_name + '.physmem.store0'
2212854Sgabeblack@google.com            cpt.add_section(section_name)
2312854Sgabeblack@google.com            cpt.set(section_name, 'store_id', '0')
2412854Sgabeblack@google.com            cpt.set(section_name, 'range_size', mem_size)
2512854Sgabeblack@google.com            cpt.set(section_name, 'filename', mem_filename)
2612854Sgabeblack@google.com        elif re.search('.*sys.*\.\w*mem$', sec):
2712854Sgabeblack@google.com            # Due to the lack of information about a start address,
2812854Sgabeblack@google.com            # this migration only works if there is a single memory in
2912854Sgabeblack@google.com            # the system, thus starting at 0
3012854Sgabeblack@google.com            raise ValueError("more than one memory detected (" + sec + ")")
3112854Sgabeblack@google.com
3212854Sgabeblack@google.comlegacy_version = 2
3312854Sgabeblack@google.com