1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | from mapping import * |
---|
4 | |
---|
5 | ############################################################################### |
---|
6 | # file : arch.py (for the tsar_generic_iob architecture) |
---|
7 | # date : may 2014 |
---|
8 | # author : Alain Greiner |
---|
9 | ############################################################################### |
---|
10 | # This file contains a mapping generator for the "tsar_generic_iob" platform. |
---|
11 | # This includes both the hardware architecture (clusters, processors, |
---|
12 | # peripherals, physical space segmentation) and the mapping of all kernel |
---|
13 | # objects (global vsegs). This platform includes 6 external peripherals, |
---|
14 | # accessible through two IO_Bridge components located in cluster [0,0] and |
---|
15 | # cluster [x_size-1, y_size-1]. Available peripherals are: TTY, BDV, FBF, |
---|
16 | # ROM, NIC, CMA. |
---|
17 | # |
---|
18 | # The "constructor" parameters are: |
---|
19 | # - x_size : number of clusters in a row |
---|
20 | # - y_size : number of clusters in a column |
---|
21 | # - nb_procs : number of processors per cluster |
---|
22 | # |
---|
23 | # The "hidden" parameters (defined below) are: |
---|
24 | # - nb_ttys : number of TTY channels |
---|
25 | # - nb_nics : number of NIC channels |
---|
26 | # - fbf_width : frame_buffer width = frame_buffer heigth |
---|
27 | # - x_io : cluster_io x coordinate |
---|
28 | # - y_io : cluster_io y coordinate |
---|
29 | # - x_width : number of bits for x coordinate |
---|
30 | # - y_width : number of bits for y coordinate |
---|
31 | # - paddr_width : number of bits for physical address |
---|
32 | # - irq_per_proc : number of input IRQs per processor |
---|
33 | # - use_ramdisk : use a ramdisk when True |
---|
34 | # - peri_increment : address increment for replicated peripherals |
---|
35 | ############################################################################### |
---|
36 | |
---|
37 | ######################## |
---|
38 | def arch( x_size = 2, |
---|
39 | y_size = 2, |
---|
40 | nb_procs = 2 ): |
---|
41 | |
---|
42 | ### define architecture constants |
---|
43 | |
---|
44 | nb_ttys = 1 |
---|
45 | nb_nics = 2 |
---|
46 | fbf_width = 128 |
---|
47 | x_io = 0 |
---|
48 | y_io = 0 |
---|
49 | x_width = 4 |
---|
50 | y_width = 4 |
---|
51 | paddr_width = 40 |
---|
52 | irq_per_proc = 4 |
---|
53 | use_ramdisk = True |
---|
54 | peri_increment = 0x10000 |
---|
55 | reset_address = 0x00000000 |
---|
56 | distributed_ptabs = True |
---|
57 | |
---|
58 | ### parameters checking |
---|
59 | |
---|
60 | assert( nb_procs <= 4 ) |
---|
61 | |
---|
62 | assert( (x_size == 1) or (x_size == 2) or (x_size == 4) |
---|
63 | or (x_size == 8) or (x_size == 16) ) |
---|
64 | |
---|
65 | assert( (y_size == 1) or (y_size == 2) or (y_size == 4) |
---|
66 | or (y_size == 8) or (y_size == 16) ) |
---|
67 | |
---|
68 | assert( nb_ttys == 1 ) |
---|
69 | |
---|
70 | assert( ((x_io == 0) and (y_io == 0)) or |
---|
71 | ((x_io == x_size-1) and (y_io == y_size-1)) ) |
---|
72 | |
---|
73 | platform_name = 'tsar_iob_%d_%d_%d' % ( x_size, y_size, nb_procs ) |
---|
74 | |
---|
75 | ### define physical segments |
---|
76 | |
---|
77 | ram_base = 0x0000000000 |
---|
78 | ram_size = 0x4000000 # 64 Mbytes |
---|
79 | |
---|
80 | xcu_base = 0x00F0000000 |
---|
81 | xcu_size = 0x1000 # 4 Kbytes |
---|
82 | |
---|
83 | mmc_base = 0x00E0000000 |
---|
84 | mmc_size = 0x1000 # 4 Kbytes |
---|
85 | |
---|
86 | offset_io = ((x_io << y_width) + y_io) << (paddr_width - x_width - y_width) |
---|
87 | |
---|
88 | bdv_base = 0x00F2000000 + offset_io |
---|
89 | bdv_size = 0x1000 # 4kbytes |
---|
90 | |
---|
91 | tty_base = 0x00F4000000 + offset_io |
---|
92 | tty_size = 0x4000 # 16 Kbytes |
---|
93 | |
---|
94 | nic_base = 0x00F7000000 + offset_io |
---|
95 | nic_size = 0x80000 # 512 kbytes |
---|
96 | |
---|
97 | cma_base = 0x00F8000000 + offset_io |
---|
98 | cma_size = 0x1000 * 2 * nb_nics # 4 kbytes * 2 * nb_nics |
---|
99 | |
---|
100 | fbf_base = 0x00F3000000 + offset_io |
---|
101 | fbf_size = fbf_width * fbf_width # fbf_width * fbf_width bytes |
---|
102 | |
---|
103 | pic_base = 0x00F9000000 + offset_io |
---|
104 | pic_size = 0x1000 # 4 Kbytes |
---|
105 | |
---|
106 | rdk_base = 0x02000000 |
---|
107 | rdk_size = 0x02000000 # 32 Mbytes |
---|
108 | |
---|
109 | ### define bootloader vsegs base addresses and sizes |
---|
110 | |
---|
111 | boot_mapping_vbase = 0x00000000 # ident |
---|
112 | boot_mapping_size = 0x00080000 # 512 Kbytes |
---|
113 | |
---|
114 | boot_code_vbase = 0x00080000 # ident |
---|
115 | boot_code_size = 0x00040000 # 256 Kbytes |
---|
116 | |
---|
117 | boot_data_vbase = 0x000C0000 # ident |
---|
118 | boot_data_size = 0x00080000 # 512 Kbytes |
---|
119 | |
---|
120 | boot_stack_vbase = 0x00140000 # ident |
---|
121 | boot_stack_size = 0x00050000 # 320 Kbytes |
---|
122 | |
---|
123 | ### define kernel vsegs base addresses and sizes |
---|
124 | |
---|
125 | kernel_code_vbase = 0x80000000 |
---|
126 | kernel_code_size = 0x00020000 # 128 Kbytes |
---|
127 | |
---|
128 | kernel_data_vbase = 0x80020000 |
---|
129 | kernel_data_size = 0x00020000 # 128 Kbytes |
---|
130 | |
---|
131 | kernel_uncdata_vbase = 0x80040000 |
---|
132 | kernel_uncdata_size = 0x00010000 # 64 Kbytes |
---|
133 | |
---|
134 | kernel_init_vbase = 0x80050000 |
---|
135 | kernel_init_size = 0x00010000 # 64 Kbytes |
---|
136 | |
---|
137 | kernel_sched_vbase = 0xF0000000 # distributed in all clusters |
---|
138 | kernel_sched_size = 0x2000 * nb_procs # 8 kbytes per processor |
---|
139 | |
---|
140 | ### create mapping |
---|
141 | |
---|
142 | mapping = Mapping( name = platform_name, |
---|
143 | x_size = x_size, |
---|
144 | y_size = y_size, |
---|
145 | procs_max = nb_procs, |
---|
146 | x_width = x_width, |
---|
147 | y_width = y_width, |
---|
148 | paddr_width = paddr_width, |
---|
149 | coherence = True, |
---|
150 | irq_per_proc = irq_per_proc, |
---|
151 | use_ramdisk = use_ramdisk, |
---|
152 | x_io = x_io, |
---|
153 | y_io = y_io, |
---|
154 | peri_increment = peri_increment, |
---|
155 | reset_address = reset_address, |
---|
156 | ram_base = ram_base, |
---|
157 | ram_size = ram_size ) |
---|
158 | |
---|
159 | ### external peripherals (accessible in cluster[0,0] only for this mapping) |
---|
160 | |
---|
161 | bdv = mapping.addPeriph( 'BDV', base = bdv_base, size = bdv_size, |
---|
162 | ptype = 'IOC', subtype = 'BDV' ) |
---|
163 | |
---|
164 | tty = mapping.addPeriph( 'TTY', base = tty_base, size = tty_size, |
---|
165 | ptype = 'TTY', channels = nb_ttys ) |
---|
166 | |
---|
167 | nic = mapping.addPeriph( 'NIC', base = nic_base, size = nic_size, |
---|
168 | ptype = 'NIC', channels = nb_nics ) |
---|
169 | |
---|
170 | cma = mapping.addPeriph( 'CMA', base = cma_base, size = cma_size, |
---|
171 | ptype = 'CMA', channels = 2*nb_nics ) |
---|
172 | |
---|
173 | fbf = mapping.addPeriph( 'FBF', base = fbf_base, size = fbf_size, |
---|
174 | ptype = 'FBF', arg = fbf_width ) |
---|
175 | |
---|
176 | pic = mapping.addPeriph( 'PIC', base = pic_base, size = pic_size, |
---|
177 | ptype = 'PIC', channels = 32 ) |
---|
178 | |
---|
179 | mapping.addIrq( pic, index = 0 , isrtype = 'ISR_NIC_RX', channel = 0 ) |
---|
180 | mapping.addIrq( pic, index = 1 , isrtype = 'ISR_NIC_RX', channel = 1 ) |
---|
181 | mapping.addIrq( pic, index = 2 , isrtype = 'ISR_NIC_TX', channel = 0 ) |
---|
182 | mapping.addIrq( pic, index = 3 , isrtype = 'ISR_NIC_TX', channel = 1 ) |
---|
183 | mapping.addIrq( pic, index = 4 , isrtype = 'ISR_CMA' , channel = 0 ) |
---|
184 | mapping.addIrq( pic, index = 5 , isrtype = 'ISR_CMA' , channel = 1 ) |
---|
185 | mapping.addIrq( pic, index = 6 , isrtype = 'ISR_CMA' , channel = 2 ) |
---|
186 | mapping.addIrq( pic, index = 7 , isrtype = 'ISR_CMA' , channel = 3 ) |
---|
187 | mapping.addIrq( pic, index = 8 , isrtype = 'ISR_BDV' , channel = 0 ) |
---|
188 | mapping.addIrq( pic, index = 16, isrtype = 'ISR_TTY_RX', channel = 0 ) |
---|
189 | |
---|
190 | ### hardware components replicated in all clusters |
---|
191 | |
---|
192 | for x in xrange( x_size ): |
---|
193 | for y in xrange( y_size ): |
---|
194 | cluster_xy = (x << y_width) + y; |
---|
195 | offset = cluster_xy << (paddr_width - x_width - y_width) |
---|
196 | |
---|
197 | ram = mapping.addRam( 'RAM', base = ram_base + offset, |
---|
198 | size = ram_size ) |
---|
199 | |
---|
200 | mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset, |
---|
201 | size = mmc_size, ptype = 'MMC' ) |
---|
202 | |
---|
203 | xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, |
---|
204 | size = xcu_size, ptype = 'XCU', |
---|
205 | channels = nb_procs * irq_per_proc, |
---|
206 | arg = 16 ) |
---|
207 | |
---|
208 | # IRQs replicated in all clusters |
---|
209 | mapping.addIrq( xcu, index = 8, isrtype = 'ISR_MMC' ) |
---|
210 | |
---|
211 | # IRQ in IO cluster (0,0) |
---|
212 | if x == 0 and y == 0: |
---|
213 | mapping.addIrq( xcu, index = 9 , isrtype = 'ISR_BDV' ) |
---|
214 | mapping.addIrq( xcu, index = 10, isrtype = 'ISR_TTY_RX' ) |
---|
215 | |
---|
216 | # processors |
---|
217 | for p in xrange ( nb_procs ): |
---|
218 | mapping.addProc( x, y, p ) |
---|
219 | |
---|
220 | ### global vseg for ram disk |
---|
221 | |
---|
222 | mapping.addGlobal( 'seg_rdk', rdk_base, rdk_size, '__W_', |
---|
223 | vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', |
---|
224 | identity = True ) |
---|
225 | |
---|
226 | ### global vsegs for external peripherals / identity mapping |
---|
227 | |
---|
228 | mapping.addGlobal( 'seg_bdv', bdv_base, bdv_size, '__W_', |
---|
229 | vtype = 'PERI', x = 0, y = 0, pseg = 'BDV', |
---|
230 | identity = True ) |
---|
231 | |
---|
232 | mapping.addGlobal( 'seg_tty', tty_base, tty_size, '__W_', |
---|
233 | vtype = 'PERI', x = 0, y = 0, pseg = 'TTY', |
---|
234 | identity = True ) |
---|
235 | |
---|
236 | mapping.addGlobal( 'seg_nic', nic_base, nic_size, '__W_', |
---|
237 | vtype = 'PERI', x = 0, y = 0, pseg = 'NIC', |
---|
238 | identity = True ) |
---|
239 | |
---|
240 | mapping.addGlobal( 'seg_cma', cma_base, cma_size, '__W_', |
---|
241 | vtype = 'PERI', x = 0, y = 0, pseg = 'CMA', |
---|
242 | identity = True ) |
---|
243 | |
---|
244 | mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size, '__W_', |
---|
245 | vtype = 'PERI', x = 0, y = 0, pseg = 'FBF', |
---|
246 | identity = True ) |
---|
247 | |
---|
248 | mapping.addGlobal( 'seg_pic', pic_base, pic_size, '__W_', |
---|
249 | vtype = 'PERI', x = 0, y = 0, pseg = 'PIC', |
---|
250 | identity = True ) |
---|
251 | |
---|
252 | ### global vsegs for internal peripherals, and for schedulers |
---|
253 | ### name is indexed by (x,y) / vbase address is incremented by (cluster_xy * peri_increment) |
---|
254 | |
---|
255 | for x in xrange( x_size ): |
---|
256 | for y in xrange( y_size ): |
---|
257 | cluster_xy = (x << y_width) + y; |
---|
258 | offset = cluster_xy * peri_increment |
---|
259 | |
---|
260 | mapping.addGlobal( 'seg_xcu_%d_%d' %(x,y), xcu_base + offset, xcu_size, |
---|
261 | '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'XCU' ) |
---|
262 | |
---|
263 | mapping.addGlobal( 'seg_mmc_%d_%d' %(x,y), mmc_base + offset, mmc_size, |
---|
264 | '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'MMC' ) |
---|
265 | |
---|
266 | mapping.addGlobal( 'seg_sched_%d_%d' %(x,y), kernel_sched_vbase + offset, kernel_sched_size, |
---|
267 | 'C_W_', vtype = 'SCHED', x = x , y = y , pseg = 'RAM' ) |
---|
268 | |
---|
269 | ### GIET-VM specifics |
---|
270 | ### global vsegs for boot_loader / identity mapping |
---|
271 | |
---|
272 | mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size, |
---|
273 | 'C_W_', vtype = 'BLOB' , x = 0, y = 0, pseg = 'RAM', |
---|
274 | identity = True ) |
---|
275 | |
---|
276 | mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size, |
---|
277 | 'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', |
---|
278 | identity = True ) |
---|
279 | |
---|
280 | mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size, |
---|
281 | 'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', |
---|
282 | identity = True ) |
---|
283 | |
---|
284 | mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size, |
---|
285 | 'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', |
---|
286 | identity = True ) |
---|
287 | |
---|
288 | ### the code global vsegs for kernel can be replicated in all clusters |
---|
289 | ### if the page tables are distributed in all clusters. |
---|
290 | |
---|
291 | if distributed_ptabs: |
---|
292 | for x in xrange( x_size ): |
---|
293 | for y in xrange( y_size ): |
---|
294 | cluster_xy = (x << y_width) + y; |
---|
295 | |
---|
296 | mapping.addGlobal( 'seg_kernel_code', kernel_code_vbase, kernel_code_size, |
---|
297 | 'CXW_', vtype = 'ELF', x = x , y = y , pseg = 'RAM', |
---|
298 | binpath = 'build/kernel/kernel.elf', local = True ) |
---|
299 | |
---|
300 | mapping.addGlobal( 'seg_kernel_init', kernel_init_vbase, kernel_init_size, |
---|
301 | 'CXW_', vtype = 'ELF', x = x , y = y , pseg = 'RAM', |
---|
302 | binpath = 'build/kernel/kernel.elf', local = True ) |
---|
303 | else: |
---|
304 | mapping.addGlobal( 'seg_kernel_code', kernel_code_vbase, kernel_code_size, |
---|
305 | 'CXW_', vtype = 'ELF', x = 0 , y = 0 , pseg = 'RAM', |
---|
306 | binpath = 'build/kernel/kernel.elf', local = False ) |
---|
307 | |
---|
308 | mapping.addGlobal( 'seg_kernel_init', kernel_init_vbase, kernel_init_size, |
---|
309 | 'CXW_', vtype = 'ELF', x = 0 , y = 0 , pseg = 'RAM', |
---|
310 | binpath = 'build/kernel/kernel.elf', local = False ) |
---|
311 | |
---|
312 | ### shared global vsegs for kernel |
---|
313 | |
---|
314 | mapping.addGlobal( 'seg_kernel_data', kernel_data_vbase, kernel_data_size, |
---|
315 | 'C_W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', |
---|
316 | binpath = 'build/kernel/kernel.elf', local = False ) |
---|
317 | |
---|
318 | mapping.addGlobal( 'seg_kernel_uncdata', kernel_uncdata_vbase, kernel_uncdata_size, |
---|
319 | '__W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', |
---|
320 | binpath = 'build/kernel/kernel.elf', local = False ) |
---|
321 | |
---|
322 | ### return mapping ### |
---|
323 | |
---|
324 | return mapping |
---|
325 | |
---|
326 | ################################# platform test ####################################################### |
---|
327 | |
---|
328 | if __name__ == '__main__': |
---|
329 | |
---|
330 | mapping = arch( x_size = 2, |
---|
331 | y_size = 2, |
---|
332 | nb_procs = 2 ) |
---|
333 | |
---|
334 | # print mapping.netbsd_dts() |
---|
335 | |
---|
336 | print mapping.xml() |
---|
337 | |
---|
338 | # print mapping.giet_vsegs() |
---|
339 | |
---|
340 | |
---|
341 | # Local Variables: |
---|
342 | # tab-width: 4; |
---|
343 | # c-basic-offset: 4; |
---|
344 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
345 | # indent-tabs-mode: nil; |
---|
346 | # End: |
---|
347 | # |
---|
348 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
349 | |
---|