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

alloc.h (2385B)


      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  * File: 	alloc.h
      8  * Purpose: 	Memory allocation
      9  */
     10 
     11 #ifndef _SAL_ALLOC_H
     12 #define _SAL_ALLOC_H
     13 
     14 /*
     15  * SAL Memory and Cache Support
     16  *
     17  *    NOTE: This driver was developed only on fully cache-coherent
     18  *    systems.  Therefore, we are certain to have missed a lot of places
     19  *    where we should be calling sal_dma_flush or sal_dma_inval before
     20  *    or after DMA operations.
     21  */
     22 
     23 extern void *sal_alloc(unsigned int, char *);
     24 extern void  sal_free(void *);
     25 extern void sal_get_alloc_counters(unsigned long *alloc_bytes_count,unsigned long *free_bytes_count);
     26 extern void sal_get_alloc_counters_main_thr(unsigned long *alloc_bytes_count,unsigned long *free_bytes_count);
     27 extern void sal_set_alloc_counters_offset(unsigned long alloc_bytes_count_offset, unsigned long free_bytes_count_offset);
     28 extern void sal_set_alloc_counters_offset_main_thr(unsigned long alloc_bytes_count_offset, unsigned long free_bytes_count_offset);
     29 
     30 /*
     31  * DMA Memory allocation
     32  */
     33 
     34 extern void	*sal_dma_alloc(unsigned int, char *);
     35 extern void	sal_dma_free(void *);
     36 
     37 extern void     sal_dma_flush(void* addr, int len);
     38 extern void     sal_dma_inval(void* addr, int len);
     39 extern void	*sal_dma_vtop(void* addr);
     40 extern void	*sal_dma_ptov(void* addr);
     41 
     42 #define DISPLAY_MEM
     43 #define DISPLAY_MEM_PRINTF(x)
     44 #ifdef BROADCOM_DEBUG
     45 /* { */
     46 #ifdef INCLUDE_BCM_SAL_PROFILE
     47 /* { */
     48 extern void
     49 sal_alloc_resource_usage_get(unsigned int *alloc_curr, unsigned int *alloc_max);
     50 
     51 #ifndef __KERNEL__
     52 /* { */
     53 #if DISPLAY_MEM_USAGE
     54 /* { */
     55 #undef DISPLAY_MEM
     56 /*
     57  * Display total memory allocated by sal_alloc() so far and maximum
     58  * allocated so far.
     59  */
     60 #define DISPLAY_MEM \
     61     { \
     62         uint32 alloc_curr ; \
     63         uint32 alloc_max ; \
     64         sal_alloc_resource_usage_get(&alloc_curr, &alloc_max) ; \
     65         sal_printf( \
     66             "\r\n" \
     67             "%s(),%d: Heap memory consumers - curr/max %lu/%lu bytes\r\n\n", \
     68                             __FUNCTION__,__LINE__,(unsigned long)alloc_curr,(unsigned long)alloc_max) ; \
     69     }
     70 #undef DISPLAY_MEM_PRINTF
     71 #define DISPLAY_MEM_PRINTF(x) sal_printf x ;
     72 /* } */
     73 #endif
     74 /* } */
     75 #endif /* !__KERNEL__ */
     76 /* } */
     77 #endif
     78 /* } */
     79 #endif
     80 
     81 #endif	/* !_SAL_ALLOC_H */