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

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

Modify the mapping of the kernel_init_segment in arch.py
to have only one vseg per BPP.

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