Changeset 218 for soft


Ignore:
Timestamp:
Sep 19, 2012, 10:52:43 AM (12 years ago)
Author:
alain
Message:

Introducing support for Network controller

Location:
soft/giet_vm
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/Makefile

    r215 r218  
    6464
    6565### system compilation
    66 build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld
     66build/sys/sys.elf: $(SYS_OBJS) sys/sys.ld 
    6767        $(LD) -o $@ -T sys/sys.ld $(SYS_OBJS)
    6868        $(DU) -D $@ > $@.txt
    6969
    70 build/sys/%.o: sys/%.c giet_config.h
     70build/sys/%.o: sys/%.c giet_config.h $(MAP_XML)
    7171        $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
    7272
    73 build/sys/%.o: sys/%.s giet_config.h
     73build/sys/%.o: sys/%.s giet_config.h $(MAP_XML)
    7474        $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
    7575
     
    7979        $(DU) -D $@ > $@.txt
    8080
    81 build/boot/%.o: boot/%.c giet_config.h
     81build/boot/%.o: boot/%.c giet_config.h $(MAP_XML)
    8282        $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
    8383
    84 build/boot/%.o: boot/%.S giet_config.h
     84build/boot/%.o: boot/%.S giet_config.h $(MAP_XML)
    8585        $(CC) $(INCLUDE) $(CFLAGS)  -c -o $@ $<
    8686
  • soft/giet_vm/boot/boot_init.c

    r215 r218  
    912912                    boot_exit();
    913913                }
    914                 if ( periph[periph_id].channels != NB_TTYS )
     914                if ( periph[periph_id].channels > NB_TTYS )
    915915                {
    916916                    boot_puts("\n[BOOT ERROR] Wrong NB_TTYS in cluster ");
     
    12961296            unsigned int*   pseg_base = (unsigned int*)pseg[pseg_id].base;
    12971297
    1298             //////// vci_block_device component
    1299             if      ( type == PERIPH_TYPE_IOC )
     1298#if BOOT_DEBUG_PERI
     1299boot_puts("- peripheral type : ");
     1300boot_putd( type );
     1301boot_puts(" / address = ");
     1302boot_putx( (unsigned int)pseg_base );
     1303boot_puts(" / channels = ");
     1304boot_putd( channels );
     1305boot_puts("\n");
     1306#endif
     1307
     1308            switch ( type )
    13001309            {
    1301 
    1302                 // activate interrupts
    1303                 pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1;
    1304 
     1310                case PERIPH_TYPE_IOC:   // vci_block_device component
     1311                    pseg_base[BLOCK_DEVICE_IRQ_ENABLE] = 1;
    13051312#if BOOT_DEBUG_PERI
    1306 boot_puts("- IOC initialised : ");
    1307 boot_putd( channels );
    1308 boot_puts(" channels\n");
    1309 #endif
    1310             }
    1311 
    1312             //////// vci_multi_dma component
    1313             else if ( type == PERIPH_TYPE_DMA )
    1314             {
    1315                 for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
    1316                 {
    1317                     // activate interrupts
    1318                     pseg_base[DMA_IRQ_DISABLE + channel_id*DMA_SPAN] = 0;
    1319                 }
    1320 
     1313boot_puts("- IOC initialised\n");
     1314#endif
     1315                break;
     1316                case PERIPH_TYPE_DMA:   // vci_multi_dma component
     1317                    for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
     1318                    {
     1319                        pseg_base[DMA_IRQ_DISABLE + channel_id*DMA_SPAN] = 0;
     1320                    }
    13211321#if BOOT_DEBUG_PERI
    1322 boot_puts("- DMA initialised : ");
    1323 boot_putd( channels );
    1324 boot_puts(" channels\n");
    1325 #endif
    1326             }
    1327 
    1328             //////// vci_multi_nic component
    1329             else if ( type == PERIPH_TYPE_NIC  )
    1330             {
    1331                 for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
    1332                 {
    1333                 // TODO
    1334                 }
    1335 
     1322boot_puts("- DMA initialised\n");
     1323#endif
     1324                break;
     1325                case PERIPH_TYPE_NIC:   // vci_multi_nic component
     1326                    for ( channel_id = 0 ; channel_id < channels ; channel_id++ )
     1327                    {
     1328                        // TODO
     1329                    }
    13361330#if BOOT_DEBUG_PERI
    1337 boot_puts("- NIC initialised : ");
    1338 boot_putd( channels );
    1339 boot_puts(" channels\n");
    1340 #endif
    1341             }
    1342 
    1343             //////// vci_io_bridge component
    1344             else if ( (type == PERIPH_TYPE_IOB) && IOMMU_ACTIVE )
    1345             {
    1346                 // get the iommu page table physical address
    1347                 // TODO
    1348 
    1349                 // define IPI address mapping the IOC interrupt
    1350                 // TODO
    1351 
    1352                 // set IOMMU page table address
    1353                 // pseg_base[IOB_IOMMU_PTPR] = ptab_pbase;   
    1354 
    1355                 // activate IOMMU
    1356                 // pseg_base[IOB_IOMMU_ACTIVE] = 1;       
    1357 
     1331boot_puts("- NIC initialised\n");
     1332#endif
     1333                break;
     1334                case PERIPH_TYPE_TTY:   // vci_multi_tty component
    13581335#if BOOT_DEBUG_PERI
    1359 boot_puts("- IOB initialised : ");
    1360 boot_putd( channels );
    1361 boot_puts(" channels\n");
    1362 #endif
    1363             }
    1364 
     1336boot_puts("- TTY initialised\n");
     1337#endif
     1338                break;
     1339                case PERIPH_TYPE_IOB:   // vci_io_bridge component
     1340                    if ( IOMMU_ACTIVE )
     1341                    {
     1342                        // TODO
     1343                        // get the iommu page table physical address
     1344                        // define IPI address mapping the IOC interrupt
     1345                        // set IOMMU page table address
     1346                        // pseg_base[IOB_IOMMU_PTPR] = ptab_pbase;   
     1347                        // activate IOMMU
     1348                        // pseg_base[IOB_IOMMU_ACTIVE] = 1;       
     1349                    }
     1350#if BOOT_DEBUG_PERI
     1351boot_puts("- IOB initialised\n");
     1352#endif
     1353                break;
     1354            } // end switch periph type
    13651355        } // end for periphs
     1356
     1357#if BOOT_DEBUG_PERI
     1358boot_puts("\n[BOOT DEBUG] ****** coprocessors initialisation in cluster ");
     1359boot_putd( cluster_id );
     1360boot_puts(" ******\n");
     1361#endif
    13661362
    13671363        for ( coproc_id = cluster[cluster_id].coproc_offset ;
     
    13741370
    13751371#if BOOT_DEBUG_PERI
    1376 boot_puts("[BOOT] mwmr coproc initialisation of ");
    1377 boot_puts((unsigned int) coproc[coproc_id].name);
    1378 boot_puts(", nb ports");
     1372boot_puts("- coprocessor name : ");
     1373boot_puts( coproc[coproc_id].name );
     1374boot_puts(" / nb ports = ");
    13791375boot_putd((unsigned int)coproc[coproc_id].ports);
    13801376boot_puts("\n");
     
    14431439    unsigned int        alloc_tty_channel;                 // TTY channel allocator
    14441440    unsigned int        alloc_nic_channel;                 // NIC channel allocator
    1445     unsigned int        alloc_fbdma_channel[NB_CLUSTERS];  // FBDMA channel allocators
     1441    unsigned int        alloc_dma_channel[NB_CLUSTERS];    // DMA channel allocators
    14461442    unsigned int        alloc_timer_channel[NB_CLUSTERS];  // user TIMER allocators
    14471443
     
    14641460    for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ )
    14651461    {
    1466         alloc_fbdma_channel[cluster_id] = 0;
     1462        alloc_dma_channel[cluster_id]  = 0;
    14671463        alloc_timer_channel[cluster_id] = 0;
    14681464    }
     
    16781674            }
    16791675
    1680             // ctx_fbdma : DMA global index provided by a cluster allocator 
    1681             unsigned int ctx_fbdma = 0xFFFFFFFF;
    1682             if ( task[task_id].use_fbdma )
     1676            // ctx_dma : DMA global index provided by a cluster allocator 
     1677            unsigned int ctx_dma = 0xFFFFFFFF;
     1678            if ( task[task_id].use_fbdma || task[task_id].use_nic )
    16831679            {
    16841680                unsigned int cluster_id = task[task_id].clusterid;
    1685                 if ( alloc_fbdma_channel[cluster_id] >= NB_DMAS_MAX )
    1686                 {
    1687                     boot_puts("\n[BOOT ERROR] local FBDMA index too large for task ");
     1681                if ( alloc_dma_channel[cluster_id] >= NB_DMAS_MAX )
     1682                {
     1683                    boot_puts("\n[BOOT ERROR] local DMA index too large for task ");
    16881684                    boot_puts( task[task_id].name );
    16891685                    boot_puts(" in vspace ");
     
    16921688                    boot_exit();
    16931689                }
    1694                 ctx_fbdma = cluster_id*NB_DMAS_MAX + alloc_fbdma_channel[cluster_id];
    1695                 alloc_fbdma_channel[cluster_id]++;
     1690                ctx_dma = cluster_id*NB_DMAS_MAX + alloc_dma_channel[cluster_id];
     1691                alloc_dma_channel[cluster_id]++;
    16961692            }
    16971693
     
    17301726
    17311727            // initializes the task context in scheduler[gpid]
    1732             boot_scheduler_set_context( gpid, ltid, CTX_SR_ID    , ctx_sr     );
    1733             boot_scheduler_set_context( gpid, ltid, CTX_SP_ID    , ctx_sp     );
    1734             boot_scheduler_set_context( gpid, ltid, CTX_RA_ID    , ctx_ra     );
    1735             boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID   , ctx_epc    );
    1736             boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID  , ctx_ptpr   );
    1737             boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID   , ctx_tty    );
    1738             boot_scheduler_set_context( gpid, ltid, CTX_FBDMA_ID , ctx_fbdma  );
    1739             boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID   , ctx_nic    );
    1740             boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer  );
    1741             boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID  , ctx_ptab   );
    1742             boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID  , ltid       );
    1743             boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID  , vspace_id  );
    1744             boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID   , 1          );
     1728            boot_scheduler_set_context( gpid, ltid, CTX_SR_ID    , ctx_sr    );
     1729            boot_scheduler_set_context( gpid, ltid, CTX_SP_ID    , ctx_sp    );
     1730            boot_scheduler_set_context( gpid, ltid, CTX_RA_ID    , ctx_ra    );
     1731            boot_scheduler_set_context( gpid, ltid, CTX_EPC_ID   , ctx_epc   );
     1732            boot_scheduler_set_context( gpid, ltid, CTX_PTPR_ID  , ctx_ptpr  );
     1733            boot_scheduler_set_context( gpid, ltid, CTX_TTY_ID   , ctx_tty   );
     1734            boot_scheduler_set_context( gpid, ltid, CTX_DMA_ID   , ctx_dma   );
     1735            boot_scheduler_set_context( gpid, ltid, CTX_NIC_ID   , ctx_nic   );
     1736            boot_scheduler_set_context( gpid, ltid, CTX_TIMER_ID , ctx_timer );
     1737            boot_scheduler_set_context( gpid, ltid, CTX_PTAB_ID  , ctx_ptab  );
     1738            boot_scheduler_set_context( gpid, ltid, CTX_LTID_ID  , ltid      );
     1739            boot_scheduler_set_context( gpid, ltid, CTX_VSID_ID  , vspace_id );
     1740            boot_scheduler_set_context( gpid, ltid, CTX_RUN_ID   , 1         );
    17451741                                       
    17461742#if BOOT_DEBUG_SCHED
     
    17851781boot_puts("\n");
    17861782
    1787 boot_puts("  - ctx[FBDMA]  = ");
    1788 boot_putd( ctx_fbdma );
     1783boot_puts("  - ctx[DMA]    = ");
     1784boot_putd( ctx_dma );
    17891785boot_puts("\n");
    17901786
  • soft/giet_vm/display/main.c

    r207 r218  
    22
    33#define NBLOCS 32
    4 #define THRESHOLD 200
    54
    65__attribute__((constructor)) int main(void)
    76{
    8     unsigned char buf_in[128*128];
    9     unsigned char buf_out[128*128];
     7    unsigned char buf[128*128];
     8    unsigned int  x;
     9    unsigned int  base = 0;
    1010
    11     unsigned int i;
    12     unsigned int x;
    13     unsigned int base = 0;
    14 
    15     while (base < 5 * NBLOCS)
     11    while (base < 10 * NBLOCS)
    1612    {
    1713        giet_tty_printf("\n *** image %d *** at date = %d \n",
    1814                base / NBLOCS, giet_proctime());
    1915
    20         /* Phase 1 : lecture image sur le disque et transfert vers buf_in */
    21         x = giet_ioc_read(base, buf_in, NBLOCS);
     16        /* Phase 1 : lecture image sur le disque et transfert vers buf */
     17        x = giet_ioc_read(base, buf, NBLOCS);
    2218        if ( x )
    2319        {
     
    3127            giet_exit();
    3228        }
    33         giet_tty_printf("io_read  completed at date = %d \n", giet_proctime());
     29        giet_tty_printf("ioc_read  completed at date = %d \n", giet_proctime());
    3430
    35         /* Phase 2 : transfert de buf_in vers buf_out avec seuillage */
    36         for (i = 0; i < 128 * 128; i++)
    37         {
    38             if (buf_in[i] > THRESHOLD)
    39                 buf_out[i] = 255;
    40             else
    41                 buf_out[i] = buf_in[i];
    42         }
    43         giet_tty_printf("image processing completed at date = %d \n", giet_proctime());
    44 
    45         /* Phase 3 : transfert de buf_out vers le frame buffer par dma */
    46         x = giet_fb_write(0, buf_out, 128 * 128);
     31        // Phase 2 : transfert de buf vers le frame buffer par dma
     32        x = giet_fb_write(0, buf, 128 * 128);
    4733        if ( x )
    4834        {
     
    5036            giet_exit();
    5137        }
     38
     39        giet_tty_printf("fb_write ok at date : %d\n", giet_proctime() );
    5240
    5341        x = giet_fb_completed();
     
    5745            giet_exit();
    5846        }
    59         giet_tty_printf("transfer completed at date = %d \n", giet_proctime());
     47        giet_tty_printf("display completed at date = %d \n", giet_proctime());
    6048
    6149        base = base + NBLOCS;
  • soft/giet_vm/giet_config.h

    r216 r218  
    1616/* Debug parameters */
    1717
    18 #define BOOT_DEBUG_PERI     0                   /* trace peripherals initialisation on TTY0 */
    19 #define BOOT_DEBUG_PT           0                       /* trace page tables initialisation on TTY0 */
    20 #define BOOT_DEBUG_VOBJS        0                       /* trace vobjs initialisation on TTY0 */
    21 #define BOOT_DEBUG_SCHED        0                       /* trace schedulers initialisation on TTY0 */
     18#define BOOT_DEBUG_PERI     0                   /* trace peripherals initialisation */
     19#define BOOT_DEBUG_PT           0                       /* trace page tables initialisation */
     20#define BOOT_DEBUG_VOBJS        0                       /* trace vobjs initialisation */
     21#define BOOT_DEBUG_SCHED        0                       /* trace schedulers initialisation */
    2222
    23 #define GIET_DEBUG_INIT         0                       /* trace parallel kernel initialisation on TTY0 */
    24 #define GIET_DEBUG_SWITCH       0                       /* trace context switchs on TTY0 */
     23#define GIET_DEBUG_INIT         0                       /* trace parallel kernel initialisation */
     24#define GIET_DEBUG_SWITCH       0                       /* trace context switchs */
    2525
    2626#define CONFIG_SRL_VERBOSITY TRACE
  • soft/giet_vm/libs/stdio.c

    r204 r218  
    3333#define SYSCALL_IOC_COMPLETED   0x17
    3434#define SYSCALL_VOBJ_GET_VBASE  0x1A
     35#define SYSCALL_NIC_WRITE       0x1B
     36#define SYSCALL_NIC_READ        0x1C
     37#define SYSCALL_NIC_COMPLETED   0x1D
    3538
    3639//////////////////////////////////////////////////////////////////////////////////
     
    645648//////////////////////////////////////////////////////////////////////////////////
    646649unsigned int giet_fb_write( unsigned int        offset,
    647                             void*                       buffer,
     650                            void*               buffer,
    648651                            unsigned int        length )
    649652{
     
    667670//////////////////////////////////////////////////////////////////////////////////
    668671unsigned int giet_fb_read( unsigned int         offset,
    669                            void*                        buffer,
     672                           void*                buffer,
    670673                           unsigned int         length )
    671674{
     
    685688{
    686689    return sys_call(SYSCALL_FB_COMPLETED,
     690                    0, 0, 0, 0);
     691}
     692
     693//////////////////////////////////////////////////////////////////////////////////
     694// giet_nic_write()
     695//////////////////////////////////////////////////////////////////////////////////
     696// This non-blocking function use the DMA coprocessor to transfer data from the
     697// NIC device to an user buffer.
     698// - offset : offset (in bytes) in the NIC
     699// - buffer : base address of the memory buffer
     700// - length : number of bytes to be transfered
     701// The transfer completion is signaled by an IRQ, and must be tested by the
     702// nic_completed() function.
     703// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
     704//////////////////////////////////////////////////////////////////////////////////
     705
     706unsigned int giet_nic_write( unsigned int       offset,
     707                             void*              buffer,
     708                             unsigned int       length )
     709{
     710    return sys_call(SYSCALL_NIC_WRITE,
     711            offset,
     712            (unsigned int)buffer,
     713            length,
     714            0);
     715}
     716
     717//////////////////////////////////////////////////////////////////////////////////
     718// giet_nic_read()
     719//////////////////////////////////////////////////////////////////////////////////
     720// This non-blocking function use the DMA coprocessor to transfer data from the
     721// NIC device to an user buffer.
     722// - offset : offset (in bytes) in the NIC
     723// - buffer : base address of the memory buffer
     724// - length : number of bytes to be transfered
     725// The transfer completion is signaled by an IRQ, and must be tested by the
     726// nic_completed() function.
     727// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
     728//////////////////////////////////////////////////////////////////////////////////
     729
     730unsigned int giet_nic_read( unsigned int        offset,
     731                            void*                   buffer,
     732                            unsigned int        length )
     733{
     734    return sys_call(SYSCALL_NIC_READ,
     735            offset,
     736            (unsigned int)buffer,
     737            length,
     738            0);
     739}
     740
     741//////////////////////////////////////////////////////////////////////////////////
     742// giet_nic_completed()
     743//////////////////////////////////////////////////////////////////////////////////
     744// This blocking function returns when the transfer is completed.
     745// - Returns 0 if success, > 0 if error.
     746//////////////////////////////////////////////////////////////////////////////////
     747unsigned int giet_nic_completed()
     748{
     749    return sys_call(SYSCALL_NIC_COMPLETED,
    687750                    0, 0, 0, 0);
    688751}
  • soft/giet_vm/libs/stdio.h

    r189 r218  
    5252                                void*                   buffer,
    5353                                unsigned int    length );
     54unsigned int giet_nic_write(    unsigned int    offset,
     55                                void*           buffer,
     56                                unsigned int    length );
     57unsigned int giet_nic_read(     unsigned int    offset,
     58                                void*           buffer,
     59                                unsigned int    length );
    5460unsigned int giet_fb_completed();
     61unsigned int giet_nic_completed();
    5562
    5663/* Misc */
  • soft/giet_vm/mappings/4c_1p_four.xml

    r215 r218  
    4343*** Boot ROM and non replicated peripherals
    4444
    45             <pseg name = "PSEG_FBF" type = "PERI" base = "0x80D00000" length = "0x00200000" />
    46             <pseg name = "PSEG_TTY" type = "PERI" base = "0x80F20000" length = "0x00001000" />
    47             <pseg name = "PSEG_IOC" type = "PERI" base = "0x80F10000" length = "0x00001000" />
    48             <pseg name = "PSEG_NIC" type = "PERI" base = "0x80F80000" length = "0x00021000" />
     45            <pseg name = "PSEG_FBF" type = "PERI" base = "0xBFD00000" length = "0x00200000" />
     46            <pseg name = "PSEG_TTY" type = "PERI" base = "0xBFF20000" length = "0x00001000" />
     47            <pseg name = "PSEG_IOC" type = "PERI" base = "0xBFF10000" length = "0x00001000" />
     48            <pseg name = "PSEG_NIC" type = "PERI" base = "0xBFF80000" length = "0x00021000" />
    4949            <pseg name = "PSEG_ROM" type = "ROM"  base = "0xBFC00000" length = "0x00100000" />
    5050
     
    9595
    9696    <globalset>
    97         <vseg name = "seg_boot_code"      vbase = "0xbfc00000" mode = "CXW_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
     97        <vseg name = "seg_boot_code"      vbase = "0xBFC00000" mode = "CXW_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
    9898            <vobj name = "boot_code"      type = "ELF" length = "0x00008000" binpath    = "build/boot/boot.elf" />
    9999        </vseg>
    100         <vseg name = "seg_boot_stack"     vbase = "0xbfc08000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
     100        <vseg name = "seg_boot_stack"     vbase = "0xBFC08000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
    101101            <vobj name = "boot_stack"     type = "BUFFER" length = "0x00004000" />
    102102        </vseg>
    103         <vseg name = "seg_boot_mapping"   vbase = "0xbfc0c000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
     103        <vseg name = "seg_boot_mapping"   vbase = "0xBFC0c000" mode = "C_W_" clusterid = "2" psegname = "PSEG_ROM" ident = "1" >
    104104            <vobj name = "boot_mapping"   type = "BLOB" length  = "0x00004000" binpath  = "map.bin" />
    105105        </vseg>
     
    122122*** Non replicated peripherals
    123123
    124         <vseg name = "seg_ioc"            vbase = "0x80F10000" mode = "__W_" clusterid = "2" psegname = "PSEG_IOC" ident = "1" >
     124        <vseg name = "seg_ioc"            vbase = "0xBFF10000" mode = "__W_" clusterid = "2" psegname = "PSEG_IOC" ident = "1" >
    125125            <vobj name = "ioc"            type = "PERI" length  = "0x00001000" />
    126126        </vseg>
    127         <vseg name = "seg_tty"            vbase = "0x80F20000" mode = "__W_" clusterid = "2" psegname = "PSEG_TTY" ident = "1" >
     127        <vseg name = "seg_tty"            vbase = "0xBFF20000" mode = "__W_" clusterid = "2" psegname = "PSEG_TTY" ident = "1" >
    128128                        <vobj name = "tty"            type = "PERI" length  = "0x00001000" />
    129129        </vseg>
    130         <vseg name = "seg_fbf"            vbase = "0x80D00000" mode = "__W_" clusterid = "2" psegname = "PSEG_FBF" ident = "1" >
     130        <vseg name = "seg_fbf"            vbase = "0xBFD00000" mode = "__W_" clusterid = "2" psegname = "PSEG_FBF" ident = "1" >
    131131            <vobj name = "fbf"            type = "PERI" length  = "0x00200000" />
    132132        </vseg>
    133         <vseg name = "seg_nic"            vbase = "0x80f80000" mode = "__W_" clusterid = "2" psegname = "PSEG_NIC" ident = "1" >
     133        <vseg name = "seg_nic"            vbase = "0xBFF80000" mode = "__W_" clusterid = "2" psegname = "PSEG_NIC" ident = "1" >
    134134            <vobj name = "nic"            type = "PERI" length  = "0x00021000" />
    135135        </vseg>
  • soft/giet_vm/sys/common.h

    r207 r218  
    1818
    1919extern _ld_symbol_t seg_iob_base;
     20extern _ld_symbol_t seg_nic_base;
    2021extern _ld_symbol_t seg_icu_base;
    2122extern _ld_symbol_t seg_tim_base;
  • soft/giet_vm/sys/ctx_handler.c

    r199 r218  
    4040//
    4141// ctx[0]<- ***|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC  |ctx[40]<- TTY
    42 // ctx[1]<- $1 |ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR   |ctx[41]<- FBDMA
     42// ctx[1]<- $1 |ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR   |ctx[41]<- DMA
    4343// ctx[2]<- $2 |ctx[10]<- $10|ctx[18]<- $18|ctx[26]<- LO |ctx[34]<- SR   |ctx[42]<- NIC
    4444// ctx[3]<- $3 |ctx[11]<- $11|ctx[19]<- $19|ctx[27]<- HI |ctx[35]<- BVAR |ctx[43]<- TIMER
  • soft/giet_vm/sys/ctx_handler.h

    r199 r218  
    3838
    3939#define CTX_TTY_ID              40
    40 #define CTX_FBDMA_ID    41
    41 #define CTX_NIC_ID              42
     40#define CTX_DMA_ID          41
     41#define CTX_NIC_ID          42
    4242#define CTX_TIMER_ID    43
    4343#define CTX_PTAB_ID             44
  • soft/giet_vm/sys/drivers.c

    r216 r218  
    2424// - NB_TTYS   
    2525//
    26 // The following virtual base addresses must be defined in the giet.ld file:
     26// The following virtual base addresses must be defined in the giet_vsegs.ld file:
    2727// - seg_icu_base
    2828// - seg_tim_base
     
    3232// - seg_fbf_base
    3333// - seg_ioc_base
     34// - seg_nic_base
    3435// As some peripherals can be replicated in the clusters (ICU, TIMER, DMA)
    3536// These addresses must be completed by an offset depending on the cluster index
     
    713714//////////////////////////////////////////////////////////////////////////////////
    714715
    715 //+1: for the case where the NB_DMAS_MAX == 0
    716716#if NB_DMAS_MAX > 0
    717717in_unckdata unsigned int                        _dma_lock[NB_DMAS_MAX * NB_CLUSTERS]
    718                                        = { [0 ... ((NB_DMAS_MAX) * NB_CLUSTERS)-1] = 0 };
     718                                       = { [0 ... (NB_DMAS_MAX * NB_CLUSTERS)-1] = 0 };
    719719
    720720in_unckdata volatile unsigned int       _dma_done[NB_DMAS_MAX * NB_CLUSTERS]
     
    749749#endif
    750750}
     751
    751752//////////////////////////////////////////////////////////////////////////////////
    752753// _dma_get_status()
     
    773774
    774775//////////////////////////////////////////////////////////////////////////////////
    775 //      VciFrameBuffer driver
    776 //////////////////////////////////////////////////////////////////////////////////
    777 // The vci_frame_buffer device can be accessed directly by software with memcpy(),
    778 // or it can be accessed through a multi-channels DMA component:
    779 // 
    780 // The '_fb_sync_write' and '_fb_sync_read' functions use a memcpy strategy to
    781 // implement the transfer between a data buffer (user space) and the frame
    782 // buffer (kernel space). They are blocking until completion of the transfer.
    783 //
    784 // The '_fb_write()', '_fb_read()' and '_fb_completed()' functions use the DMA
    785 // controlers (distributed in the clusters) to transfer data
    786 // between the user buffer and the frame buffer. A  DMA channel is
    787 // allocated to each task requesting it in the mapping_info data structure.
    788 //////////////////////////////////////////////////////////////////////////////////
    789 
    790 //////////////////////////////////////////////////////////////////////////////////
    791 // _fb_sync_write()
    792 // Transfer data from an memory buffer to the frame_buffer device using
    793 // a memcpy. The source memory buffer must be in user address space.
    794 // - offset : offset (in bytes) in the frame buffer.
    795 // - buffer : base address of the memory buffer.
    796 // - length : number of bytes to be transfered.
    797 // Returns 0 if success, > 0 if error.
    798 //////////////////////////////////////////////////////////////////////////////////
    799 unsigned int _fb_sync_write( unsigned int       offset,
    800                              const void*        buffer,
    801                              unsigned int       length )
    802 {
    803 
    804     // buffer must be mapped in user space
    805     if ( ((unsigned int)buffer + length ) >= 0x80000000 )
    806     {
    807         return 1;
    808     }
    809     else
    810     {
    811         unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset;
    812         memcpy((void*)fb_address, (void*)buffer, length);
    813         return 0;
    814     }
    815 }
    816 
    817 //////////////////////////////////////////////////////////////////////////////////
    818 // _fb_sync_read()
    819 // Transfer data from the frame_buffer device to a memory buffer using
    820 // a memcpy. The destination memory buffer must be in user address space.
    821 // - offset : offset (in bytes) in the frame buffer.
    822 // - buffer : base address of the memory buffer.
    823 // - length : number of bytes to be transfered.
    824 // Returns 0 if success, > 0 if error.
    825 //////////////////////////////////////////////////////////////////////////////////
    826 unsigned int _fb_sync_read( unsigned int        offset,
    827                             const void*         buffer,
    828                             unsigned int        length )
    829 {
    830     // buffer must be mapped in user space
    831     if ( ((unsigned int)buffer + length ) >= 0x80000000 )
    832     {
    833         return 1;
    834     }
    835     else
    836     {
    837         unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset;
    838         memcpy((void*)buffer, (void*)fb_address, length);
    839         return 0;
    840     }
    841 }
    842 
    843 //////////////////////////////////////////////////////////////////////////////////
    844 // _fb_dma_access()
    845 // Transfer data between a user buffer and the frame_buffer using DMA.
    846 // - to_user    : from frame buffer to user buffer when true.
    847 // - offset     : offset (in bytes) in the frame buffer.
    848 // - user_vaddr : virtual base address of the memory buffer.
    849 // - length     : number of bytes to be transfered.
     776// _dma_transfer()
     777// Transfer data between a user buffer and a device buffer using DMA.
     778// Two devices types are supported: Frame Buffer if dev_type == 0
     779//                                  Multi-Nic if dev_type != 0
     780// Arguments are:
     781// - dev_type     : device type.
     782// - to_user      : from  device buffer to user buffer when true.
     783// - offset       : offset (in bytes) in the device buffer.
     784// - user_vaddr   : virtual base address of the user buffer.
     785// - length       : number of bytes to be transfered.
     786//
     787// The DMA channel is obtained from task context (CTX_FBDMA_ID / CTX_NIDMA_ID.
    850788// The user buffer must be mapped in user address space and word-aligned.
    851789// The user buffer length must be multiple of 4 bytes.
    852 // Me must compute the physical base addresses for both the frame buffer
     790// Me must compute the physical base addresses for both the device buffer
    853791// and the user buffer before programming the DMA transfer.
    854792// The GIET being fully static, we don't need to split the transfer in 4 Kbytes
     
    856794// Returns 0 if success, > 0 if error.
    857795//////////////////////////////////////////////////////////////////////////////////
    858 unsigned int _fb_dma_access( unsigned int       to_user,
     796unsigned int _dma_transfer(  unsigned int   dev_type,
     797                             unsigned int   to_user,
    859798                             unsigned int   offset,
    860799                             unsigned int   user_vaddr,
     
    862801{
    863802#if NB_DMAS_MAX > 0
    864     unsigned int        ko;                             // unsuccessfull V2P translation
    865     unsigned int        flags;                  // protection flags
    866     unsigned int        ppn;                    // physical page number
    867     unsigned int    user_pbase;         // user buffer pbase address
    868     unsigned int    fb_pbase;           // frame buffer pbase address
     803    unsigned int        ko;                                     // unsuccessfull V2P translation
     804    unsigned int        flags;                          // protection flags
     805    unsigned int        ppn;                            // physical page number
     806    unsigned int    user_pbase;                 // user buffer pbase address
     807    unsigned int    device_pbase;                       // frame buffer pbase address
     808    unsigned int        device_vaddr;                   // device buffer vbase address
     809
     810    // check user buffer address and length alignment
     811    if ( (user_vaddr & 0x3) || (length & 0x3) )
     812    {
     813        _get_lock(&_tty_put_lock);
     814        _puts("\n[GIET ERROR] in _dma_transfer : user buffer not word aligned\n");
     815        _release_lock(&_tty_put_lock);
     816        return 1;
     817    }
    869818
    870819    // get DMA channel and compute DMA vbase address
    871820    unsigned int        task_id    = _get_current_task_id();
    872     unsigned int        dma_id     = _get_context_slot( task_id, CTX_FBDMA_ID );
     821    unsigned int    dma_id     = _get_context_slot( task_id, CTX_DMA_ID );
    873822    unsigned int    cluster_id = dma_id / NB_DMAS_MAX;
    874823    unsigned int    loc_id     = dma_id % NB_DMAS_MAX;
    875 
    876     unsigned int*       dma_base   = (unsigned int*)( (char*)&seg_dma_base +
    877                                  (cluster_id * (unsigned)CLUSTER_SIZE) );
    878  
    879     // check user buffer address and length alignment
    880     if ( (user_vaddr & 0x3) || (length & 0x3) )
    881     {
    882         _get_lock(&_tty_put_lock);
    883         _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not word aligned\n");
    884         _release_lock(&_tty_put_lock);
    885         return 1;
    886     }
    887 
    888     // get user space page table virtual address
     824    unsigned int*       dma_base   = (unsigned int*)( (char*)&seg_dma_base +
     825                                    (cluster_id * (unsigned)CLUSTER_SIZE) );
     826
     827    // get page table address
    889828    unsigned int        user_ptab = _get_context_slot( task_id, CTX_PTAB_ID );
    890829
    891     // compute frame buffer pbase address
    892     unsigned int fb_vaddr = (unsigned int)&seg_fbf_base + offset;
    893 
     830    // get peripheral buffer virtual address
     831    if ( dev_type)  device_vaddr = (unsigned int)&seg_nic_base + offset;
     832    else            device_vaddr = (unsigned int)&seg_fbf_base + offset;
     833
     834    // get device buffer physical address
    894835    ko = _v2p_translate( (page_table_t*)user_ptab,
    895                          (fb_vaddr >> 12),
     836                         (device_vaddr >> 12),
    896837                         &ppn,
    897838                         &flags );
    898     fb_pbase = (ppn << 12) | (fb_vaddr & 0x00000FFF);
    899 
    900839    if ( ko )
    901840    {
    902841        _get_lock(&_tty_put_lock);
    903         _puts("\n[GIET ERROR] in _fbdma_access() : frame buffer unmapped\n");
     842        _puts("\n[GIET ERROR] in _dma_transfer : device buffer unmapped\n");
    904843        _release_lock(&_tty_put_lock);
    905844        return 2;
    906845    }
    907 
    908     // Compute user buffer pbase address
     846    device_pbase = (ppn << 12) | (device_vaddr & 0x00000FFF);
     847
     848    // Compute user buffer physical address
    909849    ko = _v2p_translate( (page_table_t*)user_ptab,
    910850                         (user_vaddr >> 12),
    911851                         &ppn,
    912852                         &flags );
    913     user_pbase = (ppn << 12) | (user_vaddr & 0x00000FFF);
    914 
    915853    if ( ko )
    916854    {
    917855        _get_lock(&_tty_put_lock);
    918         _puts("\n[GIET ERROR] in _fbdma_access() : user buffer unmapped\n");
     856        _puts("\n[GIET ERROR] in _dma_transfer() : user buffer unmapped\n");
    919857        _release_lock(&_tty_put_lock);
    920858        return 3;
     
    923861    {
    924862        _get_lock(&_tty_put_lock);
    925         _puts("[GIET ERROR] in _fbdma_access() : user buffer not in user space\n");
     863        _puts("[GIET ERROR] in _dma_transfer() : user buffer not in user space\n");
    926864        _release_lock(&_tty_put_lock);
    927865        return 4;
     
    930868    {
    931869        _get_lock(&_tty_put_lock);
    932         _puts("\n[GIET ERROR] in _fbdma_access() : user buffer not writable\n");
     870        _puts("\n[GIET ERROR] in _dma_transfer() : user buffer not writable\n");
    933871        _release_lock(&_tty_put_lock);
    934872        return 5;
    935873    }
    936 
    937 
    938 
    939 /*
     874    user_pbase = (ppn << 12) | (user_vaddr & 0x00000FFF);
     875
     876/*  This is a draft for IOMMU support
     877   
    940878    // loop on all virtual pages covering the user buffer
    941879    unsigned int user_vpn_min = user_vaddr >> 12;
     
    987925    // invalidate data cache in case of memory write
    988926    if ( to_user ) _dcache_buf_invalidate( (void*)user_vaddr, length );
    989 
     927   
    990928    // get the lock
    991929    _get_lock( &_dma_lock[dma_id] );
     
    994932    if ( to_user )
    995933    {
    996         dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int)fb_pbase;
     934        dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int)device_pbase;
    997935        dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int)user_pbase;
    998936    }
     
    1000938    {
    1001939        dma_base[loc_id*DMA_SPAN + DMA_SRC] = (unsigned int)user_pbase;
    1002         dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int)fb_pbase;
     940        dma_base[loc_id*DMA_SPAN + DMA_DST] = (unsigned int)device_pbase;
    1003941    }
    1004942    dma_base[loc_id*DMA_SPAN + DMA_LEN] = (unsigned int)length;
     
    1007945
    1008946#else //NB_DMAS_MAX == 0
     947
    1009948    return -1;
    1010 #endif
    1011 
     949
     950#endif
     951}  // end _dma_transfer() 
     952
     953//////////////////////////////////////////////////////////////////////////////////
     954// _dma_completed()
     955// This function checks completion of a DMA transfer to or from a peripheral
     956// device (Frame Buffer or Multi-Nic).
     957// As it is a blocking call, the processor is busy waiting.
     958// Returns 0 if success, > 0 if error
     959// (1 == read error / 2 == DMA idle error / 3 == write error)
     960//////////////////////////////////////////////////////////////////////////////////
     961unsigned int _dma_completed()
     962{
     963#if NB_DMAS_MAX > 0
     964    unsigned int    task_id = _get_current_task_id();
     965    unsigned int    dma_id  = _get_context_slot( task_id, CTX_DMA_ID );
     966
     967    // busy waiting with a pseudo random delay between bus access
     968    while (_dma_done[dma_id] == 0)
     969    {
     970        unsigned int delay = (( _proctime() ^ _procid()<<4 ) & 0x3F) + 1;
     971        asm volatile("move  $3,   %0                    \n"
     972                     "loop_nic_completed:               \n"
     973                     "addi  $3, $3, -1              \n"
     974                     "bnez  $3, loop_nic_completed      \n"
     975                     "nop                                       \n"
     976                     :
     977                     : "r"(delay)
     978                     : "$3" );
     979    }
     980   
     981/* draft support for IOMMU
     982    // unmap the buffer from IOMMU page table if IOMMU is activated
     983    if ( GIET_IOMMU_ACTIVE )
     984    {
     985        unsigned int* iob_address = (unsigned int*)&seg_iob_base;
     986
     987        unsigned int  ix1         = _dma_iommu_ix1 + dma_id;
     988        unsigned int  ix2;
     989
     990        for ( ix2 = 0 ; ix2 < _dma_iommu_npages[dma_id] ; ix2++ )
     991        {
     992            // unmap the page in IOMMU page table
     993            _iommu_inval_pte2( ix1,             // PT1 index
     994                               ix2 );   // PT2 index
     995
     996            // clear IOMMU TLB
     997            iob_address[IOB_INVAL_PTE] = (ix1 << 21) | (ix2 << 12);
     998        }
     999    }
     1000*/
     1001
     1002    // reset synchronization variables
     1003    _dma_lock[dma_id] = 0;
     1004    _dma_done[dma_id] = 0;
     1005
     1006    return _dma_status[dma_id];
     1007
     1008#else //NB_DMAS_MAX == 0
     1009    return -1;
     1010#endif
     1011}  // end _dma_completed
     1012
     1013//////////////////////////////////////////////////////////////////////////////////
     1014//      VciFrameBuffer driver
     1015//////////////////////////////////////////////////////////////////////////////////
     1016// The vci_frame_buffer device can be accessed directly by software with memcpy(),
     1017// or it can be accessed through a multi-channels DMA component:
     1018// 
     1019// The '_fb_sync_write' and '_fb_sync_read' functions use a memcpy strategy to
     1020// implement the transfer between a data buffer (user space) and the frame
     1021// buffer (kernel space). They are blocking until completion of the transfer.
     1022//
     1023// The '_fb_write()', '_fb_read()' and '_fb_completed()' functions use the
     1024// VciMultiDma components (distributed in the clusters) to transfer data
     1025// between the user buffer and the frame buffer. A  FBDMA channel is
     1026// allocated to each task requesting it in the mapping_info data structure.
     1027//////////////////////////////////////////////////////////////////////////////////
     1028
     1029//////////////////////////////////////////////////////////////////////////////////
     1030// _fb_sync_write()
     1031// Transfer data from an memory buffer to the frame_buffer device using a memcpy.
     1032// - offset : offset (in bytes) in the frame buffer.
     1033// - buffer : base address of the memory buffer.
     1034// - length : number of bytes to be transfered.
     1035//////////////////////////////////////////////////////////////////////////////////
     1036unsigned int _fb_sync_write( unsigned int       offset,
     1037                             const void*        buffer,
     1038                             unsigned int       length )
     1039{
     1040    unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset;
     1041    memcpy((void*)fb_address, (void*)buffer, length);
     1042    return 0;
     1043}
     1044
     1045//////////////////////////////////////////////////////////////////////////////////
     1046// _fb_sync_read()
     1047// Transfer data from the frame_buffer device to a memory buffer using a memcpy.
     1048// - offset : offset (in bytes) in the frame buffer.
     1049// - buffer : base address of the memory buffer.
     1050// - length : number of bytes to be transfered.
     1051//////////////////////////////////////////////////////////////////////////////////
     1052unsigned int _fb_sync_read( unsigned int        offset,
     1053                            const void*         buffer,
     1054                            unsigned int        length )
     1055{
     1056    unsigned char *fb_address = (unsigned char*)&seg_fbf_base + offset;
     1057    memcpy((void*)buffer, (void*)fb_address, length);
     1058    return 0;
     1059}
     1060
    10121061//////////////////////////////////////////////////////////////////////////////////
    10131062// _fb_write()
     
    10191068//////////////////////////////////////////////////////////////////////////////////
    10201069unsigned int _fb_write( unsigned int    offset,
    1021                         const void*             buffer,
     1070                        const    void*  buffer,
    10221071                        unsigned int    length )
    10231072{
    1024     return _fb_dma_access( 0,                                           // write to frame buffer
    1025                            offset,
    1026                            (unsigned int)buffer,
    1027                            length );   
     1073    return _dma_transfer( 0,                                            // frame buffer
     1074                          0,                                            // write
     1075                                  offset,
     1076                                  (unsigned int)buffer,
     1077                                  length );     
    10281078}
    10291079
     
    10401090                       unsigned int     length )
    10411091{
    1042     return _fb_dma_access( 1,                                           // read from frame buffer
    1043                            offset,
    1044                            (unsigned int)buffer,
    1045                            length );   
     1092    return _dma_transfer( 0,                                            // frame buffer
     1093                          1,                                            // read
     1094                                  offset,
     1095                                  (unsigned int)buffer,
     1096                                  length );     
    10461097}
    10471098
     
    10551106unsigned int _fb_completed()
    10561107{
    1057 #if NB_DMAS_MAX > 0
    1058     unsigned int task_id = _get_current_task_id();
    1059     unsigned int dma_id  = _get_context_slot( task_id, CTX_FBDMA_ID );
    1060 
    1061     // busy waiting with a pseudo random delay between bus access
    1062     while (_dma_done[dma_id] == 0)
    1063     {
    1064             unsigned int i;
    1065         unsigned int delay = ( _proctime() ^ _procid()<<4 ) & 0xFF;
    1066         for (i = 0; i < delay; i++)
    1067             asm volatile("nop");
    1068     }
    1069    
    1070     // unmap the buffer from IOMMU page table if IOMMU is activated
    1071     if ( IOMMU_ACTIVE )
    1072     {
    1073         unsigned int* iob_address = (unsigned int*) &seg_iob_base;
    1074 
    1075         unsigned int  ix1         = _dma_iommu_ix1 + dma_id;
    1076         unsigned int  ix2;
    1077 
    1078         for ( ix2 = 0 ; ix2 < _dma_iommu_npages[dma_id] ; ix2++ )
    1079         {
    1080             // unmap the page in IOMMU page table
    1081             _iommu_inval_pte2( ix1,             // PT1 index
    1082                                ix2 );   // PT2 index
    1083 
    1084             // clear IOMMU TLB
    1085             iob_address[IOB_INVAL_PTE] = (ix1 << 21) | (ix2 << 12);
    1086         }
    1087     }
    1088 
    1089     // reset synchronization variables
    1090     _dma_lock[dma_id] = 0;
    1091     _dma_done[dma_id] = 0;
    1092 
    1093     return _dma_status[dma_id];
    1094 
    1095 #else //NB_DMAS_MAX == 0
    1096 
    1097     return -1;
    1098 
    1099 #endif
    1100 }
    1101 
     1108    return _dma_completed();
     1109}
     1110
     1111//////////////////////////////////////////////////////////////////////////////////
     1112//      VciMultiNic driver
     1113//////////////////////////////////////////////////////////////////////////////////
     1114// The VciMultiNic device can be accessed directly by software with memcpy(),
     1115// or it can be accessed through a multi-channels DMA component:
     1116// 
     1117// The '_nic_sync_write' and '_nic_sync_read' functions use a memcpy strategy to
     1118// implement the transfer between a data buffer (user space) and the NIC
     1119// buffer (kernel space). They are blocking until completion of the transfer.
     1120//
     1121// The '_nic_write()', '_nic_read()' and '_nic_completed()' functions use the
     1122// VciMultiDma components (distributed in the clusters) to transfer data
     1123// between the user buffer and the NIC. A  NIDMA channel is allocated to each
     1124// task requesting it in the mapping_info data structure.
     1125//////////////////////////////////////////////////////////////////////////////////
     1126
     1127//////////////////////////////////////////////////////////////////////////////////
     1128// _nic_sync_write()
     1129// Transfer data from an memory buffer to the NIC device using a memcpy.
     1130// - offset : offset (in bytes) in the frame buffer.
     1131// - buffer : base address of the memory buffer.
     1132// - length : number of bytes to be transfered.
     1133//////////////////////////////////////////////////////////////////////////////////
     1134unsigned int _nic_sync_write( unsigned int      offset,
     1135                              const void*       buffer,
     1136                              unsigned int      length )
     1137{
     1138    unsigned char *nic_address = (unsigned char*)&seg_nic_base + offset;
     1139    memcpy((void*)nic_address, (void*)buffer, length);
     1140    return 0;
     1141}
     1142
     1143//////////////////////////////////////////////////////////////////////////////////
     1144// _nic_sync_read()
     1145// Transfer data from the NIC device to a memory buffer using a memcpy.
     1146// - offset : offset (in bytes) in the frame buffer.
     1147// - buffer : base address of the memory buffer.
     1148// - length : number of bytes to be transfered.
     1149//////////////////////////////////////////////////////////////////////////////////
     1150unsigned int _nic_sync_read( unsigned int       offset,
     1151                             const void*        buffer,
     1152                             unsigned int       length )
     1153{
     1154    unsigned char *nic_address = (unsigned char*)&seg_nic_base + offset;
     1155    memcpy((void*)buffer, (void*)nic_address, length);
     1156    return 0;
     1157}
     1158
     1159//////////////////////////////////////////////////////////////////////////////////
     1160// _nic_write()
     1161// Transfer data from a memory buffer to the NIC device using  DMA.
     1162// - offset : offset (in bytes) in the frame buffer.
     1163// - buffer : base address of the memory buffer.
     1164// - length : number of bytes to be transfered.
     1165// Returns 0 if success, > 0 if error.
     1166//////////////////////////////////////////////////////////////////////////////////
     1167unsigned int _nic_write( unsigned int   offset,
     1168                         const void*    buffer,
     1169                         unsigned int   length )
     1170{
     1171    return _dma_transfer( 1,            // NIC
     1172                          0,                    // write
     1173                                      offset,
     1174                                      (unsigned int)buffer,
     1175                                      length );
     1176}
     1177
     1178//////////////////////////////////////////////////////////////////////////////////
     1179// _nic_read()
     1180// Transfer data from the NIC device to a memory buffer using  DMA.
     1181// - offset : offset (in bytes) in the frame buffer.
     1182// - buffer : base address of the memory buffer.
     1183// - length : number of bytes to be transfered.
     1184// Returns 0 if success, > 0 if error.
     1185//////////////////////////////////////////////////////////////////////////////////
     1186unsigned int _nic_read( unsigned int    offset,
     1187                        const void*             buffer,
     1188                        unsigned int    length )
     1189{
     1190    return _dma_transfer( 1,            // NIC
     1191                          1,                    // read
     1192                          offset,
     1193                                      (unsigned int)buffer,
     1194                                      length );
     1195}
     1196
     1197//////////////////////////////////////////////////////////////////////////////////
     1198// _nic_completed()
     1199// This function checks completion of a DMA transfer to or fom a NIC channel.
     1200// As it is a blocking call, the processor is busy waiting.
     1201// Returns 0 if success, > 0 if error
     1202// (1 == read error / 2 == DMA idle error / 3 == write error)
     1203//////////////////////////////////////////////////////////////////////////////////
     1204unsigned int _nic_completed()
     1205{
     1206    return _dma_completed();
     1207}
     1208
  • soft/giet_vm/sys/drivers.h

    r207 r218  
    88#ifndef _GIET_SYS_DRIVERS_H_
    99#define _GIET_SYS_DRIVERS_H_
     10
    1011
    1112///////////////////////////////////////////////////////////////////////////////////
     
    9697                              unsigned int*     status );
    9798
     99unsigned int _dma_transfer(   unsigned int  dev_type,
     100                              unsigned int  to_user,
     101                              unsigned int  offset,
     102                              unsigned int  user_vaddr,
     103                              unsigned int  length );
     104
     105unsigned int _dma_completed();
     106
    98107///////////////////////////////////////////////////////////////////////////////////
    99108// Frame Buffer access functions  (vci_frame_buffer)
     
    119128
    120129///////////////////////////////////////////////////////////////////////////////////
     130// NIC device access functions  (vci_multi_nic)
     131///////////////////////////////////////////////////////////////////////////////////
     132
     133unsigned int _nic_sync_write(unsigned int       offset,
     134                            const void*         buffer,
     135                            unsigned int        length);
     136
     137unsigned int _nic_sync_read( unsigned int       offset,
     138                            const void*         buffer,
     139                            unsigned int        length);
     140
     141
     142unsigned int _nic_write(    unsigned int        offset,
     143                                        const void*             buffer,
     144                                        unsigned int    length);
     145
     146unsigned int _nic_read(     unsigned int        offset,
     147                                        const void*             buffer,
     148                                        unsigned int    length);
     149
     150unsigned int _nic_completed();
     151
     152///////////////////////////////////////////////////////////////////////////////////
    121153// GCD access functions
    122154///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/sys/exc_handler.c

    r207 r218  
    6868static void _display_cause(unsigned int type)
    6969{
     70    _get_lock(&_tty_put_lock);
    7071    _puts("\n[GIET] Exception for task ");
    7172    _putd( _get_current_task_id() );
     
    8182    _putx( _get_bvar() );
    8283    _puts("\n");
     84    _puts("...Task desactivated\n");
     85    _release_lock(&_tty_put_lock);
    8386
    8487    // goes to sleeping state
  • soft/giet_vm/sys/kernel_init.c

    r216 r218  
    3333
    3434///////////////////////////////////////////////////////////////////////////////////
    35 // Kernel Global variables
     35// array of pointers on the page tables (both virtual and physical addresses)
    3636///////////////////////////////////////////////////////////////////////////////////
    3737
     
    4242unsigned int                    _ptabs_vaddr[GIET_NB_VSPACE_MAX];
    4343
     44///////////////////////////////////////////////////////////////////////////////////
     45// array of pointers on the schedulers (physical addresses)
     46///////////////////////////////////////////////////////////////////////////////////
     47
    4448__attribute__((section (".kdata")))
    4549static_scheduler_t*             _schedulers_paddr[NB_CLUSTERS*NB_PROCS_MAX];
     50
     51///////////////////////////////////////////////////////////////////////////////////
     52// staks for the "idle" tasks (256 bytes for each processor)
     53///////////////////////////////////////////////////////////////////////////////////
    4654
    4755__attribute__((section (".kdata")))
     
    201209    }
    202210
    203     // step 5 : initialise the "idle" task context
     211    // step 5 : initialise, for each processor, the "idle" task context:
    204212    //          the SR initialisation value is 0xFF03 because
    205     //          the task _ctx_idle() executes in kernel mode...
     213    //          the task _ctx_idle() executes in kernel mode.
    206214    //          it uses the page table of vspace[0]
     215    //          the stack size is 256 bytes
    207216 
    208217    _set_context_slot( IDLE_TASK_INDEX, CTX_RUN_ID,  1 );
    209218    _set_context_slot( IDLE_TASK_INDEX, CTX_SR_ID,   0xFF03 );
    210     _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID,   (unsigned int)&_idle_stack[global_pid] + 64 );
     219    _set_context_slot( IDLE_TASK_INDEX, CTX_SP_ID,   (unsigned int)_idle_stack + (global_pid<<8) );
    211220    _set_context_slot( IDLE_TASK_INDEX, CTX_RA_ID,   (unsigned int)&_ctx_eret );
    212221    _set_context_slot( IDLE_TASK_INDEX, CTX_EPC_ID,  (unsigned int)&_ctx_idle );
     
    233242
    234243        _get_lock( &_tty_put_lock );
    235         _puts("\n [GIET WARNING] No task allocated to processor ");
     244        _puts("\n[GIET WARNING] No task allocated to processor ");
    236245        _putd( global_pid );
    237246        _puts(" => idle\n");
  • soft/giet_vm/sys/sys_handler.c

    r215 r218  
    4949    &_sys_ukn,          /* 0x19 */
    5050    &_vobj_get_vbase,   /* 0x1A */
    51     &_sys_ukn,          /* 0x1B */
    52     &_sys_ukn,          /* 0x1C */
    53     &_sys_ukn,          /* 0x1D */
     51    &_nic_write,        /* 0x1B */
     52    &_nic_read,         /* 0x1C */
     53    &_nic_completed,    /* 0x1D */
    5454    &_sys_ukn,          /* 0x1E */
    5555    &_sys_ukn,          /* 0x1F */
  • soft/giet_vm/xml/xml_parser.c

    r217 r218  
    138138unsigned int dma_base_offset = 0xFFFFFFFF;
    139139unsigned int ioc_base_offset = 0xFFFFFFFF;
     140unsigned int nic_base_offset = 0xFFFFFFFF;
    140141unsigned int fbf_base_offset = 0xFFFFFFFF;
    141142unsigned int icu_base_offset = 0xFFFFFFFF;
     
    10941095            else  error = 1;
    10951096
    1096             //nic_base_offset = pseg[ periph[periph_index]->psegid ]->base;
     1097            nic_base_offset = pseg[ periph[periph_index]->psegid ]->base;
    10971098            nb_nic_channel = periph[periph_index]->channels;
    10981099        }
     
    21652166    ld_write(fdout, "seg_icu_base" ,  icu_base_offset);
    21662167    ld_write(fdout, "seg_ioc_base" ,  ioc_base_offset);
     2168    ld_write(fdout, "seg_nic_base" ,  nic_base_offset);
    21672169    ld_write(fdout, "seg_tty_base" ,  tty_base_offset);
    21682170    ld_write(fdout, "seg_dma_base" ,  dma_base_offset);
Note: See TracChangeset for help on using the changeset viewer.