@@ -55,9 +55,9 @@ extern uintptr_t _ELF_END_;
5555bool OS::power_ = true ;
5656bool OS::boot_sequence_passed_ = false ;
5757MHz OS::cpu_mhz_ {-1 };
58- uintptr_t OS::low_memory_size_ { 0 } ;
59- uintptr_t OS::high_memory_size_ { 0 } ;
60- uintptr_t OS::memory_end_ { 0 } ;
58+ uintptr_t OS::low_memory_size_ = 0 ;
59+ uintptr_t OS::high_memory_size_ = 0 ;
60+ uintptr_t OS::memory_end_ = 0 ;
6161uintptr_t OS::heap_max_ {0xfffffff };
6262const uintptr_t OS::elf_binary_size_ {(uintptr_t )&_ELF_END_ - (uintptr_t )&_ELF_START_};
6363std::string OS::cmdline{Service::binary_name ()};
@@ -114,11 +114,12 @@ void OS::start(uint32_t boot_magic, uint32_t boot_addr)
114114 }
115115 Expects (high_memory_size_);
116116
117+ // NOTE: end of physical memory can be set by soft-reset
118+ OS::memory_end_ = OS::high_memory_size_ + 0x100000 ;
119+
117120 PROFILE (" Memory map" );
118121 // Assign memory ranges used by the kernel
119122 auto & memmap = memory_map ();
120-
121- OS::memory_end_ = high_memory_size_ + 0x100000 ;
122123 MYINFO (" Assigning fixed memory ranges (Memory map)" );
123124
124125 memmap.assign_range ({0x6000 , 0x8fff , " Statman" , " Statistics" });
@@ -286,12 +287,14 @@ size_t OS::print(const char* str, const size_t len)
286287void OS::legacy_boot () {
287288 // Fetch CMOS memory info (unfortunately this is maximally 10^16 kb)
288289 auto mem = hw::CMOS::meminfo ();
289- low_memory_size_ = mem.base .total * 1024 ;
290- INFO2 (" * Low memory: %i Kib" , mem.base .total );
291- high_memory_size_ = mem.extended .total * 1024 ;
292-
293- // Use memsize provided by Make / linker unless CMOS knows this is wrong
294- INFO2 (" * High memory (from cmos): %i Kib" , mem.extended .total );
290+ if (low_memory_size_ == 0 ) {
291+ low_memory_size_ = mem.base .total * 1024 ;
292+ INFO2 (" * Low memory: %i Kib" , mem.base .total );
293+ }
294+ if (high_memory_size_ == 0 ) {
295+ high_memory_size_ = mem.extended .total * 1024 ;
296+ INFO2 (" * High memory (from cmos): %i Kib" , mem.extended .total );
297+ }
295298
296299 auto & memmap = memory_map ();
297300
0 commit comments