source: branches/fault_tolerance/platforms/tsar_generic_iob/arch.py @ 736

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

fault_tolerance/tsar_generic_iob: architecture desc

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