Deleted Added
sdiff udiff text old ( 13952:197e72db5ab0 ) new ( 13980:62a28c423e91 )
full compact
1# Copyright (c) 2015 Advanced Micro Devices, Inc.
2# All rights reserved
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 38 unchanged lines hidden (view full) ---

47 with open(joinpath(*path), 'a') as f:
48 f.write(str(contents))
49
50def replace_tree(path):
51 if isdir(path):
52 rmtree(path)
53 mkdir(path)
54
55def config_filesystem(options):
56 fsdir = joinpath(m5.options.outdir, 'fs')
57 replace_tree(fsdir)
58
59 # Set up /proc
60 procdir = joinpath(fsdir, 'proc')
61 mkdir(procdir)
62
63 cpu_clock = '0'
64 if hasattr(options, 'cpu_clock'):
65 cpu_clock = options.cpu_clock
66 cpu_clock = toFrequency(cpu_clock)/mega
67
68 l2_size = '0'
69 if hasattr(options, 'l2_size'):
70 l2_size = options.l2_size
71 l2_size = toMemorySize(l2_size)/kibi
72
73 cacheline_size = '0'
74 if hasattr(options, 'cacheline_size'):
75 cacheline_size = options.cacheline_size
76
77 for i in xrange(options.num_cpus):
78 one_cpu = 'processor : %d\n' % (i) + \
79 'vendor_id : Generic\n' + \
80 'cpu family : 0\n' + \
81 'model : 0\n' + \
82 'model name : Generic\n' + \
83 'stepping : 0\n' + \
84 'cpu MHz : %0.3d\n' \
85 % cpu_clock + \
86 'cache size: : %dK\n' \
87 % l2_size + \
88 'physical id : 0\n' + \
89 'siblings : %s\n' \
90 % options.num_cpus + \
91 'core id : %d\n' \
92 % i + \
93 'cpu cores : %d\n' \
94 % options.num_cpus + \
95 'fpu : yes\n' + \
96 'fpu exception : yes\n' + \
97 'cpuid level : 1\n' + \
98 'wp : yes\n' + \
99 'flags : fpu\n' + \
100 'cache alignment : %d\n' \
101 % cacheline_size + \
102 '\n'
103 file_append((procdir, 'cpuinfo'), one_cpu)
104
105 file_append((procdir, 'stat'), 'cpu 0 0 0 0 0 0 0\n')
106 for i in xrange(options.num_cpus):
107 file_append((procdir, 'stat'), 'cpu%d 0 0 0 0 0 0 0\n' % i)
108
109 # Set up /sys
110 sysdir = joinpath(fsdir, 'sys')
111 mkdir(sysdir)
112
113 # Set up /sys/devices/system/cpu
114 cpudir = joinpath(sysdir, 'devices', 'system', 'cpu')
115 makedirs(cpudir)
116
117 file_append((cpudir, 'online'), '0-%d' % (options.num_cpus-1))
118 file_append((cpudir, 'possible'), '0-%d' % (options.num_cpus-1))
119
120 # Set up /tmp
121 tmpdir = joinpath(fsdir, 'tmp')
122 replace_tree(tmpdir)
123
124def register_node(cpu_list, mem, node_number):
125 nodebasedir = joinpath(m5.options.outdir, 'fs', 'sys', 'devices',
126 'system', 'node')
127
128 nodedir = joinpath(nodebasedir,'node%d' % node_number)
129 makedirs(nodedir)
130
131 file_append((nodedir, 'cpumap'), hex_mask(cpu_list))

--- 39 unchanged lines hidden (view full) ---

171
172 # Since cache size = number of indices * associativity * block size
173 num_sets = toMemorySize(size) / int(assoc) * int(line_size)
174
175 file_append((indexdir, 'number_of_sets'), num_sets)
176 file_append((indexdir, 'physical_line_partition'), '1')
177 file_append((indexdir, 'shared_cpu_map'), hex_mask(cpus))
178
179def redirect_paths(chroot):
180 # Redirect filesystem syscalls from src to the first matching dests
181 redirect_paths = [RedirectPath(app_path = "/proc",
182 host_paths = ["%s/fs/proc" % m5.options.outdir]),
183 RedirectPath(app_path = "/sys",
184 host_paths = ["%s/fs/sys" % m5.options.outdir]),
185 RedirectPath(app_path = "/tmp",
186 host_paths = ["%s/fs/tmp" % m5.options.outdir]),
187 RedirectPath(app_path = "/",
188 host_paths = ["%s" % chroot])]
189 return redirect_paths