source: trunk/platforms/tsar_generic_iob/arch.py @ 1045

Last change on this file since 1045 was 1033, checked in by alain, 8 years ago

Modify the arch.py again to support TWO BPPs for bootloader.

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