[425] | 1 | #!/usr/bin/env python |
---|
[305] | 2 | |
---|
[319] | 3 | import sys |
---|
| 4 | |
---|
[512] | 5 | ######################################################################################## |
---|
[305] | 6 | # file : giet_mapping.py |
---|
| 7 | # date : april 2014 |
---|
| 8 | # author : Alain Greiner |
---|
[512] | 9 | ######################################################################################## |
---|
[319] | 10 | # This file contains the classes required to define a mapping for the GIET_VM. |
---|
| 11 | # - A 'Mapping' contains a set of 'Cluster' (hardware architecture) |
---|
[520] | 12 | # a set of 'Vseg' (kernel glogals virtual segments) |
---|
| 13 | # a set of 'Vspace' (one or several user applications) |
---|
[512] | 14 | # - A 'Cluster' contains a set of 'Pseg' (physical segments in cluster) |
---|
[319] | 15 | # a set of 'Proc' (processors in cluster) |
---|
| 16 | # a set of 'Periph' (peripherals in cluster) |
---|
[512] | 17 | # - A 'Vspace' contains a set of 'Vseg' (user virtual segments) |
---|
| 18 | # a set of 'Task' (user parallel tasks) |
---|
[441] | 19 | # - A 'Periph' contains a set of 'Irq' (only for XCU and PIC types ) |
---|
[512] | 20 | ######################################################################################## |
---|
[319] | 21 | # Implementation Note |
---|
[512] | 22 | # The objects used to describe a mapping are distributed in the PYTHON structure: |
---|
[319] | 23 | # For example the psegs set is split in several subsets (one subset per cluster), |
---|
| 24 | # or the tasks set is split in several subsets (one subset per vspace), etc... |
---|
| 25 | # In the C binary data structure used by the giet_vm, all objects of same type |
---|
[406] | 26 | # are stored in a linear array (one single array for all psegs for example). |
---|
[512] | 27 | # For all objects, we compute and store in the PYTHON object itself a "global index" |
---|
[406] | 28 | # corresponding to the index in this global array, and this index can be used as |
---|
[319] | 29 | # a pseudo-pointer to identify a specific object of a given type. |
---|
[512] | 30 | ######################################################################################## |
---|
[305] | 31 | |
---|
[512] | 32 | ######################################################################################## |
---|
[411] | 33 | # Various constants |
---|
[512] | 34 | ######################################################################################## |
---|
[411] | 35 | |
---|
| 36 | PADDR_WIDTH = 40 # number of bits for physical address |
---|
| 37 | X_WIDTH = 4 # number of bits encoding x coordinate |
---|
| 38 | Y_WIDTH = 4 # number of bits encoding y coordinate |
---|
| 39 | P_WIDTH = 4 # number of bits encoding local proc_id |
---|
| 40 | VPN_ANTI_MASK = 0x00000FFF # mask virtual address to get offset in a small page |
---|
| 41 | BPN_MASK = 0xFFE00000 # mask virtual address to get the BPN (big page) |
---|
[520] | 42 | PERI_INCREMENT = 0x10000 # virtual address increment for replicated l vsegs |
---|
[411] | 43 | RESET_ADDRESS = 0xBFC00000 # Processor wired boot_address |
---|
| 44 | MAPPING_SIGNATURE = 0xDACE2014 # Magic number indicating a valid C binary struture |
---|
| 45 | |
---|
[512] | 46 | ######################################################################################## |
---|
[520] | 47 | # These lists must be consistent with values defined in |
---|
| 48 | # mapping_info.h / xml_driver.c /xml_parser.c |
---|
[512] | 49 | ######################################################################################## |
---|
[319] | 50 | PERIPHTYPES = [ |
---|
| 51 | 'CMA', |
---|
| 52 | 'DMA', |
---|
| 53 | 'FBF', |
---|
| 54 | 'IOB', |
---|
| 55 | 'IOC', |
---|
| 56 | 'MMC', |
---|
| 57 | 'MWR', |
---|
| 58 | 'NIC', |
---|
| 59 | 'ROM', |
---|
| 60 | 'SIM', |
---|
| 61 | 'TIM', |
---|
| 62 | 'TTY', |
---|
| 63 | 'XCU', |
---|
| 64 | 'PIC', |
---|
[491] | 65 | 'DROM', |
---|
[319] | 66 | ] |
---|
| 67 | |
---|
[520] | 68 | IOCSUBTYPES = [ |
---|
[319] | 69 | 'BDV', |
---|
| 70 | 'HBA', |
---|
| 71 | 'SPI', |
---|
| 72 | 'NONE', |
---|
| 73 | ] |
---|
| 74 | |
---|
[520] | 75 | MWRSUBTYPES = [ |
---|
| 76 | 'GCD', |
---|
| 77 | 'DCT', |
---|
| 78 | ] |
---|
| 79 | |
---|
| 80 | ###################################################################################### |
---|
| 81 | # These lists must be consistent with values defined in |
---|
| 82 | # irq_handler.c / irq_handler.h / xml_driver.c / xml_parser.c |
---|
| 83 | ###################################################################################### |
---|
[319] | 84 | IRQTYPES = [ |
---|
| 85 | 'HWI', |
---|
| 86 | 'WTI', |
---|
| 87 | 'PTI', |
---|
| 88 | ] |
---|
| 89 | |
---|
| 90 | ISRTYPES = [ |
---|
| 91 | 'ISR_DEFAULT', |
---|
| 92 | 'ISR_TICK', |
---|
| 93 | 'ISR_TTY_RX', |
---|
| 94 | 'ISR_TTY_TX', |
---|
| 95 | 'ISR_BDV', |
---|
| 96 | 'ISR_TIMER', |
---|
| 97 | 'ISR_WAKUP', |
---|
| 98 | 'ISR_NIC_RX', |
---|
| 99 | 'ISR_NIC_TX', |
---|
| 100 | 'ISR_CMA', |
---|
| 101 | 'ISR_MMC', |
---|
| 102 | 'ISR_DMA', |
---|
| 103 | 'ISR_SPI', |
---|
[520] | 104 | 'ISR_MWR' |
---|
[319] | 105 | ] |
---|
| 106 | |
---|
[512] | 107 | VSEGTYPES = [ |
---|
[319] | 108 | 'ELF', |
---|
| 109 | 'BLOB', |
---|
| 110 | 'PTAB', |
---|
| 111 | 'PERI', |
---|
[512] | 112 | 'MWMR', # deprecated |
---|
| 113 | 'LOCK', # deprecated |
---|
[319] | 114 | 'BUFFER', |
---|
[512] | 115 | 'BARRIER', # deprecated |
---|
| 116 | 'CONST', # deprecated |
---|
| 117 | 'MEMSPACE', # deprecated |
---|
| 118 | 'SCHED', |
---|
[471] | 119 | 'HEAP', |
---|
[319] | 120 | ] |
---|
| 121 | |
---|
| 122 | VSEGMODES = [ |
---|
| 123 | '____', |
---|
| 124 | '___U', |
---|
| 125 | '__W_', |
---|
| 126 | '__WU', |
---|
| 127 | '_X__', |
---|
| 128 | '_X_U', |
---|
| 129 | '_XW_', |
---|
| 130 | '_XWU', |
---|
| 131 | 'C___', |
---|
| 132 | 'C__U', |
---|
| 133 | 'C_W_', |
---|
| 134 | 'C_WU', |
---|
| 135 | 'CX__', |
---|
| 136 | 'CX_U', |
---|
| 137 | 'CXW_', |
---|
| 138 | 'CXWU', |
---|
| 139 | ] |
---|
| 140 | |
---|
| 141 | PSEGTYPES = [ |
---|
| 142 | 'RAM', |
---|
| 143 | 'PERI', |
---|
| 144 | ] |
---|
| 145 | |
---|
[512] | 146 | ####################################################################################### |
---|
[305] | 147 | class Mapping( object ): |
---|
[512] | 148 | ####################################################################################### |
---|
[305] | 149 | def __init__( self, |
---|
[411] | 150 | name, # mapping name |
---|
| 151 | x_size, # number of clusters in a row |
---|
| 152 | y_size, # number of clusters in a column |
---|
[421] | 153 | nprocs, # max number of processors per cluster |
---|
[411] | 154 | x_width = X_WIDTH, # number of bits encoding x coordinate |
---|
| 155 | y_width = Y_WIDTH, # number of bits encoding y coordinate |
---|
[512] | 156 | p_width = P_WIDTH, # number of bits encoding lpid |
---|
[411] | 157 | paddr_width = PADDR_WIDTH, # number of bits for physical address |
---|
[512] | 158 | coherence = 1, # hardware cache coherence if non-zero |
---|
[411] | 159 | irq_per_proc = 1, # number or IRQs from XCU to processor |
---|
| 160 | use_ramdisk = False, # use ramdisk when true |
---|
| 161 | x_io = 0, # cluster_io x coordinate |
---|
| 162 | y_io = 0, # cluster_io y coordinate |
---|
| 163 | peri_increment = PERI_INCREMENT, # address increment for globals |
---|
| 164 | reset_address = RESET_ADDRESS, # Processor wired boot_address |
---|
| 165 | ram_base = 0, # RAM physical base in cluster[0,0] |
---|
| 166 | ram_size = 0 ): # RAM size in each cluster (bytes) |
---|
[305] | 167 | |
---|
[411] | 168 | assert ( x_size <= (1<<X_WIDTH) ) |
---|
| 169 | assert ( y_size <= (1<<Y_WIDTH) ) |
---|
| 170 | assert ( nprocs <= (1<<P_WIDTH) ) |
---|
[406] | 171 | |
---|
[411] | 172 | self.signature = MAPPING_SIGNATURE |
---|
[319] | 173 | self.name = name |
---|
[497] | 174 | self.name = name |
---|
[406] | 175 | self.paddr_width = paddr_width |
---|
[319] | 176 | self.coherence = coherence |
---|
| 177 | self.x_size = x_size |
---|
| 178 | self.y_size = y_size |
---|
[441] | 179 | self.nprocs = nprocs |
---|
[319] | 180 | self.x_width = x_width |
---|
| 181 | self.y_width = y_width |
---|
[406] | 182 | self.p_width = p_width |
---|
[319] | 183 | self.irq_per_proc = irq_per_proc |
---|
| 184 | self.use_ramdisk = use_ramdisk |
---|
| 185 | self.x_io = x_io |
---|
| 186 | self.y_io = y_io |
---|
[328] | 187 | self.peri_increment = peri_increment |
---|
[319] | 188 | self.reset_address = reset_address |
---|
[356] | 189 | self.ram_base = ram_base |
---|
| 190 | self.ram_size = ram_size |
---|
[305] | 191 | |
---|
[319] | 192 | self.total_vspaces = 0 |
---|
| 193 | self.total_globals = 0 |
---|
| 194 | self.total_psegs = 0 |
---|
| 195 | self.total_vsegs = 0 |
---|
| 196 | self.total_tasks = 0 |
---|
| 197 | self.total_procs = 0 |
---|
| 198 | self.total_irqs = 0 |
---|
| 199 | self.total_periphs = 0 |
---|
[305] | 200 | |
---|
[319] | 201 | self.clusters = [] |
---|
| 202 | self.globs = [] |
---|
| 203 | self.vspaces = [] |
---|
[305] | 204 | |
---|
[319] | 205 | for x in xrange( self.x_size ): |
---|
| 206 | for y in xrange( self.y_size ): |
---|
| 207 | cluster = Cluster( x , y ) |
---|
[406] | 208 | cluster.index = (x * self.y_size) + y |
---|
[319] | 209 | self.clusters.append( cluster ) |
---|
[305] | 210 | |
---|
| 211 | return |
---|
| 212 | |
---|
[319] | 213 | ########################## add a ram pseg in a cluster |
---|
[406] | 214 | def addRam( self, |
---|
[319] | 215 | name, # pseg name |
---|
| 216 | base, # pseg base address |
---|
| 217 | size ): # pseg length (bytes) |
---|
[406] | 218 | |
---|
[497] | 219 | # computes cluster index and coordinates from the base address |
---|
[356] | 220 | paddr_lsb_width = self.paddr_width - self.x_width - self.y_width |
---|
| 221 | cluster_xy = base >> paddr_lsb_width |
---|
[497] | 222 | x = cluster_xy >> (self.y_width); |
---|
| 223 | y = cluster_xy & ((1 << self.y_width) - 1) |
---|
| 224 | cluster_id = (x * self.y_size) + y |
---|
[305] | 225 | |
---|
[411] | 226 | assert (base & VPN_ANTI_MASK) == 0 |
---|
[319] | 227 | |
---|
| 228 | assert (x < self.x_size) and (y < self.y_size) |
---|
[406] | 229 | |
---|
[356] | 230 | assert ( (base & ((1<<paddr_lsb_width)-1)) == self.ram_base ) |
---|
| 231 | |
---|
| 232 | assert ( size == self.ram_size ) |
---|
| 233 | |
---|
[319] | 234 | # add one pseg in the mapping |
---|
| 235 | pseg = Pseg( name, base, size, x, y, 'RAM' ) |
---|
| 236 | self.clusters[cluster_id].psegs.append( pseg ) |
---|
| 237 | pseg.index = self.total_psegs |
---|
| 238 | self.total_psegs += 1 |
---|
| 239 | |
---|
| 240 | return pseg |
---|
| 241 | |
---|
[512] | 242 | ########################## add a peripheral and the associated pseg in a cluster |
---|
[406] | 243 | def addPeriph( self, |
---|
[319] | 244 | name, # associated pseg name |
---|
| 245 | base, # associated pseg base address |
---|
| 246 | size, # associated pseg length (bytes) |
---|
[406] | 247 | ptype, # peripheral type |
---|
[319] | 248 | subtype = 'NONE', # peripheral subtype |
---|
| 249 | channels = 1, # number of channels |
---|
[520] | 250 | arg0 = 0, # optional argument (semantic depends on ptype) |
---|
| 251 | arg1 = 0, # optional argument (semantic depends on ptype) |
---|
| 252 | arg2 = 0, # optional argument (semantic depends on ptype) |
---|
| 253 | arg3 = 0 ): # optional argument (semantic depends on ptype) |
---|
[319] | 254 | |
---|
[497] | 255 | # computes cluster index and coordinates from the base address |
---|
[319] | 256 | cluster_xy = base >> (self.paddr_width - self.x_width - self.y_width) |
---|
[497] | 257 | x = cluster_xy >> (self.y_width); |
---|
| 258 | y = cluster_xy & ((1 << self.y_width) - 1) |
---|
| 259 | cluster_id = (x * self.y_size) + y |
---|
[305] | 260 | |
---|
[319] | 261 | assert (x < self.x_size) and (y < self.y_size) |
---|
| 262 | |
---|
[411] | 263 | assert (base & VPN_ANTI_MASK) == 0 |
---|
[319] | 264 | |
---|
| 265 | assert ptype in PERIPHTYPES |
---|
| 266 | |
---|
[520] | 267 | if (ptype == 'IOC'): assert subtype in IOCSUBTYPES |
---|
| 268 | if (ptype == 'MWR'): assert subtype in MWRSUBTYPES |
---|
[319] | 269 | |
---|
| 270 | # add one pseg into mapping |
---|
| 271 | pseg = Pseg( name, base, size, x, y, 'PERI' ) |
---|
| 272 | self.clusters[cluster_id].psegs.append( pseg ) |
---|
| 273 | pseg.index = self.total_psegs |
---|
| 274 | self.total_psegs += 1 |
---|
| 275 | |
---|
| 276 | # add one periph into mapping |
---|
[520] | 277 | periph = Periph( pseg, ptype, subtype, channels, arg0, arg1, arg2, arg3 ) |
---|
[319] | 278 | self.clusters[cluster_id].periphs.append( periph ) |
---|
| 279 | periph.index = self.total_periphs |
---|
| 280 | self.total_periphs += 1 |
---|
| 281 | |
---|
| 282 | return periph |
---|
| 283 | |
---|
| 284 | ################################ add an IRQ in a peripheral |
---|
| 285 | def addIrq( self, |
---|
| 286 | periph, # peripheral containing IRQ (PIC or XCU) |
---|
| 287 | index, # peripheral input port index |
---|
| 288 | isrtype, # ISR type |
---|
| 289 | channel = 0 ): # channel for multi-channels ISR |
---|
| 290 | |
---|
| 291 | assert isrtype in ISRTYPES |
---|
| 292 | |
---|
| 293 | assert index < 32 |
---|
| 294 | |
---|
[406] | 295 | # add one irq into mapping |
---|
[319] | 296 | irq = Irq( 'HWI', index , isrtype, channel ) |
---|
| 297 | periph.irqs.append( irq ) |
---|
| 298 | irq.index = self.total_irqs |
---|
| 299 | self.total_irqs += 1 |
---|
| 300 | |
---|
| 301 | return irq |
---|
| 302 | |
---|
| 303 | ########################## add a processor in a cluster |
---|
[406] | 304 | def addProc( self, |
---|
[319] | 305 | x, # cluster x coordinate |
---|
| 306 | y, # cluster y coordinate |
---|
[520] | 307 | lpid ): # processor local index |
---|
[319] | 308 | |
---|
| 309 | assert (x < self.x_size) and (y < self.y_size) |
---|
| 310 | |
---|
| 311 | cluster_id = (x * self.y_size) + y |
---|
| 312 | |
---|
[406] | 313 | # add one proc into mapping |
---|
[520] | 314 | proc = Processor( x, y, lpid ) |
---|
[319] | 315 | self.clusters[cluster_id].procs.append( proc ) |
---|
| 316 | proc.index = self.total_procs |
---|
[305] | 317 | self.total_procs += 1 |
---|
| 318 | |
---|
[319] | 319 | return proc |
---|
| 320 | |
---|
[411] | 321 | ############################ add one global vseg into mapping |
---|
| 322 | def addGlobal( self, |
---|
| 323 | name, # vseg name |
---|
| 324 | vbase, # virtual base address |
---|
[512] | 325 | length, # vseg length (bytes) |
---|
[411] | 326 | mode, # CXWU flags |
---|
[512] | 327 | vtype, # vseg type |
---|
[411] | 328 | x, # destination x coordinate |
---|
| 329 | y, # destination y coordinate |
---|
| 330 | pseg, # destination pseg name |
---|
| 331 | identity = False, # identity mapping required if true |
---|
| 332 | local = False, # only mapped in local PTAB if true |
---|
[512] | 333 | big = False, # to be mapped in a big physical page |
---|
| 334 | binpath = '' ): # pathname for binary code if required |
---|
[319] | 335 | |
---|
[411] | 336 | # two global vsegs must not overlap if they have different names |
---|
| 337 | for prev in self.globs: |
---|
[512] | 338 | if ( ((prev.vbase + prev.length) > vbase ) and |
---|
| 339 | ((vbase + length) > prev.vbase) and |
---|
[411] | 340 | (prev.name != name) ): |
---|
[512] | 341 | print '[genmap error] in addGlobal()' |
---|
| 342 | print ' global vseg %s overlap %s' % (name, prev.name) |
---|
| 343 | print ' %s : base = %x / size = %x' %( name, vbase, size ) |
---|
| 344 | print ' %s : base = %x / size = %x' %( prev.name, prev.vbase, prev.size ) |
---|
[411] | 345 | sys.exit(1) |
---|
| 346 | |
---|
[328] | 347 | # add one vseg into mapping |
---|
[512] | 348 | vseg = Vseg( name, vbase, length, mode, vtype, x, y, pseg, |
---|
| 349 | identity = identity, local = local, big = big, binpath = binpath ) |
---|
[348] | 350 | |
---|
[328] | 351 | self.globs.append( vseg ) |
---|
| 352 | self.total_globals += 1 |
---|
[406] | 353 | vseg.index = self.total_vsegs |
---|
[328] | 354 | self.total_vsegs += 1 |
---|
[406] | 355 | |
---|
[305] | 356 | return |
---|
| 357 | |
---|
[319] | 358 | ################################ add a vspace into mapping |
---|
[406] | 359 | def addVspace( self, |
---|
[319] | 360 | name, # vspace name |
---|
[512] | 361 | startname ): # name of vseg containing start_vector |
---|
[319] | 362 | |
---|
| 363 | # add one vspace into mapping |
---|
| 364 | vspace = Vspace( name, startname ) |
---|
[305] | 365 | self.vspaces.append( vspace ) |
---|
[319] | 366 | vspace.index = self.total_vspaces |
---|
| 367 | self.total_vspaces += 1 |
---|
| 368 | |
---|
| 369 | return vspace |
---|
[406] | 370 | |
---|
[512] | 371 | ################################# add a private vseg in a vspace |
---|
[319] | 372 | def addVseg( self, |
---|
[406] | 373 | vspace, # vspace containing the vseg |
---|
[319] | 374 | name, # vseg name |
---|
| 375 | vbase, # virtual base address |
---|
[512] | 376 | length, # vseg length (bytes) |
---|
[319] | 377 | mode, # CXWU flags |
---|
[512] | 378 | vtype, # vseg type |
---|
[319] | 379 | x, # destination x coordinate |
---|
| 380 | y, # destination y coordinate |
---|
| 381 | pseg, # destination pseg name |
---|
[411] | 382 | local = False, # only mapped in local PTAB if true |
---|
[512] | 383 | big = False, # to be mapped in a big physical page |
---|
| 384 | binpath = '' ): # pathname for binary code |
---|
[319] | 385 | |
---|
| 386 | assert mode in VSEGMODES |
---|
| 387 | |
---|
[512] | 388 | assert vtype in VSEGTYPES |
---|
[319] | 389 | |
---|
| 390 | assert (x < self.x_size) and (y < self.y_size) |
---|
| 391 | |
---|
| 392 | # add one vseg into mapping |
---|
[512] | 393 | vseg = Vseg( name, vbase, length, mode, vtype, x, y, pseg, |
---|
| 394 | identity = False, local = local, big = big, binpath = binpath ) |
---|
[319] | 395 | vspace.vsegs.append( vseg ) |
---|
| 396 | vseg.index = self.total_vsegs |
---|
| 397 | self.total_vsegs += 1 |
---|
| 398 | |
---|
| 399 | return vseg |
---|
| 400 | |
---|
[406] | 401 | ################################ add a task in a vspace |
---|
| 402 | def addTask( self, |
---|
[319] | 403 | vspace, # vspace containing task |
---|
| 404 | name, # task name |
---|
| 405 | trdid, # task index in vspace |
---|
| 406 | x, # destination x coordinate |
---|
| 407 | y, # destination y coordinate |
---|
| 408 | lpid, # destination processor local index |
---|
[512] | 409 | stackname, # name of vseg containing stack |
---|
| 410 | heapname, # name of vseg containing heap |
---|
[441] | 411 | startid ): # index in start_vector |
---|
[406] | 412 | |
---|
[319] | 413 | assert (x < self.x_size) and (y < self.y_size) |
---|
[411] | 414 | assert lpid < self.nprocs |
---|
[319] | 415 | |
---|
[406] | 416 | # add one task into mapping |
---|
[441] | 417 | task = Task( name, trdid, x, y, lpid, stackname, heapname, startid ) |
---|
[319] | 418 | vspace.tasks.append( task ) |
---|
| 419 | task.index = self.total_tasks |
---|
| 420 | self.total_tasks += 1 |
---|
| 421 | |
---|
| 422 | return task |
---|
| 423 | |
---|
| 424 | ################################# |
---|
| 425 | def str2bytes( self, nbytes, s ): # string => nbytes_packed byte array |
---|
| 426 | |
---|
| 427 | byte_stream = bytearray() |
---|
| 428 | length = len( s ) |
---|
| 429 | if length < (nbytes - 1): |
---|
| 430 | for b in s: |
---|
| 431 | byte_stream.append( b ) |
---|
| 432 | for x in xrange(nbytes-length): |
---|
| 433 | byte_stream.append( '\0' ) |
---|
| 434 | else: |
---|
[512] | 435 | print '[genmap error] in str2bytes()' |
---|
| 436 | print ' string %s too long' % s |
---|
[319] | 437 | sys.exit(1) |
---|
| 438 | |
---|
| 439 | return byte_stream |
---|
| 440 | |
---|
| 441 | ################################### |
---|
[406] | 442 | def int2bytes( self, nbytes, val ): # integer => nbytes litle endian byte array |
---|
[319] | 443 | |
---|
| 444 | byte_stream = bytearray() |
---|
| 445 | for n in xrange( nbytes ): |
---|
| 446 | byte_stream.append( (val >> (n<<3)) & 0xFF ) |
---|
| 447 | |
---|
| 448 | return byte_stream |
---|
| 449 | |
---|
[512] | 450 | ################ |
---|
[411] | 451 | def xml( self ): # compute string for map.xml file generation |
---|
[319] | 452 | |
---|
[305] | 453 | s = '<?xml version="1.0"?>\n\n' |
---|
[319] | 454 | s += '<mapping_info signature = "0x%x"\n' % (self.signature) |
---|
[305] | 455 | s += ' name = "%s"\n' % (self.name) |
---|
| 456 | s += ' x_size = "%d"\n' % (self.x_size) |
---|
| 457 | s += ' y_size = "%d"\n' % (self.y_size) |
---|
| 458 | s += ' x_width = "%d"\n' % (self.x_width) |
---|
| 459 | s += ' y_width = "%d"\n' % (self.y_width) |
---|
| 460 | s += ' irq_per_proc = "%d"\n' % (self.irq_per_proc) |
---|
[319] | 461 | s += ' use_ramdisk = "%d"\n' % (self.use_ramdisk) |
---|
[305] | 462 | s += ' x_io = "%d"\n' % (self.x_io) |
---|
| 463 | s += ' y_io = "%d" >\n' % (self.y_io) |
---|
[319] | 464 | s += '\n' |
---|
| 465 | |
---|
[305] | 466 | s += ' <clusterset>\n' |
---|
| 467 | for x in xrange ( self.x_size ): |
---|
| 468 | for y in xrange ( self.y_size ): |
---|
[406] | 469 | cluster_id = (x * self.y_size) + y |
---|
[319] | 470 | s += self.clusters[cluster_id].xml() |
---|
[305] | 471 | s += ' </clusterset>\n' |
---|
[319] | 472 | s += '\n' |
---|
| 473 | |
---|
[305] | 474 | s += ' <globalset>\n' |
---|
[319] | 475 | for vseg in self.globs: s += vseg.xml() |
---|
[305] | 476 | s += ' </globalset>\n' |
---|
[319] | 477 | s += '\n' |
---|
| 478 | |
---|
[305] | 479 | s += ' <vspaceset>\n' |
---|
[319] | 480 | for vspace in self.vspaces: s += vspace.xml() |
---|
[305] | 481 | s += ' </vspaceset>\n' |
---|
[319] | 482 | |
---|
[305] | 483 | s += '</mapping_info>\n' |
---|
| 484 | return s |
---|
[319] | 485 | |
---|
[512] | 486 | ########################## |
---|
[411] | 487 | def cbin( self, verbose ): # C binary structure for map.bin file generation |
---|
[319] | 488 | |
---|
| 489 | byte_stream = bytearray() |
---|
| 490 | |
---|
| 491 | # header |
---|
| 492 | byte_stream += self.int2bytes(4, self.signature) |
---|
[406] | 493 | byte_stream += self.int2bytes(4, self.x_size) |
---|
| 494 | byte_stream += self.int2bytes(4, self.y_size) |
---|
| 495 | byte_stream += self.int2bytes(4, self.x_width) |
---|
| 496 | byte_stream += self.int2bytes(4, self.y_width) |
---|
| 497 | byte_stream += self.int2bytes(4, self.x_io) |
---|
| 498 | byte_stream += self.int2bytes(4, self.y_io) |
---|
| 499 | byte_stream += self.int2bytes(4, self.irq_per_proc) |
---|
| 500 | byte_stream += self.int2bytes(4, self.use_ramdisk) |
---|
| 501 | byte_stream += self.int2bytes(4, self.total_globals) |
---|
| 502 | byte_stream += self.int2bytes(4, self.total_vspaces) |
---|
| 503 | byte_stream += self.int2bytes(4, self.total_psegs) |
---|
| 504 | byte_stream += self.int2bytes(4, self.total_vsegs) |
---|
| 505 | byte_stream += self.int2bytes(4, self.total_tasks) |
---|
| 506 | byte_stream += self.int2bytes(4, self.total_procs) |
---|
| 507 | byte_stream += self.int2bytes(4, self.total_irqs) |
---|
| 508 | byte_stream += self.int2bytes(4, self.total_periphs) |
---|
[319] | 509 | byte_stream += self.str2bytes(32, self.name) |
---|
| 510 | |
---|
| 511 | if ( verbose ): |
---|
[406] | 512 | print '\n' |
---|
[319] | 513 | print 'name = %s' % self.name |
---|
| 514 | print 'signature = %x' % self.signature |
---|
| 515 | print 'x_size = %d' % self.x_size |
---|
| 516 | print 'y_size = %d' % self.y_size |
---|
| 517 | print 'x_width = %d' % self.x_width |
---|
| 518 | print 'y_width = %d' % self.y_width |
---|
[406] | 519 | print 'x_io = %d' % self.x_io |
---|
| 520 | print 'y_io = %d' % self.y_io |
---|
[319] | 521 | print 'irq_per_proc = %d' % self.irq_per_proc |
---|
| 522 | print 'use_ramdisk = %d' % self.use_ramdisk |
---|
| 523 | print 'total_globals = %d' % self.total_globals |
---|
[406] | 524 | print 'total_psegs = %d' % self.total_psegs |
---|
| 525 | print 'total_vsegs = %d' % self.total_vsegs |
---|
| 526 | print 'total_tasks = %d' % self.total_tasks |
---|
| 527 | print 'total_procs = %d' % self.total_procs |
---|
| 528 | print 'total_irqs = %d' % self.total_irqs |
---|
[319] | 529 | print 'total_periphs = %d' % self.total_periphs |
---|
[406] | 530 | print '\n' |
---|
[319] | 531 | |
---|
| 532 | # clusters array |
---|
| 533 | index = 0 |
---|
| 534 | for cluster in self.clusters: |
---|
| 535 | byte_stream += cluster.cbin( self, verbose, index ) |
---|
| 536 | index += 1 |
---|
| 537 | |
---|
| 538 | if ( verbose ): print '\n' |
---|
| 539 | |
---|
| 540 | # psegs array |
---|
| 541 | index = 0 |
---|
| 542 | for cluster in self.clusters: |
---|
[406] | 543 | for pseg in cluster.psegs: |
---|
[319] | 544 | byte_stream += pseg.cbin( self, verbose, index, cluster ) |
---|
| 545 | index += 1 |
---|
| 546 | |
---|
| 547 | if ( verbose ): print '\n' |
---|
| 548 | |
---|
| 549 | # vspaces array |
---|
| 550 | index = 0 |
---|
[406] | 551 | for vspace in self.vspaces: |
---|
| 552 | byte_stream += vspace.cbin( self, verbose, index ) |
---|
[319] | 553 | index += 1 |
---|
| 554 | |
---|
| 555 | if ( verbose ): print '\n' |
---|
| 556 | |
---|
| 557 | # vsegs array |
---|
| 558 | index = 0 |
---|
| 559 | for vseg in self.globs: |
---|
| 560 | byte_stream += vseg.cbin( self, verbose, index ) |
---|
| 561 | index += 1 |
---|
| 562 | for vspace in self.vspaces: |
---|
[406] | 563 | for vseg in vspace.vsegs: |
---|
[319] | 564 | byte_stream += vseg.cbin( self, verbose, index ) |
---|
| 565 | index += 1 |
---|
| 566 | |
---|
| 567 | if ( verbose ): print '\n' |
---|
| 568 | |
---|
| 569 | # tasks array |
---|
| 570 | index = 0 |
---|
| 571 | for vspace in self.vspaces: |
---|
[406] | 572 | for task in vspace.tasks: |
---|
[319] | 573 | byte_stream += task.cbin( self, verbose, index, vspace ) |
---|
| 574 | index += 1 |
---|
| 575 | |
---|
| 576 | if ( verbose ): print '\n' |
---|
| 577 | |
---|
| 578 | # procs array |
---|
| 579 | index = 0 |
---|
| 580 | for cluster in self.clusters: |
---|
[406] | 581 | for proc in cluster.procs: |
---|
[319] | 582 | byte_stream += proc.cbin( self, verbose, index ) |
---|
| 583 | index += 1 |
---|
[406] | 584 | |
---|
[319] | 585 | if ( verbose ): print '\n' |
---|
| 586 | |
---|
| 587 | # irqs array |
---|
[406] | 588 | index = 0 |
---|
[319] | 589 | for cluster in self.clusters: |
---|
| 590 | for periph in cluster.periphs: |
---|
| 591 | for irq in periph.irqs: |
---|
| 592 | byte_stream += irq.cbin( self, verbose, index ) |
---|
| 593 | index += 1 |
---|
| 594 | |
---|
| 595 | if ( verbose ): print '\n' |
---|
| 596 | |
---|
| 597 | # periphs array |
---|
| 598 | index = 0 |
---|
| 599 | for cluster in self.clusters: |
---|
[406] | 600 | for periph in cluster.periphs: |
---|
[319] | 601 | byte_stream += periph.cbin( self, verbose, index ) |
---|
| 602 | index += 1 |
---|
| 603 | |
---|
| 604 | return byte_stream |
---|
| 605 | # end of cbin() |
---|
[406] | 606 | |
---|
[411] | 607 | ################################################################################## |
---|
| 608 | def giet_vsegs( self ): # compute string for giet_vsegs.ld file generation |
---|
[319] | 609 | # required by giet_vm compilation |
---|
| 610 | |
---|
[406] | 611 | # search the vsegs required for the giet_vsegs.ld |
---|
[319] | 612 | boot_code_found = False |
---|
| 613 | boot_data_found = False |
---|
| 614 | kernel_uncdata_found = False |
---|
| 615 | kernel_data_found = False |
---|
| 616 | kernel_code_found = False |
---|
| 617 | kernel_init_found = False |
---|
| 618 | for vseg in self.globs: |
---|
[348] | 619 | |
---|
[319] | 620 | if ( vseg.name == 'seg_boot_code' ): |
---|
[406] | 621 | boot_code_vbase = vseg.vbase |
---|
[512] | 622 | boot_code_size = vseg.length |
---|
[319] | 623 | boot_code_found = True |
---|
| 624 | |
---|
[406] | 625 | if ( vseg.name == 'seg_boot_data' ): |
---|
| 626 | boot_data_vbase = vseg.vbase |
---|
[512] | 627 | boot_data_size = vseg.length |
---|
[319] | 628 | boot_data_found = True |
---|
| 629 | |
---|
| 630 | if ( vseg.name == 'seg_kernel_data' ): |
---|
[406] | 631 | kernel_data_vbase = vseg.vbase |
---|
[512] | 632 | kernel_data_size = vseg.length |
---|
[319] | 633 | kernel_data_found = True |
---|
| 634 | |
---|
| 635 | if ( vseg.name == 'seg_kernel_code' ): |
---|
[406] | 636 | kernel_code_vbase = vseg.vbase |
---|
[512] | 637 | kernel_code_size = vseg.length |
---|
[319] | 638 | kernel_code_found = True |
---|
| 639 | |
---|
| 640 | if ( vseg.name == 'seg_kernel_init' ): |
---|
[406] | 641 | kernel_init_vbase = vseg.vbase |
---|
[512] | 642 | kernel_init_size = vseg.length |
---|
[319] | 643 | kernel_init_found = True |
---|
| 644 | |
---|
| 645 | # check if all required vsegs have been found |
---|
[406] | 646 | if ( boot_code_found == False ): |
---|
[512] | 647 | print '[genmap error] in giet_vsegs()' |
---|
| 648 | print ' seg_boot_code vseg missing' |
---|
[319] | 649 | sys.exit() |
---|
| 650 | |
---|
[406] | 651 | if ( boot_data_found == False ): |
---|
[512] | 652 | print '[genmap error] in giet_vsegs()' |
---|
| 653 | print ' seg_boot_data vseg missing' |
---|
[319] | 654 | sys.exit() |
---|
| 655 | |
---|
[406] | 656 | if ( kernel_data_found == False ): |
---|
[512] | 657 | print '[genmap error] in giet_vsegs()' |
---|
| 658 | print ' seg_kernel_data vseg missing' |
---|
[319] | 659 | sys.exit() |
---|
| 660 | |
---|
| 661 | if ( kernel_code_found == False ): |
---|
[512] | 662 | print '[genmap error] in giet_vsegs()' |
---|
| 663 | print ' seg_kernel_code vseg missing' |
---|
[319] | 664 | sys.exit() |
---|
| 665 | |
---|
| 666 | if ( kernel_init_found == False ): |
---|
[512] | 667 | print '[genmap error] in giet_vsegs()' |
---|
| 668 | print ' seg_kernel_init vseg missing' |
---|
[319] | 669 | sys.exit() |
---|
| 670 | |
---|
| 671 | # build string |
---|
[406] | 672 | s = '/* Generated by genmap for %s */\n' % self.name |
---|
[319] | 673 | s += '\n' |
---|
| 674 | |
---|
[406] | 675 | s += 'boot_code_vbase = 0x%x;\n' % boot_code_vbase |
---|
| 676 | s += 'boot_code_size = 0x%x;\n' % boot_code_size |
---|
[319] | 677 | s += '\n' |
---|
[406] | 678 | s += 'boot_data_vbase = 0x%x;\n' % boot_data_vbase |
---|
| 679 | s += 'boot_data_size = 0x%x;\n' % boot_data_size |
---|
[319] | 680 | s += '\n' |
---|
[406] | 681 | s += 'kernel_code_vbase = 0x%x;\n' % kernel_code_vbase |
---|
| 682 | s += 'kernel_code_size = 0x%x;\n' % kernel_code_size |
---|
[319] | 683 | s += '\n' |
---|
[406] | 684 | s += 'kernel_data_vbase = 0x%x;\n' % kernel_data_vbase |
---|
| 685 | s += 'kernel_data_size = 0x%x;\n' % kernel_data_size |
---|
[319] | 686 | s += '\n' |
---|
[406] | 687 | s += 'kernel_init_vbase = 0x%x;\n' % kernel_init_vbase |
---|
| 688 | s += 'kernel_init_size = 0x%x;\n' % kernel_init_size |
---|
[319] | 689 | s += '\n' |
---|
| 690 | |
---|
| 691 | return s |
---|
[406] | 692 | |
---|
[411] | 693 | ################################################################################### |
---|
| 694 | def hard_config( self ): # compute string for hard_config.h file generation, |
---|
| 695 | # required by |
---|
[319] | 696 | # - top.cpp compilation |
---|
| 697 | # - giet_vm compilation |
---|
| 698 | # - tsar_preloader compilation |
---|
| 699 | |
---|
| 700 | nb_total_procs = 0 |
---|
| 701 | |
---|
| 702 | # for each peripheral type, define default values |
---|
[406] | 703 | # for pbase address, size, number of components, and channels |
---|
[319] | 704 | nb_cma = 0 |
---|
| 705 | cma_channels = 0 |
---|
| 706 | seg_cma_base = 0xFFFFFFFF |
---|
| 707 | seg_cma_size = 0 |
---|
| 708 | |
---|
| 709 | nb_dma = 0 |
---|
| 710 | dma_channels = 0 |
---|
| 711 | seg_dma_base = 0xFFFFFFFF |
---|
| 712 | seg_dma_size = 0 |
---|
| 713 | |
---|
| 714 | nb_fbf = 0 |
---|
| 715 | fbf_channels = 0 |
---|
| 716 | seg_fbf_base = 0xFFFFFFFF |
---|
| 717 | seg_fbf_size = 0 |
---|
[520] | 718 | fbf_arg0 = 0 |
---|
| 719 | fbf_arg1 = 0 |
---|
[319] | 720 | |
---|
| 721 | nb_iob = 0 |
---|
| 722 | iob_channels = 0 |
---|
| 723 | seg_iob_base = 0xFFFFFFFF |
---|
| 724 | seg_iob_size = 0 |
---|
| 725 | |
---|
| 726 | nb_ioc = 0 |
---|
| 727 | ioc_channels = 0 |
---|
| 728 | seg_ioc_base = 0xFFFFFFFF |
---|
| 729 | seg_ioc_size = 0 |
---|
| 730 | |
---|
| 731 | nb_mmc = 0 |
---|
| 732 | mmc_channels = 0 |
---|
| 733 | seg_mmc_base = 0xFFFFFFFF |
---|
| 734 | seg_mmc_size = 0 |
---|
| 735 | |
---|
| 736 | nb_mwr = 0 |
---|
| 737 | mwr_channels = 0 |
---|
| 738 | seg_mwr_base = 0xFFFFFFFF |
---|
| 739 | seg_mwr_size = 0 |
---|
[520] | 740 | mwr_arg0 = 0 |
---|
| 741 | mwr_arg1 = 0 |
---|
| 742 | mwr_arg2 = 0 |
---|
| 743 | mwr_arg3 = 0 |
---|
[319] | 744 | |
---|
| 745 | nb_nic = 0 |
---|
| 746 | nic_channels = 0 |
---|
| 747 | seg_nic_base = 0xFFFFFFFF |
---|
| 748 | seg_nic_size = 0 |
---|
| 749 | |
---|
| 750 | nb_pic = 0 |
---|
| 751 | pic_channels = 0 |
---|
| 752 | seg_pic_base = 0xFFFFFFFF |
---|
| 753 | seg_pic_size = 0 |
---|
| 754 | |
---|
| 755 | nb_rom = 0 |
---|
| 756 | rom_channels = 0 |
---|
| 757 | seg_rom_base = 0xFFFFFFFF |
---|
| 758 | seg_rom_size = 0 |
---|
| 759 | |
---|
| 760 | nb_sim = 0 |
---|
| 761 | sim_channels = 0 |
---|
| 762 | seg_sim_base = 0xFFFFFFFF |
---|
| 763 | seg_sim_size = 0 |
---|
| 764 | |
---|
| 765 | nb_tim = 0 |
---|
| 766 | tim_channels = 0 |
---|
| 767 | seg_tim_base = 0xFFFFFFFF |
---|
| 768 | seg_tim_size = 0 |
---|
| 769 | |
---|
| 770 | nb_tty = 0 |
---|
| 771 | tty_channels = 0 |
---|
| 772 | seg_tty_base = 0xFFFFFFFF |
---|
| 773 | seg_tty_size = 0 |
---|
| 774 | |
---|
| 775 | nb_xcu = 0 |
---|
| 776 | xcu_channels = 0 |
---|
| 777 | seg_xcu_base = 0xFFFFFFFF |
---|
| 778 | seg_xcu_size = 0 |
---|
[520] | 779 | xcu_arg0 = 0 |
---|
[319] | 780 | |
---|
[491] | 781 | nb_drom = 0 |
---|
| 782 | drom_channels = 0 |
---|
| 783 | seg_drom_base = 0xFFFFFFFF |
---|
| 784 | seg_drom_size = 0 |
---|
| 785 | |
---|
[319] | 786 | use_bdv = False |
---|
| 787 | use_spi = False |
---|
| 788 | use_hba = False |
---|
| 789 | |
---|
| 790 | # get peripherals attributes |
---|
| 791 | for cluster in self.clusters: |
---|
| 792 | for periph in cluster.periphs: |
---|
[406] | 793 | if ( periph.ptype == 'CMA' ): |
---|
[319] | 794 | seg_cma_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 795 | seg_cma_size = periph.pseg.size |
---|
| 796 | cma_channels = periph.channels |
---|
| 797 | nb_cma +=1 |
---|
| 798 | |
---|
[406] | 799 | elif ( periph.ptype == 'DMA' ): |
---|
| 800 | seg_dma_base = periph.pseg.base & 0xFFFFFFFF |
---|
[319] | 801 | seg_dma_size = periph.pseg.size |
---|
| 802 | dma_channels = periph.channels |
---|
| 803 | nb_dma +=1 |
---|
| 804 | |
---|
[406] | 805 | elif ( periph.ptype == 'FBF' ): |
---|
[319] | 806 | seg_fbf_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 807 | seg_fbf_size = periph.pseg.size |
---|
| 808 | fbf_channels = periph.channels |
---|
[520] | 809 | fbf_arg0 = periph.arg0 |
---|
| 810 | fbf_arg1 = periph.arg1 |
---|
[319] | 811 | nb_fbf +=1 |
---|
| 812 | |
---|
| 813 | elif ( periph.ptype == 'IOB' ): |
---|
| 814 | seg_iob_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 815 | seg_iob_size = periph.pseg.size |
---|
| 816 | iob_channels = periph.channels |
---|
| 817 | nb_iob +=1 |
---|
| 818 | |
---|
[406] | 819 | elif ( periph.ptype == 'IOC' ): |
---|
[319] | 820 | seg_ioc_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 821 | seg_ioc_size = periph.pseg.size |
---|
| 822 | ioc_channels = periph.channels |
---|
| 823 | nb_ioc += 1 |
---|
[404] | 824 | |
---|
| 825 | if self.use_ramdisk: continue |
---|
| 826 | |
---|
[319] | 827 | if ( periph.subtype == 'BDV' ): use_bdv = True |
---|
| 828 | elif ( periph.subtype == 'HBA' ): use_hba = True |
---|
| 829 | elif ( periph.subtype == 'SPI' ): use_spi = True |
---|
| 830 | |
---|
| 831 | elif ( periph.ptype == 'MMC' ): |
---|
| 832 | seg_mmc_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 833 | seg_mmc_size = periph.pseg.size |
---|
| 834 | mmc_channels = periph.channels |
---|
| 835 | nb_mmc +=1 |
---|
| 836 | |
---|
| 837 | elif ( periph.ptype == 'MWR' ): |
---|
| 838 | seg_mwr_base = periph.pseg.base & 0xFFFFFFFF |
---|
[520] | 839 | seg_mwr_size = periph.pseg.size |
---|
[319] | 840 | mwr_channels = periph.channels |
---|
[520] | 841 | mwr_arg0 = periph.arg0 |
---|
| 842 | mwr_arg1 = periph.arg1 |
---|
| 843 | mwr_arg2 = periph.arg2 |
---|
| 844 | mwr_arg3 = periph.arg3 |
---|
[319] | 845 | nb_mwr +=1 |
---|
| 846 | |
---|
| 847 | elif ( periph.ptype == 'ROM' ): |
---|
| 848 | seg_rom_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 849 | seg_rom_size = periph.pseg.size |
---|
| 850 | rom_channels = periph.channels |
---|
| 851 | nb_rom +=1 |
---|
| 852 | |
---|
[491] | 853 | elif ( periph.ptype == 'DROM' ): |
---|
| 854 | seg_drom_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 855 | seg_drom_size = periph.pseg.size |
---|
| 856 | drom_channels = periph.channels |
---|
| 857 | nb_drom +=1 |
---|
| 858 | |
---|
[319] | 859 | elif ( periph.ptype == 'SIM' ): |
---|
| 860 | seg_sim_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 861 | seg_sim_size = periph.pseg.size |
---|
| 862 | sim_channels = periph.channels |
---|
| 863 | nb_sim +=1 |
---|
| 864 | |
---|
[406] | 865 | elif ( periph.ptype == 'NIC' ): |
---|
[319] | 866 | seg_nic_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 867 | seg_nic_size = periph.pseg.size |
---|
| 868 | nic_channels = periph.channels |
---|
| 869 | nb_nic +=1 |
---|
| 870 | |
---|
[406] | 871 | elif ( periph.ptype == 'PIC' ): |
---|
[319] | 872 | seg_pic_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 873 | seg_pic_size = periph.pseg.size |
---|
| 874 | pic_channels = periph.channels |
---|
| 875 | nb_pic +=1 |
---|
[406] | 876 | |
---|
| 877 | elif ( periph.ptype == 'TIM' ): |
---|
[319] | 878 | seg_tim_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 879 | seg_tim_size = periph.pseg.size |
---|
| 880 | tim_channels = periph.channels |
---|
| 881 | nb_tim +=1 |
---|
[406] | 882 | |
---|
[319] | 883 | elif ( periph.ptype == 'TTY' ): |
---|
| 884 | seg_tty_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 885 | seg_tty_size = periph.pseg.size |
---|
| 886 | tty_channels = periph.channels |
---|
| 887 | nb_tty +=1 |
---|
[406] | 888 | |
---|
| 889 | elif ( periph.ptype == 'XCU' ): |
---|
[319] | 890 | seg_xcu_base = periph.pseg.base & 0xFFFFFFFF |
---|
| 891 | seg_xcu_size = periph.pseg.size |
---|
| 892 | xcu_channels = periph.channels |
---|
[520] | 893 | xcu_arg0 = periph.arg0 |
---|
[319] | 894 | nb_xcu +=1 |
---|
[406] | 895 | |
---|
[319] | 896 | # no more than two access to external peripherals |
---|
[406] | 897 | assert ( nb_fbf <= 2 ) |
---|
| 898 | assert ( nb_cma <= 2 ) |
---|
| 899 | assert ( nb_ioc <= 2 ) |
---|
| 900 | assert ( nb_nic <= 2 ) |
---|
| 901 | assert ( nb_tim <= 2 ) |
---|
| 902 | assert ( nb_tty <= 2 ) |
---|
[319] | 903 | assert ( nb_pic <= 2 ) |
---|
| 904 | |
---|
| 905 | # one and only one type of IOC controller |
---|
[403] | 906 | nb_iocs = 0 |
---|
| 907 | if use_hba : nb_iocs += 1 |
---|
| 908 | if use_bdv : nb_iocs += 1 |
---|
| 909 | if use_spi : nb_iocs += 1 |
---|
| 910 | if self.use_ramdisk: nb_iocs += 1 |
---|
| 911 | assert ( nb_iocs == 1 ) |
---|
[404] | 912 | |
---|
[319] | 913 | # Compute total number of processors |
---|
| 914 | for cluster in self.clusters: |
---|
| 915 | nb_total_procs += len( cluster.procs ) |
---|
| 916 | |
---|
| 917 | # Compute physical addresses for BOOT vsegs |
---|
| 918 | boot_mapping_found = False |
---|
| 919 | boot_code_found = False |
---|
| 920 | boot_data_found = False |
---|
| 921 | boot_stack_found = False |
---|
| 922 | |
---|
| 923 | for vseg in self.globs: |
---|
| 924 | if ( vseg.name == 'seg_boot_mapping' ): |
---|
[406] | 925 | boot_mapping_base = vseg.vbase |
---|
[512] | 926 | boot_mapping_size = vseg.length |
---|
[348] | 927 | boot_mapping_identity = vseg.identity |
---|
[319] | 928 | boot_mapping_found = True |
---|
| 929 | |
---|
| 930 | if ( vseg.name == 'seg_boot_code' ): |
---|
[406] | 931 | boot_code_base = vseg.vbase |
---|
[512] | 932 | boot_code_size = vseg.length |
---|
[348] | 933 | boot_code_identity = vseg.identity |
---|
[319] | 934 | boot_code_found = True |
---|
| 935 | |
---|
[406] | 936 | if ( vseg.name == 'seg_boot_data' ): |
---|
| 937 | boot_data_base = vseg.vbase |
---|
[512] | 938 | boot_data_size = vseg.length |
---|
[348] | 939 | boot_data_identity = vseg.identity |
---|
[319] | 940 | boot_data_found = True |
---|
| 941 | |
---|
| 942 | if ( vseg.name == 'seg_boot_stack' ): |
---|
[406] | 943 | boot_stack_base = vseg.vbase |
---|
[512] | 944 | boot_stack_size = vseg.length |
---|
[348] | 945 | boot_stack_identity = vseg.identity |
---|
[319] | 946 | boot_stack_found = True |
---|
| 947 | |
---|
[328] | 948 | # check that BOOT vsegs are found and identity mapping |
---|
[348] | 949 | if ( (boot_mapping_found == False) or (boot_mapping_identity == False) ): |
---|
[512] | 950 | print '[genmap error] in hard_config()' |
---|
| 951 | print ' seg_boot_mapping missing or not identity mapping' |
---|
[319] | 952 | sys.exit() |
---|
| 953 | |
---|
[406] | 954 | if ( (boot_code_found == False) or (boot_code_identity == False) ): |
---|
[512] | 955 | print '[genmap error] in hard_config()' |
---|
| 956 | print ' seg_boot_code missing or not identity mapping' |
---|
[319] | 957 | sys.exit() |
---|
| 958 | |
---|
[406] | 959 | if ( (boot_data_found == False) or (boot_data_identity == False) ): |
---|
[512] | 960 | print '[genmap error] in hard_config()' |
---|
| 961 | print ' seg_boot_data missing or not identity mapping' |
---|
[319] | 962 | sys.exit() |
---|
| 963 | |
---|
[348] | 964 | if ( (boot_stack_found == False) or (boot_stack_identity == False) ): |
---|
[512] | 965 | print '[genmap error] in giet_vsegs()' |
---|
| 966 | print ' seg_boot_stask missing or not identity mapping' |
---|
[319] | 967 | sys.exit() |
---|
| 968 | |
---|
| 969 | # Search RAMDISK global vseg if required |
---|
| 970 | seg_rdk_base = 0xFFFFFFFF |
---|
| 971 | seg_rdk_size = 0 |
---|
| 972 | seg_rdk_found = False |
---|
| 973 | |
---|
| 974 | if self.use_ramdisk: |
---|
| 975 | for vseg in self.globs: |
---|
[497] | 976 | if ( vseg.name == 'seg_ramdisk' ): |
---|
[319] | 977 | seg_rdk_base = vseg.vbase |
---|
[512] | 978 | seg_rdk_size = vseg.length |
---|
[319] | 979 | seg_rdk_found = True |
---|
| 980 | |
---|
| 981 | if ( seg_rdk_found == False ): |
---|
| 982 | print 'Error in hard_config() "seg_ramdisk" not found' |
---|
| 983 | sys.exit(1) |
---|
| 984 | |
---|
| 985 | # build string |
---|
[406] | 986 | s = '/* Generated by genmap for %s */\n' % self.name |
---|
[319] | 987 | s += '\n' |
---|
| 988 | s += '#ifndef HARD_CONFIG_H\n' |
---|
| 989 | s += '#define HARD_CONFIG_H\n' |
---|
| 990 | s += '\n' |
---|
| 991 | |
---|
[406] | 992 | s += '/* General platform parameters */\n' |
---|
[319] | 993 | s += '\n' |
---|
| 994 | s += '#define X_SIZE %d\n' % self.x_size |
---|
| 995 | s += '#define Y_SIZE %d\n' % self.y_size |
---|
| 996 | s += '#define X_WIDTH %d\n' % self.x_width |
---|
| 997 | s += '#define Y_WIDTH %d\n' % self.y_width |
---|
[406] | 998 | s += '#define P_WIDTH %d\n' % self.p_width |
---|
[319] | 999 | s += '#define X_IO %d\n' % self.x_io |
---|
[406] | 1000 | s += '#define Y_IO %d\n' % self.y_io |
---|
[411] | 1001 | s += '#define NB_PROCS_MAX %d\n' % self.nprocs |
---|
[319] | 1002 | s += '#define IRQ_PER_PROCESSOR %d\n' % self.irq_per_proc |
---|
| 1003 | s += '#define RESET_ADDRESS 0x%x\n' % self.reset_address |
---|
| 1004 | s += '#define NB_TOTAL_PROCS %d\n' % nb_total_procs |
---|
| 1005 | s += '\n' |
---|
| 1006 | |
---|
[406] | 1007 | s += '/* Peripherals */\n' |
---|
[319] | 1008 | s += '\n' |
---|
| 1009 | s += '#define NB_TTY_CHANNELS %d\n' % tty_channels |
---|
| 1010 | s += '#define NB_IOC_CHANNELS %d\n' % ioc_channels |
---|
| 1011 | s += '#define NB_NIC_CHANNELS %d\n' % nic_channels |
---|
| 1012 | s += '#define NB_CMA_CHANNELS %d\n' % cma_channels |
---|
| 1013 | s += '#define NB_TIM_CHANNELS %d\n' % tim_channels |
---|
| 1014 | s += '#define NB_DMA_CHANNELS %d\n' % dma_channels |
---|
| 1015 | s += '\n' |
---|
| 1016 | s += '#define USE_XCU %d\n' % ( nb_xcu != 0 ) |
---|
| 1017 | s += '#define USE_IOB %d\n' % ( nb_iob != 0 ) |
---|
| 1018 | s += '#define USE_PIC %d\n' % ( nb_pic != 0 ) |
---|
| 1019 | s += '#define USE_FBF %d\n' % ( nb_fbf != 0 ) |
---|
| 1020 | s += '\n' |
---|
| 1021 | s += '#define USE_IOC_BDV %d\n' % use_bdv |
---|
| 1022 | s += '#define USE_IOC_SPI %d\n' % use_spi |
---|
| 1023 | s += '#define USE_IOC_HBA %d\n' % use_hba |
---|
[403] | 1024 | s += '#define USE_IOC_RDK %d\n' % self.use_ramdisk |
---|
[319] | 1025 | s += '\n' |
---|
[520] | 1026 | s += '#define FBUF_X_SIZE %d\n' % fbf_arg0 |
---|
| 1027 | s += '#define FBUF_Y_SIZE %d\n' % fbf_arg1 |
---|
[328] | 1028 | s += '\n' |
---|
[520] | 1029 | s += '#define XCU_NB_INPUTS %d\n' % xcu_arg0 |
---|
[328] | 1030 | s += '\n' |
---|
[520] | 1031 | s += '#define MWR_TO_COPROC %d\n' % mwr_arg0 |
---|
| 1032 | s += '#define MWR_FROM_COPROC %d\n' % mwr_arg1 |
---|
| 1033 | s += '#define MWR_CONFIG %d\n' % mwr_arg2 |
---|
| 1034 | s += '#define MWR_STATUS %d\n' % mwr_arg3 |
---|
| 1035 | s += '\n' |
---|
[319] | 1036 | |
---|
[356] | 1037 | s += '/* base addresses and sizes for physical segments */\n' |
---|
[319] | 1038 | s += '\n' |
---|
[406] | 1039 | s += '#define SEG_RAM_BASE 0x%x\n' % self.ram_base |
---|
| 1040 | s += '#define SEG_RAM_SIZE 0x%x\n' % self.ram_size |
---|
[356] | 1041 | s += '\n' |
---|
[406] | 1042 | s += '#define SEG_CMA_BASE 0x%x\n' % seg_cma_base |
---|
| 1043 | s += '#define SEG_CMA_SIZE 0x%x\n' % seg_cma_size |
---|
[319] | 1044 | s += '\n' |
---|
[406] | 1045 | s += '#define SEG_DMA_BASE 0x%x\n' % seg_dma_base |
---|
| 1046 | s += '#define SEG_DMA_SIZE 0x%x\n' % seg_dma_size |
---|
[319] | 1047 | s += '\n' |
---|
[406] | 1048 | s += '#define SEG_FBF_BASE 0x%x\n' % seg_fbf_base |
---|
| 1049 | s += '#define SEG_FBF_SIZE 0x%x\n' % seg_fbf_size |
---|
[319] | 1050 | s += '\n' |
---|
[406] | 1051 | s += '#define SEG_IOB_BASE 0x%x\n' % seg_iob_base |
---|
| 1052 | s += '#define SEG_IOB_SIZE 0x%x\n' % seg_iob_size |
---|
[319] | 1053 | s += '\n' |
---|
[406] | 1054 | s += '#define SEG_IOC_BASE 0x%x\n' % seg_ioc_base |
---|
| 1055 | s += '#define SEG_IOC_SIZE 0x%x\n' % seg_ioc_size |
---|
[319] | 1056 | s += '\n' |
---|
[406] | 1057 | s += '#define SEG_MMC_BASE 0x%x\n' % seg_mmc_base |
---|
| 1058 | s += '#define SEG_MMC_SIZE 0x%x\n' % seg_mmc_size |
---|
[319] | 1059 | s += '\n' |
---|
[406] | 1060 | s += '#define SEG_MWR_BASE 0x%x\n' % seg_mwr_base |
---|
| 1061 | s += '#define SEG_MWR_SIZE 0x%x\n' % seg_mwr_size |
---|
[319] | 1062 | s += '\n' |
---|
[406] | 1063 | s += '#define SEG_ROM_BASE 0x%x\n' % seg_rom_base |
---|
| 1064 | s += '#define SEG_ROM_SIZE 0x%x\n' % seg_rom_size |
---|
[319] | 1065 | s += '\n' |
---|
[406] | 1066 | s += '#define SEG_SIM_BASE 0x%x\n' % seg_sim_base |
---|
| 1067 | s += '#define SEG_SIM_SIZE 0x%x\n' % seg_sim_size |
---|
[319] | 1068 | s += '\n' |
---|
[406] | 1069 | s += '#define SEG_NIC_BASE 0x%x\n' % seg_nic_base |
---|
| 1070 | s += '#define SEG_NIC_SIZE 0x%x\n' % seg_nic_size |
---|
[319] | 1071 | s += '\n' |
---|
[406] | 1072 | s += '#define SEG_PIC_BASE 0x%x\n' % seg_pic_base |
---|
| 1073 | s += '#define SEG_PIC_SIZE 0x%x\n' % seg_pic_size |
---|
[319] | 1074 | s += '\n' |
---|
[406] | 1075 | s += '#define SEG_TIM_BASE 0x%x\n' % seg_tim_base |
---|
| 1076 | s += '#define SEG_TIM_SIZE 0x%x\n' % seg_tim_size |
---|
[319] | 1077 | s += '\n' |
---|
[406] | 1078 | s += '#define SEG_TTY_BASE 0x%x\n' % seg_tty_base |
---|
| 1079 | s += '#define SEG_TTY_SIZE 0x%x\n' % seg_tty_size |
---|
[319] | 1080 | s += '\n' |
---|
[406] | 1081 | s += '#define SEG_XCU_BASE 0x%x\n' % seg_xcu_base |
---|
| 1082 | s += '#define SEG_XCU_SIZE 0x%x\n' % seg_xcu_size |
---|
[319] | 1083 | s += '\n' |
---|
| 1084 | s += '#define SEG_RDK_BASE 0x%x\n' % seg_rdk_base |
---|
| 1085 | s += '#define SEG_RDK_SIZE 0x%x\n' % seg_rdk_size |
---|
| 1086 | s += '\n' |
---|
[491] | 1087 | s += '#define SEG_DROM_BASE 0x%x\n' % seg_drom_base |
---|
| 1088 | s += '#define SEG_DROM_SIZE 0x%x\n' % seg_drom_size |
---|
| 1089 | s += '\n' |
---|
[328] | 1090 | s += '#define PERI_CLUSTER_INCREMENT 0x%x\n' % self.peri_increment |
---|
[319] | 1091 | s += '\n' |
---|
| 1092 | |
---|
[326] | 1093 | s += '/* physical base addresses for identity mapped vsegs */\n' |
---|
| 1094 | s += '/* used by the GietVM OS */\n' |
---|
[319] | 1095 | s += '\n' |
---|
| 1096 | s += '#define SEG_BOOT_MAPPING_BASE 0x%x\n' % boot_mapping_base |
---|
| 1097 | s += '#define SEG_BOOT_MAPPING_SIZE 0x%x\n' % boot_mapping_size |
---|
| 1098 | s += '\n' |
---|
| 1099 | s += '#define SEG_BOOT_CODE_BASE 0x%x\n' % boot_code_base |
---|
| 1100 | s += '#define SEG_BOOT_CODE_SIZE 0x%x\n' % boot_code_size |
---|
| 1101 | s += '\n' |
---|
| 1102 | s += '#define SEG_BOOT_DATA_BASE 0x%x\n' % boot_data_base |
---|
| 1103 | s += '#define SEG_BOOT_DATA_SIZE 0x%x\n' % boot_data_size |
---|
| 1104 | s += '\n' |
---|
| 1105 | s += '#define SEG_BOOT_STACK_BASE 0x%x\n' % boot_stack_base |
---|
| 1106 | s += '#define SEG_BOOT_STACK_SIZE 0x%x\n' % boot_stack_size |
---|
| 1107 | s += '#endif\n' |
---|
[406] | 1108 | |
---|
[319] | 1109 | return s |
---|
| 1110 | |
---|
| 1111 | # end of hard_config() |
---|
| 1112 | |
---|
[411] | 1113 | ################################################################################ |
---|
| 1114 | def linux_dts( self ): # compute string for linux.dts file generation |
---|
[424] | 1115 | # used for linux configuration |
---|
[411] | 1116 | # header |
---|
| 1117 | s = '/dts-v1/;\n' |
---|
| 1118 | s += '\n' |
---|
| 1119 | s += '/{\n' |
---|
[421] | 1120 | s += ' compatible = "tsar,%s";\n' % self.name |
---|
[411] | 1121 | s += ' #address-cells = <2>;\n' # physical address on 64 bits |
---|
| 1122 | s += ' #size-cells = <1>;\n' # segment size on 32 bits |
---|
| 1123 | s += ' model = "%s";\n' % self.name |
---|
| 1124 | s += '\n' |
---|
| 1125 | |
---|
| 1126 | # linux globals arguments |
---|
| 1127 | s += ' chosen {\n' |
---|
| 1128 | s += ' linux,stdout-path = &tty;\n' |
---|
| 1129 | s += ' bootargs = "console=tty0 console=ttyVTTY0 earlyprintk";\n' |
---|
[424] | 1130 | s += ' };\n\n' |
---|
[411] | 1131 | |
---|
| 1132 | # cpus (for each cluster) |
---|
| 1133 | s += ' cpus {\n' |
---|
| 1134 | s += ' #address-cells = <1>;\n' |
---|
| 1135 | s += ' #size-cells = <0>;\n' |
---|
| 1136 | |
---|
| 1137 | for cluster in self.clusters: |
---|
| 1138 | for proc in cluster.procs: |
---|
| 1139 | x = cluster.x |
---|
| 1140 | y = cluster.y |
---|
| 1141 | l = proc.lpid |
---|
[421] | 1142 | proc_id = (((x << self.y_width) + y) << self.p_width) + l |
---|
[411] | 1143 | s += ' cpu@%d_%d_%d {\n' %(x,y,l) |
---|
| 1144 | s += ' device_type = "cpu";\n' |
---|
| 1145 | s += ' compatible = "soclib,mips32el";\n' |
---|
| 1146 | s += ' reg = <0x%x>;\n' % proc_id |
---|
| 1147 | s += ' };\n' |
---|
| 1148 | s += '\n' |
---|
| 1149 | |
---|
| 1150 | s += ' };\n\n' |
---|
| 1151 | |
---|
| 1152 | # devices (ram or peripheral) are grouped per cluster |
---|
[424] | 1153 | # the "compatible" attribute links a peripheral device |
---|
[411] | 1154 | # to one or several drivers identified by ("major","minor") |
---|
| 1155 | |
---|
| 1156 | for cluster in self.clusters: |
---|
| 1157 | x = cluster.x |
---|
| 1158 | y = cluster.y |
---|
| 1159 | found_xcu = False |
---|
| 1160 | found_pic = False |
---|
| 1161 | |
---|
| 1162 | s += ' /*** cluster[%d,%d] ***/\n\n' % (x,y) |
---|
| 1163 | |
---|
| 1164 | # scan all psegs to find RAM in current cluster |
---|
| 1165 | for pseg in cluster.psegs: |
---|
| 1166 | if ( pseg.segtype == 'RAM' ): |
---|
| 1167 | msb = pseg.base >> 32 |
---|
| 1168 | lsb = pseg.base & 0xFFFFFFFF |
---|
| 1169 | size = pseg.size |
---|
| 1170 | |
---|
[424] | 1171 | s += ' ram_%d_%d: ram@0x%x {\n' % (x, y, pseg.base) |
---|
[411] | 1172 | s += ' device_type = "memory";\n' |
---|
| 1173 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1174 | s += ' };\n\n' |
---|
| 1175 | |
---|
| 1176 | # scan all periphs to find XCU or PIC in current cluster |
---|
| 1177 | for periph in cluster.periphs: |
---|
| 1178 | msb = periph.pseg.base >> 32 |
---|
| 1179 | lsb = periph.pseg.base & 0xFFFFFFFF |
---|
| 1180 | size = periph.pseg.size |
---|
| 1181 | |
---|
| 1182 | # search XCU (can be replicated) |
---|
[424] | 1183 | if ( (periph.ptype == 'XCU') ): |
---|
[411] | 1184 | found_xcu = True |
---|
| 1185 | xcu = periph |
---|
[424] | 1186 | irq_ctrl_name = 'xcu_%d_%d' % (x, y) |
---|
[411] | 1187 | |
---|
[424] | 1188 | s += ' %s: xcu@0x%x {\n' % (irq_ctrl_name, periph.pseg.base) |
---|
[421] | 1189 | s += ' compatible = "soclib,vci_xicu","soclib,vci_xicu_timer";\n' |
---|
[411] | 1190 | s += ' interrupt-controller;\n' |
---|
| 1191 | s += ' #interrupt-cells = <1>;\n' |
---|
[512] | 1192 | s += ' clocks = <&freq>;\n' # XCU contains a timer |
---|
[424] | 1193 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[411] | 1194 | s += ' };\n\n' |
---|
| 1195 | |
---|
| 1196 | # search PIC (non replicated) |
---|
[424] | 1197 | if ( periph.ptype == 'PIC' ): |
---|
[411] | 1198 | found_pic = True |
---|
| 1199 | pic = periph |
---|
| 1200 | irq_ctrl_name = 'pic' |
---|
| 1201 | |
---|
[424] | 1202 | s += ' %s: pic@0x%x {\n' % (irq_ctrl_name, periph.pseg.base) |
---|
[421] | 1203 | s += ' compatible = "soclib,vci_iopic";\n' |
---|
[411] | 1204 | s += ' interrupt-controller;\n' |
---|
| 1205 | s += ' #interrupt-cells = <1>;\n' |
---|
| 1206 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1207 | s += ' };\n\n' |
---|
| 1208 | |
---|
| 1209 | # we need one interrupt controler in any cluster containing peripherals |
---|
[512] | 1210 | if ( (found_xcu == False) and |
---|
| 1211 | (found_pic == False) and |
---|
| 1212 | (len(cluster.periphs) > 0) ): |
---|
| 1213 | print '[genmap error] in linux_dts()' |
---|
| 1214 | print ' No XCU/PIC in cluster(%d,%d)' % (x,y) |
---|
[424] | 1215 | sys.exit(1) |
---|
[411] | 1216 | |
---|
| 1217 | if ( found_pic == True ): irq_ctrl = pic |
---|
| 1218 | else: irq_ctrl = xcu |
---|
[424] | 1219 | |
---|
[411] | 1220 | # scan all periphs to find TTY and IOC in current cluster |
---|
| 1221 | for periph in cluster.periphs: |
---|
| 1222 | msb = periph.pseg.base >> 32 |
---|
| 1223 | lsb = periph.pseg.base & 0xFFFFFFFF |
---|
| 1224 | size = periph.pseg.size |
---|
| 1225 | |
---|
| 1226 | # search TTY (non replicated) |
---|
[424] | 1227 | if ( periph.ptype == 'TTY' ): |
---|
[411] | 1228 | |
---|
| 1229 | # get HWI index to XCU or PIC (only TTY channel 0 is used by Linux) |
---|
| 1230 | hwi_id = 0xFFFFFFFF |
---|
| 1231 | for irq in irq_ctrl.irqs: |
---|
[512] | 1232 | if ( (irq.isrtype == 'ISR_TTY_RX') and (irq.channel == 0) ): |
---|
| 1233 | hwi_id = irq.srcid |
---|
| 1234 | |
---|
[411] | 1235 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1236 | print '[genmap error] in linux.dts()' |
---|
| 1237 | print ' IRQ_TTY_RX not found' |
---|
[411] | 1238 | sys.exit(1) |
---|
| 1239 | |
---|
| 1240 | s += ' tty: tty {\n' |
---|
[421] | 1241 | s += ' compatible = "soclib,vci_multi_tty";\n' |
---|
[411] | 1242 | s += ' interrupt-parent = <&%s>;\n' % (irq_ctrl_name) |
---|
[424] | 1243 | s += ' interrupts = <%d>;\n' % hwi_id |
---|
[411] | 1244 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1245 | s += ' };\n\n' |
---|
| 1246 | |
---|
| 1247 | # search IOC (non replicated) |
---|
[424] | 1248 | elif ( periph.ptype == 'IOC' ): |
---|
[411] | 1249 | |
---|
| 1250 | if ( periph.subtype == 'BDV' ): |
---|
| 1251 | |
---|
| 1252 | # get irq line index associated to bdv |
---|
| 1253 | hwi_id = 0xFFFFFFFF |
---|
| 1254 | for irq in irq_ctrl.irqs: |
---|
| 1255 | if ( irq.isrtype == 'ISR_BDV' ): hwi_id = irq.srcid |
---|
[512] | 1256 | |
---|
[411] | 1257 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1258 | print '[genmap error] in linux.dts()' |
---|
| 1259 | print ' ISR_BDV not found' |
---|
[411] | 1260 | sys.exit(1) |
---|
| 1261 | |
---|
| 1262 | s += ' bdv: bdv {\n' |
---|
[517] | 1263 | s += ' compatible = "tsar,vci_block_device";\n' |
---|
[411] | 1264 | s += ' interrupt-parent = <&%s>;\n' % (irq_ctrl_name) |
---|
[424] | 1265 | s += ' interrupts = <%d>;\n' % hwi_id |
---|
[411] | 1266 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1267 | s += ' };\n\n' |
---|
| 1268 | |
---|
| 1269 | elif ( periph.subtype == 'HBA' ): |
---|
| 1270 | |
---|
[512] | 1271 | print '[genmap error] in linux_dts()' |
---|
| 1272 | print ' HBA peripheral not supported by LINUX' |
---|
[411] | 1273 | sys.exit(1) |
---|
| 1274 | |
---|
| 1275 | elif ( periph.subtype == 'SPI' ): |
---|
| 1276 | |
---|
[512] | 1277 | print '[genmap error] in linux_dts()' |
---|
| 1278 | print ' SPI peripheral not supported by LINUX' |
---|
[411] | 1279 | sys.exit(1) |
---|
| 1280 | |
---|
[465] | 1281 | # XCU or PIC have been already parsed |
---|
| 1282 | elif ( periph.ptype == 'XCU' ) or ( periph.ptype == 'PIC' ): |
---|
| 1283 | pass |
---|
| 1284 | |
---|
[411] | 1285 | # other peripherals |
---|
[424] | 1286 | else: |
---|
[512] | 1287 | print '[genmap warning] in linux_dts()' |
---|
| 1288 | print ' %s peripheral not supported by LINUX' % (periph.ptype) |
---|
[424] | 1289 | |
---|
| 1290 | # clocks |
---|
[411] | 1291 | s += ' /*** clocks ***/\n\n' |
---|
| 1292 | s += ' clocks {\n' |
---|
[424] | 1293 | s += ' freq: freq@50MHZ {\n' |
---|
[411] | 1294 | s += ' #clock-cells = <0>;\n' |
---|
| 1295 | s += ' compatible = "fixed-clock";\n' |
---|
| 1296 | s += ' clock-frequency = <50000000>;\n' |
---|
| 1297 | s += ' };\n' |
---|
| 1298 | s += ' };\n\n' |
---|
| 1299 | s += ' cpuclk {\n' |
---|
[421] | 1300 | s += ' compatible = "soclib,mips32_clksrc";\n' |
---|
[424] | 1301 | s += ' clocks = <&freq>;\n' |
---|
[411] | 1302 | s += ' };\n' |
---|
| 1303 | s += '};\n' |
---|
| 1304 | |
---|
| 1305 | return s |
---|
| 1306 | # end linux_dts() |
---|
| 1307 | |
---|
| 1308 | |
---|
| 1309 | ############################################################################# |
---|
[319] | 1310 | def netbsd_dts( self ): # compute string for netbsd.dts file generation, |
---|
[406] | 1311 | # used for netbsd configuration |
---|
[319] | 1312 | # header |
---|
| 1313 | s = '/dts-v1/;\n' |
---|
| 1314 | s += '\n' |
---|
| 1315 | s += '/{\n' |
---|
[406] | 1316 | s += ' #address-cells = <2>;\n' |
---|
| 1317 | s += ' #size-cells = <1>;\n' |
---|
[319] | 1318 | |
---|
| 1319 | # cpus (for each cluster) |
---|
| 1320 | s += ' cpus {\n' |
---|
| 1321 | s += ' #address-cells = <1>;\n' |
---|
| 1322 | s += ' #size-cells = <0>;\n' |
---|
| 1323 | |
---|
| 1324 | for cluster in self.clusters: |
---|
| 1325 | for proc in cluster.procs: |
---|
[406] | 1326 | proc_id = (((cluster.x << self.y_width) + cluster.y) << self.p_width) + proc.lpid |
---|
[319] | 1327 | |
---|
| 1328 | s += ' Mips,32@0x%x {\n' % proc_id |
---|
| 1329 | s += ' device_type = "cpu";\n' |
---|
| 1330 | s += ' icudev_type = "cpu:mips";\n' |
---|
| 1331 | s += ' name = "Mips,32";\n' |
---|
| 1332 | s += ' reg = <0x%x>;\n' % proc_id |
---|
| 1333 | s += ' };\n' |
---|
| 1334 | s += '\n' |
---|
| 1335 | |
---|
| 1336 | s += ' };\n' |
---|
| 1337 | |
---|
[411] | 1338 | # physical memory banks (for each cluster) |
---|
[319] | 1339 | for cluster in self.clusters: |
---|
| 1340 | for pseg in cluster.psegs: |
---|
| 1341 | |
---|
| 1342 | if ( pseg.segtype == 'RAM' ): |
---|
| 1343 | msb = pseg.base >> 32 |
---|
| 1344 | lsb = pseg.base & 0xFFFFFFFF |
---|
| 1345 | size = pseg.size |
---|
| 1346 | |
---|
| 1347 | s += ' %s@0x%x {\n' % (pseg.name, pseg.base) |
---|
| 1348 | s += ' cached = <1>;\n' |
---|
| 1349 | s += ' device_type = "memory";\n' |
---|
| 1350 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1351 | s += ' };\n' |
---|
| 1352 | |
---|
| 1353 | # peripherals (for each cluster) |
---|
| 1354 | for cluster in self.clusters: |
---|
[411] | 1355 | x = cluster.x |
---|
| 1356 | y = cluster.y |
---|
[319] | 1357 | |
---|
[406] | 1358 | # research XCU component |
---|
[319] | 1359 | found_xcu = False |
---|
| 1360 | for periph in cluster.periphs: |
---|
[406] | 1361 | if ( (periph.ptype == 'XCU') ): |
---|
[319] | 1362 | found_xcu = True |
---|
| 1363 | xcu = periph |
---|
| 1364 | msb = periph.pseg.base >> 32 |
---|
| 1365 | lsb = periph.pseg.base & 0xFFFFFFFF |
---|
| 1366 | size = periph.pseg.size |
---|
| 1367 | |
---|
| 1368 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1369 | s += ' device_type = "soclib:xicu:root";\n' |
---|
| 1370 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[400] | 1371 | s += ' input_lines = <%d>;\n' % periph.arg |
---|
| 1372 | s += ' ipis = <%d>;\n' % periph.arg |
---|
| 1373 | s += ' timers = <%d>;\n' % periph.arg |
---|
[319] | 1374 | |
---|
| 1375 | output_id = 0 # output index from XCU |
---|
| 1376 | for lpid in xrange ( len(cluster.procs) ): # destination processor index |
---|
| 1377 | for itid in xrange ( self.irq_per_proc ): # input irq index on processor |
---|
[406] | 1378 | cluster_xy = (cluster.x << self.y_width) + cluster.y |
---|
| 1379 | proc_id = (cluster_xy << self.p_width) + lpid |
---|
[319] | 1380 | s += ' out@%d {\n' % output_id |
---|
| 1381 | s += ' device_type = "soclib:xicu:filter";\n' |
---|
[411] | 1382 | s += ' irq = <&{/cpus/Mips,32@0x%x} %d>;\n' % (proc_id, itid) |
---|
[406] | 1383 | s += ' output_line = <%d>;\n' % output_id |
---|
[411] | 1384 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1385 | s += ' };\n' |
---|
| 1386 | |
---|
| 1387 | output_id += 1 |
---|
| 1388 | |
---|
| 1389 | s += ' };\n' |
---|
| 1390 | |
---|
| 1391 | # research PIC component |
---|
| 1392 | found_pic = False |
---|
| 1393 | for periph in cluster.periphs: |
---|
[406] | 1394 | if ( periph.ptype == 'PIC' ): |
---|
[319] | 1395 | found_pic = True |
---|
| 1396 | pic = periph |
---|
| 1397 | msb = periph.pseg.base >> 32 |
---|
| 1398 | lsb = periph.pseg.base & 0xFFFFFFFF |
---|
| 1399 | size = periph.pseg.size |
---|
| 1400 | |
---|
| 1401 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1402 | s += ' device_type = "soclib:pic:root";\n' |
---|
| 1403 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[406] | 1404 | s += ' input_lines = <%d>;\n' % periph.channels |
---|
[319] | 1405 | s += ' };\n' |
---|
| 1406 | |
---|
[411] | 1407 | # at least one interrupt controller |
---|
[319] | 1408 | if ( (found_xcu == False) and (found_pic == False) and (len(cluster.periphs) > 0) ): |
---|
[512] | 1409 | print '[genmap error] in netbsd_dts()' |
---|
| 1410 | print ' No XCU/PIC in cluster(%d,%d)' % (x,y) |
---|
[406] | 1411 | sys.exit(1) |
---|
| 1412 | |
---|
[319] | 1413 | if ( found_pic == True ): irq_tgt = pic |
---|
| 1414 | else: irq_tgt = xcu |
---|
[406] | 1415 | |
---|
[319] | 1416 | # get all others peripherals in cluster |
---|
| 1417 | for periph in cluster.periphs: |
---|
| 1418 | msb = periph.pseg.base >> 32 |
---|
| 1419 | lsb = periph.pseg.base & 0xFFFFFFFF |
---|
| 1420 | size = periph.pseg.size |
---|
| 1421 | |
---|
| 1422 | # research DMA component |
---|
| 1423 | if ( periph.ptype == 'DMA' ): |
---|
| 1424 | |
---|
| 1425 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
[411] | 1426 | s += ' device_type = "soclib:dma";\n' |
---|
| 1427 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[319] | 1428 | s += ' channel_count = <%d>;\n' % periph.channels |
---|
| 1429 | |
---|
| 1430 | # multi-channels : get HWI index (to XCU) for each channel |
---|
| 1431 | for channel in xrange( periph.channels ): |
---|
| 1432 | hwi_id = 0xFFFFFFFF |
---|
| 1433 | for irq in xcu.irqs: |
---|
[406] | 1434 | if ( (irq.isrtype == 'ISR_DMA') and (irq.channel == channel) ): |
---|
[319] | 1435 | hwi_id = irq.srcid |
---|
[512] | 1436 | |
---|
[319] | 1437 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1438 | print '[genmap error] in netbsd.dts()' |
---|
| 1439 | print ' ISR_DMA channel %d not found' % channel |
---|
[319] | 1440 | sys.exit(1) |
---|
| 1441 | |
---|
| 1442 | name = '%s@0x%x' % (xcu.pseg.name, xcu.pseg.base) |
---|
| 1443 | s += ' irq@%d{\n' % channel |
---|
| 1444 | s += ' device_type = "soclib:periph:irq";\n' |
---|
| 1445 | s += ' output_line = <%d>;\n' % channel |
---|
[411] | 1446 | s += ' irq = <&{/%s} %d>;\n' % (name, hwi_id) |
---|
| 1447 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1448 | s += ' };\n' |
---|
| 1449 | |
---|
[406] | 1450 | s += ' };\n' |
---|
[319] | 1451 | |
---|
| 1452 | # research MMC component |
---|
| 1453 | elif ( periph.ptype == 'MMC' ): |
---|
| 1454 | |
---|
| 1455 | # get irq line index associated to MMC in XCU |
---|
| 1456 | irq_in = 0xFFFFFFFF |
---|
| 1457 | for irq in xcu.irqs: |
---|
| 1458 | if ( irq.isrtype == 'ISR_MMC' ): irq_in = irq.srcid |
---|
[512] | 1459 | |
---|
[319] | 1460 | if ( irq_in == 0xFFFFFFFF ): |
---|
[512] | 1461 | print '[genmap error] in netbsd.dts()' |
---|
| 1462 | print ' ISR_MMC not found' |
---|
[319] | 1463 | sys.exit(1) |
---|
| 1464 | |
---|
| 1465 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1466 | s += ' device_type = "soclib:mmc";\n' |
---|
[411] | 1467 | s += ' irq = <&{/%s@0x%x} %d>;\n' % (irq_tgt.pseg.name, irq_tgt.pseg.base, irq_in) |
---|
| 1468 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[406] | 1469 | s += ' };\n' |
---|
[319] | 1470 | |
---|
| 1471 | # research FBF component |
---|
[406] | 1472 | elif ( periph.ptype == 'FBF' ): |
---|
[319] | 1473 | |
---|
[411] | 1474 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1475 | s += ' device_type = "soclib:framebuffer";\n' |
---|
| 1476 | s += ' mode = <32>;\n' # bits par pixel |
---|
[400] | 1477 | s += ' width = <%d>;\n' % periph.arg |
---|
| 1478 | s += ' height = <%d>;\n' % periph.arg |
---|
[319] | 1479 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1480 | s += ' };\n' |
---|
| 1481 | |
---|
| 1482 | # research IOC component |
---|
[406] | 1483 | elif ( periph.ptype == 'IOC' ): |
---|
[319] | 1484 | |
---|
| 1485 | if ( periph.subtype == 'BDV' ): |
---|
| 1486 | |
---|
| 1487 | # get irq line index associated to bdv |
---|
| 1488 | irq_in = 0xFFFFFFFF |
---|
| 1489 | for irq in irq_tgt.irqs: |
---|
| 1490 | if ( irq.isrtype == 'ISR_BDV' ): irq_in = irq.srcid |
---|
| 1491 | if ( irq_in == 0xFFFFFFFF ): |
---|
[512] | 1492 | print '[genmap error] in netbsd.dts()' |
---|
| 1493 | print ' ISR_BDV not found' |
---|
[319] | 1494 | sys.exit(1) |
---|
| 1495 | |
---|
[411] | 1496 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1497 | s += ' device_type = "soclib:blockdevice";\n' |
---|
[411] | 1498 | s += ' irq = <&{/%s@0x%x} %d>;\n' % (irq_tgt.pseg.name,irq_tgt.pseg.base,irq_in) |
---|
| 1499 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[319] | 1500 | s += ' };\n' |
---|
| 1501 | |
---|
| 1502 | elif ( periph.subtype == 'HBA' ): |
---|
[512] | 1503 | print '[genmap error] in netbsd_dts()' |
---|
| 1504 | print ' HBA peripheral not supported by NetBSD' |
---|
[319] | 1505 | sys.exit(1) |
---|
| 1506 | |
---|
| 1507 | elif ( periph.subtype == 'SPI' ): |
---|
| 1508 | |
---|
| 1509 | # get irq line index associated to spi |
---|
| 1510 | irq_in = 0xFFFFFFFF |
---|
| 1511 | for irq in irq_tgt.irqs: |
---|
| 1512 | if ( irq.isrtype == 'ISR_SPI' ): irq_in = irq.srcid |
---|
| 1513 | if ( irq_in == 0xFFFFFFFF ): |
---|
[512] | 1514 | print '[genmap error] in netbsd.dts()' |
---|
| 1515 | print ' ISR_SPI not found' |
---|
[319] | 1516 | sys.exit(1) |
---|
| 1517 | |
---|
| 1518 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1519 | s += ' device_type = "soclib:spi";\n' |
---|
[411] | 1520 | s += ' irq = <&{/%s@0x%x} %d>;\n' % (irq_tgt.pseg.name,irq_tgt.pseg.base,irq_in) |
---|
| 1521 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[319] | 1522 | s += ' };\n' |
---|
| 1523 | |
---|
| 1524 | # research ROM component |
---|
| 1525 | elif ( periph.ptype == 'ROM' ): |
---|
| 1526 | |
---|
[411] | 1527 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1528 | s += ' device_type = "rom";\n' |
---|
[411] | 1529 | s += ' cached = <1>;\n' |
---|
| 1530 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[319] | 1531 | s += ' };\n' |
---|
| 1532 | |
---|
| 1533 | # research SIM component |
---|
| 1534 | elif ( periph.ptype == 'SIM' ): |
---|
| 1535 | |
---|
| 1536 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1537 | s += ' device_type = "soclib:simhelper";\n' |
---|
| 1538 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1539 | s += ' };\n' |
---|
| 1540 | |
---|
| 1541 | # research TTY component |
---|
| 1542 | elif ( periph.ptype == 'TTY' ): |
---|
| 1543 | |
---|
[411] | 1544 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1545 | s += ' device_type = "soclib:tty";\n' |
---|
[406] | 1546 | s += ' channel_count = < %d >;\n' % periph.channels |
---|
[411] | 1547 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
[319] | 1548 | |
---|
| 1549 | # multi-channels : get HWI index (to XCU or PIC) for each channel |
---|
| 1550 | for channel in xrange( periph.channels ): |
---|
| 1551 | hwi_id = 0xFFFFFFFF |
---|
| 1552 | for irq in irq_tgt.irqs: |
---|
[406] | 1553 | if ( (irq.isrtype == 'ISR_TTY_RX') and (irq.channel == channel) ): |
---|
[319] | 1554 | hwi_id = irq.srcid |
---|
| 1555 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1556 | print '[genmap error] in netbsd.dts()' |
---|
| 1557 | print ' ISR_TTY_RX channel %d not found' % channel |
---|
[319] | 1558 | sys.exit(1) |
---|
| 1559 | |
---|
| 1560 | name = '%s@0x%x' % (irq_tgt.pseg.name, irq_tgt.pseg.base) |
---|
| 1561 | s += ' irq@%d{\n' % channel |
---|
| 1562 | s += ' device_type = "soclib:periph:irq";\n' |
---|
| 1563 | s += ' output_line = <%d>;\n' % channel |
---|
[411] | 1564 | s += ' irq = <&{/%s} %d>;\n' % (name, hwi_id) |
---|
| 1565 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1566 | s += ' };\n' |
---|
| 1567 | |
---|
| 1568 | s += ' };\n' |
---|
[406] | 1569 | |
---|
[319] | 1570 | # research IOB component |
---|
| 1571 | elif ( periph.ptype == 'IOB' ): |
---|
| 1572 | |
---|
| 1573 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1574 | s += ' device_type = "soclib:iob";\n' |
---|
| 1575 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1576 | s += ' };\n' |
---|
| 1577 | |
---|
| 1578 | # research NIC component |
---|
[406] | 1579 | elif ( periph.ptype == 'NIC' ): |
---|
[319] | 1580 | |
---|
| 1581 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1582 | s += ' device_type = "soclib:nic";\n' |
---|
| 1583 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1584 | s += ' channel_count = < %d >;\n' % periph.channels |
---|
| 1585 | |
---|
| 1586 | # multi-channels : get HWI index (to XCU or PIC) for RX & TX IRQs |
---|
| 1587 | # RX IRQ : (2*channel) / TX IRQs : (2*channel + 1) |
---|
| 1588 | for channel in xrange( periph.channels ): |
---|
| 1589 | hwi_id = 0xFFFFFFFF |
---|
| 1590 | for irq in irq_tgt.irqs: |
---|
[406] | 1591 | if ( (irq.isrtype == 'ISR_NIC_RX') and (irq.channel == channel) ): |
---|
[319] | 1592 | hwi_id = irq.srcid |
---|
| 1593 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1594 | print '[genmap error] in netbsd.dts()' |
---|
| 1595 | print ' ISR_NIC_RX channel %d not found' % channel |
---|
[319] | 1596 | sys.exit(1) |
---|
| 1597 | |
---|
| 1598 | name = '%s@0x%x' % (irq_tgt.pseg.name, irq_tgt.pseg.base) |
---|
| 1599 | s += ' irq_rx@%d{\n' % channel |
---|
| 1600 | s += ' device_type = "soclib:periph:irq";\n' |
---|
| 1601 | s += ' output_line = <%d>;\n' % (2*channel) |
---|
| 1602 | s += ' irq = <&{/%s} %d>;\n' % (name, hwi_id) |
---|
| 1603 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1604 | s += ' };\n' |
---|
| 1605 | |
---|
| 1606 | hwi_id = 0xFFFFFFFF |
---|
| 1607 | for irq in irq_tgt.irqs: |
---|
[406] | 1608 | if ( (irq.isrtype == 'ISR_NIC_TX') and (irq.channel == channel) ): |
---|
[319] | 1609 | hwi_id = irq.srcid |
---|
| 1610 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1611 | print '[genmap error] in netbsd.dts()' |
---|
| 1612 | print ' ISR_NIC_TX channel %d not found' % channel |
---|
[319] | 1613 | sys.exit(1) |
---|
| 1614 | |
---|
| 1615 | name = '%s@0x%x' % (irq_tgt.pseg.name, irq_tgt.pseg.base) |
---|
| 1616 | s += ' irq_tx@%d{\n' % channel |
---|
| 1617 | s += ' device_type = "soclib:periph:irq";\n' |
---|
| 1618 | s += ' output_line = <%d>;\n' % (2*channel + 1) |
---|
| 1619 | s += ' irq = <&{/%s} %d>;\n' % (name, hwi_id) |
---|
| 1620 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1621 | s += ' };\n' |
---|
[406] | 1622 | |
---|
[319] | 1623 | s += ' };\n' |
---|
| 1624 | |
---|
| 1625 | # research CMA component |
---|
[406] | 1626 | elif ( periph.ptype == 'CMA' ): |
---|
[319] | 1627 | |
---|
| 1628 | s += ' %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base) |
---|
| 1629 | s += ' device_type = "soclib:cma";\n' |
---|
| 1630 | s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) |
---|
| 1631 | s += ' channel_count = < %d >;\n' % periph.channels |
---|
| 1632 | |
---|
| 1633 | # multi-channels : get HWI index (to XCU or PIC) for each channel |
---|
| 1634 | for channel in xrange( periph.channels ): |
---|
| 1635 | hwi_id = 0xFFFFFFFF |
---|
| 1636 | for irq in irq_tgt.irqs: |
---|
[406] | 1637 | if ( (irq.isrtype == 'ISR_CMA') and (irq.channel == channel) ): |
---|
[319] | 1638 | hwi_id = irq.srcid |
---|
[512] | 1639 | |
---|
[319] | 1640 | if ( hwi_id == 0xFFFFFFFF ): |
---|
[512] | 1641 | print '[genmap error] in netbsd.dts()' |
---|
| 1642 | print ' ISR_CMA channel %d not found' % channel |
---|
[319] | 1643 | sys.exit(1) |
---|
| 1644 | |
---|
| 1645 | name = '%s@0x%x' % (irq_tgt.pseg.name, irq_tgt.pseg.base) |
---|
| 1646 | s += ' irq@%d{\n' % channel |
---|
| 1647 | s += ' device_type = "soclib:periph:irq";\n' |
---|
| 1648 | s += ' output_line = <%d>;\n' % channel |
---|
[411] | 1649 | s += ' irq = <&{/%s} %d>;\n' % (name, hwi_id) |
---|
| 1650 | s += ' parent = <&{/%s@0x%x}>;\n' % (periph.pseg.name, periph.pseg.base) |
---|
[319] | 1651 | s += ' };\n' |
---|
| 1652 | |
---|
| 1653 | s += ' };\n' |
---|
| 1654 | |
---|
| 1655 | # research TIM component |
---|
[406] | 1656 | elif ( periph.ptype == 'TIM' ): |
---|
[319] | 1657 | |
---|
[512] | 1658 | print '[genmap error] in netbsd_dts()' |
---|
| 1659 | print ' TIM peripheral not supported by NetBSD' |
---|
[319] | 1660 | sys.exit(1) |
---|
| 1661 | |
---|
| 1662 | # research MWR component |
---|
| 1663 | elif ( periph.ptype == 'MWR' ): |
---|
| 1664 | |
---|
[512] | 1665 | print '[genmap error] in netbsd_dts()' |
---|
| 1666 | print ' MWR peripheral not supported by NetBSD' |
---|
[319] | 1667 | sys.exit(1) |
---|
| 1668 | |
---|
| 1669 | # topology |
---|
| 1670 | s += '\n' |
---|
| 1671 | s += ' topology {\n' |
---|
| 1672 | s += ' #address-cells = <2>;\n' |
---|
| 1673 | s += ' #size-cells = <0>;\n' |
---|
| 1674 | for cluster in self.clusters: |
---|
[406] | 1675 | s += ' cluster@%d,%d {\n' % (cluster.x, cluster.y) |
---|
[319] | 1676 | s += ' reg = <%d %d>;\n' % (cluster.x, cluster.y) |
---|
| 1677 | s += ' devices = <\n' |
---|
| 1678 | |
---|
[406] | 1679 | offset = ((cluster.x << self.y_width) + cluster.y) << self.p_width |
---|
[319] | 1680 | for proc in cluster.procs: |
---|
| 1681 | s += ' &{/cpus/Mips,32@0x%x}\n' % (offset + proc.lpid) |
---|
| 1682 | for periph in cluster.periphs: |
---|
| 1683 | s += ' &{/%s@0x%x}\n' % (periph.pseg.name, periph.pseg.base) |
---|
[492] | 1684 | for pseg in cluster.psegs: |
---|
| 1685 | if ( pseg.segtype == 'RAM' ): |
---|
| 1686 | s += ' &{/%s@0x%x}\n' % (pseg.name, pseg.base) |
---|
[319] | 1687 | |
---|
| 1688 | s += ' >;\n' |
---|
| 1689 | s += ' };\n' |
---|
| 1690 | s += ' };\n' |
---|
| 1691 | s += '};\n' |
---|
| 1692 | |
---|
| 1693 | return s |
---|
[411] | 1694 | # end netbsd_dts() |
---|
[319] | 1695 | |
---|
| 1696 | ########################### |
---|
| 1697 | def almos_archinfo( self ): # compute string for arch.info file generation, |
---|
[406] | 1698 | # used for almos configuration |
---|
[319] | 1699 | # header |
---|
[327] | 1700 | s = '# arch.info file generated by genmap for %s\n' % self.name |
---|
[319] | 1701 | s += '\n' |
---|
| 1702 | s += '[HEADER]\n' |
---|
| 1703 | s += ' REVISION=1\n' |
---|
| 1704 | s += ' ARCH=%s\n' % self.name |
---|
| 1705 | s += ' XMAX=%d\n' % self.x_size |
---|
| 1706 | s += ' YMAX=%d\n' % self.y_size |
---|
[411] | 1707 | s += ' CPU_NR=%d\n' % self.nprocs |
---|
[319] | 1708 | s += '\n' |
---|
| 1709 | |
---|
| 1710 | # clusters |
---|
| 1711 | cluster_id = 0 |
---|
| 1712 | for cluster in self.clusters: |
---|
| 1713 | |
---|
| 1714 | ram = None |
---|
| 1715 | nb_cpus = len( cluster.procs ) |
---|
| 1716 | nb_devs = len( cluster.periphs ) |
---|
| 1717 | |
---|
| 1718 | # search a RAM |
---|
| 1719 | for pseg in cluster.psegs: |
---|
[406] | 1720 | if ( pseg.segtype == 'RAM' ): |
---|
[319] | 1721 | ram = pseg |
---|
| 1722 | nb_devs += 1 |
---|
| 1723 | |
---|
| 1724 | # search XCU to get IRQs indexes if cluster contains peripherals |
---|
| 1725 | if ( len( cluster.periphs ) != 0 ): |
---|
| 1726 | tty_irq_id = None |
---|
| 1727 | bdv_irq_id = None |
---|
| 1728 | dma_irq_id = None |
---|
| 1729 | |
---|
| 1730 | for periph in cluster.periphs: |
---|
[406] | 1731 | if ( periph.ptype == 'XCU' ): |
---|
[319] | 1732 | # scan irqs |
---|
| 1733 | for irq in periph.irqs: |
---|
| 1734 | if ( irq.isrtype == 'ISR_TTY_RX' ) : tty_irq_id = irq.srcid |
---|
| 1735 | if ( irq.isrtype == 'ISR_BDV' ) : bdv_irq_id = irq.srcid |
---|
| 1736 | if ( irq.isrtype == 'ISR_DMA' ) : dma_irq_id = irq.srcid |
---|
| 1737 | |
---|
| 1738 | # Build the cluster description |
---|
| 1739 | s += '[CLUSTER]\n' |
---|
[406] | 1740 | s += ' CID=%d\n' % cluster_id |
---|
| 1741 | s += ' ARCH_CID=0x%x\n' % ((cluster.x << self.y_width) + cluster.y) |
---|
[319] | 1742 | s += ' CPU_NR=%d\n' % nb_cpus |
---|
| 1743 | s += ' DEV_NR=%d\n' % nb_devs |
---|
| 1744 | |
---|
[406] | 1745 | |
---|
[319] | 1746 | # Handling RAM when cluster contain a RAM |
---|
| 1747 | if (ram != None ): |
---|
| 1748 | base = ram.base |
---|
| 1749 | size = ram.size |
---|
| 1750 | irqid = -1 |
---|
[406] | 1751 | s += ' DEVID=RAM' |
---|
[319] | 1752 | s += ' BASE=0x%x SIZE=0x%x IRQ=-1\n' % ( base, size ) |
---|
| 1753 | |
---|
| 1754 | # Handling peripherals |
---|
| 1755 | for periph in cluster.periphs: |
---|
| 1756 | base = periph.pseg.base |
---|
| 1757 | size = periph.pseg.size |
---|
| 1758 | |
---|
[406] | 1759 | if ( periph.ptype == 'XCU' ): |
---|
[319] | 1760 | |
---|
[406] | 1761 | s += ' DEVID=XICU' |
---|
[319] | 1762 | s += ' BASE=0x%x SIZE=0x%x IRQ=-1\n' % ( base, size ) |
---|
| 1763 | |
---|
[406] | 1764 | elif ( (periph.ptype == 'TTY') |
---|
[319] | 1765 | and (tty_irq_id != None) ): |
---|
| 1766 | |
---|
[406] | 1767 | s += ' DEVID=TTY' |
---|
[319] | 1768 | s += ' BASE=0x%x SIZE=0x%x IRQ=%d\n' % ( base, size, tty_irq_id ) |
---|
| 1769 | |
---|
[406] | 1770 | elif ( (periph.ptype == 'DMA') |
---|
[319] | 1771 | and (dma_irq_id != None) ): |
---|
| 1772 | |
---|
| 1773 | s += ' DEVID=DMA' |
---|
| 1774 | s += ' BASE=0x%x SIZE=0x%x IRQ=%d\n' % ( base, size, dma_irq_id ) |
---|
| 1775 | |
---|
| 1776 | elif ( periph.ptype == 'FBF' ): |
---|
| 1777 | |
---|
| 1778 | s += ' DEVID=FB' |
---|
| 1779 | s += ' BASE=0x%x SIZE=0x%x IRQ=-1\n' % ( base, size ) |
---|
| 1780 | |
---|
| 1781 | elif ( (periph.ptype == 'IOC') and (periph.subtype == 'BDV') |
---|
| 1782 | and (bdv_irq_id != None) ): |
---|
| 1783 | |
---|
[406] | 1784 | s += ' DEVID=BLKDEV' |
---|
[319] | 1785 | s += ' BASE=0x%x SIZE=0x%x IRQ=%d\n' % ( base, size, bdv_irq_id ) |
---|
| 1786 | |
---|
| 1787 | elif ( periph.ptype == 'PIC' ): |
---|
| 1788 | |
---|
[406] | 1789 | s += ' DEVID=IOPIC' |
---|
[319] | 1790 | s += ' BASE=0x%x SIZE=0x%x IRQ=-1\n' % ( base, size ) |
---|
| 1791 | |
---|
| 1792 | else: |
---|
| 1793 | print '# Warning from almos_archinfo() in cluster[%d,%d]' \ |
---|
| 1794 | % (cluster.x, cluster.y) |
---|
| 1795 | print '# peripheral type %s/%s not supported yet\n' \ |
---|
| 1796 | % ( periph.ptype, periph.subtype ) |
---|
[406] | 1797 | |
---|
[319] | 1798 | cluster_id += 1 |
---|
| 1799 | |
---|
| 1800 | return s |
---|
| 1801 | |
---|
| 1802 | # end of almos_archinfo() |
---|
| 1803 | |
---|
| 1804 | |
---|
| 1805 | |
---|
| 1806 | |
---|
| 1807 | |
---|
| 1808 | |
---|
| 1809 | |
---|
| 1810 | |
---|
| 1811 | ########################################################################################### |
---|
| 1812 | class Cluster ( object ): |
---|
| 1813 | ########################################################################################### |
---|
| 1814 | def __init__( self, |
---|
[406] | 1815 | x, |
---|
[319] | 1816 | y ): |
---|
[406] | 1817 | |
---|
[319] | 1818 | self.index = 0 # global index (set by Mapping constructor) |
---|
| 1819 | self.x = x # x coordinate |
---|
| 1820 | self.y = y # y coordinate |
---|
| 1821 | self.psegs = [] # filled by addRam() or addPeriph() |
---|
| 1822 | self.procs = [] # filled by addProc() |
---|
| 1823 | self.periphs = [] # filled by addPeriph() |
---|
| 1824 | |
---|
| 1825 | return |
---|
| 1826 | |
---|
| 1827 | ################ |
---|
| 1828 | def xml( self ): # xml for a cluster |
---|
| 1829 | |
---|
| 1830 | s = ' <cluster x="%d" y="%d" >\n' % (self.x, self.y) |
---|
[406] | 1831 | for pseg in self.psegs: s += pseg.xml() |
---|
[319] | 1832 | for proc in self.procs: s += proc.xml() |
---|
[406] | 1833 | for peri in self.periphs: s += peri.xml() |
---|
[319] | 1834 | s += ' </cluster>\n' |
---|
| 1835 | |
---|
| 1836 | return s |
---|
| 1837 | |
---|
| 1838 | ############################################# |
---|
| 1839 | def cbin( self, mapping, verbose, expected ): # C binary structure for Cluster |
---|
| 1840 | |
---|
| 1841 | if ( verbose ): |
---|
| 1842 | print '*** cbin for cluster [%d,%d]' % (self.x, self.y) |
---|
| 1843 | |
---|
| 1844 | # check index |
---|
| 1845 | if (self.index != expected): |
---|
[512] | 1846 | print '[genmap error] in Cluster.cbin()' |
---|
| 1847 | print ' cluster global index = %d / expected = %d' % (self.index,expected) |
---|
[319] | 1848 | sys.exit(1) |
---|
| 1849 | |
---|
[406] | 1850 | # compute global index for first pseg |
---|
[319] | 1851 | if ( len(self.psegs) > 0 ): |
---|
| 1852 | pseg_id = self.psegs[0].index |
---|
| 1853 | else: |
---|
| 1854 | pseg_id = 0 |
---|
| 1855 | |
---|
[406] | 1856 | # compute global index for first proc |
---|
[319] | 1857 | if ( len(self.procs) > 0 ): |
---|
| 1858 | proc_id = self.procs[0].index |
---|
| 1859 | else: |
---|
| 1860 | proc_id = 0 |
---|
| 1861 | |
---|
[406] | 1862 | # compute global index for first periph |
---|
[319] | 1863 | if ( len(self.periphs) > 0 ): |
---|
| 1864 | periph_id = self.periphs[0].index |
---|
| 1865 | else: |
---|
| 1866 | periph_id = 0 |
---|
| 1867 | |
---|
| 1868 | byte_stream = bytearray() |
---|
[512] | 1869 | byte_stream += mapping.int2bytes( 4 , self.x ) # x coordinate |
---|
| 1870 | byte_stream += mapping.int2bytes( 4 , self.y ) # x coordinate |
---|
| 1871 | byte_stream += mapping.int2bytes( 4 , len( self.psegs ) ) # number psegs in cluster |
---|
| 1872 | byte_stream += mapping.int2bytes( 4 , pseg_id ) # first pseg global index |
---|
| 1873 | byte_stream += mapping.int2bytes( 4 , len( self.procs ) ) # number procs in cluster |
---|
| 1874 | byte_stream += mapping.int2bytes( 4 , proc_id ) # first proc global index |
---|
| 1875 | byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster |
---|
| 1876 | byte_stream += mapping.int2bytes( 4 , periph_id ) # first periph global index |
---|
[406] | 1877 | |
---|
[319] | 1878 | if ( verbose ): |
---|
| 1879 | print 'nb_psegs = %d' % len( self.psegs ) |
---|
| 1880 | print 'pseg_id = %d' % pseg_id |
---|
| 1881 | print 'nb_procs = %d' % len( self.procs ) |
---|
| 1882 | print 'proc_id = %d' % proc_id |
---|
| 1883 | print 'nb_periphs = %d' % len( self.periphs ) |
---|
| 1884 | print 'periph_id = %d' % periph_id |
---|
| 1885 | |
---|
| 1886 | return byte_stream |
---|
| 1887 | |
---|
[512] | 1888 | ######################################################################################## |
---|
[305] | 1889 | class Vspace( object ): |
---|
[512] | 1890 | ######################################################################################## |
---|
[406] | 1891 | def __init__( self, |
---|
| 1892 | name, |
---|
[319] | 1893 | startname ): |
---|
| 1894 | |
---|
| 1895 | self.index = 0 # global index ( set by addVspace() ) |
---|
| 1896 | self.name = name # vspace name |
---|
[512] | 1897 | self.startname = startname # name of vseg containing the start_vector |
---|
[406] | 1898 | self.vsegs = [] |
---|
[305] | 1899 | self.tasks = [] |
---|
| 1900 | |
---|
| 1901 | return |
---|
| 1902 | |
---|
[319] | 1903 | ################ |
---|
| 1904 | def xml( self ): # xml for one vspace |
---|
| 1905 | |
---|
[305] | 1906 | s = ' <vspace name="%s" startname="%s" >\n' % ( self.name, self.startname ) |
---|
[319] | 1907 | for vseg in self.vsegs: s += vseg.xml() |
---|
[406] | 1908 | for task in self.tasks: s += task.xml() |
---|
[305] | 1909 | s += ' </vspace>\n' |
---|
[319] | 1910 | |
---|
[305] | 1911 | return s |
---|
| 1912 | |
---|
[319] | 1913 | ############################################# |
---|
| 1914 | def cbin( self, mapping, verbose, expected ): # C binary structure for Vspace |
---|
| 1915 | |
---|
| 1916 | if ( verbose ): |
---|
| 1917 | print '*** cbin for vspace %s' % (self.name) |
---|
| 1918 | |
---|
| 1919 | # check index |
---|
| 1920 | if (self.index != expected): |
---|
[512] | 1921 | print '[genmap error] in Vspace.cbin()' |
---|
| 1922 | print ' vspace global index = %d / expected = %d' %(self.index,expected) |
---|
[319] | 1923 | sys.exit(1) |
---|
| 1924 | |
---|
[512] | 1925 | # compute global index for vseg containing start_vector |
---|
| 1926 | vseg_start_id = 0xFFFFFFFF |
---|
[319] | 1927 | for vseg in self.vsegs: |
---|
[512] | 1928 | if ( vseg.name == self.startname ): vseg_start_id = vseg.index |
---|
| 1929 | |
---|
| 1930 | if ( vseg_start_id == 0xFFFFFFFF ): |
---|
| 1931 | print '[genmap error] in Vspace.cbin()' |
---|
| 1932 | print ' startname %s not found for vspace %s' %(self.startname,self.name) |
---|
[319] | 1933 | sys.exit(1) |
---|
[406] | 1934 | |
---|
[512] | 1935 | # compute first vseg and first task global index |
---|
[319] | 1936 | first_vseg_id = self.vsegs[0].index |
---|
| 1937 | first_task_id = self.tasks[0].index |
---|
[406] | 1938 | |
---|
[512] | 1939 | # compute number of tasks and number of vsegs |
---|
[319] | 1940 | nb_vsegs = len( self.vsegs ) |
---|
| 1941 | nb_tasks = len( self.tasks ) |
---|
| 1942 | |
---|
| 1943 | byte_stream = bytearray() |
---|
| 1944 | byte_stream += mapping.str2bytes( 32, self.name ) # vspace name |
---|
[512] | 1945 | byte_stream += mapping.int2bytes( 4, vseg_start_id ) # vseg start_vector |
---|
[319] | 1946 | byte_stream += mapping.int2bytes( 4, nb_vsegs ) # number of vsegs |
---|
| 1947 | byte_stream += mapping.int2bytes( 4, nb_tasks ) # number of tasks |
---|
| 1948 | byte_stream += mapping.int2bytes( 4, first_vseg_id ) # first vseg global index |
---|
| 1949 | byte_stream += mapping.int2bytes( 4, first_task_id ) # first task global index |
---|
| 1950 | |
---|
| 1951 | if ( verbose ): |
---|
[512] | 1952 | print 'start_id = %d' % vseg_start_id |
---|
[319] | 1953 | print 'nb_vsegs = %d' % nb_vsegs |
---|
| 1954 | print 'nb_tasks = %d' % nb_tasks |
---|
| 1955 | print 'vseg_id = %d' % first_vseg_id |
---|
| 1956 | print 'task_id = %d' % first_task_id |
---|
| 1957 | |
---|
| 1958 | return byte_stream |
---|
| 1959 | |
---|
[512] | 1960 | ######################################################################################## |
---|
[305] | 1961 | class Task( object ): |
---|
[512] | 1962 | ######################################################################################## |
---|
[406] | 1963 | def __init__( self, |
---|
| 1964 | name, |
---|
| 1965 | trdid, |
---|
| 1966 | x, |
---|
[319] | 1967 | y, |
---|
[406] | 1968 | p, |
---|
| 1969 | stackname, |
---|
| 1970 | heapname, |
---|
[441] | 1971 | startid ): |
---|
[319] | 1972 | |
---|
| 1973 | self.index = 0 # global index value set by addTask() |
---|
| 1974 | self.name = name # tsk name |
---|
| 1975 | self.trdid = trdid # task index (unique in vspace) |
---|
[406] | 1976 | self.x = x # cluster x coordinate |
---|
| 1977 | self.y = y # cluster y coordinate |
---|
| 1978 | self.p = p # processor local index |
---|
[512] | 1979 | self.stackname = stackname # name of vseg containing the stack |
---|
| 1980 | self.heapname = heapname # name of vseg containing the heap |
---|
[319] | 1981 | self.startid = startid # index in start_vector |
---|
[305] | 1982 | return |
---|
| 1983 | |
---|
[319] | 1984 | ################ |
---|
| 1985 | def xml( self ): # xml for one task |
---|
| 1986 | |
---|
| 1987 | s = ' <task name="%s"' % self.name |
---|
| 1988 | s += ' trdid="%d"' % self.trdid |
---|
| 1989 | s += ' x="%d"' % self.x |
---|
| 1990 | s += ' y="%d"' % self.y |
---|
| 1991 | s += ' p="%d"' % self.p |
---|
[512] | 1992 | s += '\n ' |
---|
[319] | 1993 | s += ' stackname="%s"' % self.stackname |
---|
| 1994 | s += ' heapname="%s"' % self.heapname |
---|
| 1995 | s += ' startid="%d"' % self.startid |
---|
[406] | 1996 | s += ' />\n' |
---|
[319] | 1997 | |
---|
[305] | 1998 | return s |
---|
| 1999 | |
---|
[319] | 2000 | ##################################################### |
---|
[406] | 2001 | def cbin( self, mapping, verbose, expected, vspace ): # C binary data structure for Task |
---|
[319] | 2002 | |
---|
| 2003 | if ( verbose ): |
---|
| 2004 | print '*** cbin for task %s in vspace %s' % (self.name, vspace.name) |
---|
| 2005 | |
---|
| 2006 | # check index |
---|
| 2007 | if (self.index != expected): |
---|
[512] | 2008 | print '[genmap error] in Task.cbin()' |
---|
| 2009 | print ' task global index = %d / expected = %d' %(self.index,expected) |
---|
[319] | 2010 | sys.exit(1) |
---|
| 2011 | |
---|
| 2012 | # compute cluster global index |
---|
| 2013 | cluster_id = (self.x * mapping.y_size) + self.y |
---|
| 2014 | |
---|
[512] | 2015 | # compute vseg index for stack |
---|
| 2016 | vseg_stack_id = 0xFFFFFFFF |
---|
[319] | 2017 | for vseg in vspace.vsegs: |
---|
[512] | 2018 | if ( vseg.name == self.stackname ): vseg_stack_id = vseg.index |
---|
| 2019 | |
---|
| 2020 | if ( vseg_stack_id == 0xFFFFFFFF ): |
---|
| 2021 | print '[genmap error] in Task.cbin()' |
---|
| 2022 | print ' stackname %s not found for task %s in vspace %s' \ |
---|
[319] | 2023 | % ( self.stackname, self.name, vspace.name ) |
---|
| 2024 | sys.exit(1) |
---|
| 2025 | |
---|
[512] | 2026 | # compute vseg index for heap |
---|
[453] | 2027 | if ( self.heapname == '' ): |
---|
[512] | 2028 | vseg_heap_id = 0 |
---|
[453] | 2029 | else: |
---|
[512] | 2030 | vseg_heap_id = 0xFFFFFFFF |
---|
[453] | 2031 | for vseg in vspace.vsegs: |
---|
[512] | 2032 | if ( vseg.name == self.heapname ): vseg_heap_id = vseg.index |
---|
| 2033 | |
---|
| 2034 | if ( vseg_heap_id == 0xFFFFFFFF ): |
---|
| 2035 | print '[genmap error] in Task.cbin()' |
---|
| 2036 | print ' heapname %s not found for task %s in vspace %s' \ |
---|
[453] | 2037 | % ( self.heapname, self.name, vspace.name ) |
---|
| 2038 | sys.exit(1) |
---|
[319] | 2039 | |
---|
| 2040 | byte_stream = bytearray() |
---|
| 2041 | byte_stream += mapping.str2bytes( 32, self.name ) # task name in vspace |
---|
| 2042 | byte_stream += mapping.int2bytes( 4, cluster_id ) # cluster global index |
---|
[512] | 2043 | byte_stream += mapping.int2bytes( 4, self.p ) # processor local index |
---|
[319] | 2044 | byte_stream += mapping.int2bytes( 4, self.trdid ) # thread local index in vspace |
---|
[512] | 2045 | byte_stream += mapping.int2bytes( 4, vseg_stack_id ) # stack vseg local index |
---|
| 2046 | byte_stream += mapping.int2bytes( 4, vseg_heap_id ) # heap vseg local index |
---|
[406] | 2047 | byte_stream += mapping.int2bytes( 4, self.startid ) # index in start vector |
---|
[319] | 2048 | |
---|
| 2049 | if ( verbose ): |
---|
| 2050 | print 'clusterid = %d' % cluster_id |
---|
| 2051 | print 'lpid = %d' % self.p |
---|
[406] | 2052 | print 'trdid = %d' % self.trdid |
---|
[512] | 2053 | print 'stackid = %d' % vseg_stack_id |
---|
| 2054 | print 'heapid = %d' % vseg_heap_id |
---|
[406] | 2055 | print 'startid = %d' % self.startid |
---|
| 2056 | |
---|
[319] | 2057 | return byte_stream |
---|
| 2058 | |
---|
[512] | 2059 | ######################################################################################## |
---|
[305] | 2060 | class Vseg( object ): |
---|
[512] | 2061 | ######################################################################################## |
---|
[406] | 2062 | def __init__( self, |
---|
| 2063 | name, |
---|
| 2064 | vbase, |
---|
[512] | 2065 | length, |
---|
[406] | 2066 | mode, |
---|
[512] | 2067 | vtype, |
---|
[406] | 2068 | x, |
---|
| 2069 | y, |
---|
[512] | 2070 | pseg, |
---|
[348] | 2071 | identity = False, |
---|
[411] | 2072 | local = False, |
---|
[512] | 2073 | big = False, |
---|
| 2074 | binpath = '' ): |
---|
[305] | 2075 | |
---|
[512] | 2076 | assert (vbase & 0xFFFFFFFF) == vbase |
---|
| 2077 | |
---|
| 2078 | assert (length & 0xFFFFFFFF) == length |
---|
| 2079 | |
---|
[319] | 2080 | assert mode in VSEGMODES |
---|
| 2081 | |
---|
[512] | 2082 | assert vtype in VSEGTYPES |
---|
| 2083 | |
---|
| 2084 | assert (vtype != 'ELF') or (binpath != '') |
---|
| 2085 | |
---|
[348] | 2086 | self.index = 0 # global index ( set by addVseg() ) |
---|
[512] | 2087 | self.name = name # vseg name (unique in vspace) |
---|
| 2088 | self.vbase = vbase # virtual base address in vspace |
---|
| 2089 | self.length = length # vseg length (bytes) |
---|
| 2090 | self.vtype = vtype # vseg type (defined in VSEGTYPES) |
---|
[348] | 2091 | self.mode = mode # CXWU access rights |
---|
[406] | 2092 | self.x = x # x coordinate of destination cluster |
---|
[348] | 2093 | self.y = y # y coordinate of destination cluster |
---|
[512] | 2094 | self.psegname = pseg # name of pseg in destination cluster |
---|
[348] | 2095 | self.identity = identity # identity mapping required |
---|
[411] | 2096 | self.local = local # only mapped in local PTAB when true |
---|
| 2097 | self.big = big # to be mapped in a big physical page |
---|
[512] | 2098 | self.binpath = binpath # path name for binary file (ELF or BLOB) |
---|
| 2099 | |
---|
[305] | 2100 | return |
---|
| 2101 | |
---|
[319] | 2102 | ################ |
---|
[406] | 2103 | def xml( self ): # xml for one vseg |
---|
[319] | 2104 | |
---|
[512] | 2105 | s = ' <vseg name="%s"' %(self.name) |
---|
| 2106 | s += ' vbase="0x%x"' %(self.vbase) |
---|
| 2107 | s += ' length="0x%x"' %(self.length) |
---|
| 2108 | s += ' type="%s"' %(self.vtype) |
---|
| 2109 | s += ' mode="%s"' %(self.mode) |
---|
| 2110 | s += '\n ' |
---|
| 2111 | s += ' x="%d"' %(self.x) |
---|
| 2112 | s += ' y="%d"' %(self.y) |
---|
| 2113 | s += ' psegname="%s"' %(self.psegname) |
---|
| 2114 | if ( self.identity ): s += ' ident="1"' |
---|
| 2115 | if ( self.local ): s += ' local="1"' |
---|
| 2116 | if ( self.big ): s += ' big="1"' |
---|
| 2117 | if ( self.binpath != '' ): s += ' binpath="%s"' %(self.binpath) |
---|
| 2118 | s += ' />\n' |
---|
[319] | 2119 | |
---|
[305] | 2120 | return s |
---|
| 2121 | |
---|
[319] | 2122 | ############################################# |
---|
| 2123 | def cbin( self, mapping, verbose, expected ): # C binary structure for Vseg |
---|
| 2124 | |
---|
| 2125 | if ( verbose ): |
---|
| 2126 | print '*** cbin for vseg[%d] %s' % (self.index, self.name) |
---|
| 2127 | |
---|
| 2128 | # check index |
---|
| 2129 | if (self.index != expected): |
---|
[512] | 2130 | print '[genmap error] in Vseg.cbin()' |
---|
| 2131 | print ' vseg global index = %d / expected = %d' \ |
---|
[319] | 2132 | % (self.index, expected ) |
---|
| 2133 | sys.exit(1) |
---|
| 2134 | |
---|
| 2135 | # compute pseg_id |
---|
| 2136 | pseg_id = 0xFFFFFFFF |
---|
| 2137 | cluster_id = (self.x * mapping.y_size) + self.y |
---|
| 2138 | cluster = mapping.clusters[cluster_id] |
---|
| 2139 | for pseg in cluster.psegs: |
---|
| 2140 | if (self.psegname == pseg.name): |
---|
| 2141 | pseg_id = pseg.index |
---|
| 2142 | if (pseg_id == 0xFFFFFFFF): |
---|
[512] | 2143 | print '[genmap error] in Vseg.cbin() : ' |
---|
| 2144 | print ' psegname %s not found for vseg %s in cluster %d' \ |
---|
[319] | 2145 | % ( self.psegname, self.name, cluster_id ) |
---|
| 2146 | sys.exit(1) |
---|
| 2147 | |
---|
| 2148 | # compute numerical value for mode |
---|
| 2149 | mode_id = 0xFFFFFFFF |
---|
[406] | 2150 | for x in xrange( len(VSEGMODES) ): |
---|
| 2151 | if ( self.mode == VSEGMODES[x] ): |
---|
[319] | 2152 | mode_id = x |
---|
| 2153 | if ( mode_id == 0xFFFFFFFF ): |
---|
[512] | 2154 | print '[genmap error] in Vseg.cbin() : ' |
---|
| 2155 | print ' undefined vseg mode %s' % self.mode |
---|
[319] | 2156 | sys.exit(1) |
---|
| 2157 | |
---|
[512] | 2158 | # compute numerical value for vtype |
---|
| 2159 | vtype_id = 0xFFFFFFFF |
---|
| 2160 | for x in xrange( len(VSEGTYPES) ): |
---|
| 2161 | if ( self.vtype == VSEGTYPES[x] ): |
---|
| 2162 | vtype_id = x |
---|
| 2163 | if ( vtype_id == 0xFFFFFFFF ): |
---|
| 2164 | print '[genmap error] in Vseg.cbin()' |
---|
| 2165 | print ' undefined vseg type %s' % self.vtype |
---|
| 2166 | sys.exit(1) |
---|
[319] | 2167 | |
---|
| 2168 | byte_stream = bytearray() |
---|
[406] | 2169 | byte_stream += mapping.str2bytes( 32, self.name ) # vseg name |
---|
[512] | 2170 | byte_stream += mapping.str2bytes( 64, self.binpath ) # binpath |
---|
[319] | 2171 | byte_stream += mapping.int2bytes( 4, self.vbase ) # virtual base address |
---|
| 2172 | byte_stream += mapping.int2bytes( 8, 0 ) # physical base address |
---|
[512] | 2173 | byte_stream += mapping.int2bytes( 4, self.length ) # vseg size (bytes) |
---|
| 2174 | byte_stream += mapping.int2bytes( 4, pseg_id ) # pseg global index |
---|
[319] | 2175 | byte_stream += mapping.int2bytes( 4, mode_id ) # CXWU flags |
---|
[512] | 2176 | byte_stream += mapping.int2bytes( 4, vtype_id ) # vseg type |
---|
[319] | 2177 | byte_stream += mapping.int2bytes( 1, 0 ) # mapped when non zero |
---|
[512] | 2178 | byte_stream += mapping.int2bytes( 1, self.identity ) # identity mapping |
---|
[411] | 2179 | byte_stream += mapping.int2bytes( 1, self.local ) # only mapped in local PTAB |
---|
[512] | 2180 | byte_stream += mapping.int2bytes( 1, self.big ) # to be mapped in BPP |
---|
[319] | 2181 | |
---|
| 2182 | if ( verbose ): |
---|
[512] | 2183 | print 'binpath = %s' % self.binpath |
---|
[319] | 2184 | print 'vbase = %x' % self.vbase |
---|
[512] | 2185 | print 'pbase = 0' |
---|
| 2186 | print 'length = %x' % self.length |
---|
[319] | 2187 | print 'pseg_id = %d' % pseg_id |
---|
[512] | 2188 | print 'mode = %d' % mode_id |
---|
| 2189 | print 'type = %d' % vtype_id |
---|
| 2190 | print 'mapped = 0' |
---|
| 2191 | print 'ident = %d' % self.identity |
---|
| 2192 | print 'local = %d' % self.local |
---|
| 2193 | print 'big = %d' % self.big |
---|
[406] | 2194 | |
---|
[319] | 2195 | return byte_stream |
---|
| 2196 | |
---|
[512] | 2197 | ###################################################################################### |
---|
[305] | 2198 | class Processor ( object ): |
---|
[512] | 2199 | ###################################################################################### |
---|
[319] | 2200 | def __init__( self, |
---|
[406] | 2201 | x, |
---|
| 2202 | y, |
---|
[319] | 2203 | lpid ): |
---|
| 2204 | |
---|
| 2205 | self.index = 0 # global index ( set by addProc() ) |
---|
| 2206 | self.x = x # x cluster coordinate |
---|
| 2207 | self.y = y # y cluster coordinate |
---|
| 2208 | self.lpid = lpid # processor local index |
---|
| 2209 | |
---|
[305] | 2210 | return |
---|
| 2211 | |
---|
[319] | 2212 | ################ |
---|
[406] | 2213 | def xml( self ): # xml for a processor |
---|
[305] | 2214 | return ' <proc index="%d" />\n' % (self.lpid) |
---|
| 2215 | |
---|
[319] | 2216 | ############################################# |
---|
| 2217 | def cbin( self, mapping, verbose, expected ): # C binary structure for Proc |
---|
| 2218 | |
---|
| 2219 | if ( verbose ): |
---|
| 2220 | print '*** cbin for proc %d in cluster (%d,%d)' % (self.lpid, self.x, self.y) |
---|
| 2221 | |
---|
| 2222 | # check index |
---|
| 2223 | if (self.index != expected): |
---|
[512] | 2224 | print '[genmap error] in Proc.cbin()' |
---|
| 2225 | print ' proc global index = %d / expected = %d' % (self.index,expected) |
---|
[319] | 2226 | sys.exit(1) |
---|
| 2227 | |
---|
| 2228 | byte_stream = bytearray() |
---|
| 2229 | byte_stream += mapping.int2bytes( 4 , self.lpid ) # local index |
---|
[406] | 2230 | |
---|
[319] | 2231 | return byte_stream |
---|
| 2232 | |
---|
[512] | 2233 | ###################################################################################### |
---|
[305] | 2234 | class Pseg ( object ): |
---|
[512] | 2235 | ###################################################################################### |
---|
[406] | 2236 | def __init__( self, |
---|
| 2237 | name, |
---|
| 2238 | base, |
---|
| 2239 | size, |
---|
[319] | 2240 | x, |
---|
| 2241 | y, |
---|
| 2242 | segtype ): |
---|
| 2243 | |
---|
| 2244 | assert( segtype in PSEGTYPES ) |
---|
| 2245 | |
---|
| 2246 | self.index = 0 # global index ( set by addPseg() ) |
---|
| 2247 | self.name = name # pseg name (unique in cluster) |
---|
| 2248 | self.base = base # physical base address |
---|
| 2249 | self.size = size # segment size (bytes) |
---|
[406] | 2250 | self.x = x # cluster x coordinate |
---|
| 2251 | self.y = y # cluster y coordinate |
---|
[319] | 2252 | self.segtype = segtype # RAM / PERI (defined in mapping_info.h) |
---|
| 2253 | |
---|
[305] | 2254 | return |
---|
[406] | 2255 | |
---|
[319] | 2256 | ################ |
---|
| 2257 | def xml( self ): # xml for a pseg |
---|
| 2258 | |
---|
[305] | 2259 | return ' <pseg name="%s" type="%s" base="0x%x" length="0x%x" />\n' \ |
---|
| 2260 | % (self.name, self.segtype, self.base, self.size) |
---|
| 2261 | |
---|
[319] | 2262 | ###################################################### |
---|
| 2263 | def cbin( self, mapping, verbose, expected, cluster ): # C binary structure for Pseg |
---|
| 2264 | |
---|
| 2265 | if ( verbose ): |
---|
| 2266 | print '*** cbin for pseg[%d] %s in cluster[%d,%d]' \ |
---|
| 2267 | % (self.index, self.name, cluster.x, cluster.y) |
---|
| 2268 | |
---|
| 2269 | # check index |
---|
| 2270 | if (self.index != expected): |
---|
[512] | 2271 | print '[genmap error] in Pseg.cbin()' |
---|
| 2272 | print ' pseg global index = %d / expected = %d' % (self.index,expected) |
---|
[319] | 2273 | sys.exit(1) |
---|
[406] | 2274 | |
---|
[319] | 2275 | # compute numerical value for segtype |
---|
| 2276 | segtype_int = 0xFFFFFFFF |
---|
[406] | 2277 | for x in xrange( len(PSEGTYPES) ): |
---|
[512] | 2278 | if ( self.segtype == PSEGTYPES[x] ): segtype_int = x |
---|
| 2279 | |
---|
[319] | 2280 | if ( segtype_int == 0xFFFFFFFF ): |
---|
[512] | 2281 | print '[genmap error] in Pseg.cbin()' |
---|
| 2282 | print ' undefined segment type %s' % self.segtype |
---|
[319] | 2283 | sys.exit(1) |
---|
| 2284 | |
---|
| 2285 | byte_stream = bytearray() |
---|
[406] | 2286 | byte_stream += mapping.str2bytes( 32, self.name ) # pseg name |
---|
[319] | 2287 | byte_stream += mapping.int2bytes( 8 , self.base ) # physical base address |
---|
| 2288 | byte_stream += mapping.int2bytes( 8 , self.size ) # segment length |
---|
| 2289 | byte_stream += mapping.int2bytes( 4 , segtype_int ) # segment type |
---|
| 2290 | byte_stream += mapping.int2bytes( 4 , cluster.index ) # cluster global index |
---|
[406] | 2291 | byte_stream += mapping.int2bytes( 4 , 0 ) # linked list of vsegs |
---|
[319] | 2292 | |
---|
| 2293 | if ( verbose ): |
---|
| 2294 | print 'pbase = %x' % self.base |
---|
| 2295 | print 'size = %x' % self.size |
---|
| 2296 | print 'type = %s' % self.segtype |
---|
[406] | 2297 | |
---|
[319] | 2298 | return byte_stream |
---|
| 2299 | |
---|
[512] | 2300 | ###################################################################################### |
---|
[319] | 2301 | class Periph ( object ): |
---|
[512] | 2302 | ###################################################################################### |
---|
[406] | 2303 | def __init__( self, |
---|
[319] | 2304 | pseg, # associated pseg |
---|
| 2305 | ptype, # peripheral type |
---|
| 2306 | subtype = 'NONE', # peripheral subtype |
---|
| 2307 | channels = 1, # for multi-channels peripherals |
---|
[520] | 2308 | arg0 = 0, # optional argument (semantic depends on ptype) |
---|
| 2309 | arg1 = 0, # optional argument (semantic depends on ptype) |
---|
| 2310 | arg2 = 0, # optional argument (semantic depends on ptype) |
---|
| 2311 | arg3 = 0 ): # optional argument (semantic depends on ptype) |
---|
[319] | 2312 | |
---|
| 2313 | self.index = 0 # global index ( set by addPeriph() ) |
---|
[406] | 2314 | self.channels = channels |
---|
| 2315 | self.ptype = ptype |
---|
| 2316 | self.subtype = subtype |
---|
[520] | 2317 | self.arg0 = arg0 |
---|
| 2318 | self.arg1 = arg1 |
---|
| 2319 | self.arg2 = arg2 |
---|
| 2320 | self.arg3 = arg3 |
---|
[319] | 2321 | self.pseg = pseg |
---|
| 2322 | self.irqs = [] |
---|
[305] | 2323 | return |
---|
| 2324 | |
---|
[319] | 2325 | ################ |
---|
| 2326 | def xml( self ): # xml for a periph |
---|
| 2327 | |
---|
| 2328 | s = ' <periph type="%s"' % self.ptype |
---|
| 2329 | s += ' subtype="%s"' % self.subtype |
---|
| 2330 | s += ' psegname="%s"' % self.pseg.name |
---|
| 2331 | s += ' channels="%d"' % self.channels |
---|
[520] | 2332 | s += ' arg0="%d"' % self.arg0 |
---|
| 2333 | s += ' arg1="%d"' % self.arg1 |
---|
| 2334 | s += ' arg2="%d"' % self.arg2 |
---|
| 2335 | s += ' arg3="%d"' % self.arg3 |
---|
[441] | 2336 | if ( (self.ptype == 'PIC') or (self.ptype == 'XCU') ): |
---|
[520] | 2337 | s += ' >\n' |
---|
[319] | 2338 | for irq in self.irqs: s += irq.xml() |
---|
[520] | 2339 | s += ' </periph>\n' |
---|
| 2340 | else: |
---|
| 2341 | s += ' />\n' |
---|
[305] | 2342 | return s |
---|
| 2343 | |
---|
[319] | 2344 | ############################################# |
---|
| 2345 | def cbin( self, mapping, verbose, expected ): # C binary structure for Periph |
---|
[305] | 2346 | |
---|
[319] | 2347 | if ( verbose ): |
---|
| 2348 | print '*** cbin for periph %s in cluster [%d,%d]' \ |
---|
| 2349 | % (self.ptype, self.pseg.x, self.pseg.y) |
---|
[305] | 2350 | |
---|
[319] | 2351 | # check index |
---|
| 2352 | if (self.index != expected): |
---|
[512] | 2353 | print '[genmap error] in Periph.cbin()' |
---|
| 2354 | print ' periph global index = %d / expected = %d' % (self.index,expected) |
---|
[319] | 2355 | sys.exit(1) |
---|
[305] | 2356 | |
---|
[319] | 2357 | # compute pseg global index |
---|
| 2358 | pseg_id = self.pseg.index |
---|
[305] | 2359 | |
---|
[319] | 2360 | # compute first irq global index |
---|
| 2361 | if ( len(self.irqs) > 0 ): |
---|
| 2362 | irq_id = self.irqs[0].index |
---|
| 2363 | else: |
---|
| 2364 | irq_id = 0 |
---|
[305] | 2365 | |
---|
[319] | 2366 | # compute numerical value for ptype |
---|
| 2367 | ptype_id = 0xFFFFFFFF |
---|
[406] | 2368 | for x in xrange( len(PERIPHTYPES) ): |
---|
[319] | 2369 | if ( self.ptype == PERIPHTYPES[x] ): ptype_id = x |
---|
[512] | 2370 | |
---|
[319] | 2371 | if ( ptype_id == 0xFFFFFFFF ): |
---|
[512] | 2372 | print '[genmap error] in Periph.cbin()' |
---|
| 2373 | print ' undefined peripheral type %s' % self.ptype |
---|
[319] | 2374 | sys.exit(1) |
---|
[305] | 2375 | |
---|
[319] | 2376 | # compute numerical value for subtype |
---|
| 2377 | subtype_id = 0xFFFFFFFF |
---|
[520] | 2378 | if (self.ptype == 'IOC'): |
---|
| 2379 | for x in xrange( len(IOCSUBTYPES) ): |
---|
| 2380 | if ( self.subtype == IOCSUBTYPES[x] ): subtype_id = x |
---|
| 2381 | if (self.ptype == 'MWR'): |
---|
| 2382 | for x in xrange( len(MWRSUBTYPES) ): |
---|
| 2383 | if ( self.subtype == MWRSUBTYPES[x] ): subtype_id = x |
---|
| 2384 | |
---|
[319] | 2385 | byte_stream = bytearray() |
---|
[406] | 2386 | byte_stream += mapping.int2bytes( 4 , ptype_id ) # peripheral type |
---|
[319] | 2387 | byte_stream += mapping.int2bytes( 4 , subtype_id ) # peripheral subtype |
---|
[406] | 2388 | byte_stream += mapping.int2bytes( 4 , pseg_id ) # pseg global index |
---|
[319] | 2389 | byte_stream += mapping.int2bytes( 4 , self.channels ) # number of channels |
---|
[520] | 2390 | byte_stream += mapping.int2bytes( 4 , self.arg0 ) # optionnal arg0 |
---|
| 2391 | byte_stream += mapping.int2bytes( 4 , self.arg1 ) # optionnal arg1 |
---|
| 2392 | byte_stream += mapping.int2bytes( 4 , self.arg2 ) # optionnal arg2 |
---|
| 2393 | byte_stream += mapping.int2bytes( 4 , self.arg3 ) # optionnal arg3 |
---|
[406] | 2394 | byte_stream += mapping.int2bytes( 4 , len( self.irqs ) ) # number of input irqs |
---|
| 2395 | byte_stream += mapping.int2bytes( 4 , irq_id ) # first irq global index |
---|
[305] | 2396 | |
---|
[319] | 2397 | if ( verbose ): |
---|
| 2398 | print 'ptype = %d' % ptype_id |
---|
[520] | 2399 | print 'subtype = %d' % subtype_id |
---|
[319] | 2400 | print 'pseg_id = %d' % pseg_id |
---|
| 2401 | print 'nb_irqs = %d' % len( self.irqs ) |
---|
[406] | 2402 | print 'irq_id = %d' % irq_id |
---|
[319] | 2403 | return byte_stream |
---|
[305] | 2404 | |
---|
[512] | 2405 | ###################################################################################### |
---|
[319] | 2406 | class Irq ( object ): |
---|
[512] | 2407 | ###################################################################################### |
---|
[406] | 2408 | def __init__( self, |
---|
[319] | 2409 | irqtype, # input IRQ type : HWI / WTI / PTI (for XCU only) |
---|
| 2410 | srcid, # input IRQ index (for XCU or PIC) |
---|
| 2411 | isrtype, # Type of ISR to be executed |
---|
| 2412 | channel = 0 ): # channel index for multi-channel ISR |
---|
[305] | 2413 | |
---|
[319] | 2414 | assert irqtype in IRQTYPES |
---|
| 2415 | assert isrtype in ISRTYPES |
---|
| 2416 | assert srcid < 32 |
---|
[305] | 2417 | |
---|
[319] | 2418 | self.index = 0 # global index ( set by addIrq() ) |
---|
[406] | 2419 | self.irqtype = irqtype # IRQ type |
---|
[319] | 2420 | self.srcid = srcid # source IRQ index |
---|
[406] | 2421 | self.isrtype = isrtype # ISR type |
---|
[319] | 2422 | self.channel = channel # channel index (for multi-channels ISR) |
---|
[305] | 2423 | return |
---|
| 2424 | |
---|
[319] | 2425 | ################ |
---|
| 2426 | def xml( self ): # xml for Irq |
---|
[305] | 2427 | |
---|
[319] | 2428 | return ' <irq srctype="%s" srcid="%d" isr="%s" channel="%d" />\n' \ |
---|
| 2429 | % ( self.irqtype, self.srcid, self.isrtype, self.channel ) |
---|
[305] | 2430 | |
---|
[319] | 2431 | ############################################# |
---|
| 2432 | def cbin( self, mapping, verbose, expected ): # C binary structure for Irq |
---|
[305] | 2433 | |
---|
[319] | 2434 | if ( verbose ): |
---|
[406] | 2435 | print '*** cbin for irq[%d]' % (self.index) |
---|
[305] | 2436 | |
---|
[319] | 2437 | # check index |
---|
| 2438 | if (self.index != expected): |
---|
[512] | 2439 | print '[genmap error] in Irq.cbin()' |
---|
| 2440 | print ' irq global index = %d / expected = %d' % (self.index,expected) |
---|
[319] | 2441 | sys.exit(1) |
---|
[305] | 2442 | |
---|
[319] | 2443 | # compute numerical value for irqtype |
---|
| 2444 | irqtype_id = 0xFFFFFFFF |
---|
| 2445 | for x in xrange( len(IRQTYPES) ): |
---|
[512] | 2446 | if ( self.irqtype == IRQTYPES[x] ): irqtype_id = x |
---|
| 2447 | |
---|
[319] | 2448 | if ( irqtype_id == 0xFFFFFFFF ): |
---|
[512] | 2449 | print '[genmap error] in Irq.cbin()' |
---|
| 2450 | print ' undefined irqtype %s' % self.irqtype |
---|
[319] | 2451 | sys.exit(1) |
---|
[305] | 2452 | |
---|
[319] | 2453 | # compute numerical value for isrtype |
---|
| 2454 | isrtype_id = 0xFFFFFFFF |
---|
[406] | 2455 | for x in xrange( len(ISRTYPES) ): |
---|
[512] | 2456 | if ( self.isrtype == ISRTYPES[x] ): isrtype_id = x |
---|
| 2457 | |
---|
[319] | 2458 | if ( isrtype_id == 0xFFFFFFFF ): |
---|
[512] | 2459 | print '[genmap error] in Irq.cbin()' |
---|
| 2460 | print ' undefined isrtype %s' % self.isrtype |
---|
[319] | 2461 | sys.exit(1) |
---|
| 2462 | |
---|
| 2463 | byte_stream = bytearray() |
---|
| 2464 | byte_stream += mapping.int2bytes( 4, irqtype_id ) |
---|
| 2465 | byte_stream += mapping.int2bytes( 4, self.srcid ) |
---|
| 2466 | byte_stream += mapping.int2bytes( 4, isrtype_id ) |
---|
| 2467 | byte_stream += mapping.int2bytes( 4, self.channel ) |
---|
| 2468 | byte_stream += mapping.int2bytes( 4, 0 ) |
---|
| 2469 | byte_stream += mapping.int2bytes( 4, 0 ) |
---|
| 2470 | |
---|
| 2471 | if ( verbose ): |
---|
| 2472 | print 'irqtype = %s' % self.irqtype |
---|
| 2473 | print 'srcid = %d' % self.srcid |
---|
| 2474 | print 'isrtype = %s' % self.isrtype |
---|
| 2475 | print 'channel = %d' % self.channel |
---|
| 2476 | |
---|
| 2477 | return byte_stream |
---|
| 2478 | |
---|
[305] | 2479 | # Local Variables: |
---|
| 2480 | # tab-width: 4; |
---|
| 2481 | # c-basic-offset: 4; |
---|
| 2482 | # c-file-offsets:((innamespace . 0)(inline-open . 0)); |
---|
| 2483 | # indent-tabs-mode: nil; |
---|
| 2484 | # End: |
---|
| 2485 | # |
---|
| 2486 | # vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 2487 | |
---|