Cleaned up sortix/kernel.cpp and it now uses the new coding style.
All kernel.cpp code related to jssortix was removed as it is not supported any longer.
This commit is contained in:
parent
4f3e22140c
commit
969c0e8048
|
@ -59,58 +59,13 @@
|
|||
|
||||
using namespace Maxsi;
|
||||
|
||||
void* RunApplication(void* Parameter);
|
||||
|
||||
// Keep the stack size aligned with $CPU/base.s
|
||||
extern "C" { size_t stack[64*1024] = {0}; }
|
||||
|
||||
namespace Sortix
|
||||
namespace Sortix {
|
||||
|
||||
void DoMaxsiLogo()
|
||||
{
|
||||
void DoBSoD()
|
||||
{
|
||||
#ifdef PLATFORM_SERIAL
|
||||
UART::WriteChar(27);
|
||||
UART::WriteChar(91);
|
||||
UART::WriteChar(48 + 4);
|
||||
UART::WriteChar(48 + 4);
|
||||
UART::WriteChar(109);
|
||||
#endif
|
||||
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print("Windows Boot Manager has experienced a problem. ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" Status: 0xc000000f ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" Info: An error occured during transferring execution. ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print("You can try to recover the system with the Microsoft Windows System Recovery ");
|
||||
Log::Print("Tools. (You might need to restart the system manually). ");
|
||||
Log::Print(" ");
|
||||
Log::Print("If the problem continues, please contact your system administrator or computer ");
|
||||
Log::Print("manufacturer. ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
Log::Print(" ");
|
||||
|
||||
#ifdef JSSORTIX
|
||||
JSSortix::Exit();
|
||||
#else
|
||||
while ( true ) { }
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoMaxsiLogo()
|
||||
{
|
||||
Log::Print("\e[37;41m\e[2J"); // Make the background color red.
|
||||
Log::Print(" _ \n");
|
||||
Log::Print(" / \\ \n");
|
||||
|
@ -127,55 +82,26 @@ namespace Sortix
|
|||
Log::Print(" / \\ / \\ \n");
|
||||
Log::Print(" /_____________\\ /____________\\ \n");
|
||||
Log::Print(" \n");
|
||||
Log::Print(" BOOTING OPERATING SYSTEM... ");
|
||||
}
|
||||
|
||||
void DoWelcome()
|
||||
{
|
||||
#ifdef BSOD
|
||||
DoBSoD();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoWelcome()
|
||||
{
|
||||
DoMaxsiLogo();
|
||||
}
|
||||
|
||||
extern "C" void KernelInit(unsigned long Magic, multiboot_info_t* BootInfo)
|
||||
{
|
||||
#ifdef JSSORTIX
|
||||
// TODO: Make JSVM multiboot compliant.
|
||||
multiboot_info_t MBInfo; BootInfo = &MBInfo;
|
||||
multiboot_memory_map_t MBMMap;
|
||||
|
||||
MBMMap.addr = 0x100000;
|
||||
MBMMap.len = 0xC00000;
|
||||
MBMMap.type = MULTIBOOT_MEMORY_AVAILABLE;
|
||||
MBMMap.size = sizeof(MBMMap) - sizeof(MBMMap.size);
|
||||
BootInfo->flags = MULTIBOOT_INFO_MEM_MAP;
|
||||
BootInfo->mmap_addr = (multiboot_uint32_t) &MBMMap;
|
||||
BootInfo->mmap_length = sizeof(MBMMap);
|
||||
#endif
|
||||
Log::Print(" BOOTING OPERATING SYSTEM... ");
|
||||
}
|
||||
|
||||
extern "C" void KernelInit(unsigned long magic, multiboot_info_t* bootinfo)
|
||||
{
|
||||
// Initialize system calls.
|
||||
Syscall::Init();
|
||||
|
||||
// Detect and initialize any serial COM ports in the system.
|
||||
COM::EarlyInit();
|
||||
|
||||
// Initialize the default terminal.
|
||||
Maxsi::Format::Callback logcallback;
|
||||
void* logpointer;
|
||||
|
||||
#if PLATFORM_SERIAL
|
||||
// Initialize the serial driver.
|
||||
UART::Init();
|
||||
|
||||
SerialTerminal::Init();
|
||||
logcallback = SerialTerminal::Print;
|
||||
logpointer = NULL;
|
||||
|
||||
#else
|
||||
VGATerminal::Init();
|
||||
logcallback = VGATerminal::Print;
|
||||
logpointer = NULL;
|
||||
|
||||
#endif
|
||||
Maxsi::Format::Callback logcallback = VGATerminal::Print;
|
||||
void* logpointer = NULL;
|
||||
|
||||
// Initialize the kernel log.
|
||||
Log::Init(logcallback, logpointer);
|
||||
|
@ -183,34 +109,29 @@ namespace Sortix
|
|||
// Display the boot welcome screen.
|
||||
DoWelcome();
|
||||
|
||||
if ( BootInfo == NULL ) { Panic("kernel.cpp: The bootinfo structure was NULL. Are your bootloader multiboot compliant?"); }
|
||||
|
||||
COM::EarlyInit();
|
||||
if ( !bootinfo )
|
||||
{
|
||||
Panic("The bootinfo structure was NULL. Are your bootloader "
|
||||
"multiboot compliant?");
|
||||
}
|
||||
|
||||
addr_t initrd = NULL;
|
||||
size_t initrdsize = 0;
|
||||
|
||||
#ifndef JSSORTIX
|
||||
uint32_t* modules = (uint32_t*) BootInfo->mods_addr;
|
||||
for ( uint32_t I = 0; I < BootInfo->mods_count; I++ )
|
||||
uint32_t* modules = (uint32_t*) bootinfo->mods_addr;
|
||||
for ( uint32_t i = 0; i < bootinfo->mods_count; i++ )
|
||||
{
|
||||
initrdsize = modules[2*I+1] - modules[2*I+0];
|
||||
initrd = (addr_t) modules[2*I+0];
|
||||
initrdsize = modules[2*i+1] - modules[2*i+0];
|
||||
initrd = (addr_t) modules[2*i+0];
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !initrd ) { PanicF("No init ramdisk provided"); }
|
||||
|
||||
#else
|
||||
// TODO: UGLY HACK because JSVM doesn't support multiboot yet!
|
||||
initrd = (addr_t) 0x180000UL;
|
||||
initrdsize = 0x280000; // 2 MiB 512 KiB
|
||||
#endif
|
||||
|
||||
Memory::RegisterInitRDSize(initrdsize);
|
||||
|
||||
// Initialize the paging and virtual memory.
|
||||
Memory::Init(BootInfo);
|
||||
// Initialize paging and virtual memory.
|
||||
Memory::Init(bootinfo);
|
||||
|
||||
// Initialize the GDT and TSS structures.
|
||||
GDT::Init();
|
||||
|
@ -269,10 +190,8 @@ namespace Sortix
|
|||
// Set up the initial ram disk.
|
||||
InitRD::Init(initrd, initrdsize);
|
||||
|
||||
#ifndef JSSORTIX
|
||||
// Search for PCI devices and load their drivers.
|
||||
PCI::Init();
|
||||
#endif
|
||||
|
||||
// Alright, now the system's drivers are loaded and initialized. It is
|
||||
// time to load the initial user-space programs and start execution of
|
||||
|
@ -322,5 +241,6 @@ namespace Sortix
|
|||
|
||||
// Run the OS.
|
||||
Scheduler::MainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Sortix
|
||||
|
|
Loading…
Reference in New Issue