simple_idr.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * simple_idr.h
  3. *
  4. * Copyright (c) 2007-2019 Allwinnertech Co., Ltd.
  5. *
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include <hal_sem.h>
  18. #ifndef _MALI_IDR_H
  19. #define _MALI_IDR_H
  20. #define IDR_BIT 8
  21. #define IDR_SIZE (1<<8)
  22. #define IDR32_MASK 0xffffffff
  23. #define NO_ID 0
  24. struct id_layer {
  25. int num_layer;
  26. struct id_layer *layer[IDR_SIZE];
  27. int bitmap[IDR_SIZE/32];//full will set
  28. struct id_layer *pre;
  29. struct id_layer *next;
  30. };
  31. struct id_dir {
  32. hal_sem_t lock;
  33. struct id_layer *top;
  34. struct id_layer *lu_cache[4];
  35. int lu_id;
  36. int cur_max_level;
  37. int status;// -1 is destroyed, 0 is normal no visitting, 1 is now visitting...
  38. struct id_layer *head;
  39. };
  40. int id_alloc(struct id_dir *dir, void *value);
  41. void id_free(struct id_dir *dir, int id);
  42. void* id_get(struct id_dir *dir, int id);
  43. struct id_dir* id_creat(void);
  44. void id_destroyed(struct id_dir *dir);
  45. #endif