22 auto operator()(
const char* format, ...) const ->
int {
28bmalloc::Bmalloc<BmallocLogger>* allocator =
nullptr;
31extern "C" auto malloc(
size_t size) ->
void* {
33 return allocator->malloc(size);
38extern "C" auto free(
void* ptr) ->
void {
44extern "C" auto calloc(
size_t num,
size_t size) ->
void* {
46 return allocator->calloc(num, size);
51extern "C" auto realloc(
void* ptr,
size_t new_size) ->
void* {
53 return allocator->realloc(ptr, new_size);
60 return allocator->aligned_alloc(alignment, size);
67 allocator->aligned_free(ptr);
74 BasicInfoSingleton::instance().elf_addr +
75 KernelElfSingleton::instance().GetElfSize()));
76 auto allocator_size = BasicInfoSingleton::instance().physical_memory_addr +
77 BasicInfoSingleton::instance().physical_memory_size -
78 reinterpret_cast<uint64_t
>(allocator_addr);
80 klog::Info(
"bmalloc address: {:#x}, size: {:#X}",
81 static_cast<uint64_t
>(
reinterpret_cast<uintptr_t
>(allocator_addr)),
82 static_cast<uint64_t
>(allocator_size));
84 static bmalloc::Bmalloc<BmallocLogger> bmallocator(allocator_addr,
86 allocator = &bmallocator;
89 VirtualMemorySingleton::create();
90 VirtualMemorySingleton::instance().InitCurrentCore();
93 if (SIMPLEKERNEL_EARLY_CONSOLE_BASE != 0) {
94 VirtualMemorySingleton::instance()
95 .MapMMIO(SIMPLEKERNEL_EARLY_CONSOLE_BASE,
99 return std::unexpected(err);
103 klog::Info(
"Memory initialization completed");
107 VirtualMemorySingleton::instance().InitCurrentCore();
108 klog::Info(
"SMP Memory initialization completed");
std::expected< T, Error > Expected
std::expected 别名模板
auto aligned_alloc(size_t alignment, size_t size) -> void *
auto aligned_free(void *ptr) -> void
auto calloc(size_t num, size_t size) -> void *
auto malloc(size_t size) -> void *
auto free(void *ptr) -> void
auto MemoryInit() -> void
内存子系统初始化
auto realloc(void *ptr, size_t new_size) -> void *
auto MemoryInitSMP() -> void
多核内存子系统初始化
static constexpr size_t kPageSize
auto PageAlignUp(uint64_t addr) -> uint64_t
auto Info(etl::format_string< Args... > fmt, Args &&... args) -> void
以 INFO 级别记录日志
auto Warn(etl::format_string< Args... > fmt, Args &&... args) -> void
以 WARN 级别记录日志
constexpr auto message() const -> const char *