Ignore:
Timestamp:
Jun 10, 2014, 12:33:23 PM (10 years ago)
Author:
alain
Message:

All drivers have been modified to use only the information
contained in the hard_config.h file

File:
1 edited

Legend:

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

    r295 r320  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
    7 
     7// This peripheral is replicated in aall clusters containing processors.
     8//
     9// SEG_XCU_BASE and VSEG_CLUSTER_INCREMENT must be defined in hard_config.h file.
     10///////////////////////////////////////////////////////////////////////////////////
     11
     12#include <hard_config.h>
    813#include <giet_config.h>
    914#include <xcu_driver.h>
     
    3237#endif
    3338
    34 #if !defined( USE_XICU )
    35 # error: You must define USE_XICU in the hard_config.h file
     39#if !defined( USE_XCU )
     40# error: You must define USE_XCU in the hard_config.h file
     41#endif
     42
     43#if !defined( SEG_XCU_BASE )
     44# error: You must define SEG_XCU_BASE in the hard_config.h file
     45#endif
     46
     47#if !defined( VSEG_CLUSTER_INCREMENT )
     48# error: You must define VSEG_CLUSTER_INCREMENT in the hard_config.h file
    3649#endif
    3750
     
    4760                    unsigned int irq_type )
    4861{
    49 #if USE_XICU
     62#if USE_XCU
    5063    // parameters checking
    5164    unsigned int x = cluster_xy >> Y_WIDTH;
     
    5568    if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit();
    5669
    57     volatile unsigned int* xcu_address =
    58         (unsigned int *) ((unsigned int)&seg_xcu_base +
    59         (cluster_xy * (unsigned int)&vseg_cluster_increment));
     70    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     71                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
    6072
    6173    unsigned int func;
    62     if      (irq_type == IRQ_TYPE_PTI) func = XICU_MSK_PTI_ENABLE;
    63     else if (irq_type == IRQ_TYPE_WTI) func = XICU_MSK_WTI_ENABLE;
    64     else if (irq_type == IRQ_TYPE_HWI) func = XICU_MSK_HWI_ENABLE;
     74    if      (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE;
     75    else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE;
     76    else if (irq_type == IRQ_TYPE_HWI) func = XCU_MSK_HWI_ENABLE;
    6577    else
    6678    {
     
    6981    }
    7082
    71     xcu_address[XICU_REG(func,channel)] = value;
    72 
    73 #else
    74     _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_XICU not set\n");
     83    xcu_address[XCU_REG(func,channel)] = value;
     84
     85#else
     86    _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_XCU not set\n");
    7587    _exit();
    7688#endif
     
    90102                     unsigned int * irq_type )
    91103{
    92 #if USE_XICU
     104#if USE_XCU
    93105    // parameters checking
    94106    unsigned int x = cluster_xy >> Y_WIDTH;
     
    98110    if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit();
    99111
    100     volatile unsigned int* xcu_address =
    101         (unsigned int *) ((unsigned int)&seg_xcu_base +
    102         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    103 
    104     unsigned int prio = xcu_address[XICU_REG(XICU_PRIO,channel)];
     112    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     113                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     114
     115    unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)];
    105116    unsigned int pti_ok = (prio & 0x00000001);
    106117    unsigned int hwi_ok = (prio & 0x00000002);
     
    130141 
    131142#else
    132     _printf("[GIET ERROR] _xcu_get_index should not be used if USE_XICU is not set\n");
     143    _printf("[GIET ERROR] _xcu_get_index should not be used if USE_XCU is not set\n");
    133144    _exit();
    134145#endif
     
    143154                    unsigned int wdata )
    144155{
    145 #if USE_XICU
     156#if USE_XCU
    146157    // parameters checking
    147158    unsigned int x = cluster_xy >> Y_WIDTH;
     
    151162    if (wti_index >= 32)           _exit();
    152163
    153     volatile unsigned int* xcu_address =
    154         (unsigned int *) ((unsigned int)&seg_xcu_base +
    155         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    156 
    157     xcu_address[XICU_REG(XICU_WTI_REG,wti_index)] = wdata;
    158 
    159 #else
    160     _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XICU is not set\n");
     164    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     165                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     166
     167    xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata;
     168
     169#else
     170    _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XCU is not set\n");
    161171    _exit();
    162172#endif
     
    173183                         unsigned int * value )
    174184{
    175 #if USE_XICU
     185#if USE_XCU
    176186    // parameters checking
    177187    unsigned int x = cluster_xy >> Y_WIDTH;
     
    181191    if (wti_index >= 32)           _exit();
    182192 
    183     volatile unsigned int* xcu_address =
    184         (unsigned int *) ((unsigned int)&seg_xcu_base +
    185         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    186 
    187     *value = xcu_address[XICU_REG(XICU_WTI_REG, wti_index)];
    188 
    189 #else
    190     _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XICU is not set\n");
     193    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     194                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     195
     196    *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)];
     197
     198#else
     199    _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XCU is not set\n");
    191200    _exit();
    192201#endif
     
    203212                           unsigned int * address )
    204213{
    205 #if USE_XICU
     214#if USE_XCU
    206215    if (wti_index >= 32)           _exit();
    207216 
    208     unsigned int xcu_address = (unsigned int)&seg_xcu_base;
    209     *address = xcu_address + (XICU_REG(XICU_WTI_REG, wti_index)<<2);
    210 
    211 #else
    212     _printf("[GIET ERROR] in _xcu_get_wti_address() USE_XICU is not set\n");
    213     _exit();
    214 #endif
    215 }
    216 
    217 ////////////////////////////////////////////////////////////////////////////////
    218 // This function activates a timer contained in XICU by writing in the
     217    unsigned int xcu_address = (unsigned int)SEG_XCU_BASE;
     218    *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2);
     219
     220#else
     221    _printf("[GIET ERROR] in _xcu_get_wti_address() USE_XCU is not set\n");
     222    _exit();
     223#endif
     224}
     225
     226////////////////////////////////////////////////////////////////////////////////
     227// This function activates a timer contained in XCU by writing in the
    219228// proper register the period value.
    220229////////////////////////////////////////////////////////////////////////////////
     
    223232                       unsigned int period )
    224233{
    225 #if USE_XICU
     234#if USE_XCU
    226235    // parameters checking
    227236    unsigned int x = cluster_xy >> Y_WIDTH;
     
    230239    if (y >= Y_SIZE)             _exit();
    231240
    232     volatile unsigned int* xcu_address =
    233         (unsigned int *) ((unsigned int)&seg_xcu_base +
    234         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    235 
    236     xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
    237 
    238 #else
    239     _printf("[GIET ERROR] in _xcu_timer_start() USE_XICU is not set\n");
    240     _exit();
    241 #endif
    242 }
    243 
    244 //////////////////////////////////////////////////////////////////////////////
    245 // This function desactivates a timer in XICU component
     241    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     242                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     243
     244    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
     245
     246#else
     247    _printf("[GIET ERROR] in _xcu_timer_start() USE_XCU is not set\n");
     248    _exit();
     249#endif
     250}
     251
     252//////////////////////////////////////////////////////////////////////////////
     253// This function desactivates a timer in XCU component
    246254// by writing in the proper register.
    247255//////////////////////////////////////////////////////////////////////////////
     
    249257                      unsigned int pti_index)
    250258{
    251 #if USE_XICU
     259#if USE_XCU
    252260    // parameters checking
    253261    unsigned int x = cluster_xy >> Y_WIDTH;
     
    256264    if (y >= Y_SIZE)             _exit();
    257265
    258     volatile unsigned int * xcu_address =
    259         (unsigned int *) ((unsigned int)&seg_xcu_base +
    260         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    261 
    262     xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
    263 
    264 #else
    265     _printf("[GIET ERROR] in _xcu_timer_stop() USE_XICU is not set\n");
    266     _exit();
    267 #endif
    268 }
    269 
    270 //////////////////////////////////////////////////////////////////////////////
    271 // This function acknowlegge a timer interrupt in XICU
    272 // component by reading in the proper register.
     266    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     267                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     268
     269    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
     270
     271#else
     272    _printf("[GIET ERROR] in _xcu_timer_stop() USE_XCU is not set\n");
     273    _exit();
     274#endif
     275}
     276
     277//////////////////////////////////////////////////////////////////////////////
     278// This function acknowlegge a timer interrupt in XCU
     279// component by reading in the proper XCU register.
    273280// It can be used by both the isr_switch() for a "system" timer,
    274281// or by the _isr_timer() for an "user" timer.
    275282//////////////////////////////////////////////////////////////////////////////
    276 void _xcu_timer_reset_irq( unsigned int cluster_xy,
    277                            unsigned int pti_index )
    278 {
    279 #if USE_XICU
     283unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy,
     284                                   unsigned int pti_index )
     285{
     286#if USE_XCU
    280287    // parameters checking
    281288    unsigned int x = cluster_xy >> Y_WIDTH;
     
    284291    if (y >= Y_SIZE)             _exit();
    285292
    286     volatile unsigned int * xcu_address =
    287         (unsigned int *) ((unsigned int)&seg_xcu_base +
    288         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    289 
    290     xcu_address[XICU_REG(XICU_PTI_ACK, pti_index)];
    291 
    292 #else
    293     _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XICU is not set\n");
    294     _exit();
     293    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     294                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     295
     296    // This return value is not used / avoid a compilation warning.
     297    return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)];
     298
     299#else
     300    _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XCU is not set\n");
     301    _exit();
     302    return 0;
    295303#endif
    296304}
     
    307315                           unsigned int pti_index )
    308316{
    309 #if USE_XICU
     317#if USE_XCU
    310318    // parameters checking
    311319    unsigned int x = cluster_xy >> Y_WIDTH;
     
    314322    if (y >= Y_SIZE)             _exit();
    315323
    316     volatile unsigned int * xcu_address =
    317         (unsigned int *) ((unsigned int) &seg_xcu_base +
    318         (cluster_xy * (unsigned int)&vseg_cluster_increment));
    319 
    320     unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, pti_index)];
     324    unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +
     325                                (cluster_xy * VSEG_CLUSTER_INCREMENT) );
     326
     327    unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)];
    321328
    322329    // we write 0 first because if the timer is currently running,
    323330    // the corresponding timer counter is not reset
    324     xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
    325     xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
    326 
    327 #else
    328     _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_XICU is not set\n");
     331    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;
     332    xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;
     333
     334#else
     335    _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_XCU is not set\n");
    329336    _exit();
    330337#endif
Note: See TracChangeset for help on using the changeset viewer.