41 |
/* Check if the bit BIT in FLAGS is set. */ |
/* Check if the bit BIT in FLAGS is set. */ |
42 |
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit))) |
#define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit))) |
43 |
|
|
44 |
|
/* The following must be defined and are used to calculate the extents |
45 |
|
of the laden binary itself. */ |
46 |
|
extern char _start; |
47 |
|
extern char _end; |
48 |
|
|
49 |
/* Setup the argument vector and pass control over to the main |
/* Setup the argument vector and pass control over to the main |
50 |
function. */ |
function. */ |
53 |
{ |
{ |
54 |
int argc = 0; |
int argc = 0; |
55 |
char **argv = 0; |
char **argv = 0; |
56 |
|
l4_word_t start; |
57 |
|
l4_word_t end; |
58 |
|
|
59 |
|
|
60 |
/* Verify that we are booted by a Multiboot-compliant boot loader. */ |
/* Verify that we are booted by a Multiboot-compliant boot loader. */ |
61 |
if (magic != MULTIBOOT_BOOTLOADER_MAGIC) |
if (magic != MULTIBOOT_BOOTLOADER_MAGIC) |
121 |
a later time. */ |
a later time. */ |
122 |
boot_info = (uint32_t) mbi; |
boot_info = (uint32_t) mbi; |
123 |
|
|
124 |
|
/* Now protect ourselves and the mulitboot info (at least the module |
125 |
|
configuration. */ |
126 |
|
loader_add_region ("laden", (l4_word_t) &_start, (l4_word_t) &_end, 1); |
127 |
|
|
128 |
|
start = (l4_word_t) mbi; |
129 |
|
end = start + sizeof (*mbi) - 1; |
130 |
|
if (CHECK_FLAG (mbi->flags, 3)) |
131 |
|
{ |
132 |
|
module_t *mod = (module_t *) mbi->mods_addr; |
133 |
|
int nr; |
134 |
|
|
135 |
|
if (((l4_word_t) mod) < start) |
136 |
|
start = (l4_word_t) mod; |
137 |
|
if (((l4_word_t) mod) + mbi->mods_count * sizeof (*mod) > end) |
138 |
|
end = ((l4_word_t) mod) + mbi->mods_count * sizeof (*mod); |
139 |
|
|
140 |
|
for (nr = 0; nr < mbi->mods_count; nr++) |
141 |
|
{ |
142 |
|
char *str = (char *) mod[nr].string; |
143 |
|
|
144 |
|
if (str) |
145 |
|
{ |
146 |
|
if (((l4_word_t) str) < start) |
147 |
|
start = (l4_word_t) str; |
148 |
|
while (*str) |
149 |
|
str++; |
150 |
|
if (((l4_word_t) str) > end) |
151 |
|
end = (l4_word_t) str; |
152 |
|
} |
153 |
|
} |
154 |
|
} |
155 |
|
loader_add_region ("grub-mbi", start, end, 1); |
156 |
|
|
157 |
/* Now invoke the main function. */ |
/* Now invoke the main function. */ |
158 |
main (argc, argv); |
main (argc, argv); |
159 |
|
|