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

Last change on this file since 820 was 820, checked in by cfuguet, 10 years ago

tsar_generic_leti: Complete update of the arch.py file

  • The arch.py file includes now the support for BPPs on the GietVM
  • Property svn:executable set to *
File size: 16.4 KB
RevLine 
[793]1#!/usr/bin/env python
2
[803]3from math import log, ceil
[793]4from mapping import *
5
6###############################################################################
[803]7#   file   : arch.py  (for the tsar_generic_leti architecture)
[793]8#   date   : may 2014
9#   author : Alain Greiner
10###############################################################################
[803]11#  This file contains a mapping generator for the "tsar_generic_leti" platform.
[793]12#  This includes both the hardware architecture (clusters, processors,
13#  peripherals, physical space segmentation) and the mapping of all kernel
[803]14#  objects (global vsegs).
[793]15#
16#  The "constructor" parameters are:
17#  - x_size         : number of clusters in a row
18#  - y_size         : number of clusters in a column
19#  - nb_procs       : number of processors per cluster
[820]20#  - fbf_width      : frame_buffer width = frame_buffer heigth
[793]21#
22#  The "hidden" parameters (defined below) are:
23#  - nb_ttys        : number of TTY channels
24#  - nb_nics        : number of NIC channels
25#  - x_io           : cluster_io x coordinate
26#  - y_io           : cluster_io y coordinate
27#  - x_width        : number of bits for x coordinate
28#  - y_width        : number of bits for y coordinate
29#  - paddr_width    : number of bits for physical address
30#  - irq_per_proc   : number of input IRQs per processor
31#  - use_ramdisk    : use a ramdisk when True
32#  - peri_increment : address increment for replicated peripherals
[820]33#
34# Regarding physical memory allocation, there is one allocator per cluster:
35# - We use only one big physical page (2 Mbytes) for the five boot vsegs,
36#   allocated in cluster[0,0], identity mapping.
37# - We use one big page per cluster for the kernel vsegs.
38#   The kernel_code, kernel_init and kernel_ptab can be replicated in all clusters.
39#   The kernel_data and kernel_uncdata shared vsegs are only mapped in cluster[0,0].
40# - We use 8 small physical pages (4 Kbytes) per cluster for the schedulers.
41# - We use one big page for each external peripheral in IO cluster,
42# - We use one small page per cluster for each internal peripheral.
43###################################################################################
[793]44
45########################
[820]46def arch( x_size    = 2,
47          y_size    = 2,
48          nb_procs  = 2,
49          fbf_width = 128 ):
[793]50
51    ### define architecture constants
52
[820]53    nb_ttys         = 1
54    nb_nics         = 2
55    x_io            = 0
56    y_io            = 0
57    x_width         = 4
58    y_width         = 4
59    p_width         = 4
60    paddr_width     = 40
61    irq_per_proc    = 4
62    use_ramdisk     = True
63    peri_increment  = 0x10000    # distributed peripherals vbase address increment
64    sched_increment = 0x10000    # distributed schedulers vbase address increment
65    ptab_increment  = 0x200000   # distributed page tables vbase address increment
66    reset_address   = 0x00000000
[793]67
68    ### parameters checking
69
[803]70    assert( nb_procs <= (1 << p_width) )
[793]71
72    assert( (x_size == 1) or (x_size == 2) or (x_size == 4)
73             or (x_size == 8) or (x_size == 16) )
74
75    assert( (y_size == 1) or (y_size == 2) or (y_size == 4)
76             or (y_size == 8) or (y_size == 16) )
77
78    assert( nb_ttys == 1 )
79
80    assert( ((x_io == 0) and (y_io == 0)) or
81            ((x_io == x_size-1) and (y_io == y_size-1)) )
82
[803]83    platform_name  = 'tsar_leti_%d_%d_%d' % ( x_size, y_size, nb_procs )
[793]84
85    ### define physical segments
[820]86    ### These segments are replicated in all clusters
[793]87
88    ram_base = 0x0000000000
89    ram_size = 0x4000000                   # 64 Mbytes
90
91    xcu_base = 0x00F0000000
92    xcu_size = 0x1000                      # 4 Kbytes
93
94    mmc_base = 0x00E0000000
95    mmc_size = 0x1000                      # 4 Kbytes
96
[820]97    ### define physical segments for external peripherals
98    ## These segments are only defined in cluster_io
99
[793]100    offset_io = ((x_io << y_width) + y_io) << (paddr_width - x_width - y_width)
101
102    bdv_base  = 0x00F2000000 + offset_io
103    bdv_size  = 0x1000                     # 4kbytes
104
105    tty_base  = 0x00F4000000 + offset_io
106    tty_size  = 0x4000                     # 16 Kbytes
107
108    nic_base  = 0x00F7000000 + offset_io
109    nic_size  = 0x80000                    # 512 kbytes
110
111    cma_base  = 0x00F8000000 + offset_io
112    cma_size  = 0x1000 * 2 * nb_nics       # 4 kbytes * 2 * nb_nics
113
114    fbf_base  = 0x00F3000000 + offset_io
115    fbf_size  = fbf_width * fbf_width      # fbf_width * fbf_width bytes
116
117    pic_base  = 0x00F9000000 + offset_io
118    pic_size  = 0x1000                     # 4 Kbytes
119
120    rdk_base  = 0x02000000
121    rdk_size  = 0x02000000                 # 32 Mbytes
122
[819]123    ### define preloader & bootloader vsegs base addresses and sizes
[820]124    ### We want to pack these 5 vsegs in the same big page
125    ### => boot cost is one BPP in cluster[0][0]
[803]126
[820]127                               '__W_', vtype = 'PERI' , x = x , y = y , pseg =
128                               'XCU',
[803]129    preloader_vbase      = 0x00000000      # ident
130    preloader_size       = 0x00010000      # 64 Kbytes
131
132    boot_mapping_vbase   = 0x00010000      # ident
[793]133    boot_mapping_size    = 0x00080000      # 512 Kbytes
134
[803]135    boot_code_vbase      = 0x00090000      # ident
[793]136    boot_code_size       = 0x00040000      # 256 Kbytes
137
[803]138    boot_data_vbase      = 0x000D0000      # ident
[793]139    boot_data_size       = 0x00080000      # 512 Kbytes
140
[803]141    boot_stack_vbase     = 0x00150000      # ident
[793]142    boot_stack_size      = 0x00050000      # 320 Kbytes
143
144    ### define kernel vsegs base addresses and sizes
[820]145    ### code, init, ptab & sched vsegs are replicated in all clusters.
146    ### data & uncdata vsegs are only mapped in cluster[0][0].
147    ### - We pack code, init, data vsegs in the same BIG page.
148    ### - We use another BIG page for the ptab vseg.
149    ### - We use 2*nb_procs SMALL pages for the sched vseg.
150    ### - we use one SMALL page for uncdata
151    ### => kernel cost is 2 BPPs and (2*n + 1) SPPs per cluster.
152
[793]153    kernel_code_vbase    = 0x80000000
[819]154    kernel_code_size     = 0x00080000      # 512 Kbytes per cluster
[793]155
[819]156    kernel_init_vbase    = 0x80080000
157    kernel_init_size     = 0x00080000      # 512 Kbytes per cluster
[793]158
[819]159    kernel_data_vbase    = 0x80100000
[820]160    kernel_data_size     = 0x00100000      # 1 Mbytes in cluster[0][0]
[793]161
[819]162    kernel_ptab_vbase    = 0xB0000000
163    kernel_ptab_size     = 0x00200000      # 2 Mbytes per cluster
[793]164
[819]165    kernel_uncdata_vbase = 0x90000000
166    kernel_uncdata_size  = 0x00001000      # 4 Kbytes
[793]167
[820]168    kernel_sched_vbase   = 0xA0000000            # distributed in all clusters
169    kernel_sched_size    = 0x00002000 * nb_procs # 8 kbytes per processor
[819]170
[793]171    ### create mapping
172
173    mapping = Mapping( name           = platform_name,
174                       x_size         = x_size,
175                       y_size         = y_size,
[819]176                       nprocs         = nb_procs,
[793]177                       x_width        = x_width,
178                       y_width        = y_width,
[803]179                       p_width        = p_width,
[793]180                       paddr_width    = paddr_width,
181                       coherence      = True,
182                       irq_per_proc   = irq_per_proc,
183                       use_ramdisk    = use_ramdisk,
184                       x_io           = x_io,
185                       y_io           = y_io,
186                       peri_increment = peri_increment,
187                       reset_address  = reset_address,
188                       ram_base       = ram_base,
189                       ram_size       = ram_size )
190
191    ###  external peripherals (accessible in cluster[0,0] only for this mapping)
192
[820]193    bdv = mapping.addPeriph( 'BDV', base = bdv_base, size = bdv_size, ptype = 'IOC', subtype = 'BDV' )
[793]194
[820]195    tty = mapping.addPeriph( 'TTY', base = tty_base, size = tty_size, ptype = 'TTY', channels = nb_ttys )
[793]196
[820]197    nic = mapping.addPeriph( 'NIC', base = nic_base, size = nic_size, ptype = 'NIC', channels = nb_nics )
[793]198
[820]199    cma = mapping.addPeriph( 'CMA', base = cma_base, size = cma_size, ptype = 'CMA', channels = 2*nb_nics )
[793]200
[820]201    fbf = mapping.addPeriph( 'FBF', base = fbf_base, size = fbf_size, ptype = 'FBF', arg = fbf_width )
[793]202
[820]203    pic = mapping.addPeriph( 'PIC', base = pic_base, size = pic_size, ptype = 'PIC', channels = 32 )
[793]204
205    mapping.addIrq( pic, index = 0 , isrtype = 'ISR_NIC_RX', channel = 0 )
206    mapping.addIrq( pic, index = 1 , isrtype = 'ISR_NIC_RX', channel = 1 )
207    mapping.addIrq( pic, index = 2 , isrtype = 'ISR_NIC_TX', channel = 0 )
208    mapping.addIrq( pic, index = 3 , isrtype = 'ISR_NIC_TX', channel = 1 )
209    mapping.addIrq( pic, index = 4 , isrtype = 'ISR_CMA'   , channel = 0 )
210    mapping.addIrq( pic, index = 5 , isrtype = 'ISR_CMA'   , channel = 1 )
211    mapping.addIrq( pic, index = 6 , isrtype = 'ISR_CMA'   , channel = 2 )
212    mapping.addIrq( pic, index = 7 , isrtype = 'ISR_CMA'   , channel = 3 )
213    mapping.addIrq( pic, index = 8 , isrtype = 'ISR_BDV'   , channel = 0 )
214    mapping.addIrq( pic, index = 16, isrtype = 'ISR_TTY_RX', channel = 0 )
215
216    ### hardware components replicated in all clusters
217
218    for x in xrange( x_size ):
219        for y in xrange( y_size ):
220            cluster_xy = (x << y_width) + y;
221            offset     = cluster_xy << (paddr_width - x_width - y_width)
222
[820]223            ram = mapping.addRam( 'RAM', base = ram_base + offset, size = ram_size )
[793]224
[820]225            mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset, size = mmc_size,
226                                     ptype = 'MMC' )
[793]227
[820]228            xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, size = xcu_size,
229                                     ptype = 'XCU', channels = nb_procs * irq_per_proc, arg = 16 )
[793]230
231            # IRQs replicated in all clusters
232            mapping.addIrq( xcu, index = 8, isrtype = 'ISR_MMC' )
233
234            # IRQ in IO cluster (0,0)
235            if x == 0 and y == 0:
236                mapping.addIrq( xcu, index = 9 , isrtype = 'ISR_BDV'    )
237                mapping.addIrq( xcu, index = 10, isrtype = 'ISR_TTY_RX' )
238
239            # processors
240            for p in xrange ( nb_procs ):
241                mapping.addProc( x, y, p )
242
[820]243    ### global vsegs for preloader & boot_loader
244    ### we want to pack those 5 vsegs in the same big page
245    ### => same flags CXW_ / identity mapping / non local / big page
[793]246
[820]247    mapping.addGlobal( 'seg_preloader', preloader_vbase, preloader_size,
[819]248                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
249                       identity = True, local = False, big = True )
250
[793]251    mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size,
[819]252                       'CXW_', vtype = 'BLOB'  , x = 0, y = 0, pseg = 'RAM',
253                       identity = True, local = False, big = True )
[793]254
255    mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size,
256                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
[819]257                       identity = True, local = False, big = True )
[793]258
259    mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size,
[819]260                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
261                       identity = True, local = False, big = True )
[793]262
263    mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size,
[819]264                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
265                       identity = True, local = False, big = True )
[793]266
[820]267    ### global vsegs kernel_code, kernel_init : local / big page
268    ### replicated in all clusters with the same name (same vbase)
[819]269    for x in xrange( x_size ):
270        for y in xrange( y_size ):
271            cluster_xy = (x << y_width) + y;
[793]272
[819]273            mapping.addGlobal( 'seg_kernel_code', kernel_code_vbase, kernel_code_size,
[820]274                               'CXW_', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
275                               binpath = 'build/kernel/kernel.elf',
[819]276                               local = True, big = True )
[793]277
[819]278            mapping.addGlobal( 'seg_kernel_init', kernel_init_vbase, kernel_init_size,
[820]279                               'CXW_', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
[819]280                               binpath = 'build/kernel/kernel.elf',
281                               local = True, big = True )
[793]282
[820]283    ### global vseg kernel_data: non local / big page
284    ### Only mapped in cluster[0][0]
[793]285    mapping.addGlobal( 'seg_kernel_data', kernel_data_vbase, kernel_data_size,
286                       'C_W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
287                       binpath = 'build/kernel/kernel.elf', local = False )
288
[820]289    ### global vseg kernel_uncdata: non local / small page
290    ### Only mapped in cluster[0][0]
[793]291    mapping.addGlobal( 'seg_kernel_uncdata', kernel_uncdata_vbase, kernel_uncdata_size,
292                       '__W_', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
293                       binpath = 'build/kernel/kernel.elf', local = False )
294
[820]295    for x in xrange( x_size ):
296        for y in xrange( y_size ):
297            cluster_xy = (x << y_width) + y;
298
299            ### Global vsegs kernel_ptab_x_y: non local / big pages
300            ### replicated in all clusters with name indexed by (x,y)
301            ### as vbase address is incremented by (cluster_xy * vseg_increment)
302            offset = cluster_xy * ptab_increment
303            mapping.addGlobal( 'seg_kernel_ptab_%d_%d' %(x,y), kernel_ptab_vbase + offset, kernel_ptab_size,
304                               'CXW_', vtype = 'PTAB', x = x, y = y, pseg = 'RAM',
305                               local = False, big = True )
306
307            ### global vsegs kernel_sched : non local / small pages
308            ### allocated in all clusters with name indexed by (x,y)
309            ### as vbase address is incremented by (cluster_xy * vseg_increment)
310            offset = cluster_xy * sched_increment
311            mapping.addGlobal( 'seg_kernel_sched_%d_%d' %(x,y), kernel_sched_vbase + offset , kernel_sched_size,
312                               'C_W_', vtype = 'SCHED', x = x, y = y, pseg = 'RAM',
313                               local = False, big = False )
314
315    ### global vseg for ram disk
316    if use_ramdisk:
317        mapping.addGlobal( 'seg_rdk', rdk_base, rdk_size, '__W_',
318                           vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
319                           identity = True, local = False, big = True )
320
321    ### global vsegs for external peripherals: non local / big page
322    mapping.addGlobal( 'seg_bdv', bdv_base, bdv_size, '__W_',
323                       vtype = 'PERI', x = 0, y = 0, pseg = 'BDV',
324                       local = False, big = True )
325
326    mapping.addGlobal( 'seg_tty', tty_base, tty_size, '__W_',
327                       vtype = 'PERI', x = 0, y = 0, pseg = 'TTY',
328                       local = False, big = True )
329
330    mapping.addGlobal( 'seg_nic', nic_base, nic_size, '__W_',
331                       vtype = 'PERI', x = 0, y = 0, pseg = 'NIC',
332                       local = False, big = True )
333
334    mapping.addGlobal( 'seg_cma', cma_base, cma_size, '__W_',
335                       vtype = 'PERI', x = 0, y = 0, pseg = 'CMA',
336                       local = False, big = True )
337
338    mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size, '__W_',
339                       vtype = 'PERI', x = 0, y = 0, pseg = 'FBF',
340                       local = False, big = True )
341
342    mapping.addGlobal( 'seg_pic', pic_base, pic_size, '__W_',
343                       vtype = 'PERI', x = 0, y = 0, pseg = 'PIC',
344                       local = False, big = True )
345
346    ### global vsegs for internal peripherals : non local / small pages
347    ### allocated in all clusters with name indexed by (x,y)
348    ### as vbase address is incremented by (cluster_xy * vseg_increment)
349    for x in xrange( x_size ):
350        for y in xrange( y_size ):
351            offset = ((x << y_width) + y) * peri_increment
352
353            mapping.addGlobal( 'seg_xcu_%d_%d' %(x,y), xcu_base + offset, xcu_size,
354                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'XCU',
355                               local = False, big = False )
356
357            mapping.addGlobal( 'seg_mmc_%d_%d' %(x,y), mmc_base + offset, mmc_size,
358                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'MMC',
359                               local = False, big = False )
360
[793]361    ### return mapping ###
362
363    return mapping
364
365################################# platform test #######################################################
366
367if __name__ == '__main__':
368
369    mapping = arch( x_size    = 2,
370                    y_size    = 2,
371                    nb_procs  = 2 )
372
373#   print mapping.netbsd_dts()
374
375    print mapping.xml()
376
377#   print mapping.giet_vsegs()
378
379
380# Local Variables:
381# tab-width: 4;
382# c-basic-offset: 4;
383# c-file-offsets:((innamespace . 0)(inline-open . 0));
384# indent-tabs-mode: nil;
385# End:
386#
387# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
388
Note: See TracBrowser for help on using the repository browser.