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

Last change on this file since 966 was 966, checked in by alain, 9 years ago

Cosmetic

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