2022-11-13 10:25:15 +00:00
|
|
|
#include "Framebuffer.h"
|
2022-11-13 11:20:53 +00:00
|
|
|
#include "Init.h"
|
2022-11-13 14:33:53 +00:00
|
|
|
#include "MemoryManager.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-10-16 13:31:58 +00:00
|
|
|
|
2022-11-13 13:29:15 +00:00
|
|
|
extern u8 fb[1];
|
|
|
|
|
2022-09-05 14:13:51 +00:00
|
|
|
extern "C" void _start()
|
|
|
|
{
|
2022-11-13 11:20:53 +00:00
|
|
|
Init::check_magic();
|
|
|
|
Init::early_init();
|
2022-11-13 09:30:10 +00:00
|
|
|
|
2022-11-13 11:20:53 +00:00
|
|
|
Serial::println("Hello, world!");
|
2022-11-13 10:25:15 +00:00
|
|
|
|
|
|
|
Framebuffer::rect(0, 0, 200, 200, 0xFF00FF00);
|
|
|
|
|
2022-11-13 13:29:15 +00:00
|
|
|
Serial::println(MMU::get_physical((u64)fb).has_error() ? "fb is not mapped" : "fb is mapped!!");
|
|
|
|
|
2022-11-13 14:33:53 +00:00
|
|
|
const u64 address = 0xfffffffff8000000;
|
|
|
|
|
|
|
|
u64 physical = MemoryManager::alloc_physical_page().release_value();
|
|
|
|
|
|
|
|
bool success = !MMU::map(address, physical, MMU::ReadWrite | MMU::NoExecute).has_error();
|
|
|
|
|
|
|
|
if (success) Serial::println("Mapped page :)");
|
|
|
|
else
|
|
|
|
Serial::println("Failed to map page");
|
|
|
|
|
|
|
|
if (MMU::get_physical(address).release_value() == physical) Serial::println("Mapping is active ;)");
|
|
|
|
else
|
|
|
|
Serial::println("Mapping is not active");
|
|
|
|
|
|
|
|
int flags = MMU::get_flags(address).release_value();
|
|
|
|
|
|
|
|
if (flags & MMU::ReadWrite) Serial::println("Mapping is writable");
|
|
|
|
if (flags & MMU::NoExecute) Serial::println("Mapping is not executable");
|
|
|
|
|
|
|
|
u32* ptr = (u32*)address;
|
|
|
|
(void)*ptr;
|
|
|
|
|
|
|
|
Serial::println("Can read from pointer");
|
|
|
|
|
|
|
|
*ptr = 8;
|
|
|
|
|
|
|
|
Serial::println("Can write to pointer");
|
|
|
|
|
2022-11-13 09:09:09 +00:00
|
|
|
for (;;)
|
|
|
|
;
|
2022-09-05 14:13:51 +00:00
|
|
|
}
|