[kernel] Clean up main.cpp and others

The kernel/main.cpp and kernel/memory_bootstrap.cpp files had become
something of a junk drawer. This change cleans them up in the following
ways:

- Most CPU initialization has moved to cpu.cpp, allowing several
  functions to be made static and removed from cpu.h
- Multi-core startup code has moved to the new smp.h and smp.cpp, and
  ap_startup.s has been renamed smp.s to match.
- run_constructors() has moved to memory_bootstrap.cpp, and all the
  functionality of that file has been hidden behind a new public
  interface mem::initialize().
- load_init_server() has moved from memory_bootstrap.cpp to main.cpp
This commit is contained in:
Justin C. Miller
2022-01-27 19:28:35 -08:00
parent 3f8dfbd5b2
commit fd25d3babc
15 changed files with 341 additions and 313 deletions

View File

@@ -9,6 +9,10 @@
#include <arch/memory.h>
namespace bootproto {
struct args;
}
void * operator new (size_t, void *p) noexcept;
/// Allocate from the default allocator.
@@ -81,4 +85,8 @@ constexpr uintptr_t page_align_down(uintptr_t a) { return a & ~(frame_size-1); }
/// Get the given address, aligned to the next page
constexpr uintptr_t page_align_up(uintptr_t a) { return page_align_down(a-1) + frame_size; }
/// Initialize memory. Create the kernel vm space and its memory regions,
/// the physical page allocator and heap allocator, and run global constructors.
void initialize(bootproto::args &args);
} // namespace mem