1*a9c837d8SKevin Wolf /*
2*a9c837d8SKevin Wolf * Copyright (c) 2015 Kevin Wolf <kwolf@redhat.com>
3*a9c837d8SKevin Wolf *
4*a9c837d8SKevin Wolf * Permission is hereby granted, free of charge, to any person obtaining a copy
5*a9c837d8SKevin Wolf * of this software and associated documentation files (the "Software"), to deal
6*a9c837d8SKevin Wolf * in the Software without restriction, including without limitation the rights
7*a9c837d8SKevin Wolf * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8*a9c837d8SKevin Wolf * copies of the Software, and to permit persons to whom the Software is
9*a9c837d8SKevin Wolf * furnished to do so, subject to the following conditions:
10*a9c837d8SKevin Wolf *
11*a9c837d8SKevin Wolf * The above copyright notice and this permission notice shall be included in
12*a9c837d8SKevin Wolf * all copies or substantial portions of the Software.
13*a9c837d8SKevin Wolf *
14*a9c837d8SKevin Wolf * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*a9c837d8SKevin Wolf * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*a9c837d8SKevin Wolf * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*a9c837d8SKevin Wolf * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18*a9c837d8SKevin Wolf * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19*a9c837d8SKevin Wolf * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20*a9c837d8SKevin Wolf * THE SOFTWARE.
21*a9c837d8SKevin Wolf */
22*a9c837d8SKevin Wolf
23*a9c837d8SKevin Wolf #include "libc.h"
24*a9c837d8SKevin Wolf #include "multiboot.h"
25*a9c837d8SKevin Wolf
test_main(uint32_t magic,struct mb_info * mbi)26*a9c837d8SKevin Wolf int test_main(uint32_t magic, struct mb_info *mbi)
27*a9c837d8SKevin Wolf {
28*a9c837d8SKevin Wolf struct mb_module *mod;
29*a9c837d8SKevin Wolf unsigned int i;
30*a9c837d8SKevin Wolf
31*a9c837d8SKevin Wolf (void) magic;
32*a9c837d8SKevin Wolf
33*a9c837d8SKevin Wolf printf("Module list with %d entries at %x\n",
34*a9c837d8SKevin Wolf mbi->mods_count, mbi->mods_addr);
35*a9c837d8SKevin Wolf
36*a9c837d8SKevin Wolf for (i = 0, mod = (struct mb_module*) mbi->mods_addr;
37*a9c837d8SKevin Wolf i < mbi->mods_count;
38*a9c837d8SKevin Wolf i++, mod++)
39*a9c837d8SKevin Wolf {
40*a9c837d8SKevin Wolf char buf[1024];
41*a9c837d8SKevin Wolf unsigned int size = mod->mod_end - mod->mod_start;
42*a9c837d8SKevin Wolf
43*a9c837d8SKevin Wolf printf("[%p] Module: %x - %x (%d bytes) '%s'\n",
44*a9c837d8SKevin Wolf mod, mod->mod_start, mod->mod_end, size, mod->string);
45*a9c837d8SKevin Wolf
46*a9c837d8SKevin Wolf /* Print test file, but remove the newline at the end */
47*a9c837d8SKevin Wolf if (size < sizeof(buf)) {
48*a9c837d8SKevin Wolf memcpy(buf, (void*) mod->mod_start, size);
49*a9c837d8SKevin Wolf buf[size - 1] = '\0';
50*a9c837d8SKevin Wolf printf(" Content: '%s'\n", buf);
51*a9c837d8SKevin Wolf }
52*a9c837d8SKevin Wolf }
53*a9c837d8SKevin Wolf
54*a9c837d8SKevin Wolf return 0;
55*a9c837d8SKevin Wolf }
56