int main() { //initialise the platform itself __platform_init(); //do not initialise the scheduler, this is done by __framework_bootstrap() __framework_bootstrap(); //initialise platform functionality that depends on the framework __platform_post_framework_init(); scheduler_run(); return 0; }
int main (void) { __platform_init(); __framework_bootstrap(); //__platform_post_framework_init(); scheduler_run(); return 0; }
int main(){ //BSP_TraceProfilerSetup(); // Only when using bootloader //SCB->VTOR=0x4000; //activate VCOM //initialise the platform itself __platform_init(); //do not initialise the scheduler, this is done by __framework_bootstrap() __framework_bootstrap(); //initialise platform functionality that depends on the framework __platform_post_framework_init(); scheduler_run(); return 0; }
int main() { //BSP_TraceProfilerSetup(); // Only when using bootloader //SCB->VTOR=0x4000; //activate VCOM #ifdef PLATFORM_USE_VCOM hw_gpio_configure_pin(VCOM_ENABLE, false, gpioModePushPull, 1); hw_gpio_set(VCOM_ENABLE); #endif //initialise the platform itself __platform_init(); //do not initialise the scheduler, this is done by __framework_bootstrap() __framework_bootstrap(); //initialise platform functionality that depends on the framework __platform_post_framework_init(); scheduler_run(); return 0; }
void OS::start(uint32_t boot_magic, uint32_t boot_addr) { OS::cmdline = Service::binary_name(); // Initialize stdout handlers if(os_default_stdout) { OS::add_stdout(&OS::default_stdout); } PROFILE("OS::start"); // Print a fancy header CAPTION("#include<os> // Literally"); MYINFO("Stack: %p", get_cpu_esp()); MYINFO("Boot magic: 0x%x, addr: 0x%x", boot_magic, boot_addr); // Call global ctors PROFILE("Global constructors"); __libc_init_array(); // PAGING // PROFILE("Enable paging"); extern void __arch_init_paging(); __arch_init_paging(); // BOOT METHOD // PROFILE("Multiboot / legacy"); OS::memory_end_ = 0; // Detect memory limits etc. depending on boot type if (boot_magic == MULTIBOOT_BOOTLOADER_MAGIC) { OS::multiboot(boot_addr); } else { if (is_softreset_magic(boot_magic) && boot_addr != 0) OS::resume_softreset(boot_addr); OS::legacy_boot(); } assert(OS::memory_end_ != 0); // Give the rest of physical memory to heap OS::heap_max_ = OS::memory_end_; /// STATMAN /// PROFILE("Statman"); /// initialize on page 9, 8 pages in size Statman::get().init(0x8000, 0x8000); PROFILE("Memory map"); // Assign memory ranges used by the kernel auto& memmap = memory_map(); MYINFO("Assigning fixed memory ranges (Memory map)"); memmap.assign_range({0x8000, 0xffff, "Statman"}); #if defined(ARCH_x86_64) /** * TODO: Map binary parts using mem::map instead of assigning ranges directly * e.g. the .text segment is now mapped individually by __arch_init_paging */ memmap.assign_range({0x1000, 0x6fff, "Pagetables"}); memmap.assign_range({0x10000, 0x9d3ff, "Stack"}); #elif defined(ARCH_i686) memmap.assign_range({0x10000, 0x9d3ff, "Stack"}); #endif assert(::heap_begin != 0x0 and OS::heap_max_ != 0x0); // @note for security we don't want to expose this memmap.assign_range({(uintptr_t)&_end, ::heap_begin - 1, "Pre-heap"}); uintptr_t span_max = std::numeric_limits<std::ptrdiff_t>::max(); uintptr_t heap_range_max_ = std::min(span_max, OS::heap_max_); MYINFO("Assigning heap"); memmap.assign_range({::heap_begin, heap_range_max_, "Dynamic memory", heap_usage }); MYINFO("Virtual memory map"); for (const auto &i : memmap) INFO2("%s",i.second.to_string().c_str()); PROFILE("Platform init"); extern void __platform_init(); __platform_init(); PROFILE("RTC init"); // Realtime/monotonic clock RTC::init(); }
void OS::start(char* _cmdline, uintptr_t mem_size) { // Initialize stdout handlers OS::add_stdout(&OS::default_stdout); PROFILE(""); // Print a fancy header CAPTION("#include<os> // Literally"); void* esp = get_cpu_esp(); MYINFO("Stack: %p", esp); /// STATMAN /// /// initialize on page 7, 2 pages in size Statman::get().init(0x6000, 0x3000); OS::cmdline = _cmdline; // setup memory and heap end OS::memory_end_ = mem_size; OS::heap_max_ = OS::memory_end_; // Call global ctors PROFILE("Global constructors"); __libc_init_array(); PROFILE("Memory map"); // Assign memory ranges used by the kernel auto& memmap = memory_map(); MYINFO("Assigning fixed memory ranges (Memory map)"); memmap.assign_range({0x500, 0x5fff, "solo5", "solo5"}); memmap.assign_range({0x6000, 0x8fff, "Statman", "Statistics"}); memmap.assign_range({0xA000, 0x9fbff, "Stack", "Kernel / service main stack"}); memmap.assign_range({(uintptr_t)&_LOAD_START_, (uintptr_t)&_end, "ELF", "Your service binary including OS"}); Expects(::heap_begin and heap_max_); // @note for security we don't want to expose this memmap.assign_range({(uintptr_t)&_end + 1, ::heap_begin - 1, "Pre-heap", "Heap randomization area"}); uintptr_t span_max = std::numeric_limits<std::ptrdiff_t>::max(); uintptr_t heap_range_max_ = std::min(span_max, heap_max_); MYINFO("Assigning heap"); memmap.assign_range({::heap_begin, heap_range_max_, "Heap", "Dynamic memory", heap_usage }); MYINFO("Printing memory map"); for (const auto &i : memmap) INFO2("* %s",i.second.to_string().c_str()); extern void __platform_init(); __platform_init(); MYINFO("Booted at monotonic_ns=%lld walltime_ns=%lld", solo5_clock_monotonic(), solo5_clock_wall()); Solo5_manager::init(); // We don't need a start or stop function in solo5. Timers::init( // timer start function [] (std::chrono::microseconds) {}, // timer stop function [] () {}); // Some tests are asserting there is at least one timer that is always ON // (the RTC calibration timer). Let's fake some timer so those tests pass. Timers::oneshot(std::chrono::hours(1000000), [] (auto) {}); Timers::ready(); }