source: trunk/platforms/tsar_generic_iob/genmap.py @ 710

Last change on this file since 710 was 710, checked in by alain, 10 years ago

Remove the multi-TTY capability: only one external TTY channel.
This reduce the number of external IRQs (i.e. the number of WTIs)
and we can now generate mono-cluster / mono-processor architecture.

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