Changeset 95


Ignore:
Timestamp:
Jun 29, 2017, 1:40:15 PM (4 years ago)
Author:
alain
Message:

hal_special: replace hal_time_stamp() by hal_get_cycles()
hal_remote : remove hal_remove_unc()

Location:
trunk/hal
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/generic/hal_remote.h

    r72 r95  
    105105
    106106/*****************************************************************************************
    107  * This function reads an uncachable 32 bits word in a remote cluster.
    108  *****************************************************************************************
    109  * @ xp      : extended pointer to remote data
    110  * @ return read value
    111  ****************************************************************************************/
    112 uint32_t hal_remote_lw_unc( xptr_t  xp );
    113 
    114 /*****************************************************************************************
    115107 * This non blocking function makes an atomic Compare-And-Swap in a remote cluster.
    116108 *****************************************************************************************
     
    136128
    137129/*****************************************************************************************
    138  * This function makes an atomic "and" between a local mask value and
     130 * This blocking function makes an atomic "and" between a local mask value and
    139131 * a 32 bits integer in a remote cluster. Returns only after success.
    140132 *****************************************************************************************
     
    147139
    148140/*****************************************************************************************
    149  * This function makes an atomic "or" between a local mask value and
     141 * This blocking function makes an atomic "or" between a local mask value and
    150142 * a 32 bits integer in a remote cluster. Returns only after success.
    151143 *****************************************************************************************
  • trunk/hal/generic/hal_special.h

    r17 r95  
    33 *
    44 * Authors   Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *           Alain Greiner    (2016)
     5 *           Alain Greiner    (2016,2017)
    66 *
    77 * Copyright (c)  UPMC Sorbonne Universites
     
    4444
    4545/*****************************************************************************************
    46  * This function returns the content of the calling core cycles counter register.
     46 * This function returns the content of the calling core cycles counter.
     47 * This cycle counter is reset when the core is initialised (at reboot).
     48 * If the hardware counter is not a 64 bits register, this function is in charge
     49 * of handling overflow.
    4750 ****************************************************************************************/
    48 uint32_t hal_time_stamp();
     51uint64_t hal_time_stamp();
    4952
    5053/*****************************************************************************************
  • trunk/hal/generic/hal_uspace.h

    r23 r95  
    3131//
    3232// When moving data between user space and kernel space, the user address is always
    33 // a virtual address, but the kernel address can be a physical address, on some
    34 // architectures. For sake of portability, data transfers must use the following API.
     33// a virtual address, but the kernel address can be a physical address, on 32 bits
     34// architectures, and require MMU dynamic activation/deactivation.
     35// For sake of portability, user/kernel data transfers must use the following API.
    3536//////////////////////////////////////////////////////////////////////////////////////////
    3637
     
    6162
    6263/*****************************************************************************************
     64 * This function tranfers a NUL terminated string from the user space to the kernel space.
     65 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
     66 *****************************************************************************************
     67 * @ u_dst     : destination buffer address in user space.
     68 * @ k_src     : source address in kernel space.
     69 ****************************************************************************************/
     70extern void hal_strcpy_from_uspace( char * k_dst,
     71                                    char * u_src );
     72
     73/*****************************************************************************************
     74 * This function tranfers a NUL terminated string from the kernel space to the user space.
     75 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
     76 *****************************************************************************************
     77 * @ u_dst     : destination buffer address in user space.
     78 * @ k_src     : source address in kernel space.
     79 ****************************************************************************************/
     80extern void hal_strcpy_to_uspace( char * u_dst,
     81                                  char * k_src );
     82
     83/*****************************************************************************************
    6384 * This function computes the length of a string in user space.
    6485 * If the kernel uses physical addresses, it activates the MMU to access the user buffer.
     
    6788 * @ return length of the string.
    6889 ****************************************************************************************/
    69 uint32_t hal_strlen_from_uspace( char     * string );
     90uint32_t hal_strlen_from_uspace( char * string );
    7091
    7192
  • trunk/hal/tsar_mips32/core/hal_remote.c

    r92 r95  
    154154}
    155155
    156 ////////////////////////////////////////
    157 uint32_t hal_remote_lw_unc( xptr_t  xp )
    158 {
    159         uint32_t data;
    160     uint32_t ptr = (uint32_t)GET_PTR( xp );
    161     uint32_t cxy = (uint32_t)GET_CXY( xp );
    162 
    163     asm volatile(
    164         ".set noreorder              \n"
    165         "mfc2   $15,    $24          \n"  /* $15 <= PADDR_EXT   */
    166         "mtc2   %2,     $24          \n"  /* PADDR_EXT <= cxy   */   
    167         "ll     %0,     0(%1)        \n"  /* data <= *paddr     */
    168         "mtc2   $15,    $24          \n"  /* PADDR_EXT <= $15   */   
    169         ".set reorder                \n"
    170         : "=r" (data) : "r" (ptr), "r" (cxy) : "$15" );
    171 
    172         return ( data );
    173 }
    174 
    175156///////////////////////////////////////////
    176157bool_t hal_remote_atomic_cas( xptr_t    xp,
  • trunk/hal/tsar_mips32/core/hal_special.c

    r62 r95  
    4242
    4343/////////////////////////
    44 uint32_t hal_time_stamp()
    45 {
    46         uint32_t cycles;
    47  
    48         asm volatile ("mfc0   %0,  $9  " : "=&r" (cycles));
    49  
     44uint64_t hal_get_cycles()
     45{
     46        uint64_t cycles;                // absolute time to be returned
     47    uint32_t last_count;            // last registered cycles count
     48    uint32_t current_count;         // current cycles count
     49        uint32_t elapsed;
     50
     51    core_t * core = CURRENT_THREAD->core;
     52
     53    // get last registered time stamp
     54        last_count = core->time_stamp;
     55
     56    // get current time stamp from hardware register
     57        asm volatile ("mfc0   %0,  $9  " : "=&r" (current_count));
     58
     59        // compute number of elapsed cycles, taking into account 32 bits register wrap
     60        if(current_count < last_count) elapsed = (0xFFFFFFFF - last_count) + current_count;
     61        else                           elapsed = current_count - last_count;
     62
     63    // compute absolute time
     64        cycles = core->cycles + elapsed;
     65
     66        // update core time
     67        core->time_stamp = current_count;
     68        core->cycles     = cycles;
     69
     70        hal_wbflush();
     71
    5072        return cycles;
    5173}
Note: See TracChangeset for help on using the changeset viewer.