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