Index: soft/giet_vm/giet_python/mapping.py
===================================================================
--- soft/giet_vm/giet_python/mapping.py	(revision 517)
+++ soft/giet_vm/giet_python/mapping.py	(revision 520)
@@ -10,14 +10,12 @@
 #  This file contains the classes required to define a mapping for the GIET_VM.
 # - A 'Mapping' contains a set of 'Cluster'   (hardware architecture)
-#                        a set of 'Vseg'      (kernel virtual segments, called globals)
-#                        a set of 'Vspace'    (one or several user applications).
+#                        a set of 'Vseg'      (kernel glogals virtual segments)
+#                        a set of 'Vspace'    (one or several user applications)
 # - A 'Cluster' contains a set of 'Pseg'      (physical segments in cluster)
 #                        a set of 'Proc'      (processors in cluster)
 #                        a set of 'Periph'    (peripherals in cluster)
-#                        a set of 'Coproc'    (coprocessors in cluster)
 # - A 'Vspace' contains  a set of 'Vseg'      (user virtual segments)
 #                        a set of 'Task'      (user parallel tasks)
 # - A 'Periph' contains  a set of 'Irq'       (only for XCU and PIC types )
-# - A 'Coproc' contains  a set of 'Cpports'   (one port per MWMR channel)
 ########################################################################################
 # Implementation Note
@@ -42,10 +40,11 @@
 VPN_ANTI_MASK     = 0x00000FFF    # mask virtual address to get offset in a small page 
 BPN_MASK          = 0xFFE00000    # mask virtual address to get the BPN (big page)
-PERI_INCREMENT    = 0x10000       # virtual address increment for replicated global vsegs
+PERI_INCREMENT    = 0x10000       # virtual address increment for replicated l vsegs
 RESET_ADDRESS     = 0xBFC00000    # Processor wired boot_address
 MAPPING_SIGNATURE = 0xDACE2014    # Magic number indicating a valid C binary struture
 
 ########################################################################################
-# These global lists must be consistent with enums in mapping_info.h or irq_handler.
+# These lists must be consistent with values defined in
+# mapping_info.h / xml_driver.c /xml_parser.c
 ########################################################################################
 PERIPHTYPES =    [
@@ -67,5 +66,5 @@
                  ]
 
-PERIPHSUBTYPES = [
+IOCSUBTYPES =    [
                   'BDV',
                   'HBA',
@@ -74,4 +73,13 @@
                  ]
 
+MWRSUBTYPES =    [
+                  'GCD',
+                  'DCT',
+                 ]
+   
+######################################################################################
+# These lists must be consistent with values defined in 
+# irq_handler.c / irq_handler.h / xml_driver.c / xml_parser.c
+######################################################################################
 IRQTYPES =       [
                   'HWI',
@@ -94,4 +102,5 @@
                   'ISR_DMA',
                   'ISR_SPI',
+                  'ISR_MWR'
                  ]
 
@@ -132,11 +141,5 @@
 PSEGTYPES =      [
                   'RAM',
-                  'ROM',        # deprecated => use PERI
                   'PERI',
-                 ]
-
-CP_PORT_DIRS =   [
-                  'TO_COPROC',
-                  'FROM_COPROC',
                  ]
 
@@ -194,6 +197,4 @@
         self.total_procs    = 0
         self.total_irqs     = 0
-        self.total_coprocs  = 0
-        self.total_cpports  = 0
         self.total_periphs  = 0
 
@@ -247,5 +248,8 @@
                    subtype  = 'NONE',  # peripheral subtype
                    channels = 1,       # number of channels
-                   arg      = 0 ):     # optional argument (semantic depends on ptype)
+                   arg0     = 0,       # optional argument (semantic depends on ptype)
+                   arg1     = 0,       # optional argument (semantic depends on ptype)
+                   arg2     = 0,       # optional argument (semantic depends on ptype)
+                   arg3     = 0 ):     # optional argument (semantic depends on ptype)
 
         # computes cluster index and coordinates from the base address
@@ -261,5 +265,6 @@
         assert ptype in PERIPHTYPES
 
-        assert subtype in PERIPHSUBTYPES
+        if (ptype == 'IOC'): assert subtype in IOCSUBTYPES
+        if (ptype == 'MWR'): assert subtype in MWRSUBTYPES
 
         # add one pseg into mapping
@@ -270,5 +275,5 @@
 
         # add one periph into mapping
-        periph = Periph( pseg, ptype, subtype, channels, arg )
+        periph = Periph( pseg, ptype, subtype, channels, arg0, arg1, arg2, arg3 )
         self.clusters[cluster_id].periphs.append( periph )
         periph.index = self.total_periphs
@@ -300,5 +305,5 @@
                  x,                    # cluster x coordinate
                  y,                    # cluster y coordinate
-                 p ):                  # processor local index
+                 lpid ):               # processor local index
 
         assert (x < self.x_size) and (y < self.y_size)
@@ -307,5 +312,5 @@
 
         # add one proc into mapping
-        proc = Processor( x, y, p )
+        proc = Processor( x, y, lpid )
         self.clusters[cluster_id].procs.append( proc )
         proc.index = self.total_procs
@@ -313,50 +318,4 @@
 
         return proc
-
-    ##############################    add a coprocessor in a cluster
-    def addCoproc( self,
-                   name,               # associated pseg name
-                   base,               # associated pseg base address
-                   size ):             # associated pseg length
-
-        # check cluster coordinates (obtained from the base address)
-        cluster_xy = base >> (self.paddr_width - self.x_width - self.y_width)
-        x = cluster_xy >> (self.y_width);
-        y = cluster_xy & ((1 << self.y_width) - 1)
-
-        assert (x < self.x_size) and (y < self.y_size)
-
-        cluster_id = (x * self.y_size) + y
-
-        # add one pseg into mapping
-        pseg = Pseg( name, base, size, x, y, 'PERI' )
-        self.clusters[cluster_id].psegs.append( pseg )
-        pseg.index = self.total_psegs
-        self.total_psegs += 1
-
-        # add one coproc into mapping
-        periph = Coproc( pseg )
-        self.clusters[cluster_id].coprocs.append( coproc )
-        periph.index = self.total_coprocs
-        self.total_coprocs += 1
-
-        return coproc
-
-    ##################################    add a port in a coprocessor
-    def addPort( self,
-                 coproc,               # coprocessor containing the port
-                 direction,            # direction (TO_COPROC / FROM_COPROC)
-                 vspacename,           # name of vspace using the coproc
-                 mwmrname ):           # name of the vseg containing the MWMR channel
-
-        assert direction in CP_PORT_DIRS
-
-        # add one cpport into mapping
-        port = Cpport( direction, vspacename, mwmrname )
-        coproc.ports.append( port )
-        port.index = self.total_cpports
-        self.total_cpports += 1
-
-        return port
 
     ############################    add one global vseg into mapping 
@@ -547,6 +506,4 @@
         byte_stream += self.int2bytes(4,  self.total_procs)
         byte_stream += self.int2bytes(4,  self.total_irqs)
-        byte_stream += self.int2bytes(4,  self.total_coprocs)
-        byte_stream += self.int2bytes(4,  self.total_cpports)
         byte_stream += self.int2bytes(4,  self.total_periphs)
         byte_stream += self.str2bytes(32, self.name)
@@ -570,6 +527,4 @@
             print 'total_procs   = %d' % self.total_procs
             print 'total_irqs    = %d' % self.total_irqs
-            print 'total_coprocs = %d' % self.total_coprocs
-            print 'total_cpports = %d' % self.total_cpports
             print 'total_periphs = %d' % self.total_periphs
             print '\n'
@@ -640,23 +595,4 @@
         if ( verbose ): print '\n'
 
-        # coprocs array
-        index = 0
-        for cluster in self.clusters:
-            for coproc in cluster.coprocs:
-                byte_stream += coproc.cbin( self, verbose, index )
-                index += 1
-
-        if ( verbose ): print '\n'
-
-        # cpports array
-        index = 0
-        for cluster in self.clusters:
-            for coproc in cluster.coprocs:
-                for port in coproc.ports:
-                    byte_stream += port.cbin( self, verbose, index )
-                    index += 1
-
-        if ( verbose ): print '\n'
-
         # periphs array
         index = 0
@@ -778,7 +714,8 @@
         nb_fbf       = 0
         fbf_channels = 0
-        fbf_arg      = 0
         seg_fbf_base = 0xFFFFFFFF
         seg_fbf_size = 0
+        fbf_arg0     = 0
+        fbf_arg1     = 0
 
         nb_iob       = 0
@@ -801,4 +738,8 @@
         seg_mwr_base = 0xFFFFFFFF
         seg_mwr_size = 0
+        mwr_arg0     = 0
+        mwr_arg1     = 0
+        mwr_arg2     = 0
+        mwr_arg3     = 0
 
         nb_nic       = 0
@@ -834,7 +775,7 @@
         nb_xcu       = 0
         xcu_channels = 0
-        xcu_arg      = 0
         seg_xcu_base = 0xFFFFFFFF
         seg_xcu_size = 0
+        xcu_arg0     = 0
 
         nb_drom       = 0
@@ -866,5 +807,6 @@
                     seg_fbf_size = periph.pseg.size
                     fbf_channels = periph.channels
-                    fbf_arg      = periph.arg
+                    fbf_arg0     = periph.arg0
+                    fbf_arg1     = periph.arg1
                     nb_fbf +=1
 
@@ -895,6 +837,10 @@
                 elif ( periph.ptype == 'MWR' ):
                     seg_mwr_base = periph.pseg.base & 0xFFFFFFFF
-                    seg_wmr_size = periph.pseg.size
+                    seg_mwr_size = periph.pseg.size
                     mwr_channels = periph.channels
+                    mwr_arg0     = periph.arg0
+                    mwr_arg1     = periph.arg1
+                    mwr_arg2     = periph.arg2
+                    mwr_arg3     = periph.arg3
                     nb_mwr +=1
 
@@ -945,5 +891,5 @@
                     seg_xcu_size = periph.pseg.size
                     xcu_channels = periph.channels
-                    xcu_arg      = periph.arg
+                    xcu_arg0     = periph.arg0
                     nb_xcu +=1
 
@@ -1078,8 +1024,13 @@
         s += '#define USE_IOC_RDK            %d\n'    % self.use_ramdisk
         s += '\n'
-        s += '#define FBUF_X_SIZE            %d\n'    % fbf_arg
-        s += '#define FBUF_Y_SIZE            %d\n'    % fbf_arg
-        s += '\n'
-        s += '#define XCU_NB_INPUTS          %d\n'    % xcu_arg
+        s += '#define FBUF_X_SIZE            %d\n'    % fbf_arg0
+        s += '#define FBUF_Y_SIZE            %d\n'    % fbf_arg1
+        s += '\n'
+        s += '#define XCU_NB_INPUTS          %d\n'    % xcu_arg0
+        s += '\n'
+        s += '#define MWR_TO_COPROC          %d\n'    % mwr_arg0
+        s += '#define MWR_FROM_COPROC        %d\n'    % mwr_arg1
+        s += '#define MWR_CONFIG             %d\n'    % mwr_arg2
+        s += '#define MWR_STATUS             %d\n'    % mwr_arg3
         s += '\n'
 
@@ -1764,7 +1715,4 @@
             nb_cpus = len( cluster.procs )
             nb_devs = len( cluster.periphs )
-            if ( len( cluster.coprocs ) != 0 ):
-                print 'Error in almos_archinfo() coprocessors not supported yet'
-                sys.exit(1)
 
             # search a RAM
@@ -1873,5 +1821,4 @@
         self.psegs       = []            # filled by addRam() or addPeriph()
         self.procs       = []            # filled by addProc()
-        self.coprocs     = []            # filled by addCoproc()
         self.periphs     = []            # filled by addPeriph()
 
@@ -1884,5 +1831,4 @@
         for pseg in self.psegs:   s += pseg.xml()
         for proc in self.procs:   s += proc.xml()
-        for copr in self.coprocs: s += copr.xml()
         for peri in self.periphs: s += peri.xml()
         s += '        </cluster>\n'
@@ -1913,10 +1859,4 @@
         else:
             proc_id = 0
-
-        # compute global index for first coproc
-        if ( len(self.coprocs) > 0 ):
-            coproc_id = self.coprocs[0].index
-        else:
-            coproc_id = 0
 
         # compute global index for first periph
@@ -1933,6 +1873,4 @@
         byte_stream += mapping.int2bytes( 4 , len( self.procs ) )   # number procs in cluster
         byte_stream += mapping.int2bytes( 4 , proc_id )             # first proc global index
-        byte_stream += mapping.int2bytes( 4 , len( self.coprocs ) ) # number coprocs in cluster
-        byte_stream += mapping.int2bytes( 4 , coproc_id )           # first coproc global index
         byte_stream += mapping.int2bytes( 4 , len( self.periphs ) ) # number periphs in cluster
         byte_stream += mapping.int2bytes( 4 , periph_id )           # first periph global index
@@ -1943,6 +1881,4 @@
             print 'nb_procs   = %d' %  len( self.procs )
             print 'proc_id    = %d' %  proc_id
-            print 'nb_coprocs = %d' %  len( self.coprocs )
-            print 'coproc_id  = %d' %  coproc_id
             print 'nb_periphs = %d' %  len( self.periphs )
             print 'periph_id  = %d' %  periph_id
@@ -2370,9 +2306,8 @@
                   subtype  = 'NONE',  # peripheral subtype
                   channels = 1,       # for multi-channels peripherals
-                  arg      = 0 ):     # optional argument (semantic depends on ptype)
-
-        assert ptype in PERIPHTYPES
-
-        assert subtype in PERIPHSUBTYPES
+                  arg0     = 0,       # optional argument (semantic depends on ptype)
+                  arg1     = 0,       # optional argument (semantic depends on ptype)
+                  arg2     = 0,       # optional argument (semantic depends on ptype)
+                  arg3     = 0 ):     # optional argument (semantic depends on ptype)
 
         self.index    = 0            # global index ( set by addPeriph() )
@@ -2380,5 +2315,8 @@
         self.ptype    = ptype
         self.subtype  = subtype
-        self.arg      = arg
+        self.arg0     = arg0
+        self.arg1     = arg1
+        self.arg2     = arg2
+        self.arg3     = arg3
         self.pseg     = pseg
         self.irqs     = []
@@ -2392,9 +2330,14 @@
         s += ' psegname="%s"'                % self.pseg.name
         s += ' channels="%d"'                % self.channels
-        s += ' arg="%d" >\n'                 % self.arg
+        s += ' arg0="%d"'                    % self.arg0
+        s += ' arg1="%d"'                    % self.arg1
+        s += ' arg2="%d"'                    % self.arg2
+        s += ' arg3="%d"'                    % self.arg3
         if ( (self.ptype == 'PIC') or (self.ptype == 'XCU') ):
+            s += ' >\n'
             for irq in self.irqs: s += irq.xml()
-        s += '            </periph>\n'
-
+            s += '            </periph>\n'
+        else:
+            s += ' />\n'
         return s
 
@@ -2433,8 +2376,11 @@
         # compute numerical value for subtype
         subtype_id = 0xFFFFFFFF
-        for x in xrange( len(PERIPHSUBTYPES) ):
-            if ( self.subtype == PERIPHSUBTYPES[x] ):  subtype_id = x
-
-        # compute
+        if (self.ptype == 'IOC'):
+            for x in xrange( len(IOCSUBTYPES) ):
+                if ( self.subtype == IOCSUBTYPES[x] ):  subtype_id = x
+        if (self.ptype == 'MWR'):
+            for x in xrange( len(MWRSUBTYPES) ):
+                if ( self.subtype == MWRSUBTYPES[x] ):  subtype_id = x
+        
         byte_stream = bytearray()
         byte_stream += mapping.int2bytes( 4 , ptype_id )         # peripheral type
@@ -2442,5 +2388,8 @@
         byte_stream += mapping.int2bytes( 4 , pseg_id )          # pseg global index
         byte_stream += mapping.int2bytes( 4 , self.channels )    # number of channels
-        byte_stream += mapping.int2bytes( 4 , self.arg )         # optionnal argument
+        byte_stream += mapping.int2bytes( 4 , self.arg0 )        # optionnal arg0
+        byte_stream += mapping.int2bytes( 4 , self.arg1 )        # optionnal arg1
+        byte_stream += mapping.int2bytes( 4 , self.arg2 )        # optionnal arg2
+        byte_stream += mapping.int2bytes( 4 , self.arg3 )        # optionnal arg3
         byte_stream += mapping.int2bytes( 4 , len( self.irqs ) ) # number of input irqs
         byte_stream += mapping.int2bytes( 4 , irq_id )           # first irq global index
@@ -2448,4 +2397,5 @@
         if ( verbose ):
             print 'ptype      = %d' %  ptype_id
+            print 'subtype    = %d' %  subtype_id
             print 'pseg_id    = %d' %  pseg_id
             print 'nb_irqs    = %d' %  len( self.irqs )
@@ -2527,131 +2477,4 @@
         return byte_stream
 
-######################################################################################
-class Coproc ( object ):
-######################################################################################
-    def __init__( self,
-                  pseg ):           # associated pseg
-
-        self.index    = 0        # global index value set by addCoproc()
-        self.pseg     = pseg
-        self.ports    = []
-
-        return
-
-    ################
-    def xml( self ):    # xml for Coproc
-
-        print '[genmap error] in Coproc.xml() : not defined yet'
-        sys.exit(1)
-
-        return
-
-    #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Coproc
-
-        if ( verbose ):
-            print '*** cbin for coproc in cluster (%d,%d)' % (self.pseg.x, self.pseg.y)
-
-        # check index
-        if (self.index != expected):
-            print '[genmap error] in Coproc.cbin()'
-            print '    coproc global index = %d / expected = %d' % (self.index,expected)
-            sys.exit(1)
-
-        # compute pseg global index
-        pseg_id = self.pseg.index
-
-        # compute first port global index
-        port_id = self.ports[0].index
-
-        byte_stream = bytearray()
-        byte_stream += mapping.str2bytes( 32, self.pseg.name )    # probablement inutile (AG)
-        byte_stream += mapping.int2bytes( 4 , pseg_id )           # pseg global index
-        byte_stream += mapping.int2bytes( 4 , len( self.ports ) ) # number of input irqs
-        byte_stream += mapping.int2bytes( 4 , port_id )           # first port global index
-
-        if ( verbose ):
-            print 'irqtype    = %s' %  self.irqtype
-            print 'pseg_id    = %d' %  pseg_id
-            print 'nb_ports   = %d' %  len( self.ports )
-            print 'port_id      %d' %  port_id
-
-        return byte_stream
-
-######################################################################################
-class Cpport ( object ):
-######################################################################################
-    def __init__( self,
-                  direction,
-                  vspacename,
-                  mwmrname ):
-
-        self.index      = 0           # global index ( set by addCpport() )
-        self.direction  = direction   # TO_COPROC / FROM_COPROC
-        self.vspacename = vspacename  # name of vspace containing mwmr channel
-        self.mwmrname   = mwmrname    # name of vseg defining mwmr channel
-
-        return
-
-    ################
-    def xml( self ):    # xml for Cpport
-
-        print '[genmap error] in Cpport.xml() : not defined yet'
-        sys.exit(1)
-
-        return
-
-    #############################################
-    def cbin( self, mapping, verbose, expected ):    # C binary structure for Cpport
-
-        if ( verbose ):
-            print '*** cbin for cpport[%d]' % (self.index)
-
-        # check index
-        if ( self.index != expected ):
-            print '[genmap error] in Cpport.cbin()'
-            print '    port global index = %d / expected = %d' % (self.index,expected)
-            sys.exit(1)
-
-        # compute numerical value for direction
-        if ( self.direction == 'TO_COPROC' ):
-             dir_int = 0
-        else:
-             dir_int = 1
-
-        # compute vspace global index
-        vspace_id = 0xFFFFFFFF
-        for vspace in mapping.vspaces:
-            if ( self.vspacename == vspace.name ): vspace_id = vspace.index
-
-        if (vspace_id == 0xFFFFFFFF):
-            print '[genmap error] in Cpport.cbin()'
-            print '    vspace name %s not found'  % ( self.vspacename )
-            sys.exit(1)
-
-        # compute mwmr vseg global index
-        mwmr_id = 0xFFFFFFFF
-        for vseg in mapping.vspace[vspace_id].vsegs:
-                if (self.mwmrname == vseg.name): mwmr_id = vseg.index
-
-        if (mwmr_id == 0xFFFFFFFF):
-            print '[genmap error] in Cpport.cbin()'
-            print '    mwmr vseg name %s not found in vspace %s' \
-                  % ( self.mwmrname, self.vspacename )
-            sys.exit(1)
-
-        byte_stream = bytearray()
-        byte_stream += mapping.int2bytes( 4 , dir_int )         # pseg global index
-        byte_stream += mapping.int2bytes( 4 , vspace_id )       # vspace global index
-        byte_stream += mapping.int2bytes( 4 , mwmr_id )         # mwmr vseg global index
-
-        if ( verbose ):
-            print 'direction  = %s' %  self.direction
-            print 'vspace_id  = %d' %  vspace_id
-            print 'mwmr_id    = %d' %  mwmr_id
-
-        return byte_stream
-
-
 # Local Variables:
 # tab-width: 4;
