]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/moe/server/src/gc_support.cc
update
[l4.git] / l4 / pkg / moe / server / src / gc_support.cc
1
2 #include <l4/sys/ipc_gate>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <l4/sys/kdebug.h>
6
7 #include "globals.h"
8 #include "page_alloc.h"
9
10 extern "C" {
11 #include <private/gc_priv.h>
12 }
13
14 extern char _etext[];
15 extern char _end[];
16 extern void *__libc_stack_end;
17
18 extern "C" {
19
20 void GC_register_data_segments(void);
21 ptr_t GC_get_main_stack_base(void);
22 struct hblk *GC_get_mem(size_t bytes);
23
24 }
25
26 void GC_register_data_segments(void)
27 {
28   GC_add_roots_inner((ptr_t)&_etext, (ptr_t)&_end, FALSE);
29 }
30
31 ptr_t GC_get_main_stack_base(void)
32 {
33   return (ptr_t)__libc_stack_end;
34 }
35
36
37
38 static void GC_default_push_other_roots(void)
39 {
40   l4_msg_regs_t *mr = l4_utcb_mr();
41   static l4_umword_t b[2];
42   b[0] = mr->mr[0];
43   b[1] = mr->mr[1];
44   l4_cap_idx_t const start = Cap_alloc::Gc_cap_0 << L4_CAP_SHIFT;
45   l4_cap_idx_t const end = (Cap_alloc::Gc_cap_0 + Cap_alloc::Gc_caps) << L4_CAP_SHIFT;
46   l4_umword_t o = 0;
47   for (l4_cap_idx_t c = start; c < end; c += L4_CAP_OFFSET)
48     {
49       L4::Cap<L4::Ipc_gate> g(c);
50       if (!object_pool.cap_alloc()->is_allocated(g))
51         continue;
52
53       if (l4_error(g->get_infos(&o)) < 0)
54         continue;
55
56       o &= ~3UL;
57       GC_push_one(o);
58       //printf("found so @ %lx\n", o);
59     }
60   //GC_push_one();
61   mr->mr[0] = b[0];
62   mr->mr[1] = b[1];
63 }
64
65 GC_INNER void (*GC_push_other_roots)(void) = GC_default_push_other_roots;
66
67 hblk *GC_get_mem(size_t s)
68 {
69   //printf("MOE: ps=%lx\n", GC_page_size);
70   if (s & (GC_page_size - 1))
71     {
72       //printf("MOE: stupidly sized memory requested\n");
73       enter_kdebug("XX");
74       return 0;
75     }
76
77   //printf("MOE: real_malloc(%zx)\n", s);
78   return (hblk*)Single_page_alloc_base::_alloc(Single_page_alloc_base::nothrow, s, GC_page_size);
79 }
80
81 /* Find the page size */
82 GC_INNER word GC_page_size = L4_PAGESIZE;
83 GC_INNER GC_bool GC_dirty_maintained = FALSE;
84
85 extern "C" GC_INNER void GC_setpagesize(void);
86 GC_INNER void GC_setpagesize() {}
87
88
89 extern "C" GC_INNER void GC_dirty_init(void);
90 GC_INNER void GC_dirty_init()
91 {
92   if (GC_print_stats == VERBOSE)
93     GC_log_printf("Initializing DEFAULT_VDB...\n");
94   //GC_dirty_maintained = TRUE;
95 }
96
97 extern "C" GC_INNER void GC_read_dirty(void);
98 GC_INNER void GC_read_dirty() {}
99
100 extern "C" GC_INNER GC_bool GC_page_was_dirty(struct hblk *h);
101
102 GC_INNER GC_bool GC_page_was_dirty(struct hblk *h)
103 {
104   (void)h;
105   return TRUE;
106 }
107
108 extern "C" GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
109                                    GC_bool is_ptrfree);
110 GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
111                                    GC_bool is_ptrfree)
112 {
113   (void)h;
114   (void)nblocks;
115   (void)is_ptrfree;
116 }