-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgfxboot_olist.c
81 lines (59 loc) · 1.7 KB
/
gfxboot_olist.c
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <gfxboot/gfxboot.h>
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// obj list
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
obj_id_t gfx_obj_olist_new(unsigned max)
{
obj_id_t id = gfx_obj_alloc(OTYPE_OLIST, OBJ_OLIST_SIZE(max));
olist_t *ol = gfx_obj_olist_ptr(id);
if(ol) {
ol->max = max;
}
return id;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
olist_t *gfx_obj_olist_ptr(obj_id_t id)
{
obj_t *ptr = gfx_obj_ptr(id);
if(!ptr || ptr->base_type != OTYPE_OLIST) return 0;
return (olist_t *) ptr->data.ptr;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int gfx_obj_olist_dump(obj_t *ptr, dump_style_t style)
{
unsigned u, used;
if(!ptr) return 1;
olist_t *ol = ptr->data.ptr;
if(ptr->data.size != OBJ_OLIST_SIZE(ol->max)) {
if(style.ref) {
gfxboot_log(" <invalid data>\n");
}
else {
gfxboot_log("<invalid data>");
}
return 1;
}
for(u = used = 0; u < ol->max; u++) {
if(ol->ptr[u].base_type != OTYPE_NONE) used++;
}
if(!style.ref) {
if(style.inspect) {
gfxboot_log("size %u, next %u, max %u", used, ol->next, ol->max);
return 1;
}
else {
return 0;
}
}
if(style.dump) gfxboot_log(" ");
for(u = 0; u < ol->max; u++) {
if(ol->ptr[u].base_type != OTYPE_NONE) {
obj_id_t id = OBJ_ID(u, ol->ptr[u].gen);
dump_style_t s = { .inspect = style.inspect, .no_head = 1, .max = style.max };
s.dump = style.dump && u;
gfx_obj_dump(id, s);
}
}
return 1;
}