luxos/SysCore/main.c
2021-09-14 18:46:50 +03:00

74 lines
1.8 KiB
C

#include <string.h>
#include <system.h>
#include <conio.h>
//#include <hal.h>
//#include "hal/floppy/floppy.h"
#include "drivers/drivers.h"
#include <time.h>
#include <bootinfo.h>
#include "memory/mmngr_ph.h"
#include "memory/mmngr_vi.h"
#include "video/vga03h.h"
#include <stdlib.h>
// format of a memory region
typedef struct {
unsigned startLo;
unsigned startHi;
unsigned sizeLo;
unsigned sizeHi;
unsigned type;
unsigned 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 void _code, _data, _bss, _end;
void k_init(multiboot_info* bootinfo)
{
memset(&_bss, 0, &_end - &_bss); // zero the bss
unsigned int i;
// Start phyiscal memory manager
unsigned memSize = bootinfo->Memory;
memory_region* memMap = bootinfo->MemoryMapAddress;
pmmngr_init (memSize, (unsigned)&_end);
// Initialize graphics & HAL
//graphics_init();
DriversInstall();
// Initialize memory
for (i=0; (memMap[i].sizeHi != 0 || memMap[i].sizeLo != 0) && i<15; ++i)
if (memMap[i].type==1)
pmmngr_init_region (memMap[i].startLo, memMap[i].sizeLo);
// Protect kernel, bios data area etc
pmmngr_deinit_region (0x100000, 4096+(unsigned)((&_end) + (memSize / 4)*3) - 0xC0000000);
pmmngr_deinit_region (0x0, 0x500); // IVT, Bios Data Area
// Initialize virtual mem manager
vmmngr_initialize();
}
extern void shell();
void k_main(unsigned kernel_size, multiboot_info* bootinfo)
{
k_init(bootinfo);
vga03h_install();
shell();
for(;;);
}