23 //----------------------------------------------------------------------------
26 /* Empty class for VHW descriptor in KIP for native ia32 */
27 class Vhw_descriptor {};
29 //----------------------------------------------------------------------------
32 #include "mem_region.h"
40 char const *version_string() const;
42 // returns the 1st address beyond all available physical memory
43 Address main_memory_high() const;
46 static Kip *global_kip asm ("GLOBAL_KIP");
49 #define L4_KERNEL_INFO_MAGIC (0x4BE6344CL) /* "L4µK" */
51 //============================================================================
57 #include "static_assert.h"
61 Mem_desc::Mem_desc(Address start, Address end, Mem_type t, bool v = false,
63 : _l((start & ~0x3ffUL) | (t & 0x0f) | ((st << 4) & 0x0f0)
69 Address Mem_desc::start() const
70 { return _l & ~0x3ffUL; }
73 Address Mem_desc::end() const
74 { return _h | 0x3ffUL; }
78 Mem_desc::type(Mem_type t)
79 { _l = (_l & ~0x0f) | (t & 0x0f); }
82 Mem_desc::Mem_type Mem_desc::type() const
83 { return (Mem_type)(_l & 0x0f); }
86 unsigned Mem_desc::ext_type() const
87 { return _l & 0x0f0; }
90 unsigned Mem_desc::is_virtual() const
91 { return _l & 0x200; }
94 bool Mem_desc::contains(unsigned long addr)
96 return start() <= addr && end() >= addr;
100 bool Mem_desc::valid() const
101 { return type() && start() < end(); }
104 Mem_desc *Kip::mem_descs()
105 { return (Mem_desc*)(((Address)this) + (_mem_info >> (MWORD_BITS/2))); }
108 Mem_desc const *Kip::mem_descs() const
109 { return (Mem_desc const *)(((Address)this) + (_mem_info >> (MWORD_BITS/2))); }
112 unsigned Kip::num_mem_descs() const
113 { return _mem_info & ((1UL << (MWORD_BITS/2))-1); }
116 void Kip::num_mem_descs (unsigned n)
118 _mem_info = (_mem_info & ~((1UL << (MWORD_BITS/2))-1)
119 | (n & ((1UL << (MWORD_BITS/2))-1)));
123 Mem_desc *Kip::add_mem_region(Mem_desc const &md)
125 Mem_desc *m = mem_descs();
126 Mem_desc *end = m + num_mem_descs();
129 if (m->type() == Mem_desc::Undefined)
136 // Add mem region failed -- must be a Fiasco startup problem. Bail out.
137 panic("Too few memory descriptors in KIP");
142 Kip *Kip::global_kip;
145 void Kip::init_global_kip(Kip *kip)
149 kip->platform_info.is_mp = Config::Max_num_cpus > 1;
151 // check that the KIP has actually been set up
152 //assert(kip->sigma0_ip && kip->root_ip && kip->user_ptr);
155 PUBLIC static inline Kip *Kip::k() { return global_kip; }
158 char const *Kip::version_string() const
160 static_assert((sizeof(Kip) & 0xf) == 0, "Invalid KIP structure size");
162 return reinterpret_cast <char const *> (this) + (offset_version_strings << 4);
165 asm(".section .initkip.version, \"a\", %progbits \n" \
166 ".string \"" CONFIG_KERNEL_VERSION_STRING "\" \n" \
169 asm(".section .initkip.features.fini, \"a\", %progbits \n" \