root / xseg / xtypes / xobj.h @ 597a1115
History | View | Annotate | Download (1.1 kB)
1 |
#ifndef __XOBJ_H__
|
---|---|
2 |
#define __XOBJ_H__
|
3 |
|
4 |
#include <sys/util.h> |
5 |
#include <xtypes/xlock.h> |
6 |
#include <xtypes/xheap.h> |
7 |
#include <xtypes/domain.h> |
8 |
|
9 |
#define X_ALLOC ((uint32_t) (1 << 0)) |
10 |
|
11 |
struct xobject_header {
|
12 |
XPTR_TYPE(struct xseg_object_handler) obj_h;
|
13 |
}; |
14 |
|
15 |
struct xobject {
|
16 |
uint32_t magic; |
17 |
uint64_t size; |
18 |
xptr next; |
19 |
}; |
20 |
|
21 |
struct xobject_h {
|
22 |
struct xlock lock;
|
23 |
uint32_t magic; |
24 |
uint64_t obj_size; |
25 |
uint32_t flags; |
26 |
XPTR_TYPE(void) container;
|
27 |
xptr heap; |
28 |
xptr allocated; |
29 |
uint64_t nr_allocated; |
30 |
uint64_t allocated_space; |
31 |
xptr list; |
32 |
uint64_t nr_free; |
33 |
}; |
34 |
|
35 |
void *xobj_get_obj(struct xobject_h * obj_h, uint32_t flags); |
36 |
void xobj_put_obj(struct xobject_h * obj_h, void *ptr); |
37 |
int xobj_alloc_obj(struct xobject_h * obj_h, uint64_t nr); |
38 |
int xobj_handler_init(struct xobject_h *obj_h, void *container, |
39 |
uint32_t magic, uint64_t size, struct xheap *heap);
|
40 |
|
41 |
//TODO
|
42 |
//xobj_handler_destroy()
|
43 |
//releases allocated pages
|
44 |
//
|
45 |
//maybe we need lock free versions of get/put obj
|
46 |
//
|
47 |
//also an
|
48 |
//unsigned long xobj_get_objs(obj_h, flags, uint64_t nr, void **buf)
|
49 |
//which will put nr objects in buf
|
50 |
#endif
|