source: trunk/platforms/tsar_generic_leti/arch.py @ 803

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

tsar_generic_leti: Using the new P_WIDTH constant from hard_config.h

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