2021-09-14 15:34:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <system.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <hal.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <bootinfo.h>
|
|
|
|
#include "memory/mmngr_ph.h"
|
2021-09-14 15:35:13 +00:00
|
|
|
#include "memory/mmngr_vi.h"
|
2021-09-14 15:34:14 +00:00
|
|
|
#include "shell/shell.c"
|
|
|
|
|
|
|
|
//! format of a memory region
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
uint32_t startLo;
|
|
|
|
uint32_t startHi;
|
|
|
|
uint32_t sizeLo;
|
|
|
|
uint32_t sizeHi;
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t acpi_3_0;
|
|
|
|
} memory_region ;
|
|
|
|
|
|
|
|
//! different memory regions (in memory_region.type)
|
|
|
|
char* strMemoryTypes[] = {
|
|
|
|
"",
|
|
|
|
"Available", //memory_region.type==0
|
|
|
|
"Reserved", //memory_region.type==1
|
|
|
|
"ACPI Reclaim", //memory_region.type==2
|
|
|
|
"ACPI NVS Memory" //memory_region.type==3
|
|
|
|
};
|
|
|
|
|
|
|
|
extern dword _code;
|
|
|
|
extern dword _data;
|
|
|
|
extern dword _bss;
|
|
|
|
extern dword _end;
|
|
|
|
|
|
|
|
void k_init(multiboot_info* bootinfo)
|
|
|
|
{
|
|
|
|
// Start by zero-ing the bss
|
|
|
|
memset(&_bss, 0, &_end - &_bss);
|
|
|
|
|
|
|
|
// Initialize HAL
|
|
|
|
i86_hal_initialize();
|
|
|
|
|
|
|
|
// Initialize Graphics
|
|
|
|
graphics_init();
|
|
|
|
|
|
|
|
// cleanup the console screen
|
|
|
|
set_default_colors (0x07, 0x04);
|
|
|
|
clrscr();
|
|
|
|
|
|
|
|
// Start memory manager
|
|
|
|
uint32_t memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64;
|
|
|
|
memory_region* memMap = (memory_region*)0x1000;
|
|
|
|
pmmngr_init (memSize, (uint32_t)&_end);
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
2021-09-14 15:35:13 +00:00
|
|
|
for (i=0; (memMap[i].sizeHi != 0 || memMap[i].sizeLo != 0) && i<15; ++i)
|
2021-09-14 15:34:14 +00:00
|
|
|
if (memMap[i].type==1) pmmngr_init_region (memMap[i].startLo, memMap[i].sizeLo);
|
|
|
|
|
2021-09-14 15:35:13 +00:00
|
|
|
// Protect kernel, bios data area etc
|
|
|
|
_end += (memSize / 4) * 3;
|
|
|
|
pmmngr_deinit_region (0x100000, _end - 0x100000);
|
|
|
|
pmmngr_deinit_region (0x0, 0x500);
|
|
|
|
pmmngr_deinit_region (0x9FC00, 0x400);
|
|
|
|
pmmngr_deinit_region (0xA0000, 0x60000);
|
|
|
|
|
|
|
|
// Start Virtual Memory Manager & Enable paging
|
|
|
|
vmmngr_initialize();
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void k_main(uint32_t kernel_size, multiboot_info* bootinfo)
|
|
|
|
{
|
|
|
|
k_init(bootinfo);
|
|
|
|
apps_osver();
|
|
|
|
|
|
|
|
shell();
|
|
|
|
|
|
|
|
for(;;);
|
|
|
|
}
|