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

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

Remove the seg_kernel_init vseg from the mapping.

  • 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_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,
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.
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     = 0x00200000           # 2 Mbytes per cluster
165
166    kernel_data_vbase    = 0x90000000
167    kernel_data_size     = 0x00200000           # 2 Mbytes in cluster[0,0]
168
169    kernel_ptab_vbase    = 0xE0000000
170    kernel_ptab_size     = 0x00200000           # 2 Mbytes per cluster
171
172    kernel_heap_vbase    = 0xD0000000
173    kernel_heap_size     = 0x00400000           # 4 Mbytes per cluster
174
175    kernel_sched_vbase   = 0xA0000000   
176    kernel_sched_size    = 0x00002000*nb_procs  # 8 Kbytes per proc per cluster
177
178    #########################
179    ### create mapping
180    #########################
181
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,       
188                       p_width        = p_width,
189                       paddr_width    = paddr_width,   
190                       coherence      = True,         
191                       irq_per_proc   = irq_per_proc, 
192                       use_ramdisk    = (ioc_type == 'RDK'),
193                       x_io           = x_io,         
194                       y_io           = y_io,
195                       peri_increment = peri_increment,
196                       ram_base       = ram_base,
197                       ram_size       = ram_size )
198
199
200    #############################
201    ###   Hardware Components
202    #############################
203
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)
208
209            ### components replicated in all clusters
210            mapping.addRam( 'RAM', base = ram_base + offset, 
211                                  size = ram_size )
212
213            xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, 
214                                     size = xcu_size, ptype = 'XCU', 
215                                     channels = nb_procs * irq_per_proc, 
216                                     arg0 = 32, arg1 = 32, arg2 = 32 )
217
218            mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset,
219                                     size = mmc_size, ptype = 'MMC' )
220
221            if ( mwr_type == 'GCD' ):
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 )
225
226            if ( mwr_type == 'DCT' ):
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 )
230
231            if ( mwr_type == 'CPY' ):
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 )
235
236            mapping.addIrq( xcu, index = 0, src = mmc, isrtype = 'ISR_MMC' )
237            mapping.addIrq( xcu, index = 1, src = mwr, isrtype = 'ISR_MWR' )
238
239            for p in xrange ( nb_procs ):
240                mapping.addProc( x , y , p )
241
242            ### external peripherals in cluster_io
243            if ( (x==x_io) and (y==y_io) ):
244
245                iob = mapping.addPeriph( 'IOB', base = iob_base + offset, size = iob_size, 
246                                         ptype = 'IOB' )
247
248                ioc = mapping.addPeriph( 'IOC', base = ioc_base + offset, size = ioc_size, 
249                                         ptype = 'IOC', subtype = ioc_type )
250
251                tty = mapping.addPeriph( 'TTY', base = tty_base + offset, size = tty_size, 
252                                         ptype = 'TTY', channels = nb_ttys )
253
254                nic = mapping.addPeriph( 'NIC', base = nic_base + offset, size = nic_size, 
255                                         ptype = 'NIC', channels = nb_nics )
256
257                cma = mapping.addPeriph( 'CMA', base = cma_base + offset, size = cma_size, 
258                                         ptype = 'CMA', channels = nb_cmas )
259
260                fbf = mapping.addPeriph( 'FBF', base = fbf_base + offset, size = fbf_size, 
261                                         ptype = 'FBF', arg0 = fbf_width, arg1 = fbf_width )
262
263                rom = mapping.addPeriph( 'ROM', base = rom_base + offset, size = rom_size, 
264                                         ptype = 'ROM' )
265
266                pic = mapping.addPeriph( 'PIC', base = pic_base + offset, size = pic_size, 
267                                         ptype = 'PIC', channels = 32 )
268
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 )
273
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 )
278
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 )
287
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'
291                if ( ioc_type == 'SPI' ): isr_ioc = 'ISR_SPI'
292
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 )
311
312
313    ####################################
314    ###   Boot & Kernel vsegs mapping
315    ####################################
316
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
320
321    mapping.addGlobal( 'seg_boot_mapping', boot_mapping_vbase, boot_mapping_size,
322                       'CXW_', vtype = 'BLOB'  , x = 0, y = 0, pseg = 'RAM',
323                       identity = True , local = False, big = True )
324
325    mapping.addGlobal( 'seg_boot_code', boot_code_vbase, boot_code_size,
326                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
327                       identity = True , local = False, big = True )
328
329    mapping.addGlobal( 'seg_boot_data', boot_data_vbase, boot_data_size,
330                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
331                       identity = True , local = False, big = True )
332
333    mapping.addGlobal( 'seg_boot_stack', boot_stack_vbase, boot_stack_size,
334                       'CXW_', vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM',
335                       identity = True , local = False, big = True )
336
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', 
341                       binpath = 'bin/kernel/kernel.elf', 
342                       local = False, big = True )
343
344    ### global vsegs kernel_code : big / local
345    ### replicated in all clusters with indexed name & same vbase
346    for x in xrange( x_size ):
347        for y in xrange( y_size ):
348            mapping.addGlobal( 'seg_kernel_code_%d_%d' %(x,y), 
349                               kernel_code_vbase, kernel_code_size,
350                               'CXW_', vtype = 'ELF', x = x , y = y , pseg = 'RAM',
351                               binpath = 'bin/kernel/kernel.elf', 
352                               local = True, big = True )
353
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
364    ### global vsegs kernel_sched_x_y : small / non local
365    ### one vseg per cluster with name indexed by (x,y)
366    for x in xrange( x_size ):
367        for y in xrange( y_size ):
368            offset = ((x << y_width) + y) * kernel_sched_size
369            mapping.addGlobal( 'seg_kernel_sched_%d_%d' %(x,y), 
370                               kernel_sched_vbase + offset , kernel_sched_size,
371                               'C_W_', vtype = 'SCHED', x = x , y = y , pseg = 'RAM',
372                               local = False, big = False )
373
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
379            mapping.addGlobal( 'seg_kernel_heap_%d_%d' %(x,y), 
380                               kernel_heap_vbase + offset , kernel_heap_size,
381                               'C_W_', vtype = 'HEAP', x = x , y = y , pseg = 'RAM',
382                               local = False, big = True )
383
384    ### global vsegs for external peripherals : non local / big page
385    mapping.addGlobal( 'seg_iob', iob_base, iob_size, '__W_',
386                       vtype = 'PERI', x = 0, y = 0, pseg = 'IOB',
387                       local = False, big = True )
388
389    mapping.addGlobal( 'seg_ioc', ioc_base, ioc_size, '__W_',
390                       vtype = 'PERI', x = 0, y = 0, pseg = 'IOC',
391                       local = False, big = True )
392
393    mapping.addGlobal( 'seg_tty', tty_base, tty_size, '__W_',
394                       vtype = 'PERI', x = 0, y = 0, pseg = 'TTY',
395                       local = False, big = True )
396
397    mapping.addGlobal( 'seg_nic', nic_base, nic_size, '__W_',
398                       vtype = 'PERI', x = 0, y = 0, pseg = 'NIC',
399                       local = False, big = True )
400
401    mapping.addGlobal( 'seg_cma', cma_base, cma_size, '__W_',
402                       vtype = 'PERI', x = 0, y = 0, pseg = 'CMA',
403                       local = False, big = True )
404
405    mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size, '__W_',
406                       vtype = 'PERI', x = 0, y = 0, pseg = 'FBF',
407                       local = False, big = True )
408
409    mapping.addGlobal( 'seg_pic', pic_base, pic_size, '__W_',
410                       vtype = 'PERI', x = 0, y = 0, pseg = 'PIC',
411                       local = False, big = True )
412
413    mapping.addGlobal( 'seg_rom', rom_base, rom_size, 'CXW_',
414                       vtype = 'PERI', x = 0, y = 0, pseg = 'ROM',
415                       local = False, big = True )
416
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)
420    for x in xrange( x_size ):
421        for y in xrange( y_size ):
422            offset = ((x << y_width) + y) * peri_increment
423
424            mapping.addGlobal( 'seg_xcu_%d_%d' %(x,y), 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), mmc_base + offset, mmc_size,
429                               '__W_', vtype = 'PERI' , x = x , y = y , pseg = 'MMC',
430                               local = False, big = False )
431
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
437    return mapping
438
439################################# platform test ####################################
440
441if __name__ == '__main__':
442
443    mapping = arch( x_size    = 2,
444                    y_size    = 2,
445                    nb_procs  = 2 )
446
447#   print mapping.netbsd_dts()
448
449    print mapping.xml()
450
451#   print mapping.giet_vsegs()
452
453
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.