Ignore:
Timestamp:
Mar 28, 2015, 8:04:20 PM (9 years ago)
Author:
alain
Message:

Cosmetic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_python/mapping.py

    r537 r539  
    33import sys
    44
    5 ########################################################################################
     5###################################################################################
    66#   file   : giet_mapping.py
    77#   date   : april 2014
    88#   author : Alain Greiner
    9 ########################################################################################
     9###################################################################################
    1010#  This file contains the classes required to define a mapping for the GIET_VM.
    1111# - A 'Mapping' contains a set of 'Cluster'   (hardware architecture)
     
    1818#                        a set of 'Task'      (user parallel tasks)
    1919# - A 'Periph' contains  a set of 'Irq'       (only for XCU and PIC types )
    20 ########################################################################################
     20###################################################################################
    2121# Implementation Note
    2222# The objects used to describe a mapping are distributed in the PYTHON structure:
     
    2525# In the C binary data structure used by the giet_vm, all objects of same type
    2626# are stored in a linear array (one single array for all psegs for example).
    27 # For all objects, we compute and store in the  PYTHON object itself a "global index"
     27# For all objects, we compute and store in the PYTHON object a "global index"
    2828# corresponding to the index in this global array, and this index can be used as
    2929# a pseudo-pointer to identify a specific object of a given type.
    30 ########################################################################################
    31 
    32 ########################################################################################
     30###################################################################################
     31
     32###################################################################################
    3333# Various constants
    34 ########################################################################################
     34###################################################################################
    3535
    3636PADDR_WIDTH       = 40            # number of bits for physical address
     
    3838Y_WIDTH           = 4             # number of bits encoding y coordinate
    3939P_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)
    42 PERI_INCREMENT    = 0x10000       # virtual address increment for replicated l vsegs
     40VPN_ANTI_MASK     = 0x00000FFF    # mask vaddr to get offset in small page
     41BPN_MASK          = 0xFFE00000    # mask vaddr to get the BPN in big page
     42PERI_INCREMENT    = 0x10000       # virtual address increment for replicated vsegs
    4343RESET_ADDRESS     = 0xBFC00000    # Processor wired boot_address
    44 MAPPING_SIGNATURE = 0xDACE2014    # Magic number indicating a valid C binary struture
    45 
    46 ########################################################################################
     44MAPPING_SIGNATURE = 0xDACE2014    # Magic number indicating a valid C BLOB
     45
     46###################################################################################
    4747# These lists must be consistent with values defined in
    4848# mapping_info.h / xml_driver.c /xml_parser.c
    49 ########################################################################################
     49###################################################################################
    5050PERIPHTYPES =    [
    5151                  'CMA',
     
    7878                 ]
    7979   
    80 ######################################################################################
     80###################################################################################
    8181# These lists must be consistent with values defined in
    8282# irq_handler.c / irq_handler.h / xml_driver.c / xml_parser.c
    83 ######################################################################################
     83###################################################################################
    8484IRQTYPES =       [
    8585                  'HWI',
     
    145145                 ]
    146146
    147 #######################################################################################
     147###################################################################################
    148148class Mapping( object ):
    149 #######################################################################################
     149###################################################################################
    150150    def __init__( self,
    151151                  name,                            # mapping name
     
    165165                  reset_address  = RESET_ADDRESS,  # Processor wired boot_address
    166166                  ram_base       = 0,              # RAM physical base in cluster[0,0]
    167                   ram_size       = 0 ):            # RAM size in each cluster (bytes)
     167                  ram_size       = 0 ):            # RAM size per cluster (bytes)
    168168
    169169        assert ( x_size <= (1<<X_WIDTH) )
     
    606606    # end of cbin()
    607607
    608     ##################################################################################
    609     def giet_vsegs( self ):      # compute string for giet_vsegs.ld file generation
     608    #######################################################################
     609    def giet_vsegs( self ):      # compute string for giet_vsegs.ld file
    610610                                 # required by giet_vm compilation
    611611
     
    619619        for vseg in self.globs:
    620620
    621             if ( vseg.name == 'seg_boot_code' ):
     621            if ( vseg.name[0:13] == 'seg_boot_code' ):
    622622                boot_code_vbase      = vseg.vbase
    623623                boot_code_size       = vseg.length
    624624                boot_code_found      = True
    625625
    626             if ( vseg.name == 'seg_boot_data' ):
     626            if ( vseg.name[0:13] == 'seg_boot_data' ):
    627627                boot_data_vbase      = vseg.vbase
    628628                boot_data_size       = vseg.length
    629629                boot_data_found      = True
    630630
    631             if ( vseg.name == 'seg_kernel_data' ):
     631            if ( vseg.name[0:15] == 'seg_kernel_data' ):
    632632                kernel_data_vbase    = vseg.vbase
    633633                kernel_data_size     = vseg.length
    634634                kernel_data_found    = True
    635635
    636             if ( vseg.name == 'seg_kernel_code' ):
     636            if ( vseg.name[0:15] == 'seg_kernel_code' ):
    637637                kernel_code_vbase    = vseg.vbase
    638638                kernel_code_size     = vseg.length
    639639                kernel_code_found    = True
    640640
    641             if ( vseg.name == 'seg_kernel_init' ):
     641            if ( vseg.name[0:15] == 'seg_kernel_init' ):
    642642                kernel_init_vbase    = vseg.vbase
    643643                kernel_init_size     = vseg.length
     
    692692        return s
    693693
    694     ###################################################################################
    695     def hard_config( self ):     # compute string for hard_config.h file generation,
     694    ######################################################################
     695    def hard_config( self ):     # compute string for hard_config.h file
    696696                                 # required by
    697697                                 # - top.cpp compilation
     
    11171117    # end of hard_config()
    11181118
    1119     ################################################################################
    1120     def linux_dts( self ):     # compute string for linux.dts file generation
     1119    #################################################################
     1120    def linux_dts( self ):     # compute string for linux.dts file
    11211121                               # used for linux configuration
    11221122        # header
     
    12331233                if ( periph.ptype == 'TTY' ):
    12341234
    1235                     # get HWI index to XCU or PIC (only TTY channel 0 is used by Linux)
     1235                    # get HWI index to XCU or PIC (only TTY0 is used by Linux)
    12361236                    hwi_id = 0xFFFFFFFF
    12371237                    for irq in irq_ctrl.irqs:
     
    12741274
    12751275                    else:
    1276                         print '[genmap warning] in linux_dts() : %s' % (periph.subtype),
     1276                        print '[genmap warning] in linux_dts() : '
     1277                        print ' %s' % (periph.subtype),
    12771278                        print 'peripheral not supported by LINUX'
    12781279
     
    12831284                # other peripherals
    12841285                else:
    1285                     print '[genmap warning] in linux_dts()'
    1286                     print '    %s peripheral not supported by LINUX' % (periph.ptype)
     1286                    print '[genmap warning] in linux_dts() : '
     1287                    print ' %s peripheral not supported by LINUX' % (periph.ptype)
    12871288
    12881289        # clocks
     
    13051306
    13061307
    1307     #############################################################################
    1308     def netbsd_dts( self ):    # compute string for netbsd.dts file generation,
     1308    #################################################################
     1309    def netbsd_dts( self ):    # compute string for netbsd.dts file
    13091310                               # used for netbsd configuration
    13101311        # header
     
    13221323        for cluster in self.clusters:
    13231324            for proc in cluster.procs:
    1324                 proc_id = (((cluster.x << self.y_width) + cluster.y) << self.p_width) + proc.lpid
     1325                proc_id = (((cluster.x << self.y_width) + cluster.y)
     1326                              << self.p_width) + proc.lpid
    13251327
    13261328                s += '    Mips,32@0x%x {\n'                % proc_id
     
    13461348                    s += '    cached      = <1>;\n'
    13471349                    s += '    device_type = "memory";\n'
    1348                     s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb, lsb, size)
     1350                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb,lsb,size)
    13491351                    s += '  };\n'
    13501352
     
    13661368                    s += '  %s@0x%x {\n'  % (periph.pseg.name, periph.pseg.base)
    13671369                    s += '    device_type = "soclib:xicu:root";\n'
    1368                     s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb, lsb, size)
     1370                    s += '    reg         = <0x%x  0x%x  0x%x>;\n' % (msb,lsb,size)
    13691371                    s += '    input_lines = <%d>;\n'    % periph.arg
    13701372                    s += '    ipis        = <%d>;\n'    % periph.arg
     
    14301432                        hwi_id = 0xFFFFFFFF
    14311433                        for irq in xcu.irqs:
    1432                             if ( (irq.isrtype == 'ISR_DMA') and (irq.channel == channel) ):
     1434                            if ( (irq.isrtype == 'ISR_DMA') and
     1435                                 (irq.channel == channel) ):
    14331436                                hwi_id = irq.srcid
    14341437
     
    14721475                    s += '  %s@0x%x {\n' % (periph.pseg.name, periph.pseg.base)
    14731476                    s += '    device_type = "soclib:framebuffer";\n'
    1474                     s += '    mode        = <32>;\n'                    # bits par pixel
     1477                    s += '    mode        = <32>;\n'            # bits par pixel
    14751478                    s += '    width       = <%d>;\n'    % periph.arg
    14761479                    s += '    height      = <%d>;\n'    % periph.arg
     
    16921695        # end netbsd_dts()
    16931696
    1694     ###########################
    1695     def almos_archinfo( self ):    # compute string for arch.info file generation,
     1697    ######################################################################
     1698    def almos_archinfo( self ):    # compute string for arch.info file
    16961699                                   # used for almos configuration
    16971700        # header
     
    17301733                        # scan irqs
    17311734                        for irq in periph.irqs:
    1732                             if ( irq.isrtype == 'ISR_TTY_RX' ) : tty_irq_id = irq.srcid
    1733                             if ( irq.isrtype == 'ISR_BDV'    ) : bdv_irq_id = irq.srcid
    1734                             if ( irq.isrtype == 'ISR_DMA'    ) : dma_irq_id = irq.srcid
     1735                            if (irq.isrtype=='ISR_TTY_RX'): tty_irq_id = irq.srcid
     1736                            if (irq.isrtype=='ISR_BDV'   ): bdv_irq_id = irq.srcid
     1737                            if (irq.isrtype=='ISR_DMA'   ): dma_irq_id = irq.srcid
    17351738
    17361739            # Build the cluster description
    17371740            s += '[CLUSTER]\n'
    17381741            s += '         CID=%d\n'        % cluster_id
    1739             s += '         ARCH_CID=0x%x\n' % ((cluster.x << self.y_width) + cluster.y)
     1742            s += '         ARCH_CID=0x%x\n' % ((cluster.x<<self.y_width)+cluster.y)
    17401743            s += '         CPU_NR=%d\n'     % nb_cpus
    17411744            s += '         DEV_NR=%d\n'     % nb_devs
     
    17481751                irqid = -1
    17491752                s += '         DEVID=RAM'
    1750                 s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
     1753                s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % (base,size)
    17511754
    17521755            # Handling peripherals
     
    17581761
    17591762                    s += '         DEVID=XICU'
    1760                     s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
     1763                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size)
    17611764
    17621765                elif ( (periph.ptype == 'TTY')
     
    17641767
    17651768                    s += '         DEVID=TTY'
    1766                     s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, tty_irq_id )
     1769                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,tty_irq_id)
    17671770
    17681771                elif ( (periph.ptype == 'DMA')
     
    17701773
    17711774                    s += '         DEVID=DMA'
    1772                     s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, dma_irq_id )
     1775                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,dma_irq_id)
    17731776
    17741777                elif ( periph.ptype == 'FBF' ):
    17751778
    17761779                    s += '         DEVID=FB'
    1777                     s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
     1780                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size )
    17781781
    17791782                elif ( (periph.ptype == 'IOC') and (periph.subtype == 'BDV')
     
    17811784
    17821785                    s += '         DEVID=BLKDEV'
    1783                     s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' % ( base, size, bdv_irq_id )
     1786                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=%d\n' %(base,size,bdv_irq_id)
    17841787
    17851788                elif ( periph.ptype == 'PIC' ):
    17861789
    1787                         s += '         DEVID=IOPIC'
    1788                         s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' % ( base, size )
     1790                    s += '         DEVID=IOPIC'
     1791                    s += '  BASE=0x%x  SIZE=0x%x  IRQ=-1\n' %(base,size)
    17891792
    17901793                else:
     
    18071810
    18081811
    1809 ###########################################################################################
     1812###################################################################################
    18101813class Cluster ( object ):
    1811 ###########################################################################################
     1814###################################################################################
    18121815    def __init__( self,
    18131816                  x,
    18141817                  y ):
    18151818
    1816         self.index       = 0             # global index (set by Mapping constructor)
    1817         self.x           = x             # x coordinate
    1818         self.y           = y             # y coordinate
    1819         self.psegs       = []            # filled by addRam() or addPeriph()
    1820         self.procs       = []            # filled by addProc()
    1821         self.periphs     = []            # filled by addPeriph()
     1819        self.index       = 0           # global index (set by Mapping constructor)
     1820        self.x           = x           # x coordinate
     1821        self.y           = y           # y coordinate
     1822        self.psegs       = []          # filled by addRam() or addPeriph()
     1823        self.procs       = []          # filled by addProc()
     1824        self.periphs     = []          # filled by addPeriph()
    18221825
    18231826        return
     
    18351838
    18361839    #############################################
    1837     def cbin( self, mapping, verbose, expected ):    # C binary structure for Cluster
     1840    def cbin( self, mapping, verbose, expected ):  # C binary structure for Cluster
    18381841
    18391842        if ( verbose ):
     
    18431846        if (self.index != expected):
    18441847            print '[genmap error] in Cluster.cbin()'
    1845             print '    cluster global index = %d / expected = %d' % (self.index,expected)
     1848            print '    cluster global index = %d / expected = %d' \
     1849                       % (self.index,expected)
    18461850            sys.exit(1)
    18471851
     
    18651869
    18661870        byte_stream = bytearray()
    1867         byte_stream += mapping.int2bytes( 4 , self.x )              # x coordinate
    1868         byte_stream += mapping.int2bytes( 4 , self.y )              # x coordinate
    1869         byte_stream += mapping.int2bytes( 4 , len( self.psegs ) )   # number psegs in cluster
    1870         byte_stream += mapping.int2bytes( 4 , pseg_id )             # first pseg global index
    1871         byte_stream += mapping.int2bytes( 4 , len( self.procs ) )   # number procs in cluster
    1872         byte_stream += mapping.int2bytes( 4 , proc_id )             # first proc global index
    1873         byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster
    1874         byte_stream += mapping.int2bytes( 4 , periph_id )           # first periph global index
     1871        byte_stream += mapping.int2bytes(4,self.x)            # x coordinate
     1872        byte_stream += mapping.int2bytes(4,self.y)            # x coordinate
     1873        byte_stream += mapping.int2bytes(4,len(self.psegs))   # psegs in cluster
     1874        byte_stream += mapping.int2bytes(4,pseg_id )          # global index
     1875        byte_stream += mapping.int2bytes(4,len(self.procs))   # procs in cluster
     1876        byte_stream += mapping.int2bytes(4,proc_id )          # global index
     1877        byte_stream += mapping.int2bytes(4,len(self.periphs)) # periphs in cluster
     1878        byte_stream += mapping.int2bytes(4, periph_id )       # global index
    18751879
    18761880        if ( verbose ):
     
    18841888        return byte_stream
    18851889
    1886 ########################################################################################
     1890##################################################################################
    18871891class Vspace( object ):
    1888 ########################################################################################
     1892##################################################################################
    18891893    def __init__( self,
    18901894                  name,
     
    19101914
    19111915    #############################################
    1912     def cbin( self, mapping, verbose, expected ):   # C binary structure for Vspace
     1916    def cbin( self, mapping, verbose, expected ):   # C binary for Vspace
    19131917
    19141918        if ( verbose ):
     
    19181922        if (self.index != expected):
    19191923            print '[genmap error] in Vspace.cbin()'
    1920             print '    vspace global index = %d / expected = %d' %(self.index,expected)
     1924            print '    vspace global index = %d / expected = %d' \
     1925                        %(self.index,expected)
    19211926            sys.exit(1)
    19221927
     
    19281933        if ( vseg_start_id == 0xFFFFFFFF ):
    19291934            print '[genmap error] in Vspace.cbin()'
    1930             print '    startname %s not found for vspace %s' %(self.startname,self.name)
     1935            print '    startname %s not found for vspace %s' \
     1936                        %(self.startname,self.name)
    19311937            sys.exit(1)
    19321938
     
    19401946
    19411947        byte_stream = bytearray()
    1942         byte_stream += mapping.str2bytes( 32, self.name )         # vspace name
    1943         byte_stream += mapping.int2bytes( 4,  vseg_start_id )     # vseg start_vector
    1944         byte_stream += mapping.int2bytes( 4,  nb_vsegs )          # number of vsegs
    1945         byte_stream += mapping.int2bytes( 4,  nb_tasks )          # number of tasks
    1946         byte_stream += mapping.int2bytes( 4,  first_vseg_id )     # first vseg global index
    1947         byte_stream += mapping.int2bytes( 4,  first_task_id )     # first task global index
     1948        byte_stream += mapping.str2bytes(32,self.name)         # vspace name
     1949        byte_stream += mapping.int2bytes(4, vseg_start_id)     # vseg start_vector
     1950        byte_stream += mapping.int2bytes(4, nb_vsegs)          # number of vsegs
     1951        byte_stream += mapping.int2bytes(4, nb_tasks)          # number of tasks
     1952        byte_stream += mapping.int2bytes(4, first_vseg_id)     # global index
     1953        byte_stream += mapping.int2bytes(4, first_task_id)     # global index
    19481954
    19491955        if ( verbose ):
     
    19561962        return byte_stream
    19571963
    1958 ########################################################################################
     1964##################################################################################
    19591965class Task( object ):
    1960 ########################################################################################
     1966##################################################################################
    19611967    def __init__( self,
    19621968                  name,
     
    19801986        return
    19811987
    1982     ################
     1988    ######################################
    19831989    def xml( self ):    # xml for one task
    19841990
     
    19962002        return s
    19972003
    1998     #####################################################
    1999     def cbin( self, mapping, verbose, expected, vspace ):  # C binary data structure for Task
     2004    ##########################################################################
     2005    def cbin( self, mapping, verbose, expected, vspace ):  # C binary for Task
    20002006
    20012007        if ( verbose ):
    2002             print '*** cbin for task %s in vspace %s' % (self.name, vspace.name)
     2008            print '*** cbin for task %s in vspace %s' \
     2009                     % (self.name, vspace.name)
    20032010
    20042011        # check index
    20052012        if (self.index != expected):
    20062013            print '[genmap error] in Task.cbin()'
    2007             print '    task global index = %d / expected = %d' %(self.index,expected)
     2014            print '    task global index = %d / expected = %d' \
     2015                        %(self.index,expected)
    20082016            sys.exit(1)
    20092017
     
    20372045
    20382046        byte_stream = bytearray()
    2039         byte_stream += mapping.str2bytes( 32, self.name )       # task name in vspace
    2040         byte_stream += mapping.int2bytes( 4,  cluster_id )      # cluster global index
    2041         byte_stream += mapping.int2bytes( 4,  self.p )          # processor local index
    2042         byte_stream += mapping.int2bytes( 4,  self.trdid )      # thread local index in vspace
    2043         byte_stream += mapping.int2bytes( 4,  vseg_stack_id )  # stack vseg local index
    2044         byte_stream += mapping.int2bytes( 4,  vseg_heap_id )    # heap vseg local index
    2045         byte_stream += mapping.int2bytes( 4,  self.startid )    # index in start vector
     2047        byte_stream += mapping.str2bytes(32,self.name)     # task name in vspace
     2048        byte_stream += mapping.int2bytes(4, cluster_id)    # cluster global index
     2049        byte_stream += mapping.int2bytes(4, self.p)        # processor local index
     2050        byte_stream += mapping.int2bytes(4, self.trdid)    # thread index in vspace
     2051        byte_stream += mapping.int2bytes(4, vseg_stack_id) # stack vseg local index
     2052        byte_stream += mapping.int2bytes(4, vseg_heap_id)  # heap vseg local index
     2053        byte_stream += mapping.int2bytes(4, self.startid)  # index in start vector
    20462054
    20472055        if ( verbose ):
     
    20552063        return byte_stream
    20562064
    2057 ########################################################################################
     2065##################################################################################
    20582066class Vseg( object ):
    2059 ########################################################################################
     2067##################################################################################
    20602068    def __init__( self,
    20612069                  name,
     
    20942102        self.local    = local               # only mapped in local PTAB when true
    20952103        self.big      = big                 # to be mapped in a big physical page
    2096         self.binpath  = binpath             # path name for binary file (ELF or BLOB)
     2104        self.binpath  = binpath             # pathname for binary file (ELF or BLOB)
    20972105
    20982106        return
    20992107
    2100     ################
    2101     def xml( self ):  # xml for one vseg
     2108    ##################################
     2109    def xml( self ):  # xml for a vseg
    21022110
    21032111        s =  '            <vseg name="%s"' %(self.name)
     
    21182126        return s
    21192127
    2120     #############################################
    2121     def cbin( self, mapping, verbose, expected ):    # C binary structure for Vseg
     2128    #####################################################################
     2129    def cbin( self, mapping, verbose, expected ):    # C binary for Vseg
    21222130
    21232131        if ( verbose ):
     
    21652173
    21662174        byte_stream = bytearray()
    2167         byte_stream += mapping.str2bytes( 32, self.name )       # vseg name
    2168         byte_stream += mapping.str2bytes( 64, self.binpath )    # binpath
    2169         byte_stream += mapping.int2bytes( 4,  self.vbase )      # virtual base address
    2170         byte_stream += mapping.int2bytes( 8,  0 )               # physical base address
    2171         byte_stream += mapping.int2bytes( 4,  self.length )     # vseg size (bytes)
    2172         byte_stream += mapping.int2bytes( 4,  pseg_id )         # pseg global index
    2173         byte_stream += mapping.int2bytes( 4,  mode_id )         # CXWU flags
    2174         byte_stream += mapping.int2bytes( 4,  vtype_id )        # vseg type
    2175         byte_stream += mapping.int2bytes( 1,  0 )               # mapped when non zero
    2176         byte_stream += mapping.int2bytes( 1,  self.identity )  # identity mapping
    2177         byte_stream += mapping.int2bytes( 1,  self.local )      # only mapped in local PTAB
    2178         byte_stream += mapping.int2bytes( 1,  self.big )        # to be mapped in BPP
     2175        byte_stream += mapping.str2bytes(32,self.name )     # vseg name
     2176        byte_stream += mapping.str2bytes(64,self.binpath )  # binpath
     2177        byte_stream += mapping.int2bytes(4, self.vbase )    # virtual base address
     2178        byte_stream += mapping.int2bytes(8, 0 )             # physical base address
     2179        byte_stream += mapping.int2bytes(4, self.length )   # vseg size (bytes)
     2180        byte_stream += mapping.int2bytes(4, pseg_id )       # pseg global index
     2181        byte_stream += mapping.int2bytes(4, mode_id )       # CXWU flags
     2182        byte_stream += mapping.int2bytes(4, vtype_id )      # vseg type
     2183        byte_stream += mapping.int2bytes(1, 0 )             # mapped when non zero
     2184        byte_stream += mapping.int2bytes(1, self.identity ) # identity mapping
     2185        byte_stream += mapping.int2bytes(1, self.local )    # only in local PTAB
     2186        byte_stream += mapping.int2bytes(1,  self.big )     # to be mapped in BPP
    21792187
    21802188        if ( verbose ):
     
    21932201        return byte_stream
    21942202
    2195 ######################################################################################
     2203##################################################################################
    21962204class Processor ( object ):
    2197 ######################################################################################
     2205##################################################################################
    21982206    def __init__( self,
    21992207                  x,
     
    22082216        return
    22092217
    2210     ################
     2218    ########################################
    22112219    def xml( self ):   # xml for a processor
    22122220        return '            <proc index="%d" />\n' % (self.lpid)
    22132221
    2214     #############################################
    2215     def cbin( self, mapping, verbose, expected ):    # C binary structure for Proc
     2222    ####################################################################
     2223    def cbin( self, mapping, verbose, expected ):    # C binary for Proc
    22162224
    22172225        if ( verbose ):
    2218             print '*** cbin for proc %d in cluster (%d,%d)' % (self.lpid, self.x, self.y)
     2226            print '*** cbin for proc %d in cluster (%d,%d)' \
     2227                  % (self.lpid, self.x, self.y)
    22192228
    22202229        # check index
    22212230        if (self.index != expected):
    22222231            print '[genmap error] in Proc.cbin()'
    2223             print '    proc global index = %d / expected = %d' % (self.index,expected)
     2232            print '    proc global index = %d / expected = %d' \
     2233                       % (self.index,expected)
    22242234            sys.exit(1)
    22252235
     
    22292239        return byte_stream
    22302240
    2231 ######################################################################################
     2241##################################################################################
    22322242class Pseg ( object ):
    2233 ######################################################################################
     2243##################################################################################
    22342244    def __init__( self,
    22352245                  name,
     
    22522262        return
    22532263
    2254     ################
     2264    ###################################
    22552265    def xml( self ):   # xml for a pseg
    22562266
    2257         return '            <pseg name="%s" type="%s" base="0x%x" length="0x%x" />\n' \
    2258                 % (self.name, self.segtype, self.base, self.size)
    2259 
    2260     ######################################################
    2261     def cbin( self, mapping, verbose, expected, cluster ):    # C binary structure for Pseg
     2267        s = '            <pseg name="%s" type="%s" base="0x%x" length="0x%x" />\n' \
     2268                         % (self.name, self.segtype, self.base, self.size)
     2269        return s
     2270
     2271    ###########################################################################
     2272    def cbin( self, mapping, verbose, expected, cluster ):  # C binary for Pseg
    22622273
    22632274        if ( verbose ):
     
    22682279        if (self.index != expected):
    22692280            print '[genmap error] in Pseg.cbin()'
    2270             print '    pseg global index = %d / expected = %d' % (self.index,expected)
     2281            print '    pseg global index = %d / expected = %d' \
     2282                       % (self.index,expected)
    22712283            sys.exit(1)
    22722284
     
    22822294
    22832295        byte_stream = bytearray()
    2284         byte_stream += mapping.str2bytes( 32, self.name )      # pseg name
    2285         byte_stream += mapping.int2bytes( 8 , self.base )      # physical base address
    2286         byte_stream += mapping.int2bytes( 8 , self.size )      # segment length
    2287         byte_stream += mapping.int2bytes( 4 , segtype_int )    # segment type
    2288         byte_stream += mapping.int2bytes( 4 , cluster.index ) # cluster global index
    2289         byte_stream += mapping.int2bytes( 4 , 0 )              # linked list of vsegs
     2296        byte_stream += mapping.str2bytes(32,self.name)     # pseg name
     2297        byte_stream += mapping.int2bytes(8 ,self.base)     # physical base address
     2298        byte_stream += mapping.int2bytes(8 ,self.size)     # segment length
     2299        byte_stream += mapping.int2bytes(4 ,segtype_int)   # segment type
     2300        byte_stream += mapping.int2bytes(4 ,cluster.index) # cluster global index
     2301        byte_stream += mapping.int2bytes(4 ,0)             # linked list of vsegs
    22902302
    22912303        if ( verbose ):
     
    22962308        return byte_stream
    22972309
    2298 ######################################################################################
     2310##################################################################################
    22992311class Periph ( object ):
    2300 ######################################################################################
     2312##################################################################################
    23012313    def __init__( self,
    23022314                  pseg,               # associated pseg
     
    23042316                  subtype  = 'NONE',  # peripheral subtype
    23052317                  channels = 1,       # for multi-channels peripherals
    2306                   arg0     = 0,       # optional argument (semantic depends on ptype)
    2307                   arg1     = 0,       # optional argument (semantic depends on ptype)
    2308                   arg2     = 0,       # optional argument (semantic depends on ptype)
    2309                   arg3     = 0 ):     # optional argument (semantic depends on ptype)
     2318                  arg0     = 0,       # optional (semantic depends on ptype)
     2319                  arg1     = 0,       # optional (semantic depends on ptype)
     2320                  arg2     = 0,       # optional (semantic depends on ptype)
     2321                  arg3     = 0 ):     # optional (semantic depends on ptype)
    23102322
    23112323        self.index    = 0            # global index ( set by addPeriph() )
     
    23212333        return
    23222334
    2323     ################
     2335    ######################################
    23242336    def xml( self ):    # xml for a periph
    23252337
     
    23402352        return s
    23412353
    2342     #############################################
    2343     def cbin( self, mapping, verbose, expected ):    # C binary structure for Periph
     2354    ######################################################################
     2355    def cbin( self, mapping, verbose, expected ):    # C binary for Periph
    23442356
    23452357        if ( verbose ):
     
    23502362        if (self.index != expected):
    23512363            print '[genmap error] in Periph.cbin()'
    2352             print '    periph global index = %d / expected = %d' % (self.index,expected)
     2364            print '    periph global index = %d / expected = %d' \
     2365                       % (self.index,expected)
    23532366            sys.exit(1)
    23542367
     
    23822395       
    23832396        byte_stream = bytearray()
    2384         byte_stream += mapping.int2bytes( 4 , ptype_id )         # peripheral type
    2385         byte_stream += mapping.int2bytes( 4 , subtype_id )       # peripheral subtype
    2386         byte_stream += mapping.int2bytes( 4 , pseg_id )          # pseg global index
    2387         byte_stream += mapping.int2bytes( 4 , self.channels )    # number of channels
    2388         byte_stream += mapping.int2bytes( 4 , self.arg0 )        # optionnal arg0
    2389         byte_stream += mapping.int2bytes( 4 , self.arg1 )        # optionnal arg1
    2390         byte_stream += mapping.int2bytes( 4 , self.arg2 )        # optionnal arg2
    2391         byte_stream += mapping.int2bytes( 4 , self.arg3 )        # optionnal arg3
    2392         byte_stream += mapping.int2bytes( 4 , len( self.irqs ) ) # number of input irqs
    2393         byte_stream += mapping.int2bytes( 4 , irq_id )           # first irq global index
     2397        byte_stream += mapping.int2bytes(4,ptype_id)       # peripheral type
     2398        byte_stream += mapping.int2bytes(4,subtype_id)     # peripheral subtype
     2399        byte_stream += mapping.int2bytes(4,pseg_id)        # pseg global index
     2400        byte_stream += mapping.int2bytes(4,self.channels)  # number of channels
     2401        byte_stream += mapping.int2bytes(4,self.arg0)      # optionnal arg0
     2402        byte_stream += mapping.int2bytes(4,self.arg1)      # optionnal arg1
     2403        byte_stream += mapping.int2bytes(4,self.arg2)      # optionnal arg2
     2404        byte_stream += mapping.int2bytes(4,self.arg3)      # optionnal arg3
     2405        byte_stream += mapping.int2bytes(4,len(self.irqs)) # number of input irqs
     2406        byte_stream += mapping.int2bytes( 4 , irq_id )     # global index
    23942407
    23952408        if ( verbose ):
     
    24012414        return byte_stream
    24022415
    2403 ######################################################################################
     2416##################################################################################
    24042417class Irq ( object ):
    2405 ######################################################################################
     2418##################################################################################
    24062419    def __init__( self,
    24072420                  irqtype,         # input IRQ type : HWI / WTI / PTI (for XCU only)
     
    24212434        return
    24222435
    2423     ################
     2436    ################################
    24242437    def xml( self ):   # xml for Irq
    24252438
    2426         return '                <irq srctype="%s" srcid="%d" isr="%s" channel="%d" />\n' \
     2439        s = '                <irq srctype="%s" srcid="%d" isr="%s" channel="%d" />\n' \
    24272440                % ( self.irqtype, self.srcid, self.isrtype, self.channel )
    2428 
    2429     #############################################
    2430     def cbin( self, mapping, verbose, expected ):     # C binary structure for Irq
     2441        return s
     2442
     2443    ####################################################################
     2444    def cbin( self, mapping, verbose, expected ):     # C binary for Irq
    24312445
    24322446        if ( verbose ):
     
    24362450        if (self.index != expected):
    24372451            print '[genmap error] in Irq.cbin()'
    2438             print '    irq global index = %d / expected = %d' % (self.index,expected)
     2452            print '    irq global index = %d / expected = %d' \
     2453                       % (self.index,expected)
    24392454            sys.exit(1)
    24402455
Note: See TracChangeset for help on using the changeset viewer.