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