source: trunk/platforms/tsar_generic_leti/arch.py @ 1029

Last change on this file since 1029 was 1029, checked in by cfuguet, 8 years ago
  • Support the cluster 0 to be the IO cluster.
  • Update the arch.py to allow the execution of new revisions of the Giet-VM.
  • Property svn:executable set to *
File size: 19.8 KB
Line 
1#!/usr/bin/env python
2
3from math import log, ceil
4from mapping import *
5
6###############################################################################
7#   file   : arch.py  (for the tsar_generic_leti architecture)
8#   date   : may 2014
9#   author : Alain Greiner
10###############################################################################
11#  This file contains a mapping generator for the "tsar_generic_leti" platform.
12#  This includes both the hardware architecture (clusters, processors,
13#  peripherals, physical space segmentation) and the mapping of all boot
14#  and kernel objects (global vsegs).
15#
16#  This platform includes 6 external peripherals controllers located
17#  in cluster[x_size-1][y_size-1]: TTY, IOC, FBF, NIC, CMA, PIC.
18#  It does not use the IOB component.
19#  It does not use an external ROM, as the preloader code is (pre)loaded
20#  at address 0x0, in the physical memory of cluster[0][0].
21#  It can use an - optional - RAMDISK located in cluster[0][0].
22#  The upper row (y = y_size-1) does not contain processors or memory.
23#
24#  The "constructor" parameters (defined in Makefile) are:
25#  - x_size         : number of clusters in a row
26#  - y_size         : number of clusters in a column
27#  - nb_procs       : number of processors per cluster
28#  - nb_ttys        : number of TTY channels
29#  - fbf_width      : frame_buffer width = frame_buffer heigth
30#  - ioc_type       : can be 'BDV','HBA','SDC','RDK'
31#
32#  The others hardware parameters (defined below) are:
33#  - nb_nics        : number of NIC channels
34#  - nb_cmas        : number of CMA channels
35#  - x_io           : cluster_io x coordinate
36#  - y_io           : cluster_io y coordinate
37#  - x_width        : number of bits for x coordinate
38#  - y_width        : number of bits for y coordinate
39#  - paddr_width    : number of bits for physical address
40#  - irq_per_proc   : number of input IRQs per processor
41#  - use_ramdisk    : use a RAMDISK when True
42#  - peri_increment : address increment for replicated vsegs
43#
44#  Regarding the boot and kernel vsegs mapping :
45#  - We use one big physical page (2 Mbytes) for the preloader and the four
46#    boot vsegs, all allocated in cluster[0,0].
47#  - We use the 16 next big pages in cluster[0][0] to implement the RAMDISK.
48#  - We use one big page per cluster for the replicated kernel code vsegs.
49#  - We use one big page in cluster[0][0] for the kernel data vseg.
50#  - We use one big page per cluster for the distributed kernel heap vsegs.
51#  - We use one big page per cluster for the distributed ptab vsegs.
52#  - We use small physical pages (4 Kbytes) per cluster for the schedulers.
53#  - We use one big page for each external peripheral in IO cluster,
54#  - We use one small page per cluster for each internal peripheral.
55###############################################################################
56
57########################
58def arch( x_size    = 2,
59          y_size    = 2,
60          nb_procs  = 4,
61          nb_ttys   = 1,
62          fbf_width = 128,
63          ioc_type  = 'HBA',
64          mwr_type  = 'CPY'):
65
66    ### define architecture constants
67
68    nb_nics         = 1
69    nb_cmas         = 2
70    x_io            = 0
71    y_io            = 0
72    x_width         = 4
73    y_width         = 4
74    p_width         = 2           # LETI constraint
75    paddr_width     = 40
76    irq_per_proc    = 4           # NetBSD constraint
77    peri_increment  = 0x10000 
78    reset_address   = 0x00000000  # LETI constraint
79
80    ### parameters checking
81
82    assert( nb_procs <= 4 )
83
84    assert( x_size <= (1 << x_width) )
85
86    assert( (y_size > 1) and (y_size <= (1 << y_width)) )
87
88    assert( ioc_type in [ 'BDV' , 'HBA' , 'SDC' , 'RDK' ] )
89 
90    ### define type and name
91
92    platform_name  = 'tsar_leti_%d_%d_%d' % ( x_size, y_size, nb_procs )
93    platform_name  += '_%d_%d_%s' % ( fbf_width , nb_ttys , ioc_type )
94
95    ### define physical segments replicated in all clusters
96    ### the base address is extended by the cluster_xy (8 bits)
97
98    ram_base = 0x00000000
99    ram_size = 0x4000000                   # 64 Mbytes
100
101    xcu_base = 0xF0000000
102    xcu_size = 0x1000                      # 4 Kbytes
103
104    mmc_base = 0xF1000000
105    mmc_size = 0x1000                      # 4 Kbytes
106
107    ### define physical segments for external peripherals
108    ## These segments are only defined in cluster_io
109
110    ioc_base  = 0xF2000000
111    ioc_size  = 0x1000                     # 4kbytes
112
113    tty_base  = 0xF4000000
114    tty_size  = 0x4000                     # 16 Kbytes
115
116    nic_base  = 0xF7000000
117    nic_size  = 0x80000                    # 512 kbytes
118
119    cma_base  = 0xF8000000
120    cma_size  = 0x1000 * 2 * nb_nics       # 4 kbytes * 2 * nb_nics
121
122    pic_base  = 0xF9000000
123    pic_size  = 0x1000                     # 4 Kbytes
124
125    fbf_base  = 0xF3000000
126    fbf_size  = fbf_width * fbf_width      # fbf_width * fbf_width bytes
127
128
129    ### define preloader & bootloader vsegs base addresses and sizes
130    ### We want to pack these 5 vsegs in the same big page
131    ### => boot cost is one BPP in cluster[0][0]
132
133    preloader_vbase      = reset_address   # ident
134    preloader_size       = 0x00010000      # 64 Kbytes
135
136    boot_mapping_vbase   = 0x00010000      # ident
137    boot_mapping_size    = 0x00080000      # 512 Kbytes
138
139    boot_code_vbase      = 0x00090000      # ident
140    boot_code_size       = 0x00040000      # 256 Kbytes
141
142    boot_data_vbase      = 0x000D0000      # ident
143    boot_data_size       = 0x000B0000      # 704 Kbytes
144
145    boot_stack_vbase     = 0x00180000      # ident
146    boot_stack_size      = 0x00080000      # 512 Kbytes
147
148    ### define ramdisk vseg / must be identity mapping in cluster[0][0]
149    ### occupies 16 BPP after the boot 
150    ramdisk_vbase        = 0x02000000
151    ramdisk_size         = 0x02000000      # 32 Mbytes
152
153    ### define kernel vsegs base addresses and sizes
154    ### code, init, ptab, heap & sched vsegs are replicated in all clusters.
155    ### data & uncdata vsegs are only mapped in cluster[0][0].
156
157    kernel_code_vbase    = 0x80000000
158    kernel_code_size     = 0x00100000      # 1 Mbytes per cluster
159
160    kernel_init_vbase    = 0x88000000
161    kernel_init_size     = 0x00100000      # 1 Mbytes per cluster
162
163    kernel_data_vbase    = 0x90000000
164    kernel_data_size     = 0x00200000      # 2 Mbytes in cluster[0][0]
165
166    kernel_ptab_vbase    = 0xE0000000
167    kernel_ptab_size     = 0x00200000      # 2 Mbytes per cluster
168
169    kernel_heap_vbase    = 0xD0000000
170    kernel_heap_size     = 0x00200000      # 2 Mbytes per cluster
171
172    kernel_sched_vbase   = 0xA0000000
173    kernel_sched_size    = 0x00002000 * nb_procs # 8 kbytes per proc per cluster
174
175    #####################
176    ### create mapping
177    #####################
178
179    mapping = Mapping( name           = platform_name,
180                       x_size         = x_size,
181                       y_size         = y_size,
182                       nprocs         = nb_procs,
183                       x_width        = x_width,
184                       y_width        = y_width,
185                       p_width        = p_width,
186                       paddr_width    = paddr_width,
187                       coherence      = True,
188                       irq_per_proc   = irq_per_proc,
189                       use_ramdisk    = (ioc_type == 'RDK'),
190                       x_io           = x_io,
191                       y_io           = y_io,
192                       peri_increment = peri_increment,
193                       reset_address  = reset_address,
194                       ram_base       = ram_base,
195                       ram_size       = ram_size )
196
197    ###########################
198    ### Hardware Description
199    ###########################
200
201    for x in xrange( x_size ):
202        for y in xrange( y_size ):
203            cluster_xy = (x << y_width) + y;
204            offset     = cluster_xy << (paddr_width - x_width - y_width)
205 
206            ### components replicated in all clusters but the upper row
207            if ( y < (y_size - 1) ):
208
209                ram = mapping.addRam( 'RAM', base = ram_base + offset, 
210                                      size = ram_size )
211
212                mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset, 
213                                         size = mmc_size, ptype = 'MMC' )
214
215                xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, 
216                                         size = xcu_size, ptype = 'XCU', 
217                                         channels = nb_procs * irq_per_proc, 
218                                         arg0 = 16, arg1 = 16, arg2 = 16 )
219
220                mapping.addIrq( xcu, index = 8 , src = mmc, isrtype = 'ISR_MMC' )
221
222                if ( x==0 ) and ( y==0 ):
223                    tty = mapping.addPeriph( 'TTY', base = tty_base + offset, size = tty_size, 
224                                             ptype = 'TTY', channels = nb_ttys )
225
226                    mapping.addIrq( xcu, index = 10, src = tty,
227                                    isrtype = 'ISR_TTY_RX', channel = 0 )
228
229                for p in xrange ( nb_procs ):
230                    mapping.addProc( x, y, p )
231
232            ###  peripherals in external cluster_io
233            if ( x_io!=0 ) and ( y_io!=0 ) and ( x==( x_size-1 ) ) and ( y==( y_size-1 ) ) :
234
235                if ( ioc_type != 'RDK' ):
236                    ioc = mapping.addPeriph( 'IOC', base = ioc_base + offset, size = ioc_size, 
237                                             ptype = 'IOC', subtype = ioc_type )
238
239                tty = mapping.addPeriph( 'TTY', base = tty_base + offset, size = tty_size, 
240                                         ptype = 'TTY', channels = nb_ttys )
241
242                nic = mapping.addPeriph( 'NIC', base = nic_base + offset, size = nic_size, 
243                                         ptype = 'NIC', channels = nb_nics )
244
245                cma = mapping.addPeriph( 'CMA', base = cma_base + offset, size = cma_size, 
246                                         ptype = 'CMA', channels = nb_cmas )
247
248                fbf = mapping.addPeriph( 'FBF', base = fbf_base + offset, size = fbf_size, 
249                                         ptype = 'FBF', arg0 = fbf_width, arg1 = fbf_width )
250
251                pic = mapping.addPeriph( 'PIC', base = pic_base + offset, size = pic_size, 
252                                         ptype = 'PIC', channels = 32 )
253
254                mapping.addIrq( pic, index = 0, src = nic,
255                                isrtype = 'ISR_NIC_RX', channel = 0 )
256                mapping.addIrq( pic, index = 1, src = nic,
257                                isrtype = 'ISR_NIC_RX', channel = 1 )
258                mapping.addIrq( pic, index = 2, src = nic,
259                                isrtype = 'ISR_NIC_TX', channel = 0 )
260                mapping.addIrq( pic, index = 3, src = nic,
261                                isrtype = 'ISR_NIC_TX', channel = 1 )
262                mapping.addIrq( pic, index = 4, src = cma,
263                                isrtype = 'ISR_CMA', channel = 0 )
264                mapping.addIrq( pic, index = 5, src = cma,
265                                isrtype = 'ISR_CMA', channel = 1 )
266                mapping.addIrq( pic, index = 6, src = cma,
267                                isrtype = 'ISR_CMA', channel = 2 )
268                mapping.addIrq( pic, index = 7, src = cma,
269                                isrtype = 'ISR_CMA', channel = 3 )
270
271                if ( ioc_type != 'RDK' ):
272                    if   ( ioc_type == 'BDV' ): isr_type = 'ISR_BDV'
273                    elif ( ioc_type == 'HBA' ): isr_type = 'ISR_HBA'
274                    elif ( ioc_type == 'SDC' ): isr_type = 'ISR_SDC'
275
276                    mapping.addIrq( pic, index = 8, src = ioc,
277                                    isrtype = isr_type, channel = 0 )
278
279                mapping.addIrq( pic, index = 16, src = tty,
280                                isrtype = 'ISR_TTY_RX', channel = 0 )
281                mapping.addIrq( pic, index = 17, src = tty,
282                                isrtype = 'ISR_TTY_RX', channel = 1 )
283                mapping.addIrq( pic, index = 18, src = tty,
284                                isrtype = 'ISR_TTY_RX', channel = 2 )
285                mapping.addIrq( pic, index = 19, src = tty,
286                                isrtype = 'ISR_TTY_RX', channel = 3 )
287                mapping.addIrq( pic, index = 20, src = tty,
288                                isrtype = 'ISR_TTY_RX', channel = 4 )
289                mapping.addIrq( pic, index = 21, src = tty,
290                                isrtype = 'ISR_TTY_RX', channel = 5 )
291                mapping.addIrq( pic, index = 22, src = tty,
292                                isrtype = 'ISR_TTY_RX', channel = 6 )
293                mapping.addIrq( pic, index = 23, src = tty,
294                                isrtype = 'ISR_TTY_RX', channel = 7 )
295
296    ###################################
297    ### boot & kernel vsegs mapping
298    ###################################
299
300    ### global vsegs for preloader & boot_loader are mapped in cluster[0][0]
301    ### => same flags CXW_ / identity mapping / non local / big page
302
303    mapping.addGlobal( 'seg_preloader', preloader_vbase, preloader_size,
304                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
305                       identity = True, local = False, big = True )
306
307    mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size,
308                       'CXW_', vtype = 'BLOB'  , x = 0, y = 0, pseg = 'RAM',
309                       identity = True, local = False, big = True )
310
311    mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size,
312                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
313                       identity = True, local = False, big = True )
314
315    mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size,
316                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
317                       identity = True, local = False, big = True )
318
319    mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size,
320                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
321                       identity = True, local = False, big = True )
322
323    ### global vseg for RAM-DISK in cluster[0][0]
324    ### identity mapping / non local / big pages
325    if (ioc_type == 'RDK'):
326        mapping.addGlobal( 'seg_ramdisk', ramdisk_vbase, ramdisk_size,
327                           'C_W_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
328                           identity = True, local = True, big = True )
329
330    ### global vseg kernel_data: non local / big page
331    ### Only mapped in cluster[0][0]
332    mapping.addGlobal( 'seg_kernel_data', 
333                       kernel_data_vbase, kernel_data_size,
334                       'C_W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
335                       binpath = 'bin/kernel/kernel.elf', 
336                       local = False, big = True )
337
338    ### global vsegs kernel_code, kernel_init : local / big page
339    ### replicated in all clusters containing processors
340    ### same content => same name / same vbase
341    for x in xrange( x_size ):
342        for y in xrange( y_size - 1 ):
343            mapping.addGlobal( 'seg_kernel_code', 
344                               kernel_code_vbase, kernel_code_size,
345                               'CXW_', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
346                               binpath = 'bin/kernel/kernel.elf',
347                               local = True, big = True )
348
349            mapping.addGlobal( 'seg_kernel_init', 
350                               kernel_init_vbase, kernel_init_size,
351                               'CXW_', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
352                               binpath = 'bin/kernel/kernel.elf',
353                               local = True, big = True )
354
355    ### Global vsegs kernel_ptab_x_y: non local / big page
356    ### replicated in all clusters containing processors
357    ### different content => name & vbase indexed by (x,y)
358    for x in xrange( x_size ):
359        for y in xrange( y_size - 1 ):
360            offset = ((x << y_width) + y) * kernel_ptab_size
361            mapping.addGlobal( 'seg_kernel_ptab_%d_%d' %(x,y), 
362                               kernel_ptab_vbase + offset, kernel_ptab_size,
363                               'CXW_', vtype = 'PTAB', x = x, y = y, pseg = 'RAM',
364                               local = False, big = True )
365
366    ### global vsegs kernel_sched : non local / small pages
367    ### allocated in all clusters containing processors
368    ### different content => name & vbase indexed by (x,y)
369    for x in xrange( x_size ):
370        for y in xrange( y_size - 1 ):
371            offset = ((x << y_width) + y) * kernel_ptab_size
372            mapping.addGlobal( 'seg_kernel_sched_%d_%d' %(x,y), 
373                               kernel_sched_vbase + offset , kernel_sched_size,
374                               'C_W_', vtype = 'SCHED', x = x, y = y, pseg = 'RAM',
375                               local = False, big = False )
376
377    ### global vsegs kernel_heap_x_y : non local / big pages
378    ### distributed in all clusters containing processors
379    ### different content => name & vbase indexed by (x,y)
380    for x in xrange( x_size ):
381        for y in xrange( y_size - 1 ):
382            offset = ((x << y_width) + y) * kernel_heap_size
383            mapping.addGlobal( 'seg_kernel_heap_%d_%d' %(x,y), 
384                               kernel_heap_vbase + offset , kernel_heap_size,
385                               'C_W_', vtype = 'HEAP', x = x , y = y , pseg = 'RAM',
386                               local = False, big = True )
387
388    ### global vsegs for external peripherals: non local / big page
389    ### only mapped in cluster_io
390    if ioc_type != 'RDK':
391        mapping.addGlobal( 'seg_ioc', ioc_base, ioc_size,
392                           '__W_', vtype = 'PERI', x = x_io, y = y_io,
393                           pseg = 'IOC', local = False, big = True )
394
395    mapping.addGlobal( 'seg_tty', tty_base, tty_size, 
396                       '__W_', vtype = 'PERI', x = x_io, y = y_io,
397                       pseg = 'TTY', local = False, big = True )
398
399    if ( x_io!=0 ) and ( y_io!=0 ) :
400        mapping.addGlobal( 'seg_nic', nic_base, nic_size,
401                           '__W_', vtype = 'PERI', x = x_size-1, y = y_size-1,
402                           pseg = 'NIC', local = False, big = True )
403
404        mapping.addGlobal( 'seg_cma', cma_base, cma_size,
405                           '__W_', vtype = 'PERI', x = x_size-1, y = y_size-1,
406                           pseg = 'CMA', local = False, big = True )
407
408        mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size,
409                           '__W_', vtype = 'PERI', x = x_size-1, y = y_size-1,
410                           pseg = 'FBF', local = False, big = True )
411
412        mapping.addGlobal( 'seg_pic', pic_base, pic_size,
413                           '__W_', vtype = 'PERI', x = x_size-1, y = y_size-1,
414                           pseg = 'PIC', local = False, big = True )
415
416    ### global vsegs for internal peripherals : non local / small pages
417    ### allocated in all clusters containing processors
418    ### name and vbase indexed by (x,y)
419    for x in xrange( x_size ):
420        for y in xrange( y_size - 1 ):
421            offset = ((x << y_width) + y) * peri_increment
422
423            mapping.addGlobal( 'seg_xcu_%d_%d' %(x,y), 
424                               xcu_base + offset, xcu_size,
425                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'XCU',
426                               local = False, big = False )
427
428            mapping.addGlobal( 'seg_mmc_%d_%d' %(x,y), 
429                               mmc_base + offset, mmc_size,
430                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'MMC',
431                               local = False, big = False )
432
433    return mapping
434
435########################## platform test #############################################
436
437if __name__ == '__main__':
438
439    mapping = arch( x_size    = 2,
440                    y_size    = 2,
441                    nb_procs  = 2 )
442
443#   print mapping.netbsd_dts()
444
445    print mapping.xml()
446
447#   print mapping.giet_vsegs()
448
449
450# Local Variables:
451# tab-width: 4;
452# c-basic-offset: 4;
453# c-file-offsets:((innamespace . 0)(inline-open . 0));
454# indent-tabs-mode: nil;
455# End:
456#
457# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
458
Note: See TracBrowser for help on using the repository browser.