1818// #define DEBUG
1919#define MYINFO (X,...) INFO(" Kernel" , X, ##__VA_ARGS__)
2020
21- #include < cstdio>
22- #include < boot/multiboot.h>
23- #include < hw/cmos.hpp>
2421#include < kernel/os.hpp>
2522#include < kernel/rng.hpp>
26- #include < kernel/cpuid.hpp>
2723#include < util/fixedvec.hpp>
2824#include < kprint>
2925#include < service>
30- #include < statman >
26+ #include < cstdio >
3127#include < cinttypes>
3228
3329// #define ENABLE_PROFILERS
@@ -53,12 +49,9 @@ bool OS::power_ = true;
5349bool OS::boot_sequence_passed_ = false ;
5450MHz OS::cpu_mhz_ {-1 };
5551uintptr_t OS::liveupdate_loc_ = 0 ;
56- uintptr_t OS::low_memory_size_ = 0 ;
57- uintptr_t OS::high_memory_size_ = 0 ;
5852uintptr_t OS::memory_end_ = 0 ;
59- uintptr_t OS::heap_max_ { 0xfffffff } ;
53+ uintptr_t OS::heap_max_ = ( uintptr_t ) - 1 ;
6054const uintptr_t OS::elf_binary_size_ {(uintptr_t )&_ELF_END_ - (uintptr_t )&_ELF_START_};
61- std::string OS::cmdline{Service::binary_name ()};
6255
6356// stdout redirection
6457using Print_vec = fixedvector<OS::print_func, 8 >;
@@ -79,8 +72,8 @@ void* OS::liveupdate_storage_area() noexcept
7972 return (void *) OS::liveupdate_loc_;
8073}
8174
82- const std::string& OS::cmdline_args () noexcept
83- {
75+ const char * OS::cmdline = nullptr ;
76+ const char * OS::cmdline_args () noexcept {
8477 return cmdline;
8578}
8679
@@ -141,7 +134,7 @@ void OS::post_start()
141134 printf (" IncludeOS %s (%s / %i-bit)\n " ,
142135 version ().c_str (), arch ().c_str (),
143136 static_cast <int >(sizeof (uintptr_t )) * 8 );
144- printf (" +--> Running [ %s ]\n " , Service::name (). c_str () );
137+ printf (" +--> Running [ %s ]\n " , Service::name ());
145138 FILLINE (' ~' );
146139
147140 Service::start ();
@@ -151,11 +144,6 @@ void OS::add_stdout(OS::print_func func)
151144{
152145 os_print_handlers.add (func);
153146}
154- __attribute__ ((weak))
155- void default_stdout_handlers()
156- {
157- OS::add_stdout (&OS::default_stdout);
158- }
159147__attribute__ ((weak))
160148bool os_enable_boot_logging = false;
161149void OS::print (const char * str, const size_t len)
@@ -165,49 +153,3 @@ void OS::print(const char* str, const size_t len)
165153 callback (str, len);
166154 }
167155}
168-
169- void OS::legacy_boot () {
170- // Fetch CMOS memory info (unfortunately this is maximally 10^16 kb)
171- auto mem = hw::CMOS::meminfo ();
172- if (low_memory_size_ == 0 ) {
173- low_memory_size_ = mem.base .total * 1024 ;
174- INFO2 (" * Low memory: %i Kib" , mem.base .total );
175- }
176- if (high_memory_size_ == 0 ) {
177- high_memory_size_ = mem.extended .total * 1024 ;
178- INFO2 (" * High memory (from cmos): %i Kib" , mem.extended .total );
179- }
180-
181- auto & memmap = memory_map ();
182-
183- // No guarantees without multiboot, but we assume standard memory layout
184- memmap.assign_range ({0x0009FC00 , 0x0009FFFF ,
185- " EBDA" , " Extended BIOS data area" });
186- memmap.assign_range ({0x000A0000 , 0x000FFFFF ,
187- " VGA/ROM" , " Memory mapped video memory" });
188-
189- // @note : since the maximum size of a span is unsigned (ptrdiff_t) we may need more than one
190- uintptr_t addr_max = std::numeric_limits<std::size_t >::max ();
191- uintptr_t span_max = std::numeric_limits<std::ptrdiff_t >::max ();
192-
193- uintptr_t unavail_start = 0x100000 + high_memory_size_;
194- size_t interval = std::min (span_max, addr_max - unavail_start) - 1 ;
195- uintptr_t unavail_end = unavail_start + interval;
196-
197- while (unavail_end < addr_max){
198- INFO2 (" * Unavailable memory: 0x%" PRIxPTR" - 0x%" PRIxPTR, unavail_start, unavail_end);
199- memmap.assign_range ({unavail_start, unavail_end,
200- " N/A" , " Reserved / outside physical range" });
201- unavail_start = unavail_end + 1 ;
202- interval = std::min (span_max, addr_max - unavail_start);
203- // Increment might wrapped around
204- if (unavail_start > unavail_end + interval or unavail_start + interval == addr_max){
205- INFO2 (" * Last chunk of memory: 0x%" PRIxPTR" - 0x%" PRIxPTR, unavail_start, addr_max);
206- memmap.assign_range ({unavail_start, addr_max,
207- " N/A" , " Reserved / outside physical range" });
208- break ;
209- }
210-
211- unavail_end += interval;
212- }
213- }
0 commit comments