Skip to content

Commit e10a011

Browse files
authored
Merge pull request #1391 from fwsGonzo/dev
Functionality required by the latest LiveUpdate
2 parents 65217dd + b0fd614 commit e10a011

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

api/hw/devices.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace hw {
4949
/** List all devices (decorated, as seen in boot output) */
5050
inline static void print_devices();
5151

52+
inline static void flush_all();
5253

5354
inline static void deactivate_all();
5455

@@ -161,6 +162,11 @@ namespace hw {
161162
deactivate_type(devices<hw::Block_device>());
162163
deactivate_type(devices<hw::Nic>());
163164
}
165+
inline void Devices::flush_all()
166+
{
167+
for (auto& dev : devices<hw::Nic>())
168+
dev->flush();
169+
}
164170

165171
} //< namespace hw
166172

api/posix/sys/mman.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct posix_typed_mem_info
3535
int mlock(const void *, size_t);
3636
int mlockall(int);
3737
void *mmap(void *, size_t, int, int, int, off_t);
38+
void *mremap(void*, size_t, size_t, int flags, ... /* void *new_address */);
3839
int mprotect(void *, size_t, int);
3940
int msync(void *, size_t, int);
4041
int munlock(const void *, size_t);
@@ -68,6 +69,9 @@ int shm_unlink(const char *);
6869
// Returned on failure to allocate pages
6970
#define MAP_FAILED ((void*)-1)
7071

72+
#define MREMAP_FIXED 0x2
73+
#define MREMAP_MAYMOVE 0x4
74+
7175
#ifdef __cplusplus
7276
}
7377
#endif

src/kernel/os.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ extern uintptr_t _ELF_END_;
5555
bool OS::power_ = true;
5656
bool OS::boot_sequence_passed_ = false;
5757
MHz 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;
6161
uintptr_t OS::heap_max_ {0xfffffff};
6262
const uintptr_t OS::elf_binary_size_ {(uintptr_t)&_ELF_END_ - (uintptr_t)&_ELF_START_};
6363
std::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)
286287
void 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

src/kernel/softreset.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ void OS::resume_softreset(intptr_t addr)
4545

4646
/// restore known values
4747
OS::memory_end_ = data->high_mem;
48+
OS::low_memory_size_ = 0x100000;
49+
OS::high_memory_size_ = OS::memory_end_ - 0x100000;
4850
OS::cpu_mhz_ = data->cpu_freq;
4951
x86::apic_timer_set_ticks(data->apic_ticks);
5052

0 commit comments

Comments
 (0)