Changeset 481


Ignore:
Timestamp:
Jan 1, 2015, 8:23:48 PM (9 years ago)
Author:
alain
Message:

1) The NIC, IOC, DMA and HBA drivers have been adapted to support the new _v2p_translate() function prototype (returns void).
2) The _mmc_inval() and _mmc_sync() functions does not use anymore the hard lock in the MMC, but use a soft spin_lock.
3) The NIC driver does not use anymore the GIET_NIC_BUFSIZE, GIET_NIC_NBUFS, and GIET_NIC_TIMEOUT parameters (removed from giet_config.h file).
4) The NIC driver registers map has been modified to support 64 bytes buffer descriptors for chained buffers.

Location:
soft/giet_vm/giet_drivers
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/dma_driver.c

    r456 r481  
    278278    }
    279279
    280     unsigned int ko;
    281280    unsigned int ppn;
    282281    unsigned int flags;
     
    313312
    314313    // get src_paddr buffer physical addresse
    315     ko = _v2p_translate( (page_table_t*)pt,              // page table pointer
    316                          src_vaddr>>12,                  // vpn
    317                          &ppn,                           // ppn
    318                          &flags );                       // flags
    319     if ( ko )
    320     {
    321         _puts("\n[DMA ERROR] in _dma_copy() : source buffer unmapped\n");
    322         _exit();
    323     }
     314    _v2p_translate( (page_table_t*)pt,              // page table pointer
     315                     src_vaddr>>12,                  // vpn
     316                     &ppn,                           // ppn
     317                     &flags );                       // flags
    324318    unsigned long long src_paddr = (((unsigned long long)ppn) << 12) |
    325319                                   (unsigned long long)(src_vaddr & 0x00000FFF);
    326320
    327321    // get dst_paddr buffer physical addresse
    328     ko = _v2p_translate( (page_table_t*)pt,              // page table pointer
    329                          dst_vaddr>>12,                  // vpn
    330                          &ppn,                           // ppn
    331                          &flags );                       // flags
    332     if ( ko )
    333     {
    334         _puts("\n[DMA ERROR] in _dma_copy() : dest buffer unmapped\n");
    335         _exit();
    336     }
     322    _v2p_translate( (page_table_t*)pt,              // page table pointer
     323                     dst_vaddr>>12,                  // vpn
     324                     &ppn,                           // ppn
     325                     &flags );                       // flags
    337326    unsigned long long dst_paddr = (((unsigned long long)ppn) << 12) |
    338327                                   (unsigned long long)(dst_vaddr & 0x00000FFF);
  • soft/giet_vm/giet_drivers/hba_driver.c

    r456 r481  
    173173
    174174        // get ppn and flags
    175         ko = _v2p_translate( (page_table_t*)user_pt_vbase,
    176                               vpn,
    177                               &ppn,
    178                               &flags );
     175        _v2p_translate( (page_table_t*)user_pt_vbase,
     176                        vpn,
     177                        &ppn,
     178                        &flags );
    179179
    180180        // check access rights
    181         if ( ko )
    182         {
    183             _puts("[GIET ERROR] in _hba_set_cmd() : user buffer unmapped\n");
    184             return -1;
    185         }
    186181        if ((flags & PTE_U) == 0)
    187182        {
     
    261256    unsigned int ppn;
    262257    unsigned int flags;
    263     unsigned int fail;
    264258    unsigned int vbase;
    265259    unsigned int c;               // c == command index
     
    281275    // Command list physical addresse
    282276    vbase = (unsigned int)(&hba_cmd_list[channel]);
    283     fail = _v2p_translate( (page_table_t*)pt,
    284                            vbase>>12,
    285                            &ppn,
    286                            &flags );
    287     if ( fail )
    288     {
    289         _puts("[GIET ERROR] in _hba_init() : command list unmapped\n");
    290         return -1;
    291     }
     277    _v2p_translate( (page_table_t*)pt,
     278                     vbase>>12,
     279                     &ppn,
     280                     &flags );
    292281    hba_cmd_list_paddr[channel] = ((paddr_t)ppn) | (vbase & 0xFFF);
    293282
     
    296285    {
    297286        vbase = (unsigned int)(&hba_cmd_table[channel][c]);
    298         fail = _v2p_translate( (page_table_t*)pt,
    299                                vbase>>12,
    300                                &ppn,
    301                                &flags );
    302         if ( fail )
    303         {
    304             _puts("[GIET ERROR] in _hba_init() : command table unmapped\n");
    305             return -1;
    306         }
     287        _v2p_translate( (page_table_t*)pt,
     288                         vbase>>12,
     289                         &ppn,
     290                         &flags );
    307291        hba_cmd_table_paddr[channel][c] = ((paddr_t)ppn) | (vbase & 0xFFF);
    308292    }
  • soft/giet_vm/giet_drivers/ioc_driver.c

    r456 r481  
    150150
    151151        // get user buffer first page ppn and flags
    152         unsigned int ko = _v2p_translate( (page_table_t*)pt_vbase,
    153                                            buf_vaddr >> 12,
    154                                            &ppn,
    155                                            &flags );
     152        _v2p_translate( (page_table_t*)pt_vbase,
     153                        buf_vaddr >> 12,
     154                        &ppn,
     155                        &flags );
     156
    156157        // check access rights
    157         if ( ko )
    158         {
    159             _puts("\n[IOC ERROR] in _ioc_access() : buffer unmapped\n");
    160             _exit();
    161         }
    162 
    163158        if ( (mode == IOC_USER_MODE) && ((flags & PTE_U) == 0) )
    164159        {
  • soft/giet_vm/giet_drivers/mmc_driver.c

    r456 r481  
    66///////////////////////////////////////////////////////////////////////////////////
    77
    8 #include <giet_config.h>
     8#include <hard_config.h>
    99#include <mmc_driver.h>
    1010#include <tty0.h>
     11#include <locks.h>
    1112#include <utils.h>
     13
    1214#include <io.h>
    1315
     
    8991    }
    9092
    91     // get the hard lock protecting exclusive access to MEMC
    92     while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) );
     93    // get the hard queuing lock protecting exclusive access to MEMC
     94    _spin_lock_acquire( &_mmc_lock[x][y] );
    9395
    9496    // write inval arguments
    95     _mmc_set_register(cluster_xy, 0, MEMC_ADDR_LO   , (unsigned int)buf_paddr);
    96     _mmc_set_register(cluster_xy, 0, MEMC_ADDR_HI   , (unsigned int)(buf_paddr>>32));
    97     _mmc_set_register(cluster_xy, 0, MEMC_BUF_LENGTH, buf_length);
    98     _mmc_set_register(cluster_xy, 0, MEMC_CMD_TYPE  , MEMC_CMD_INVAL);
     97    _mmc_set_register( cluster_xy , 0 , MEMC_ADDR_LO   , (unsigned int)buf_paddr );
     98    _mmc_set_register( cluster_xy , 0 , MEMC_ADDR_HI   , (unsigned int)(buf_paddr>>32) );
     99    _mmc_set_register( cluster_xy , 0 , MEMC_BUF_LENGTH, buf_length );
     100    _mmc_set_register( cluster_xy , 0 , MEMC_CMD_TYPE  , MEMC_CMD_INVAL );
    99101
    100102    // release the lock
    101     _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0);
     103    _spin_lock_release( &_mmc_lock[x][y] );
    102104}
    103105
     
    118120    }
    119121
    120     // get the hard lock protecting exclusive access to MEMC
    121     while ( _mmc_get_register(cluster_xy, 0, MEMC_LOCK) );
     122    // get the hard queuing lock protecting exclusive access to MEMC
     123    _spin_lock_acquire( &_mmc_lock[x][y] );
    122124
    123125    // write inval arguments
     
    128130
    129131    // release the lock
    130     _mmc_set_register(cluster_xy, 0, MEMC_LOCK, 0);
     132    _spin_lock_release( &_mmc_lock[x][y] );
    131133}
    132134
  • soft/giet_vm/giet_drivers/mmc_driver.h

    r345 r481  
    88#ifndef _GIET_MMC_DRIVERS_H_
    99#define _GIET_MMC_DRIVERS_H_
     10
     11#include <hard_config.h>
     12#include <locks.h>
    1013
    1114///////////////////////////////////////////////////////////////////////////////////
     
    3033
    3134#define MMC_REG(func,idx) ((func<<7)|idx)
     35
     36///////////////////////////////////////////////////////////////////////////////
     37// Distributed locks protecting MMC components (one per cluster)
     38///////////////////////////////////////////////////////////////////////////////
     39
     40spin_lock_t  _mmc_lock[X_SIZE][Y_SIZE]  __attribute__((aligned(64)));
    3241
    3342///////////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/nic_driver.c

    r456 r481  
    4949# error: You must define USE_IOB in the hard_config.h file
    5050#endif
    51 
    52 #if !defined( GIET_NIC_NBUFS )
    53 # error: You must define GIET_NIC_NBUFS in the giet_config.h file
    54 #endif
    55 
    56 #if !defined( GIET_NIC_BUFSIZE )
    57 # error: You must define GIET_NIC_BUFSIZE in the giet_config.h file
    58 #endif
    59 
    60 #if !defined( GIET_NIC_TIMEOUT )
    61 # error: You must define GIET_NIC_TIMEOUT in the giet_config.h file
    62 #endif
    63 
    64 #define in_unckdata __attribute__((section (".unckdata")))
    6551
    6652///////////////////////////////////////////////////////////////////////////////
  • soft/giet_vm/giet_drivers/nic_driver.h

    r456 r481  
    7676};
    7777
    78 /////////////////////////////////////////////////////////////////////////////////////
     78//////////////////////////////////////////////////////////////////////////////////////////////
    7979//            Channel Addressable Registers
    80 // A container descriptor has the following form:
    81 // LOW WORD  : 32 LSB bits of the container physical base address     
    82 // HIGH WORD : 16 MSB bits of the container physical base address + status (bit 31) 
    83 /////////////////////////////////////////////////////////////////////////////////////
     80// A buffer descriptor occupies 64 bytes, but only 8 bytes (two 32 bits words) are useful:
     81// LOW WORD   contains the 32 LSB bits of the buffer paddr               
     82// HIGH WORD  contains the 16 MSB bits of the buffer paddr, plus status (bit 31)
     83//////////////////////////////////////////////////////////////////////////////////////////////
     84
    8485enum SoclibMultiNicChannelRegisters
    8586{
    8687    NIC_RX_DESC_LO_0          = 0,   // RX_0 descriptor low word         (Read/Write)
    8788    NIC_RX_DESC_HI_0          = 1,   // RX_0 descriptor high word        (Read/Write)
    88     NIC_RX_DESC_LO_1          = 2,   // RX_1 descriptor low word         (Read/Write)
    89     NIC_RX_DESC_HI_1          = 3,   // RX_1 descriptor high word        (Read/Write)
    90     NIC_TX_DESC_LO_0          = 4,   // TX_0 descriptor low word         (Read/Write)
    91     NIC_TX_DESC_HI_0          = 5,   // TX_0 descriptor high word        (Read/Write)
    92     NIC_TX_DESC_LO_1          = 6,   // TX_1 descriptor low word         (Read/Write)
    93     NIC_TX_DESC_HI_1          = 7,   // TX_1 descriptor high word        (Read/Write)
    94     NIC_MAC_4                 = 8,   // channel mac address 32 LSB bits  (Read Only)
    95     NIC_MAC_2                 = 9,   // channel mac address 16 LSB bits  (Read Only)
    96     NIC_RX_RUN                = 10,  // RX packets can be received       (write_only)
    97     NIC_TX_RUN                = 11,  // TX packets can be transmitted    (write_only)
     89    NIC_RX_DESC_LO_1          = 16,  // RX_1 descriptor low word         (Read/Write)
     90    NIC_RX_DESC_HI_1          = 17,  // RX_1 descriptor high word        (Read/Write)
     91    NIC_TX_DESC_LO_0          = 32,  // TX_0 descriptor low word         (Read/Write)
     92    NIC_TX_DESC_HI_0          = 33,  // TX_0 descriptor high word        (Read/Write)
     93    NIC_TX_DESC_LO_1          = 48,  // TX_1 descriptor low word         (Read/Write)
     94    NIC_TX_DESC_HI_1          = 49,  // TX_1 descriptor high word        (Read/Write)
     95    NIC_MAC_4                 = 64,  // channel mac address 32 LSB bits  (Read Only)
     96    NIC_MAC_2                 = 65,  // channel mac address 16 LSB bits  (Read Only)
     97    NIC_RX_RUN                = 66,  // RX packets can be received       (write_only)
     98    NIC_TX_RUN                = 67,  // TX packets can be transmitted    (write_only)
    9899};
    99100
Note: See TracChangeset for help on using the changeset viewer.