move heap, obj outside of xseg and make them xtypes
[archipelago] / xseg / xtypes / xobj.h
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 xseg_object_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         uint32_t magic;
23         uint64_t obj_size;
24         uint32_t flags;
25         XPTR_TYPE(void) container;
26         xptr heap;
27         xptr allocated;
28         xptr list;
29         struct xlock lock;
30 };
31
32 void *xobj_get_obj(struct xobject_h * obj_h, uint32_t flags);
33 void xobj_put_obj(struct xobject_h * obj_h, void *ptr);
34 int xobj_alloc_obj(struct xobject_h * obj_h, uint64_t nr);
35 int xobj_handler_init(struct xobject_h *obj_h, void *container,
36                 uint32_t magic, uint64_t size, struct xheap *heap);
37
38
39 #endif