Changeset 512 for soft/giet_vm
- Timestamp:
- Feb 14, 2015, 5:09:27 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_python/mapping.py
r497 r512 3 3 import sys 4 4 5 ######################################################################################## ##5 ######################################################################################## 6 6 # file : giet_mapping.py 7 7 # date : april 2014 8 8 # author : Alain Greiner 9 ######################################################################################## ##9 ######################################################################################## 10 10 # This file contains the classes required to define a mapping for the GIET_VM. 11 11 # - A 'Mapping' contains a set of 'Cluster' (hardware architecture) 12 # a set of 'Vseg' (kernel virtual segments mapping)13 # a set of 'Vspace' ( several user applications).14 # - A 'Cluster' contains a set of 'Pseg' ( allphysical segments in cluster)12 # a set of 'Vseg' (kernel virtual segments, called globals) 13 # a set of 'Vspace' (one or several user applications). 14 # - A 'Cluster' contains a set of 'Pseg' (physical segments in cluster) 15 15 # a set of 'Proc' (processors in cluster) 16 16 # a set of 'Periph' (peripherals in cluster) 17 17 # a set of 'Coproc' (coprocessors in cluster) 18 # - A 'Vspace' contains a set of 'Vseg' (user virtual segments mapping) 19 # a set of 'Task' (user tasks mapping) 20 # - A 'Vseg' contains a set of 'Vobj' 18 # - A 'Vspace' contains a set of 'Vseg' (user virtual segments) 19 # a set of 'Task' (user parallel tasks) 21 20 # - A 'Periph' contains a set of 'Irq' (only for XCU and PIC types ) 22 21 # - A 'Coproc' contains a set of 'Cpports' (one port per MWMR channel) 23 ######################################################################################## ##22 ######################################################################################## 24 23 # Implementation Note 25 # The variousobjects used to describe a mapping are distributed in the PYTHON structure:24 # The objects used to describe a mapping are distributed in the PYTHON structure: 26 25 # For example the psegs set is split in several subsets (one subset per cluster), 27 26 # or the tasks set is split in several subsets (one subset per vspace), etc... 28 27 # In the C binary data structure used by the giet_vm, all objects of same type 29 28 # are stored in a linear array (one single array for all psegs for example). 30 # For all objects, we compute and store in the PYTHON object itsel a "global index"29 # For all objects, we compute and store in the PYTHON object itself a "global index" 31 30 # corresponding to the index in this global array, and this index can be used as 32 31 # a pseudo-pointer to identify a specific object of a given type. 33 ######################################################################################## ##34 35 ######################################################################################## ##32 ######################################################################################## 33 34 ######################################################################################## 36 35 # Various constants 37 ######################################################################################## ##36 ######################################################################################## 38 37 39 38 PADDR_WIDTH = 40 # number of bits for physical address … … 47 46 MAPPING_SIGNATURE = 0xDACE2014 # Magic number indicating a valid C binary struture 48 47 49 ######################################################################################## ##48 ######################################################################################## 50 49 # These global lists must be consistent with enums in mapping_info.h or irq_handler. 51 ######################################################################################## ##50 ######################################################################################## 52 51 PERIPHTYPES = [ 53 52 'CMA', … … 97 96 ] 98 97 99 V OBJTYPES = [98 VSEGTYPES = [ 100 99 'ELF', 101 100 'BLOB', 102 101 'PTAB', 103 102 'PERI', 104 'MWMR', 105 'LOCK', 103 'MWMR', # deprecated 104 'LOCK', # deprecated 106 105 'BUFFER', 107 'BARRIER', 108 'CONST', 109 'MEMSPACE', 110 'SCHED', 106 'BARRIER', # deprecated 107 'CONST', # deprecated 108 'MEMSPACE', # deprecated 109 'SCHED', 111 110 'HEAP', 112 111 ] … … 142 141 ] 143 142 144 ####################################################################################### ###143 ####################################################################################### 145 144 class Mapping( object ): 146 ####################################################################################### ###145 ####################################################################################### 147 146 def __init__( self, 148 147 name, # mapping name … … 152 151 x_width = X_WIDTH, # number of bits encoding x coordinate 153 152 y_width = Y_WIDTH, # number of bits encoding y coordinate 154 p_width = P_WIDTH, # number of bits encoding l ocal proc_id153 p_width = P_WIDTH, # number of bits encoding lpid 155 154 paddr_width = PADDR_WIDTH, # number of bits for physical address 156 coherence = 1, # hardware cache coherence whennon-zero155 coherence = 1, # hardware cache coherence if non-zero 157 156 irq_per_proc = 1, # number or IRQs from XCU to processor 158 157 use_ramdisk = False, # use ramdisk when true … … 192 191 self.total_psegs = 0 193 192 self.total_vsegs = 0 194 self.total_vobjs = 0195 193 self.total_tasks = 0 196 194 self.total_procs = 0 … … 241 239 return pseg 242 240 243 ########################## ####add a peripheral and the associated pseg in a cluster241 ########################## add a peripheral and the associated pseg in a cluster 244 242 def addPeriph( self, 245 243 name, # associated pseg name … … 350 348 direction, # direction (TO_COPROC / FROM_COPROC) 351 349 vspacename, # name of vspace using the coproc 352 mwmrname ): # name of the v obj defining the MWMR channel350 mwmrname ): # name of the vseg containing the MWMR channel 353 351 354 352 assert direction in CP_PORT_DIRS … … 366 364 name, # vseg name 367 365 vbase, # virtual base address 368 size, # vobjlength (bytes)366 length, # vseg length (bytes) 369 367 mode, # CXWU flags 370 vtype, # v objtype368 vtype, # vseg type 371 369 x, # destination x coordinate 372 370 y, # destination y coordinate 373 371 pseg, # destination pseg name 374 372 identity = False, # identity mapping required if true 375 binpath = '', # pathname for binary code if required376 align = 0, # alignment required377 373 local = False, # only mapped in local PTAB if true 378 big = False ): # to be mapped in a big physical page 379 380 assert mode in VSEGMODES 381 382 assert vtype in VOBJTYPES 383 384 assert (x < self.x_size) and (y < self.y_size) 374 big = False, # to be mapped in a big physical page 375 binpath = '' ): # pathname for binary code if required 385 376 386 377 # two global vsegs must not overlap if they have different names 387 378 for prev in self.globs: 388 prev_vbase = prev.vbase 389 prev_size = prev.vobjs[0].length 390 391 if ( ((prev_vbase + prev_size) > vbase ) and 392 ((vbase + size) > prev_vbase) and 379 if ( ((prev.vbase + prev.length) > vbase ) and 380 ((vbase + length) > prev.vbase) and 393 381 (prev.name != name) ): 394 print '[genmap error] in addGlobal() : %s overlap %s' % (name, prev.name) 395 print ' %s : base = %x / size = %x' %( name, vbase, size ) 396 print ' %s : base = %x / size = %x' %( prev.name, prev_vbase, prev_size ) 382 print '[genmap error] in addGlobal()' 383 print ' global vseg %s overlap %s' % (name, prev.name) 384 print ' %s : base = %x / size = %x' %( name, vbase, size ) 385 print ' %s : base = %x / size = %x' %( prev.name, prev.vbase, prev.size ) 397 386 sys.exit(1) 398 387 399 388 # add one vseg into mapping 400 vseg = Vseg( name, vbase, mode, x, y, pseg,401 identity = identity, local = local, big = big )389 vseg = Vseg( name, vbase, length, mode, vtype, x, y, pseg, 390 identity = identity, local = local, big = big, binpath = binpath ) 402 391 403 392 self.globs.append( vseg ) … … 406 395 self.total_vsegs += 1 407 396 408 # add one vobj into mapping409 vobj = Vobj( name, size, vtype, binpath, 0, 0 )410 vseg.vobjs.append( vobj )411 vobj.index = self.total_vobjs412 self.total_vobjs += 1413 414 397 return 415 398 … … 417 400 def addVspace( self, 418 401 name, # vspace name 419 startname ): # name of v objcontaining start_vector402 startname ): # name of vseg containing start_vector 420 403 421 404 # add one vspace into mapping … … 427 410 return vspace 428 411 429 ################################# add a private vseg and a vobjin a vspace412 ################################# add a private vseg in a vspace 430 413 def addVseg( self, 431 414 vspace, # vspace containing the vseg 432 415 name, # vseg name 433 416 vbase, # virtual base address 434 size, # vobjlength (bytes)417 length, # vseg length (bytes) 435 418 mode, # CXWU flags 436 vtype, # v objtype419 vtype, # vseg type 437 420 x, # destination x coordinate 438 421 y, # destination y coordinate 439 422 pseg, # destination pseg name 440 binpath = '', # pathname for binary code441 align = 0, # alignment required442 init = 0, # initial value443 423 local = False, # only mapped in local PTAB if true 444 big = False ): # to be mapped in a big physical page 424 big = False, # to be mapped in a big physical page 425 binpath = '' ): # pathname for binary code 445 426 446 427 assert mode in VSEGMODES 447 428 448 assert vtype in V OBJTYPES429 assert vtype in VSEGTYPES 449 430 450 431 assert (x < self.x_size) and (y < self.y_size) 451 432 452 433 # add one vseg into mapping 453 vseg = Vseg( name, vbase, mode, x, y, pseg, local = local, big = big ) 434 vseg = Vseg( name, vbase, length, mode, vtype, x, y, pseg, 435 identity = False, local = local, big = big, binpath = binpath ) 454 436 vspace.vsegs.append( vseg ) 455 437 vseg.index = self.total_vsegs 456 438 self.total_vsegs += 1 457 439 458 # add one vobj into mapping459 vobj = Vobj( name, size, vtype, binpath, align, init )460 vseg.vobjs.append( vobj )461 vobj.index = self.total_vobjs462 self.total_vobjs += 1463 464 440 return vseg 465 466 ################################ add a vobj in a private vseg467 def addVobj( self,468 vseg, # vseg containing vobj469 name, # vobj name470 size, # vobj length (bytes)471 vtype, # vobj type472 binpath = '', # pathname to binary473 align = 0, # alignment constraint474 init = 0 ): # initial value475 476 assert vtype in VOBJTYPES477 478 # add one vobj into mapping479 vobj = Vobj( name, size, vtype, binpath, align, init )480 vseg.vobjs.append( vobj )481 vobj.index = self.total_vobjs482 self.total_vobjs += 1483 484 return vobj485 441 486 442 ################################ add a task in a vspace … … 492 448 y, # destination y coordinate 493 449 lpid, # destination processor local index 494 stackname, # name of v objcontaining stack495 heapname, # name of v objcontaining heap450 stackname, # name of vseg containing stack 451 heapname, # name of vseg containing heap 496 452 startid ): # index in start_vector 497 453 … … 518 474 byte_stream.append( '\0' ) 519 475 else: 520 print '[genmap error] in str2bytes() : string %s too long' % s 476 print '[genmap error] in str2bytes()' 477 print ' string %s too long' % s 521 478 sys.exit(1) 522 479 … … 532 489 return byte_stream 533 490 534 ################ ####################################################################491 ################ 535 492 def xml( self ): # compute string for map.xml file generation 536 493 … … 568 525 return s 569 526 570 ########################## ###########################################################527 ########################## 571 528 def cbin( self, verbose ): # C binary structure for map.bin file generation 572 529 … … 587 544 byte_stream += self.int2bytes(4, self.total_psegs) 588 545 byte_stream += self.int2bytes(4, self.total_vsegs) 589 byte_stream += self.int2bytes(4, self.total_vobjs)590 546 byte_stream += self.int2bytes(4, self.total_tasks) 591 547 byte_stream += self.int2bytes(4, self.total_procs) … … 611 567 print 'total_psegs = %d' % self.total_psegs 612 568 print 'total_vsegs = %d' % self.total_vsegs 613 print 'total_vobjs = %d' % self.total_vobjs614 569 print 'total_tasks = %d' % self.total_tasks 615 570 print 'total_procs = %d' % self.total_procs … … 657 612 if ( verbose ): print '\n' 658 613 659 # vobjs array660 index = 0661 for vseg in self.globs:662 for vobj in vseg.vobjs:663 byte_stream += vobj.cbin( self, verbose, index )664 index += 1665 for vspace in self.vspaces:666 for vseg in vspace.vsegs:667 for vobj in vseg.vobjs:668 byte_stream += vobj.cbin( self, verbose, index )669 index += 1670 671 if ( verbose ): print '\n'672 673 614 # tasks array 674 615 index = 0 … … 743 684 if ( vseg.name == 'seg_boot_code' ): 744 685 boot_code_vbase = vseg.vbase 745 boot_code_size = vseg. vobjs[0].length686 boot_code_size = vseg.length 746 687 boot_code_found = True 747 688 748 689 if ( vseg.name == 'seg_boot_data' ): 749 690 boot_data_vbase = vseg.vbase 750 boot_data_size = vseg. vobjs[0].length691 boot_data_size = vseg.length 751 692 boot_data_found = True 752 753 if ( vseg.name == 'seg_kernel_uncdata' ):754 kernel_uncdata_vbase = vseg.vbase755 kernel_uncdata_size = vseg.vobjs[0].length756 kernel_uncdata_found = True757 693 758 694 if ( vseg.name == 'seg_kernel_data' ): 759 695 kernel_data_vbase = vseg.vbase 760 kernel_data_size = vseg. vobjs[0].length696 kernel_data_size = vseg.length 761 697 kernel_data_found = True 762 698 763 699 if ( vseg.name == 'seg_kernel_code' ): 764 700 kernel_code_vbase = vseg.vbase 765 kernel_code_size = vseg. vobjs[0].length701 kernel_code_size = vseg.length 766 702 kernel_code_found = True 767 703 768 704 if ( vseg.name == 'seg_kernel_init' ): 769 705 kernel_init_vbase = vseg.vbase 770 kernel_init_size = vseg. vobjs[0].length706 kernel_init_size = vseg.length 771 707 kernel_init_found = True 772 708 773 709 # check if all required vsegs have been found 774 710 if ( boot_code_found == False ): 775 print '[genmap error] in giet_vsegs() : seg_boot_code vseg missing' 711 print '[genmap error] in giet_vsegs()' 712 print ' seg_boot_code vseg missing' 776 713 sys.exit() 777 714 778 715 if ( boot_data_found == False ): 779 print '[genmap error] in giet_vsegs() : seg_boot_data vseg missing' 716 print '[genmap error] in giet_vsegs()' 717 print ' seg_boot_data vseg missing' 780 718 sys.exit() 781 719 782 720 if ( kernel_data_found == False ): 783 print '[genmap error] in giet_vsegs() : seg_kernel_data vseg missing' 721 print '[genmap error] in giet_vsegs()' 722 print ' seg_kernel_data vseg missing' 784 723 sys.exit() 785 724 786 if ( kernel_uncdata_found == False ): 787 print '[genmap error] in giet_vsegs() : seg_kernel_uncdata vseg missing' 725 if ( kernel_code_found == False ): 726 print '[genmap error] in giet_vsegs()' 727 print ' seg_kernel_code vseg missing' 788 728 sys.exit() 789 729 790 if ( kernel_code_found == False ):791 print '[genmap error] in giet_vsegs() : seg_kernel_code vseg missing'792 sys.exit()793 794 730 if ( kernel_init_found == False ): 795 print '[genmap error] in giet_vsegs() : seg_kernel_init vseg missing' 731 print '[genmap error] in giet_vsegs()' 732 print ' seg_kernel_init vseg missing' 796 733 sys.exit() 797 734 … … 811 748 s += 'kernel_data_vbase = 0x%x;\n' % kernel_data_vbase 812 749 s += 'kernel_data_size = 0x%x;\n' % kernel_data_size 813 s += '\n'814 s += 'kernel_uncdata_vbase = 0x%x;\n' % kernel_uncdata_vbase815 s += 'kernel_uncdata_size = 0x%x;\n' % kernel_uncdata_size816 750 s += '\n' 817 751 s += 'kernel_init_vbase = 0x%x;\n' % kernel_init_vbase … … 1044 978 if ( vseg.name == 'seg_boot_mapping' ): 1045 979 boot_mapping_base = vseg.vbase 1046 boot_mapping_size = vseg. vobjs[0].length980 boot_mapping_size = vseg.length 1047 981 boot_mapping_identity = vseg.identity 1048 982 boot_mapping_found = True … … 1050 984 if ( vseg.name == 'seg_boot_code' ): 1051 985 boot_code_base = vseg.vbase 1052 boot_code_size = vseg. vobjs[0].length986 boot_code_size = vseg.length 1053 987 boot_code_identity = vseg.identity 1054 988 boot_code_found = True … … 1056 990 if ( vseg.name == 'seg_boot_data' ): 1057 991 boot_data_base = vseg.vbase 1058 boot_data_size = vseg. vobjs[0].length992 boot_data_size = vseg.length 1059 993 boot_data_identity = vseg.identity 1060 994 boot_data_found = True … … 1062 996 if ( vseg.name == 'seg_boot_stack' ): 1063 997 boot_stack_base = vseg.vbase 1064 boot_stack_size = vseg. vobjs[0].length998 boot_stack_size = vseg.length 1065 999 boot_stack_identity = vseg.identity 1066 1000 boot_stack_found = True … … 1068 1002 # check that BOOT vsegs are found and identity mapping 1069 1003 if ( (boot_mapping_found == False) or (boot_mapping_identity == False) ): 1070 print '[genmap error] in hard_config() : seg_boot_mapping missing or not ident' 1004 print '[genmap error] in hard_config()' 1005 print ' seg_boot_mapping missing or not identity mapping' 1071 1006 sys.exit() 1072 1007 1073 1008 if ( (boot_code_found == False) or (boot_code_identity == False) ): 1074 print '[genmap error] in hard_config() : seg_boot_code missing or not ident' 1009 print '[genmap error] in hard_config()' 1010 print ' seg_boot_code missing or not identity mapping' 1075 1011 sys.exit() 1076 1012 1077 1013 if ( (boot_data_found == False) or (boot_data_identity == False) ): 1078 print '[genmap error] in hard_config() : seg_boot_data missing or not ident' 1014 print '[genmap error] in hard_config()' 1015 print ' seg_boot_data missing or not identity mapping' 1079 1016 sys.exit() 1080 1017 1081 1018 if ( (boot_stack_found == False) or (boot_stack_identity == False) ): 1082 print '[genmap error] in giet_vsegs() : seg_boot_stack missing or not ident' 1019 print '[genmap error] in giet_vsegs()' 1020 print ' seg_boot_stask missing or not identity mapping' 1083 1021 sys.exit() 1084 1022 … … 1092 1030 if ( vseg.name == 'seg_ramdisk' ): 1093 1031 seg_rdk_base = vseg.vbase 1094 seg_rdk_size = vseg. vobjs[0].length1032 seg_rdk_size = vseg.length 1095 1033 seg_rdk_found = True 1096 1034 … … 1301 1239 s += ' interrupt-controller;\n' 1302 1240 s += ' #interrupt-cells = <1>;\n' 1303 s += ' clocks = <&freq>;\n' # the XCU componentcontains a timer1241 s += ' clocks = <&freq>;\n' # XCU contains a timer 1304 1242 s += ' reg = <0x%x 0x%x 0x%x>;\n' % (msb, lsb, size) 1305 1243 s += ' };\n\n' … … 1319 1257 1320 1258 # we need one interrupt controler in any cluster containing peripherals 1321 if ( (found_xcu == False) and (found_pic == False) and (len(cluster.periphs) > 0) ): 1322 print '[genmap error] in linux_dts() : No XCU/PIC in cluster(%d,%d)' % (x,y) 1259 if ( (found_xcu == False) and 1260 (found_pic == False) and 1261 (len(cluster.periphs) > 0) ): 1262 print '[genmap error] in linux_dts()' 1263 print ' No XCU/PIC in cluster(%d,%d)' % (x,y) 1323 1264 sys.exit(1) 1324 1265 … … 1338 1279 hwi_id = 0xFFFFFFFF 1339 1280 for irq in irq_ctrl.irqs: 1340 if ( (irq.isrtype == 'ISR_TTY_RX') and (irq.channel == 0) ): hwi_id = irq.srcid 1281 if ( (irq.isrtype == 'ISR_TTY_RX') and (irq.channel == 0) ): 1282 hwi_id = irq.srcid 1283 1341 1284 if ( hwi_id == 0xFFFFFFFF ): 1342 print '[genmap error] in linux.dts() IRQ_TTY_RX not found' 1285 print '[genmap error] in linux.dts()' 1286 print ' IRQ_TTY_RX not found' 1343 1287 sys.exit(1) 1344 1288 … … 1359 1303 for irq in irq_ctrl.irqs: 1360 1304 if ( irq.isrtype == 'ISR_BDV' ): hwi_id = irq.srcid 1305 1361 1306 if ( hwi_id == 0xFFFFFFFF ): 1362 print '[genmap error] in linux.dts() ISR_BDV not found' 1307 print '[genmap error] in linux.dts()' 1308 print ' ISR_BDV not found' 1363 1309 sys.exit(1) 1364 1310 … … 1372 1318 elif ( periph.subtype == 'HBA' ): 1373 1319 1374 print '[genmap error] in linux_dts() : HBA peripheral not supported by LINUX' 1320 print '[genmap error] in linux_dts()' 1321 print ' HBA peripheral not supported by LINUX' 1375 1322 sys.exit(1) 1376 1323 1377 1324 elif ( periph.subtype == 'SPI' ): 1378 1325 1379 print '[genmap error] in linux_dts() : SPI peripheral not supported by LINUX' 1326 print '[genmap error] in linux_dts()' 1327 print ' SPI peripheral not supported by LINUX' 1380 1328 sys.exit(1) 1381 1329 … … 1386 1334 # other peripherals 1387 1335 else: 1388 type = periph.ptype1389 print ' [genmap warning] in linux_dts() : %s peripheral not supported by LINUX' % (type)1336 print '[genmap warning] in linux_dts()' 1337 print ' %s peripheral not supported by LINUX' % (periph.ptype) 1390 1338 1391 1339 # clocks … … 1508 1456 # at least one interrupt controller 1509 1457 if ( (found_xcu == False) and (found_pic == False) and (len(cluster.periphs) > 0) ): 1510 print '[genmap error] in netbsd_dts() : No XCU/PIC in cluster(%d,%d)' % (x,y) 1458 print '[genmap error] in netbsd_dts()' 1459 print ' No XCU/PIC in cluster(%d,%d)' % (x,y) 1511 1460 sys.exit(1) 1512 1461 … … 1534 1483 if ( (irq.isrtype == 'ISR_DMA') and (irq.channel == channel) ): 1535 1484 hwi_id = irq.srcid 1485 1536 1486 if ( hwi_id == 0xFFFFFFFF ): 1537 print '[genmap error] in netbsd.dts() ISR_DMA channel %d not found' % channel 1487 print '[genmap error] in netbsd.dts()' 1488 print ' ISR_DMA channel %d not found' % channel 1538 1489 sys.exit(1) 1539 1490 … … 1555 1506 for irq in xcu.irqs: 1556 1507 if ( irq.isrtype == 'ISR_MMC' ): irq_in = irq.srcid 1508 1557 1509 if ( irq_in == 0xFFFFFFFF ): 1558 print '[genmap error] in netbsd.dts() ISR_MMC not found' 1510 print '[genmap error] in netbsd.dts()' 1511 print ' ISR_MMC not found' 1559 1512 sys.exit(1) 1560 1513 … … 1586 1539 if ( irq.isrtype == 'ISR_BDV' ): irq_in = irq.srcid 1587 1540 if ( irq_in == 0xFFFFFFFF ): 1588 print '[genmap error] in netbsd.dts() ISR_BDV not found' 1541 print '[genmap error] in netbsd.dts()' 1542 print ' ISR_BDV not found' 1589 1543 sys.exit(1) 1590 1544 … … 1596 1550 1597 1551 elif ( periph.subtype == 'HBA' ): 1598 print '[genmap error] in netbsd_dts() : HBA peripheral not supported by NetBSD' 1552 print '[genmap error] in netbsd_dts()' 1553 print ' HBA peripheral not supported by NetBSD' 1599 1554 sys.exit(1) 1600 1555 … … 1606 1561 if ( irq.isrtype == 'ISR_SPI' ): irq_in = irq.srcid 1607 1562 if ( irq_in == 0xFFFFFFFF ): 1608 print '[genmap error] in netbsd.dts() ISR_SPI not found' 1563 print '[genmap error] in netbsd.dts()' 1564 print ' ISR_SPI not found' 1609 1565 sys.exit(1) 1610 1566 … … 1647 1603 hwi_id = irq.srcid 1648 1604 if ( hwi_id == 0xFFFFFFFF ): 1649 print '[genmap error] in netbsd.dts() ISR_TTY_RX channel %d not found' % channel 1605 print '[genmap error] in netbsd.dts()' 1606 print ' ISR_TTY_RX channel %d not found' % channel 1650 1607 sys.exit(1) 1651 1608 … … 1684 1641 hwi_id = irq.srcid 1685 1642 if ( hwi_id == 0xFFFFFFFF ): 1686 print '[genmap error] in netbsd.dts() ISR_NIC_RX channel %d not found' % channel 1643 print '[genmap error] in netbsd.dts()' 1644 print ' ISR_NIC_RX channel %d not found' % channel 1687 1645 sys.exit(1) 1688 1646 … … 1700 1658 hwi_id = irq.srcid 1701 1659 if ( hwi_id == 0xFFFFFFFF ): 1702 print '[genmap error] in netbsd.dts() ISR_NIC_TX channel %d not found' % channel 1660 print '[genmap error] in netbsd.dts()' 1661 print ' ISR_NIC_TX channel %d not found' % channel 1703 1662 sys.exit(1) 1704 1663 … … 1727 1686 if ( (irq.isrtype == 'ISR_CMA') and (irq.channel == channel) ): 1728 1687 hwi_id = irq.srcid 1688 1729 1689 if ( hwi_id == 0xFFFFFFFF ): 1730 print '[genmap error] in netbsd.dts() ISR_CMA channel %d not found' % channel 1690 print '[genmap error] in netbsd.dts()' 1691 print ' ISR_CMA channel %d not found' % channel 1731 1692 sys.exit(1) 1732 1693 … … 1744 1705 elif ( periph.ptype == 'TIM' ): 1745 1706 1746 print '[genmap error] in netbsd_dts() : TIM peripheral not supported by NetBSD' 1707 print '[genmap error] in netbsd_dts()' 1708 print ' TIM peripheral not supported by NetBSD' 1747 1709 sys.exit(1) 1748 1710 … … 1750 1712 elif ( periph.ptype == 'MWR' ): 1751 1713 1752 print '[genmap error] in netbsd_dts() : MWR peripheral not supported by NetBSD' 1714 print '[genmap error] in netbsd_dts()' 1715 print ' MWR peripheral not supported by NetBSD' 1753 1716 sys.exit(1) 1754 1717 … … 1935 1898 # check index 1936 1899 if (self.index != expected): 1937 print '[genmap error] in Cluster.cbin() : cluster global index = %d / expected = %d' \1938 % (self.index, expected)1900 print '[genmap error] in Cluster.cbin()' 1901 print ' cluster global index = %d / expected = %d' % (self.index,expected) 1939 1902 sys.exit(1) 1940 1903 … … 1964 1927 1965 1928 byte_stream = bytearray() 1966 byte_stream += mapping.int2bytes( 4 , self.x ) 1967 byte_stream += mapping.int2bytes( 4 , self.y ) 1968 byte_stream += mapping.int2bytes( 4 , len( self.psegs ) ) # number ofpsegs in cluster1969 byte_stream += mapping.int2bytes( 4 , pseg_id ) 1970 byte_stream += mapping.int2bytes( 4 , len( self.procs ) ) # number ofprocs in cluster1971 byte_stream += mapping.int2bytes( 4 , proc_id ) 1972 byte_stream += mapping.int2bytes( 4 , len( self.coprocs ) ) # number ofcoprocs in cluster1973 byte_stream += mapping.int2bytes( 4 , coproc_id ) 1974 byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number ofperiphs in cluster1975 byte_stream += mapping.int2bytes( 4 , periph_id ) 1929 byte_stream += mapping.int2bytes( 4 , self.x ) # x coordinate 1930 byte_stream += mapping.int2bytes( 4 , self.y ) # x coordinate 1931 byte_stream += mapping.int2bytes( 4 , len( self.psegs ) ) # number psegs in cluster 1932 byte_stream += mapping.int2bytes( 4 , pseg_id ) # first pseg global index 1933 byte_stream += mapping.int2bytes( 4 , len( self.procs ) ) # number procs in cluster 1934 byte_stream += mapping.int2bytes( 4 , proc_id ) # first proc global index 1935 byte_stream += mapping.int2bytes( 4 , len( self.coprocs ) ) # number coprocs in cluster 1936 byte_stream += mapping.int2bytes( 4 , coproc_id ) # first coproc global index 1937 byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster 1938 byte_stream += mapping.int2bytes( 4 , periph_id ) # first periph global index 1976 1939 1977 1940 if ( verbose ): … … 1987 1950 return byte_stream 1988 1951 1989 ######################################################################################## ###1952 ######################################################################################## 1990 1953 class Vspace( object ): 1991 ######################################################################################## ###1954 ######################################################################################## 1992 1955 def __init__( self, 1993 1956 name, … … 1996 1959 self.index = 0 # global index ( set by addVspace() ) 1997 1960 self.name = name # vspace name 1998 self.startname = startname # name of v objcontaining the start_vector1961 self.startname = startname # name of vseg containing the start_vector 1999 1962 self.vsegs = [] 2000 1963 self.tasks = [] … … 2020 1983 # check index 2021 1984 if (self.index != expected): 2022 print '[genmap error] in Vspace.cbin() : vspace global index = %d / expected = %d' \2023 % (self.index, expected)1985 print '[genmap error] in Vspace.cbin()' 1986 print ' vspace global index = %d / expected = %d' %(self.index,expected) 2024 1987 sys.exit(1) 2025 1988 2026 # compute global index for v objcontaining start_vector2027 v obj_start_id = 0xFFFFFFFF1989 # compute global index for vseg containing start_vector 1990 vseg_start_id = 0xFFFFFFFF 2028 1991 for vseg in self.vsegs: 2029 if ( vseg. vobjs[0].name == self.startname ):2030 vobj_start_id = vseg.vobjs[0].index 2031 if ( v obj_start_id == 0xFFFFFFFF ):2032 print '[genmap error] in Vspace.cbin() : startname %s not found for vspace %s' \2033 % ( self.startname, self.name)1992 if ( vseg.name == self.startname ): vseg_start_id = vseg.index 1993 1994 if ( vseg_start_id == 0xFFFFFFFF ): 1995 print '[genmap error] in Vspace.cbin()' 1996 print ' startname %s not found for vspace %s' %(self.startname,self.name) 2034 1997 sys.exit(1) 2035 1998 2036 # compute first vseg , vobj,task global index1999 # compute first vseg and first task global index 2037 2000 first_vseg_id = self.vsegs[0].index 2038 first_vobj_id = self.vsegs[0].vobjs[0].index2039 2001 first_task_id = self.tasks[0].index 2040 2002 2041 # compute number of vobjs, tasks,vsegs2003 # compute number of tasks and number of vsegs 2042 2004 nb_vsegs = len( self.vsegs ) 2043 2005 nb_tasks = len( self.tasks ) 2044 nb_vobjs = 02045 for vseg in self.vsegs:2046 nb_vobjs += len( vseg.vobjs )2047 2006 2048 2007 byte_stream = bytearray() 2049 2008 byte_stream += mapping.str2bytes( 32, self.name ) # vspace name 2050 byte_stream += mapping.int2bytes( 4, v obj_start_id ) # vobjstart_vector2009 byte_stream += mapping.int2bytes( 4, vseg_start_id ) # vseg start_vector 2051 2010 byte_stream += mapping.int2bytes( 4, nb_vsegs ) # number of vsegs 2052 byte_stream += mapping.int2bytes( 4, nb_vobjs ) # number of vobjs2053 2011 byte_stream += mapping.int2bytes( 4, nb_tasks ) # number of tasks 2054 2012 byte_stream += mapping.int2bytes( 4, first_vseg_id ) # first vseg global index 2055 byte_stream += mapping.int2bytes( 4, first_vobj_id ) # first vobj global index2056 2013 byte_stream += mapping.int2bytes( 4, first_task_id ) # first task global index 2057 2014 2058 2015 if ( verbose ): 2059 print 'start_id = %d' % v obj_start_id2016 print 'start_id = %d' % vseg_start_id 2060 2017 print 'nb_vsegs = %d' % nb_vsegs 2061 print 'nb_vobjs = %d' % nb_vobjs2062 2018 print 'nb_tasks = %d' % nb_tasks 2063 2019 print 'vseg_id = %d' % first_vseg_id 2064 print 'vobj_id = %d' % first_vobj_id2065 2020 print 'task_id = %d' % first_task_id 2066 2021 2067 2022 return byte_stream 2068 2023 2069 ######################################################################################## ###2024 ######################################################################################## 2070 2025 class Task( object ): 2071 ######################################################################################## ###2026 ######################################################################################## 2072 2027 def __init__( self, 2073 2028 name, … … 2086 2041 self.y = y # cluster y coordinate 2087 2042 self.p = p # processor local index 2088 self.stackname = stackname # name of v objcontaining the stack2089 self.heapname = heapname # name of v objcontaining the heap2043 self.stackname = stackname # name of vseg containing the stack 2044 self.heapname = heapname # name of vseg containing the heap 2090 2045 self.startid = startid # index in start_vector 2091 2046 return … … 2099 2054 s += ' y="%d"' % self.y 2100 2055 s += ' p="%d"' % self.p 2056 s += '\n ' 2101 2057 s += ' stackname="%s"' % self.stackname 2102 2058 s += ' heapname="%s"' % self.heapname … … 2114 2070 # check index 2115 2071 if (self.index != expected): 2116 print '[genmap error] in Task.cbin() : task global index = %d / expected = %d' \2117 % (self.index, expected)2072 print '[genmap error] in Task.cbin()' 2073 print ' task global index = %d / expected = %d' %(self.index,expected) 2118 2074 sys.exit(1) 2119 2075 … … 2121 2077 cluster_id = (self.x * mapping.y_size) + self.y 2122 2078 2123 # compute v obj localindex for stack2124 v obj_stack_id = 0xFFFFFFFF2079 # compute vseg index for stack 2080 vseg_stack_id = 0xFFFFFFFF 2125 2081 for vseg in vspace.vsegs: 2126 if ( vseg.vobjs[0].name == self.stackname ): 2127 vobj_stack_id = vseg.vobjs[0].index 2128 if ( vobj_stack_id == 0xFFFFFFFF ): 2129 print '[genmap error] in Task.cbin() : stackname %s not found for task %s in vspace %s' \ 2082 if ( vseg.name == self.stackname ): vseg_stack_id = vseg.index 2083 2084 if ( vseg_stack_id == 0xFFFFFFFF ): 2085 print '[genmap error] in Task.cbin()' 2086 print ' stackname %s not found for task %s in vspace %s' \ 2130 2087 % ( self.stackname, self.name, vspace.name ) 2131 2088 sys.exit(1) 2132 2089 2133 # compute v obj localindex for heap2090 # compute vseg index for heap 2134 2091 if ( self.heapname == '' ): 2135 v obj_heap_id = 02092 vseg_heap_id = 0 2136 2093 else: 2137 v obj_heap_id = 0xFFFFFFFF2094 vseg_heap_id = 0xFFFFFFFF 2138 2095 for vseg in vspace.vsegs: 2139 if ( vseg.vobjs[0].name == self.heapname ): 2140 vobj_heap_id = vseg.vobjs[0].index 2141 if ( vobj_heap_id == 0xFFFFFFFF ): 2142 print '[genmap error] in Task.cbin() : heapname %s not found for task %s in vspace %s' \ 2096 if ( vseg.name == self.heapname ): vseg_heap_id = vseg.index 2097 2098 if ( vseg_heap_id == 0xFFFFFFFF ): 2099 print '[genmap error] in Task.cbin()' 2100 print ' heapname %s not found for task %s in vspace %s' \ 2143 2101 % ( self.heapname, self.name, vspace.name ) 2144 2102 sys.exit(1) … … 2147 2105 byte_stream += mapping.str2bytes( 32, self.name ) # task name in vspace 2148 2106 byte_stream += mapping.int2bytes( 4, cluster_id ) # cluster global index 2149 byte_stream += mapping.int2bytes( 4, self.p ) # processor local index in cluster2107 byte_stream += mapping.int2bytes( 4, self.p ) # processor local index 2150 2108 byte_stream += mapping.int2bytes( 4, self.trdid ) # thread local index in vspace 2151 byte_stream += mapping.int2bytes( 4, v obj_stack_id ) # stack vobjlocal index2152 byte_stream += mapping.int2bytes( 4, v obj_heap_id ) # heap vobjlocal index2109 byte_stream += mapping.int2bytes( 4, vseg_stack_id ) # stack vseg local index 2110 byte_stream += mapping.int2bytes( 4, vseg_heap_id ) # heap vseg local index 2153 2111 byte_stream += mapping.int2bytes( 4, self.startid ) # index in start vector 2154 2112 … … 2157 2115 print 'lpid = %d' % self.p 2158 2116 print 'trdid = %d' % self.trdid 2159 print 'stackid = %d' % v obj_stack_id2160 print 'heapid = %d' % v obj_heap_id2117 print 'stackid = %d' % vseg_stack_id 2118 print 'heapid = %d' % vseg_heap_id 2161 2119 print 'startid = %d' % self.startid 2162 2120 2163 2121 return byte_stream 2164 2122 2165 ######################################################################################## ###2123 ######################################################################################## 2166 2124 class Vseg( object ): 2167 ######################################################################################## ###2125 ######################################################################################## 2168 2126 def __init__( self, 2169 2127 name, 2170 2128 vbase, 2129 length, 2171 2130 mode, 2131 vtype, 2172 2132 x, 2173 2133 y, 2174 pseg name,2134 pseg, 2175 2135 identity = False, 2176 2136 local = False, 2177 big = False ): 2137 big = False, 2138 binpath = '' ): 2139 2140 assert (vbase & 0xFFFFFFFF) == vbase 2141 2142 assert (length & 0xFFFFFFFF) == length 2178 2143 2179 2144 assert mode in VSEGMODES 2180 2145 2146 assert vtype in VSEGTYPES 2147 2148 assert (vtype != 'ELF') or (binpath != '') 2149 2181 2150 self.index = 0 # global index ( set by addVseg() ) 2182 self.name = name # vseg name 2183 self.vbase = vbase & 0xFFFFFFFF # virtual base address in vspace 2151 self.name = name # vseg name (unique in vspace) 2152 self.vbase = vbase # virtual base address in vspace 2153 self.length = length # vseg length (bytes) 2154 self.vtype = vtype # vseg type (defined in VSEGTYPES) 2184 2155 self.mode = mode # CXWU access rights 2185 2156 self.x = x # x coordinate of destination cluster 2186 2157 self.y = y # y coordinate of destination cluster 2187 self.psegname = pseg name# name of pseg in destination cluster2158 self.psegname = pseg # name of pseg in destination cluster 2188 2159 self.identity = identity # identity mapping required 2189 2160 self.local = local # only mapped in local PTAB when true 2190 2161 self.big = big # to be mapped in a big physical page 2191 self.vobjs = [] 2162 self.binpath = binpath # path name for binary file (ELF or BLOB) 2163 2192 2164 return 2193 2165 … … 2195 2167 def xml( self ): # xml for one vseg 2196 2168 2197 s = ' <vseg name="%s" vbase="0x%x" mode="%s" x="%d" y="%d" psegname="%s"' \ 2198 % ( self.name, self.vbase, self.mode, self.x, self.y, self.psegname ) 2199 if ( self.identity ): s += ' ident="1"' 2200 if ( self.local ): s += ' local="1"' 2201 if ( self.big ): s += ' big="1"' 2202 s += ' >\n' 2203 for vobj in self.vobjs: s += vobj.xml() 2204 s += ' </vseg>\n' 2169 s = ' <vseg name="%s"' %(self.name) 2170 s += ' vbase="0x%x"' %(self.vbase) 2171 s += ' length="0x%x"' %(self.length) 2172 s += ' type="%s"' %(self.vtype) 2173 s += ' mode="%s"' %(self.mode) 2174 s += '\n ' 2175 s += ' x="%d"' %(self.x) 2176 s += ' y="%d"' %(self.y) 2177 s += ' psegname="%s"' %(self.psegname) 2178 if ( self.identity ): s += ' ident="1"' 2179 if ( self.local ): s += ' local="1"' 2180 if ( self.big ): s += ' big="1"' 2181 if ( self.binpath != '' ): s += ' binpath="%s"' %(self.binpath) 2182 s += ' />\n' 2205 2183 2206 2184 return s … … 2214 2192 # check index 2215 2193 if (self.index != expected): 2216 print '[genmap error] in Vseg.cbin() : vseg global index = %d / expected = %d' \ 2194 print '[genmap error] in Vseg.cbin()' 2195 print ' vseg global index = %d / expected = %d' \ 2217 2196 % (self.index, expected ) 2218 2197 sys.exit(1) … … 2226 2205 pseg_id = pseg.index 2227 2206 if (pseg_id == 0xFFFFFFFF): 2228 print '[genmap error] in Vseg.cbin() : psegname %s not found for vseg %s in cluster %d' \ 2207 print '[genmap error] in Vseg.cbin() : ' 2208 print ' psegname %s not found for vseg %s in cluster %d' \ 2229 2209 % ( self.psegname, self.name, cluster_id ) 2230 2210 sys.exit(1) … … 2236 2216 mode_id = x 2237 2217 if ( mode_id == 0xFFFFFFFF ): 2238 print '[genmap error] in Vseg.cbin() : undefined vseg mode %s' % self.mode 2218 print '[genmap error] in Vseg.cbin() : ' 2219 print ' undefined vseg mode %s' % self.mode 2239 2220 sys.exit(1) 2240 2221 2241 # compute vobj_id 2242 vobj_id = self.vobjs[0].index 2222 # compute numerical value for vtype 2223 vtype_id = 0xFFFFFFFF 2224 for x in xrange( len(VSEGTYPES) ): 2225 if ( self.vtype == VSEGTYPES[x] ): 2226 vtype_id = x 2227 if ( vtype_id == 0xFFFFFFFF ): 2228 print '[genmap error] in Vseg.cbin()' 2229 print ' undefined vseg type %s' % self.vtype 2230 sys.exit(1) 2243 2231 2244 2232 byte_stream = bytearray() 2245 2233 byte_stream += mapping.str2bytes( 32, self.name ) # vseg name 2234 byte_stream += mapping.str2bytes( 64, self.binpath ) # binpath 2246 2235 byte_stream += mapping.int2bytes( 4, self.vbase ) # virtual base address 2247 2236 byte_stream += mapping.int2bytes( 8, 0 ) # physical base address 2248 byte_stream += mapping.int2bytes( 4, 0 )# vseg size (bytes)2249 byte_stream += mapping.int2bytes( 4, pseg_id ) # p hysical segmentglobal index2237 byte_stream += mapping.int2bytes( 4, self.length ) # vseg size (bytes) 2238 byte_stream += mapping.int2bytes( 4, pseg_id ) # pseg global index 2250 2239 byte_stream += mapping.int2bytes( 4, mode_id ) # CXWU flags 2251 byte_stream += mapping.int2bytes( 4, len(self.vobjs) ) # number of vobjs in vseg 2252 byte_stream += mapping.int2bytes( 4, vobj_id ) # first vobj global index 2253 byte_stream += mapping.int2bytes( 4, 0 ) # linked list of vsegs on pseg 2240 byte_stream += mapping.int2bytes( 4, vtype_id ) # vseg type 2254 2241 byte_stream += mapping.int2bytes( 1, 0 ) # mapped when non zero 2255 byte_stream += mapping.int2bytes( 1, self.identity ) # identity mapping if non zero2242 byte_stream += mapping.int2bytes( 1, self.identity ) # identity mapping 2256 2243 byte_stream += mapping.int2bytes( 1, self.local ) # only mapped in local PTAB 2257 byte_stream += mapping.int2bytes( 1, self.big ) # to be mapped in big physical page 2258 2259 if ( verbose ): 2260 print 'vbase = %x' % self.vbase 2261 print 'pseg_id = %d' % pseg_id 2262 print 'mode = %s' % self.mode 2263 print 'nb_vobjs = %d' % len(self.vobjs) 2264 print 'vobj_id = %d' % vobj_id 2265 2266 return byte_stream 2267 2268 ########################################################################################### 2269 class Vobj( object ): 2270 ########################################################################################### 2271 def __init__( self, 2272 name, 2273 length, 2274 vtype, 2275 binpath = '', 2276 align = 0, 2277 init = 0 ): 2278 2279 assert vtype in ['ELF','BLOB','PTAB','PERI','MWMR','LOCK', \ 2280 'BUFFER','BARRIER','CONST','MEMSPACE','SCHED','HEAP'] 2281 2282 assert (vtype != 'ELF') or (binpath != '') 2283 2284 self.index = 0 # global index ( set by addVobj() ) 2285 self.name = name # vobj name (unique in vspace) 2286 self.vtype = vtype # vobj type (defined in mapping_info.h) 2287 self.length = length # vobj size (bytes) 2288 self.binpath = binpath # pathname for (ELF type) 2289 self.align = align # required alignment (logarithm of 2) 2290 self.init = init # initialisation value (for BARRIER or MWMR types) 2291 2292 return 2293 2294 ################ 2295 def xml( self ): # xml for a vobj 2296 2297 s = ' <vobj name="%s" type="%s" length="0x%x"' \ 2298 % ( self.name, self.vtype, self.length ) 2299 if (self.binpath != ''): s += ' binpath="%s"' % (self.binpath) 2300 if (self.align != 0 ): s += ' align="%d"' % (self.align) 2301 if (self.init != 0 ): s += ' init="%d"' % (self.init) 2302 s += ' />\n' 2303 2304 return s 2305 2306 ############################################# 2307 def cbin( self, mapping, verbose, expected ): # C binary structure for Vobj 2308 2309 # check index 2310 if (self.index != expected): 2311 print '[genmap error] in Vobj.cbin() : vobj global index = %d / expected = %d' \ 2312 % (self.index, expected ) 2313 sys.exit(1) 2314 elif ( verbose ): 2315 print '*** cbin for vobj[%d] %s' % (self.index, self.name) 2316 2317 # compute numerical value for vtype 2318 vtype_int = 0xFFFFFFFF 2319 for x in xrange( len(VOBJTYPES) ): 2320 if ( self.vtype == VOBJTYPES[x] ): 2321 vtype_int = x 2322 if ( vtype_int == 0xFFFFFFFF ): 2323 print '[genmap error] in Vobj.cbin() : undefined vobj type %s' % self.vtype 2324 sys.exit(1) 2325 2326 byte_stream = bytearray() 2327 byte_stream += mapping.str2bytes( 32, self.name ) # vobj name 2328 byte_stream += mapping.str2bytes( 64, self.binpath ) # pathname for .elf file 2329 byte_stream += mapping.int2bytes( 4 , vtype_int ) # vobj type 2330 byte_stream += mapping.int2bytes( 4 , self.length ) # vobj size 2331 byte_stream += mapping.int2bytes( 4 , self.align ) # required alignment 2332 byte_stream += mapping.int2bytes( 4 , 0 ) # virtual base address 2333 byte_stream += mapping.int2bytes( 4 , self.init ) # init value 2244 byte_stream += mapping.int2bytes( 1, self.big ) # to be mapped in BPP 2334 2245 2335 2246 if ( verbose ): 2336 2247 print 'binpath = %s' % self.binpath 2337 print 'type = %s' % self.vtype 2248 print 'vbase = %x' % self.vbase 2249 print 'pbase = 0' 2338 2250 print 'length = %x' % self.length 2251 print 'pseg_id = %d' % pseg_id 2252 print 'mode = %d' % mode_id 2253 print 'type = %d' % vtype_id 2254 print 'mapped = 0' 2255 print 'ident = %d' % self.identity 2256 print 'local = %d' % self.local 2257 print 'big = %d' % self.big 2339 2258 2340 2259 return byte_stream 2341 2260 2342 ###################################################################################### #####2261 ###################################################################################### 2343 2262 class Processor ( object ): 2344 ###################################################################################### #####2263 ###################################################################################### 2345 2264 def __init__( self, 2346 2265 x, … … 2367 2286 # check index 2368 2287 if (self.index != expected): 2369 print '[genmap error] in Proc.cbin() : proc global index = %d / expected = %d' \2370 % (self.index, expected)2288 print '[genmap error] in Proc.cbin()' 2289 print ' proc global index = %d / expected = %d' % (self.index,expected) 2371 2290 sys.exit(1) 2372 2291 … … 2376 2295 return byte_stream 2377 2296 2378 ###################################################################################### #####2297 ###################################################################################### 2379 2298 class Pseg ( object ): 2380 ###################################################################################### #####2299 ###################################################################################### 2381 2300 def __init__( self, 2382 2301 name, … … 2414 2333 # check index 2415 2334 if (self.index != expected): 2416 print '[genmap error] in Pseg.cbin() : pseg global index = %d / expected = %d' \2417 % (self.index, expected)2335 print '[genmap error] in Pseg.cbin()' 2336 print ' pseg global index = %d / expected = %d' % (self.index,expected) 2418 2337 sys.exit(1) 2419 2338 … … 2421 2340 segtype_int = 0xFFFFFFFF 2422 2341 for x in xrange( len(PSEGTYPES) ): 2423 if ( self.segtype == PSEGTYPES[x] ): 2424 segtype_int = x 2342 if ( self.segtype == PSEGTYPES[x] ): segtype_int = x 2343 2425 2344 if ( segtype_int == 0xFFFFFFFF ): 2426 print '[genmap error] in Pseg.cbin() : undefined segment type %s' % self.segtype 2345 print '[genmap error] in Pseg.cbin()' 2346 print ' undefined segment type %s' % self.segtype 2427 2347 sys.exit(1) 2428 2348 … … 2442 2362 return byte_stream 2443 2363 2444 ###################################################################################### #####2364 ###################################################################################### 2445 2365 class Periph ( object ): 2446 ###################################################################################### #####2366 ###################################################################################### 2447 2367 def __init__( self, 2448 2368 pseg, # associated pseg … … 2488 2408 # check index 2489 2409 if (self.index != expected): 2490 print '[genmap error] in Periph.cbin() : periph global index = %d / expected = %d' \2491 % (self.index, expected)2410 print '[genmap error] in Periph.cbin()' 2411 print ' periph global index = %d / expected = %d' % (self.index,expected) 2492 2412 sys.exit(1) 2493 2413 … … 2505 2425 for x in xrange( len(PERIPHTYPES) ): 2506 2426 if ( self.ptype == PERIPHTYPES[x] ): ptype_id = x 2427 2507 2428 if ( ptype_id == 0xFFFFFFFF ): 2508 print '[genmap error] in Periph.cbin() : undefined peripheral type %s' % self.ptype 2429 print '[genmap error] in Periph.cbin()' 2430 print ' undefined peripheral type %s' % self.ptype 2509 2431 sys.exit(1) 2510 2432 … … 2531 2453 return byte_stream 2532 2454 2533 ###################################################################################### #####2455 ###################################################################################### 2534 2456 class Irq ( object ): 2535 ###################################################################################### #####2457 ###################################################################################### 2536 2458 def __init__( self, 2537 2459 irqtype, # input IRQ type : HWI / WTI / PTI (for XCU only) … … 2565 2487 # check index 2566 2488 if (self.index != expected): 2567 print '[genmap error] in Irq.cbin() : irq global index = %d / expected = %d' \2568 % (self.index, expected)2489 print '[genmap error] in Irq.cbin()' 2490 print ' irq global index = %d / expected = %d' % (self.index,expected) 2569 2491 sys.exit(1) 2570 2492 … … 2572 2494 irqtype_id = 0xFFFFFFFF 2573 2495 for x in xrange( len(IRQTYPES) ): 2574 if ( self.irqtype == IRQTYPES[x] ): 2575 irqtype_id = x 2496 if ( self.irqtype == IRQTYPES[x] ): irqtype_id = x 2497 2576 2498 if ( irqtype_id == 0xFFFFFFFF ): 2577 print '[genmap error] in Irq.cbin() : undefined irqtype %s' % self.irqtype 2499 print '[genmap error] in Irq.cbin()' 2500 print ' undefined irqtype %s' % self.irqtype 2578 2501 sys.exit(1) 2579 2502 … … 2581 2504 isrtype_id = 0xFFFFFFFF 2582 2505 for x in xrange( len(ISRTYPES) ): 2583 if ( self.isrtype == ISRTYPES[x] ): 2584 isrtype_id = x 2506 if ( self.isrtype == ISRTYPES[x] ): isrtype_id = x 2507 2585 2508 if ( isrtype_id == 0xFFFFFFFF ): 2586 print '[genmap error] in Irq.cbin() : undefined isrtype %s' % self.isrtype 2509 print '[genmap error] in Irq.cbin()' 2510 print ' undefined isrtype %s' % self.isrtype 2587 2511 sys.exit(1) 2588 2512 … … 2603 2527 return byte_stream 2604 2528 2605 ###################################################################################### #####2529 ###################################################################################### 2606 2530 class Coproc ( object ): 2607 ###################################################################################### #####2531 ###################################################################################### 2608 2532 def __init__( self, 2609 2533 pseg ): # associated pseg … … 2631 2555 # check index 2632 2556 if (self.index != expected): 2633 print '[genmap error] in Coproc.cbin() : coproc global index = %d / expected = %d' \2634 % (self.index, expected)2557 print '[genmap error] in Coproc.cbin()' 2558 print ' coproc global index = %d / expected = %d' % (self.index,expected) 2635 2559 sys.exit(1) 2636 2560 … … 2655 2579 return byte_stream 2656 2580 2657 ###################################################################################### #####2581 ###################################################################################### 2658 2582 class Cpport ( object ): 2659 ###################################################################################### #####2583 ###################################################################################### 2660 2584 def __init__( self, 2661 2585 direction, … … 2666 2590 self.direction = direction # TO_COPROC / FROM_COPROC 2667 2591 self.vspacename = vspacename # name of vspace containing mwmr channel 2668 self.mwmrname = mwmrname # name of v objdefining mwmr channel2592 self.mwmrname = mwmrname # name of vseg defining mwmr channel 2669 2593 2670 2594 return … … 2686 2610 # check index 2687 2611 if ( self.index != expected ): 2688 print '[genmap error] in Cpport.cbin() : port global index = %d / expected = %d' \2689 % ( self.index, expected)2612 print '[genmap error] in Cpport.cbin()' 2613 print ' port global index = %d / expected = %d' % (self.index,expected) 2690 2614 sys.exit(1) 2691 2615 … … 2699 2623 vspace_id = 0xFFFFFFFF 2700 2624 for vspace in mapping.vspaces: 2701 if ( self.vspacename == vspace.name ): 2702 vspace_id = vspace.index 2625 if ( self.vspacename == vspace.name ): vspace_id = vspace.index 2626 2703 2627 if (vspace_id == 0xFFFFFFFF): 2704 print '[genmap error] in Cpport.cbin() : vspace name %s not found' \2705 2628 print '[genmap error] in Cpport.cbin()' 2629 print ' vspace name %s not found' % ( self.vspacename ) 2706 2630 sys.exit(1) 2707 2631 2708 # compute mwmr global index2632 # compute mwmr vseg global index 2709 2633 mwmr_id = 0xFFFFFFFF 2710 2634 for vseg in mapping.vspace[vspace_id].vsegs: 2711 for vobj in vseg.vobjs: 2712 if (self.mwmrname == vobj.name): 2713 mwmr_id = vobj.index 2635 if (self.mwmrname == vseg.name): mwmr_id = vseg.index 2636 2714 2637 if (mwmr_id == 0xFFFFFFFF): 2715 print '[genmap error] in Cpport.cbin() : mwmr vobj name %s not found in vspace %s' \ 2638 print '[genmap error] in Cpport.cbin()' 2639 print ' mwmr vseg name %s not found in vspace %s' \ 2716 2640 % ( self.mwmrname, self.vspacename ) 2717 2641 sys.exit(1) … … 2720 2644 byte_stream += mapping.int2bytes( 4 , dir_int ) # pseg global index 2721 2645 byte_stream += mapping.int2bytes( 4 , vspace_id ) # vspace global index 2722 byte_stream += mapping.int2bytes( 4 , mwmr_id ) # mwmr v objglobal index2646 byte_stream += mapping.int2bytes( 4 , mwmr_id ) # mwmr vseg global index 2723 2647 2724 2648 if ( verbose ):
Note: See TracChangeset
for help on using the changeset viewer.