[707] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | from 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 | ########################## |
---|
| 28 | def 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', arg1 = 128, arg2 = 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 | mapping.addIrq( pic, index = 2, isrtype = 'ISR_NIC_TX', channel = 0 ) |
---|
| 170 | mapping.addIrq( pic, index = 3, isrtype = 'ISR_NIC_TX', channel = 1 ) |
---|
| 171 | |
---|
| 172 | mapping.addIrq( pic, index = 4, isrtype = 'ISR_CMA' , channel = 0 ) |
---|
| 173 | mapping.addIrq( pic, index = 5, isrtype = 'ISR_CMA' , channel = 1 ) |
---|
| 174 | mapping.addIrq( pic, index = 6, isrtype = 'ISR_CMA' , channel = 2 ) |
---|
| 175 | mapping.addIrq( pic, index = 7, isrtype = 'ISR_CMA' , channel = 3 ) |
---|
| 176 | |
---|
| 177 | mapping.addIrq( pic, index = 8, isrtype = 'ISR_BDV' , channel = 0 ) |
---|
| 178 | |
---|
| 179 | mapping.addIrq( pic, index = 16, isrtype = 'ISR_TTY_RX', channel = 0 ) |
---|
| 180 | mapping.addIrq( pic, index = 17, isrtype = 'ISR_TTY_RX', channel = 1 ) |
---|
| 181 | mapping.addIrq( pic, index = 18, isrtype = 'ISR_TTY_RX', channel = 2 ) |
---|
| 182 | mapping.addIrq( pic, index = 19, isrtype = 'ISR_TTY_RX', channel = 3 ) |
---|
| 183 | mapping.addIrq( pic, index = 20, isrtype = 'ISR_TTY_RX', channel = 4 ) |
---|
| 184 | mapping.addIrq( pic, index = 21, isrtype = 'ISR_TTY_RX', channel = 5 ) |
---|
| 185 | mapping.addIrq( pic, index = 22, isrtype = 'ISR_TTY_RX', channel = 6 ) |
---|
| 186 | mapping.addIrq( pic, index = 23, isrtype = 'ISR_TTY_RX', channel = 7 ) |
---|
| 187 | |
---|
| 188 | ### hardware components replicated in all clusters |
---|
| 189 | |
---|
| 190 | for x in xrange( x_size ): |
---|
| 191 | for y in xrange( y_size ): |
---|
| 192 | cluster_xy = (x << y_width) + y; |
---|
| 193 | offset = cluster_xy << (paddr_width - x_width - y_width) |
---|
| 194 | |
---|
| 195 | ram = mapping.addRam( 'RAM', base = ram_base + offset, size = ram_size ) |
---|
| 196 | |
---|
| 197 | mmc = mapping.addPeriph( 'MMC', base = mmc_base + offset, size = mmc_size, |
---|
| 198 | ptype = 'MMC' ) |
---|
| 199 | |
---|
| 200 | dma = mapping.addPeriph( 'DMA', base = dma_base + offset, size = dma_size, |
---|
| 201 | ptype = 'DMA', channels = nb_procs ) |
---|
| 202 | |
---|
| 203 | xcu = mapping.addPeriph( 'XCU', base = xcu_base + offset, size = xcu_size, |
---|
| 204 | ptype = 'XCU', channels = nb_procs * irq_per_proc, |
---|
| 205 | arg1 = 16, arg2 = 16, arg3 = 16 ) |
---|
| 206 | |
---|
| 207 | # MMC IRQ replicated in all clusters |
---|
| 208 | mapping.addIrq( xcu, index = 0, isrtype = 'ISR_MMC' ) |
---|
| 209 | |
---|
| 210 | # DMA IRQs replicated in all clusters |
---|
| 211 | for p in xrange( nb_procs ): |
---|
| 212 | mapping.addIrq( xcu, index = (p+1), isrtype = 'ISR_DMA', channel = p ) |
---|
| 213 | |
---|
| 214 | # processors |
---|
| 215 | for p in xrange ( nb_procs ): |
---|
| 216 | mapping.addProc( x, y, p ) |
---|
| 217 | |
---|
| 218 | ### global vsegs for boot_loader / identity mapping |
---|
| 219 | |
---|
| 220 | mapping.addGlobal( 'seg_boot_mapping' , boot_mapping_vbase , boot_mapping_size , 'C_W_', |
---|
| 221 | vtype = 'BLOB' , x = 0, y = 0, pseg = 'RAM', identity = True ) |
---|
| 222 | |
---|
| 223 | mapping.addGlobal( 'seg_boot_code' , boot_code_vbase , boot_code_size , 'CXW_', |
---|
| 224 | vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', identity = True ) |
---|
| 225 | |
---|
| 226 | mapping.addGlobal( 'seg_boot_data' , boot_data_vbase , boot_data_size , 'C_W_', |
---|
| 227 | vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', identity = True ) |
---|
| 228 | |
---|
| 229 | mapping.addGlobal( 'seg_boot_buffer' , boot_buffer_vbase , boot_buffer_size , 'C_W_', |
---|
| 230 | vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', identity = True ) |
---|
| 231 | |
---|
| 232 | mapping.addGlobal( 'seg_boot_stack' , boot_stack_vbase , boot_stack_size , 'C_W_', |
---|
| 233 | vtype = 'BUFFER', x = 0, y = 0, pseg = 'RAM', identity = True ) |
---|
| 234 | |
---|
| 235 | ### global vsegs for kernel |
---|
| 236 | |
---|
| 237 | mapping.addGlobal( 'seg_kernel_code' , kernel_code_vbase , kernel_code_size , 'CXW_', |
---|
| 238 | vtype = 'ELF' , x = 0, y = 0, pseg = 'RAM', binpath = 'build/kernel/kernel.elf' ) |
---|
| 239 | |
---|
| 240 | mapping.addGlobal( 'seg_kernel_data' , kernel_data_vbase , kernel_data_size , 'C_W_', |
---|
| 241 | vtype = 'ELF' , x = 0, y = 0, pseg = 'RAM', binpath = 'build/kernel/kernel.elf' ) |
---|
| 242 | |
---|
| 243 | mapping.addGlobal( 'seg_kernel_uncdata', kernel_uncdata_vbase, kernel_uncdata_size, '__W_', |
---|
| 244 | vtype = 'ELF' , x = 0, y = 0, pseg = 'RAM', binpath = 'build/kernel/kernel.elf' ) |
---|
| 245 | |
---|
| 246 | mapping.addGlobal( 'seg_kernel_init' , kernel_init_vbase , kernel_init_size , 'CXW_', |
---|
| 247 | vtype = 'ELF' , x = 0, y = 0, pseg = 'RAM', binpath = 'build/kernel/kernel.elf' ) |
---|
| 248 | |
---|
| 249 | ### global vsegs for external peripherals / identity mapping |
---|
| 250 | |
---|
| 251 | mapping.addGlobal( 'seg_iob', iob_base, iob_size, '__W_', |
---|
| 252 | vtype = 'PERI', x = 0, y = 0, pseg = 'IOB', identity = True ) |
---|
| 253 | |
---|
| 254 | mapping.addGlobal( 'seg_bdv', bdv_base, bdv_size, '__W_', |
---|
| 255 | vtype = 'PERI', x = 0, y = 0, pseg = 'BDV', identity = True ) |
---|
| 256 | |
---|
| 257 | mapping.addGlobal( 'seg_tty', tty_base, tty_size, '__W_', |
---|
| 258 | vtype = 'PERI', x = 0, y = 0, pseg = 'TTY', identity = True ) |
---|
| 259 | |
---|
| 260 | mapping.addGlobal( 'seg_nic', nic_base, nic_size, '__W_', |
---|
| 261 | vtype = 'PERI', x = 0, y = 0, pseg = 'NIC', identity = True ) |
---|
| 262 | |
---|
| 263 | mapping.addGlobal( 'seg_cma', cma_base, cma_size, '__W_', |
---|
| 264 | vtype = 'PERI', x = 0, y = 0, pseg = 'CMA', identity = True ) |
---|
| 265 | |
---|
| 266 | mapping.addGlobal( 'seg_fbf', fbf_base, fbf_size, '__W_', |
---|
| 267 | vtype = 'PERI', x = 0, y = 0, pseg = 'FBF', identity = True ) |
---|
| 268 | |
---|
| 269 | mapping.addGlobal( 'seg_pic', pic_base, pic_size, '__W_', |
---|
| 270 | vtype = 'PERI', x = 0, y = 0, pseg = 'PIC', identity = True ) |
---|
| 271 | |
---|
| 272 | mapping.addGlobal( 'seg_rom', rom_base, rom_size, 'CXW_', |
---|
| 273 | vtype = 'PERI', x = 0, y = 0, pseg = 'ROM', identity = True ) |
---|
| 274 | |
---|
| 275 | ### Global vsegs for replicated peripherals, and for scheduler |
---|
| 276 | ### Note: one vseg per cluster: the vseg name is indexed by (x,y) |
---|
| 277 | ### the vseg base address is incremented by (cluster_xy * 0x10000) |
---|
| 278 | |
---|
| 279 | mapping.addGlobal( 'seg_xcu' , xcu_base , xcu_size , '__W_', |
---|
| 280 | vtype = 'PERI' , x = 0, y = 0, pseg = 'XCU', replicated = True ) |
---|
| 281 | |
---|
| 282 | mapping.addGlobal( 'seg_dma' , dma_base , dma_size , '__W_', |
---|
| 283 | vtype = 'PERI' , x = 0, y = 0, pseg = 'DMA', replicated = True ) |
---|
| 284 | |
---|
| 285 | mapping.addGlobal( 'seg_mmc' , mmc_base , mmc_size , '__W_', |
---|
| 286 | vtype = 'PERI' , x = 0, y = 0, pseg = 'MMC', replicated = True ) |
---|
| 287 | |
---|
| 288 | mapping.addGlobal( 'seg_sched', kernel_sched_vbase, kernel_sched_size, 'C_W_', |
---|
| 289 | vtype = 'SCHED', x = 0, y = 0, pseg = 'RAM', replicated = True ) |
---|
| 290 | |
---|
| 291 | ### return mapping ### |
---|
| 292 | |
---|
| 293 | return mapping |
---|
| 294 | |
---|
| 295 | ################################# platform test ####################################################### |
---|
| 296 | |
---|
| 297 | if __name__ == '__main__': |
---|
| 298 | |
---|
| 299 | mapping = genmap( x_size = 2, |
---|
| 300 | y_size = 2, |
---|
| 301 | nb_procs = 2, |
---|
| 302 | nb_ttys = 1, |
---|
| 303 | nb_nics = 2, |
---|
| 304 | fbf_width = 128, |
---|
| 305 | x_io = 0, |
---|
| 306 | y_io = 0 ) |
---|
| 307 | |
---|
| 308 | # print mapping.netbsd_dts() |
---|
| 309 | |
---|
| 310 | print mapping.xml() |
---|
| 311 | |
---|
| 312 | # print mapping.giet_vsegs() |
---|
| 313 | |
---|
| 314 | |
---|
| 315 | # Local Variables: |
---|
| 316 | # tab-width: 4; |
---|
| 317 | # c-basic-offset: 4; |
---|
| 318 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 319 | # indent-tabs-mode: nil; |
---|
| 320 | # End: |
---|
| 321 | # |
---|
| 322 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 323 | |
---|