5 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
6 * Alexander Warg <warg@os.inf.tu-dresden.de>,
7 * Frank Mehnert <fm3@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
19 #include <l4/sys/l4int.h>
21 using L4::Kip::Mem_desc;
23 /* XXX not possible to include kip.h from L4Ka::Pistachio here */
25 #if L4_MWORD_BITS == 32
26 #define V4KIP_SIGMA0_SP 0x20
27 #define V4KIP_SIGMA0_IP 0x24
28 #define V4KIP_SIGMA0_LOW 0x28
29 #define V4KIP_SIGMA0_HIGH 0x2C
30 #define V4KIP_ROOT_SP 0x40
31 #define V4KIP_ROOT_IP 0x44
32 #define V4KIP_ROOT_LOW 0x48
33 #define V4KIP_ROOT_HIGH 0x4C
34 #define V4KIP_MEM_INFO 0x54
35 #define V4KIP_BOOT_INFO 0xB8
36 #elif L4_MWORD_BITS == 64
37 #define V4KIP_SIGMA0_SP 0x40
38 #define V4KIP_SIGMA0_IP 0x48
39 #define V4KIP_SIGMA0_LOW 0x50
40 #define V4KIP_SIGMA0_HIGH 0x58
41 #define V4KIP_ROOT_SP 0x80
42 #define V4KIP_ROOT_IP 0x88
43 #define V4KIP_ROOT_LOW 0x90
44 #define V4KIP_ROOT_HIGH 0x98
45 #define V4KIP_MEM_INFO 0xA8
46 #define V4KIP_BOOT_INFO 0x170
48 #error unknown architecture
51 #define V4KIP_WORD(kip,offset) ((l4_umword_t*)(((char*)(kip))+(offset)))
54 * @brief Initialize KIP prototype for Fiasco/v4.
57 init_kip_v4 (void *l4i, boot_info_t *bi, l4util_mb_info_t *mbi,
58 Region_list *ram, Region_list *regions)
60 Mem_desc *md = Mem_desc::first(l4i);
61 for (Region const* c = ram->begin(); c != ram->end(); ++c)
62 (md++)->set(c->begin(), c->end(), Mem_desc::Conventional);
65 // 1: all memory is accessible for users
70 // 4: (additional) 20MB kernel memory
71 if (mem_end > (240 << 20))
73 *p++ = (mem_end - (20 << 20)) | 2;
79 (md++)->set(0xA0000, 0xBFFFF, Mem_desc::Shared);
81 (md++)->set(0xC0000, 0xEFFFF, Mem_desc::Shared);
83 unsigned long s0_low = ~0UL, s0_high = 0;
84 unsigned long root_low = ~0UL, root_high = 0;
86 for (Region const *c = regions->begin(); c != regions->end(); ++c)
88 Mem_desc::Mem_type type = Mem_desc::Reserved;
89 unsigned char sub_type = 0;
97 type = Mem_desc::Reserved;
100 type = Mem_desc::Dedicated;
101 if (s0_low > c->begin())
103 if (s0_high < c->end())
107 type = Mem_desc::Bootloader;
108 if (root_low > c->begin())
109 root_low = c->begin();
110 if (root_high < c->end())
111 root_high = c->end();
114 type = Mem_desc::Arch;
115 sub_type = c->sub_type();
118 (md++)->set(c->begin(), c->end() - 1, type, sub_type);
121 *V4KIP_WORD(l4i,V4KIP_SIGMA0_LOW) = s0_low;
122 *V4KIP_WORD(l4i,V4KIP_SIGMA0_HIGH) = s0_high+1;
123 *V4KIP_WORD(l4i,V4KIP_SIGMA0_IP) = bi->sigma0_start;
125 *V4KIP_WORD(l4i,V4KIP_ROOT_LOW) = root_low;
126 *V4KIP_WORD(l4i,V4KIP_ROOT_HIGH) = root_high+1;
127 *V4KIP_WORD(l4i,V4KIP_ROOT_IP) = bi->roottask_start;
128 *V4KIP_WORD(l4i,V4KIP_ROOT_SP) = bi->roottask_stack;
130 *V4KIP_WORD(l4i,V4KIP_BOOT_INFO) = (unsigned long)mbi;
132 // set the mem_info variable: count of mem descriptors
133 Mem_desc::count(l4i, md - Mem_desc::first(l4i));