2021-09-14 15:34:14 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <system.h>
|
|
|
|
#include <conio.h>
|
2021-09-14 15:46:50 +00:00
|
|
|
//#include <hal.h>
|
|
|
|
//#include "hal/floppy/floppy.h"
|
|
|
|
#include "drivers/drivers.h"
|
2021-09-14 15:34:14 +00:00
|
|
|
#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:35:52 +00:00
|
|
|
#include "video/vga03h.h"
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
#include <stdlib.h>
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
// format of a memory region
|
|
|
|
typedef struct {
|
|
|
|
unsigned startLo;
|
|
|
|
unsigned startHi;
|
|
|
|
unsigned sizeLo;
|
|
|
|
unsigned sizeHi;
|
|
|
|
unsigned type;
|
|
|
|
unsigned acpi_3_0;
|
2021-09-14 15:34:14 +00:00
|
|
|
} memory_region ;
|
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
// different memory regions (in memory_region.type)
|
|
|
|
/*char* strMemoryTypes[] = {
|
2021-09-14 15:34:14 +00:00
|
|
|
"",
|
|
|
|
"Available", //memory_region.type==0
|
|
|
|
"Reserved", //memory_region.type==1
|
|
|
|
"ACPI Reclaim", //memory_region.type==2
|
|
|
|
"ACPI NVS Memory" //memory_region.type==3
|
2021-09-14 15:35:52 +00:00
|
|
|
};*/
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
extern void _code, _data, _bss, _end;
|
2021-09-14 15:34:14 +00:00
|
|
|
|
|
|
|
void k_init(multiboot_info* bootinfo)
|
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
memset(&_bss, 0, &_end - &_bss); // zero the bss
|
|
|
|
unsigned int i;
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
// Start phyiscal memory manager
|
|
|
|
unsigned memSize = bootinfo->Memory;
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
memory_region* memMap = bootinfo->MemoryMapAddress;
|
|
|
|
pmmngr_init (memSize, (unsigned)&_end);
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
// Initialize graphics & HAL
|
|
|
|
//graphics_init();
|
2021-09-14 15:46:50 +00:00
|
|
|
DriversInstall();
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
// Initialize memory
|
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:35:52 +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
|
2021-09-14 15:35:52 +00:00
|
|
|
pmmngr_deinit_region (0x100000, 4096+(unsigned)((&_end) + (memSize / 4)*3) - 0xC0000000);
|
|
|
|
pmmngr_deinit_region (0x0, 0x500); // IVT, Bios Data Area
|
|
|
|
|
|
|
|
// Initialize virtual mem manager
|
2021-09-14 15:35:13 +00:00
|
|
|
vmmngr_initialize();
|
2021-09-14 15:34:14 +00:00
|
|
|
}
|
2021-09-14 15:35:52 +00:00
|
|
|
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
extern void shell();
|
|
|
|
void k_main(unsigned kernel_size, multiboot_info* bootinfo)
|
2021-09-14 15:34:14 +00:00
|
|
|
{
|
2021-09-14 15:35:52 +00:00
|
|
|
k_init(bootinfo);
|
|
|
|
vga03h_install();
|
2021-09-14 15:34:14 +00:00
|
|
|
|
2021-09-14 15:35:52 +00:00
|
|
|
shell();
|
|
|
|
for(;;);
|
2021-09-14 15:46:50 +00:00
|
|
|
}
|