]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/bootstrap_custom/server/src/init_kip_f.cc
fiasco: bootstrap: copy bootstrap into bootstrap_custom for to port this into Jailhouse.
[l4.git] / l4 / pkg / bootstrap_custom / server / src / init_kip_f.cc
1 /**
2  * \file
3  */
4 /*
5  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
6  *               Alexander Warg <warg@os.inf.tu-dresden.de>
7  *     economic rights: Technische Universität Dresden (Germany)
8  *
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU General Public License 2.
11  * Please see the COPYING-GPL-2 file for details.
12  */
13
14 #include <stdio.h>
15 #include <string.h>
16 #include <l4/sys/kip.h>
17 #include <l4/util/l4_macros.h>
18 #include "panic.h"
19
20 #include "macros.h"
21 #include "init_kip.h"
22 #include "region.h"
23 #include "startup.h"
24 #include <l4/sys/kip>
25
26 using L4::Kip::Mem_desc;
27
28 /**
29  * setup Kernel Info Page
30  */
31 void
32 init_kip_f(void *_l4i, boot_info_t *bi, l4util_mb_info_t *mbi,
33            Region_list *ram, Region_list *regions)
34 {
35   l4_kernel_info_t *l4i = (l4_kernel_info_t *)_l4i;
36
37   unsigned char l4_api = l4i->version >> 24;
38
39   if (l4_api != 0x87 /*VERSION_FIASCO*/)
40     panic("cannot load kernels other than Fiasco");
41
42   Mem_desc *md = Mem_desc::first(_l4i);
43   for (Region const* c = ram->begin(); c != ram->end(); ++c)
44     (md++)->set(c->begin(), c->end(), Mem_desc::Conventional);
45
46   for (Region const *c = regions->begin(); c != regions->end(); ++c)
47     {
48       Mem_desc::Mem_type type = Mem_desc::Reserved;
49       unsigned char sub_type = 0;
50       switch (c->type())
51         {
52         case Region::No_mem:
53         case Region::Ram:
54         case Region::Boot:
55           continue;
56         case Region::Kernel:
57           type = Mem_desc::Reserved;
58           break;
59         case Region::Sigma0:
60           type = Mem_desc::Dedicated;
61           break;
62         case Region::Root:
63           type = Mem_desc::Bootloader;
64           break;
65         case Region::Arch:
66           type = Mem_desc::Arch;
67           sub_type = c->sub_type();
68           break;
69         case Region::Info:
70           type = Mem_desc::Info;
71           sub_type = c->sub_type();
72           break;
73         }
74       (md++)->set(c->begin(), c->end() - 1, type, sub_type);
75     }
76
77   l4i->user_ptr = (unsigned long)mbi;
78
79   /* set up sigma0 info */
80   l4i->sigma0_eip = bi->sigma0_start;
81   printf("  Sigma0 config    ip:" l4_addr_fmt " sp:" l4_addr_fmt "\n",
82          l4i->sigma0_eip, l4i->sigma0_esp);
83
84   /* set up roottask info */
85   l4i->root_eip          = bi->roottask_start;
86   printf("  Roottask config  ip:" l4_addr_fmt " sp:" l4_addr_fmt "\n",
87          l4i->root_eip, l4i->root_esp);
88
89   /* Platform info */
90   strncpy(l4i->platform_info.name, PLATFORM_TYPE,
91           sizeof(l4i->platform_info.name));
92   l4i->platform_info.name[sizeof(l4i->platform_info.name) - 1] = 0;
93 }