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

mem_avl.h (1661B)


      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: 	mem_avl.h
      8  * Purpose: 	Defines a generic memory manager using AVL tree and DDL List.
      9  */
     10 
     11 #ifndef _SHR_MEM_AVL_H
     12 #define _SHR_MEM_AVL_H
     13 
     14 #include <shared/avl.h>
     15 
     16 typedef struct shr_mem_avl_entry_s {
     17     int size;
     18     unsigned int addr;
     19     int used;
     20     struct shr_mem_avl_entry_s *next;
     21     struct shr_mem_avl_entry_s *self; /* This entry is copied in avl entry datum. self points to the node in DLL */
     22     struct shr_mem_avl_entry_s *prev;
     23 } shr_mem_avl_entry_t;
     24 
     25 typedef shr_mem_avl_entry_t *shr_mem_avl_entry_pt;
     26 
     27 typedef struct shr_mem_avl_st{
     28     shr_avl_t *tree;                        /* AVL Tree of free node */
     29     shr_mem_avl_entry_t *mem_list;          /* DLL Element List (all nodes) */
     30 }shr_mem_avl_t;
     31 
     32 extern int shr_mem_avl_create(shr_mem_avl_t **mem_avl_ptr,
     33                               int mem_size,
     34                               int mem_base,
     35                               int max_blocks);
     36 
     37 extern int shr_mem_avl_destroy(shr_mem_avl_t *mem_avl);
     38 
     39 extern int shr_mem_avl_malloc(shr_mem_avl_t *mem_avl, int size, unsigned int *addr);
     40 extern int shr_mem_avl_realloc(shr_mem_avl_t *mem_avl, int size, unsigned int addr);
     41 extern int shr_mem_avl_free(shr_mem_avl_t *mem_avl, unsigned int addr);
     42 extern int shr_mem_avl_free_tree_list(shr_mem_avl_t *mem_avl);
     43 extern int shr_mem_avl_list_output(shr_mem_avl_t *mem_avl);
     44 
     45 extern int shr_mem_avl_free_count(shr_mem_avl_t *mem_avl, int size, int *count);
     46 #endif /* _SHR_MEM_AVL_H */