openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

buser_sal.h (1246B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  */
      7 
      8 #ifndef BMF_SAL_H
      9 #define BMF_SAL_H
     10 
     11 /*
     12  * include system specific header file for SAL.
     13  */
     14 #if defined(BROADCOM_SAL)
     15 #include <include/sal/core/alloc.h>
     16 #include <include/sal/core/sync.h>
     17 #include <include/sal/core/thread.h>
     18 
     19 typedef sal_mutex_t buser_sal_lock_t;
     20 
     21 /*
     22  * BMF_SAL_SEM_CREATE creates a buser_sal_lock_t and return 
     23  * buser_sal_lock_t back.
     24  */
     25 #define BMF_SAL_LOCK_CREATE(n)       sal_mutex_create((n))
     26 
     27 /*
     28  * Destroy lock.
     29  */
     30 #define BMF_SAL_LOCK_DESTROY(s)      sal_mutex_destroy((s))
     31 
     32 /*
     33  * Take lock.
     34  */
     35 #define BMF_SAL_LOCK(s)              sal_mutex_take((s), sal_mutex_FOREVER)
     36 
     37 /*
     38  * unlock.
     39  */
     40 #define BMF_SAL_UNLOCK(s)            sal_mutex_give((s))
     41 
     42 /*
     43  * memory allocation.
     44  */
     45 #define BMF_SAL_MALLOC(s,n)          sal_alloc((s),(n))
     46 
     47 /*
     48  * free memory.
     49  */
     50 #define BMF_SAL_FREE(p)              sal_free((p))
     51 
     52 /*
     53  * Sleep for t microseconds
     54  */
     55 #define BMF_SAL_USLEEP(t)            sal_usleep((t))
     56 
     57 #else
     58 
     59 #error "User should provide SAL implementation"
     60 
     61 #endif /* BROADCOM_SAL */
     62 
     63 
     64 #endif /* BMF_SAL_H */
     65