1 /* IA32/AMD64 Specific Boot info */
2 INTERFACE[ia32,ux,amd64]:
8 EXTENSION class Boot_info
12 static Address mbi_phys();
14 static Multiboot_info *mbi_virt();
18 //-------------------------------------------------------------------------
19 INTERFACE[ia32,amd64]:
21 EXTENSION class Boot_info
24 static Address _mbi_pa;
25 static unsigned _flag;
26 static unsigned _checksum_ro;
27 static unsigned _checksum_rw;
28 static Multiboot_info _kmbi;
32 //-------------------------------------------------------------------------
33 IMPLEMENTATION[ia32,ux,amd64]:
36 #include "mem_layout.h"
38 PUBLIC static inline NEEDS ["config.h","mem_layout.h"]
40 Boot_info::kmem_start(Address mem_max)
42 Address end_addr = (mbi_virt()->mem_upper + 1024) << 10;
45 if (end_addr > mem_max)
51 size = end_addr / 100 * Config::kernel_mem_per_cent;
52 if (size > Config::kernel_mem_max)
53 size = Config::kernel_mem_max;
56 base = end_addr - size & Config::PAGE_MASK;
57 if (Mem_layout::phys_to_pmem(base) < Mem_layout::Physmem)
58 base = Mem_layout::pmem_to_phys(Mem_layout::Physmem);
64 //-----------------------------------------------------------------------------
65 IMPLEMENTATION[ia32,amd64]:
72 #include "mem_layout.h"
74 // these members needs to be initialized with some
75 // data to go into the data section and not into bss
76 Address Boot_info::_mbi_pa = 125;
77 unsigned Boot_info::_flag = 3;
78 unsigned Boot_info::_checksum_ro = 15;
79 unsigned Boot_info::_checksum_rw = 16;
81 // initialized after startup cleaned out the bss
83 Multiboot_info Boot_info::_kmbi;
86 /// \defgroup pre init setup
88 * The Boot_info object must be set up with these functions
89 * before Boot_info::init() is called!
90 * This can be done either in __main, if booted on hardware
91 * or in an initializer with a higher priority than BOOT_INFO_INIT_PRIO
92 * (e.g UX_STARTUP1_INIT_PRIO) if the kernel runs on software (FIASCO-UX)
97 void Boot_info::set_flags(unsigned aflags)
101 void Boot_info::set_checksum_ro(unsigned ro_cs)
102 { _checksum_ro = ro_cs; }
105 void Boot_info::set_checksum_rw(unsigned rw_cs)
106 { _checksum_rw = rw_cs; }
114 // we assume that we run in 1:1 mapped mode
115 _kmbi = *(Multiboot_info *)mbi_phys();
116 Cmdline::init(_kmbi.flags & Multiboot_info::Cmdline
117 ? reinterpret_cast<char*>(_kmbi.cmdline)
123 Boot_info::get_flags(void)
130 Boot_info::get_checksum_ro(void)
137 Boot_info::get_checksum_rw(void)
144 Boot_info::reset_checksum_ro(void)
146 set_checksum_ro(Checksum::get_checksum_ro());
151 Boot_info::set_mbi_phys(Address phys)
158 Boot_info::mbi_phys(void)
165 Boot_info::mbi_virt()
172 Boot_info::kmemsize()
176 return ( (c = strstr(Cmdline::cmdline(), " -kmemsize="))
177 ||(c = strstr(Cmdline::cmdline(), " -kmemsize ")))
178 ? strtol(c+11, 0, 0) << 20