2022-11-30 12:29:28 +00:00
|
|
|
#include "Log.h"
|
2022-11-15 18:10:32 +00:00
|
|
|
#include "arch/CPU.h"
|
2022-11-13 13:29:15 +00:00
|
|
|
#include "arch/MMU.h"
|
2022-11-13 09:30:10 +00:00
|
|
|
#include "arch/Serial.h"
|
2022-11-19 19:01:01 +00:00
|
|
|
#include "arch/Timer.h"
|
2022-11-19 16:59:49 +00:00
|
|
|
#include "boot/Init.h"
|
2022-12-03 16:25:25 +00:00
|
|
|
#include "config.h"
|
2022-11-20 14:15:26 +00:00
|
|
|
#include "memory/Heap.h"
|
2022-11-19 16:59:49 +00:00
|
|
|
#include "memory/MemoryManager.h"
|
2022-11-20 16:56:07 +00:00
|
|
|
#include "video/TextConsole.h"
|
2022-12-04 11:42:43 +00:00
|
|
|
#include <luna/Units.h>
|
2022-10-16 13:31:58 +00:00
|
|
|
|
2022-11-20 16:56:07 +00:00
|
|
|
Result<void> init()
|
2022-09-05 14:13:51 +00:00
|
|
|
{
|
2022-12-03 16:25:25 +00:00
|
|
|
kinfoln("Starting Moon %s", MOON_VERSION);
|
2022-11-13 10:25:15 +00:00
|
|
|
|
2022-11-30 16:16:36 +00:00
|
|
|
kinfoln("Current platform: %s", CPU::platform_string());
|
2022-11-19 11:30:36 +00:00
|
|
|
|
2022-11-30 16:16:36 +00:00
|
|
|
kinfoln("Current processor: %s", TRY(CPU::identify()));
|
2022-11-13 13:29:15 +00:00
|
|
|
|
2022-11-19 19:01:01 +00:00
|
|
|
Timer::init();
|
2022-11-16 16:37:18 +00:00
|
|
|
|
2022-11-19 19:01:01 +00:00
|
|
|
CPU::platform_finish_init();
|
|
|
|
|
|
|
|
CPU::enable_interrupts();
|
|
|
|
|
2022-11-30 11:42:11 +00:00
|
|
|
char buffer[64];
|
2022-11-30 15:30:42 +00:00
|
|
|
to_dynamic_unit(MemoryManager::total(), buffer, sizeof(buffer));
|
|
|
|
kinfoln("Total memory: %s", buffer);
|
2022-11-30 11:42:11 +00:00
|
|
|
to_dynamic_unit(MemoryManager::free(), buffer, sizeof(buffer));
|
2022-11-30 15:30:42 +00:00
|
|
|
kinfoln("Free memory: %s", buffer);
|
2022-11-30 11:42:11 +00:00
|
|
|
to_dynamic_unit(MemoryManager::used(), buffer, sizeof(buffer));
|
2022-11-30 15:30:42 +00:00
|
|
|
kinfoln("Used memory: %s", buffer);
|
2022-11-30 11:42:11 +00:00
|
|
|
to_dynamic_unit(MemoryManager::reserved(), buffer, sizeof(buffer));
|
2022-11-30 12:29:28 +00:00
|
|
|
kinfoln("Reserved memory: %s", buffer);
|
2022-11-30 11:42:11 +00:00
|
|
|
|
2022-11-20 16:56:07 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" [[noreturn]] void _start()
|
|
|
|
{
|
|
|
|
Init::check_magic();
|
|
|
|
Init::early_init();
|
|
|
|
auto rc = init();
|
2022-11-30 16:16:36 +00:00
|
|
|
if (rc.has_error()) kerrorln("Runtime error: %s", rc.error_string());
|
2022-11-15 18:10:32 +00:00
|
|
|
CPU::efficient_halt();
|
2022-09-05 14:13:51 +00:00
|
|
|
}
|