Converted tabs to spaces
This commit is contained in:
parent
05941e6cda
commit
96d45988be
2 changed files with 48 additions and 44 deletions
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
*.cpp filter=spabs
|
||||||
|
*.c filter=spabs
|
||||||
|
*.h filter=spabs
|
||||||
|
*.S filter=spabs
|
|
@ -11,42 +11,42 @@
|
||||||
#include <pmm.hpp>
|
#include <pmm.hpp>
|
||||||
extern "C" void intr_stub_0(void);
|
extern "C" void intr_stub_0(void);
|
||||||
void main(void ** programs, MTGosHAL::Serial &debug, MTGosHAL::PMM &mm, MTGosHAL::Screen &out,
|
void main(void ** programs, MTGosHAL::Serial &debug, MTGosHAL::PMM &mm, MTGosHAL::Screen &out,
|
||||||
MTGosHAL::Screen &err, MTGosHAL::Keyboard &in, MTGosHAL::Multitasking &tasks, MTGosHAL::BlockDevice &disk);
|
MTGosHAL::Screen &err, MTGosHAL::Keyboard &in, MTGosHAL::Multitasking &tasks, MTGosHAL::BlockDevice &disk);
|
||||||
void** progs;
|
void** progs;
|
||||||
namespace MTGosHAL {
|
namespace MTGosHAL {
|
||||||
Serial debug;
|
Serial debug;
|
||||||
GDT gdt;
|
GDT gdt;
|
||||||
IDT idt;
|
IDT idt;
|
||||||
PMM mm;
|
PMM mm;
|
||||||
Screen out;
|
Screen out;
|
||||||
Screen err;
|
Screen err;
|
||||||
Keyboard in;
|
Keyboard in;
|
||||||
Multitasking tasks;
|
Multitasking tasks;
|
||||||
BlockDevice disk;
|
BlockDevice disk;
|
||||||
void main(int eax, struct multiboot_info* ebx) {
|
void main(int eax, struct multiboot_info* ebx) {
|
||||||
//Init debug output
|
//Init debug output
|
||||||
new (&debug) Serial();
|
new (&debug) Serial();
|
||||||
debug << "Hello debugger! This is MTGos v00r01\nThese logs are probably very long, so please redirect the output to a file.\n";
|
debug << "Hello debugger! This is MTGos v00r01\nThese logs are probably very long, so please redirect the output to a file.\n";
|
||||||
|
|
||||||
debug << "Init GDT\n";
|
debug << "Init GDT\n";
|
||||||
new (&gdt) GDT();
|
new (&gdt) GDT();
|
||||||
gdt.setEntry(0, 0, 0, 0);
|
gdt.setEntry(0, 0, 0, 0);
|
||||||
gdt.setEntry(1, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_CODESEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT);
|
gdt.setEntry(1, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_CODESEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT);
|
||||||
gdt.setEntry(2, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_DATASEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT);
|
gdt.setEntry(2, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_DATASEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT);
|
||||||
gdt.setEntry(3, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_CODESEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT | GDT_FLAG_RING3);
|
gdt.setEntry(3, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_CODESEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT | GDT_FLAG_RING3);
|
||||||
gdt.setEntry(4, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_DATASEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT | GDT_FLAG_RING3);
|
gdt.setEntry(4, 0, 0xfffff, GDT_FLAG_SEGMENT | GDT_FLAG_32_BIT | GDT_FLAG_DATASEG | GDT_FLAG_4K_GRAN | GDT_FLAG_PRESENT | GDT_FLAG_RING3);
|
||||||
gdt.setEntry(5, (uint32_t)tasks.tss, sizeof(tasks.tss), GDT_FLAG_RING3 | GDT_FLAG_TSS | GDT_FLAG_PRESENT);
|
gdt.setEntry(5, (uint32_t)tasks.tss, sizeof(tasks.tss), GDT_FLAG_RING3 | GDT_FLAG_TSS | GDT_FLAG_PRESENT);
|
||||||
gdt.setEntry(6, 0, 0xfffff, GDT_FLAG_RING3 | GDT_FLAG_TSS | GDT_FLAG_PRESENT);
|
gdt.setEntry(6, 0, 0xfffff, GDT_FLAG_RING3 | GDT_FLAG_TSS | GDT_FLAG_PRESENT);
|
||||||
gdt.apply();
|
gdt.apply();
|
||||||
|
|
||||||
debug << "Init IDT\n";
|
debug << "Init IDT\n";
|
||||||
new (&idt) IDT();
|
new (&idt) IDT();
|
||||||
for(int i=0;i<256;i++) {
|
for(int i=0;i<256;i++) {
|
||||||
idt.setEntry(i, (void *)((uint32_t)&intr_stub_0+i*16), SEG_KERNEL, IDT_INTERRUPT_GATE | IDT_SEG_32_BIT | IDT_RING_0 | IDT_USED);
|
idt.setEntry(i, (void *)((uint32_t)&intr_stub_0+i*16), SEG_KERNEL, IDT_INTERRUPT_GATE | IDT_SEG_32_BIT | IDT_RING_0 | IDT_USED);
|
||||||
}
|
}
|
||||||
idt.setEntry(48, (void *)((uint32_t)&intr_stub_0+768), SEG_KERNEL, IDT_TRAP_GATE | IDT_SEG_32_BIT | IDT_RING_3 | IDT_USED);
|
idt.setEntry(48, (void *)((uint32_t)&intr_stub_0+768), SEG_KERNEL, IDT_TRAP_GATE | IDT_SEG_32_BIT | IDT_RING_3 | IDT_USED);
|
||||||
idt.setEntry(8, (void *)((uint32_t)&intr_stub_0+128), SEG_DBL_FAULT, IDT_TASK_GATE | IDT_SEG_32_BIT | IDT_RING_0 | IDT_USED);
|
idt.setEntry(8, (void *)((uint32_t)&intr_stub_0+128), SEG_DBL_FAULT, IDT_TASK_GATE | IDT_SEG_32_BIT | IDT_RING_0 | IDT_USED);
|
||||||
idt.apply();
|
idt.apply();
|
||||||
asm volatile("ltr %%ax" : : "a"(5<<3));
|
asm volatile("ltr %%ax" : : "a"(5<<3));
|
||||||
debug << "Init MM\n";
|
debug << "Init MM\n";
|
||||||
new (&mm) PMM(ebx);
|
new (&mm) PMM(ebx);
|
||||||
|
@ -54,48 +54,48 @@ namespace MTGosHAL {
|
||||||
debug << "Init Screen output\n";
|
debug << "Init Screen output\n";
|
||||||
new (&out) Screen(ebx);
|
new (&out) Screen(ebx);
|
||||||
new (&err) Screen(ebx);
|
new (&err) Screen(ebx);
|
||||||
out << BG_color::BLACK << FG_color::WHITE << "Loading MTGos...\n";
|
out << BG_color::BLACK << FG_color::WHITE << "Loading MTGos...\n";
|
||||||
err << BG_color::BLACK << FG_color::RED;
|
err << BG_color::BLACK << FG_color::RED;
|
||||||
|
|
||||||
debug << "Init Keyboard\n";
|
debug << "Init Keyboard\n";
|
||||||
new (&in) Keyboard();
|
new (&in) Keyboard();
|
||||||
|
|
||||||
debug << "Init Multitasking\n";
|
debug << "Init Multitasking\n";
|
||||||
new (&tasks) Multitasking();
|
new (&tasks) Multitasking();
|
||||||
|
|
||||||
debug << "Init Disk\n";
|
debug << "Init Disk\n";
|
||||||
new (&disk) BlockDevice();
|
new (&disk) BlockDevice();
|
||||||
|
|
||||||
debug << "Kernel initialized\n";
|
debug << "Kernel initialized\n";
|
||||||
if(eax!=0x2BADB002)
|
if(eax!=0x2BADB002)
|
||||||
err << "System wasn't loaded by a Multiboot-conformant launcher!\n";
|
err << "System wasn't loaded by a Multiboot-conformant launcher!\n";
|
||||||
multiboot_mod_list *mods = (multiboot_mod_list*) ebx->mods_addr;
|
multiboot_mod_list *mods = (multiboot_mod_list*) ebx->mods_addr;
|
||||||
progs=(void**)mm.alloc(4096);
|
progs=(void**)mm.alloc(4096);
|
||||||
for(int i=0;i<1024;i++) {
|
for(int i=0;i<1024;i++) {
|
||||||
progs[i]=nullptr;
|
progs[i]=nullptr;
|
||||||
}
|
}
|
||||||
for(uint32_t i=0;i<(ebx->mods_count<1023?ebx->mods_count:1023);i++) { //Basically until MIN(ebx->mods_count, 1023), as we only support loading up to 1023 programs directly.
|
for(uint32_t i=0;i<(ebx->mods_count<1023?ebx->mods_count:1023);i++) { //Basically until MIN(ebx->mods_count, 1023), as we only support loading up to 1023 programs directly.
|
||||||
progs[i]=(void*)(mods[i].mod_start);
|
progs[i]=(void*)(mods[i].mod_start);
|
||||||
debug << "Found module!\n";
|
debug << "Found module!\n";
|
||||||
}
|
}
|
||||||
::main(progs, debug, mm, out, err, in, tasks, disk);
|
::main(progs, debug, mm, out, err, in, tasks, disk);
|
||||||
uint8_t buf[512];
|
uint8_t buf[512];
|
||||||
disk.readSector(disk.getDriveNumByName("ATA0m"),0,buf);
|
disk.readSector(disk.getDriveNumByName("ATA0m"),0,buf);
|
||||||
out << (char*)buf;
|
out << (char*)buf;
|
||||||
out << "こんにちは、ユニコード。\nЗдравствуй, Юникод.\nΓεια σου, Γιούνικοντ.\n안녕하세요, 유니코드.\n"_s;
|
out << "こんにちは、ユニコード。\nЗдравствуй, Юникод.\nΓεια σου, Γιούνικοντ.\n안녕하세요, 유니코드.\n"_s;
|
||||||
//sti();
|
//sti();
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typedef void (*constructor)();
|
typedef void (*constructor)();
|
||||||
typedef void (*destructor)();
|
typedef void (*destructor)();
|
||||||
extern "C" destructor start_dtors;
|
extern "C" destructor start_dtors;
|
||||||
extern "C" destructor end_dtors;
|
extern "C" destructor end_dtors;
|
||||||
extern "C" void init(int eax, struct multiboot_info* ebx) {
|
extern "C" void init(int eax, struct multiboot_info* ebx) {
|
||||||
MTGosHAL::main(eax, ebx);
|
MTGosHAL::main(eax, ebx);
|
||||||
for(destructor* i = &start_dtors; i != &end_dtors; i++)
|
for(destructor* i = &start_dtors; i != &end_dtors; i++)
|
||||||
(*i)();
|
(*i)();
|
||||||
}
|
}
|
||||||
extern "C" void __cxa_pure_virtual() {
|
extern "C" void __cxa_pure_virtual() {
|
||||||
MTGosHAL::debug << "A pure virtual function just got called.\n";
|
MTGosHAL::debug << "A pure virtual function just got called.\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue